const TerrainTile * CGameInfoCallback::getTile( int3 tile, bool verbose) const { ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!isVisible(tile), verbose, tile << " is not visible!", NULL); //boost::shared_lock<boost::shared_mutex> lock(*gs->mx); return &gs->map->getTile(tile); }
EPlayerStatus::EStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const { const PlayerState *ps = gs->getPlayer(player, verbose); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG); return ps->status; }
std::vector <const CGObjectInstance * > CGameInfoCallback::getVisitableObjs(int3 pos, bool verbose /*= true*/) const { std::vector<const CGObjectInstance *> ret; const TerrainTile *t = getTile(pos, verbose); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!t, verbose, pos << " is not visible!", ret); BOOST_FOREACH(const CGObjectInstance * obj, t->visitableObjects) { if(player < 0 || obj->ID != Obj::EVENT) //hide events from players ret.push_back(obj); } return ret; }
const PlayerState * CGameInfoCallback::getPlayer(TPlayerColor color, bool verbose) const { ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!hasAccess(color), verbose, "Cannot access player " << color << "info!", NULL); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!vstd::contains(gs->players,color), verbose, "Cannot find player " << color << "info!", NULL); return &gs->players[color]; }