CNetGame::CNetGame ( ) { fRestartWaitTime = 0.0f; this->allowAdminTeleport = FALSE; this->allowInteriorWeapons = FALSE; this->worldTime = 12; this->weather = 1; this->enableBonusStuntForAll = true; this->gravity = 0.008f; this->deathDropAmount = 0; this->enableZoneName = false; this->playerPool = NULL; this->vehiclePool = NULL; this->gamemodeManager = NULL; this->pickupPool = NULL; this->objectPool = NULL; this->menuPool = NULL; this->textDrawPool = NULL; this->disableNameTagLineOfSight = true; this->gangZonePool = NULL; this->text3DLabelsPool = NULL; this->bLanMode = FALSE; this->byteMod = 0x01; this->blimitGlobalChatRadius = false; this->dlimitGlobalChatRadius = 10000.0f; this->bLimitPlayerMarkerRadius = FALSE; this->dlimitPlayerMarkerRadius = 10000.0f; this->nameTagDrawDistance = 70.0f; this->disableInteriorEnterExit = false; this->currentGameModeIndex = 0; this->currentGameModeRepeat = 0; this->isFirstGameModeLoad = FALSE; this->scriptTimerManager = new CScriptTimers; this->scriptHttpManager = new CScriptHttp; #ifndef WIN32 this->elapsedTime = 0.0; #endif if(__Console->GetIntVar("maxplayers") > MAX_PLAYERS) __Console->SetIntVar("maxplayers", MAX_PLAYERS); char* szBindAddress = __Console->GetStringVar("bind"); if (szBindAddress && szBindAddress[0] == 0) szBindAddress = NULL; uint16_t Port = __Console->GetIntVar("port"); uint16_t MaxPlayers = __Console->GetIntVar("maxplayers"); BOOL useLanMode = __Console->GetBoolVar("lanmode"); this->rakServerInterface = RakNetworkFactory::GetRakServerInterface(); //NetGameStartTime = RakNet::GetTime(); if (!this->rakServerInterface->Start(MaxPlayers, 0, iServerSleepTimer, Port, szBindAddress)) { if (szBindAddress) logprintf("Unable to start server on %s:%d. Port in use?",szBindAddress, Port); else logprintf("Unable to start server on port: %d. Port in use?", Port); return; } LoadBanList(); if(!this->setNextGamemodeFile(NULL)) { logprintf("I couldn't load any gamemode scripts. Please verify your server.cfg"); logprintf("It needs a gamemode0 line at the very least."); fcloseall(); exit(1); } this->rakServerInterface->StartOccasionalPing(); char* szPass = __Console->GetStringVar("password"); if ((szPass) && (szPass[0] != 0)) { this->rakServerInterface->SetPassword(szPass); } RegisterRPCs(this->rakServerInterface); char szTime[256]; sprintf(szTime, "%02d:%02d", this->worldTime, 0); __Console->AddStringVar("worldtime", CONSOLE_VARFLAG_RULE, szTime); if(useLanMode) this->bLanMode = true; char szScriptFiles[512]; int len; #ifdef WIN32 GetCurrentDirectoryA(sizeof(szScriptFiles), szScriptFiles); len = strlen(szScriptFiles); if (szScriptFiles[len-1] != '\\') { szScriptFiles[len] = '\\'; szScriptFiles[len+1] = '\0'; } strcat(szScriptFiles, "scriptfiles\\"); SetEnvironmentVariableA("AMXFILE", szScriptFiles); #else getcwd(szScriptFiles, sizeof(szScriptFiles)); len = strlen(szScriptFiles); if (szScriptFiles[len-1] != '/') { szScriptFiles[len] = '/'; szScriptFiles[len+1] = '\0'; } strcat(szScriptFiles, "scriptfiles/"); setenv("AMXFILE", szScriptFiles, 1); #endif this->filterscriptsManager = new CFilterscriptsManager(); if (szBindAddress) { printf( "\nStarted server on %s:%d, with maxplayers: %d lanmode is %s.\n\n", szBindAddress, Port, MaxPlayers, useLanMode?"ON":"OFF" ); } else { printf( "\nStarted server on port: %d, with maxplayers: %d lanmode is %s.\n\n", Port, MaxPlayers, useLanMode?"ON":"OFF" ); } this->gameState = 0; }
CNetGame::CNetGame() { fRestartWaitTime = 0.0f; m_bAdminTeleport = false; m_bAllowWeapons = FALSE; m_byteWorldTime = 12; m_byteWeather = 10; m_bStuntBonus = true; m_fGravity = 0.008f; m_iDeathDropMoney = 0; m_bZoneNames = FALSE; m_longSynchedWeapons = DEFAULT_WEAPONS; // Change number here and in ShutdownForGameModeRestart for default weapon sets // Init member variables m_pPlayerPool = NULL; m_pVehiclePool = NULL; m_pGameMode = NULL; m_pPickupPool = NULL; m_pObjectPool = NULL; m_pMenuPool = NULL; m_pTextPool = NULL; m_pGangZonePool = NULL; m_bLanMode = FALSE; m_byteMod = 0x01; m_bACEnabled = pConsole->GetBoolVariable("anticheat"); m_bLimitGlobalChatRadius = FALSE; m_fGlobalChatRadius = 10000.0f; m_fNameTagDrawDistance = 70.0f; m_bDisableEnterExits = false; m_iCurrentGameModeIndex = 0; m_iCurrentGameModeRepeat = 0; m_bFirstGameModeLoaded = FALSE; m_pScriptTimers = new CScriptTimers; #ifndef WIN32 m_dElapsedTime = 0.0; #endif if(pConsole->GetIntVariable("maxplayers") > MAX_PLAYERS) { pConsole->SetIntVariable("maxplayers", MAX_PLAYERS); } CHAR *szBindAddress = pConsole->GetStringVariable("bind"); if (szBindAddress && szBindAddress[0] == 0) szBindAddress = NULL; DWORD dwPort = pConsole->GetIntVariable("port"); DWORD dwMaxPlayers = pConsole->GetIntVariable("maxplayers"); BOOL bLanMode = pConsole->GetBoolVariable("lanmode"); BOOL bMyriad = pConsole->GetBoolVariable("myriad"); // Setup RakNet m_pRak = RakNetworkFactory::GetRakServerInterface(); //m_pRak->InitializeSecurity(0, 0); //m_pRak->SetTrackFrequencyTable(true); if (!m_pRak->Start(dwMaxPlayers, 0, 10, dwPort, szBindAddress)) { if (szBindAddress) logprintf("Unable to start server on %s:%d. Port in use?", szBindAddress, dwPort); else logprintf("Unable to start server on port: %d. Port in use?", dwPort); return; } LoadBanList(); if(!SetNextScriptFile(NULL)) { logprintf("I couldn't load any gamemode scripts. Please verify your server.cfg"); logprintf("It needs a gamemode0 line at the very least."); fcloseall(); exit(1); } m_pRak->StartOccasionalPing(); //m_pRak->SetMTUSize(1492); char* szPass = pConsole->GetStringVariable("password"); if ((szPass) && (szPass[0] != 0)) { m_pRak->SetPassword(szPass); } // Register our RPC handlers RegisterRPCs(m_pRak); //if (IsACEnabled()) //CAntiCheat::Initialize(this); char szTime[256]; sprintf(szTime, "%02d:%02d", m_byteWorldTime, 0); pConsole->AddStringVariable("worldtime", CON_VARFLAG_RULE, szTime); if (bMyriad) { pConsole->SetStringVariable("mapname", "Myriad Islands"); m_byteMod = 0x02; } // Define LAN mode if(bLanMode) { m_bLanMode = TRUE; } char szScriptFiles[512]; int len; #ifdef WIN32 GetCurrentDirectory(sizeof(szScriptFiles), szScriptFiles); len = strlen(szScriptFiles); if (szScriptFiles[len-1] != '\\') { szScriptFiles[len] = '\\'; szScriptFiles[len+1] = '\0'; } strcat(szScriptFiles, "scriptfiles\\"); SetEnvironmentVariable("AMXFILE", szScriptFiles); #else getcwd(szScriptFiles, sizeof(szScriptFiles)); len = strlen(szScriptFiles); if (szScriptFiles[len-1] != '/') { szScriptFiles[len] = '/'; szScriptFiles[len+1] = '\0'; } strcat(szScriptFiles, "scriptfiles/"); setenv("AMXFILE", szScriptFiles, 1); #endif // Filterscripts are now entirely controlled from here, were all done from Gamemode before m_pFilterScripts = new CFilterScripts(); if (szBindAddress) { printf( " Started Server on %s:%d, with maxplayers: %d lanmode is %s.\n", szBindAddress, dwPort, dwMaxPlayers, bLanMode?"ON":"OFF" ); } else { printf( " Started Server on port: %d, with maxplayers: %d lanmode is %s.\n", dwPort, dwMaxPlayers, bLanMode?"ON":"OFF" ); } m_iGameState = GAMESTATE_STOPPED; }