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
This commit is contained in:
jason@long.name 2013-05-28 01:55:49 +00:00
parent 25751e73c4
commit f5e1793592
3 changed files with 47 additions and 29 deletions

View file

@ -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;

View file

@ -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
//

View file

@ -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;
}
}