diff --git a/inc/engine.h b/inc/engine.h index 6d12965..82d5316 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -673,6 +673,11 @@ public: static DETOUR_RETURN CR_STDCALL replacement (SharedLibrary::Handle module, const char *function) { return EntityLinkage::instance ().lookup (module, function); } + +public: + void clearExportTable () { + m_exports.clear (); + } }; // expose globals diff --git a/src/engine.cpp b/src/engine.cpp index f08c30a..38fd7e9 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -60,8 +60,29 @@ void Game::levelInitialize (edict_t *entities, int max) { // clear all breakables before initialization m_breakables.clear (); - // precache everything - precache (); + // initialize all config files + conf.loadConfigs (); + + // update worldmodel + illum.resetWorldModel (); + + // do level initialization stuff here... + graph.loadGraphData (); + + // execute main config + conf.loadMainConfig (); + + // load map-specific config + conf.loadMapSpecificConfig (); + + // initialize quota management + bots.initQuota (); + + // rebuild vistable if needed + graph.rebuildVisibility (); + + // install the sendto hook to fake queries + util.installSendTo (); // go thru the all entities on map, and do whatever we're want for (int i = 0; i < max; ++i) { @@ -75,12 +96,6 @@ void Game::levelInitialize (edict_t *entities, int max) { if (strcmp (classname, "worldspawn") == 0) { m_startEntity = ent; - - // initialize some structures - bots.initRound (); - - // install the sendto hook to fake queries - util.installSendTo (); } else if (strcmp (classname, "player_weaponstrip") == 0) { if (is (GameFlags::Legacy) && strings.isEmpty (ent->v.target.chars ())) { @@ -90,9 +105,7 @@ void Game::levelInitialize (edict_t *entities, int max) { engfuncs.pfnRemoveEntity (ent); } } - else if (strcmp (classname, "info_player_start") == 0) { - m_engineWrap.setModel (ent, "models/player/urban/urban.mdl"); - + else if (strcmp (classname, "info_player_start") == 0 || strcmp (classname, "info_vip_start") == 0) { ent->v.rendermode = kRenderTransAlpha; // set its render mode to transparency ent->v.renderamt = 127; // set its transparency amount ent->v.effects |= EF_NODRAW; @@ -100,21 +113,12 @@ void Game::levelInitialize (edict_t *entities, int max) { ++m_spawnCount[Team::CT]; } else if (strcmp (classname, "info_player_deathmatch") == 0) { - m_engineWrap.setModel (ent, "models/player/terror/terror.mdl"); - ent->v.rendermode = kRenderTransAlpha; // set its render mode to transparency ent->v.renderamt = 127; // set its transparency amount ent->v.effects |= EF_NODRAW; ++m_spawnCount[Team::Terrorist]; } - else if (strcmp (classname, "info_vip_start") == 0) { - m_engineWrap.setModel (ent, "models/player/vip/vip.mdl"); - - ent->v.rendermode = kRenderTransAlpha; // set its render mode to transparency - ent->v.renderamt = 127; // set its transparency amount - ent->v.effects |= EF_NODRAW; - } else if (strcmp (classname, "func_vip_safetyzone") == 0 || strcmp (classname, "info_vip_safetyzone") == 0) { m_mapFlags |= MapFlags::Assassination; // assassination map } diff --git a/src/linkage.cpp b/src/linkage.cpp index bc5be56..86dd269 100644 --- a/src/linkage.cpp +++ b/src/linkage.cpp @@ -138,6 +138,9 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { bot->spawned (); } + // precache everything + game.precache (); + if (game.is (GameFlags::Metamod)) { RETURN_META_VALUE (MRES_IGNORED, 0); } @@ -289,7 +292,7 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { dllapi.pfnClientCommand (ent); }; - table->pfnServerActivate = [] (edict_t *pentEdictList, int edictCount, int clientMax) { + table->pfnServerActivate = [] (edict_t *edictList, int edictCount, int clientMax) { // this function is called when the server has fully loaded and is about to manifest itself // on the network as such. Since a mapchange is actually a server shutdown followed by a // restart, this function is also called when a new map is being loaded. Hence it's the @@ -297,32 +300,13 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { // loading the bot profiles, and drawing the world map (ie, filling the navigation hashtable). // Once this function has been called, the server can be considered as "running". - conf.loadConfigs (); // initialize all config files - - // do a level initialization - game.levelInitialize (pentEdictList, edictCount); - - // update worldmodel - illum.resetWorldModel (); - - // do level initialization stuff here... - graph.loadGraphData (); - - // execute main config - conf.loadMainConfig (); - - // load map-specific config - conf.loadMapSpecificConfig (); - - // initialize quota management - bots.initQuota (); - if (game.is (GameFlags::Metamod)) { RETURN_META (MRES_IGNORED); } - dllapi.pfnServerActivate (pentEdictList, edictCount, clientMax); + dllapi.pfnServerActivate (edictList, edictCount, clientMax); - graph.rebuildVisibility (); + // do a level initialization + game.levelInitialize (edictList, edictCount); }; table->pfnServerDeactivate = [] () { @@ -364,6 +348,9 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { RETURN_META (MRES_IGNORED); } dllapi.pfnServerDeactivate (); + + // refill export table + ents.clearExportTable (); }; table->pfnStartFrame = [] () { @@ -486,7 +473,7 @@ CR_LINKAGE_C int GetEntityAPI_Post (gamefuncs_t *table, int) { RETURN_META (MRES_IGNORED); }; - table->pfnServerActivate = [] (edict_t *, int, int) { + table->pfnServerActivate = [] (edict_t *edictList, int edictCount, int) { // this function is called when the server has fully loaded and is about to manifest itself // on the network as such. Since a mapchange is actually a server shutdown followed by a // restart, this function is also called when a new map is being loaded. Hence it's the @@ -495,7 +482,8 @@ CR_LINKAGE_C int GetEntityAPI_Post (gamefuncs_t *table, int) { // Once this function has been called, the server can be considered as "running". Post version // called only by metamod. - graph.rebuildVisibility (); + // do a level initialization + game.levelInitialize (edictList, edictCount); RETURN_META (MRES_IGNORED); }; diff --git a/src/manager.cpp b/src/manager.cpp index 0736474..7bdd44d 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -54,6 +54,8 @@ BotManager::BotManager () { m_timeRoundEnd = 0.0f; m_autoKillCheckTime = 0.0f; + m_maintainTime = 0.0f; + m_quotaMaintainTime = 0.0f; m_bombPlanted = false; m_botsCanPause = false; @@ -470,8 +472,6 @@ void BotManager::maintainAutoKill () { } void BotManager::reset () { - m_maintainTime = 0.0f; - m_quotaMaintainTime = 0.0f; m_grenadeUpdateTime = 0.0f; m_entityUpdateTime = 0.0f; m_plantSearchUpdateTime = 0.0f;