mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 23:37:58 +03:00
Merge pull request #30 from ReDucTor/vscript-fixes
Various vscript fixes
This commit is contained in:
commit
bc6a35a99c
@ -499,6 +499,22 @@ namespace SQVector
|
||||
return 1;
|
||||
}
|
||||
|
||||
SQInteger Norm(HSQUIRRELVM vm)
|
||||
{
|
||||
Vector* v1 = nullptr;
|
||||
|
||||
if (sq_gettop(vm) != 1 ||
|
||||
SQ_FAILED(sq_getinstanceup(vm, 1, (SQUserPointer*)&v1, TYPETAG_VECTOR)))
|
||||
{
|
||||
return sq_throwerror(vm, "Expected (Vector)");
|
||||
}
|
||||
|
||||
float len = v1->NormalizeInPlace();
|
||||
sq_pushfloat(vm, len);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
SQInteger Dot(HSQUIRRELVM vm)
|
||||
{
|
||||
Vector* v1 = nullptr;
|
||||
@ -628,7 +644,7 @@ namespace SQVector
|
||||
{_SC("Length2D"), Length2D, 1, _SC(".")},
|
||||
{_SC("Length2DSqr"), Length2DSqr, 1, _SC(".")},
|
||||
{_SC("Normalized"), Normalized, 1, _SC(".")},
|
||||
{_SC("Norm"), Normalized, 1, _SC(".")},
|
||||
{_SC("Norm"), Norm, 1, _SC(".")},
|
||||
{_SC("_div"), Divide, 2, _SC("..")},
|
||||
{_SC("Dot"), Dot, 2, _SC("..")},
|
||||
{_SC("Cross"), Cross, 2, _SC("..")},
|
||||
@ -2249,7 +2265,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 +2295,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 +2698,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…
x
Reference in New Issue
Block a user