mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Reconnection partially works
This commit is contained in:
@@ -562,6 +562,13 @@ void CServerHandler::startGameplay(CGameState * gameState)
|
|||||||
saveSession->Bool() = true;
|
saveSession->Bool() = true;
|
||||||
Settings saveUuid = settings.write["server"]["uuid"];
|
Settings saveUuid = settings.write["server"]["uuid"];
|
||||||
saveUuid->String() = uuid;
|
saveUuid->String() = uuid;
|
||||||
|
Settings saveNames = settings.write["server"]["names"];
|
||||||
|
for(auto & name : myNames)
|
||||||
|
{
|
||||||
|
JsonNode jsonName;
|
||||||
|
jsonName.String() = name;
|
||||||
|
saveNames->Vector().push_back(jsonName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,13 +656,23 @@ ui8 CServerHandler::getLoadMode()
|
|||||||
|
|
||||||
void CServerHandler::restoreLastSession()
|
void CServerHandler::restoreLastSession()
|
||||||
{
|
{
|
||||||
std::vector<std::string> nm{"stub"};
|
auto loadSession = [this]()
|
||||||
resetStateForLobby(StartInfo::LOAD_GAME, &nm);
|
{
|
||||||
|
for(auto & name : settings["server"]["names"].Vector())
|
||||||
|
myNames.push_back(name.String());
|
||||||
|
resetStateForLobby(StartInfo::LOAD_GAME, &myNames);
|
||||||
screenType = ESelectionScreen::loadGame;
|
screenType = ESelectionScreen::loadGame;
|
||||||
justConnectToServer("127.0.0.1", 3030);
|
justConnectToServer("127.0.0.1", 3030);
|
||||||
//c->disableSmartVectorMemberSerialization();
|
};
|
||||||
//c->disableSmartPointerSerialization();
|
|
||||||
//c->disableStackSendingByID();
|
auto cleanUpSession = []()
|
||||||
|
{
|
||||||
|
//reset settings
|
||||||
|
Settings saveSession = settings.write["server"]["reconnect"];
|
||||||
|
saveSession->Bool() = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
CInfoWindow::showYesNoDialog("Connect to the last session?", {}, loadSession, cleanUpSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerHandler::debugStartTest(std::string filename, bool save)
|
void CServerHandler::debugStartTest(std::string filename, bool save)
|
||||||
|
|||||||
@@ -356,13 +356,14 @@ void PlayerReinitInterface::applyCl(CClient * cl)
|
|||||||
if(cl->gameState()->currentPlayer == player)
|
if(cl->gameState()->currentPlayer == player)
|
||||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
||||||
}
|
}
|
||||||
else
|
else if(playerConnectionId == CSH->c->connectionID)
|
||||||
{
|
{
|
||||||
plSettings.connectedPlayerIDs.insert(playerConnectionId);
|
plSettings.connectedPlayerIDs.insert(playerConnectionId);
|
||||||
|
cl->playerint.clear();
|
||||||
cl->initPlayerInterfaces();
|
cl->initPlayerInterfaces();
|
||||||
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
|
auto currentPlayer = cl->gameState()->currentPlayer;
|
||||||
//if(cl->gameState()->currentPlayer == player)
|
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, currentPlayer);
|
||||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
callOnlyThatInterface(cl, currentPlayer, &CGameInterface::yourTurn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@
|
|||||||
"type" : "object",
|
"type" : "object",
|
||||||
"additionalProperties" : false,
|
"additionalProperties" : false,
|
||||||
"default": {},
|
"default": {},
|
||||||
"required" : [ "server", "port", "localInformation", "playerAI", "friendlyAI","neutralAI", "enemyAI", "reconnect", "uuid" ],
|
"required" : [ "server", "port", "localInformation", "playerAI", "friendlyAI","neutralAI", "enemyAI", "reconnect", "uuid", "names" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"server" : {
|
"server" : {
|
||||||
"type":"string",
|
"type":"string",
|
||||||
@@ -290,6 +290,15 @@
|
|||||||
"uuid" : {
|
"uuid" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"default" : ""
|
"default" : ""
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"type" : "array",
|
||||||
|
"default" : {},
|
||||||
|
"items":
|
||||||
|
{
|
||||||
|
"type" : "string",
|
||||||
|
"default" : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -369,9 +369,6 @@ DLL_LINKAGE void PlayerReinitInterface::applyGs(CGameState *gs)
|
|||||||
{
|
{
|
||||||
if(!gs || !gs->scenarioOps)
|
if(!gs || !gs->scenarioOps)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gs->currentPlayer = player;
|
|
||||||
|
|
||||||
//auto & playerState = gs->players[player];
|
//auto & playerState = gs->players[player];
|
||||||
//playerState.daysWithoutCastle = daysWithoutCastle;
|
//playerState.daysWithoutCastle = daysWithoutCastle;
|
||||||
|
|
||||||
|
|||||||
@@ -466,6 +466,7 @@ bool CVCMIServer::passHost(int toConnectionId)
|
|||||||
|
|
||||||
void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<std::string> & names, std::string uuid, StartInfo::EMode mode)
|
void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<std::string> & names, std::string uuid, StartInfo::EMode mode)
|
||||||
{
|
{
|
||||||
|
if(state == EServerState::LOBBY)
|
||||||
c->connectionID = currentClientId++;
|
c->connectionID = currentClientId++;
|
||||||
|
|
||||||
if(!hostClient)
|
if(!hostClient)
|
||||||
@@ -476,6 +477,8 @@ void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<st
|
|||||||
}
|
}
|
||||||
|
|
||||||
logNetwork->info("Connection with client %d established. UUID: %s", c->connectionID, c->uuid);
|
logNetwork->info("Connection with client %d established. UUID: %s", c->connectionID, c->uuid);
|
||||||
|
|
||||||
|
if(state == EServerState::LOBBY)
|
||||||
for(auto & name : names)
|
for(auto & name : names)
|
||||||
{
|
{
|
||||||
logNetwork->info("Client %d player: %s", c->connectionID, name);
|
logNetwork->info("Client %d player: %s", c->connectionID, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user