MCPcopy Create free account
hub / github.com/SimHacker/micropolis / doCommercial

Method doCommercial

MicropolisCore/src/MicropolisEngine/src/zone.cpp:751–800  ·  view source on GitHub ↗

* Handle commercial zone. * @param pos Position of the commercial zone. * @param zonePwrFlg Does the zone have power? * @todo Make zonePwrFlg a boolean. */

Source from the content-addressed store, hash-verified

749 * @todo Make zonePwrFlg a boolean.
750 */
751void Micropolis::doCommercial(const Position &pos, bool zonePower)
752{
753 short tpop, TrfGood;
754 short zscore, locvalve, value;
755
756 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
757
758 comZonePop++;
759 tpop = getComZonePop(tile);
760 comPop += tpop;
761
762 if (tpop > getRandom(5)) {
763 /* Try driving from commercial to industrial */
764 TrfGood = makeTraffic(pos, ZT_INDUSTRIAL);
765 } else {
766 TrfGood = 1;
767 }
768
769 if (TrfGood == -1) {
770 value = getLandPollutionValue(pos);
771 doComOut(pos, tpop, value);
772 return;
773 }
774
775 if (!(getRandom16() & 7)) {
776
777 locvalve = evalCom(pos, TrfGood);
778 zscore = comValve + locvalve;
779
780 if (!zonePower) {
781 zscore = -500;
782 }
783
784 if (TrfGood &&
785 (zscore > -350) &&
786 (((short)(zscore - 26380)) > ((short)getRandom16Signed()))) {
787 value = getLandPollutionValue(pos);
788 doComIn(pos, tpop, value);
789 return;
790 }
791
792 if ((zscore < 350) &&
793 (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) {
794 value = getLandPollutionValue(pos);
795 doComOut(pos, tpop, value);
796 }
797
798 }
799
800}
801
802
803/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected