* Handle rail track. * Generate a train, and handle road deteriorating effects. * @param pos Position of the rail. */
| 1003 | * @param pos Position of the rail. |
| 1004 | */ |
| 1005 | void Micropolis::doRail(const Position &pos) |
| 1006 | { |
| 1007 | railTotal++; |
| 1008 | |
| 1009 | generateTrain(pos.posX, pos.posY); |
| 1010 | |
| 1011 | if (roadEffect < (15 * MAX_ROAD_EFFECT / 16)) { |
| 1012 | |
| 1013 | // roadEffect < 15/16 of max road, enable deteriorating rail |
| 1014 | if (!(getRandom16() & 511)) { |
| 1015 | |
| 1016 | MapValue curValue = map[pos.posX][pos.posY]; |
| 1017 | if (!(curValue & CONDBIT)) { |
| 1018 | |
| 1019 | // Otherwise the '(getRandom16() & 31)' makes no sense |
| 1020 | assert(MAX_ROAD_EFFECT == 32); |
| 1021 | if (roadEffect < (getRandom16() & 31)) { |
| 1022 | MapTile tile = curValue & LOMASK; |
| 1023 | if (tile < RAILBASE + 2) { |
| 1024 | map[pos.posX][pos.posY] = RIVER; |
| 1025 | } else { |
| 1026 | map[pos.posX][pos.posY] = randomRubble(); |
| 1027 | } |
| 1028 | return; |
| 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | |
| 1036 | /** |
nothing calls this directly
no test coverage detected