mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-26 23:05:30 +03:00
Fixing issue with default values not being saved with vscript
This commit is contained in:
parent
f219b14420
commit
faf4928ba5
@ -2249,7 +2249,7 @@ void SquirrelVM::WriteObject(CUtlBuffer* pBuffer, WriteStateMap& writeState, SQI
|
||||
|
||||
SQInteger nparams = 0, nfreevars = 0;
|
||||
sq_getclosureinfo(vm_, idx, &nparams, &nfreevars);
|
||||
if (nfreevars == 0)
|
||||
if (nfreevars == 0 && _closure(obj)->_function->_defaultparams == 0)
|
||||
{
|
||||
pBuffer->PutChar(0);
|
||||
|
||||
@ -2279,6 +2279,14 @@ void SquirrelVM::WriteObject(CUtlBuffer* pBuffer, WriteStateMap& writeState, SQI
|
||||
WriteObject(pBuffer, writeState, -1);
|
||||
sq_poptop(vm_);
|
||||
}
|
||||
|
||||
int ndefaultparams = _closure(obj)->_function->_ndefaultparams;
|
||||
for (int i = 0; i < ndefaultparams; ++i)
|
||||
{
|
||||
sq_pushobject(vm_, _closure(obj)->_defaultparams[i]);
|
||||
WriteObject(pBuffer, writeState, -1);
|
||||
sq_poptop(vm_);
|
||||
}
|
||||
}
|
||||
|
||||
if (_closure(obj)->_env)
|
||||
@ -2674,6 +2682,17 @@ void SquirrelVM::ReadObject(CUtlBuffer* pBuffer, ReadStateMap& readState)
|
||||
sq_poptop(vm_);
|
||||
}
|
||||
|
||||
int ndefaultparams = _closure(ret)->_function->_ndefaultparams;
|
||||
for (int i = 0; i < ndefaultparams; ++i)
|
||||
{
|
||||
ReadObject(pBuffer, readState);
|
||||
HSQOBJECT obj;
|
||||
sq_resetobject(&obj);
|
||||
sq_getstackobj(vm_, -1, &obj);
|
||||
_closure(ret)->_defaultparams[i] = obj;
|
||||
sq_poptop(vm_);
|
||||
}
|
||||
|
||||
*obj = ret;
|
||||
sq_addref(vm_, obj);
|
||||
sq_pushobject(vm_, *obj);
|
||||
|
Loading…
Reference in New Issue
Block a user