Set debugcode to true if we are developers

This commit is contained in:
Diavolo 2022-01-08 12:52:05 +01:00
parent 77c2043006
commit c833a57508
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
4 changed files with 25 additions and 1 deletions

View File

@ -331,7 +331,7 @@ namespace Components
{
auto* client = &Game::svs_clients[i];
if (client->state < 3)
if (client->state < Game::CS_CONNECTED)
continue;
if (!client->isBot)

View File

@ -642,6 +642,21 @@ namespace Components
{
Script::ScriptStorage.clear();
});
Script::AddFunction("DebugCode", [](Game::scr_entref_t) // gsc: DebugCode(<int toggle>)
{
if (Game::Scr_GetNumParam() != 1u)
{
Game::Scr_Error("^1DebugCode: Needs one int parameter!\n");
return;
}
const auto toggle = Game::Scr_GetInt(0);
Game::scrVmPub->debugCode = (toggle)
? true
: false;
});
}
Script::Script()
@ -658,7 +673,12 @@ namespace Components
int developer = Dvar::Var("developer").get<int>();
if (developer > 0 && Dedicated::IsEnabled())
{
Utils::Hook::Set<BYTE>(0x48D8C7, 0x75);
// Seems to always be false, if set to true
// it will call RuntimeErrorInternal
Game::scrVmPub->debugCode = true;
}
});
Utils::Hook(0x612E8D, Script::FunctionError, HOOK_CALL).install()->quick();

View File

@ -275,6 +275,7 @@ namespace Game
Scr_NotifyLevel_t Scr_NotifyLevel = Scr_NotifyLevel_t(0x4D9C30);
Scr_Error_t Scr_Error = Scr_Error_t(0x61E8B0);
Scr_ObjectError_t Scr_ObjectError = Scr_ObjectError_t(0x42EF40);
Scr_ParamError_t Scr_ParamError = Scr_ParamError_t(0x4FBC70);
Scr_GetType_t Scr_GetType = Scr_GetType_t(0x422900);
Scr_ClearOutParams_t Scr_ClearOutParams = Scr_ClearOutParams_t(0x4386E0);

View File

@ -705,6 +705,9 @@ namespace Game
typedef void(__cdecl * Scr_ObjectError_t)(const char*);
extern Scr_ObjectError_t Scr_ObjectError;
typedef void(__cdecl * Scr_ParamError_t)(unsigned int paramIndex, const char*);
extern Scr_ParamError_t Scr_ParamError;
typedef script_t* (__cdecl * Script_Alloc_t)(int length);
extern Script_Alloc_t Script_Alloc;