MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / doFloodFill

Method doFloodFill

source/gamemap/GameMap.cpp:2155–2202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2153}
2154
2155bool GameMap::doFloodFill(Seat* seat, Tile* tile)
2156{
2157 if (!mFloodFillEnabled)
2158 return false;
2159
2160 if(tile->isFloodFillFilled(seat))
2161 return false;
2162
2163 bool hasChanged = false;
2164 // If a neigboor is colored with the same colors, we color the tile
2165 for(Tile* neigh : tile->getAllNeighbors())
2166 {
2167 // TODO: check if this can be optimized with Tile::isFloodFillPossible
2168 switch(tile->getType())
2169 {
2170 case TileType::dirt:
2171 case TileType::gold:
2172 case TileType::rock:
2173 {
2174 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::ground, neigh);
2175 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundWater, neigh);
2176 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundLava, neigh);
2177 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundWaterLava, neigh);
2178 break;
2179 }
2180 case TileType::water:
2181 {
2182 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundWater, neigh);
2183 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundWaterLava, neigh);
2184 break;
2185 }
2186 case TileType::lava:
2187 {
2188 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundLava, neigh);
2189 hasChanged |= tile->updateFloodFillFromTile(seat, FloodFillType::groundWaterLava, neigh);
2190 break;
2191 }
2192 default:
2193 continue;
2194 }
2195
2196 // If the tile is fully filled, no need to continue
2197 if(tile->isFloodFillFilled(seat))
2198 return true;
2199 }
2200
2201 return hasChanged;
2202}
2203
2204void GameMap::replaceFloodFill(Seat* seat, FloodFillType floodFillType, uint32_t colorOld, uint32_t colorNew)
2205{

Callers

nothing calls this directly

Calls 3

isFloodFillFilledMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected