// *************************************************************** // Function: InitNetworkServers.cpp // *************************************************************** #include "Main.h" int ConfigureICServer(); int ConfigureServer(); //************************************ // Name: InitNetworkServers // // Initializes the configures the network servers for both LS and ICS // // Parameters: // // Return: // 0 - No errors // -1 - Errors //************************************ int InitNetworkServers() { //create the internal communication server gCoreLog.WriteCategory("[Initializing]"); gCoreLog.Section("Internal Communications Server...");; if (gpInternalComm!=NULL) delete gpInternalComm; gpInternalComm=new Server; assert(gpInternalComm!=NULL); unsigned char* pIp=0; if (!gServerConfig.automaticIp) pIp=gServerConfig.ip; if (gpInternalComm->Init(gServerConfig.icPort, "ICS", pIp, false, &gCoreLog)==-1) { gCoreLog.SectionFail(); return -1; } gCoreLog.SectionOk(); ConfigureICServer(); //Create the login server gCoreLog.Section("Login Server..."); //make a new network server if (gpLoginServer!=NULL) delete gpLoginServer; gpLoginServer=new Server; assert(gpLoginServer!=NULL); pIp=0; if (!gServerConfig.automaticIp) pIp=gServerConfig.ip; if (gpLoginServer->Init(gServerConfig.port, "LS", pIp, false, &gCoreLog)==-1) { gCoreLog.SectionFail(); return -1; } //Update server config if (ConfigureServer()==-1) { gCoreLog.LOCATION; gCoreLog.error("Could not configure the server!"); return -2; } gCoreLog.SectionOk(); return 0; } //************************************ // Name: ConfigureServer // // Configures the login network server. // // Parameters: // // Return: // 0 - ok //************************************ int ConfigureServer() { //Update Server Configuration SERVERCONFIG servConfig; servConfig.notifyOnConnect=true; servConfig.maxConnections=gServerConfig.maxPlayers; gpLoginServer->UpdateServerConfig(servConfig); gpLoginServer->Crypto=Crypto; return 0; } //************************************ // Name: ConfigureICServer // // Configures the IC network server // // Parameters: // // Return: // 0 - ok //************************************ int ConfigureICServer() { //Update Server Configuration //load from config file later on SERVERCONFIG servConfig; if (gServerConfig.maxGameServers<1){gServerConfig.maxGameServers=1;} else if (gServerConfig.maxGameServers>245){gServerConfig.maxGameServers=245;} servConfig.maxConnections=gServerConfig.maxGameServers; servConfig.notifyOnConnect=true; gpInternalComm->UpdateServerConfig(servConfig); gpInternalComm->Crypto=Crypto; return 0; }