mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-25 00:37:24 +02:00
Fix UUID initialization on client
This commit is contained in:
@ -138,18 +138,14 @@ CServerHandler::~CServerHandler()
|
|||||||
CServerHandler::CServerHandler()
|
CServerHandler::CServerHandler()
|
||||||
: state(EClientState::NONE)
|
: state(EClientState::NONE)
|
||||||
, networkClient(std::make_unique<NetworkClient>(*this))
|
, networkClient(std::make_unique<NetworkClient>(*this))
|
||||||
|
, applier(std::make_unique<CApplier<CBaseForLobbyApply>>())
|
||||||
, client(nullptr)
|
, client(nullptr)
|
||||||
, loadMode(0)
|
, loadMode(0)
|
||||||
, campaignStateToSend(nullptr)
|
, campaignStateToSend(nullptr)
|
||||||
, campaignServerRestartLock(false)
|
, campaignServerRestartLock(false)
|
||||||
{
|
{
|
||||||
uuid = boost::uuids::to_string(boost::uuids::random_generator()());
|
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);
|
registerTypesLobbyPacks(*applier);
|
||||||
|
|
||||||
threadNetwork = std::make_unique<boost::thread>(&CServerHandler::threadRunNetwork, this);
|
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");
|
logNetwork->info("Connection established");
|
||||||
c = std::make_shared<CConnection>(netConnection);
|
c = std::make_shared<CConnection>(netConnection);
|
||||||
|
c->uuid = uuid;
|
||||||
c->enterLobbyConnectionMode();
|
c->enterLobbyConnectionMode();
|
||||||
sendClientConnecting();
|
sendClientConnecting();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class CServerHandler : public IServerAPI, public LobbyInfo, public INetworkClien
|
|||||||
friend class ApplyOnLobbyHandlerNetPackVisitor;
|
friend class ApplyOnLobbyHandlerNetPackVisitor;
|
||||||
|
|
||||||
std::unique_ptr<NetworkClient> networkClient;
|
std::unique_ptr<NetworkClient> networkClient;
|
||||||
std::shared_ptr<CApplier<CBaseForLobbyApply>> applier;
|
std::unique_ptr<CApplier<CBaseForLobbyApply>> applier;
|
||||||
std::shared_ptr<CMapInfo> mapToStart;
|
std::shared_ptr<CMapInfo> mapToStart;
|
||||||
std::vector<std::string> myNames;
|
std::vector<std::string> myNames;
|
||||||
std::shared_ptr<HighScoreCalculation> highScoreCalc;
|
std::shared_ptr<HighScoreCalculation> highScoreCalc;
|
||||||
|
@ -36,8 +36,7 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientCon
|
|||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
// Check if it's LobbyClientConnected for our client
|
// 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;
|
handler.c->connectionID = pack.clientId;
|
||||||
if(handler.mapToStart)
|
if(handler.mapToStart)
|
||||||
|
Reference in New Issue
Block a user