0x004BE048
| 936 | |
| 937 | // 0x004BE048 |
| 938 | uint16_t countSurroundingTrees(const Pos2& pos) |
| 939 | { |
| 940 | // Search a 10x10 area centred at pos. |
| 941 | // Initial tile position is the top left of the area. |
| 942 | auto initialTilePos = World::toTileSpace(pos) - World::TilePos2(5, 5); |
| 943 | |
| 944 | uint16_t surroundingTrees = 0; |
| 945 | for (const auto& tilePos : getClampedRange(initialTilePos, initialTilePos + TilePos2{ 10, 10 })) |
| 946 | { |
| 947 | auto tile = get(tilePos); |
| 948 | for (auto& element : tile) |
| 949 | { |
| 950 | // NB: vanilla was checking for trees above the surface element. |
| 951 | // This has been omitted from our implementation. |
| 952 | auto* tree = element.as<TreeElement>(); |
| 953 | if (tree == nullptr) |
| 954 | { |
| 955 | continue; |
| 956 | } |
| 957 | |
| 958 | if (tree->isGhost()) |
| 959 | { |
| 960 | continue; |
| 961 | } |
| 962 | |
| 963 | surroundingTrees++; |
| 964 | } |
| 965 | } |
| 966 | |
| 967 | return surroundingTrees; |
| 968 | } |
| 969 | |
| 970 | // 0x004C5604 |
| 971 | uint16_t countNearbyWaterTiles(Pos2 pos) |
no test coverage detected