From deb9738b6f104b38fb57287ffa3f26dd43f0b60c Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Mon, 18 Feb 2013 01:57:27 +0000 Subject: [PATCH] cleanup: repairZone: use zoneBase variable to place tiles git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@550 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/MapScanner.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index 2fd6750..eb2b23d 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -715,23 +715,25 @@ class MapScanner /** * Regenerate the tiles that make up the zone, repairing from * fire, etc. - * Only tiles that aren't rubble will be regenerated. + * Only tiles that are not rubble, radioactive, flooded, or + * on fire will be regenerated. * @param zoneCenter the tile value for the "center" tile of the zone * @param zoneSize integer (3-6) indicating the width/height of * the zone. */ void repairZone(char zoneCenter, int zoneSize) { - int cnt=0; + // from the given center tile, figure out what the + // northwest tile should be + int zoneBase = zoneCenter - 1 - zoneSize; + for (int y = 0; y < zoneSize; y++) { - for (int x = 0; x < zoneSize; x++) + for (int x = 0; x < zoneSize; x++, zoneBase++) { int xx = xpos - 1 + x; int yy = ypos - 1 + y; - cnt++; - if (city.testBounds(xx, yy)) { int thCh = city.map[yy][xx]; @@ -746,7 +748,7 @@ class MapScanner { //not rubble, radiactive, on fire or flooded city.setTile(xx,yy,(char) - (zoneCenter-2-zoneSize+cnt+CONDBIT+BURNBIT) + (zoneBase+CONDBIT+BURNBIT) ); } }