* Grows the town with an extra house. * Check if there are enough neighbour house tiles * next to the current tile. If there are enough * add another house. * * @param t The current town. * @param tile The target tile for the extra house. * @return true if an extra house has been added. */
| 1211 | * @return true if an extra house has been added. |
| 1212 | */ |
| 1213 | static bool GrowTownWithExtraHouse(Town *t, TileIndex tile, TownExpandModes modes) |
| 1214 | { |
| 1215 | /* We can't look further than that. */ |
| 1216 | if (DistanceFromEdge(tile) == 0) return false; |
| 1217 | |
| 1218 | uint counter = 0; // counts the house neighbour tiles |
| 1219 | |
| 1220 | /* Check the tiles E,N,W and S of the current tile for houses */ |
| 1221 | for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
| 1222 | /* Count both void and house tiles for checking whether there |
| 1223 | * are enough houses in the area. This to make it likely that |
| 1224 | * houses get build up to the edge of the map. */ |
| 1225 | switch (GetTileType(TileAddByDiagDir(tile, dir))) { |
| 1226 | case MP_HOUSE: |
| 1227 | case MP_VOID: |
| 1228 | counter++; |
| 1229 | break; |
| 1230 | |
| 1231 | default: |
| 1232 | break; |
| 1233 | } |
| 1234 | |
| 1235 | /* If there are enough neighbours stop here */ |
| 1236 | if (counter >= 3) { |
| 1237 | return TryBuildTownHouse(t, tile, modes); |
| 1238 | } |
| 1239 | } |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
| 1243 | /** |
| 1244 | * Grows the town with a road piece. |
no test coverage detected