diff options
author | F1F7Y <64418963+F1F7Y@users.noreply.github.com> | 2024-09-02 17:50:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 17:50:37 +0200 |
commit | ce21abe9c4c58d7c7d986fb01824ab107081ad2f (patch) | |
tree | d723f3ddab3994adfd0391eed5d53faf8db26e65 /primedev/vscript/languages/squirrel_re/squirrel | |
parent | 79fbb9b9a751d6c3a863b1fed95cd8480a1586ab (diff) | |
download | NorthstarLauncher-1.27.6.tar.gz NorthstarLauncher-1.27.6.zip |
vscript: Move squirrel types to their respective files (#788)v1.27.6-rc4v1.27.6
Refactor logic to move Squirrel types to their own respective files and extend existing layouts in the process where applicable.
Contains additional smaller fixes.
Diffstat (limited to 'primedev/vscript/languages/squirrel_re/squirrel')
14 files changed, 482 insertions, 0 deletions
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h b/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h new file mode 100644 index 00000000..3214dc81 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h @@ -0,0 +1,12 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+struct SQArray : public SQCollectable
+{
+ SQObject* _values;
+ int _usedSlots;
+ int _allocated;
+};
+static_assert(sizeof(SQArray) == 0x40);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqclosure.h b/primedev/vscript/languages/squirrel_re/squirrel/sqclosure.h new file mode 100644 index 00000000..85c3adef --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqclosure.h @@ -0,0 +1,29 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+struct alignas(8) SQClosure : public SQCollectable
+{
+ SQObject obj_30;
+ SQObject _function;
+ SQObject* _outervalues;
+ unsigned char gap_58[8];
+};
+static_assert(sizeof(SQClosure) == 96);
+
+struct alignas(8) SQNativeClosure : public SQCollectable
+{
+ char unknown_30;
+ unsigned char padding_34[7];
+ long long value_38;
+ long long value_40;
+ long long value_48;
+ long long value_50;
+ long long value_58;
+ SQObjectType _nameType;
+ SQString* _name;
+ long long value_70;
+ long long value_78;
+};
+static_assert(sizeof(SQNativeClosure) == 128);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqcompiler.h b/primedev/vscript/languages/squirrel_re/squirrel/sqcompiler.h new file mode 100644 index 00000000..5a54751c --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqcompiler.h @@ -0,0 +1,26 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqlexer.h"
+
+struct SQCompiler
+{
+ BYTE gap0[4];
+ int _token;
+ BYTE gap_8[8];
+ SQObject object_10;
+ SQLexer lexer;
+ int64_t qword90;
+ int64_t qword98;
+ BYTE gapA0[280];
+ bool bFatalError;
+ BYTE gap1B9[143];
+ int64_t qword248;
+ int64_t qword250;
+ int64_t qword258;
+ int64_t qword260;
+ BYTE gap268[280];
+ HSQUIRRELVM pSQVM;
+ unsigned char gap_288[8];
+};
+static_assert(sizeof(SQCompiler) == 0x390);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqfunctionproto.h b/primedev/vscript/languages/squirrel_re/squirrel/sqfunctionproto.h new file mode 100644 index 00000000..77bec7eb --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqfunctionproto.h @@ -0,0 +1,24 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+// NOTE [Fifty]: Variable sized struct
+struct alignas(8) SQFunctionProto : public SQCollectable
+{
+ void* pointer_30;
+ SQObjectType _fileNameType;
+ SQString* _fileName;
+ SQObjectType _funcNameType;
+ SQString* _funcName;
+ SQObject obj_58;
+ unsigned char gap_68[12];
+ int _stacksize;
+ unsigned char gap_78[48];
+ int nParameters;
+ unsigned char gap_AC[60];
+ int nDefaultParams;
+ unsigned char gap_EC[200];
+};
+// TODO [Fifty]: Find out the size of the base struct
+static_assert(offsetof(SQFunctionProto, _fileName) == 0x40); // Sanity this check for now
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqlexer.h b/primedev/vscript/languages/squirrel_re/squirrel/sqlexer.h new file mode 100644 index 00000000..dc19bea8 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqlexer.h @@ -0,0 +1,9 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+
+// TODO [Fifty]: Verify size
+struct SQLexer
+{
+ unsigned char gap_0[112];
+};
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqobject.h b/primedev/vscript/languages/squirrel_re/squirrel/sqobject.h new file mode 100644 index 00000000..ea5c0da9 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqobject.h @@ -0,0 +1,93 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+
+struct SQTable;
+
+struct SQRefCounted
+{
+ void* vftable;
+ SQInteger uiRef;
+ void* weakRef; // Probably
+};
+
+struct SQCollectable : public SQRefCounted
+{
+ SQCollectable* _next;
+ SQCollectable* _prev;
+ SQSharedState* _sharedstate;
+};
+
+struct SQDelegable : public SQCollectable
+{
+ SQTable* _delegate;
+};
+
+enum SQObjectType : int
+{
+ _RT_NULL = 0x1,
+ _RT_INTEGER = 0x2,
+ _RT_FLOAT = 0x4,
+ _RT_BOOL = 0x8,
+ _RT_STRING = 0x10,
+ _RT_TABLE = 0x20,
+ _RT_ARRAY = 0x40,
+ _RT_USERDATA = 0x80,
+ _RT_CLOSURE = 0x100,
+ _RT_NATIVECLOSURE = 0x200,
+ _RT_GENERATOR = 0x400,
+ OT_USERPOINTER = 0x800,
+ _RT_USERPOINTER = 0x800,
+ _RT_THREAD = 0x1000,
+ _RT_FUNCPROTO = 0x2000,
+ _RT_CLASS = 0x4000,
+ _RT_INSTANCE = 0x8000,
+ _RT_WEAKREF = 0x10000,
+ OT_VECTOR = 0x40000,
+ SQOBJECT_CANBEFALSE = 0x1000000,
+ OT_NULL = 0x1000001,
+ OT_BOOL = 0x1000008,
+ SQOBJECT_DELEGABLE = 0x2000000,
+ SQOBJECT_NUMERIC = 0x4000000,
+ OT_INTEGER = 0x5000002,
+ OT_FLOAT = 0x5000004,
+ SQOBJECT_REF_COUNTED = 0x8000000,
+ OT_STRING = 0x8000010,
+ OT_ARRAY = 0x8000040,
+ OT_CLOSURE = 0x8000100,
+ OT_NATIVECLOSURE = 0x8000200,
+ OT_ASSET = 0x8000400,
+ OT_THREAD = 0x8001000,
+ OT_FUNCPROTO = 0x8002000,
+ OT_CLAAS = 0x8004000,
+ OT_STRUCT = 0x8200000,
+ OT_WEAKREF = 0x8010000,
+ OT_TABLE = 0xA000020,
+ OT_USERDATA = 0xA000080,
+ OT_INSTANCE = 0xA008000,
+ OT_ENTITY = 0xA400000,
+};
+
+union SQObjectValue
+{
+ SQString* asString;
+ SQTable* asTable;
+ SQClosure* asClosure;
+ SQFunctionProto* asFuncProto;
+ SQStructDef* asStructDef;
+ long long as64Integer;
+ SQNativeClosure* asNativeClosure;
+ SQArray* asArray;
+ HSQUIRRELVM asThread;
+ float asFloat;
+ int asInteger;
+ SQUserData* asUserdata;
+ SQStructInstance* asStructInstance;
+};
+
+struct SQObject
+{
+ SQObjectType _Type;
+ int structNumber;
+ SQObjectValue _VAL;
+};
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqopcodes.h b/primedev/vscript/languages/squirrel_re/squirrel/sqopcodes.h new file mode 100644 index 00000000..be0756c1 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqopcodes.h @@ -0,0 +1,13 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+
+// TODO [Fifty]: Verify size
+struct alignas(4) SQInstruction
+{
+ int op;
+ int arg1;
+ int output;
+ short arg2;
+ short arg3;
+};
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqstate.h b/primedev/vscript/languages/squirrel_re/squirrel/sqstate.h new file mode 100644 index 00000000..d5282ac7 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqstate.h @@ -0,0 +1,120 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+
+class CSquirrelVM;
+struct SQCompiler;
+
+// TODO [Fifty]: Verify size
+struct StringTable
+{
+ unsigned char gap_0[12];
+ int _numofslots;
+ unsigned char gap_10[200];
+};
+
+struct SQSharedState
+{
+ unsigned char gap_0[72];
+ void* unknown;
+ unsigned char gap_50[16344];
+ SQObjectType _unknownTableType00;
+ long long _unknownTableValue00;
+ unsigned char gap_4038[16];
+ StringTable* _stringTable;
+ unsigned char gap_4050[32];
+ SQObjectType _unknownTableType0;
+ long long _unknownTableValue0;
+ SQObjectType _unknownObjectType1;
+ long long _unknownObjectValue1;
+ unsigned char gap_4090[8];
+ SQObjectType _unknownArrayType2;
+ long long _unknownArrayValue2;
+ SQObjectType _gobalsArrayType;
+ SQStructInstance* _globalsArray;
+ unsigned char gap_40B8[16];
+ SQObjectType _nativeClosuresType;
+ SQTable* _nativeClosures;
+ SQObjectType _typedConstantsType;
+ SQTable* _typedConstants;
+ SQObjectType _untypedConstantsType;
+ SQTable* _untypedConstants;
+ SQObjectType _globalsMaybeType;
+ SQTable* _globals;
+ SQObjectType _functionsType;
+ SQTable* _functions;
+ SQObjectType _structsType;
+ SQTable* _structs;
+ SQObjectType _typeDefsType;
+ SQTable* _typeDefs;
+ SQObjectType unknownTableType;
+ SQTable* unknownTable;
+ SQObjectType _squirrelFilesType;
+ SQTable* _squirrelFiles;
+ unsigned char gap_4158[80];
+ SQObjectType _nativeClosures2Type;
+ SQTable* _nativeClosures2;
+ SQObjectType _entityTypesMaybeType;
+ SQTable* _entityTypesMaybe;
+ SQObjectType unknownTable2Type;
+ SQTable* unknownTable2;
+ unsigned char gap_41D8[64];
+ SQCompiler* pCompiler;
+ SQObjectType _compilerKeywordsType;
+ SQTable* _compilerKeywords;
+ HSQUIRRELVM _currentThreadMaybe;
+ unsigned char gap_4238[8];
+ SQObjectType unknownTable3Type;
+ SQTable* unknownTable3;
+ unsigned char gap_4250[16];
+ SQObjectType unknownThreadType;
+ SQTable* unknownThread;
+ SQObjectType _tableNativeFunctionsType;
+ SQTable* _tableNativeFunctions;
+ SQObjectType _unknownTableType4;
+ long long _unknownObjectValue4;
+ SQObjectType _unknownObjectType5;
+ long long _unknownObjectValue5;
+ SQObjectType _unknownObjectType6;
+ long long _unknownObjectValue6;
+ SQObjectType _unknownObjectType7;
+ long long _unknownObjectValue7;
+ SQObjectType _unknownObjectType8;
+ long long _unknownObjectValue8;
+ SQObjectType _unknownObjectType9;
+ long long _unknownObjectValue9;
+ SQObjectType _unknownObjectType10;
+ long long _unknownObjectValue10;
+ SQObjectType _unknownObjectType11;
+ long long _unknownObjectValue11;
+ SQObjectType _unknownObjectType12;
+ long long _unknownObjectValue12;
+ SQObjectType _unknownObjectType13;
+ long long _unknownObjectValue13;
+ SQObjectType _unknownObjectType14;
+ long long _unknownObjectValue14;
+ SQObjectType _unknownObjectType15;
+ long long _unknownObjectValue15;
+ unsigned __int8 gap_4340[8];
+ void* fnFatalErrorCallback;
+ void* fnPrintCallback;
+ unsigned __int8 gap_4358[16];
+ void* logEntityFunction;
+ unsigned char gap_4370[1];
+ SQChar szContextName[8];
+ unsigned char gap[31];
+ SQObjectType _waitStringType;
+ SQString* _waitStringValue;
+ SQObjectType _SpinOffAndWaitForStringType;
+ SQString* _SpinOffAndWaitForStringValue;
+ SQObjectType _SpinOffAndWaitForSoloStringType;
+ SQString* _SpinOffAndWaitForSoloStringValue;
+ SQObjectType _SpinOffStringType;
+ SQString* _SpinOffStringValue;
+ SQObjectType _SpinOffDelayedStringType;
+ SQString* _SpinOffDelayedStringValue;
+ CSquirrelVM* cSquirrelVM;
+ bool enableDebugInfo; // functionality stripped
+ unsigned char gap_43F1[23];
+};
+static_assert(sizeof(SQSharedState) == 17416);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqstring.h b/primedev/vscript/languages/squirrel_re/squirrel/sqstring.h new file mode 100644 index 00000000..5b17f489 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqstring.h @@ -0,0 +1,15 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+// NOTE [Fifty]: Variable sized struct
+struct alignas(8) SQString : public SQRefCounted
+{
+ SQSharedState* sharedState;
+ int length;
+ unsigned char gap_24[4];
+ char _hash[8];
+ char _val[1];
+};
+static_assert(sizeof(SQString) == 56); // [Fifty]: Game allocates 56 + strlen
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqstruct.h b/primedev/vscript/languages/squirrel_re/squirrel/sqstruct.h new file mode 100644 index 00000000..1e357df8 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqstruct.h @@ -0,0 +1,24 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+struct SQStructDef : public SQCollectable
+{
+ SQObjectType _nameType;
+ SQString* _name;
+ unsigned char gap_38[16];
+ SQObjectType _variableNamesType;
+ SQTable* _variableNames;
+ unsigned char gap_[32];
+};
+static_assert(sizeof(SQStructDef) == 128);
+
+// NOTE [Fifty]: Variable sized struct
+struct SQStructInstance : public SQCollectable
+{
+ unsigned int size;
+ BYTE gap_34[4];
+ SQObject data[1];
+};
+static_assert(sizeof(SQStructInstance) == 72);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqtable.h b/primedev/vscript/languages/squirrel_re/squirrel/sqtable.h new file mode 100644 index 00000000..e0ced436 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqtable.h @@ -0,0 +1,21 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+struct alignas(8) SQTable : public SQDelegable
+{
+ struct _HashNode
+ {
+ SQObject val;
+ SQObject key;
+ _HashNode* next;
+ };
+
+ _HashNode* _nodes;
+ int _numOfNodes;
+ int size;
+ int field_48;
+ int _usedNodes;
+};
+static_assert(sizeof(SQTable) == 80);
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/squserdata.h b/primedev/vscript/languages/squirrel_re/squirrel/squserdata.h new file mode 100644 index 00000000..98ede887 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/squserdata.h @@ -0,0 +1,15 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqobject.h"
+
+// NOTE [Fifty]: Variable sized struct
+struct SQUserData : public SQDelegable
+{
+ int size;
+ char padding1[4];
+ void* (*releasehook)(void* val, int size);
+ long long typeId;
+ char data[1];
+};
+static_assert(sizeof(SQUserData) == 88); // [Fifty]: Game allocates 87 + size (passed to the function)
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqvector.h b/primedev/vscript/languages/squirrel_re/squirrel/sqvector.h new file mode 100644 index 00000000..63984e90 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqvector.h @@ -0,0 +1,12 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+
+// TODO [Fifty]: Verify size
+struct SQVector
+{
+ SQObjectType _Type;
+ float x;
+ float y;
+ float z;
+};
diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqvm.h b/primedev/vscript/languages/squirrel_re/squirrel/sqvm.h new file mode 100644 index 00000000..d16092e7 --- /dev/null +++ b/primedev/vscript/languages/squirrel_re/squirrel/sqvm.h @@ -0,0 +1,69 @@ +#pragma once
+
+#include "vscript/languages/squirrel_re/include/squirrel.h"
+#include "vscript/languages/squirrel_re/squirrel/sqstring.h"
+
+struct SQVM;
+
+enum class ScriptContext : int
+{
+ INVALID = -1,
+ SERVER,
+ CLIENT,
+ UI,
+};
+
+struct alignas(8) SQVM
+{
+ struct alignas(8) CallInfo
+ {
+ long long ip;
+ SQObject* _literals;
+ SQObject obj10;
+ SQObject closure;
+ int _etraps[4];
+ int _root;
+ short _vargs_size;
+ short _vargs_base;
+ unsigned char gap[16];
+ };
+
+ void* vftable;
+ int uiRef;
+ unsigned char gap_8[12];
+ void* _toString;
+ void* _roottable_pointer;
+ void* pointer_28;
+ CallInfo* ci;
+ CallInfo* _callstack;
+ int _callstacksize;
+ int _stackbase;
+ SQObject* _stackOfCurrentFunction;
+ SQSharedState* sharedState;
+ void* pointer_58;
+ void* pointer_60;
+ int _top;
+ SQObject* _stack;
+ unsigned char gap_78[8];
+ SQObject* _vargvstack;
+ unsigned char gap_88[8];
+ SQObject temp_reg;
+ unsigned char gapA0[8];
+ void* pointer_A8;
+ unsigned char gap_B0[8];
+ SQObject _roottable_object;
+ SQObject _lasterror;
+ SQObject _errorHandler;
+ long long field_E8;
+ int traps;
+ unsigned char gap_F4[12];
+ int _nnativecalls;
+ int _suspended;
+ int _suspended_root;
+ int _unk;
+ int _suspended_target;
+ int trapAmount;
+ int _suspend_varargs;
+ int unknown_field_11C;
+ SQObject object_120;
+};
|