mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Cleaning error messages at access to players.
This commit is contained in:
parent
d9273b3b2a
commit
36a7cff998
@ -391,7 +391,7 @@ EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTow
|
||||
|
||||
if(ID == BuildingID::CAPITOL)
|
||||
{
|
||||
const PlayerState *ps = getPlayer(t->tempOwner);
|
||||
const PlayerState *ps = getPlayer(t->tempOwner, false);
|
||||
if(ps)
|
||||
{
|
||||
for(const CGTownInstance *t : ps->towns)
|
||||
|
@ -858,9 +858,14 @@ void CBonusSystemNode::newChildAttached(CBonusSystemNode *child)
|
||||
|
||||
void CBonusSystemNode::childDetached(CBonusSystemNode *child)
|
||||
{
|
||||
assert(vstd::contains(children, child));
|
||||
children -= child;
|
||||
//BONUS_LOG_LINE(child->nodeName() << " #detached from# " << nodeName());
|
||||
if (vstd::contains(children, child))
|
||||
children -= child;
|
||||
else
|
||||
{
|
||||
logBonus->errorStream() << std::string("Error!" + child->nodeName() + " #cannot be detached from# " + nodeName());
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CBonusSystemNode::detachFromAll()
|
||||
|
@ -4758,10 +4758,11 @@ void CGameHandler::handleTimeEvents()
|
||||
{
|
||||
CMapEvent ev = gs->map->events.front();
|
||||
|
||||
for (auto p : gs->players)
|
||||
for (int player = 0; player < PlayerColor::PLAYER_LIMIT_I; player++)
|
||||
{
|
||||
auto player = p.first.getNum();
|
||||
auto pinfo = &p.second;
|
||||
auto color = PlayerColor(player);
|
||||
|
||||
PlayerState *pinfo = gs->getPlayer(color, false); //do not output error if player does not exist
|
||||
|
||||
if( pinfo //player exists
|
||||
&& (ev.players & 1<<player) //event is enabled to this player
|
||||
@ -4772,12 +4773,12 @@ void CGameHandler::handleTimeEvents()
|
||||
{
|
||||
//give resources
|
||||
SetResources sr;
|
||||
sr.player = PlayerColor(player);
|
||||
sr.player = color;
|
||||
sr.res = pinfo->resources + ev.resources;
|
||||
|
||||
//prepare dialog
|
||||
InfoWindow iw;
|
||||
iw.player = PlayerColor(player);
|
||||
iw.player = color;
|
||||
iw.text << ev.message;
|
||||
|
||||
for (int i=0; i<ev.resources.size(); i++)
|
||||
@ -4825,7 +4826,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
{
|
||||
PlayerColor player = town->tempOwner;
|
||||
CCastleEvent ev = town->events.front();
|
||||
PlayerState *pinfo = gs->getPlayer(player);
|
||||
PlayerState *pinfo = gs->getPlayer(player, false);
|
||||
|
||||
if( pinfo //player exists
|
||||
&& (ev.players & 1<<player.getNum()) //event is enabled to this player
|
||||
@ -5081,7 +5082,7 @@ void CGameHandler::checkVictoryLossConditions(const std::set<PlayerColor> & play
|
||||
{
|
||||
for(auto playerColor : playerColors)
|
||||
{
|
||||
if(gs->getPlayer(playerColor))
|
||||
if(gs->getPlayer(playerColor, false))
|
||||
checkVictoryLossConditionsForPlayer(playerColor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user