mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-13 21:54:43 +00:00
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:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user