aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-19 02:18:24 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-19 02:18:24 +0100
commited7e4fed4ddedaf9d4c181052ca552a0914d57bb (patch)
tree0d451e40d82b0513c4f2acd42ea750638b1d4c88
parent9b8a6d155a7a2cf1bfb4e8d98980bfb0b6e94d92 (diff)
downloadNorthstarLauncher-ed7e4fed4ddedaf9d4c181052ca552a0914d57bb.tar.gz
NorthstarLauncher-ed7e4fed4ddedaf9d4c181052ca552a0914d57bb.zip
add masterserver mod list support and fix some squirrel issues
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj4
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters4
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp5
-rw-r--r--NorthstarDedicatedTest/gameutils.cpp8
-rw-r--r--NorthstarDedicatedTest/gameutils.h7
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp59
-rw-r--r--NorthstarDedicatedTest/masterserver.h8
-rw-r--r--NorthstarDedicatedTest/miscserverscript.cpp65
-rw-r--r--NorthstarDedicatedTest/miscserverscript.h1
-rw-r--r--NorthstarDedicatedTest/scriptmodmenu.cpp19
-rw-r--r--NorthstarDedicatedTest/scriptserverbrowser.cpp63
-rw-r--r--NorthstarDedicatedTest/serverauthentication.cpp2
-rw-r--r--NorthstarDedicatedTest/serverscriptpersistence.cpp30
-rw-r--r--NorthstarDedicatedTest/serverscriptpersistence.h1
-rw-r--r--NorthstarDedicatedTest/squirrel.cpp10
-rw-r--r--NorthstarDedicatedTest/squirrel.h9
16 files changed, 238 insertions, 57 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index f0d10de3..4997b322 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -316,7 +316,7 @@
<ClInclude Include="modmanager.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="playlist.h" />
- <ClInclude Include="serverscriptpersistence.h" />
+ <ClInclude Include="miscserverscript.h" />
<ClInclude Include="securitypatches.h" />
<ClInclude Include="scriptmodmenu.h" />
<ClInclude Include="scriptserverbrowser.h" />
@@ -358,7 +358,7 @@
<ClCompile Include="scriptserverbrowser.cpp" />
<ClCompile Include="scriptsrson.cpp" />
<ClCompile Include="serverauthentication.cpp" />
- <ClCompile Include="serverscriptpersistence.cpp" />
+ <ClCompile Include="miscserverscript.cpp" />
<ClCompile Include="sigscanning.cpp" />
<ClCompile Include="sourceconsole.cpp" />
<ClCompile Include="sourceinterface.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 8d39b3bd..99f45f39 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -576,7 +576,7 @@
<ClInclude Include="misccommands.h">
<Filter>Header Files\Shared\Convar</Filter>
</ClInclude>
- <ClInclude Include="serverscriptpersistence.h">
+ <ClInclude Include="miscserverscript.h">
<Filter>Header Files\Server</Filter>
</ClInclude>
</ItemGroup>
@@ -668,7 +668,7 @@
<ClCompile Include="misccommands.cpp">
<Filter>Source Files\Shared\Convar</Filter>
</ClCompile>
- <ClCompile Include="serverscriptpersistence.cpp">
+ <ClCompile Include="miscserverscript.cpp">
<Filter>Source Files\Server</Filter>
</ClCompile>
</ItemGroup>
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index cb3477e0..bc1bfd77 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -20,7 +20,7 @@
#include "modlocalisation.h"
#include "playlist.h"
#include "securitypatches.h"
-#include "serverscriptpersistence.h"
+#include "miscserverscript.h"
bool initialised = false;
@@ -66,6 +66,7 @@ void InitialiseNorthstar()
AddDllLoadCallback("engine.dll", WaitForDebugger);
AddDllLoadCallback("engine.dll", InitialiseEngineGameUtilFunctions);
+ AddDllLoadCallback("server.dll", InitialiseServerGameUtilFunctions);
AddDllLoadCallback("engine.dll", InitialiseEngineSpewFuncHooks);
// dedi patches
@@ -92,7 +93,7 @@ void InitialiseNorthstar()
AddDllLoadCallback("server.dll", InitialiseServerSquirrel);
AddDllLoadCallback("engine.dll", InitialiseServerAuthentication);
AddDllLoadCallback("engine.dll", InitialiseSharedMasterServer);
- AddDllLoadCallback("server.dll", InitialiseServerScriptPersistence);
+ AddDllLoadCallback("server.dll", InitialiseMiscServerScriptCommand);
AddDllLoadCallback("engine.dll", InitialisePlaylistHooks);
diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp
index f940ff1b..984bc28a 100644
--- a/NorthstarDedicatedTest/gameutils.cpp
+++ b/NorthstarDedicatedTest/gameutils.cpp
@@ -23,6 +23,9 @@ SetCurrentPlaylistType SetCurrentPlaylist;
SetPlaylistVarOverrideType SetPlaylistVarOverride;
GetCurrentPlaylistVarType GetCurrentPlaylistVar;
+// server entity stuff
+Server_GetEntityByIndexType Server_GetEntityByIndex;
+
// uid
char* g_LocalPlayerUserID;
@@ -44,3 +47,8 @@ void InitialiseEngineGameUtilFunctions(HMODULE baseAddress)
g_LocalPlayerUserID = (char*)baseAddress + 0x13F8E688;
}
+
+void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
+{
+ Server_GetEntityByIndex = (Server_GetEntityByIndexType)((char*)baseAddress + 0xFB820);
+} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/gameutils.h b/NorthstarDedicatedTest/gameutils.h
index 188ec3bf..c861eb22 100644
--- a/NorthstarDedicatedTest/gameutils.h
+++ b/NorthstarDedicatedTest/gameutils.h
@@ -181,7 +181,12 @@ extern SetPlaylistVarOverrideType SetPlaylistVarOverride;
typedef char*(*GetCurrentPlaylistVarType)(const char* varName, bool useOverrides);
extern GetCurrentPlaylistVarType GetCurrentPlaylistVar;
+// server entity stuff
+typedef void*(*Server_GetEntityByIndexType)(int index);
+extern Server_GetEntityByIndexType Server_GetEntityByIndex;
+
// uid
extern char* g_LocalPlayerUserID;
-void InitialiseEngineGameUtilFunctions(HMODULE baseAddress); \ No newline at end of file
+void InitialiseEngineGameUtilFunctions(HMODULE baseAddress);
+void InitialiseServerGameUtilFunctions(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 4597213c..3072b6b2 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -7,7 +7,10 @@
#include "serverauthentication.h"
#include "gameutils.h"
#include "rapidjson/document.h"
+#include "rapidjson/stringbuffer.h"
+#include "rapidjson/writer.h"
#include "rapidjson/error/en.h"
+#include "modmanager.h"
ConVar* Cvar_ns_masterserver_hostname;
ConVar* Cvar_ns_masterserver_port;
@@ -130,7 +133,8 @@ void MasterServerManager::RequestServerList()
|| !serverObj.HasMember("playlist") || !serverObj["playlist"].IsString()
|| !serverObj.HasMember("playerCount") || !serverObj["playerCount"].IsNumber()
|| !serverObj.HasMember("maxPlayers") || !serverObj["maxPlayers"].IsNumber()
- || !serverObj.HasMember("hasPassword") || !serverObj["hasPassword"].IsBool())
+ || !serverObj.HasMember("hasPassword") || !serverObj["hasPassword"].IsBool()
+ || !serverObj.HasMember("modInfo") || !serverObj["modInfo"].HasMember("Mods") || !serverObj["modInfo"]["Mods"].IsArray() )
{
spdlog::error("Failed reading masterserver response: malformed server object");
goto REQUEST_END_CLEANUP;
@@ -138,6 +142,8 @@ void MasterServerManager::RequestServerList()
const char* id = serverObj["id"].GetString();
+ RemoteServerInfo* newServer = nullptr;
+
bool createNewServerInfo = true;
for (RemoteServerInfo& server : m_remoteServers)
{
@@ -145,6 +151,7 @@ void MasterServerManager::RequestServerList()
if (!strncmp((const char*)server.id, id, 32))
{
server = RemoteServerInfo(id, serverObj["name"].GetString(), serverObj["description"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), serverObj["playerCount"].GetInt(), serverObj["maxPlayers"].GetInt(), serverObj["hasPassword"].IsTrue());
+ newServer = &server;
createNewServerInfo = false;
break;
}
@@ -152,7 +159,23 @@ void MasterServerManager::RequestServerList()
// server didn't exist
if (createNewServerInfo)
- m_remoteServers.emplace_back(id, serverObj["name"].GetString(), serverObj["description"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), serverObj["playerCount"].GetInt(), serverObj["maxPlayers"].GetInt(), serverObj["hasPassword"].IsTrue());
+ newServer = &m_remoteServers.emplace_back(id, serverObj["name"].GetString(), serverObj["description"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), serverObj["playerCount"].GetInt(), serverObj["maxPlayers"].GetInt(), serverObj["hasPassword"].IsTrue());
+
+ newServer->requiredMods.clear();
+ for (auto& requiredMod : serverObj["modInfo"]["Mods"].GetArray())
+ {
+ RemoteModInfo modInfo;
+
+ if (!requiredMod.HasMember("Name") || !requiredMod["Name"].IsString())
+ continue;
+ modInfo.Name = requiredMod["Name"].GetString();
+
+ if (!requiredMod.HasMember("Version") || !requiredMod["Version"].IsString())
+ continue;
+ modInfo.Version = requiredMod["Version"].GetString();
+
+ newServer->requiredMods.push_back(modInfo);
+ }
spdlog::info("Server {} on map {} with playlist {} has {}/{} players", serverObj["name"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), serverObj["playerCount"].GetInt(), serverObj["maxPlayers"].GetInt());
}
@@ -378,7 +401,35 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
else
request = fmt::format("/server/add_server?port={}&authPort={}&name={}&description={}&map={}&playlist={}&maxPlayers={}&password=", port, authPort, name, description, map, playlist, maxPlayers);
- if (auto result = http.Post(request.c_str()))
+ // build modinfo obj
+ rapidjson::Document modinfoDoc;
+ modinfoDoc.SetObject();
+ modinfoDoc.AddMember("Mods", rapidjson::Value(rapidjson::kArrayType), modinfoDoc.GetAllocator());
+
+ int currentModIndex = 0;
+ for (Mod* mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod->RequiredOnClient)
+ continue;
+
+ modinfoDoc["Mods"].PushBack(rapidjson::Value(rapidjson::kObjectType), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("Name", rapidjson::StringRef(mod->Name.c_str()), modinfoDoc.GetAllocator());
+ modinfoDoc["Mods"][currentModIndex].AddMember("Version", rapidjson::StringRef(mod->Version.c_str()), modinfoDoc.GetAllocator());
+
+ currentModIndex++;
+ }
+
+ rapidjson::StringBuffer buffer;
+ buffer.Clear();
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+ modinfoDoc.Accept(writer);
+ const char* modInfoString = buffer.GetString();
+
+ httplib::MultipartFormDataItems requestItems = {
+ {"modinfo", std::string(modInfoString, buffer.GetSize()), "modinfo.json", "application/octet-stream"}
+ };
+
+ if (auto result = http.Post(request.c_str(), requestItems))
{
m_successfullyConnected = true;
@@ -506,7 +557,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata,
http.set_connection_timeout(10);
httplib::MultipartFormDataItems requestItems = {
- { "pdata", std::string(&pdata[0], pdataSize), "file.pdata", "application/octet-stream"}
+ { "pdata", std::string(pdata, pdataSize), "file.pdata", "application/octet-stream"}
};
// we dont process this at all atm, maybe do later, but atm not necessary
diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h
index 67f9a96f..a2a6d1f2 100644
--- a/NorthstarDedicatedTest/masterserver.h
+++ b/NorthstarDedicatedTest/masterserver.h
@@ -2,11 +2,11 @@
#include "convar.h"
#include <WinSock2.h>
-struct RemoteServerModInfo
+struct RemoteModInfo
{
public:
- std::string modName;
- std::string modServer;
+ std::string Name;
+ std::string Version;
};
class RemoteServerInfo
@@ -19,7 +19,7 @@ public:
std::string description;
char map[32];
char playlist[16];
- std::vector<RemoteServerModInfo> requiredMods;
+ std::vector<RemoteModInfo> requiredMods;
int playerCount;
int maxPlayers;
diff --git a/NorthstarDedicatedTest/miscserverscript.cpp b/NorthstarDedicatedTest/miscserverscript.cpp
new file mode 100644
index 00000000..dd4c7101
--- /dev/null
+++ b/NorthstarDedicatedTest/miscserverscript.cpp
@@ -0,0 +1,65 @@
+#include "pch.h"
+#include "miscserverscript.h"
+#include "squirrel.h"
+#include "masterserver.h"
+#include "serverauthentication.h"
+#include "gameutils.h"
+
+// annoying helper function because i can't figure out getting players or entities from sqvm rn
+// wish i didn't have to do it like this, but here we are
+void* GetPlayerByIndex(int playerIndex)
+{
+ const int PLAYER_ARRAY_OFFSET = 0x12A53F90;
+ const int PLAYER_SIZE = 0x2D728;
+
+ void* playerArrayBase = (char*)GetModuleHandleA("engine.dll") + PLAYER_ARRAY_OFFSET;
+ void* player = (char*)playerArrayBase + (playerIndex * PLAYER_SIZE);
+
+ return player;
+}
+
+// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
+SQInteger SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
+{
+ int playerIndex = ServerSq_getinteger(sqvm, 1);
+ void* player = GetPlayerByIndex(playerIndex);
+
+ if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
+ {
+ ServerSq_pusherror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ return -1;
+ }
+
+ g_ServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
+ g_ServerAuthenticationManager->WritePersistentData(player);
+ return 0;
+}
+
+// bool function NSIsWritingPlayerPersistence()
+SQInteger SQ_IsWritingPlayerPersistence(void* sqvm)
+{
+ ServerSq_pushbool(sqvm, g_MasterServerManager->m_savingPersistentData);
+ return 1;
+}
+
+// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
+SQInteger SQ_IsPlayerIndexLocalPlayer(void* sqvm)
+{
+ int playerIndex = ServerSq_getinteger(sqvm, 1);
+ void* player = GetPlayerByIndex(playerIndex);
+ if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
+ {
+ ServerSq_pusherror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ return -1;
+ }
+
+ ServerSq_pushbool(sqvm, !strcmp(g_LocalPlayerUserID, (char*)player + 0xF500));
+ return 1;
+}
+
+void InitialiseMiscServerScriptCommand(HMODULE baseAddress)
+{
+ g_ServerSquirrelManager->AddFuncRegistration("void", "NSEarlyWritePlayerIndexPersistenceForLeave", "int playerIndex", "", SQ_EarlyWritePlayerIndexPersistenceForLeave);
+ g_ServerSquirrelManager->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
+ g_ServerSquirrelManager->AddFuncRegistration("bool", "NSIsPlayerIndexLocalPlayer", "int playerIndex", "", SQ_IsPlayerIndexLocalPlayer);
+} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/miscserverscript.h b/NorthstarDedicatedTest/miscserverscript.h
new file mode 100644
index 00000000..b3e0580a
--- /dev/null
+++ b/NorthstarDedicatedTest/miscserverscript.h
@@ -0,0 +1 @@
+void InitialiseMiscServerScriptCommand(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/scriptmodmenu.cpp b/NorthstarDedicatedTest/scriptmodmenu.cpp
index 74319f56..c17b23db 100644
--- a/NorthstarDedicatedTest/scriptmodmenu.cpp
+++ b/NorthstarDedicatedTest/scriptmodmenu.cpp
@@ -127,6 +127,24 @@ SQInteger SQ_GetModLoadPriority(void* sqvm)
return 0; // return null
}
+// bool NSIsModRequiredOnClient(string modName)
+SQInteger SQ_IsModRequiredOnClient(void* sqvm)
+{
+ const SQChar* modName = ClientSq_getstring(sqvm, 1);
+
+ // manual lookup, not super performant but eh not a big deal
+ for (Mod* mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod->Name.compare(modName))
+ {
+ ClientSq_pushbool(sqvm, mod->RequiredOnClient);
+ return 1;
+ }
+ }
+
+ return 0; // return null
+}
+
// array<string> NSGetModConvarsByModName(string modName)
SQInteger SQ_GetModConvars(void* sqvm)
{
@@ -169,6 +187,7 @@ void InitialiseScriptModMenu(HMODULE baseAddress)
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModDescriptionByModName", "string modName", "Returns a given mod's description", SQ_GetModDescription);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModVersionByModName", "string modName", "Returns a given mod's version", SQ_GetModVersion);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetModDownloadLinkByModName", "string modName", "Returns a given mod's download link", SQ_GetModDownloadLink);
+ g_UISquirrelManager->AddFuncRegistration("bool", "NSIsModRequiredOnClient", "string modName", "Returns whether a given mod is required on connecting clients", SQ_IsModEnabled);
g_UISquirrelManager->AddFuncRegistration("int", "NSGetModLoadPriority", "string modName", "Returns a given mod's load priority", SQ_GetModLoadPriority);
g_UISquirrelManager->AddFuncRegistration("array<string>", "NSGetModConvarsByModName", "string modName", "Returns the names of all a given mod's cvars", SQ_GetModConvars);
diff --git a/NorthstarDedicatedTest/scriptserverbrowser.cpp b/NorthstarDedicatedTest/scriptserverbrowser.cpp
index 588dff23..de2b3281 100644
--- a/NorthstarDedicatedTest/scriptserverbrowser.cpp
+++ b/NorthstarDedicatedTest/scriptserverbrowser.cpp
@@ -141,6 +141,7 @@ SQInteger SQ_GetServerID(void* sqvm)
return 1;
}
+// bool function NSServerRequiresPassword( int serverIndex )
SQInteger SQ_ServerRequiresPassword(void* sqvm)
{
SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
@@ -155,6 +156,65 @@ SQInteger SQ_ServerRequiresPassword(void* sqvm)
return 1;
}
+// int function NSGetServerRequiredModsCount( int serverIndex )
+SQInteger SQ_GetServerRequiredModsCount(void* sqvm)
+{
+ SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+
+ if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
+ {
+ spdlog::warn("Tried to get required mods count of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
+ return 0;
+ }
+
+ ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size());
+ return 1;
+}
+
+// string function NSGetServerRequiredModName( int serverIndex, int modIndex )
+SQInteger SQ_GetServerRequiredModName(void* sqvm)
+{
+ SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger modIndex = ClientSq_getinteger(sqvm, 2);
+
+ if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
+ {
+ spdlog::warn("Tried to get hasPassword of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
+ return 0;
+ }
+
+ if (modIndex >= g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size())
+ {
+ spdlog::warn("Tried to get required mod name of mod index {} when only {} mod are available", modIndex, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size());
+ return 0;
+ }
+
+ ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods[modIndex].Name.c_str(), -1);
+ return 1;
+}
+
+// string function NSGetServerRequiredModVersion( int serverIndex, int modIndex )
+SQInteger SQ_GetServerRequiredModVersion(void* sqvm)
+{
+ SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger modIndex = ClientSq_getinteger(sqvm, 2);
+
+ if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
+ {
+ spdlog::warn("Tried to get required mod version of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
+ return 0;
+ }
+
+ if (modIndex >= g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size())
+ {
+ spdlog::warn("Tried to get required mod version of mod index {} when only {} mod are available", modIndex, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size());
+ return 0;
+ }
+
+ ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods[modIndex].Version.c_str(), -1);
+ return 1;
+}
+
// void function NSClearRecievedServerList()
SQInteger SQ_ClearRecievedServerList(void* sqvm)
{
@@ -260,6 +320,9 @@ void InitialiseScriptServerBrowser(HMODULE baseAddress)
g_UISquirrelManager->AddFuncRegistration("int", "NSGetServerMaxPlayerCount", "int serverIndex", "", SQ_GetServerMaxPlayerCount);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerID", "int serverIndex", "", SQ_GetServerID);
g_UISquirrelManager->AddFuncRegistration("bool", "NSServerRequiresPassword", "int serverIndex", "", SQ_ServerRequiresPassword);
+ g_UISquirrelManager->AddFuncRegistration("int", "NSGetServerRequiredModsCount", "int serverIndex", "", SQ_GetServerRequiredModsCount);
+ g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerRequiredModName", "int serverIndex, int modIndex", "", SQ_GetServerRequiredModName);
+ g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerRequiredModVersion", "int serverIndex, int modIndex", "", SQ_GetServerRequiredModVersion);
g_UISquirrelManager->AddFuncRegistration("void", "NSTryAuthWithServer", "int serverIndex, string password = \"\"", "", SQ_TryAuthWithServer);
g_UISquirrelManager->AddFuncRegistration("bool", "NSIsAuthenticatingWithServer", "", "", SQ_IsAuthComplete);
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp
index fe3c6183..d7fb1542 100644
--- a/NorthstarDedicatedTest/serverauthentication.cpp
+++ b/NorthstarDedicatedTest/serverauthentication.cpp
@@ -257,7 +257,7 @@ void CBaseClient__DisconnectHook(void* self, uint32_t unknownButAlways1, const c
if (strcmp(reason, "Connection closing"))
{
// dcing, write persistent data
- if (!g_ServerAuthenticationManager->m_additionalPlayerData[self].needPersistenceWriteOnLeave)
+ if (g_ServerAuthenticationManager->m_additionalPlayerData[self].needPersistenceWriteOnLeave)
g_ServerAuthenticationManager->WritePersistentData(self);
g_ServerAuthenticationManager->RemovePlayerAuthData(self); // won't do anything 99% of the time, but just in case
}
diff --git a/NorthstarDedicatedTest/serverscriptpersistence.cpp b/NorthstarDedicatedTest/serverscriptpersistence.cpp
deleted file mode 100644
index 4f7bba88..00000000
--- a/NorthstarDedicatedTest/serverscriptpersistence.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "pch.h"
-#include "serverscriptpersistence.h"
-#include "squirrel.h"
-#include "masterserver.h"
-#include "serverauthentication.h"
-
-// void function NSEarlyWritePlayerPersistenceForLeave( entity player )
-SQInteger SQ_EarlyWritePlayerPersistenceForLeave(void* sqvm)
-{
- void* player;
- if (!ServerSq_getentity(sqvm, &player) || !g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
- return 0;
-
- g_ServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
- g_ServerAuthenticationManager->WritePersistentData(player);
- return 0;
-}
-
-// bool function NSIsWritingPlayerPersistence()
-SQInteger SQ_IsWritingPlayerPersistence(void* sqvm)
-{
- ServerSq_pushbool(sqvm, g_MasterServerManager->m_savingPersistentData);
- return 1;
-}
-
-void InitialiseServerScriptPersistence(HMODULE baseAddress)
-{
- g_ServerSquirrelManager->AddFuncRegistration("void", "NSEarlyWritePlayerPersistenceForLeave", "entity player", "", SQ_EarlyWritePlayerPersistenceForLeave);
- g_ServerSquirrelManager->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
-} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/serverscriptpersistence.h b/NorthstarDedicatedTest/serverscriptpersistence.h
deleted file mode 100644
index c4eb863f..00000000
--- a/NorthstarDedicatedTest/serverscriptpersistence.h
+++ /dev/null
@@ -1 +0,0 @@
-void InitialiseServerScriptPersistence(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp
index f8d8cd33..5d8d69a2 100644
--- a/NorthstarDedicatedTest/squirrel.cpp
+++ b/NorthstarDedicatedTest/squirrel.cpp
@@ -70,6 +70,9 @@ sq_pushfloatType ServerSq_pushfloat;
sq_pushboolType ClientSq_pushbool;
sq_pushboolType ServerSq_pushbool;
+sq_pusherrorType ClientSq_pusherror;
+sq_pusherrorType ServerSq_pusherror;
+
// sq stack get funcs
sq_getstringType ClientSq_getstring;
@@ -84,9 +87,6 @@ sq_getfloatType ServerSq_getfloat;
sq_getboolType ClientSq_getbool;
sq_getboolType ServerSq_getbool;
-sq_getentityType ClientSq_getentity;
-sq_getentityType ServerSq_getentity;
-
template<Context context> void ExecuteCodeCommand(const CCommand& args);
@@ -132,12 +132,12 @@ void InitialiseClientSquirrel(HMODULE baseAddress)
ClientSq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
ClientSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
ClientSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
+ ClientSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8470);
ClientSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60C0);
ClientSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60E0);
ClientSq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x6100);
ClientSq_getbool = (sq_getboolType)((char*)baseAddress + 0x6130);
- ClientSq_getentity = (sq_getentityType)((char*)baseAddress + 0x12F80);
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x26130, &CreateNewVMHook<CLIENT>, reinterpret_cast<LPVOID*>(&ClientCreateNewVM)); // client createnewvm function
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x26E70, &DestroyVMHook<CLIENT>, reinterpret_cast<LPVOID*>(&ClientDestroyVM)); // client destroyvm function
@@ -163,12 +163,12 @@ void InitialiseServerSquirrel(HMODULE baseAddress)
ServerSq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
ServerSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
ServerSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
+ ServerSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8440);
ServerSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60A0);
ServerSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60C0);
ServerSq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x60E0);
ServerSq_getbool = (sq_getboolType)((char*)baseAddress + 0x6110);
- ServerSq_getentity = (sq_getentityType)((char*)baseAddress + 0x203B0);
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1FE90, &SQPrintHook<SERVER>, reinterpret_cast<LPVOID*>(&ServerSQPrint)); // server print function
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x260E0, &CreateNewVMHook<SERVER>, reinterpret_cast<LPVOID*>(&ServerCreateNewVM)); // server createnewvm function
diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h
index 48eba539..03622f5d 100644
--- a/NorthstarDedicatedTest/squirrel.h
+++ b/NorthstarDedicatedTest/squirrel.h
@@ -100,6 +100,10 @@ typedef void(*sq_pushboolType)(void* sqvm, SQBool b);
extern sq_pushboolType ClientSq_pushbool;
extern sq_pushboolType ServerSq_pushbool;
+typedef SQInteger(*sq_pusherrorType)(void* sqvm, const SQChar* error);
+extern sq_pusherrorType ClientSq_pusherror;
+extern sq_pusherrorType ServerSq_pusherror;
+
// sq stack get funcs
typedef const SQChar*(*sq_getstringType)(void* sqvm, SQInteger stackpos);
@@ -118,11 +122,6 @@ typedef SQBool(*sq_getboolType)(void*, SQInteger stackpos);
extern sq_getboolType ClientSq_getbool;
extern sq_getboolType ServerSq_getbool;
-typedef SQBool(*sq_getentityType)(void*, void** entity);
-extern sq_getentityType ClientSq_getentity;
-extern sq_getentityType ServerSq_getentity;
-
-
template<Context context> class SquirrelManager
{
private: