* Detect a change in city class, and produce a message if the player has * reached the next class. * @todo This code is very closely related to Micropolis::doPopNum(). * Maybe merge both in some way? * (This function gets called much more often however then doPopNum(). * Also, at the first call, the difference between thisCityPop and * cityPop is huge.) */
| 238 | * cityPop is huge.) |
| 239 | */ |
| 240 | void Micropolis::checkGrowth() |
| 241 | { |
| 242 | if ((cityTime & 3) == 0) { |
| 243 | short category = 0; |
| 244 | Quad thisCityPop = getPopulation(); |
| 245 | |
| 246 | if (cityPopLast > 0) { |
| 247 | |
| 248 | CityClass lastClass = getCityClass(cityPopLast); |
| 249 | CityClass newClass = getCityClass(thisCityPop); |
| 250 | |
| 251 | if (lastClass != newClass) { |
| 252 | |
| 253 | // Switched class, find appropiate message. |
| 254 | switch (newClass) { |
| 255 | |
| 256 | case CC_VILLAGE: |
| 257 | // Don't mention it. |
| 258 | break; |
| 259 | |
| 260 | case CC_TOWN: |
| 261 | category = MESSAGE_REACHED_TOWN; |
| 262 | break; |
| 263 | |
| 264 | case CC_CITY: |
| 265 | category = MESSAGE_REACHED_CITY; |
| 266 | break; |
| 267 | |
| 268 | case CC_CAPITAL: |
| 269 | category = MESSAGE_REACHED_CAPITAL; |
| 270 | break; |
| 271 | |
| 272 | case CC_METROPOLIS: |
| 273 | category = MESSAGE_REACHED_METROPOLIS; |
| 274 | break; |
| 275 | |
| 276 | case CC_MEGALOPOLIS: |
| 277 | category = MESSAGE_REACHED_MEGALOPOLIS; |
| 278 | break; |
| 279 | |
| 280 | default: |
| 281 | NOT_REACHED(); |
| 282 | break; |
| 283 | |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | if (category > 0 && category != categoryLast) { |
| 289 | sendMessage(category, NOWHERE, NOWHERE, true); |
| 290 | categoryLast = category; |
| 291 | } |
| 292 | |
| 293 | cityPopLast = thisCityPop; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 |
nothing calls this directly
no outgoing calls
no test coverage detected