diff options
Diffstat (limited to 'primedev/scripts')
-rw-r--r-- | primedev/scripts/scriptdatatables.cpp | 19 | ||||
-rw-r--r-- | primedev/scripts/scripthttprequesthandler.cpp | 10 | ||||
-rw-r--r-- | primedev/scripts/scriptjson.cpp | 12 | ||||
-rw-r--r-- | primedev/scripts/scriptjson.h | 2 |
4 files changed, 22 insertions, 21 deletions
diff --git a/primedev/scripts/scriptdatatables.cpp b/primedev/scripts/scriptdatatables.cpp index 5e685b48..b3c59921 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 <ScriptContext context> Datatable* (*SQ_GetDatatableInternal)(HSquirrelVM* sqvm); +template <ScriptContext context> Datatable* (*SQ_GetDatatableInternal)(HSQUIRRELVM sqvm); struct CSVData { @@ -70,10 +70,11 @@ REPLACE_SQFUNC(GetDataTable, (ScriptContext::UI | ScriptContext::CLIENT | Script g_pSquirrel<context>->raiseerror(sqvm, fmt::format("Asset \"{}\" doesn't start with \"datatable/\"", pAssetName).c_str()); return SQRESULT_ERROR; } - else if (!Cvar_ns_prefer_datatable_from_disk->GetBool() && g_pPakLoadManager->LoadFile(pAssetName)) + else if (!Cvar_ns_prefer_datatable_from_disk->GetBool() && g_pPakLoadManager->OpenFile(pAssetName)) + { return g_pSquirrel<context>->m_funcOriginals["GetDataTable"](sqvm); - // either we prefer disk datatables, or we're loading a datatable that wasn't found in rpak - else + } + else // either we prefer disk datatables, or we're loading a datatable that wasn't found in rpak { std::string sAssetPath(fmt::format("scripts/{}", pAssetName)); @@ -96,7 +97,7 @@ REPLACE_SQFUNC(GetDataTable, (ScriptContext::UI | ScriptContext::CLIENT | Script diskAssetPath /= fs::path(pAssetName); std::string sDiskAssetPath(diskAssetPath.string()); - if ((*g_pFilesystem)->m_vtable2->FileExists(&(*g_pFilesystem)->m_vtable2, sDiskAssetPath.c_str(), "GAME")) + if (g_pFilesystem->m_vtable2->FileExists(&g_pFilesystem->m_vtable2, sDiskAssetPath.c_str(), "GAME")) { std::string sTableCSV = ReadVPKFile(sDiskAssetPath.c_str()); if (!sTableCSV.size()) @@ -223,7 +224,7 @@ REPLACE_SQFUNC(GetDataTable, (ScriptContext::UI | ScriptContext::CLIENT | Script return SQRESULT_NOTNULL; } // the file doesn't exist on disk, check rpak if we haven't already - else if (Cvar_ns_prefer_datatable_from_disk->GetBool() && g_pPakLoadManager->LoadFile(pAssetName)) + else if (Cvar_ns_prefer_datatable_from_disk->GetBool() && g_pPakLoadManager->OpenFile(pAssetName)) return g_pSquirrel<context>->m_funcOriginals["GetDataTable"](sqvm); // the file doesn't exist at all, error else @@ -750,7 +751,7 @@ std::string DataTableToString(Datatable* datatable) void DumpDatatable(const char* pDatatablePath) { - Datatable* pDatatable = (Datatable*)g_pPakLoadManager->LoadFile(pDatatablePath); + Datatable* pDatatable = (Datatable*)g_pPakLoadManager->OpenFile(pDatatablePath); if (!pDatatable) { spdlog::error("couldn't load datatable {} (rpak containing it may not be loaded?)", pDatatablePath); @@ -852,12 +853,12 @@ void ConCommand_dump_datatables(const CCommand& args) ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CModule module)) { - SQ_GetDatatableInternal<ScriptContext::SERVER> = module.Offset(0x1250f0).RCast<Datatable* (*)(HSquirrelVM*)>(); + SQ_GetDatatableInternal<ScriptContext::SERVER> = module.Offset(0x1250f0).RCast<Datatable* (*)(HSQUIRRELVM)>(); } ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CModule module)) { - SQ_GetDatatableInternal<ScriptContext::CLIENT> = module.Offset(0x1C9070).RCast<Datatable* (*)(HSquirrelVM*)>(); + SQ_GetDatatableInternal<ScriptContext::CLIENT> = module.Offset(0x1C9070).RCast<Datatable* (*)(HSQUIRRELVM)>(); SQ_GetDatatableInternal<ScriptContext::UI> = SQ_GetDatatableInternal<ScriptContext::CLIENT>; } diff --git a/primedev/scripts/scripthttprequesthandler.cpp b/primedev/scripts/scripthttprequesthandler.cpp index 69828a5a..f45e83f0 100644 --- a/primedev/scripts/scripthttprequesthandler.cpp +++ b/primedev/scripts/scripthttprequesthandler.cpp @@ -450,7 +450,7 @@ template <ScriptContext context> int HttpRequestHandler::MakeHttpRequest(const H // int NS_InternalMakeHttpRequest(int method, string baseUrl, table<string, string> headers, table<string, string> queryParams, // string contentType, string body, int timeout, string userAgent) -template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM* sqvm) +template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSQUIRRELVM sqvm) { if (!g_httpRequestHandler || !g_httpRequestHandler->IsRunning()) { @@ -475,7 +475,7 @@ template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM SQTable* headerTable = sqvm->_stackOfCurrentFunction[3]._VAL.asTable; for (int idx = 0; idx < headerTable->_numOfNodes; ++idx) { - tableNode* node = &headerTable->_nodes[idx]; + SQTable::_HashNode* node = &headerTable->_nodes[idx]; if (node->key._Type == OT_STRING && node->val._Type == OT_ARRAY) { @@ -497,7 +497,7 @@ template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM SQTable* queryTable = sqvm->_stackOfCurrentFunction[4]._VAL.asTable; for (int idx = 0; idx < queryTable->_numOfNodes; ++idx) { - tableNode* node = &queryTable->_nodes[idx]; + SQTable::_HashNode* node = &queryTable->_nodes[idx]; if (node->key._Type == OT_STRING && node->val._Type == OT_ARRAY) { @@ -527,14 +527,14 @@ template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM } // bool NSIsHttpEnabled() -template <ScriptContext context> SQRESULT SQ_IsHttpEnabled(HSquirrelVM* sqvm) +template <ScriptContext context> SQRESULT SQ_IsHttpEnabled(HSQUIRRELVM sqvm) { g_pSquirrel<context>->pushbool(sqvm, !IsHttpDisabled()); return SQRESULT_NOTNULL; } // bool NSIsLocalHttpAllowed() -template <ScriptContext context> SQRESULT SQ_IsLocalHttpAllowed(HSquirrelVM* sqvm) +template <ScriptContext context> SQRESULT SQ_IsLocalHttpAllowed(HSQUIRRELVM sqvm) { g_pSquirrel<context>->pushbool(sqvm, IsLocalHttpAllowed()); return SQRESULT_NOTNULL; diff --git a/primedev/scripts/scriptjson.cpp b/primedev/scripts/scriptjson.cpp index 8959bf47..91553ae3 100644 --- a/primedev/scripts/scriptjson.cpp +++ b/primedev/scripts/scriptjson.cpp @@ -9,8 +9,8 @@ #undef GetObject // fuck microsoft developers #endif -template <ScriptContext context> void -DecodeJsonArray(HSquirrelVM* sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* arr) +template <ScriptContext context> +void DecodeJsonArray(HSQUIRRELVM sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* arr) { g_pSquirrel<context>->newarray(sqvm, 0); @@ -48,8 +48,8 @@ DecodeJsonArray(HSquirrelVM* sqvm, rapidjson::GenericValue<rapidjson::UTF8<char> } } -template <ScriptContext context> void -DecodeJsonTable(HSquirrelVM* sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* obj) +template <ScriptContext context> +void DecodeJsonTable(HSQUIRRELVM sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* obj) { g_pSquirrel<context>->newtable(sqvm); @@ -107,7 +107,7 @@ template <ScriptContext context> void EncodeJSONTable( { for (int i = 0; i < table->_numOfNodes; i++) { - tableNode* node = &table->_nodes[i]; + SQTable::_HashNode* node = &table->_nodes[i]; if (node->key._Type == OT_STRING) { rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>> newObj(rapidjson::kObjectType); @@ -240,7 +240,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<context>(table, &doc, doc.GetAllocator()); diff --git a/primedev/scripts/scriptjson.h b/primedev/scripts/scriptjson.h index b747106b..f766e3f0 100644 --- a/primedev/scripts/scriptjson.h +++ b/primedev/scripts/scriptjson.h @@ -10,4 +10,4 @@ template <ScriptContext context> void EncodeJSONTable( rapidjson::MemoryPoolAllocator<SourceAllocator>& allocator); template <ScriptContext context> void -DecodeJsonTable(HSquirrelVM* sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* obj); +DecodeJsonTable(HSQUIRRELVM sqvm, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>* obj); |