mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Make console available during other players' turn
This commit is contained in:
parent
3ff38b84a2
commit
895ec2d302
@ -284,6 +284,8 @@ void CCallback::sendMessage(const std::string &mess, const CGObjectInstance * cu
|
|||||||
{
|
{
|
||||||
ASSERT_IF_CALLED_WITH_PLAYER
|
ASSERT_IF_CALLED_WITH_PLAYER
|
||||||
PlayerMessage pm(mess, currentObject? currentObject->id : ObjectInstanceID(-1));
|
PlayerMessage pm(mess, currentObject? currentObject->id : ObjectInstanceID(-1));
|
||||||
|
if(player)
|
||||||
|
pm.player = *player;
|
||||||
sendRequest(&pm);
|
sendRequest(&pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,6 +404,15 @@ void CClient::endGame()
|
|||||||
logNetwork->info("Client stopped.");
|
logNetwork->info("Client stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClient::processDisconnectedPlayers()
|
||||||
|
{
|
||||||
|
if(!gs || !disconnectedPlayers.count(gs->currentPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
LOCPLINT->showYesNoDialog("Waiting for player. Press Ok to save & end, cancel to kick that player",
|
||||||
|
[](){}, [](){});
|
||||||
|
}
|
||||||
|
|
||||||
void CClient::initMapHandler()
|
void CClient::initMapHandler()
|
||||||
{
|
{
|
||||||
// TODO: CMapHandler initialization can probably go somewhere else
|
// TODO: CMapHandler initialization can probably go somewhere else
|
||||||
|
@ -138,6 +138,8 @@ public:
|
|||||||
std::map<PlayerColor, std::shared_ptr<CBattleGameInterface>> battleints;
|
std::map<PlayerColor, std::shared_ptr<CBattleGameInterface>> battleints;
|
||||||
|
|
||||||
std::map<PlayerColor, std::vector<std::shared_ptr<IBattleEventsReceiver>>> additionalBattleInts;
|
std::map<PlayerColor, std::vector<std::shared_ptr<IBattleEventsReceiver>>> additionalBattleInts;
|
||||||
|
|
||||||
|
std::set<PlayerColor> disconnectedPlayers;
|
||||||
|
|
||||||
boost::optional<BattleAction> curbaction;
|
boost::optional<BattleAction> curbaction;
|
||||||
|
|
||||||
@ -157,6 +159,8 @@ public:
|
|||||||
|
|
||||||
void save(const std::string & fname);
|
void save(const std::string & fname);
|
||||||
void endGame();
|
void endGame();
|
||||||
|
|
||||||
|
void processDisconnectedPlayers();
|
||||||
|
|
||||||
void initMapHandler();
|
void initMapHandler();
|
||||||
void initPlayerEnvironments();
|
void initPlayerEnvironments();
|
||||||
|
@ -811,6 +811,8 @@ void YourTurn::applyCl(CClient *cl)
|
|||||||
|
|
||||||
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
|
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
|
||||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
||||||
|
|
||||||
|
cl->processDisconnectedPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveGameClient::applyCl(CClient *cl)
|
void SaveGameClient::applyCl(CClient *cl)
|
||||||
|
@ -934,6 +934,10 @@ void CAdvMapInt::activate()
|
|||||||
|
|
||||||
screenBuf = screen;
|
screenBuf = screen;
|
||||||
GH.statusbar = statusbar;
|
GH.statusbar = statusbar;
|
||||||
|
|
||||||
|
if(LOCPLINT)
|
||||||
|
LOCPLINT->cingconsole->activate();
|
||||||
|
|
||||||
if(!duringAITurn)
|
if(!duringAITurn)
|
||||||
{
|
{
|
||||||
activeMapPanel->activate();
|
activeMapPanel->activate();
|
||||||
@ -945,8 +949,6 @@ void CAdvMapInt::activate()
|
|||||||
}
|
}
|
||||||
minimap.activate();
|
minimap.activate();
|
||||||
terrain.activate();
|
terrain.activate();
|
||||||
if(LOCPLINT)
|
|
||||||
LOCPLINT->cingconsole->activate();
|
|
||||||
|
|
||||||
GH.fakeMouseMove(); //to restore the cursor
|
GH.fakeMouseMove(); //to restore the cursor
|
||||||
}
|
}
|
||||||
@ -970,8 +972,6 @@ void CAdvMapInt::deactivate()
|
|||||||
}
|
}
|
||||||
minimap.deactivate();
|
minimap.deactivate();
|
||||||
terrain.deactivate();
|
terrain.deactivate();
|
||||||
if(LOCPLINT)
|
|
||||||
LOCPLINT->cingconsole->deactivate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1532,8 +1532,6 @@ void CAdvMapInt::endingTurn()
|
|||||||
if(settings["session"]["spectate"].Bool())
|
if(settings["session"]["spectate"].Bool())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(LOCPLINT->cingconsole->active)
|
|
||||||
LOCPLINT->cingconsole->deactivate();
|
|
||||||
LOCPLINT->makingTurn = false;
|
LOCPLINT->makingTurn = false;
|
||||||
LOCPLINT->cb->endTurn();
|
LOCPLINT->cb->endTurn();
|
||||||
CCS->soundh->ambientStopAllChannels();
|
CCS->soundh->ambientStopAllChannels();
|
||||||
|
@ -1330,12 +1330,15 @@ void CGameHandler::handleClientDisconnection(std::shared_ptr<CConnection> c)
|
|||||||
for(auto & playerConnections : connections)
|
for(auto & playerConnections : connections)
|
||||||
{
|
{
|
||||||
PlayerColor playerId = playerConnections.first;
|
PlayerColor playerId = playerConnections.first;
|
||||||
auto & playerSettings = gs->scenarioOps->getIthPlayersSettings(playerId);
|
auto * playerSettings = gs->scenarioOps->getPlayersSettings(playerId.getNum());
|
||||||
|
if(!playerSettings)
|
||||||
|
continue;
|
||||||
|
|
||||||
for(auto & playerConnection : playerConnections.second)
|
for(auto & playerConnection : playerConnections.second)
|
||||||
{
|
{
|
||||||
if(playerConnection == c)
|
if(playerConnection == c)
|
||||||
{
|
{
|
||||||
std::string messageText = boost::str(boost::format("%s (cid %d) was disconnected") % playerSettings.name % c->connectionID);
|
std::string messageText = boost::str(boost::format("%s (cid %d) was disconnected") % playerSettings->name % c->connectionID);
|
||||||
playerMessage(playerId, messageText, ObjectInstanceID{});
|
playerMessage(playerId, messageText, ObjectInstanceID{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3393,6 +3396,11 @@ bool CGameHandler::arrangeStacks(ObjectInstanceID id1, ObjectInstanceID id2, ui8
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CGameHandler::hasPlayerAt(PlayerColor player, std::shared_ptr<CConnection> c) const
|
||||||
|
{
|
||||||
|
return connections.at(player).count(c);
|
||||||
|
}
|
||||||
|
|
||||||
PlayerColor CGameHandler::getPlayerAt(std::shared_ptr<CConnection> c) const
|
PlayerColor CGameHandler::getPlayerAt(std::shared_ptr<CConnection> c) const
|
||||||
{
|
{
|
||||||
std::set<PlayerColor> all;
|
std::set<PlayerColor> all;
|
||||||
|
@ -223,6 +223,7 @@ public:
|
|||||||
void handleClientDisconnection(std::shared_ptr<CConnection> c);
|
void handleClientDisconnection(std::shared_ptr<CConnection> c);
|
||||||
void handleReceivedPack(CPackForServer * pack);
|
void handleReceivedPack(CPackForServer * pack);
|
||||||
PlayerColor getPlayerAt(std::shared_ptr<CConnection> c) const;
|
PlayerColor getPlayerAt(std::shared_ptr<CConnection> c) const;
|
||||||
|
bool hasPlayerAt(PlayerColor player, std::shared_ptr<CConnection> c) const;
|
||||||
|
|
||||||
void playerMessage(PlayerColor player, const std::string &message, ObjectInstanceID currObj);
|
void playerMessage(PlayerColor player, const std::string &message, ObjectInstanceID currObj);
|
||||||
void updateGateState();
|
void updateGateState();
|
||||||
|
@ -61,7 +61,7 @@ void CPackForServer::throwOnWrongOwner(CGameHandler * gh, ObjectInstanceID id)
|
|||||||
|
|
||||||
void CPackForServer::throwOnWrongPlayer(CGameHandler * gh, PlayerColor player)
|
void CPackForServer::throwOnWrongPlayer(CGameHandler * gh, PlayerColor player)
|
||||||
{
|
{
|
||||||
if(player != gh->getPlayerAt(c))
|
if(!gh->hasPlayerAt(player, c) && player != gh->getPlayerAt(c))
|
||||||
{
|
{
|
||||||
wrongPlayerMessage(gh, player);
|
wrongPlayerMessage(gh, player);
|
||||||
throwNotAllowedAction();
|
throwNotAllowedAction();
|
||||||
@ -381,11 +381,8 @@ bool CastAdvSpell::applyGh(CGameHandler * gh)
|
|||||||
bool PlayerMessage::applyGh(CGameHandler * gh)
|
bool PlayerMessage::applyGh(CGameHandler * gh)
|
||||||
{
|
{
|
||||||
if(!player.isSpectator()) // TODO: clearly not a great way to verify permissions
|
if(!player.isSpectator()) // TODO: clearly not a great way to verify permissions
|
||||||
{
|
|
||||||
throwOnWrongPlayer(gh, player);
|
throwOnWrongPlayer(gh, player);
|
||||||
if(gh->getPlayerAt(this->c) != player)
|
|
||||||
throwNotAllowedAction();
|
|
||||||
}
|
|
||||||
gh->playerMessage(player, text, currObj);
|
gh->playerMessage(player, text, currObj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user