// *************************************************************** // Function: InitGameServer.cpp // *************************************************************** #include "Main.h" int ConfigureICClient(); int ConfigureServer(); //************************************ // Name: InitNetworkServers // // Initializes the GS and ICS network server/client. // // Parameters: // // Return: // 0 - ok // -1 - Unable to perform network actions // -2 - Unable to configure server //************************************ int InitNetworkServers() { //make a new internal communications server gCoreLog.WriteCategory("[Initializing]"); gCoreLog.Section("Internal Communications Client..."); 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, "Internal Communications Client", pIp, true, &gCoreLog)==-1) { gCoreLog.SectionFail(); gCoreLog.error("Could not initialize the IC client!"); return -1; } gCoreLog.SectionOk(); ConfigureICClient(); gCoreLog.notice("Success: Client configured."); gCoreLog.notice("Success: Internal Communications Client initialized."); if (gpInternalComm->Connect(gServerConfig.loginServIp)!=0) { return -1; } //make a new network server gCoreLog.WriteCategory("[Initializing]"); gCoreLog.Section("Game Server..."); if (gpGameServer!=NULL) delete gpGameServer; gpGameServer=new Server; assert(gpGameServer!=NULL); pIp=0; if (!gServerConfig.automaticIp) pIp=gServerConfig.ip; if (gpGameServer->Init(gServerConfig.port, "Game Server", pIp, false, &gCoreLog)==-1) { gCoreLog.SectionFail(); gCoreLog.error("Could not initialize the server!"); return -1; } gCoreLog.SectionOk(); //Update server config if (ConfigureServer()==-1) { gCoreLog.error("Could not configure the server!"); return -2; } gCoreLog.notice("Success: Server configured."); gCoreLog.notice("Success: Game server initialized."); return 0; } //************************************ // Name: ConfigureServer // // Configures the GS // // Parameters: // // Return: // - zero //************************************ int ConfigureServer() { //Update Server Configuration SERVERCONFIG server_config; server_config.maxConnections=10; server_config.notifyOnConnect=true; gpGameServer->UpdateServerConfig(server_config); gpGameServer->Crypto=Crypto; return 0; } //************************************ // Name: ConfigureICClient // // Configures the IC client // // Parameters: // // Return: // - zero //************************************ int ConfigureICClient() { //Update Server Configuration SERVERCONFIG server_config; server_config.maxConnections=10; gpInternalComm->UpdateServerConfig(server_config); gpInternalComm->Crypto=Crypto; return 0; }