From f5e17935926be9539e88d9066b32984764839f39 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Tue, 28 May 2013 01:55:49 +0000 Subject: [PATCH] cleanup: move res/com/ind Zone Pop() functions to TileConstants git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@687 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/MapScanner.java | 6 ++-- src/micropolisj/engine/Micropolis.java | 26 -------------- src/micropolisj/engine/TileConstants.java | 44 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index f6250a0..5d6dbc0 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -778,7 +778,7 @@ class MapScanner { city.comZoneCount++; - int tpop = city.commercialZonePop(cchr9); + int tpop = commercialZonePop(cchr); city.comPop += tpop; int trafficGood; @@ -890,7 +890,7 @@ class MapScanner city.indZoneCount++; setSmoke(powerOn); - int tpop = city.industrialZonePop(cchr9); + int tpop = industrialZonePop(cchr); city.indPop += tpop; int trafficGood; @@ -949,7 +949,7 @@ class MapScanner } else { - tpop = city.residentialZonePop(cchr9); + tpop = residentialZonePop(cchr); } city.resPop += tpop; diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index c18e389..09be8ad 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -1508,32 +1508,6 @@ public class Micropolis return count; } - // counts the population in a certain type of residential zone - // a.k.a. RZPop - int residentialZonePop(char tile) - { - int czDen = ((tile - RZB) / 9) % 4; - return czDen * 8 + 16; - } - - int commercialZonePop(int tile) - { - if (tile == COMCLR) - return 0; - - int czDen = ((tile - CZB) / 9) % 5 + 1; - return czDen; - } - - int industrialZonePop(int tile) - { - if (tile == INDCLR) - return 0; - - int czDen = ((tile - IZB) / 9) % 4 + 1; - return czDen; - } - // called every several cycles; this takes the census data collected in this // cycle and records it to the history // diff --git a/src/micropolisj/engine/TileConstants.java b/src/micropolisj/engine/TileConstants.java index 320b027..fa9cd43 100644 --- a/src/micropolisj/engine/TileConstants.java +++ b/src/micropolisj/engine/TileConstants.java @@ -445,4 +445,48 @@ public class TileConstants } return (char)tile; } + + /** + * Determine the population level of a Residential zone + * tile. Note: the input tile MUST be a full-size res zone, + * it cannot be an empty zone. + * @return int multiple of 8 between 16 and 40. + */ + public static int residentialZonePop(int tile) + { + tile &= LOMASK; + int czDen = ((tile - RZB) / 9) % 4; + return czDen * 8 + 16; + } + + /** + * Determine the population level of a Commercial zone + * tile. + * The input tile MAY be an empty zone. + * @return int between 0 and 5. + */ + public static int commercialZonePop(int tile) + { + tile &= LOMASK; + if (tile == COMCLR) + return 0; + + int czDen = ((tile - CZB) / 9) % 5 + 1; + return czDen; + } + + /** + * Determine the population level of an Industrial zone tile. + * The input tile MAY be an empty zone. + * @return int between 0 and 4. + */ + public static int industrialZonePop(int tile) + { + tile &= LOMASK; + if (tile == INDCLR) + return 0; + + int czDen = ((tile - IZB) / 9) % 4 + 1; + return czDen; + } }