Pass the controllerSecret to the CNet* constructor

It wasn't clear when to call `SetControllerSecret` now it can't be done
wrong. Also the mutex has to be locked less often.
This commit is contained in:
phosit committed 2026-04-11 13:41:23 +02:00
1 parent d33fb147bc
commit dbe89d10ae
5 files changed
+17 -36

No files matched your search

@@ -105,7 +105,8 @@ void StartNetworkHost(const CStrW& playerName, const u16 serverPort, const CStr&
std::string hashedPassword = hasLobby ?
HashCryptographically(password, hostJID + password + PS_SERIALIZATION_VERSION) : "";
g_NetServer = new CNetServer(continueSavedGame, hasLobby, hashedPassword);
const std::string secret = ps_generate_guid();
g_NetServer = new CNetServer(continueSavedGame, hasLobby, hashedPassword, secret);
if (!g_NetServer->SetupConnection(serverPort))
{
@@ -122,13 +123,10 @@ void StartNetworkHost(const CStrW& playerName, const u16 serverPort, const CStr&
}
// Generate a secret to identify the host client.
std::string secret = ps_generate_guid();
g_NetServer->SetControllerSecret(secret);
g_Game = new CGame(storeReplay);
g_NetClient = new CNetClient(g_Game, playerName, hostJID, hashedPassword);
g_NetClient = new CNetClient(g_Game, playerName, hostJID, hashedPassword, secret);
g_NetClient->SetupServerData("127.0.0.1", serverPort);
g_NetClient->SetControllerSecret(secret);
if (!g_NetClient->SetupConnection(nullptr))
{