From 8ce6a1fdd5f882e0ab8684d74febb3b2904c9580 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Fri, 6 Dec 2013 16:01:58 +0000 Subject: [PATCH] tiles.rc: re-allow bulldozing dead zones That is, we allow tiles that belong to zones whose center tile has been destroyed (e.g. from a fire) to be individually bulldozed. This used to be allowed by setting the BULLBIT on those tiles when the center tile is destroyed (see killZone() method) but now that we no longer use BULLBIT, we need to test whether the center tile still exists when deciding if a tile can be bulldozed. git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@896 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/Bulldozer.java | 9 +++------ src/micropolisj/engine/Micropolis.java | 28 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/micropolisj/engine/Bulldozer.java b/src/micropolisj/engine/Bulldozer.java index 8194033..7700031 100644 --- a/src/micropolisj/engine/Bulldozer.java +++ b/src/micropolisj/engine/Bulldozer.java @@ -26,10 +26,10 @@ class Bulldozer extends ToolStroke for (int y = 0; y < b.height; y++) { for (int x = 0; x < b.width; x++) { - int tile = eff.getTile(b.x+x, b.y+y); - if (isDozeable(tile) && !isZoneCenter(tile)) { + ToolEffectIfc subEff = new TranslatedToolEffect(eff, b.x+x, b.y+y); + if (city.isTileDozeable(subEff)) { - dozeField(new TranslatedToolEffect(eff, b.x+x, b.y+y)); + dozeField(subEff); } } @@ -81,9 +81,6 @@ class Bulldozer extends ToolStroke { int tile = eff.getTile(0, 0); - // check dozeable bit - assert isDozeable(tile); - if (isOverWater(tile)) { // dozing over water, replace with water. diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 3a3530a..9c13fd5 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -428,6 +428,32 @@ public class Micropolis return map[ypos][xpos]; } + boolean isTileDozeable(ToolEffectIfc eff) + { + int myTile = eff.getTile(0, 0) & LOMASK; + TileSpec ts = Tiles.get(myTile); + if (ts.canBulldoze) { + return true; + } + + if (ts.owner != null) { + // part of a zone; only bulldozeable if the owner tile is + // no longer intact. + + int baseTile = eff.getTile(-ts.ownerOffsetX, -ts.ownerOffsetY) & LOMASK; + return !(ts.owner.tileNumber == baseTile); + } + + return false; + } + + boolean isTileDozeable(int xpos, int ypos) + { + return isTileDozeable( + new ToolEffect(this, xpos, ypos) + ); + } + public boolean isTilePowered(int xpos, int ypos) { return (getTile(xpos, ypos) & PWRBIT) == PWRBIT; @@ -2018,7 +2044,7 @@ public class Micropolis if (isCombustible(z)) { z |= 8192; //synthesize BURNBIT on export } - if (isDozeable(z)) { + if (isTileDozeable(x, y)) { z |= 4096; //synthesize BULLBIT on export } if (isAnimated(z)) {