diff --git a/core/logic/GameConfigs.cpp b/core/logic/GameConfigs.cpp index cf4742cf..2d0d394a 100644 --- a/core/logic/GameConfigs.cpp +++ b/core/logic/GameConfigs.cpp @@ -153,6 +153,23 @@ static inline bool IsPlatformCompatible(const char *platform, bool *hadPrimaryMa return false; } +static inline time_t GetFileModTime(const char *path) +{ + char filepath[PLATFORM_MAX_PATH]; + g_pSM->BuildPath(Path_SM, filepath, sizeof(filepath), "gamedata/%s.txt", path); +#ifdef PLATFORM_WINDOWS + struct _stat64 s; + if (_stat64(filepath, &s) != 0) +#elif defined PLATFORM_POSIX + struct stat s; + if (stat(filepath, &s) != 0) +#endif + { + return 0; + } + return s.st_mtime; +} + CGameConfig::CGameConfig(const char *file, const char *engine) { strncopy(m_File, file, sizeof(m_File)); @@ -160,6 +177,8 @@ CGameConfig::CGameConfig(const char *file, const char *engine) m_CustomLevel = 0; m_CustomHandler = NULL; + m_ModTime = GetFileModTime(file); + if (!engine) m_pEngine = bridge->GetSourceEngineName(); else @@ -1132,9 +1151,17 @@ bool GameConfigManager::LoadGameConfigFile(const char *file, IGameConfig **_pCon if (m_Lookup.retrieve(file, &pConfig)) { + bool ret = true; + time_t modtime = GetFileModTime(file); + if (pConfig->m_ModTime != modtime) + { + pConfig->m_ModTime = modtime; + ret = pConfig->Reparse(error, maxlength); + } + pConfig->AddRef(); *_pConfig = pConfig; - return true; + return ret; } pConfig = new CGameConfig(file); diff --git a/core/logic/GameConfigs.h b/core/logic/GameConfigs.h index dc96eeeb..e3d523d8 100644 --- a/core/logic/GameConfigs.h +++ b/core/logic/GameConfigs.h @@ -123,6 +123,7 @@ private: StringHashMap m_Addresses; const char *m_pEngine; const char *m_pBaseEngine; + time_t m_ModTime; }; class GameConfigManager :