diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-09 22:21:46 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-09 22:21:46 +0100 |
commit | 9a3e1ec2daf753106ee95d53719d94921d3b051f (patch) | |
tree | 954d8b75530d66c15fcfcf153a3a4f351e49ef8e /NorthstarDedicatedTest/scriptserverbrowser.cpp | |
parent | 4d0e4679d05b146e5e43a1a707708c6451099c54 (diff) | |
download | NorthstarLauncher-9a3e1ec2daf753106ee95d53719d94921d3b051f.tar.gz NorthstarLauncher-9a3e1ec2daf753106ee95d53719d94921d3b051f.zip |
add mod localisation, say command and more masterserver stuff
Diffstat (limited to 'NorthstarDedicatedTest/scriptserverbrowser.cpp')
-rw-r--r-- | NorthstarDedicatedTest/scriptserverbrowser.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/scriptserverbrowser.cpp b/NorthstarDedicatedTest/scriptserverbrowser.cpp index 419ed274..c5446031 100644 --- a/NorthstarDedicatedTest/scriptserverbrowser.cpp +++ b/NorthstarDedicatedTest/scriptserverbrowser.cpp @@ -49,6 +49,21 @@ SQInteger SQ_GetServerName(void* sqvm) return 1; } +// string function NSGetServerDescription( int serverIndex ) +SQInteger SQ_GetServerDescription(void* sqvm) +{ + SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); + + if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + { + spdlog::warn("Tried to get description of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size()); + return 0; + } + + ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].description.c_str(), -1); + return 1; +} + // string function NSGetServerMap( int serverIndex ) SQInteger SQ_GetServerMap(void* sqvm) { @@ -79,6 +94,36 @@ SQInteger SQ_GetServerPlaylist(void* sqvm) return 1; } +// int function NSGetServerPlayerCount( int serverIndex ) +SQInteger SQ_GetServerPlayerCount(void* sqvm) +{ + SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); + + if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + { + spdlog::warn("Tried to get playercount of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size()); + return 0; + } + + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].playerCount); + return 1; +} + +// int function NSGetServerMaxPlayerCount( int serverIndex ) +SQInteger SQ_GetServerMaxPlayerCount(void* sqvm) +{ + SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); + + if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + { + spdlog::warn("Tried to get max playercount of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size()); + return 0; + } + + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].maxPlayers); + return 1; +} + // string function NSGetServerID( int serverIndex ) SQInteger SQ_GetServerID(void* sqvm) { @@ -131,7 +176,7 @@ SQInteger SQ_TryAuthWithServer(void* sqvm) } // do auth - g_MasterServerManager->TryAuthenticateWithServer(g_MasterServerManager->m_remoteServers[serverIndex].id, (char*)password); + g_MasterServerManager->AuthenticateWithServer(g_MasterServerManager->m_remoteServers[serverIndex].id, (char*)password); return 0; } @@ -181,8 +226,11 @@ void InitialiseScriptServerBrowser(HMODULE baseAddress) g_UISquirrelManager->AddFuncRegistration("void", "NSClearRecievedServerList", "", "", SQ_ClearRecievedServerList); g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerName", "int serverIndex", "", SQ_GetServerName); + g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerDescription", "int serverIndex", "", SQ_GetServerDescription); g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerMap", "int serverIndex", "", SQ_GetServerMap); g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerPlaylist", "int serverIndex", "", SQ_GetServerPlaylist); + g_UISquirrelManager->AddFuncRegistration("int", "NSGetServerPlayerCount", "int serverIndex", "", SQ_GetServerPlayerCount); + 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); |