aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/scriptserverbrowser.cpp
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2022-11-26 10:33:39 +0100
committerGitHub <noreply@github.com>2022-11-26 04:33:39 -0500
commit3d7e310a3253ad41707217e77c62f1d8dcbc3a8b (patch)
tree9528666da9bddfffaaf7da184d3baded88f1ac4b /NorthstarDLL/scriptserverbrowser.cpp
parentc409332991d49a1ee5911a076852452cf1890659 (diff)
downloadNorthstarLauncher-3d7e310a3253ad41707217e77c62f1d8dcbc3a8b.tar.gz
NorthstarLauncher-3d7e310a3253ad41707217e77c62f1d8dcbc3a8b.zip
Parse and expose region field from JSON server list (#232)
* Add parsing region field from JSON server list * Add function to read server region from Squirrel * Update logic to post-refactor code * Make region field optional
Diffstat (limited to 'NorthstarDLL/scriptserverbrowser.cpp')
-rw-r--r--NorthstarDLL/scriptserverbrowser.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/NorthstarDLL/scriptserverbrowser.cpp b/NorthstarDLL/scriptserverbrowser.cpp
index e6066954..05f83269 100644
--- a/NorthstarDLL/scriptserverbrowser.cpp
+++ b/NorthstarDLL/scriptserverbrowser.cpp
@@ -217,6 +217,26 @@ ADD_SQFUNC("int", NSGetServerRequiredModsCount, "int serverIndex", "", ScriptCon
return SQRESULT_NOTNULL;
}
+ADD_SQFUNC("string", NSGetServerRegion, "int serverIndex", "", ScriptContext::UI)
+{
+ SQInteger serverIndex = g_pSquirrel<context>->getinteger(sqvm, 1);
+
+ if (serverIndex >= g_pMasterServerManager->m_vRemoteServers.size())
+ {
+ g_pSquirrel<context>->raiseerror(
+ sqvm,
+ fmt::format(
+ "Tried to get region of server index {} when only {} servers are available",
+ serverIndex,
+ g_pMasterServerManager->m_vRemoteServers.size())
+ .c_str());
+ return SQRESULT_ERROR;
+ }
+
+ g_pSquirrel<context>->pushstring(sqvm, g_pMasterServerManager->m_vRemoteServers[serverIndex].region, -1);
+ return SQRESULT_NOTNULL;
+}
+
ADD_SQFUNC("string", NSGetServerRequiredModName, "int serverIndex, int modIndex", "", ScriptContext::UI)
{
SQInteger serverIndex = g_pSquirrel<context>->getinteger(sqvm, 1);