mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
Some fixes for previous commit.
This commit is contained in:
parent
716c324695
commit
641aa13526
@ -167,7 +167,7 @@ struct YourTurn : public CPackForClient //100
|
|||||||
DLL_LINKAGE void applyGs(CGameState *gs);
|
DLL_LINKAGE void applyGs(CGameState *gs);
|
||||||
|
|
||||||
PlayerColor player;
|
PlayerColor player;
|
||||||
ui8 daysWithoutCastle;
|
boost::optional<ui8> daysWithoutCastle;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -1587,21 +1587,19 @@ void CGameHandler::run(bool resume)
|
|||||||
{
|
{
|
||||||
auto playerColor = *it;
|
auto playerColor = *it;
|
||||||
|
|
||||||
auto playerState = gs->players[playerColor];
|
PlayerState * playerState = &gs->players[playerColor]; //can't copy CBonusSystemNode by value
|
||||||
if (playerState.status == EPlayerStatus::INGAME)
|
if (playerState->status == EPlayerStatus::INGAME)
|
||||||
{
|
{
|
||||||
states.setFlag (playerColor, &PlayerStatus::makingTurn, true);
|
|
||||||
|
|
||||||
//count days without town
|
//count days without town
|
||||||
if (playerState.towns.empty())
|
if (playerState->towns.empty())
|
||||||
{
|
{
|
||||||
if (playerState.daysWithoutCastle)
|
if (playerState->daysWithoutCastle)
|
||||||
++(*playerState.daysWithoutCastle);
|
++(*playerState->daysWithoutCastle);
|
||||||
else playerState.daysWithoutCastle = 0;
|
else playerState->daysWithoutCastle = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerState.daysWithoutCastle = boost::none; //TODO: reset this immediatelly when player conquers any castle
|
playerState->daysWithoutCastle = boost::none; //TODO: reset this immediatelly when player conquers any castle
|
||||||
}
|
}
|
||||||
|
|
||||||
//if player runs out of time, he shouldn't get the turn (especially AI)
|
//if player runs out of time, he shouldn't get the turn (especially AI)
|
||||||
@ -1611,20 +1609,23 @@ void CGameHandler::run(bool resume)
|
|||||||
{ //player lost at the beginning of his turn
|
{ //player lost at the beginning of his turn
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else //give normal turn
|
||||||
YourTurn yt;
|
|
||||||
yt.player = playerColor;
|
|
||||||
//Change local daysWithoutCastle counter for local interface message //TODO: needed?
|
|
||||||
if (playerState.daysWithoutCastle)
|
|
||||||
yt.daysWithoutCastle = playerState.daysWithoutCastle.get();
|
|
||||||
applyAndSend(&yt);
|
|
||||||
|
|
||||||
//wait till turn is done
|
|
||||||
boost::unique_lock<boost::mutex> lock(states.mx);
|
|
||||||
while(states.players.at(playerColor).makingTurn && !end2)
|
|
||||||
{
|
{
|
||||||
static time_duration p = milliseconds(200);
|
states.setFlag(playerColor, &PlayerStatus::makingTurn, true);
|
||||||
states.cv.timed_wait(lock,p);
|
|
||||||
|
YourTurn yt;
|
||||||
|
yt.player = playerColor;
|
||||||
|
//Change local daysWithoutCastle counter for local interface message //TODO: needed?
|
||||||
|
yt.daysWithoutCastle = playerState->daysWithoutCastle;
|
||||||
|
applyAndSend(&yt);
|
||||||
|
|
||||||
|
//wait till turn is done
|
||||||
|
boost::unique_lock<boost::mutex> lock(states.mx);
|
||||||
|
while (states.players.at(playerColor).makingTurn && !end2)
|
||||||
|
{
|
||||||
|
static time_duration p = milliseconds(100);
|
||||||
|
states.cv.timed_wait(lock, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user