* Lay a road, and update road around it. * @param x X map coordinate. * @param y Y map coordinate. * @param effects Modification collecting object. * @return Tool result. */
| 258 | * @return Tool result. |
| 259 | */ |
| 260 | ToolResult Micropolis::layRoad(int x, int y, ToolEffects *effects) |
| 261 | { |
| 262 | int cost = 10; |
| 263 | |
| 264 | MapTile tile = effects->getMapTile(x, y); |
| 265 | |
| 266 | switch (tile) { |
| 267 | |
| 268 | case DIRT: |
| 269 | effects->setMapValue(x, y, ROADS | BULLBIT | BURNBIT); |
| 270 | break; |
| 271 | |
| 272 | case RIVER: /* Road on Water */ |
| 273 | case REDGE: |
| 274 | case CHANNEL: /* Check how to build bridges, if possible. */ |
| 275 | cost = 50; |
| 276 | |
| 277 | if (x < WORLD_W - 1) { |
| 278 | tile = effects->getMapTile(x + 1, y); |
| 279 | tile = neutralizeRoad(tile); |
| 280 | if (tile == VRAILROAD || tile == HBRIDGE |
| 281 | || (tile >= ROADS && tile <= HROADPOWER)) { |
| 282 | effects->setMapValue(x, y, HBRIDGE | BULLBIT); |
| 283 | break; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if (x > 0) { |
| 288 | tile = effects->getMapTile(x - 1, y); |
| 289 | tile = neutralizeRoad(tile); |
| 290 | if (tile == VRAILROAD || tile == HBRIDGE |
| 291 | || (tile >= ROADS && tile <= INTERSECTION)) { |
| 292 | effects->setMapValue(x, y, HBRIDGE | BULLBIT); |
| 293 | break; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if (y < WORLD_H - 1) { |
| 298 | tile = effects->getMapTile(x, y + 1); |
| 299 | tile = neutralizeRoad(tile); |
| 300 | if (tile == HRAILROAD || tile == VROADPOWER |
| 301 | || (tile >= VBRIDGE && tile <= INTERSECTION)) { |
| 302 | effects->setMapValue(x, y, VBRIDGE | BULLBIT); |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if (y > 0) { |
| 308 | tile = effects->getMapTile(x, y - 1); |
| 309 | tile = neutralizeRoad(tile); |
| 310 | if (tile == HRAILROAD || tile == VROADPOWER |
| 311 | || (tile >= VBRIDGE && tile <= INTERSECTION)) { |
| 312 | effects->setMapValue(x, y, VBRIDGE | BULLBIT); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /* Can't do road... */ |
nothing calls this directly
no test coverage detected