SQVM: use const qualifiers for SQCONTEXT

This commit is contained in:
Kawe Mazidjatari 2022-09-19 01:18:14 +02:00
parent 1ed7fd8203
commit 3311c99917
2 changed files with 7 additions and 8 deletions

View File

@ -203,7 +203,7 @@ SQBool Script_CreateUIVM()
// Input : context -
// Output : SQVM*
//---------------------------------------------------------------------------------
CSquirrelVM* Script_GetContextObject(SQCONTEXT context)
CSquirrelVM* Script_GetContextObject(const SQCONTEXT context)
{
switch (context)
{
@ -258,7 +258,7 @@ SQBool Script_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar
// Input : *code -
// context -
//---------------------------------------------------------------------------------
void Script_Execute(const SQChar* code, SQCONTEXT context)
void Script_Execute(const SQChar* code, const SQCONTEXT context)
{
if (!ThreadInMainThread())
{
@ -274,7 +274,7 @@ void Script_Execute(const SQChar* code, SQCONTEXT context)
CSquirrelVM* script = Script_GetContextObject(context);
if (!script)
{
Error(eDLL_T::ENGINE, NO_ERROR, "Attempted to run %s script with no handle to script context\n", SQVM_GetContextName(context));
Error(eDLL_T::ENGINE, NO_ERROR, "Attempted to run %s script with no handle to VM\n", SQVM_GetContextName(context));
return;
}
@ -285,11 +285,10 @@ void Script_Execute(const SQChar* code, SQCONTEXT context)
return;
}
SQRESULT compileResult{};
SQBufState bufState = SQBufState(code);
SQRESULT compileResult = sq_compilebuffer(v, &bufState, "console", -1);
compileResult = sq_compilebuffer(v, &bufState, "console", -1);
if (compileResult >= 0)
if (compileResult >= NULL)
{
sq_pushroottable(v);
SQRESULT callResult = sq_call(v, 1, false, false);

View File

@ -114,12 +114,12 @@ SQBool Script_CreateServerVM();
SQBool Script_CreateClientVM(CHLClient* hlclient);
#endif // !DEDICATED
SQBool Script_CreateUIVM();
CSquirrelVM* Script_GetContextObject(SQCONTEXT context);
CSquirrelVM* Script_GetContextObject(const SQCONTEXT context);
SQInteger Script_LoadRson(const SQChar* szRsonName);
SQBool Script_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar* szScriptName, SQInteger nFlag);
void Script_Execute(const SQChar* code, SQCONTEXT context);
void Script_Execute(const SQChar* code, const SQCONTEXT context);
void SQScript_Attach();
void SQScript_Detach();