* Lay a rail, and update connections (rail, road, and wire) around it. * @param x X map coordinate. * @param y Y map coordinate. * @param effects Modification collecting object. * @return Tool result. */
| 351 | * @return Tool result. |
| 352 | */ |
| 353 | ToolResult Micropolis::layRail(int x, int y, ToolEffects *effects) |
| 354 | { |
| 355 | int cost = 20; |
| 356 | |
| 357 | MapTile tile = effects->getMapTile(x, y); |
| 358 | |
| 359 | tile = neutralizeRoad(tile); |
| 360 | |
| 361 | switch (tile) { |
| 362 | case DIRT: /* Rail on Dirt */ |
| 363 | |
| 364 | effects->setMapValue(x, y, LHRAIL | BULLBIT | BURNBIT); |
| 365 | |
| 366 | break; |
| 367 | |
| 368 | case RIVER: /* Rail on Water */ |
| 369 | case REDGE: |
| 370 | case CHANNEL: /* Check how to build underwater tunnel, if possible. */ |
| 371 | |
| 372 | cost = 100; |
| 373 | |
| 374 | if (x < WORLD_W - 1) { |
| 375 | tile = effects->getMapTile(x + 1, y); |
| 376 | tile = neutralizeRoad(tile); |
| 377 | if (tile == RAILHPOWERV || tile == HRAIL |
| 378 | || (tile >= LHRAIL && tile <= HRAILROAD)) { |
| 379 | effects->setMapValue(x, y, HRAIL | BULLBIT); |
| 380 | break; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | if (x > 0) { |
| 385 | tile = effects->getMapTile(x - 1, y); |
| 386 | tile = neutralizeRoad(tile); |
| 387 | if (tile == RAILHPOWERV || tile == HRAIL |
| 388 | || (tile > VRAIL && tile < VRAILROAD)) { |
| 389 | effects->setMapValue(x, y, HRAIL | BULLBIT); |
| 390 | break; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | if (y < WORLD_H - 1) { |
| 395 | tile = effects->getMapTile(x, y + 1); |
| 396 | tile = neutralizeRoad(tile); |
| 397 | if (tile == RAILVPOWERH || tile == VRAILROAD |
| 398 | || (tile > HRAIL && tile < HRAILROAD)) { |
| 399 | effects->setMapValue(x, y, VRAIL | BULLBIT); |
| 400 | break; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | if (y > 0) { |
| 405 | tile = effects->getMapTile(x, y - 1); |
| 406 | tile = neutralizeRoad(tile); |
| 407 | if (tile == RAILVPOWERH || tile == VRAILROAD |
| 408 | || (tile > HRAIL && tile < HRAILROAD)) { |
| 409 | effects->setMapValue(x, y, VRAIL | BULLBIT); |
| 410 | break; |
nothing calls this directly
no test coverage detected