Explorar o código

Fix UUID initialization on client

Ivan Savenko hai 1 ano
pai
achega
0196707083
Modificáronse 3 ficheiros con 4 adicións e 8 borrados
  1. 2 5
      client/CServerHandler.cpp
  2. 1 1
      client/CServerHandler.h
  3. 1 2
      client/NetPacksLobbyClient.cpp

+ 2 - 5
client/CServerHandler.cpp

@@ -138,18 +138,14 @@ CServerHandler::~CServerHandler()
 CServerHandler::CServerHandler()
 	: state(EClientState::NONE)
 	, networkClient(std::make_unique<NetworkClient>(*this))
+	, applier(std::make_unique<CApplier<CBaseForLobbyApply>>())
 	, client(nullptr)
 	, loadMode(0)
 	, campaignStateToSend(nullptr)
 	, campaignServerRestartLock(false)
 {
 	uuid = boost::uuids::to_string(boost::uuids::random_generator()());
-	//read from file to restore last session
-	if(!settings["server"]["uuid"].isNull() && !settings["server"]["uuid"].String().empty())
-		uuid = settings["server"]["uuid"].String();
-	applier = std::make_shared<CApplier<CBaseForLobbyApply>>();
 	registerTypesLobbyPacks(*applier);
-
 	threadNetwork = std::make_unique<boost::thread>(&CServerHandler::threadRunNetwork, this);
 }
 
@@ -314,6 +310,7 @@ void CServerHandler::onConnectionEstablished(const std::shared_ptr<NetworkConnec
 {
 	logNetwork->info("Connection established");
 	c = std::make_shared<CConnection>(netConnection);
+	c->uuid = uuid;
 	c->enterLobbyConnectionMode();
 	sendClientConnecting();
 }

+ 1 - 1
client/CServerHandler.h

@@ -86,7 +86,7 @@ class CServerHandler : public IServerAPI, public LobbyInfo, public INetworkClien
 	friend class ApplyOnLobbyHandlerNetPackVisitor;
 
 	std::unique_ptr<NetworkClient> networkClient;
-	std::shared_ptr<CApplier<CBaseForLobbyApply>> applier;
+	std::unique_ptr<CApplier<CBaseForLobbyApply>> applier;
 	std::shared_ptr<CMapInfo> mapToStart;
 	std::vector<std::string> myNames;
 	std::shared_ptr<HighScoreCalculation> highScoreCalc;

+ 1 - 2
client/NetPacksLobbyClient.cpp

@@ -36,8 +36,7 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientCon
 	result = false;
 
 	// Check if it's LobbyClientConnected for our client
-	// TODO: restore
-	//if(pack.uuid == handler.c->uuid)
+	if(pack.uuid == handler.c->uuid)
 	{
 		handler.c->connectionID = pack.clientId;
 		if(handler.mapToStart)