diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index ae8b379..4f52bd1 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -151,6 +151,25 @@ void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server ) PM_Move( ppmove, server ); } +void SaveEngineVersion() +{ + cvar_t *sv_version = gEngfuncs.pfnGetCvarPointer("sv_version"); + if (sv_version) + { + strncpy(gHUD.m_szEngineVersion, sv_version->string, sizeof(gHUD.m_szEngineVersion) - 1); + + // Parse build number + std::string version = gHUD.m_szEngineVersion; + size_t lastComma = version.rfind(','); + + if (lastComma != std::string::npos) + { + const char *buildStr = gHUD.m_szEngineVersion + lastComma + 1; + gHUD.m_iEngineBuildNumber = atoi(buildStr); + } + } +} + int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) { gEngfuncs = *pEnginefuncs; @@ -162,6 +181,8 @@ int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t)); + SaveEngineVersion(); + update_checker::check_for_updates(); discord_integration::initialize(); diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index f558de6..40b1611 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -29,6 +29,16 @@ #include // " #include // for strncpy() +#ifdef _WIN32 +#define BUILD_OFFSET_LINUX 0 +#else +#define BUILD_OFFSET_LINUX 1 +#endif + +constexpr int ENGINE_BUILD_ANNIVERSARY_FIRST = 9884 + BUILD_OFFSET_LINUX; + +#undef BUILD_OFFSET_LINUX + // Macros to hook function calls into the HUD object #define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x ); diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 1964a12..0857878 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -787,6 +787,9 @@ class CHud bool IsTriggerForSinglePlayer(color24 rendercolor); HSPRITE white_sprite = 0; + + char m_szEngineVersion[256]; + int m_iEngineBuildNumber = -1; }; extern CHud gHUD;