void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, int player/*=-1*/, int mode/*=0*/ ) const { if(player >= GameConstants::PLAYER_LIMIT) { tlog1 << "Illegal call to getTilesInRange!\n"; return; } if (radious == -1) //reveal entire map getAllTiles (tiles, player, -1, 0); else { const TeamState * team = gs->getPlayerTeam(player); for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++) { for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++) { double distance = pos.dist2d(int3(xd,yd,pos.z)) - 0.5; if(distance <= radious) { if(player < 0 || (mode == 1 && team->fogOfWarMap[xd][yd][pos.z]==0) || (mode == -1 && team->fogOfWarMap[xd][yd][pos.z]==1) ) tiles.insert(int3(xd,yd,pos.z)); } } } } }
void CPrivilagedInfoCallback::getTilesInRange( std::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player/*=uninit*/, int mode/*=0*/, bool patrolDistance/*=false*/) const { if(!!player && *player >= PlayerColor::PLAYER_LIMIT) { logGlobal->errorStream() << "Illegal call to getTilesInRange!"; return; } if (radious == -1) //reveal entire map getAllTiles (tiles, player, -1, 0); else { const TeamState * team = !player ? nullptr : gs->getPlayerTeam(*player); for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++) { for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++) { int3 tilePos(xd,yd,pos.z); double distance; if(patrolDistance) distance = pos.mandist2d(tilePos); else distance = pos.dist2d(tilePos) - 0.5; if(distance <= radious) { if(!player || (mode == 1 && team->fogOfWarMap[xd][yd][pos.z]==0) || (mode == -1 && team->fogOfWarMap[xd][yd][pos.z]==1) ) tiles.insert(int3(xd,yd,pos.z)); } } } } }