/** ** Marks seen tile -- used mainly for the Fog Of War ** ** @param mf MapField-position. */ void CMap::MarkSeenTile(CMapField &mf) { const unsigned int tile = mf.getGraphicTile(); const unsigned int seentile = mf.playerInfo.SeenTile; // Nothing changed? Seeing already the correct tile. if (tile == seentile) { return; } mf.playerInfo.SeenTile = tile; #ifdef MINIMAP_UPDATE //rb - GRRRRRRRRRRRR const unsigned int index = &mf - Map.Fields; const int y = index / Info.MapWidth; const int x = index - (y * Info.MapWidth); const Vec2i pos = {x, y} #endif if (this->Tileset->TileTypeTable.empty() == false) { #ifndef MINIMAP_UPDATE //rb - GRRRRRRRRRRRR const unsigned int index = &mf - Map.Fields; const int y = index / Info.MapWidth; const int x = index - (y * Info.MapWidth); const Vec2i pos(x, y); #endif // Handle wood changes. FIXME: check if for growing wood correct? if (tile == this->Tileset->getRemovedTreeTile()) { FixNeighbors(MapFieldForest, 1, pos); } else if (seentile == this->Tileset->getRemovedTreeTile()) { FixTile(MapFieldForest, 1, pos); } else if (mf.ForestOnMap()) { FixTile(MapFieldForest, 1, pos); FixNeighbors(MapFieldForest, 1, pos); // Handle rock changes. } else if (tile == Tileset->getRemovedRockTile()) { FixNeighbors(MapFieldRocks, 1, pos); } else if (seentile == Tileset->getRemovedRockTile()) { FixTile(MapFieldRocks, 1, pos); } else if (mf.RockOnMap()) { FixTile(MapFieldRocks, 1, pos); FixNeighbors(MapFieldRocks, 1, pos); // Handle Walls changes. } else if (this->Tileset->isAWallTile(tile) || this->Tileset->isAWallTile(seentile)) { MapFixSeenWallTile(pos); MapFixSeenWallNeighbors(pos); } } #ifdef MINIMAP_UPDATE UI.Minimap.UpdateXY(pos); #endif }
/** ** Correct the surrounding fields. ** ** @param type Tiletype of tile to adjust ** @param seen 1 if updating seen value, 0 for real ** @param pos Map tile-position. */ void CMap::FixNeighbors(unsigned short type, int seen, const Vec2i &pos) { const Vec2i offset[] = {Vec2i(1, 0), Vec2i(-1, 0), Vec2i(0, 1), Vec2i(0, -1), Vec2i(-1, -1), Vec2i(-1, 1), Vec2i(1, -1), Vec2i(1, 1) }; for (unsigned int i = 0; i < sizeof(offset) / sizeof(*offset); ++i) { FixTile(type, seen, pos + offset[i]); } }
/** ** Marks seen tile -- used mainly for the Fog Of War ** ** @param x Map X tile-position. ** @param y Map Y tile-position. */ void CMap::MarkSeenTile(const unsigned int index) { CMapField &mf = *this->Field(index); const int tile = mf.Tile; const int seentile = mf.SeenTile; // // Nothing changed? Seeing already the correct tile. // if (tile == seentile) { return; } mf.SeenTile = tile; #ifdef MINIMAP_UPDATE //rb - GRRRRRRRRRRRR const int y = index / Info.MapWidth; const int x = index - (y * Info.MapWidth); const Vec2i pos = {x, y} #endif if (this->Tileset.TileTypeTable) { #ifndef MINIMAP_UPDATE //rb - GRRRRRRRRRRRR const int y = index / Info.MapWidth; const int x = index - (y * Info.MapWidth); const Vec2i pos(x, y); #endif // Handle wood changes. FIXME: check if for growing wood correct? if (seentile != this->Tileset.RemovedTree && tile == this->Tileset.RemovedTree) { FixNeighbors(MapFieldForest, 1, pos); } else if (seentile == this->Tileset.RemovedTree && tile != this->Tileset.RemovedTree) { FixTile(MapFieldForest, 1, pos); } else if (ForestOnMap(index)) { FixTile(MapFieldForest, 1, pos); FixNeighbors(MapFieldForest, 1, pos); // Handle rock changes. } else if (seentile != this->Tileset.RemovedRock && tile == Map.Tileset.RemovedRock) { FixNeighbors(MapFieldRocks, 1, pos); } else if (seentile == this->Tileset.RemovedRock && tile != Map.Tileset.RemovedRock) { FixTile(MapFieldRocks, 1, pos); } else if (RockOnMap(index)) { FixTile(MapFieldRocks, 1, pos); FixNeighbors(MapFieldRocks, 1, pos); // Handle Walls changes. } else if (this->Tileset.TileTypeTable[tile] == TileTypeHumanWall || this->Tileset.TileTypeTable[tile] == TileTypeOrcWall || this->Tileset.TileTypeTable[seentile] == TileTypeHumanWall || this->Tileset.TileTypeTable[seentile] == TileTypeOrcWall) { MapFixSeenWallTile(pos); MapFixSeenWallNeighbors(pos); } } #ifdef MINIMAP_UPDATE UI.Minimap.UpdateXY(pos); #endif }