aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/scriptserverbrowser.cpp
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 /NorthstarDedicatedTest/scriptserverbrowser.cpp
parent9b8a6d155a7a2cf1bfb4e8d98980bfb0b6e94d92 (diff)
downloadNorthstarLauncher-ed7e4fed4ddedaf9d4c181052ca552a0914d57bb.tar.gz
NorthstarLauncher-ed7e4fed4ddedaf9d4c181052ca552a0914d57bb.zip
add masterserver mod list support and fix some squirrel issues
Diffstat (limited to 'NorthstarDedicatedTest/scriptserverbrowser.cpp')
-rw-r--r--NorthstarDedicatedTest/scriptserverbrowser.cpp63
1 files changed, 63 insertions, 0 deletions
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);