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

Method doIndustrial

MicropolisCore/src/MicropolisEngine/src/zone.cpp:903–944  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

901 * @todo Make zonePwrFlg a boolean.
902 */
903void Micropolis::doIndustrial(const Position &pos, bool zonePower)
904{
905 short tpop, zscore, TrfGood;
906
907 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
908
909 indZonePop++;
910 setSmoke(pos, zonePower);
911 tpop = getIndZonePop(tile);
912 indPop += tpop;
913
914 if (tpop > getRandom(5)) {
915 /* Try driving from industrial to residential */
916 TrfGood = makeTraffic(pos, ZT_RESIDENTIAL);
917 } else {
918 TrfGood = 1;
919 }
920
921 if (TrfGood == -1) {
922 doIndOut(pos, tpop, getRandom16() & 1);
923 return;
924 }
925
926 if (!(getRandom16() & 7)) {
927 zscore = indValve + evalInd(TrfGood);
928
929 if (!zonePower) {
930 zscore = -500;
931 }
932
933 if (zscore > -350 &&
934 (((short)(zscore - 26380)) > ((short)getRandom16Signed()))) {
935 doIndIn(pos, tpop, getRandom16() & 1);
936 return;
937 }
938
939 if (zscore < 350 &&
940 (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) {
941 doIndOut(pos, tpop, getRandom16() & 1);
942 }
943 }
944}
945
946
947/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected