Merge pull request #311 from fedddddd/lui-scripting-fix

Fix potential LUI scripting crash
This commit is contained in:
Maurice Heumann 2022-02-21 20:36:19 +01:00 committed by GitHub
commit c97beb3867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,7 @@
function luiglobals.GetPartyMaxPlayers()
return Engine.GetDvarInt("sv_maxclients")
end
LUI.mp_hud.Scoreboard.maxPlayersOnTeam = luiglobals.GetTeamLimitForMaxPlayers(luiglobals.GetPartyMaxPlayers())
if (LUI.mp_hud.Scoreboard) then
function luiglobals.GetPartyMaxPlayers()
return Engine.GetDvarInt("sv_maxclients")
end
LUI.mp_hud.Scoreboard.maxPlayersOnTeam = luiglobals.GetTeamLimitForMaxPlayers(luiglobals.GetPartyMaxPlayers())
end

View File

@ -135,7 +135,13 @@ namespace ui_scripting
return;
}
scheduler::loop(ui_scripting::lua::engine::run_frame, scheduler::pipeline::renderer);
scheduler::loop([]()
{
if (game::Sys_IsMainThread())
{
ui_scripting::lua::engine::run_frame();
}
}, scheduler::pipeline::renderer);
hks_start_hook.create(0x1400E4E40, hks_start_stub);
hks_shutdown_hook.create(0x1400DB9A0, hks_shutdown_stub);

View File

@ -220,6 +220,7 @@ namespace game
WEAK symbol<bool(int, void const*, const netadr_s*)> Sys_SendPacket{0x14038E720, 0x1404D8460};
WEAK symbol<void(Sys_Folder, const char* path)> Sys_SetFolder{0x14037BDD0, 0x1404CCA10};
WEAK symbol<void()> Sys_ShowConsole{0x14038FA90, 0x1404D98B0};
WEAK symbol<bool()> Sys_IsMainThread{0x1402FF9C0, 0x1403E1880};
WEAK symbol<const char*(const char*)> UI_GetMapDisplayName{0, 0x1403B1CD0};
WEAK symbol<const char*(const char*)> UI_GetGameTypeDisplayName{0, 0x1403B1670};