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

Merge pull request #1000 from vcmi/multiplayer

Multiplayer
This commit is contained in:
Andrii Danylchenko
2022-10-03 20:16:39 +03:00
committed by GitHub
14 changed files with 164 additions and 58 deletions

View File

@@ -512,6 +512,14 @@ void CServerHandler::sendGuiAction(ui8 action) const
sendLobbyPack(lga);
}
void CServerHandler::sendRestartGame() const
{
LobbyEndGame endGame;
endGame.closeConnection = false;
endGame.restart = true;
sendLobbyPack(endGame);
}
void CServerHandler::sendStartGame(bool allowOnlyAI) const
{
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
@@ -524,9 +532,11 @@ void CServerHandler::sendStartGame(bool allowOnlyAI) const
* si = * lsg.initializedStartInfo;
}
sendLobbyPack(lsg);
c->enterLobbyConnectionMode();
c->disableStackSendingByID();
}
void CServerHandler::startGameplay()
void CServerHandler::startGameplay(CGameState * gameState)
{
if(CMM)
CMM->disable();
@@ -535,13 +545,13 @@ void CServerHandler::startGameplay()
switch(si->mode)
{
case StartInfo::NEW_GAME:
client->newGame();
client->newGame(gameState);
break;
case StartInfo::CAMPAIGN:
client->newGame();
client->newGame(gameState);
break;
case StartInfo::LOAD_GAME:
client->loadGame();
client->loadGame(gameState);
break;
default:
throw std::runtime_error("Invalid mode");
@@ -576,6 +586,9 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart)
GH.curInt = CMainMenu::create().get();
}
}
c->enterLobbyConnectionMode();
c->disableStackSendingByID();
}
void CServerHandler::startCampaignScenario(std::shared_ptr<CCampaignState> cs)