From 070cd9072715ed23b13eb3e78d3edee8ea72f1e4 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sun, 1 Sep 2013 21:33:56 +0000 Subject: [PATCH] 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 --- src/micropolisj/engine/MapScanner.java | 53 +++++++++++--------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index be3ca2a..290905c 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -414,36 +414,27 @@ class MapScanner */ void doZone() { - // set power bit in map, from powermap - boolean zonePwrFlag = checkZonePower(); - if (isSpecialZone(cchr)) { - doSpecialZone(zonePwrFlag); - return; + doSpecialZone(); } - - if (isResidentialZone(cchr)) + else if (isResidentialZone(cchr)) { - doResidential(zonePwrFlag); - return; + doResidential(); } - - if (isHospitalOrChurch(cchr)) + else if (isHospitalOrChurch(cchr)) { - doHospitalChurch(zonePwrFlag); - return; + doHospitalChurch(); } - - if (isCommercialZone(cchr)) + else if (isCommercialZone(cchr)) { - doCommercial(zonePwrFlag); - return; + doCommercial(); + } + else + { + assert isIndustrialZone(cchr); + doIndustrial(); } - - assert isIndustrialZone(cchr); - doIndustrial(zonePwrFlag); - return; } boolean checkZonePower() @@ -538,10 +529,10 @@ class MapScanner /** * 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) { case POWERPLANT: @@ -688,10 +679,10 @@ class MapScanner /** * Called when the current tile is the key tile of a * hospital or church. - * @param powerOn indicates whether the building has power */ - void doHospitalChurch(boolean powerOn) + void doHospitalChurch() { + boolean powerOn = checkZonePower(); if (cchr9 == HOSPITAL) { city.hospitalCount++; @@ -771,10 +762,10 @@ class MapScanner /** * Called when the current tile is the key tile of a commercial * zone. - * @param powerOn indicates whether the building has power */ - void doCommercial(boolean powerOn) + void doCommercial() { + boolean powerOn = checkZonePower(); city.comZoneCount++; int tpop = commercialZonePop(cchr); @@ -825,10 +816,10 @@ class MapScanner /** * Called when the current tile is the key tile of an * industrial zone. - * @param powerOn indicates whether the building has power */ - void doIndustrial(boolean powerOn) + void doIndustrial() { + boolean powerOn = checkZonePower(); city.indZoneCount++; int tpop = industrialZonePop(cchr); @@ -877,10 +868,10 @@ class MapScanner /** * Called when the current tile is the key tile of a * residential zone. - * @param powerOn indicates whether the building has power */ - void doResidential(boolean powerOn) + void doResidential() { + boolean powerOn = checkZonePower(); city.resZoneCount++; int tpop; //population of this zone