Skip to content

Commit

Permalink
Client: Check for old builds
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Nov 25, 2023
1 parent c7d81ae commit ba74083
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/game/client/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "results.h"
#include "opengl.h"
#include "engfuncs.h"
#include "engine_builds.h"

CHud gHUD;

Expand Down Expand Up @@ -107,6 +108,33 @@ void CheckWorkingDirectory()
#endif
}

//! Checks that the game is not running on an unsupported game build.
//! @returns Whether the build is supported.
static bool CheckForInvalidBuilds(int buildNumber)
{
constexpr char TITLE[] = "BugfixedHL - Unsupported game";

if (buildNumber < ENGINE_BUILD_P48)
{
GetSDL()->ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR, TITLE,
"Your game is too old. Please, update to the latest Steam version.");
return false;
}

if (buildNumber >= ENGINE_BUILD_ANNIVERSARY_FIRST && buildNumber < ENGINE_BUILD_ANNIVERSARY_FIXED_INTERFACES)
{
GetSDL()->ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR, TITLE,
"You are playing one of the first Half-Life 25th Anniversary Update builds.\n"
"This build broke compatibility with most mods and is not supported.\n"
"Please, update to the latest Steam version.");
return false;
}

return true;
}

/*
================================
HUD_GetHullBounds
Expand Down Expand Up @@ -214,6 +242,9 @@ int CL_DLLEXPORT Initialize(cl_enginefunc_t *pEnginefuncs, int iVersion)
// Save engine version before everything els
// (in case the game crashes there, crash handler will know the engine version)
gHUD.SaveEngineVersion();

if (!CheckForInvalidBuilds(gHUD.GetEngineBuild()))
return 0;

console::Initialize();
CvarSystem::RegisterCvars();
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/engine_builds.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#define LINUX_OFFSET 0
#endif

//! Protocol 48 builds.
constexpr int ENGINE_BUILD_P48 = 4000;

//! Probably the last version before SteamPipe.
constexpr int ENGINE_BUILD_PRE_STEAMPIPE = 4617;

Expand Down

0 comments on commit ba74083

Please sign in to comment.