Fix script command

Fixed problem where in certain cases input doesn't get compiled at all.
Fixed problem where quote marks don't get passed correctly to the execute wrapper function.

problems:
passing non-string object as reference to constructor.
using CCommand::Arg(index) seems to 'strip' quote marks from the actual buffer.
This commit is contained in:
Kawe Mazidjatari 2022-04-22 02:27:35 +02:00
parent 02cbb36474
commit 3ad668e37a
3 changed files with 8 additions and 29 deletions

View File

@ -33,11 +33,11 @@ struct SQBufState
const SQChar* bufTail;
const SQChar* bufCopy;
SQBufState(const std::string& code)
SQBufState(const SQChar* code)
{
buf = code.c_str();
bufTail = code.c_str() + code.size();
bufCopy = code.c_str();
buf = code;
bufTail = code + strlen(code);
bufCopy = code;
}
};

View File

@ -451,17 +451,11 @@ void SQVM_Execute(const SQChar* code, SQCONTEXT context)
HSQUIRRELVM v = SQVM_GetVM(context);
if (!v)
{
Error(eDLL_T::ENGINE, "Attempted to execute %s script while VM isn't initialized\n", SQVM_GetContextName(context));
Error(eDLL_T::ENGINE, "Attempted to run %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
SQVM* vTable = v->GetVTable();
if (!vTable)
{
Error(eDLL_T::ENGINE, "Attempted to execute %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
SQRESULT compileResult{};
SQBufState bufState = SQBufState(code);

View File

@ -801,12 +801,7 @@ void _SQVM_ServerScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() >= 2)
{
string svBuf;
for (int i = 1; i < args.ArgC(); i++)
{
svBuf.append(args.Arg(i));
}
SQVM_Execute(svBuf.c_str(), SQCONTEXT::SERVER);
SQVM_Execute(args.ArgS(), SQCONTEXT::SERVER);
}
}
@ -823,12 +818,7 @@ void _SQVM_ClientScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() >= 2)
{
string svBuf;
for (int i = 1; i < args.ArgC(); i++)
{
svBuf.append(args.Arg(i));
}
SQVM_Execute(svBuf.c_str(), SQCONTEXT::CLIENT);
SQVM_Execute(args.ArgS(), SQCONTEXT::CLIENT);
}
}
@ -844,12 +834,7 @@ void _SQVM_UIScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() >= 2)
{
string svBuf;
for (int i = 1; i < args.ArgC(); i++)
{
svBuf.append(args.Arg(i));
}
SQVM_Execute(svBuf.c_str(), SQCONTEXT::UI);
SQVM_Execute(args.ArgS(), SQCONTEXT::UI);
}
}