diff --git a/src/micropolisj/engine/Bulldozer.java b/src/micropolisj/engine/Bulldozer.java index be97228..b8ea990 100644 --- a/src/micropolisj/engine/Bulldozer.java +++ b/src/micropolisj/engine/Bulldozer.java @@ -46,25 +46,27 @@ class Bulldozer extends ToolStroke // zone center bit is set assert isZoneCenter(currTile); + CityDimension dim = getZoneSizeFor(currTile); + assert dim != null; + assert dim.width >= 3; + assert dim.height >= 3; + eff.spend(1); - switch (getZoneSizeFor(currTile)) - { - case 3: + + // make explosion sound; + // bigger zones => bigger explosions + + if (dim.width * dim.height < 16) { eff.makeSound(0, 0, Sound.EXPLOSION_HIGH); - putRubble(new TranslatedToolEffect(eff, -1, -1), 3, 3); - break; - case 4: - eff.makeSound(0, 0, Sound.EXPLOSION_LOW); - putRubble(new TranslatedToolEffect(eff, -1, -1), 4, 4); - break; - case 6: - eff.makeSound(0, 0, Sound.EXPLOSION_BOTH); - putRubble(new TranslatedToolEffect(eff, -1, -1), 6, 6); - break; - default: - assert false; - break; } + else if (dim.width * dim.height < 36) { + eff.makeSound(0, 0, Sound.EXPLOSION_LOW); + } + else { + eff.makeSound(0, 0, Sound.EXPLOSION_BOTH); + } + + putRubble(new TranslatedToolEffect(eff, -1, -1), dim.width, dim.height); return; } diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 992bad6..cc1d292 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -2293,14 +2293,19 @@ public class Micropolis { rateOGMem[ypos/8][xpos/8] -= 20; - int sz = TileConstants.getZoneSizeFor(zoneTile); - int zoneBase = (zoneTile&LOMASK)-1-sz; + assert isZoneCenter(zoneTile); + CityDimension dim = getZoneSizeFor(zoneTile); + assert dim != null; + assert dim.width >= 3; + assert dim.height >= 3; + + int zoneBase = (zoneTile&LOMASK) - 1 - dim.width; // this will take care of stopping smoke animations - shutdownZone(xpos, ypos, sz); + shutdownZone(xpos, ypos, dim); - for (int y = 0; y < sz; y++) { - for (int x = 0; x < sz; x++, zoneBase++) { + for (int y = 0; y < dim.height; y++) { + for (int x = 0; x < dim.width; x++, zoneBase++) { int xtem = xpos - 1 + x; int ytem = ypos - 1 + y; if (!testBounds(xtem, ytem)) @@ -2321,10 +2326,13 @@ public class Micropolis * instead. * @see #shutdownZone */ - void powerZone(int xpos, int ypos, int zoneSize) + void powerZone(int xpos, int ypos, CityDimension zoneSize) { - for (int dx = 0; dx < zoneSize; dx++) { - for (int dy = 0; dy < zoneSize; dy++) { + assert zoneSize.width >= 3; + assert zoneSize.height >= 3; + + for (int dx = 0; dx < zoneSize.width; dx++) { + for (int dy = 0; dy < zoneSize.height; dy++) { int x = xpos - 1 + dx; int y = ypos - 1 + dy; int tile = getTile(x, y); @@ -2344,10 +2352,13 @@ public class Micropolis * @see #powerZone * @see #killZone */ - void shutdownZone(int xpos, int ypos, int zoneSize) + void shutdownZone(int xpos, int ypos, CityDimension zoneSize) { - for (int dx = 0; dx < zoneSize; dx++) { - for (int dy = 0; dy < zoneSize; dy++) { + assert zoneSize.width >= 3; + assert zoneSize.height >= 3; + + for (int dx = 0; dx < zoneSize.width; dx++) { + for (int dy = 0; dy < zoneSize.height; dy++) { int x = xpos - 1 + dx; int y = ypos - 1 + dy; int tile = getTile(x, y); diff --git a/src/micropolisj/engine/TileConstants.java b/src/micropolisj/engine/TileConstants.java index 891afd2..8664bd2 100644 --- a/src/micropolisj/engine/TileConstants.java +++ b/src/micropolisj/engine/TileConstants.java @@ -396,30 +396,13 @@ public class TileConstants x == BRWV); } - public static int getZoneSizeFor(int tile) + public static CityDimension getZoneSizeFor(int tile) { - int ch = tile & LOMASK; - if (ch >= RESBASE && ch < PORTBASE) { - return 3; - } - else if (ch >= PORTBASE && ch <= LASTPORT) { - return 4; - } - else if (ch >= AIRPORTBASE && ch < COALBASE) { - return 6; - } - else if (ch >= COALBASE && ch <= LASTPOWERPLANT) { - return 4; - } - else if (ch >= FIRESTBASE && ch < STADIUMBASE) { - return 3; - } - else if (ch >= STADIUMBASE && ch <= LASTZONE) { - return 4; - } - else { - return 0; + TileSpec spec = Tiles.get(tile & LOMASK); + if (spec.owner != null) { + spec = spec.owner; } + return spec.getBuildingSize(); } public static boolean isConstructed(int tile)