* Handle residential zone. * @param pos Center tile of the residential zone. * @param zonePwrFlg Does the zone have power? */
| 532 | * @param zonePwrFlg Does the zone have power? |
| 533 | */ |
| 534 | void Micropolis::doResidential(const Position &pos, bool zonePower) |
| 535 | { |
| 536 | short tpop, zscore, locvalve, value, TrfGood; |
| 537 | |
| 538 | resZonePop++; |
| 539 | |
| 540 | MapTile tile = map[pos.posX][pos.posY] & LOMASK; |
| 541 | |
| 542 | if (tile == FREEZ) { |
| 543 | tpop = doFreePop(pos); |
| 544 | } else { |
| 545 | tpop = getResZonePop(tile); |
| 546 | } |
| 547 | |
| 548 | resPop += tpop; |
| 549 | |
| 550 | if (tpop > getRandom(35)) { |
| 551 | /* Try driving from residential to commercial */ |
| 552 | TrfGood = makeTraffic(pos, ZT_COMMERCIAL); |
| 553 | } else { |
| 554 | TrfGood = 1; |
| 555 | } |
| 556 | |
| 557 | if (TrfGood == -1) { |
| 558 | value = getLandPollutionValue(pos); |
| 559 | doResOut(pos, tpop, value); |
| 560 | return; |
| 561 | } |
| 562 | |
| 563 | if (tile == FREEZ || !(getRandom16() & 7)) { |
| 564 | |
| 565 | locvalve = evalRes(pos, TrfGood); |
| 566 | zscore = resValve + locvalve; |
| 567 | |
| 568 | if (!zonePower) { |
| 569 | zscore = -500; |
| 570 | } |
| 571 | |
| 572 | if (zscore > -350 && |
| 573 | ((short)(zscore - 26380) > ((short)getRandom16Signed()))) { |
| 574 | |
| 575 | if (!tpop && !(getRandom16() & 3)) { |
| 576 | makeHospital(pos); |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | value = getLandPollutionValue(pos); |
| 581 | doResIn(pos, tpop, value); |
| 582 | return; |
| 583 | } |
| 584 | |
| 585 | if (zscore < 350 && |
| 586 | (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) { |
| 587 | value = getLandPollutionValue(pos); |
| 588 | doResOut(pos, tpop, value); |
| 589 | } |
| 590 | } |
| 591 | } |
nothing calls this directly
no outgoing calls
no test coverage detected