Beispiel #1
0
        static void Main(string[] args)
        {
            Log.Info("LobbyServer", "Starting...");
            if (!EasyServer.InitLog("Lobby", "Configs/LobbyLog.conf") || !EasyServer.InitConfig("Configs/Lobby.xml", "Lobby")) return;
            if (!EasyServer.Listen<TcpServer>(EasyServer.GetConfValue<int>("Lobby", "ClientServer", "Port"), "ClientServer")) return;
            worldListener = new World.Listener(EasyServer.GetConfValue<String>("Lobby", "Worlds", "Ip"), EasyServer.GetConfValue<int>("Lobby", "Worlds", "Port"));
            Connection.connectionString = EasyServer.GetConfValue<String>("Lobby", "Database", "ConnectionString");
            MySqlConnection myconnection = new MySqlConnection(Connection.connectionString);
            MySqlCommand cmd = myconnection.CreateCommand();
            MySqlCommand acccmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `accounts`(`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, `email` varchar(50) NOT NULL DEFAULT '', `username` varchar(32) NOT NULL DEFAULT '', `verifier` varchar(128) DEFAULT '', `salt` varchar(20) DEFAULT '', `points` int(11) unsigned, `admin` int(1) unsigned zerofill NOT NULL DEFAULT '0', `banned` tinyint(1) NOT NULL DEFAULT '0', `extrn_login` tinyint(1) NOT NULL DEFAULT '0', `token` varchar(8), `canhost` tinyint(1) NOT NULL DEFAULT '0', UNIQUE KEY `id` (`id`), UNIQUE KEY `username` (`username`), UNIQUE KEY `email` (`email`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;", myconnection);
            MySqlCommand charcmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `characters`(`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, `account` int(10) unsigned zerofill NOT NULL, `slot` tinyint(3) unsigned zerofill NOT NULL DEFAULT '001', `name` varchar(32) NOT NULL, `faction` tinyint(1) NOT NULL, `gender` tinyint(1) NOT NULL, `rank` int(3) unsigned, `money` int(11) unsigned, `threat` tinyint(2), `playtime` int(11) unsigned, `clan` varchar(60) NOT NULL DEFAULT 'APB-EMU', `version` int(11) unsigned NOT NULL, `appearence` text NOT NULL, `custom` text NOT NULL, `world` int(10) unsigned zerofill NOT NULL, PRIMARY KEY (`id`,`account`), UNIQUE KEY `characterId` (`id`), UNIQUE KEY `slot` (`account`,`slot`), UNIQUE KEY `characterName` (`name`)) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;", myconnection);
            MySqlCommand statcmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `clientstatus`(`name` varchar(32) NOT NULL, `districtID` tinyint(1), `districtType` tinyint(1), `online` tinyint(1), `lfg` tinyint(1), `grpstatus` tinyint(1) , `grppub` tinyint(1), `grpinv` tinyint(1), UNIQUE KEY `name` (`name`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;", myconnection);
            try
            {
                myconnection.Open();
                acccmd.ExecuteNonQuery();
                charcmd.ExecuteNonQuery();
                statcmd.ExecuteNonQuery();
                myconnection.Close();
                Log.Succes("MySql", "Database connected!");
            }
            catch (MySqlException e) { Log.Error("MySql Error", e.ToString()); }

            FileMgr = new FileManager();
            string[] sVersion = EasyServer.GetConfValue<string>("Lobby", "ClientServer", "Version").Split('.');
            Build = EasyServer.GetConfValue<int>("Lobby", "ClientServer", "Build");
            Version = new byte[sVersion.Length];
            for (int i = 0; i < Version.Length; ++i) Version[i] = byte.Parse(sVersion[i]);
            Log.Info("LobbyServer", "Version = " + Version[0] + "." + Version[1] + "." + Version[2] + " : Build = " + Build);
            Log.Succes("LobbyServer", "Server initialisation complete!");
            clients.Clear();
            worlds.Clear();
            Log.Enter();
            Console.WriteLine("For available console commands, type /commands");
            Log.Enter();
            bool done = false;
            while (!done)
            {
                string command;
                command = Console.ReadLine();
                ProccessCommand(command);
            }
            EasyServer.StartConsole();
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     Log.Info("LobbyServer", "Starting...");
     if (!EasyServer.InitLog("Lobby", "Configs/Logs.conf") || !EasyServer.InitConfig("Configs/Lobby.xml", "Lobby") || !EasyServer.InitConfig("Configs/Database.xml", "Database")) return;
     if (!EasyServer.Listen<TcpServer>(EasyServer.GetConfValue<int>("Lobby", "LoginServer", "Port"), "LoginServer")) return;
     worldListener = new World.Listener(EasyServer.GetConfValue<String>("Lobby", "WorldListener", "IP"), EasyServer.GetConfValue<int>("Lobby", "WorldListener", "Port"));
     Databases.InitDB();
     Databases.Load(true);
     FileMgr = new FileManager();
     string sVersion = EasyServer.GetConfValue<string>("Lobby", "LoginServer", "GameVersion");
     if(sVersion != "RTW_CB" && sVersion != "RTW_DVD" && sVersion != "RTW_LAST")
     {
         Log.Error("ERROR", "Invalid game version!");
         return;
     }
     else
     {
         if (sVersion == "RTW_CB")
         {
             version = GameVersion.RTW_CB;
             Log.Info("Version", "Supported game version: 0.6.0.509927 (RTW closed beta)");
         }
         else if (sVersion == "RTW_DVD")
         {
             version = GameVersion.RTW_DVD;
             Log.Info("Version", "Supported game version: 1.1.0.534979 (RTW DVD release)");
         }
         else if (sVersion == "RTW_LAST")
         {
             version = GameVersion.RTW_LAST;
             Log.Info("Version", "Supported game version: 1.4.1.555239 (last RTW patch)");
         }
         else if (sVersion == "G1_LATEST")
         {
             version = GameVersion.G1_LATEST;
             Log.Info("Version", "Supported game version: 1.19.4.766569 (latest G1 patch)");
         }
         else if (sVersion == "G1_ENGUPD")
         {
             version = GameVersion.G1_ENGUPD;
             Log.Info("Version", "Supported game version: 2.0.0.750394 (G1 engine update)");
         }
         else version = GameVersion.INVALID;
     }
     Log.Succes("LobbyServer", "Server initialisation complete!");
     clients.Clear();
     worlds.Clear();
     Timer aTimer = new Timer(10000);
     aTimer.Elapsed += OnTimedEvent;
     aTimer.AutoReset = true;
     aTimer.Enabled = true;
     Log.Enter();
     Console.WriteLine("For available console commands, type /commands");
     Log.Enter();
     bool done = false;
     while (!done)
     {
         string command;
         command = Console.ReadLine();
         ProccessCommand(command);
     }
     EasyServer.StartConsole();
 }