* Lay a wire, 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. */
| 447 | * @return Tool result. |
| 448 | */ |
| 449 | ToolResult Micropolis::layWire(int x, int y, ToolEffects *effects) |
| 450 | { |
| 451 | int cost = 5; |
| 452 | |
| 453 | MapTile tile = effects->getMapTile(x, y); |
| 454 | |
| 455 | tile = neutralizeRoad(tile); |
| 456 | |
| 457 | switch (tile) { |
| 458 | |
| 459 | case DIRT: /* Wire on Dirt */ |
| 460 | |
| 461 | effects->setMapValue(x, y, LHPOWER | CONDBIT | BURNBIT | BULLBIT); |
| 462 | |
| 463 | break; |
| 464 | |
| 465 | case RIVER: /* Wire on Water */ |
| 466 | case REDGE: |
| 467 | case CHANNEL: /* Check how to lay underwater wire, if possible. */ |
| 468 | |
| 469 | cost = 25; |
| 470 | |
| 471 | if (x < WORLD_W - 1) { |
| 472 | tile = effects->getMapValue(x + 1, y); |
| 473 | if (tile & CONDBIT) { |
| 474 | tile &= LOMASK; |
| 475 | tile = neutralizeRoad(tile); |
| 476 | if (tile != HROADPOWER && tile != RAILHPOWERV && tile != HPOWER) { |
| 477 | effects->setMapValue(x, y, VPOWER | CONDBIT | BULLBIT); |
| 478 | break; |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if (x > 0) { |
| 484 | tile = effects->getMapValue(x - 1, y); |
| 485 | if (tile & CONDBIT) { |
| 486 | tile &= LOMASK; |
| 487 | tile = neutralizeRoad(tile); |
| 488 | if (tile != HROADPOWER && tile != RAILHPOWERV && tile != HPOWER) { |
| 489 | effects->setMapValue(x, y, VPOWER | CONDBIT | BULLBIT); |
| 490 | break; |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | if (y < WORLD_H - 1) { |
| 496 | tile = effects->getMapValue(x, y + 1); |
| 497 | if (tile & CONDBIT) { |
| 498 | tile &= LOMASK; |
| 499 | tile = neutralizeRoad(tile); |
| 500 | if (tile != VROADPOWER && tile != RAILVPOWERH && tile != VPOWER) { |
| 501 | effects->setMapValue(x, y, HPOWER | CONDBIT | BULLBIT); |
| 502 | break; |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 |
nothing calls this directly
no test coverage detected