diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index cd507f14..ba7af6bb 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -524,7 +524,7 @@ namespace Components { for (auto& asset : AssetHandler::EmptyAssets) { - Game::Sys_Error(25, reinterpret_cast(0x724428), Game::DB_GetXAssetTypeName(asset.first), asset.second.data()); + Game::Com_PrintWarning(25, reinterpret_cast(0x724428), Game::DB_GetXAssetTypeName(asset.first), asset.second.data()); } AssetHandler::EmptyAssets.clear(); diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 9c4509c0..8e59d30d 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -177,7 +177,7 @@ namespace Components const auto* gentity = Script::GetEntFromEntRef(id); const auto* client = Script::GetClientFromEnt(gentity); - Game::Scr_AddInt(client->isBot); + Game::Scr_AddBool(client->isBot == 1); }); Script::AddFunction("BotStop", [](Game::scr_entref_t id) // Usage: BotStop(); diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp index e44f589e..4bf0bb87 100644 --- a/src/Components/Modules/Script.cpp +++ b/src/Components/Modules/Script.cpp @@ -654,7 +654,7 @@ namespace Components return; } - Game::Scr_AddInt((ent->client->flags & Game::PLAYER_FLAG_FROZEN) != 0); + Game::Scr_AddBool((ent->client->flags & Game::PLAYER_FLAG_FROZEN) != 0); }); Script::AddFunction("DebugCode", [](Game::scr_entref_t) // gsc: DebugCode() diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 1407ab05..e2337aaa 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -72,6 +72,7 @@ namespace Game Com_MatchToken_t Com_MatchToken = Com_MatchToken_t(0x447130); Com_SetSlowMotion_t Com_SetSlowMotion = Com_SetSlowMotion_t(0x446E20); Com_Quitf_t Com_Quit_f = Com_Quitf_t(0x4D4000); + Com_PrintWarning_t Com_PrintWarning = Com_PrintWarning_t(0x4E0200); Con_DrawMiniConsole_t Con_DrawMiniConsole = Con_DrawMiniConsole_t(0x464F30); Con_DrawSolidConsole_t Con_DrawSolidConsole = Con_DrawSolidConsole_t(0x5A5040); @@ -325,7 +326,6 @@ namespace Game SV_Loaded_t SV_Loaded = SV_Loaded_t(0x4EE3E0); SV_ClientThink_t SV_ClientThink = SV_ClientThink_t(0x44ADD0); - Sys_Error_t Sys_Error = Sys_Error_t(0x4E0200); Sys_FreeFileList_t Sys_FreeFileList = Sys_FreeFileList_t(0x4D8580); Sys_IsDatabaseReady_t Sys_IsDatabaseReady = Sys_IsDatabaseReady_t(0x4CA4A0); Sys_IsDatabaseReady2_t Sys_IsDatabaseReady2 = Sys_IsDatabaseReady2_t(0x441280); @@ -338,6 +338,7 @@ namespace Game Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads = Sys_SuspendOtherThreads_t(0x45A190); Sys_ListFiles_t Sys_ListFiles = Sys_ListFiles_t(0x45A660); Sys_Milliseconds_t Sys_Milliseconds = Sys_Milliseconds_t(0x42A660); + Sys_Error_t Sys_Error = Sys_Error_t(0x43D570); TeleportPlayer_t TeleportPlayer = TeleportPlayer_t(0x496850); @@ -1018,6 +1019,28 @@ namespace Game return GraphGetValueFromFraction(graph->knotCount, graph->knots, fraction) * graph->scale; } + void IncInParam() + { + Scr_ClearOutParams(); + + if (scrVmPub->top == scrVmPub->maxStack) + { + Sys_Error("Internal script stack overflow"); + } + + scrVmPub->top++; + scrVmPub->inparamcount++; + } + + void Scr_AddBool(int value) + { + assert(value == 0 || value == 1); + + IncInParam(); + scrVmPub->top->type = VAR_INTEGER; + scrVmPub->top->u.intValue = value; + } + #pragma optimize("", off) __declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/) { diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 4d5228e1..02096537 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -151,6 +151,9 @@ namespace Game typedef void(__cdecl * Com_Quitf_t)(); extern Com_Quitf_t Com_Quit_f; + typedef void(__cdecl * Com_PrintWarning_t)(int, const char*, ...); + extern Com_PrintWarning_t Com_PrintWarning; + typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); extern Con_DrawMiniConsole_t Con_DrawMiniConsole; @@ -780,9 +783,6 @@ namespace Game typedef void(__cdecl* SV_ClientThink_t)(client_s*, usercmd_s*); extern SV_ClientThink_t SV_ClientThink; - typedef int(__cdecl * Sys_Error_t)(int, char *, ...); - extern Sys_Error_t Sys_Error; - typedef void(__cdecl * Sys_FreeFileList_t)(char** list); extern Sys_FreeFileList_t Sys_FreeFileList; @@ -822,6 +822,9 @@ namespace Game typedef void(__cdecl * Sys_SuspendOtherThreads_t)(); extern Sys_SuspendOtherThreads_t Sys_SuspendOtherThreads; + typedef void(__cdecl * Sys_Error_t)(char const*, ...); + extern Sys_Error_t Sys_Error; + typedef void(__cdecl * UI_AddMenuList_t)(UiContext *dc, MenuList *menuList, int close); extern UI_AddMenuList_t UI_AddMenuList; @@ -1050,9 +1053,12 @@ namespace Game void SV_KickClient(client_t* client, const char* reason); void SV_KickClientError(client_t* client, const std::string& reason); + void IncInParam(); + void Scr_iPrintLn(int clientNum, const std::string& message); void Scr_iPrintLnBold(int clientNum, const std::string& message); void Scr_NotifyId(unsigned int id, unsigned __int16 stringValue, unsigned int paramcount); + void Scr_AddBool(int value); void IN_KeyUp(kbutton_t* button); void IN_KeyDown(kbutton_t* button);