fix crash

This commit is contained in:
quaK 2024-08-13 16:29:28 +03:00
parent 984e5478d2
commit 70b3d380d3
2 changed files with 12 additions and 8 deletions

View File

@ -296,12 +296,12 @@ namespace party
bool preloaded_map = false;
void xstartlobby(const int max_clients, const bool private_match)
void xstartlobby()
{
// Retrieve game variables
const int privateMatch = private_match; //game::Dvar_FindVar("xblive_privatematch")->current.integer;
const int maxPlayers = max_clients; //game::Dvar_FindVar("party_maxplayers")->current.integer;
const int privateClients = 0; //game::Dvar_FindVar("ui_privateClients")->current.integer;
const int privateMatch = game::Dvar_FindVar("xblive_privatematch")->current.integer;
const int maxPlayers = game::Dvar_FindVar("party_maxplayers")->current.integer;
const int privateClients = game::Dvar_FindVar("ui_privateClients")->current.integer;
const int availableSpots = maxPlayers - privateClients;
// Get party data
@ -331,13 +331,16 @@ namespace party
void perform_game_initialization(const int max_clients, const bool private_match)
{
xstartlobby(max_clients, private_match);
const auto ui_maxclients = game::Dvar_FindVar("ui_maxclients");
const auto party_maxplayers = game::Dvar_FindVar("party_maxplayers");
game::Dvar_SetInt(ui_maxclients, max_clients);
game::Dvar_SetInt(party_maxplayers, max_clients);
const auto xblive_privatematch = game::Dvar_FindVar("xblive_privatematch");
game::Dvar_SetBool(xblive_privatematch, private_match);
xstartlobby();
command::execute("uploadstats", true);
}
@ -550,7 +553,7 @@ namespace party
command::execute(utils::string::va("seta ui_mapname %s", mapname.data()), true);
auto* gametype = game::Dvar_FindVar("g_gametype");
if (gametype && gametype->current.string)
if (gametype && gametype->current.string && gametype->current.string != "frontend"s)
{
command::execute(utils::string::va("seta ui_gametype %s", gametype->current.string), true);
}
@ -561,7 +564,7 @@ namespace party
command::execute(utils::string::va("seta ui_hardcore %d", hardcore->current.enabled), true);
}
if (!utils::hook::invoke<bool>(0x1409CDCF0) || game::Com_FrontEnd_IsInFrontEnd())
if (!utils::hook::invoke<bool>(0x1409CDCF0, game::Lobby_GetPartyData()) || game::Com_FrontEnd_IsInFrontEnd())
{
if (game::environment::is_dedi())
{

View File

@ -125,6 +125,7 @@ namespace game
WEAK symbol<const char* (dvar_t* dvar, DvarValue value)> Dvar_ValueToString{ 0x140CEED00 };
WEAK symbol<void(dvar_t* dvar, DvarSetSource source)> Dvar_Reset{ 0x140CEC490 };
WEAK symbol<unsigned int(const char* name)> Dvar_GenerateChecksum{ 0x140CEA520 };
WEAK symbol<void(dvar_t* dvar, bool value)> Dvar_SetBool{ 0x140CEC7D0 };
WEAK symbol<void(dvar_t* dvar, int value)> Dvar_SetInt{ 0x140CED3D0 };
WEAK symbol<void(dvar_t* dvar, float value)> Dvar_SetFloat{ 0x140CECD90 };
WEAK symbol<void(bool cheatOverride)> Dvar_OverrideCheatProtection{ 0x140CEB250 };