diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-09 02:46:04 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-09 02:46:04 +0100 |
commit | 9ab7c43c34183915273cc8b5ccedd72568249b27 (patch) | |
tree | 6662f6f8d5a64bb86ec725faf48fe4c8cbe3eb70 /NorthstarDedicatedTest | |
parent | 503d336e9e695a0518f90f727f4a2fe4569615e6 (diff) | |
download | NorthstarLauncher-9ab7c43c34183915273cc8b5ccedd72568249b27.tar.gz NorthstarLauncher-9ab7c43c34183915273cc8b5ccedd72568249b27.zip |
fix debug crashes
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters | 10 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 4 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dllmain.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/hooks.cpp | 21 | ||||
-rw-r--r-- | NorthstarDedicatedTest/masterserver.cpp | 200 | ||||
-rw-r--r-- | NorthstarDedicatedTest/masterserver.h | 32 | ||||
-rw-r--r-- | NorthstarDedicatedTest/misccommands.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/miscserverscript.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/modmanager.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/playlist.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/plugins.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/scriptmainmenupromos.cpp | 26 | ||||
-rw-r--r-- | NorthstarDedicatedTest/scriptserverbrowser.cpp | 98 | ||||
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 2 |
15 files changed, 208 insertions, 203 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index ea9ccbb3..58afcd9f 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -75,6 +75,9 @@ <Command> </Command> </PreBuildEvent> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "D:\origin\titanfall\Titanfall2"</Command> + </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -105,6 +108,9 @@ <Command> </Command> </PreBuildEvent> + <PostBuildEvent> + <Command>copy /Y "$(TargetPath)" "D:\origin\titanfall\Titanfall2"</Command> + </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> <ClInclude Include="audio.h" /> diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index da8f064e..686493f8 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -25,9 +25,6 @@ <Filter Include="Source Files\Shared"> <UniqueIdentifier>{4f525372-34a8-40b3-8a95-81d77cdfcf7f}</UniqueIdentifier> </Filter> - <Filter Include="Source Files\Dedicated"> - <UniqueIdentifier>{947835db-67d6-42c0-870d-62743f85231f}</UniqueIdentifier> - </Filter> <Filter Include="Header Files\Dedicated"> <UniqueIdentifier>{8b8ed12a-9269-4dc3-b932-0daefdf6a388}</UniqueIdentifier> </Filter> @@ -133,6 +130,9 @@ <Filter Include="Source Files\Shared\Exploit Fixes\UTF8Parser"> <UniqueIdentifier>{b30e08b1-b962-4264-8cbb-a0a31924b93e}</UniqueIdentifier> </Filter> + <Filter Include="Source Files\Server\Dedicated"> + <UniqueIdentifier>{947835db-67d6-42c0-870d-62743f85231f}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClInclude Include="pch.h"> @@ -1527,7 +1527,7 @@ <Filter>Source Files\Shared\Hooks</Filter> </ClCompile> <ClCompile Include="dedicated.cpp"> - <Filter>Source Files\Dedicated</Filter> + <Filter>Source Files\Server\Dedicated</Filter> </ClCompile> <ClCompile Include="sourceconsole.cpp"> <Filter>Source Files\Client</Filter> @@ -1590,7 +1590,7 @@ <Filter>Source Files\Server</Filter> </ClCompile> <ClCompile Include="dedicatedmaterialsystem.cpp"> - <Filter>Source Files\Dedicated</Filter> + <Filter>Source Files\Server\Dedicated</Filter> </ClCompile> <ClCompile Include="misccommands.cpp"> <Filter>Source Files\Shared\Convar</Filter> diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index 8f43c506..9430b7a6 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -31,7 +31,7 @@ struct CDedicatedExports void Sys_Printf(CDedicatedExports* dedicated, const char* msg) { - spdlog::info("[DEDICATED PRINT] {}", msg); + spdlog::info("[DEDICATED SERVER] {}", msg); } typedef void (*CHostState__InitType)(CHostState* self); @@ -82,7 +82,7 @@ void RunServer(CDedicatedExports* dedicated) SetConsoleTitleA(fmt::format( "{} - {} {}/{} players ({})", - g_MasterServerManager->ns_auth_srvName, + g_MasterServerManager->m_sUnicodeServerName, g_pHostState->m_levelName, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers, diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp index 394370c2..01692ed4 100644 --- a/NorthstarDedicatedTest/dllmain.cpp +++ b/NorthstarDedicatedTest/dllmain.cpp @@ -181,8 +181,8 @@ bool InitialiseNorthstar() // Write launcher version to log spdlog::info("NorthstarLauncher version: {}", version); - AddDllLoadCallback("tier0.dll", InitialiseTier0GameUtilFunctions); AddDllLoadCallback("engine.dll", WaitForDebugger); + AddDllLoadCallback("tier0.dll", InitialiseTier0GameUtilFunctions); AddDllLoadCallback("engine.dll", InitialiseEngineGameUtilFunctions); AddDllLoadCallback("server.dll", InitialiseServerGameUtilFunctions); diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp index c566ca8d..7e697701 100644 --- a/NorthstarDedicatedTest/hooks.cpp +++ b/NorthstarDedicatedTest/hooks.cpp @@ -149,18 +149,17 @@ struct DllLoadCallback bool called; }; -bool how = false; -std::vector<DllLoadCallback> dllLoadCallbacks = std::vector<DllLoadCallback>(); +// for whatever reason, just declaring and initialising the vector at file scope crashes on debug builds +// but this works, idk sucks but just how it is +std::vector<DllLoadCallback>& GetDllLoadCallbacks() +{ + static std::vector<DllLoadCallback> vec = std::vector<DllLoadCallback>(); + return vec; +} void AddDllLoadCallback(std::string dll, DllLoadCallbackFuncType callback, std::string tag, std::string reliesOn) { - if (!how) // WHY IS THIS A THING WE NEED ON DEBUG????? - { - dllLoadCallbacks = std::vector<DllLoadCallback>(); - how = true; - } - - DllLoadCallback& callbackStruct = dllLoadCallbacks.emplace_back(); + DllLoadCallback& callbackStruct = GetDllLoadCallbacks().emplace_back(); // <-- crashes here callbackStruct.dll = dll; callbackStruct.callback = callback; @@ -194,7 +193,7 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress) { bool doneCalling = true; - for (auto& callbackStruct : dllLoadCallbacks) + for (auto& callbackStruct : GetDllLoadCallbacks()) { if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename()) { @@ -222,7 +221,7 @@ void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress) { bool doneCalling = true; - for (auto& callbackStruct : dllLoadCallbacks) + for (auto& callbackStruct : GetDllLoadCallbacks()) { if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename()) { diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp index 7767ea88..287b9e99 100644 --- a/NorthstarDedicatedTest/masterserver.cpp +++ b/NorthstarDedicatedTest/masterserver.cpp @@ -109,8 +109,8 @@ std::string unescape_unicode(const std::string& str) void UpdateServerInfoFromUnicodeToUTF8() { - g_MasterServerManager->ns_auth_srvName = unescape_unicode(Cvar_ns_server_name->GetString()); - g_MasterServerManager->ns_auth_srvDesc = unescape_unicode(Cvar_ns_server_desc->GetString()); + g_MasterServerManager->m_sUnicodeServerName = unescape_unicode(Cvar_ns_server_name->GetString()); + g_MasterServerManager->m_sUnicodeServerDesc = unescape_unicode(Cvar_ns_server_desc->GetString()); } const char* HttplibErrorToString(httplib::Error error) @@ -191,11 +191,11 @@ void MasterServerManager::SetCommonHttpClientOptions(CURL* curl) void MasterServerManager::ClearServerList() { // this doesn't really do anything lol, probably isn't threadsafe - m_requestingServerList = true; + m_bRequestingServerList = true; - m_remoteServers.clear(); + m_vRemoteServers.clear(); - m_requestingServerList = false; + m_bRequestingServerList = false; } size_t CurlWriteToStringBufferCallback(char* contents, size_t size, size_t nmemb, void* userp) @@ -234,7 +234,7 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document originAuthInfo; originAuthInfo.Parse(readBuffer.c_str()); @@ -255,8 +255,8 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or if (originAuthInfo["success"].IsTrue() && originAuthInfo.HasMember("token") && originAuthInfo["token"].IsString()) { - strncpy(m_ownClientAuthToken, originAuthInfo["token"].GetString(), sizeof(m_ownClientAuthToken)); - m_ownClientAuthToken[sizeof(m_ownClientAuthToken) - 1] = 0; + strncpy(m_sOwnClientAuthToken, originAuthInfo["token"].GetString(), sizeof(m_sOwnClientAuthToken)); + m_sOwnClientAuthToken[sizeof(m_sOwnClientAuthToken) - 1] = 0; spdlog::info("Northstar origin authentication completed successfully!"); } else @@ -265,7 +265,7 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or else { spdlog::error("Failed performing northstar origin auth: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; } // we goto this instead of returning so we always hit this @@ -281,18 +281,18 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or void MasterServerManager::RequestServerList() { // do this here so it's instantly set on call for scripts - m_scriptRequestingServerList = true; + m_bScriptRequestingServerList = true; std::thread requestThread( [this]() { // make sure we never have 2 threads writing at once // i sure do hope this is actually threadsafe - while (m_requestingServerList) + while (m_bRequestingServerList) Sleep(100); - m_requestingServerList = true; - m_scriptRequestingServerList = true; + m_bRequestingServerList = true; + m_bScriptRequestingServerList = true; spdlog::info("Requesting server list from {}", Cvar_ns_masterserver_hostname->GetString()); @@ -309,7 +309,7 @@ void MasterServerManager::RequestServerList() if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document serverInfoJson; serverInfoJson.Parse(readBuffer.c_str()); @@ -365,7 +365,7 @@ void MasterServerManager::RequestServerList() RemoteServerInfo* newServer = nullptr; bool createNewServerInfo = true; - for (RemoteServerInfo& server : m_remoteServers) + for (RemoteServerInfo& server : m_vRemoteServers) { // if server already exists, update info rather than adding to it if (!strncmp((const char*)server.id, id, 32)) @@ -387,7 +387,7 @@ void MasterServerManager::RequestServerList() // server didn't exist if (createNewServerInfo) - newServer = &m_remoteServers.emplace_back( + newServer = &m_vRemoteServers.emplace_back( id, serverObj["name"].GetString(), serverObj["description"].GetString(), @@ -424,20 +424,20 @@ void MasterServerManager::RequestServerList() } std::sort( - m_remoteServers.begin(), - m_remoteServers.end(), + m_vRemoteServers.begin(), + m_vRemoteServers.end(), [](RemoteServerInfo& a, RemoteServerInfo& b) { return a.playerCount > b.playerCount; }); } else { spdlog::error("Failed requesting servers: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; } // we goto this instead of returning so we always hit this REQUEST_END_CLEANUP: - m_requestingServerList = false; - m_scriptRequestingServerList = false; + m_bRequestingServerList = false; + m_bScriptRequestingServerList = false; curl_easy_cleanup(curl); }); @@ -468,7 +468,7 @@ void MasterServerManager::RequestMainMenuPromos() if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document mainMenuPromoJson; mainMenuPromoJson.Parse(readBuffer.c_str()); @@ -522,29 +522,29 @@ void MasterServerManager::RequestMainMenuPromos() goto REQUEST_END_CLEANUP; } - m_MainMenuPromoData.newInfoTitle1 = mainMenuPromoJson["newInfo"]["Title1"].GetString(); - m_MainMenuPromoData.newInfoTitle2 = mainMenuPromoJson["newInfo"]["Title2"].GetString(); - m_MainMenuPromoData.newInfoTitle3 = mainMenuPromoJson["newInfo"]["Title3"].GetString(); + m_sMainMenuPromoData.newInfoTitle1 = mainMenuPromoJson["newInfo"]["Title1"].GetString(); + m_sMainMenuPromoData.newInfoTitle2 = mainMenuPromoJson["newInfo"]["Title2"].GetString(); + m_sMainMenuPromoData.newInfoTitle3 = mainMenuPromoJson["newInfo"]["Title3"].GetString(); - m_MainMenuPromoData.largeButtonTitle = mainMenuPromoJson["largeButton"]["Title"].GetString(); - m_MainMenuPromoData.largeButtonText = mainMenuPromoJson["largeButton"]["Text"].GetString(); - m_MainMenuPromoData.largeButtonUrl = mainMenuPromoJson["largeButton"]["Url"].GetString(); - m_MainMenuPromoData.largeButtonImageIndex = mainMenuPromoJson["largeButton"]["ImageIndex"].GetInt(); + m_sMainMenuPromoData.largeButtonTitle = mainMenuPromoJson["largeButton"]["Title"].GetString(); + m_sMainMenuPromoData.largeButtonText = mainMenuPromoJson["largeButton"]["Text"].GetString(); + m_sMainMenuPromoData.largeButtonUrl = mainMenuPromoJson["largeButton"]["Url"].GetString(); + m_sMainMenuPromoData.largeButtonImageIndex = mainMenuPromoJson["largeButton"]["ImageIndex"].GetInt(); - m_MainMenuPromoData.smallButton1Title = mainMenuPromoJson["smallButton1"]["Title"].GetString(); - m_MainMenuPromoData.smallButton1Url = mainMenuPromoJson["smallButton1"]["Url"].GetString(); - m_MainMenuPromoData.smallButton1ImageIndex = mainMenuPromoJson["smallButton1"]["ImageIndex"].GetInt(); + m_sMainMenuPromoData.smallButton1Title = mainMenuPromoJson["smallButton1"]["Title"].GetString(); + m_sMainMenuPromoData.smallButton1Url = mainMenuPromoJson["smallButton1"]["Url"].GetString(); + m_sMainMenuPromoData.smallButton1ImageIndex = mainMenuPromoJson["smallButton1"]["ImageIndex"].GetInt(); - m_MainMenuPromoData.smallButton2Title = mainMenuPromoJson["smallButton2"]["Title"].GetString(); - m_MainMenuPromoData.smallButton2Url = mainMenuPromoJson["smallButton2"]["Url"].GetString(); - m_MainMenuPromoData.smallButton2ImageIndex = mainMenuPromoJson["smallButton2"]["ImageIndex"].GetInt(); + m_sMainMenuPromoData.smallButton2Title = mainMenuPromoJson["smallButton2"]["Title"].GetString(); + m_sMainMenuPromoData.smallButton2Url = mainMenuPromoJson["smallButton2"]["Url"].GetString(); + m_sMainMenuPromoData.smallButton2ImageIndex = mainMenuPromoJson["smallButton2"]["ImageIndex"].GetInt(); m_bHasMainMenuPromoData = true; } else { spdlog::error("Failed requesting main menu promos: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; } REQUEST_END_CLEANUP: @@ -558,12 +558,12 @@ void MasterServerManager::RequestMainMenuPromos() void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken) { // dont wait, just stop if we're trying to do 2 auth requests at once - if (m_authenticatingWithGameServer) + if (m_bAuthenticatingWithGameServer) return; - m_authenticatingWithGameServer = true; - m_scriptAuthenticatingWithGameServer = true; - m_successfullyAuthenticatedWithGameServer = false; + m_bAuthenticatingWithGameServer = true; + m_bScriptAuthenticatingWithGameServer = true; + m_bSuccessfullyAuthenticatedWithGameServer = false; std::string uidStr(uid); std::string tokenStr(playerToken); @@ -588,7 +588,7 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document authInfoJson; authInfoJson.Parse(readBuffer.c_str()); @@ -654,19 +654,19 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken g_ServerAuthenticationManager->m_authData.clear(); g_ServerAuthenticationManager->m_authData.insert(std::make_pair(authInfoJson["authToken"].GetString(), newAuthData)); - m_successfullyAuthenticatedWithGameServer = true; + m_bSuccessfullyAuthenticatedWithGameServer = true; } else { spdlog::error("Failed authenticating with own server: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; - m_successfullyAuthenticatedWithGameServer = false; - m_scriptAuthenticatingWithGameServer = false; + m_bSuccessfullyConnected = false; + m_bSuccessfullyAuthenticatedWithGameServer = false; + m_bScriptAuthenticatingWithGameServer = false; } REQUEST_END_CLEANUP: - m_authenticatingWithGameServer = false; - m_scriptAuthenticatingWithGameServer = false; + m_bAuthenticatingWithGameServer = false; + m_bScriptAuthenticatingWithGameServer = false; if (m_bNewgameAfterSelfAuth) { @@ -684,12 +684,12 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, char* serverId, char* password) { // dont wait, just stop if we're trying to do 2 auth requests at once - if (m_authenticatingWithGameServer) + if (m_bAuthenticatingWithGameServer) return; - m_authenticatingWithGameServer = true; - m_scriptAuthenticatingWithGameServer = true; - m_successfullyAuthenticatedWithGameServer = false; + m_bAuthenticatingWithGameServer = true; + m_bScriptAuthenticatingWithGameServer = true; + m_bSuccessfullyAuthenticatedWithGameServer = false; std::string uidStr(uid); std::string tokenStr(playerToken); @@ -700,7 +700,7 @@ void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, c [this, uidStr, tokenStr, serverIdStr, passwordStr]() { // esnure that any persistence saving is done, so we know masterserver has newest - while (m_savingPersistentData) + while (m_bSavingPersistentData) Sleep(100); spdlog::info("Attempting authentication with server of id \"{}\"", serverIdStr); @@ -735,7 +735,7 @@ void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, c if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document connectionInfoJson; connectionInfoJson.Parse(readBuffer.c_str()); @@ -782,20 +782,20 @@ void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, c strncpy(m_pendingConnectionInfo.authToken, connectionInfoJson["authToken"].GetString(), 31); m_pendingConnectionInfo.authToken[31] = 0; - m_hasPendingConnectionInfo = true; - m_successfullyAuthenticatedWithGameServer = true; + m_bHasPendingConnectionInfo = true; + m_bSuccessfullyAuthenticatedWithGameServer = true; } else { spdlog::error("Failed authenticating with server: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; - m_successfullyAuthenticatedWithGameServer = false; - m_scriptAuthenticatingWithGameServer = false; + m_bSuccessfullyConnected = false; + m_bSuccessfullyAuthenticatedWithGameServer = false; + m_bScriptAuthenticatingWithGameServer = false; } REQUEST_END_CLEANUP: - m_authenticatingWithGameServer = false; - m_scriptAuthenticatingWithGameServer = false; + m_bAuthenticatingWithGameServer = false; + m_bScriptAuthenticatingWithGameServer = false; curl_easy_cleanup(curl); }); @@ -825,8 +825,8 @@ void MasterServerManager::AddSelfToServerList( std::thread requestThread( [this, port, authPort, strName, strDescription, strMap, strPlaylist, maxPlayers, strPassword] { - m_ownServerId[0] = 0; - m_ownServerAuthToken[0] = 0; + m_sOwnServerId[0] = 0; + m_sOwnServerAuthToken[0] = 0; CURL* curl = curl_easy_init(); SetCommonHttpClientOptions(curl); @@ -839,7 +839,7 @@ void MasterServerManager::AddSelfToServerList( curl_mime* mime = curl_mime_init(curl); curl_mimepart* part = curl_mime_addpart(mime); - curl_mime_data(part, m_ownModInfoJson.c_str(), m_ownModInfoJson.size()); + curl_mime_data(part, m_sOwnModInfoJson.c_str(), m_sOwnModInfoJson.size()); curl_mime_name(part, "modinfo"); curl_mime_filename(part, "modinfo.json"); curl_mime_type(part, "application/json"); @@ -881,7 +881,7 @@ void MasterServerManager::AddSelfToServerList( if (result == CURLcode::CURLE_OK) { - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; rapidjson_document serverAddedJson; serverAddedJson.Parse(readBuffer.c_str()); @@ -920,11 +920,11 @@ void MasterServerManager::AddSelfToServerList( goto REQUEST_END_CLEANUP; } - strncpy(m_ownServerId, serverAddedJson["id"].GetString(), sizeof(m_ownServerId)); - m_ownServerId[sizeof(m_ownServerId) - 1] = 0; + strncpy(m_sOwnServerId, serverAddedJson["id"].GetString(), sizeof(m_sOwnServerId)); + m_sOwnServerId[sizeof(m_sOwnServerId) - 1] = 0; - strncpy(m_ownServerAuthToken, serverAddedJson["serverAuthToken"].GetString(), sizeof(m_ownServerAuthToken)); - m_ownServerAuthToken[sizeof(m_ownServerAuthToken) - 1] = 0; + strncpy(m_sOwnServerAuthToken, serverAddedJson["serverAuthToken"].GetString(), sizeof(m_sOwnServerAuthToken)); + m_sOwnServerAuthToken[sizeof(m_sOwnServerAuthToken) - 1] = 0; // heartbeat thread // ideally this should actually be done in main thread, rather than on it's own thread, so it'd stop if server freezes @@ -934,7 +934,7 @@ void MasterServerManager::AddSelfToServerList( Sleep(5000); // defensive check, as m_ownServer could be set to null during the Sleep(5000) above - if (!*m_ownServerId) + if (!*m_sOwnServerId) return; do @@ -951,8 +951,8 @@ void MasterServerManager::AddSelfToServerList( // send all registration info so we have all necessary info to reregister our server if masterserver goes down, // without a restart this isn't threadsafe :terror: { - char* escapedNameNew = curl_easy_escape(curl, g_MasterServerManager->ns_auth_srvName.c_str(), NULL); - char* escapedDescNew = curl_easy_escape(curl, g_MasterServerManager->ns_auth_srvDesc.c_str(), NULL); + char* escapedNameNew = curl_easy_escape(curl, g_MasterServerManager->m_sUnicodeServerName.c_str(), NULL); + char* escapedDescNew = curl_easy_escape(curl, g_MasterServerManager->m_sUnicodeServerDesc.c_str(), NULL); char* escapedMapNew = curl_easy_escape(curl, g_pHostState->m_levelName, NULL); char* escapedPlaylistNew = curl_easy_escape(curl, GetCurrentPlaylistName(), NULL); char* escapedPasswordNew = curl_easy_escape(curl, Cvar_ns_server_password->GetString(), NULL); @@ -970,7 +970,7 @@ void MasterServerManager::AddSelfToServerList( "update_values?id={}&port={}&authPort={}&name={}&description={}&map={}&playlist={}&playerCount={}&" "maxPlayers={}&password={}", Cvar_ns_masterserver_hostname->GetString(), - m_ownServerId, + m_sOwnServerId, Cvar_hostport->GetInt(), Cvar_ns_player_auth_port->GetInt(), escapedNameNew, @@ -992,7 +992,7 @@ void MasterServerManager::AddSelfToServerList( curl_mime* mime = curl_mime_init(curl); curl_mimepart* part = curl_mime_addpart(mime); - curl_mime_data(part, m_ownModInfoJson.c_str(), m_ownModInfoJson.size()); + curl_mime_data(part, m_sOwnModInfoJson.c_str(), m_sOwnModInfoJson.size()); curl_mime_name(part, "modinfo"); curl_mime_filename(part, "modinfo.json"); curl_mime_type(part, "application/json"); @@ -1002,7 +1002,7 @@ void MasterServerManager::AddSelfToServerList( CURLcode result = curl_easy_perform(curl); // defensive check, as m_ownServerId could be set to null before this request gets processed - if (!*m_ownServerId) + if (!*m_sOwnServerId) return; if (result == CURLcode::CURLE_OK) @@ -1014,17 +1014,17 @@ void MasterServerManager::AddSelfToServerList( { if (serverAddedJson.HasMember("id") && serverAddedJson["id"].IsString()) { - strncpy(m_ownServerId, serverAddedJson["id"].GetString(), sizeof(m_ownServerId)); - m_ownServerId[sizeof(m_ownServerId) - 1] = 0; + strncpy(m_sOwnServerId, serverAddedJson["id"].GetString(), sizeof(m_sOwnServerId)); + m_sOwnServerId[sizeof(m_sOwnServerId) - 1] = 0; } if (serverAddedJson.HasMember("serverAuthToken") && serverAddedJson["serverAuthToken"].IsString()) { strncpy( - m_ownServerAuthToken, + m_sOwnServerAuthToken, serverAddedJson["serverAuthToken"].GetString(), - sizeof(m_ownServerAuthToken)); - m_ownServerAuthToken[sizeof(m_ownServerAuthToken) - 1] = 0; + sizeof(m_sOwnServerAuthToken)); + m_sOwnServerAuthToken[sizeof(m_sOwnServerAuthToken) - 1] = 0; } } } @@ -1033,7 +1033,7 @@ void MasterServerManager::AddSelfToServerList( curl_easy_cleanup(curl); Sleep(10000); - } while (*m_ownServerId); + } while (*m_sOwnServerId); }); heartbeatThread.detach(); @@ -1041,7 +1041,7 @@ void MasterServerManager::AddSelfToServerList( else { spdlog::error("Failed adding self to server list: error {}", curl_easy_strerror(result)); - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; } REQUEST_END_CLEANUP: @@ -1055,7 +1055,7 @@ void MasterServerManager::AddSelfToServerList( void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, int maxPlayers) { // dont call this if we don't have a server id - if (!*m_ownServerId) + if (!*m_sOwnServerId) return; std::string strMap(map); @@ -1083,7 +1083,7 @@ void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, fmt::format( "{}/server/update_values?id={}&map={}&playlist={}&maxPlayers={}", Cvar_ns_masterserver_hostname->GetString(), - m_ownServerId, + m_sOwnServerId, mapEscaped, playlistEscaped, maxPlayers) @@ -1096,9 +1096,9 @@ void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, CURLcode result = curl_easy_perform(curl); if (result == CURLcode::CURLE_OK) - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; else - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; curl_easy_cleanup(curl); }); @@ -1109,7 +1109,7 @@ void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, void MasterServerManager::UpdateServerPlayerCount(int playerCount) { // dont call this if we don't have a server id - if (!*m_ownServerId) + if (!*m_sOwnServerId) return; std::thread requestThread( @@ -1126,15 +1126,15 @@ void MasterServerManager::UpdateServerPlayerCount(int playerCount) curl, CURLOPT_URL, fmt::format( - "{}/server/update_values?id={}&playerCount={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId, playerCount) + "{}/server/update_values?id={}&playerCount={}", Cvar_ns_masterserver_hostname->GetString(), m_sOwnServerId, playerCount) .c_str()); CURLcode result = curl_easy_perform(curl); if (result == CURLcode::CURLE_OK) - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; else - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; curl_easy_cleanup(curl); }); @@ -1145,7 +1145,7 @@ void MasterServerManager::UpdateServerPlayerCount(int playerCount) void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata, size_t pdataSize) { // still call this if we don't have a server id, since lobbies that aren't port forwarded need to be able to call it - m_savingPersistentData = true; + m_bSavingPersistentData = true; if (!pdataSize) { spdlog::warn("attempted to write pdata of size 0!"); @@ -1169,7 +1169,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata, "{}/accounts/write_persistence?id={}&serverId={}", Cvar_ns_masterserver_hostname->GetString(), strPlayerId, - m_ownServerId) + m_sOwnServerId) .c_str()); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback); @@ -1188,13 +1188,13 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata, CURLcode result = curl_easy_perform(curl); if (result == CURLcode::CURLE_OK) - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; else - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; curl_easy_cleanup(curl); - m_savingPersistentData = false; + m_bSavingPersistentData = false; }); requestThread.detach(); @@ -1203,7 +1203,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata, void MasterServerManager::RemoveSelfFromServerList() { // dont call this if we don't have a server id - if (!*m_ownServerId || !Cvar_ns_report_server_to_masterserver->GetBool()) + if (!*m_sOwnServerId || !Cvar_ns_report_server_to_masterserver->GetBool()) return; std::thread requestThread( @@ -1219,15 +1219,15 @@ void MasterServerManager::RemoveSelfFromServerList() curl_easy_setopt( curl, CURLOPT_URL, - fmt::format("{}/server/remove_server?id={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId).c_str()); + fmt::format("{}/server/remove_server?id={}", Cvar_ns_masterserver_hostname->GetString(), m_sOwnServerId).c_str()); - *m_ownServerId = 0; + *m_sOwnServerId = 0; CURLcode result = curl_easy_perform(curl); if (result == CURLcode::CURLE_OK) - m_successfullyConnected = true; + m_bSuccessfullyConnected = true; else - m_successfullyConnected = false; + m_bSuccessfullyConnected = false; curl_easy_cleanup(curl); }); @@ -1331,7 +1331,7 @@ void CHostState__State_GameShutdownHook(CHostState* hostState) CHostState__State_GameShutdown(hostState); } -MasterServerManager::MasterServerManager() : m_pendingConnectionInfo {}, m_ownServerId {""}, m_ownClientAuthToken {""} {} +MasterServerManager::MasterServerManager() : m_pendingConnectionInfo {}, m_sOwnServerId {""}, m_sOwnClientAuthToken {""} {} ON_DLL_LOAD_RELIESON("engine.dll", MasterServer, ConCommand, (HMODULE baseAddress) { diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h index 9f1818d5..ff727878 100644 --- a/NorthstarDedicatedTest/masterserver.h +++ b/NorthstarDedicatedTest/masterserver.h @@ -73,38 +73,38 @@ struct MainMenuPromoData class MasterServerManager { private: - bool m_requestingServerList = false; - bool m_authenticatingWithGameServer = false; + bool m_bRequestingServerList = false; + bool m_bAuthenticatingWithGameServer = false; public: - char m_ownServerId[33]; - char m_ownServerAuthToken[33]; - char m_ownClientAuthToken[33]; + char m_sOwnServerId[33]; + char m_sOwnServerAuthToken[33]; + char m_sOwnClientAuthToken[33]; - std::string m_ownModInfoJson; - std::string ns_auth_srvName; // Unicode unescaped version of Cvar_ns_auth_servername for support in cjk characters - std::string ns_auth_srvDesc; // Unicode unescaped version of Cvar_ns_auth_serverdesc for support in cjk characters + std::string m_sOwnModInfoJson; + std::string m_sUnicodeServerName; // Unicode unescaped version of Cvar_ns_auth_servername for support in cjk characters + std::string m_sUnicodeServerDesc; // Unicode unescaped version of Cvar_ns_auth_serverdesc for support in cjk characters bool m_bOriginAuthWithMasterServerDone = false; bool m_bOriginAuthWithMasterServerInProgress = false; bool m_bRequireClientAuth = false; - bool m_savingPersistentData = false; + bool m_bSavingPersistentData = false; - bool m_scriptRequestingServerList = false; - bool m_successfullyConnected = true; + bool m_bScriptRequestingServerList = false; + bool m_bSuccessfullyConnected = true; bool m_bNewgameAfterSelfAuth = false; - bool m_scriptAuthenticatingWithGameServer = false; - bool m_successfullyAuthenticatedWithGameServer = false; + bool m_bScriptAuthenticatingWithGameServer = false; + bool m_bSuccessfullyAuthenticatedWithGameServer = false; - bool m_hasPendingConnectionInfo = false; + bool m_bHasPendingConnectionInfo = false; RemoteServerConnectionInfo m_pendingConnectionInfo; - std::vector<RemoteServerInfo> m_remoteServers; + std::vector<RemoteServerInfo> m_vRemoteServers; bool m_bHasMainMenuPromoData = false; - MainMenuPromoData m_MainMenuPromoData; + MainMenuPromoData m_sMainMenuPromoData; private: void SetCommonHttpClientOptions(CURL* curl); diff --git a/NorthstarDedicatedTest/misccommands.cpp b/NorthstarDedicatedTest/misccommands.cpp index df2f4a3d..0c7de684 100644 --- a/NorthstarDedicatedTest/misccommands.cpp +++ b/NorthstarDedicatedTest/misccommands.cpp @@ -29,7 +29,7 @@ void AddMiscConCommands() { // hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect g_MasterServerManager->m_bNewgameAfterSelfAuth = true; - g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_ownClientAuthToken); + g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_sOwnClientAuthToken); }); // this is a concommand because we make a deferred call to it from another thread diff --git a/NorthstarDedicatedTest/miscserverscript.cpp b/NorthstarDedicatedTest/miscserverscript.cpp index f8884e7c..0f66d386 100644 --- a/NorthstarDedicatedTest/miscserverscript.cpp +++ b/NorthstarDedicatedTest/miscserverscript.cpp @@ -39,7 +39,7 @@ SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm) // bool function NSIsWritingPlayerPersistence() SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm) { - ServerSq_pushbool(sqvm, g_MasterServerManager->m_savingPersistentData); + ServerSq_pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData); return SQRESULT_NOTNULL; } diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp index f19e64d6..01f9670a 100644 --- a/NorthstarDedicatedTest/modmanager.cpp +++ b/NorthstarDedicatedTest/modmanager.cpp @@ -495,7 +495,7 @@ void ModManager::LoadMods() buffer.Clear(); rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); modinfoDoc.Accept(writer); - g_MasterServerManager->m_ownModInfoJson = std::string(buffer.GetString()); + g_MasterServerManager->m_sOwnModInfoJson = std::string(buffer.GetString()); m_hasLoadedMods = true; } diff --git a/NorthstarDedicatedTest/playlist.cpp b/NorthstarDedicatedTest/playlist.cpp index c1598825..59798510 100644 --- a/NorthstarDedicatedTest/playlist.cpp +++ b/NorthstarDedicatedTest/playlist.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "playlist.h" +#include "NSMem.h" #include "hooks.h" #include "concommand.h" #include "convar.h" @@ -72,7 +73,6 @@ int GetCurrentGamemodeMaxPlayersHook() return maxPlayers; } -#include "NSMem.h" ON_DLL_LOAD_RELIESON("engine.dll", PlaylistHooks, ConCommand, (HMODULE baseAddress) { RegisterConCommand("setplaylist", SetPlaylistCommand, "Sets the current playlist", FCVAR_NONE); diff --git a/NorthstarDedicatedTest/plugins.cpp b/NorthstarDedicatedTest/plugins.cpp index 54067772..7424d954 100644 --- a/NorthstarDedicatedTest/plugins.cpp +++ b/NorthstarDedicatedTest/plugins.cpp @@ -193,7 +193,7 @@ SQRESULT SQ_SetConnected(void* sqvm) SQRESULT SQ_UpdateListenServer(void* sqvm) { AcquireSRWLockExclusive(&serverInfoLock); - serverInfo.id = g_MasterServerManager->m_ownServerId; + serverInfo.id = g_MasterServerManager->m_sOwnServerId; serverInfo.password = Cvar_ns_server_password->GetString(); ReleaseSRWLockExclusive(&serverInfoLock); return SQRESULT_NOTNULL; diff --git a/NorthstarDedicatedTest/scriptmainmenupromos.cpp b/NorthstarDedicatedTest/scriptmainmenupromos.cpp index 0d425b65..e03b6142 100644 --- a/NorthstarDedicatedTest/scriptmainmenupromos.cpp +++ b/NorthstarDedicatedTest/scriptmainmenupromos.cpp @@ -49,79 +49,79 @@ SQRESULT SQ_GetCustomMainMenuPromoData(void* sqvm) { case eMainMenuPromoDataProperty::newInfoTitle1: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.newInfoTitle1.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle1.c_str(), -1); break; } case eMainMenuPromoDataProperty::newInfoTitle2: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.newInfoTitle2.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle2.c_str(), -1); break; } case eMainMenuPromoDataProperty::newInfoTitle3: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.newInfoTitle3.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle3.c_str(), -1); break; } case eMainMenuPromoDataProperty::largeButtonTitle: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.largeButtonTitle.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonTitle.c_str(), -1); break; } case eMainMenuPromoDataProperty::largeButtonText: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.largeButtonText.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonText.c_str(), -1); break; } case eMainMenuPromoDataProperty::largeButtonUrl: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.largeButtonUrl.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonUrl.c_str(), -1); break; } case eMainMenuPromoDataProperty::largeButtonImageIndex: { - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_MainMenuPromoData.largeButtonImageIndex); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonImageIndex); break; } case eMainMenuPromoDataProperty::smallButton1Title: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton1Title.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Title.c_str(), -1); break; } case eMainMenuPromoDataProperty::smallButton1Url: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton1Url.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Url.c_str(), -1); break; } case eMainMenuPromoDataProperty::smallButton1ImageIndex: { - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton1ImageIndex); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1ImageIndex); break; } case eMainMenuPromoDataProperty::smallButton2Title: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton2Title.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Title.c_str(), -1); break; } case eMainMenuPromoDataProperty::smallButton2Url: { - ClientSq_pushstring(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton2Url.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Url.c_str(), -1); break; } case eMainMenuPromoDataProperty::smallButton2ImageIndex: { - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_MainMenuPromoData.smallButton2ImageIndex); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2ImageIndex); break; } } diff --git a/NorthstarDedicatedTest/scriptserverbrowser.cpp b/NorthstarDedicatedTest/scriptserverbrowser.cpp index 64ffacfc..41506230 100644 --- a/NorthstarDedicatedTest/scriptserverbrowser.cpp +++ b/NorthstarDedicatedTest/scriptserverbrowser.cpp @@ -25,21 +25,21 @@ SQRESULT SQ_RequestServerList(void* sqvm) // bool function NSIsRequestingServerList() SQRESULT SQ_IsRequestingServerList(void* sqvm) { - ClientSq_pushbool(sqvm, g_MasterServerManager->m_scriptRequestingServerList); + ClientSq_pushbool(sqvm, g_MasterServerManager->m_bScriptRequestingServerList); return SQRESULT_NOTNULL; } // bool function NSMasterServerConnectionSuccessful() SQRESULT SQ_MasterServerConnectionSuccessful(void* sqvm) { - ClientSq_pushbool(sqvm, g_MasterServerManager->m_successfullyConnected); + ClientSq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyConnected); return SQRESULT_NOTNULL; } // int function NSGetServerCount() SQRESULT SQ_GetServerCount(void* sqvm) { - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers.size()); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers.size()); return SQRESULT_NOTNULL; } @@ -48,19 +48,19 @@ SQRESULT SQ_GetServerName(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get name of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].name, -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].name, -1); return SQRESULT_NOTNULL; } @@ -69,19 +69,19 @@ SQRESULT SQ_GetServerDescription(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get description of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].description.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].description.c_str(), -1); return SQRESULT_NOTNULL; } @@ -90,19 +90,19 @@ SQInteger SQ_GetServerMap(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get map of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].map, -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].map, -1); return SQRESULT_NOTNULL; } @@ -111,19 +111,19 @@ SQRESULT SQ_GetServerPlaylist(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get playlist of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].playlist, -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playlist, -1); return SQRESULT_NOTNULL; } @@ -132,19 +132,19 @@ SQRESULT SQ_GetServerPlayerCount(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get playercount of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].playerCount); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playerCount); return SQRESULT_NOTNULL; } @@ -153,19 +153,19 @@ SQRESULT SQ_GetServerMaxPlayerCount(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get max playercount of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].maxPlayers); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].maxPlayers); return SQRESULT_NOTNULL; } @@ -174,19 +174,19 @@ SQRESULT SQ_GetServerID(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get id of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].id, -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].id, -1); return SQRESULT_NOTNULL; } @@ -195,19 +195,19 @@ SQRESULT SQ_ServerRequiresPassword(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get hasPassword of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushbool(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiresPassword); + ClientSq_pushbool(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiresPassword); return SQRESULT_NOTNULL; } @@ -216,19 +216,19 @@ SQRESULT SQ_GetServerRequiredModsCount(void* sqvm) { SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get required mods count of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size()); + ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()); return SQRESULT_NOTNULL; } @@ -238,31 +238,31 @@ SQRESULT SQ_GetServerRequiredModName(void* sqvm) SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); SQInteger modIndex = ClientSq_getinteger(sqvm, 2); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get hasPassword of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - if (modIndex >= g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size()) + if (modIndex >= g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get required mod name of mod index {} when only {} mod are available", modIndex, - g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size()) + g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods[modIndex].Name.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Name.c_str(), -1); return SQRESULT_NOTNULL; } @@ -272,31 +272,31 @@ SQRESULT SQ_GetServerRequiredModVersion(void* sqvm) SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); SQInteger modIndex = ClientSq_getinteger(sqvm, 2); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get required mod version of server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } - if (modIndex >= g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size()) + if (modIndex >= g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to get required mod version of mod index {} when only {} mod are available", modIndex, - g_MasterServerManager->m_remoteServers[serverIndex].requiredMods.size()) + g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size()) .c_str()); return SQRESULT_ERROR; } - ClientSq_pushstring(sqvm, g_MasterServerManager->m_remoteServers[serverIndex].requiredMods[modIndex].Version.c_str(), -1); + ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Version.c_str(), -1); return SQRESULT_NOTNULL; } @@ -315,14 +315,14 @@ SQRESULT SQ_TryAuthWithServer(void* sqvm) SQInteger serverIndex = ClientSq_getinteger(sqvm, 1); const SQChar* password = ClientSq_getstring(sqvm, 2); - if (serverIndex >= g_MasterServerManager->m_remoteServers.size()) + if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size()) { ClientSq_pusherror( sqvm, fmt::format( "Tried to auth with server index {} when only {} servers are available", serverIndex, - g_MasterServerManager->m_remoteServers.size()) + g_MasterServerManager->m_vRemoteServers.size()) .c_str()); return SQRESULT_ERROR; } @@ -335,8 +335,8 @@ SQRESULT SQ_TryAuthWithServer(void* sqvm) // do auth g_MasterServerManager->AuthenticateWithServer( g_LocalPlayerUserID, - g_MasterServerManager->m_ownClientAuthToken, - g_MasterServerManager->m_remoteServers[serverIndex].id, + g_MasterServerManager->m_sOwnClientAuthToken, + g_MasterServerManager->m_vRemoteServers[serverIndex].id, (char*)password); return SQRESULT_NULL; @@ -345,21 +345,21 @@ SQRESULT SQ_TryAuthWithServer(void* sqvm) // bool function NSIsAuthenticatingWithServer() SQRESULT SQ_IsAuthComplete(void* sqvm) { - ClientSq_pushbool(sqvm, g_MasterServerManager->m_scriptAuthenticatingWithGameServer); + ClientSq_pushbool(sqvm, g_MasterServerManager->m_bScriptAuthenticatingWithGameServer); return SQRESULT_NOTNULL; } // bool function NSWasAuthSuccessful() SQRESULT SQ_WasAuthSuccessful(void* sqvm) { - ClientSq_pushbool(sqvm, g_MasterServerManager->m_successfullyAuthenticatedWithGameServer); + ClientSq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyAuthenticatedWithGameServer); return SQRESULT_NOTNULL; } // void function NSConnectToAuthedServer() SQRESULT SQ_ConnectToAuthedServer(void* sqvm) { - if (!g_MasterServerManager->m_hasPendingConnectionInfo) + if (!g_MasterServerManager->m_bHasPendingConnectionInfo) { ClientSq_pusherror(sqvm, fmt::format("Tried to connect to authed server before any pending connection info was available").c_str()); return SQRESULT_ERROR; @@ -382,7 +382,7 @@ SQRESULT SQ_ConnectToAuthedServer(void* sqvm) .c_str(), cmd_source_t::kCommandSrcCode); - g_MasterServerManager->m_hasPendingConnectionInfo = false; + g_MasterServerManager->m_bHasPendingConnectionInfo = false; return SQRESULT_NULL; } @@ -390,7 +390,7 @@ SQRESULT SQ_ConnectToAuthedServer(void* sqvm) SQRESULT SQ_TryAuthWithLocalServer(void* sqvm) { // do auth request - g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_ownClientAuthToken); + g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_sOwnClientAuthToken); return SQRESULT_NULL; } diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index b7360d2f..27db8bc9 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -121,7 +121,7 @@ void ServerAuthenticationManager::StartPlayerAuthServer() if (!request.has_param("id") || !request.has_param("authToken") || request.body.size() >= 65335 || !request.has_param("serverAuthToken") || strcmp( - g_MasterServerManager->m_ownServerAuthToken, + g_MasterServerManager->m_sOwnServerAuthToken, request.get_param_value("serverAuthToken") .c_str())) // || !resolvedRemoteAddr || ((in_addr**)resolvedRemoteAddr->h_addr_list)[0]->S_un.S_addr != // remoteAddr) |