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
2026-03-02 19:22:44 +01:00
parent d33fb147bc
commit dbe89d10ae
5 changed files with 17 additions and 36 deletions
+3 -7
View File
@@ -67,13 +67,14 @@ constexpr u32 NETWORK_BAD_PING = DEFAULT_TURN_LENGTH * COMMAND_DELAY_MP / 2;
CNetClient *g_NetClient = NULL;
CNetClient::CNetClient(CGame* game, const CStrW& username, const CStr& hostJID,
std::string hashedPassword) :
std::string hashedPassword, std::string controllerSecret) :
m_UserName{username},
m_HostJID{hostJID},
m_Game{game},
// Hash on top with the user's name, to make sure not all
// hashing data is in control of the host.
m_Password{HashCryptographically(std::move(hashedPassword), m_UserName.ToUTF8())}
m_Password{HashCryptographically(std::move(hashedPassword), m_UserName.ToUTF8())},
m_ControllerSecret{std::move(controllerSecret)}
{
m_Game->SetTurnManager(NULL); // delete the old local turn manager so we don't accidentally use it
@@ -146,11 +147,6 @@ CNetClient::~CNetClient()
DestroyConnection();
}
void CNetClient::SetControllerSecret(const std::string& secret)
{
m_ControllerSecret = secret;
}
bool CNetClient::SetupConnection(ENetHost* enetClient)
{