mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
This patch removes a lot of old code. Context is now exclusively grabbed from the CSquirrelVM instance. This patch also comes with a few new types: SQArray and SQTable! The implementation also allows pushing Vector3D's on the stack, but these are handled slightly differently.. The largest field in tagSQObjectValue is 8 bytes, Vector3D is 12 bytes unaligned, but the tagSQObjectValue field in the tagSQObject struct is aligned to a 8 byte boundary while the field prior is only 4 bytes, Vector3D starts right after the type field in the tagSQObject (at the padding) to keep the whole structure the same size, therefore a new field has been added in between the padding (_pad) with a simple Vector3D accessor. Also added a hook to allow registering proper script enums.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "core/stdafx.h"
|
|
#include "sqobject.h"
|
|
#include "sqstring.h"
|
|
|
|
const SQChar* IdType2Name(const SQObjectType type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case OT_NULL:return _SC("null");
|
|
case OT_INTEGER:return _SC("int");
|
|
case OT_FLOAT:return _SC("float");
|
|
case OT_BOOL:return _SC("bool");
|
|
case OT_STRING:return _SC("string");
|
|
case OT_TABLE:return _SC("table");
|
|
case OT_VAR:return _SC("var");
|
|
case OT_ARRAY:return _SC("array");
|
|
case OT_CLOSURE: return _SC("function");
|
|
case OT_THREAD: return _SC("thread");
|
|
case OT_FUNCPROTO: return _SC("function");
|
|
case OT_UNIMPLEMENTED: return _SC("unimplemented function");
|
|
case OT_CLASS: return _SC("class");
|
|
case OT_INSTANCE: return _SC("instance");
|
|
case OT_WEAKREF: return _SC("weakref");
|
|
case OT_VECTOR: return _SC("vector");
|
|
case OT_ASSET: return _SC("asset");
|
|
case OT_STRUCTDEF: return _SC("structdef");
|
|
case OT_STRUCTINSTANCE: return _SC("struct instance");
|
|
case OT_ENTITY: return _SC("entity");
|
|
default:
|
|
const int ival = (int)type;
|
|
if (ival == SQOBJECT_NUMERIC) return _SC("float or int");
|
|
if (ival == _RT_USERDATA || ival == _RT_USERPOINTER) return _SC("userdata");
|
|
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
SQRefCounted::~SQRefCounted()
|
|
{
|
|
if (_weakref) {
|
|
_weakref->_type = OT_NULL;
|
|
_weakref->_unVal.pRefCounted = NULL;
|
|
}
|
|
}
|