From 71d6444c41141e7f0eb3b20e303e10455ee12d3f Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 2 Jan 2017 23:11:31 +0700 Subject: [PATCH] Fix: to get current mapname on first spawn --- reapi/src/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/reapi/src/main.cpp b/reapi/src/main.cpp index f329805..751e295 100644 --- a/reapi/src/main.cpp +++ b/reapi/src/main.cpp @@ -69,7 +69,12 @@ void ServerDeactivate_Post() void KeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) { // get the first edict worldspawn - if (FClassnameIs(pentKeyvalue, "worldspawn")) { + if (FClassnameIs(pentKeyvalue, "worldspawn")) + { + // save true mapname + strncpy(g_szMapName, STRING(gpGlobals->mapname), sizeof(g_szMapName) - 1); + g_szMapName[sizeof(g_szMapName) - 1] = '\0'; + g_pEdicts = pentKeyvalue; g_pFunctionTable->pfnKeyValue = nullptr; } @@ -84,10 +89,6 @@ CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain) int DispatchSpawn(edict_t *pEntity) { - // save true mapname - strncpy(g_szMapName, STRING(gpGlobals->mapname), sizeof(g_szMapName) - 1); - g_szMapName[sizeof(g_szMapName) - 1] = '\0'; - g_pEdicts = g_engfuncs.pfnPEntityOfEntIndex(0); if (api_cfg.hasReGameDLL()) { g_pMove = g_ReGameApi->GetPlayerMove();