refactor: move checkZonePower down a level

(This will allow elimination of the doZone() intermediary function)

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@831 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-09-01 21:33:56 +00:00
parent 1e4dd42655
commit 070cd90727

View file

@ -414,36 +414,27 @@ class MapScanner
*/ */
void doZone() void doZone()
{ {
// set power bit in map, from powermap
boolean zonePwrFlag = checkZonePower();
if (isSpecialZone(cchr)) if (isSpecialZone(cchr))
{ {
doSpecialZone(zonePwrFlag); doSpecialZone();
return;
} }
else if (isResidentialZone(cchr))
if (isResidentialZone(cchr))
{ {
doResidential(zonePwrFlag); doResidential();
return;
} }
else if (isHospitalOrChurch(cchr))
if (isHospitalOrChurch(cchr))
{ {
doHospitalChurch(zonePwrFlag); doHospitalChurch();
return;
} }
else if (isCommercialZone(cchr))
if (isCommercialZone(cchr))
{ {
doCommercial(zonePwrFlag); doCommercial();
return;
} }
else
{
assert isIndustrialZone(cchr); assert isIndustrialZone(cchr);
doIndustrial(zonePwrFlag); doIndustrial();
return; }
} }
boolean checkZonePower() boolean checkZonePower()
@ -538,10 +529,10 @@ class MapScanner
/** /**
* Called when the current tile is the key tile of a "special" zone. * Called when the current tile is the key tile of a "special" zone.
* @param powerOn indicates whether the building has power
*/ */
void doSpecialZone(boolean powerOn) void doSpecialZone()
{ {
boolean powerOn = checkZonePower();
switch (cchr9) switch (cchr9)
{ {
case POWERPLANT: case POWERPLANT:
@ -688,10 +679,10 @@ class MapScanner
/** /**
* Called when the current tile is the key tile of a * Called when the current tile is the key tile of a
* hospital or church. * hospital or church.
* @param powerOn indicates whether the building has power
*/ */
void doHospitalChurch(boolean powerOn) void doHospitalChurch()
{ {
boolean powerOn = checkZonePower();
if (cchr9 == HOSPITAL) if (cchr9 == HOSPITAL)
{ {
city.hospitalCount++; city.hospitalCount++;
@ -771,10 +762,10 @@ class MapScanner
/** /**
* Called when the current tile is the key tile of a commercial * Called when the current tile is the key tile of a commercial
* zone. * zone.
* @param powerOn indicates whether the building has power
*/ */
void doCommercial(boolean powerOn) void doCommercial()
{ {
boolean powerOn = checkZonePower();
city.comZoneCount++; city.comZoneCount++;
int tpop = commercialZonePop(cchr); int tpop = commercialZonePop(cchr);
@ -825,10 +816,10 @@ class MapScanner
/** /**
* Called when the current tile is the key tile of an * Called when the current tile is the key tile of an
* industrial zone. * industrial zone.
* @param powerOn indicates whether the building has power
*/ */
void doIndustrial(boolean powerOn) void doIndustrial()
{ {
boolean powerOn = checkZonePower();
city.indZoneCount++; city.indZoneCount++;
int tpop = industrialZonePop(cchr); int tpop = industrialZonePop(cchr);
@ -877,10 +868,10 @@ class MapScanner
/** /**
* Called when the current tile is the key tile of a * Called when the current tile is the key tile of a
* residential zone. * residential zone.
* @param powerOn indicates whether the building has power
*/ */
void doResidential(boolean powerOn) void doResidential()
{ {
boolean powerOn = checkZonePower();
city.resZoneCount++; city.resZoneCount++;
int tpop; //population of this zone int tpop; //population of this zone