* Handle road tile. * @param pos Position of the road. */
| 1050 | * @param pos Position of the road. |
| 1051 | */ |
| 1052 | void Micropolis::doRoad(const Position &pos) |
| 1053 | { |
| 1054 | short tden, z; |
| 1055 | static const short densityTable[3] = { ROADBASE, LTRFBASE, HTRFBASE }; |
| 1056 | |
| 1057 | roadTotal++; |
| 1058 | |
| 1059 | MapValue mapValue = map[pos.posX][pos.posY]; |
| 1060 | MapTile tile = mapValue & LOMASK; |
| 1061 | |
| 1062 | /* generateBus(pos.posX, pos.posY); */ |
| 1063 | |
| 1064 | if (roadEffect < (15 * MAX_ROAD_EFFECT / 16)) { |
| 1065 | // roadEffect < 15/16 of max road, enable deteriorating road |
| 1066 | if ((getRandom16() & 511) == 0) { |
| 1067 | if (!(mapValue & CONDBIT)) { |
| 1068 | assert(MAX_ROAD_EFFECT == 32); // Otherwise the '(getRandom16() & 31)' makes no sense |
| 1069 | if (roadEffect < (getRandom16() & 31)) { |
| 1070 | if ((tile & 15) < 2 || (tile & 15) == 15) { |
| 1071 | map[pos.posX][pos.posY] = RIVER; |
| 1072 | } else { |
| 1073 | map[pos.posX][pos.posY] = randomRubble(); |
| 1074 | } |
| 1075 | return; |
| 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | if ((mapValue & BURNBIT) == 0) { /* If Bridge */ |
| 1082 | roadTotal += 4; // Bridge counts as 4 road tiles |
| 1083 | if (doBridge(Position(pos.posX, pos.posY), tile)) { |
| 1084 | return; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | if (tile < LTRFBASE) { |
| 1089 | tden = 0; |
| 1090 | } else if (tile < HTRFBASE) { |
| 1091 | tden = 1; |
| 1092 | } else { |
| 1093 | roadTotal++; // Heavy traffic counts as 2 roads. |
| 1094 | tden = 2; |
| 1095 | } |
| 1096 | |
| 1097 | short trafficDensity = trafficDensityMap.worldGet(pos.posX, pos.posY) >>6; |
| 1098 | |
| 1099 | if (trafficDensity > 1) { |
| 1100 | trafficDensity--; |
| 1101 | } |
| 1102 | |
| 1103 | if (tden != trafficDensity) { /* tden 0..2 */ |
| 1104 | z = ((tile - ROADBASE) & 15) + densityTable[trafficDensity]; |
| 1105 | z |= mapValue & (ALLBITS - ANIMBIT); |
| 1106 | |
| 1107 | if (trafficDensity > 0) { |
| 1108 | z |= ANIMBIT; |
| 1109 | } |
nothing calls this directly
no test coverage detected