Skip to content

Commit

Permalink
fix(five/sync): make sure all clients have the same game build
Browse files Browse the repository at this point in the history
Follow up fix for
3850efd

That change was made under the assumption that
sv_replaceExeToSwitchBuilds is always sent by the server. However the
older server builds don't do that. So we revert the part of commit which
changed default sv_replaceExeToSwitchBuilds on client side.

After this fix sv_replaceExeToSwitchBuilds will still be set to false by
default on the latest server builds.

If client side default value will be changed in the future - we should
push it to all channels at the same time.
  • Loading branch information
Nobelium-cfx authored and prikolium-cfx committed Feb 14, 2025
1 parent 2974200 commit c1cff3d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/client/shared/XBRInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool GetReplaceExecutableInit()
std::wstring fpath = MakeRelativeCitPath(L"CitizenFX.ini");
if (GetFileAttributes(fpath.c_str()) != INVALID_FILE_ATTRIBUTES)
{
replaceExecutable = (GetPrivateProfileInt(L"Game", L"ReplaceExecutable", 0, fpath.c_str()) != 0);
replaceExecutable = (GetPrivateProfileInt(L"Game", L"ReplaceExecutable", 1, fpath.c_str()) != 0);
}

return replaceExecutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static InitFunction initFunction([]()
g_enforcedGameBuild = xbr::GetDefaultGTA5BuildString();
auto enforceGameBuildVar = instance->AddVariable<fx::GameBuild>("sv_enforceGameBuild", ConVar_ReadOnly | ConVar_ServerInfo, xbr::GetDefaultGTA5BuildString(), &g_enforcedGameBuild);

g_replaceExecutable = true;
g_replaceExecutable = false;
auto replaceExecutableVar = instance->AddVariable<bool>("sv_replaceExeToSwitchBuilds", ConVar_ReadOnly | ConVar_ServerInfo, false, &g_replaceExecutable);

auto poolSizesIncrease = std::make_shared<std::unordered_map<std::string, uint32_t>>();
Expand Down
4 changes: 2 additions & 2 deletions code/components/net/src/NetLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ concurrency::task<void> NetLibrary::ConnectToServer(const std::string& rootUrl)
int buildRef = 0;

// Special build 1 with all DLCs turned off can not be achieved by replacing the executable. There is no executable for that build.
bool replaceExecutable = info["vars"].value("sv_replaceExeToSwitchBuilds", "false") != std::string("false") && val != std::string("1");
bool replaceExecutable = info["vars"].value("sv_replaceExeToSwitchBuilds", "true") != std::string("false") && val != std::string("1");

if (!val.empty())
{
Expand Down Expand Up @@ -1912,7 +1912,7 @@ concurrency::task<void> NetLibrary::ConnectToServer(const std::string& rootUrl)
#if defined(GTA_FIVE)
if (buildRef == 0 && xbr::GetRequestedGameBuild() != xbr::GetDefaultGameBuild())
{
OnRequestBuildSwitch(xbr::GetDefaultGameBuild(), 0, L"", false);
OnRequestBuildSwitch(xbr::GetDefaultGameBuild(), 0, L"", replaceExecutable);
m_connectionState = CS_IDLE;
return;
}
Expand Down

0 comments on commit c1cff3d

Please sign in to comment.