| 658 | |
| 659 | |
| 660 | void Micropolis::smoothWater() |
| 661 | { |
| 662 | int x, y; |
| 663 | MapTile tile; |
| 664 | Direction2 dir; |
| 665 | |
| 666 | for (x = 0; x < WORLD_W; x++) { |
| 667 | for (y = 0; y < WORLD_H; y++) { |
| 668 | |
| 669 | tile = map[x][y] & LOMASK; |
| 670 | |
| 671 | /* If (x, y) is water: */ |
| 672 | if (tile >= WATER_LOW && tile <= WATER_HIGH) { |
| 673 | |
| 674 | const Position pos(x, y); |
| 675 | for (dir = DIR2_BEGIN; dir < DIR2_END; dir = increment90(dir)) { |
| 676 | |
| 677 | /* If getting a tile off-map, condition below fails. */ |
| 678 | // @note I think this may have been a bug, since it always uses DIR2_WEST instead of dir. |
| 679 | //tile = getTileFromMap(pos, DIR2_WEST, WATER_LOW); |
| 680 | tile = getTileFromMap(pos, dir, WATER_LOW); |
| 681 | |
| 682 | /* If nearest object is not water: */ |
| 683 | if (tile < WATER_LOW || tile > WATER_HIGH) { |
| 684 | map[x][y] = REDGE; /* set river edge */ |
| 685 | break; // Continue with next tile |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | for (x = 0; x < WORLD_W; x++) { |
| 693 | for (y = 0; y < WORLD_H; y++) { |
| 694 | |
| 695 | tile = map[x][y] & LOMASK; |
| 696 | |
| 697 | /* If water which is not a channel: */ |
| 698 | if (tile != CHANNEL && tile >= WATER_LOW && tile <= WATER_HIGH) { |
| 699 | |
| 700 | bool makeRiver = true; // make (x, y) a river |
| 701 | |
| 702 | const Position pos(x, y); |
| 703 | for (dir = DIR2_BEGIN; dir < DIR2_END; dir = increment90(dir)) { |
| 704 | |
| 705 | /* If getting a tile off-map, condition below fails. */ |
| 706 | // @note I think this may have been a bug, since it always uses DIR2_WEST instead of dir. |
| 707 | //tile = getTileFromMap(pos, DIR2_WEST, WATER_LOW); |
| 708 | tile = getTileFromMap(pos, dir, WATER_LOW); |
| 709 | |
| 710 | /* If nearest object is not water: */ |
| 711 | if (tile < WATER_LOW || tile > WATER_HIGH) { |
| 712 | makeRiver = false; |
| 713 | break; |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | if (makeRiver) { |
nothing calls this directly
no test coverage detected