mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Reconnection partially works
This commit is contained in:
parent
b91bb41a80
commit
16a5414247
@ -562,6 +562,13 @@ void CServerHandler::startGameplay(CGameState * gameState)
|
||||
saveSession->Bool() = true;
|
||||
Settings saveUuid = settings.write["server"]["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()
|
||||
{
|
||||
std::vector<std::string> nm{"stub"};
|
||||
resetStateForLobby(StartInfo::LOAD_GAME, &nm);
|
||||
screenType = ESelectionScreen::loadGame;
|
||||
justConnectToServer("127.0.0.1", 3030);
|
||||
//c->disableSmartVectorMemberSerialization();
|
||||
//c->disableSmartPointerSerialization();
|
||||
//c->disableStackSendingByID();
|
||||
auto loadSession = [this]()
|
||||
{
|
||||
for(auto & name : settings["server"]["names"].Vector())
|
||||
myNames.push_back(name.String());
|
||||
resetStateForLobby(StartInfo::LOAD_GAME, &myNames);
|
||||
screenType = ESelectionScreen::loadGame;
|
||||
justConnectToServer("127.0.0.1", 3030);
|
||||
};
|
||||
|
||||
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)
|
||||
|
@ -356,13 +356,14 @@ void PlayerReinitInterface::applyCl(CClient * cl)
|
||||
if(cl->gameState()->currentPlayer == player)
|
||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
||||
}
|
||||
else
|
||||
else if(playerConnectionId == CSH->c->connectionID)
|
||||
{
|
||||
plSettings.connectedPlayerIDs.insert(playerConnectionId);
|
||||
cl->playerint.clear();
|
||||
cl->initPlayerInterfaces();
|
||||
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
|
||||
//if(cl->gameState()->currentPlayer == player)
|
||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
||||
auto currentPlayer = cl->gameState()->currentPlayer;
|
||||
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, currentPlayer);
|
||||
callOnlyThatInterface(cl, currentPlayer, &CGameInterface::yourTurn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"default": {},
|
||||
"required" : [ "server", "port", "localInformation", "playerAI", "friendlyAI","neutralAI", "enemyAI", "reconnect", "uuid" ],
|
||||
"required" : [ "server", "port", "localInformation", "playerAI", "friendlyAI","neutralAI", "enemyAI", "reconnect", "uuid", "names" ],
|
||||
"properties" : {
|
||||
"server" : {
|
||||
"type":"string",
|
||||
@ -290,6 +290,15 @@
|
||||
"uuid" : {
|
||||
"type" : "string",
|
||||
"default" : ""
|
||||
},
|
||||
"names" : {
|
||||
"type" : "array",
|
||||
"default" : {},
|
||||
"items":
|
||||
{
|
||||
"type" : "string",
|
||||
"default" : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -369,9 +369,6 @@ DLL_LINKAGE void PlayerReinitInterface::applyGs(CGameState *gs)
|
||||
{
|
||||
if(!gs || !gs->scenarioOps)
|
||||
return;
|
||||
|
||||
gs->currentPlayer = player;
|
||||
|
||||
//auto & playerState = gs->players[player];
|
||||
//playerState.daysWithoutCastle = daysWithoutCastle;
|
||||
|
||||
|
@ -466,7 +466,8 @@ bool CVCMIServer::passHost(int toConnectionId)
|
||||
|
||||
void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<std::string> & names, std::string uuid, StartInfo::EMode mode)
|
||||
{
|
||||
c->connectionID = currentClientId++;
|
||||
if(state == EServerState::LOBBY)
|
||||
c->connectionID = currentClientId++;
|
||||
|
||||
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);
|
||||
|
||||
if(state == EServerState::LOBBY)
|
||||
for(auto & name : names)
|
||||
{
|
||||
logNetwork->info("Client %d player: %s", c->connectionID, name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user