diff --git a/primedev/Northstar.cmake b/primedev/Northstar.cmake index 74c7b69b2..cb58fecde 100644 --- a/primedev/Northstar.cmake +++ b/primedev/Northstar.cmake @@ -189,6 +189,7 @@ add_library( "squirrel/squirrelautobind.cpp" "squirrel/squirrelautobind.h" "squirrel/squirrelclasstypes.h" + "squirrel/squirreldatatypes.h" "util/concurrentqueue.h" "util/printcommands.cpp" "util/printcommands.h" @@ -200,23 +201,6 @@ add_library( "util/version.h" "util/wininfo.cpp" "util/wininfo.h" - "vscript/languages/squirrel_re/include/squirrel.h" - "vscript/languages/squirrel_re/squirrel/sqarray.h" - "vscript/languages/squirrel_re/squirrel/sqclosure.h" - "vscript/languages/squirrel_re/squirrel/sqcompiler.h" - "vscript/languages/squirrel_re/squirrel/sqfunctionproto.h" - "vscript/languages/squirrel_re/squirrel/sqlexer.h" - "vscript/languages/squirrel_re/squirrel/sqobject.h" - "vscript/languages/squirrel_re/squirrel/sqopcodes.h" - "vscript/languages/squirrel_re/squirrel/sqstate.h" - "vscript/languages/squirrel_re/squirrel/sqstring.h" - "vscript/languages/squirrel_re/squirrel/sqstruct.h" - "vscript/languages/squirrel_re/squirrel/sqtable.h" - "vscript/languages/squirrel_re/squirrel/squserdata.h" - "vscript/languages/squirrel_re/squirrel/sqvector.h" - "vscript/languages/squirrel_re/squirrel/sqvm.h" - "vscript/languages/squirrel_re/vsquirrel.h" - "vscript/vscript.h" "windows/libsys.cpp" "windows/libsys.h" "util/base64.cpp" diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp index 13239c99f..68e33864b 100644 --- a/primedev/mods/modsavefiles.cpp +++ b/primedev/mods/modsavefiles.cpp @@ -537,7 +537,7 @@ ADD_SQFUNC("int", NSGetTotalSpaceRemaining, "", "", ScriptContext::CLIENT | Scri // ok, I'm just gonna explain what the fuck is going on here because this // is the pinnacle of my stupidity and I do not want to touch this ever // again, yet someone will eventually have to maintain this. -template std::string EncodeJSON(HSQUIRRELVM sqvm) +template std::string EncodeJSON(HSquirrelVM* sqvm) { // new rapidjson rapidjson_document doc; diff --git a/primedev/scripts/scriptdatatables.cpp b/primedev/scripts/scriptdatatables.cpp index b3c599212..93120fe39 100644 --- a/primedev/scripts/scriptdatatables.cpp +++ b/primedev/scripts/scriptdatatables.cpp @@ -44,7 +44,7 @@ struct Datatable ConVar* Cvar_ns_prefer_datatable_from_disk; -template Datatable* (*SQ_GetDatatableInternal)(HSQUIRRELVM sqvm); +template Datatable* (*SQ_GetDatatableInternal)(HSquirrelVM* sqvm); struct CSVData { @@ -853,12 +853,12 @@ void ConCommand_dump_datatables(const CCommand& args) ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CModule module)) { - SQ_GetDatatableInternal = module.Offset(0x1250f0).RCast(); + SQ_GetDatatableInternal = module.Offset(0x1250f0).RCast(); } ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CModule module)) { - SQ_GetDatatableInternal = module.Offset(0x1C9070).RCast(); + SQ_GetDatatableInternal = module.Offset(0x1C9070).RCast(); SQ_GetDatatableInternal = SQ_GetDatatableInternal; } diff --git a/primedev/scripts/scripthttprequesthandler.cpp b/primedev/scripts/scripthttprequesthandler.cpp index c3099e093..db988b1a8 100644 --- a/primedev/scripts/scripthttprequesthandler.cpp +++ b/primedev/scripts/scripthttprequesthandler.cpp @@ -452,7 +452,7 @@ template int HttpRequestHandler::MakeHttpRequest(const H // int NS_InternalMakeHttpRequest(int method, string baseUrl, table headers, table queryParams, // string contentType, string body, int timeout, string userAgent) -template SQRESULT SQ_InternalMakeHttpRequest(HSQUIRRELVM sqvm) +template SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM* sqvm) { if (!g_httpRequestHandler || !g_httpRequestHandler->IsRunning()) { @@ -477,7 +477,7 @@ template SQRESULT SQ_InternalMakeHttpRequest(HSQUIRRELVM SQTable* headerTable = sqvm->_stackOfCurrentFunction[3]._VAL.asTable; for (int idx = 0; idx < headerTable->_numOfNodes; ++idx) { - SQTable::_HashNode* node = &headerTable->_nodes[idx]; + tableNode* node = &headerTable->_nodes[idx]; if (node->key._Type == OT_STRING && node->val._Type == OT_ARRAY) { @@ -499,7 +499,7 @@ template SQRESULT SQ_InternalMakeHttpRequest(HSQUIRRELVM SQTable* queryTable = sqvm->_stackOfCurrentFunction[4]._VAL.asTable; for (int idx = 0; idx < queryTable->_numOfNodes; ++idx) { - SQTable::_HashNode* node = &queryTable->_nodes[idx]; + tableNode* node = &queryTable->_nodes[idx]; if (node->key._Type == OT_STRING && node->val._Type == OT_ARRAY) { @@ -529,14 +529,14 @@ template SQRESULT SQ_InternalMakeHttpRequest(HSQUIRRELVM } // bool NSIsHttpEnabled() -template SQRESULT SQ_IsHttpEnabled(HSQUIRRELVM sqvm) +template SQRESULT SQ_IsHttpEnabled(HSquirrelVM* sqvm) { g_pSquirrel->pushbool(sqvm, !IsHttpDisabled()); return SQRESULT_NOTNULL; } // bool NSIsLocalHttpAllowed() -template SQRESULT SQ_IsLocalHttpAllowed(HSQUIRRELVM sqvm) +template SQRESULT SQ_IsLocalHttpAllowed(HSquirrelVM* sqvm) { g_pSquirrel->pushbool(sqvm, IsLocalHttpAllowed()); return SQRESULT_NOTNULL; diff --git a/primedev/scripts/scriptjson.cpp b/primedev/scripts/scriptjson.cpp index da2fed1fa..06bda6f42 100644 --- a/primedev/scripts/scriptjson.cpp +++ b/primedev/scripts/scriptjson.cpp @@ -9,8 +9,8 @@ #undef GetObject // fuck microsoft developers #endif -template -void DecodeJsonArray(HSQUIRRELVM sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* arr) +template void +DecodeJsonArray(HSquirrelVM* sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* arr) { g_pSquirrel->newarray(sqvm, 0); @@ -46,8 +46,8 @@ void DecodeJsonArray(HSQUIRRELVM sqvm, rapidjson::GenericValue -void DecodeJsonTable(HSQUIRRELVM sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* obj) +template void +DecodeJsonTable(HSquirrelVM* sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* obj) { g_pSquirrel->newtable(sqvm); @@ -103,7 +103,7 @@ template void EncodeJSONTable( { for (int i = 0; i < table->_numOfNodes; i++) { - SQTable::_HashNode* node = &table->_nodes[i]; + tableNode* node = &table->_nodes[i]; if (node->key._Type == OT_STRING) { rapidjson::GenericValue, rapidjson::MemoryPoolAllocator> newObj(rapidjson::kObjectType); @@ -236,7 +236,7 @@ ADD_SQFUNC( doc.SetObject(); // temp until this is just the func parameter type - HSQUIRRELVM vm = (HSQUIRRELVM)sqvm; + HSquirrelVM* vm = (HSquirrelVM*)sqvm; SQTable* table = vm->_stackOfCurrentFunction[1]._VAL.asTable; EncodeJSONTable(table, &doc, doc.GetAllocator()); diff --git a/primedev/scripts/scriptjson.h b/primedev/scripts/scriptjson.h index f766e3f00..b747106b2 100644 --- a/primedev/scripts/scriptjson.h +++ b/primedev/scripts/scriptjson.h @@ -10,4 +10,4 @@ template void EncodeJSONTable( rapidjson::MemoryPoolAllocator& allocator); template void -DecodeJsonTable(HSQUIRRELVM sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* obj); +DecodeJsonTable(HSquirrelVM* sqvm, rapidjson::GenericValue, rapidjson::MemoryPoolAllocator>* obj); diff --git a/primedev/squirrel/squirrel.cpp b/primedev/squirrel/squirrel.cpp index 18ff9f29f..af6a2fabd 100644 --- a/primedev/squirrel/squirrel.cpp +++ b/primedev/squirrel/squirrel.cpp @@ -11,8 +11,6 @@ #include "ns_version.h" #include "core/vanilla.h" -#include "vscript/vscript.h" - #include AUTOHOOK_INIT() @@ -247,8 +245,8 @@ template void SquirrelManager::ExecuteCode(cons spdlog::info("Executing {} script code {} ", GetContextName(context), pCode); - // NOTE: SQBufferState doesn't strdup pCode! - SQBufferState bufferState = SQBufferState(pCode); + std::string strCode(pCode); + CompileBufferState bufferState = CompileBufferState(strCode); SQRESULT compileResult = compilebuffer(&bufferState, "console"); spdlog::info("sq_compilebuffer returned {}", PrintSQRESULT.at(compileResult)); @@ -303,14 +301,14 @@ template void SquirrelManager::AddFuncOverride( } // hooks -bool IsUIVM(ScriptContext context, HSQUIRRELVM pSqvm) +bool IsUIVM(ScriptContext context, HSquirrelVM* pSqvm) { NOTE_UNUSED(context); return ScriptContext(pSqvm->sharedState->cSquirrelVM->vmContext) == ScriptContext::UI; } -template void* (*sq_compiler_create)(HSQUIRRELVM sqvm, void* a2, void* a3, SQBool bShouldThrowError); -template void* __fastcall sq_compiler_createHook(HSQUIRRELVM sqvm, void* a2, void* a3, SQBool bShouldThrowError) +template void* (*sq_compiler_create)(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError); +template void* __fastcall sq_compiler_createHook(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError) { // store whether errors generated from this compile should be fatal if (IsUIVM(context, sqvm)) @@ -321,8 +319,8 @@ template void* __fastcall sq_compiler_createHook(HSQUIRR return sq_compiler_create(sqvm, a2, a3, bShouldThrowError); } -template SQInteger (*SQPrint)(HSQUIRRELVM sqvm, const char* fmt); -template SQInteger SQPrintHook(HSQUIRRELVM sqvm, const char* fmt, ...) +template SQInteger (*SQPrint)(HSquirrelVM* sqvm, const char* fmt); +template SQInteger SQPrintHook(HSquirrelVM* sqvm, const char* fmt, ...) { NOTE_UNUSED(sqvm); @@ -392,9 +390,9 @@ template void __fastcall DestroyVMHook(void* a1, CSquirr spdlog::info("DestroyVM {} {}", GetContextName(realContext), (void*)sqvm); } -template void (*SQCompileError)(HSQUIRRELVM sqvm, const char* error, const char* file, int line, int column); +template void (*SQCompileError)(HSquirrelVM* sqvm, const char* error, const char* file, int line, int column); template -void __fastcall ScriptCompileErrorHook(HSQUIRRELVM sqvm, const char* error, const char* file, int line, int column) +void __fastcall ScriptCompileErrorHook(HSquirrelVM* sqvm, const char* error, const char* file, int line, int column) { bool bIsFatalError = g_pSquirrel->m_bFatalCompilationErrors; ScriptContext realContext = context; // ui and client use the same function so we use this for prints @@ -538,7 +536,7 @@ template void ConCommand_script(const CCommand& args) g_pSquirrel->ExecuteCode(args.ArgS()); } -template SQRESULT SQ_StubbedFunc(HSQUIRRELVM sqvm) +template SQRESULT SQ_StubbedFunc(HSquirrelVM* sqvm) { SQStackInfos si; g_pSquirrel->sq_stackinfos(sqvm, 0, si); diff --git a/primedev/squirrel/squirrel.h b/primedev/squirrel/squirrel.h index 2d8d6cb46..359290e17 100644 --- a/primedev/squirrel/squirrel.h +++ b/primedev/squirrel/squirrel.h @@ -137,72 +137,132 @@ class SquirrelManagerBase } inline SQRESULT - compilebuffer(SQBufferState* bufferState, const SQChar* bufferName = "unnamedbuffer", const SQBool bShouldThrowError = false) + compilebuffer(CompileBufferState* bufferState, const SQChar* bufferName = "unnamedbuffer", const SQBool bShouldThrowError = false) { return __sq_compilebuffer(m_pSQVM->sqvm, bufferState, bufferName, -1, bShouldThrowError); } - inline SQRESULT _call(HSQUIRRELVM sqvm, const SQInteger args) { return __sq_call(sqvm, args + 1, false, true); } + inline SQRESULT _call(HSquirrelVM* sqvm, const SQInteger args) + { + return __sq_call(sqvm, args + 1, false, false); + } - inline SQInteger raiseerror(HSQUIRRELVM sqvm, const SQChar* sError) { return __sq_raiseerror(sqvm, sError); } + inline SQInteger raiseerror(HSquirrelVM* sqvm, const SQChar* sError) + { + return __sq_raiseerror(sqvm, sError); + } inline bool compilefile(CSquirrelVM* sqvm, const char* path, const char* name, int a4) { return __sq_compilefile(sqvm, path, name, a4); } - inline void newarray(HSQUIRRELVM sqvm, const SQInteger stackpos = 0) { __sq_newarray(sqvm, stackpos); } + inline void newarray(HSquirrelVM* sqvm, const SQInteger stackpos = 0) + { + __sq_newarray(sqvm, stackpos); + } - inline SQRESULT arrayappend(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_arrayappend(sqvm, stackpos); } + inline SQRESULT arrayappend(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_arrayappend(sqvm, stackpos); + } - inline SQRESULT newtable(HSQUIRRELVM sqvm) { return __sq_newtable(sqvm); } + inline SQRESULT newtable(HSquirrelVM* sqvm) + { + return __sq_newtable(sqvm); + } - inline SQRESULT newslot(HSQUIRRELVM sqvm, SQInteger idx, SQBool bStatic) { return __sq_newslot(sqvm, idx, bStatic); } + inline SQRESULT newslot(HSquirrelVM* sqvm, SQInteger idx, SQBool bStatic) + { + return __sq_newslot(sqvm, idx, bStatic); + } - inline void pushroottable(HSQUIRRELVM sqvm) { __sq_pushroottable(sqvm); } + inline void pushroottable(HSquirrelVM* sqvm) + { + __sq_pushroottable(sqvm); + } - inline void pushstring(HSQUIRRELVM sqvm, const SQChar* sVal, int length = -1) { __sq_pushstring(sqvm, sVal, length); } + inline void pushstring(HSquirrelVM* sqvm, const SQChar* sVal, int length = -1) + { + __sq_pushstring(sqvm, sVal, length); + } - inline void pushinteger(HSQUIRRELVM sqvm, const SQInteger iVal) { __sq_pushinteger(sqvm, iVal); } + inline void pushinteger(HSquirrelVM* sqvm, const SQInteger iVal) + { + __sq_pushinteger(sqvm, iVal); + } - inline void pushfloat(HSQUIRRELVM sqvm, const SQFloat flVal) { __sq_pushfloat(sqvm, flVal); } + inline void pushfloat(HSquirrelVM* sqvm, const SQFloat flVal) + { + __sq_pushfloat(sqvm, flVal); + } - inline void pushbool(HSQUIRRELVM sqvm, const SQBool bVal) { __sq_pushbool(sqvm, bVal); } + inline void pushbool(HSquirrelVM* sqvm, const SQBool bVal) + { + __sq_pushbool(sqvm, bVal); + } - inline void pushasset(HSQUIRRELVM sqvm, const SQChar* sVal, int length = -1) { __sq_pushasset(sqvm, sVal, length); } + inline void pushasset(HSquirrelVM* sqvm, const SQChar* sVal, int length = -1) + { + __sq_pushasset(sqvm, sVal, length); + } - inline void pushvector(HSQUIRRELVM sqvm, const Vector3 pVal) { __sq_pushvector(sqvm, (float*)&pVal); } + inline void pushvector(HSquirrelVM* sqvm, const Vector3 pVal) + { + __sq_pushvector(sqvm, (float*)&pVal); + } - inline void pushobject(HSQUIRRELVM sqvm, SQObject* obj) { __sq_pushobject(sqvm, obj); } + inline void pushobject(HSquirrelVM* sqvm, SQObject* obj) + { + __sq_pushobject(sqvm, obj); + } - inline const SQChar* getstring(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_getstring(sqvm, stackpos); } + inline const SQChar* getstring(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_getstring(sqvm, stackpos); + } - inline SQInteger getinteger(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_getinteger(sqvm, stackpos); } + inline SQInteger getinteger(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_getinteger(sqvm, stackpos); + } - inline SQFloat getfloat(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_getfloat(sqvm, stackpos); } + inline SQFloat getfloat(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_getfloat(sqvm, stackpos); + } - inline SQBool getbool(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_getbool(sqvm, stackpos); } + inline SQBool getbool(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_getbool(sqvm, stackpos); + } - inline SQRESULT get(HSQUIRRELVM sqvm, const SQInteger stackpos) { return __sq_get(sqvm, stackpos); } + inline SQRESULT get(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return __sq_get(sqvm, stackpos); + } - inline Vector3 getvector(HSQUIRRELVM sqvm, const SQInteger stackpos) { return *(Vector3*)__sq_getvector(sqvm, stackpos); } + inline Vector3 getvector(HSquirrelVM* sqvm, const SQInteger stackpos) + { + return *(Vector3*)__sq_getvector(sqvm, stackpos); + } - inline int sq_getfunction(HSQUIRRELVM sqvm, const char* name, SQObject* returnObj, const char* signature) + inline int sq_getfunction(HSquirrelVM* sqvm, const char* name, SQObject* returnObj, const char* signature) { return __sq_getfunction(sqvm, name, returnObj, signature); } - inline SQRESULT getasset(HSQUIRRELVM sqvm, const SQInteger stackpos, const char** result) + inline SQRESULT getasset(HSquirrelVM* sqvm, const SQInteger stackpos, const char** result) { return __sq_getasset(sqvm, stackpos, result); } - inline long long sq_stackinfos(HSQUIRRELVM sqvm, int level, SQStackInfos& out) + inline long long sq_stackinfos(HSquirrelVM* sqvm, int level, SQStackInfos& out) { return __sq_stackinfos(sqvm, level, &out, sqvm->_callstacksize); } - inline Mod* getcallingmod(HSQUIRRELVM sqvm, int depth = 0) + inline Mod* getcallingmod(HSquirrelVM* sqvm, int depth = 0) { SQStackInfos stackInfo {}; if (1 + depth >= sqvm->_callstacksize) @@ -219,26 +279,29 @@ class SquirrelManagerBase } return nullptr; } - template inline SQRESULT getuserdata(HSQUIRRELVM sqvm, const SQInteger stackpos, T* data, uint64_t* typeId) + template inline SQRESULT getuserdata(HSquirrelVM* sqvm, const SQInteger stackpos, T* data, uint64_t* typeId) { return __sq_getuserdata(sqvm, stackpos, (void**)data, typeId); // this sometimes crashes idk } - template inline T* createuserdata(HSQUIRRELVM sqvm, SQInteger size) + template inline T* createuserdata(HSquirrelVM* sqvm, SQInteger size) { void* ret = __sq_createuserdata(sqvm, size); memset(ret, 0, size); return (T*)ret; } - inline SQRESULT setuserdatatypeid(HSQUIRRELVM sqvm, const SQInteger stackpos, uint64_t typeId) + inline SQRESULT setuserdatatypeid(HSquirrelVM* sqvm, const SQInteger stackpos, uint64_t typeId) { return __sq_setuserdatatypeid(sqvm, stackpos, typeId); } - template inline SQBool getthisentity(HSQUIRRELVM sqvm, T* ppEntity) { return __sq_getthisentity(sqvm, (void**)ppEntity); } + template inline SQBool getthisentity(HSquirrelVM* sqvm, T* ppEntity) + { + return __sq_getthisentity(sqvm, (void**)ppEntity); + } - template inline T* getentity(HSQUIRRELVM sqvm, SQInteger iStackPos) + template inline T* getentity(HSquirrelVM* sqvm, SQInteger iStackPos) { SQObject obj; __sq_getobject(sqvm, iStackPos, &obj); @@ -247,9 +310,15 @@ class SquirrelManagerBase return (T*)__sq_getentityfrominstance(m_pSQVM, &obj, __sq_GetEntityConstant_CBaseEntity()); } - inline SQRESULT pushnewstructinstance(HSQUIRRELVM sqvm, const int fieldCount) { return __sq_pushnewstructinstance(sqvm, fieldCount); } + inline SQRESULT pushnewstructinstance(HSquirrelVM* sqvm, const int fieldCount) + { + return __sq_pushnewstructinstance(sqvm, fieldCount); + } - inline SQRESULT sealstructslot(HSQUIRRELVM sqvm, const int fieldIndex) { return __sq_sealstructslot(sqvm, fieldIndex); } + inline SQRESULT sealstructslot(HSquirrelVM* sqvm, const int fieldIndex) + { + return __sq_sealstructslot(sqvm, fieldIndex); + } #pragma endregion }; diff --git a/primedev/squirrel/squirrelautobind.h b/primedev/squirrel/squirrelautobind.h index cb1d21087..0fc599f3d 100644 --- a/primedev/squirrel/squirrelautobind.h +++ b/primedev/squirrel/squirrelautobind.h @@ -15,7 +15,7 @@ extern SquirrelAutoBindContainer* g_pSqAutoBindContainer; class __squirrelautobind; #define ADD_SQFUNC(returnType, funcName, argTypes, helpText, runOnContext) \ - template SQRESULT CONCAT2(Script_, funcName)(HSQUIRRELVM sqvm); \ + template SQRESULT CONCAT2(Script_, funcName)(HSquirrelVM * sqvm); \ namespace \ { \ __squirrelautobind CONCAT2(__squirrelautobind, __LINE__)( \ @@ -35,10 +35,10 @@ class __squirrelautobind; returnType, __STR(funcName), argTypes, helpText, CONCAT2(Script_, funcName) < ScriptContext::SERVER >); \ }); \ } \ - template SQRESULT CONCAT2(Script_, funcName)(HSQUIRRELVM sqvm) + template SQRESULT CONCAT2(Script_, funcName)(HSquirrelVM * sqvm) #define REPLACE_SQFUNC(funcName, runOnContext) \ - template SQRESULT CONCAT2(Script_, funcName)(HSQUIRRELVM sqvm); \ + template SQRESULT CONCAT2(Script_, funcName)(HSquirrelVM * sqvm); \ namespace \ { \ __squirrelautobind CONCAT2(__squirrelautobind, __LINE__)( \ @@ -57,7 +57,7 @@ class __squirrelautobind; __STR(funcName), CONCAT2(Script_, funcName) < ScriptContext::SERVER >); \ }); \ } \ - template SQRESULT CONCAT2(Script_, funcName)(HSQUIRRELVM sqvm) + template SQRESULT CONCAT2(Script_, funcName)(HSquirrelVM * sqvm) class __squirrelautobind { diff --git a/primedev/squirrel/squirrelclasstypes.h b/primedev/squirrel/squirrelclasstypes.h index 2fa5d2a04..91c3c4683 100644 --- a/primedev/squirrel/squirrelclasstypes.h +++ b/primedev/squirrel/squirrelclasstypes.h @@ -1,14 +1,83 @@ #pragma once - -#include "vscript/vscript.h" +#include "squirreldatatypes.h" #include +enum SQRESULT : SQInteger +{ + SQRESULT_ERROR = -1, + SQRESULT_NULL = 0, + SQRESULT_NOTNULL = 1, +}; + +typedef SQRESULT (*SQFunction)(HSquirrelVM* sqvm); + +enum class eSQReturnType +{ + Float = 0x1, + Vector = 0x3, + Integer = 0x5, + Boolean = 0x6, + Entity = 0xD, + String = 0x21, + Default = 0x20, + Arrays = 0x25, + Asset = 0x28, + Table = 0x26, +}; + const std::map PrintSQRESULT = { {SQRESULT::SQRESULT_ERROR, "SQRESULT_ERROR"}, {SQRESULT::SQRESULT_NULL, "SQRESULT_NULL"}, {SQRESULT::SQRESULT_NOTNULL, "SQRESULT_NOTNULL"}}; +struct CompileBufferState +{ + const SQChar* buffer; + const SQChar* bufferPlusLength; + const SQChar* bufferAgain; + + CompileBufferState(const std::string& code) + { + buffer = code.c_str(); + bufferPlusLength = code.c_str() + code.size(); + bufferAgain = code.c_str(); + } +}; + +struct SQFuncRegistration +{ + const char* squirrelFuncName; + const char* cppFuncName; + const char* helpText; + const char* returnTypeString; + const char* argTypes; + uint32_t unknown1; + uint32_t devLevel; + const char* shortNameMaybe; + uint32_t unknown2; + eSQReturnType returnType; + uint32_t* externalBufferPointer; + uint64_t externalBufferSize; + uint64_t unknown3; + uint64_t unknown4; + SQFunction funcPtr; + + SQFuncRegistration() + { + memset(this, 0, sizeof(SQFuncRegistration)); + this->returnType = eSQReturnType::Default; + } +}; + +enum class ScriptContext : int +{ + INVALID = -1, + SERVER, + CLIENT, + UI, +}; + typedef std::vector> FunctionVector; typedef std::function VoidFunction; @@ -115,55 +184,55 @@ typedef int64_t (*RegisterSquirrelFuncType)(CSquirrelVM* sqvm, SQFuncRegistratio typedef void (*sq_defconstType)(CSquirrelVM* sqvm, const SQChar* name, int value); typedef SQRESULT (*sq_compilebufferType)( - HSQUIRRELVM sqvm, SQBufferState* compileBuffer, const char* file, int a1, SQBool bShouldThrowError); -typedef SQRESULT (*sq_callType)(HSQUIRRELVM sqvm, SQInteger iArgs, SQBool bShouldReturn, SQBool bThrowError); -typedef SQInteger (*sq_raiseerrorType)(HSQUIRRELVM sqvm, const SQChar* pError); + HSquirrelVM* sqvm, CompileBufferState* compileBuffer, const char* file, int a1, SQBool bShouldThrowError); +typedef SQRESULT (*sq_callType)(HSquirrelVM* sqvm, SQInteger iArgs, SQBool bShouldReturn, SQBool bThrowError); +typedef SQInteger (*sq_raiseerrorType)(HSquirrelVM* sqvm, const SQChar* pError); typedef bool (*sq_compilefileType)(CSquirrelVM* sqvm, const char* path, const char* name, int a4); // sq stack array funcs -typedef void (*sq_newarrayType)(HSQUIRRELVM sqvm, SQInteger iStackpos); -typedef SQRESULT (*sq_arrayappendType)(HSQUIRRELVM sqvm, SQInteger iStackpos); +typedef void (*sq_newarrayType)(HSquirrelVM* sqvm, SQInteger iStackpos); +typedef SQRESULT (*sq_arrayappendType)(HSquirrelVM* sqvm, SQInteger iStackpos); // sq table funcs -typedef SQRESULT (*sq_newtableType)(HSQUIRRELVM sqvm); -typedef SQRESULT (*sq_newslotType)(HSQUIRRELVM sqvm, SQInteger idx, SQBool bStatic); +typedef SQRESULT (*sq_newtableType)(HSquirrelVM* sqvm); +typedef SQRESULT (*sq_newslotType)(HSquirrelVM* sqvm, SQInteger idx, SQBool bStatic); // sq stack push funcs -typedef void (*sq_pushroottableType)(HSQUIRRELVM sqvm); -typedef void (*sq_pushstringType)(HSQUIRRELVM sqvm, const SQChar* pStr, SQInteger iLength); -typedef void (*sq_pushintegerType)(HSQUIRRELVM sqvm, SQInteger i); -typedef void (*sq_pushfloatType)(HSQUIRRELVM sqvm, SQFloat f); -typedef void (*sq_pushboolType)(HSQUIRRELVM sqvm, SQBool b); -typedef void (*sq_pushassetType)(HSQUIRRELVM sqvm, const SQChar* str, SQInteger iLength); -typedef void (*sq_pushvectorType)(HSQUIRRELVM sqvm, const SQFloat* pVec); -typedef void (*sq_pushobjectType)(HSQUIRRELVM sqvm, SQObject* pVec); +typedef void (*sq_pushroottableType)(HSquirrelVM* sqvm); +typedef void (*sq_pushstringType)(HSquirrelVM* sqvm, const SQChar* pStr, SQInteger iLength); +typedef void (*sq_pushintegerType)(HSquirrelVM* sqvm, SQInteger i); +typedef void (*sq_pushfloatType)(HSquirrelVM* sqvm, SQFloat f); +typedef void (*sq_pushboolType)(HSquirrelVM* sqvm, SQBool b); +typedef void (*sq_pushassetType)(HSquirrelVM* sqvm, const SQChar* str, SQInteger iLength); +typedef void (*sq_pushvectorType)(HSquirrelVM* sqvm, const SQFloat* pVec); +typedef void (*sq_pushobjectType)(HSquirrelVM* sqvm, SQObject* pVec); // sq stack get funcs -typedef const SQChar* (*sq_getstringType)(HSQUIRRELVM sqvm, SQInteger iStackpos); -typedef SQInteger (*sq_getintegerType)(HSQUIRRELVM sqvm, SQInteger iStackpos); -typedef SQFloat (*sq_getfloatType)(HSQUIRRELVM, SQInteger iStackpos); -typedef SQBool (*sq_getboolType)(HSQUIRRELVM, SQInteger iStackpos); -typedef SQRESULT (*sq_getType)(HSQUIRRELVM sqvm, SQInteger iStackpos); -typedef SQRESULT (*sq_getassetType)(HSQUIRRELVM sqvm, SQInteger iStackpos, const char** pResult); -typedef SQRESULT (*sq_getuserdataType)(HSQUIRRELVM sqvm, SQInteger iStackpos, void** pData, uint64_t* pTypeId); -typedef SQFloat* (*sq_getvectorType)(HSQUIRRELVM sqvm, SQInteger iStackpos); -typedef SQBool (*sq_getthisentityType)(HSQUIRRELVM, void** ppEntity); -typedef void (*sq_getobjectType)(HSQUIRRELVM, SQInteger iStackPos, SQObject* pOutObj); - -typedef long long (*sq_stackinfosType)(HSQUIRRELVM sqvm, int iLevel, SQStackInfos* pOutObj, int iCallStackSize); +typedef const SQChar* (*sq_getstringType)(HSquirrelVM* sqvm, SQInteger iStackpos); +typedef SQInteger (*sq_getintegerType)(HSquirrelVM* sqvm, SQInteger iStackpos); +typedef SQFloat (*sq_getfloatType)(HSquirrelVM*, SQInteger iStackpos); +typedef SQBool (*sq_getboolType)(HSquirrelVM*, SQInteger iStackpos); +typedef SQRESULT (*sq_getType)(HSquirrelVM* sqvm, SQInteger iStackpos); +typedef SQRESULT (*sq_getassetType)(HSquirrelVM* sqvm, SQInteger iStackpos, const char** pResult); +typedef SQRESULT (*sq_getuserdataType)(HSquirrelVM* sqvm, SQInteger iStackpos, void** pData, uint64_t* pTypeId); +typedef SQFloat* (*sq_getvectorType)(HSquirrelVM* sqvm, SQInteger iStackpos); +typedef SQBool (*sq_getthisentityType)(HSquirrelVM*, void** ppEntity); +typedef void (*sq_getobjectType)(HSquirrelVM*, SQInteger iStackPos, SQObject* pOutObj); + +typedef long long (*sq_stackinfosType)(HSquirrelVM* sqvm, int iLevel, SQStackInfos* pOutObj, int iCallStackSize); // sq stack userpointer funcs -typedef void* (*sq_createuserdataType)(HSQUIRRELVM sqvm, SQInteger iSize); -typedef SQRESULT (*sq_setuserdatatypeidType)(HSQUIRRELVM sqvm, SQInteger iStackpos, uint64_t iTypeId); +typedef void* (*sq_createuserdataType)(HSquirrelVM* sqvm, SQInteger iSize); +typedef SQRESULT (*sq_setuserdatatypeidType)(HSquirrelVM* sqvm, SQInteger iStackpos, uint64_t iTypeId); // sq misc entity funcs typedef void* (*sq_getentityfrominstanceType)(CSquirrelVM* sqvm, SQObject* pInstance, char** ppEntityConstant); typedef char** (*sq_GetEntityConstantType)(); -typedef int (*sq_getfunctionType)(HSQUIRRELVM sqvm, const char* name, SQObject* returnObj, const char* signature); +typedef int (*sq_getfunctionType)(HSquirrelVM* sqvm, const char* name, SQObject* returnObj, const char* signature); // structs -typedef SQRESULT (*sq_pushnewstructinstanceType)(HSQUIRRELVM sqvm, int fieldCount); -typedef SQRESULT (*sq_sealstructslotType)(HSQUIRRELVM sqvm, int slotIndex); +typedef SQRESULT (*sq_pushnewstructinstanceType)(HSquirrelVM* sqvm, int fieldCount); +typedef SQRESULT (*sq_sealstructslotType)(HSquirrelVM* sqvm, int slotIndex); #pragma endregion diff --git a/primedev/squirrel/squirreldatatypes.h b/primedev/squirrel/squirreldatatypes.h new file mode 100644 index 000000000..84ab15ecc --- /dev/null +++ b/primedev/squirrel/squirreldatatypes.h @@ -0,0 +1,501 @@ +#pragma once +/* + This file has been generated by IDA. + It contains local type definitions from + the type library 'server.dll' +*/ + +struct HSquirrelVM; +struct CallInfo; +struct SQTable; +struct SQString; +struct SQFunctionProto; +struct SQClosure; +struct SQSharedState; +struct StringTable; +struct SQStructInstance; +struct SQStructDef; +struct SQNativeClosure; +struct SQArray; +struct tableNode; +struct SQUserData; +struct CSquirrelVM; + +typedef void (*releasehookType)(void* val, int size); + +// stolen from ttf2sdk: sqvm types +typedef float SQFloat; +typedef long SQInteger; +typedef unsigned long SQUnsignedInteger; +typedef char SQChar; +typedef SQUnsignedInteger SQBool; + +/* 127 */ +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, +}; + +/* 156 */ +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; +}; + +/* 160 */ +struct SQVector +{ + SQObjectType _Type; + float x; + float y; + float z; +}; + +/* 128 */ +struct SQObject +{ + SQObjectType _Type; + int structNumber; + SQObjectValue _VAL; +}; + +/* 138 */ +struct alignas(8) SQString +{ + void* vftable; + int uiRef; + int padding; + SQString* _next_maybe; + SQSharedState* sharedState; + int length; + unsigned char gap_24[4]; + char _hash[8]; + char _val[1]; +}; + +/* 137 */ +struct alignas(8) SQTable +{ + void* vftable; + unsigned char gap_08[4]; + int uiRef; + unsigned char gap_10[8]; + void* pointer_18; + void* pointer_20; + void* _sharedState; + long long field_30; + tableNode* _nodes; + int _numOfNodes; + int size; + int field_48; + int _usedNodes; + unsigned char _gap_50[20]; + int field_64; + unsigned char _gap_68[80]; +}; + +/* 140 */ +struct alignas(8) SQClosure +{ + void* vftable; + unsigned char gap_08[4]; + int uiRef; + void* pointer_10; + void* pointer_18; + void* pointer_20; + void* sharedState; + SQObject obj_30; + SQObject _function; + SQObject* _outervalues; + unsigned char gap_58[8]; + unsigned char gap_60[96]; + SQObject* objectPointer_C0; + unsigned char gap_C8[16]; +}; + +/* 139 */ +struct alignas(8) SQFunctionProto +{ + void* vftable; + unsigned char gap_08[4]; + int uiRef; + unsigned char gap_10[8]; + void* pointer_18; + void* pointer_20; + void* sharedState; + 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]; +}; + +/* 152 */ +struct SQStructDef +{ + void* vtable; + int uiRef; + unsigned char padding_C[4]; + unsigned char unknown[24]; + SQSharedState* sharedState; + SQObjectType _nameType; + SQString* _name; + unsigned char gap_38[16]; + SQObjectType _variableNamesType; + SQTable* _variableNames; + unsigned char gap_[32]; +}; + +/* 157 */ +struct alignas(8) SQNativeClosure +{ + void* vftable; + int uiRef; + unsigned char gap_C[4]; + long long value_10; + long long value_18; + long long value_20; + SQSharedState* sharedState; + 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; + unsigned char justInCaseGap_80[300]; +}; + +/* 162 */ +struct SQArray +{ + void* vftable; + int uiRef; + unsigned char gap_24[36]; + SQObject* _values; + int _usedSlots; + int _allocated; +}; + +/* 129 */ +struct alignas(8) HSquirrelVM +{ + 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; +}; + +/* 150 */ +struct SQStructInstance +{ + void* vftable; + __int32 uiRef; + BYTE gap_C[4]; + __int64 unknown_10; + void* pointer_18; + __int64 unknown_20; + SQSharedState* _sharedState; + unsigned int size; + BYTE gap_34[4]; + SQObject data[1]; // This struct is dynamically sized, so this size is unknown +}; + +/* 148 */ +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[72]; + 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 char gap_4340[16]; + void* printFunction; + unsigned char gap_4358[16]; + void* logEntityFunction; + unsigned char gap_4370[40]; + 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]; +}; + +/* 165 */ +struct tableNode +{ + SQObject val; + SQObject key; + tableNode* next; +}; + +/* 136 */ +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]; +}; + +/* 149 */ +struct StringTable +{ + unsigned char gap_0[12]; + int _numofslots; + unsigned char gap_10[200]; +}; + +/* 141 */ +struct alignas(8) SQStackInfos +{ + char* _name; + char* _sourceName; + int _line; +}; + +/* 151 */ +struct alignas(4) SQInstruction +{ + int op; + int arg1; + int output; + short arg2; + short arg3; +}; + +/* 154 */ +struct SQLexer +{ + unsigned char gap_0[112]; +}; + +/* 153 */ +struct SQCompiler +{ + unsigned char gap_0[4]; + int _token; + unsigned char gap_8[8]; + SQObject object_10; + SQLexer lexer; + unsigned char gap_90[752]; + HSquirrelVM* sqvm; + unsigned char gap_288[8]; +}; + +/* 155 */ +struct CSquirrelVM +{ + BYTE gap_0[8]; + HSquirrelVM* sqvm; + BYTE gap_10[8]; + SQObject unknownObject_18; + __int64 unknown_28; + BYTE gap_30[12]; + __int32 vmContext; + BYTE gap_40[648]; + char* (*formatString)(__int64 a1, const char* format, ...); + BYTE gap_2D0[24]; +}; + +struct SQUserData +{ + void* vftable; + int uiRef; + char gap_12[4]; + long long unknown_10; + long long unknown_18; + long long unknown_20; + long long sharedState; + long long unknown_30; + int size; + char padding1[4]; + releasehookType releaseHook; + long long typeId; + char data[1]; +}; diff --git a/primedev/vscript/languages/squirrel_re/include/squirrel.h b/primedev/vscript/languages/squirrel_re/include/squirrel.h deleted file mode 100644 index b068ff06b..000000000 --- a/primedev/vscript/languages/squirrel_re/include/squirrel.h +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -class Mod; -struct SQBufferState; -class CBaseEntity; - -struct SQVM; -struct SQObject; -struct SQTable; -struct SQArray; -struct SQString; -struct SQClosure; -struct SQFunctionProto; -struct SQStructDef; -struct SQNativeClosure; -struct SQStructInstance; -struct SQUserData; -struct SQSharedState; - -typedef float SQFloat; -typedef long SQInteger; -typedef unsigned long SQUnsignedInteger; -typedef char SQChar; -typedef SQUnsignedInteger SQBool; - -typedef SQVM* HSQUIRRELVM; - -enum SQRESULT : SQInteger -{ - SQRESULT_ERROR = -1, - SQRESULT_NULL = 0, - SQRESULT_NOTNULL = 1, -}; - -enum class eSQReturnType -{ - Float = 0x1, - Vector = 0x3, - Integer = 0x5, - Boolean = 0x6, - Entity = 0xD, - String = 0x21, - Default = 0x20, - Arrays = 0x25, - Asset = 0x28, - Table = 0x26, -}; - -struct SQBufferState -{ - const SQChar* buffer; - const SQChar* bufferPlusLength; - const SQChar* bufferAgain; - - SQBufferState(const SQChar* pszCode) - { - buffer = pszCode; - bufferPlusLength = pszCode + strlen(pszCode); - bufferAgain = pszCode; - } -}; - -typedef SQRESULT (*SQFunction)(HSQUIRRELVM sqvm); - -struct SQFuncRegistration -{ - const char* squirrelFuncName; - const char* cppFuncName; - const char* helpText; - const char* returnTypeString; - const char* argTypes; - uint32_t unknown1; - uint32_t devLevel; - const char* shortNameMaybe; - uint32_t unknown2; - eSQReturnType returnType; - uint32_t* externalBufferPointer; - uint64_t externalBufferSize; - uint64_t unknown3; - uint64_t unknown4; - SQFunction funcPtr; - - SQFuncRegistration() - { - memset(this, 0, sizeof(SQFuncRegistration)); - this->returnType = eSQReturnType::Default; - } -}; - -struct alignas(8) SQStackInfos -{ - char* _name; - char* _sourceName; - int _line; -}; diff --git a/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h b/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h deleted file mode 100644 index 3214dc81d..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqarray.h +++ /dev/null @@ -1,12 +0,0 @@ -#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 deleted file mode 100644 index 85c3adef0..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqclosure.h +++ /dev/null @@ -1,29 +0,0 @@ -#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 deleted file mode 100644 index 5a54751ca..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqcompiler.h +++ /dev/null @@ -1,26 +0,0 @@ -#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 deleted file mode 100644 index 77bec7ebe..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqfunctionproto.h +++ /dev/null @@ -1,24 +0,0 @@ -#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 deleted file mode 100644 index dc19bea8f..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqlexer.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 deleted file mode 100644 index ea5c0da96..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqobject.h +++ /dev/null @@ -1,93 +0,0 @@ -#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 deleted file mode 100644 index be0756c1d..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqopcodes.h +++ /dev/null @@ -1,13 +0,0 @@ -#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 deleted file mode 100644 index d5282ac7f..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqstate.h +++ /dev/null @@ -1,120 +0,0 @@ -#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 deleted file mode 100644 index 5b17f489c..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqstring.h +++ /dev/null @@ -1,15 +0,0 @@ -#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 deleted file mode 100644 index 1e357df8a..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqstruct.h +++ /dev/null @@ -1,24 +0,0 @@ -#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 deleted file mode 100644 index e0ced4362..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqtable.h +++ /dev/null @@ -1,21 +0,0 @@ -#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 deleted file mode 100644 index 98ede8878..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/squserdata.h +++ /dev/null @@ -1,15 +0,0 @@ -#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 deleted file mode 100644 index 63984e909..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqvector.h +++ /dev/null @@ -1,12 +0,0 @@ -#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 deleted file mode 100644 index d16092e7b..000000000 --- a/primedev/vscript/languages/squirrel_re/squirrel/sqvm.h +++ /dev/null @@ -1,69 +0,0 @@ -#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; -}; diff --git a/primedev/vscript/languages/squirrel_re/vsquirrel.h b/primedev/vscript/languages/squirrel_re/vsquirrel.h deleted file mode 100644 index 43be685ee..000000000 --- a/primedev/vscript/languages/squirrel_re/vsquirrel.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -struct CSquirrelVM -{ - BYTE gap_0[8]; - HSQUIRRELVM sqvm; - BYTE gap_10[8]; - SQObject unknownObject_18; - __int64 unknown_28; - BYTE gap_30[12]; - __int32 vmContext; - BYTE gap_40[648]; - char* (*formatString)(__int64 a1, const char* format, ...); - BYTE gap_2D0[24]; -}; -static_assert(sizeof(CSquirrelVM) == 744); diff --git a/primedev/vscript/vscript.h b/primedev/vscript/vscript.h deleted file mode 100644 index 4c9f072a9..000000000 --- a/primedev/vscript/vscript.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "vscript/languages/squirrel_re/include/squirrel.h" - -#include "vscript/languages/squirrel_re/squirrel/sqarray.h" -#include "vscript/languages/squirrel_re/squirrel/sqclosure.h" -#include "vscript/languages/squirrel_re/squirrel/sqcompiler.h" -#include "vscript/languages/squirrel_re/squirrel/sqfunctionproto.h" -#include "vscript/languages/squirrel_re/squirrel/sqlexer.h" -#include "vscript/languages/squirrel_re/squirrel/sqobject.h" -#include "vscript/languages/squirrel_re/squirrel/sqopcodes.h" -#include "vscript/languages/squirrel_re/squirrel/sqstate.h" -#include "vscript/languages/squirrel_re/squirrel/sqstring.h" -#include "vscript/languages/squirrel_re/squirrel/sqstruct.h" -#include "vscript/languages/squirrel_re/squirrel/sqtable.h" -#include "vscript/languages/squirrel_re/squirrel/squserdata.h" -#include "vscript/languages/squirrel_re/squirrel/sqvector.h" -#include "vscript/languages/squirrel_re/squirrel/sqvm.h" - -#include "vscript/languages/squirrel_re/vsquirrel.h"