1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

One step forward

This commit is contained in:
nordsoft
2022-10-04 02:25:22 +04:00
parent 512cf014aa
commit b91bb41a80
4 changed files with 12 additions and 5 deletions

View File

@@ -359,7 +359,9 @@ void PlayerReinitInterface::applyCl(CClient * cl)
else else
{ {
plSettings.connectedPlayerIDs.insert(playerConnectionId); plSettings.connectedPlayerIDs.insert(playerConnectionId);
cl->initPlayerInterfaces();
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player); callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
//if(cl->gameState()->currentPlayer == player)
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn); callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
} }
} }

View File

@@ -113,9 +113,11 @@ bool LobbyStartGame::applyOnLobbyHandler(CServerHandler * handler)
return false; return false;
handler->state = EClientState::STARTING; handler->state = EClientState::STARTING;
if(handler->si->mode != StartInfo::LOAD_GAME) if(handler->si->mode != StartInfo::LOAD_GAME || clientId == handler->c->connectionID)
{ {
auto modeBackup = handler->si->mode;
handler->si = initializedStartInfo; handler->si = initializedStartInfo;
handler->si->mode = modeBackup;
} }
if(settings["session"]["headless"].Bool()) if(settings["session"]["headless"].Bool())
handler->startGameplay(initializedGameState); handler->startGameplay(initializedGameState);

View File

@@ -370,6 +370,11 @@ 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];
//playerState.daysWithoutCastle = daysWithoutCastle;
//TODO: what does mean if more that one player connected? //TODO: what does mean if more that one player connected?
//gs->scenarioOps->getIthPlayersSettings(player).connectedPlayerIDs.clear(); //gs->scenarioOps->getIthPlayersSettings(player).connectedPlayerIDs.clear();
} }

View File

@@ -52,8 +52,10 @@ void LobbyClientConnected::applyOnServerAfterAnnounce(CVCMIServer * srv)
// FIXME: we need to avoid senting something to client that not yet get answer for LobbyClientConnected // FIXME: we need to avoid senting something to client that not yet get answer for LobbyClientConnected
// Until UUID set we only pass LobbyClientConnected to this client // Until UUID set we only pass LobbyClientConnected to this client
c->uuid = uuid; c->uuid = uuid;
srv->updateAndPropagateLobbyState();
if(srv->state == EServerState::GAMEPLAY) if(srv->state == EServerState::GAMEPLAY)
{ {
//immediately start game //immediately start game
std::unique_ptr<LobbyStartGame> startGameForReconnectedPlayer(new LobbyStartGame); std::unique_ptr<LobbyStartGame> startGameForReconnectedPlayer(new LobbyStartGame);
startGameForReconnectedPlayer->initializedStartInfo = srv->si; startGameForReconnectedPlayer->initializedStartInfo = srv->si;
@@ -61,10 +63,6 @@ void LobbyClientConnected::applyOnServerAfterAnnounce(CVCMIServer * srv)
startGameForReconnectedPlayer->clientId = c->connectionID; startGameForReconnectedPlayer->clientId = c->connectionID;
srv->addToAnnounceQueue(std::move(startGameForReconnectedPlayer)); srv->addToAnnounceQueue(std::move(startGameForReconnectedPlayer));
} }
else
{
srv->updateAndPropagateLobbyState();
}
} }
bool LobbyClientDisconnected::checkClientPermissions(CVCMIServer * srv) const bool LobbyClientDisconnected::checkClientPermissions(CVCMIServer * srv) const