Unhides map tiles according to visibility, starting from the given coordinates. This algorithm only processes adjacent hidden tiles, so it must start on a hidden tile and it will not reveal hidden sections separated by already-unhidden tiles.
| 355 | // start on a hidden tile and it will not reveal hidden sections separated by |
| 356 | // already-unhidden tiles. |
| 357 | static void unhideFlood_internal(const df::coord &xy) { |
| 358 | typedef std::pair <df::coord, bool> PosAndBelow; |
| 359 | std::stack<PosAndBelow> flood; |
| 360 | flood.emplace(xy, false); |
| 361 | |
| 362 | while (!flood.empty()) { |
| 363 | PosAndBelow tile = flood.top(); |
| 364 | df::coord & current = tile.first; |
| 365 | bool & from_below = tile.second; |
| 366 | flood.pop(); |
| 367 | |
| 368 | if(!Maps::isValidTilePos(current)) |
| 369 | continue; |
| 370 | df::tile_designation *des = Maps::getTileDesignation(current); |
| 371 | if(!des || !des->bits.hidden) |
| 372 | continue; |
| 373 | |
| 374 | // we don't want constructions or ice to restrict vision (to avoid bug #1871) |
| 375 | df::tiletype *tt = Maps::getTileType(current); |
| 376 | if (!tt) |
| 377 | continue; |
| 378 | |
| 379 | bool below = false; |
| 380 | bool above = false; |
| 381 | bool sides = false; |
| 382 | bool unhide = true; |
| 383 | // By tile shape, determine behavior and action |
| 384 | switch (tileShape(*tt)) { |
| 385 | // Walls |
| 386 | case tiletype_shape::WALL: |
| 387 | if (from_below) |
| 388 | unhide = false; |
| 389 | else if (tileMaterial(*tt) == tiletype_material::CONSTRUCTION || |
| 390 | tileMaterial(*tt) == tiletype_material::FROZEN_LIQUID) |
| 391 | { |
| 392 | // treat as a floor |
| 393 | above = sides = true; |
| 394 | } |
| 395 | break; |
| 396 | // Open space |
| 397 | case tiletype_shape::NONE: |
| 398 | case tiletype_shape::EMPTY: |
| 399 | case tiletype_shape::RAMP_TOP: |
| 400 | case tiletype_shape::STAIR_UPDOWN: |
| 401 | case tiletype_shape::STAIR_DOWN: |
| 402 | case tiletype_shape::BROOK_TOP: |
| 403 | above = below = sides = true; |
| 404 | break; |
| 405 | // Floors |
| 406 | case tiletype_shape::FORTIFICATION: |
| 407 | case tiletype_shape::STAIR_UP: |
| 408 | case tiletype_shape::RAMP: |
| 409 | case tiletype_shape::FLOOR: |
| 410 | case tiletype_shape::BRANCH: |
| 411 | case tiletype_shape::TRUNK_BRANCH: |
| 412 | case tiletype_shape::TWIG: |
| 413 | case tiletype_shape::SAPLING: |
| 414 | case tiletype_shape::SHRUB: |
no test coverage detected