diff --git a/src/micropolisj/engine/ExplosionSprite.java b/src/micropolisj/engine/ExplosionSprite.java index 93e659d..82e7dc2 100644 --- a/src/micropolisj/engine/ExplosionSprite.java +++ b/src/micropolisj/engine/ExplosionSprite.java @@ -52,11 +52,10 @@ public class ExplosionSprite extends Sprite if (!city.testBounds(xpos, ypos)) return; - int z = city.getTileRaw(xpos, ypos); - int t = z & LOMASK; - if (!isCombustible(z) && t != DIRT) + int t = city.getTile(xpos, ypos); + if (!isCombustible(t) && t != DIRT) return; - if (isZoneCenter(z)) + if (isZoneCenter(t)) return; city.setTile(xpos, ypos, (char)(FIRE + city.PRNG.nextInt(4))); } diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index ef46be3..2d7c3a2 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -119,12 +119,12 @@ class MapScanner extends TileBehavior if (newPower && !oldPower) { city.setTile(xpos, ypos, (char) (rawTile | PWRBIT)); - city.powerZone(xpos, ypos, getZoneSizeFor(rawTile)); + city.powerZone(xpos, ypos, getZoneSizeFor(tile)); } else if (!newPower && oldPower) { city.setTile(xpos, ypos, (char) (rawTile & (~PWRBIT))); - city.shutdownZone(xpos, ypos, getZoneSizeFor(rawTile)); + city.shutdownZone(xpos, ypos, getZoneSizeFor(tile)); } return newPower; @@ -399,7 +399,7 @@ class MapScanner extends TileBehavior if (city.testBounds(xx, yy)) { - int thCh = city.map[yy][xx]; + int thCh = city.getTile(xx, yy); if (isZoneCenter(thCh)) { continue; } @@ -426,7 +426,7 @@ class MapScanner extends TileBehavior boolean powerOn = checkZonePower(); city.comZoneCount++; - int tpop = commercialZonePop(rawTile); + int tpop = commercialZonePop(tile); city.comPop += tpop; int trafficGood; @@ -480,7 +480,7 @@ class MapScanner extends TileBehavior boolean powerOn = checkZonePower(); city.indZoneCount++; - int tpop = industrialZonePop(rawTile); + int tpop = industrialZonePop(tile); city.indPop += tpop; int trafficGood; @@ -539,7 +539,7 @@ class MapScanner extends TileBehavior } else { - tpop = residentialZonePop(rawTile); + tpop = residentialZonePop(tile); } city.resPop += tpop; diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 8909359..c9f9c51 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -708,11 +708,10 @@ public class Micropolis { for (int y = 0; y < height; y++) { - char tile = map[y][x]; + char tile = getTile(x, y); if (isZoneCenter(tile)) { - tile &= LOMASK; - int den = computePopDen(x, y, (char)tile) * 8; + int den = computePopDen(x, y, tile) * 8; if (den > 254) den = 254; tem[y/2][x/2] = den; @@ -951,10 +950,11 @@ public class Micropolis boolean rv = false; if (movePowerLocation(loc,dir)) { + char t = getTile(loc.x, loc.y); rv = ( - isConductive(map[loc.y][loc.x]) && - map[loc.y][loc.x] != NUCLEAR && - map[loc.y][loc.x] != POWERPLANT && + isConductive(t) && + t != NUCLEAR && + t != POWERPLANT && !hasPower(loc.x, loc.y) ); } @@ -2043,19 +2043,19 @@ public class Micropolis for (int y = 0; y < DEFAULT_HEIGHT; y++) { int z = map[y][x]; - if (isConductive(z)) { + if (isConductive(z & LOMASK)) { z |= 16384; //synthesize CONDBIT on export } - if (isCombustible(z)) { + if (isCombustible(z & LOMASK)) { z |= 8192; //synthesize BURNBIT on export } if (isTileDozeable(x, y)) { z |= 4096; //synthesize BULLBIT on export } - if (isAnimated(z)) { + if (isAnimated(z & LOMASK)) { z |= 2048; //synthesize ANIMBIT on export } - if (isZoneCenter(z)) { + if (isZoneCenter(z & LOMASK)) { z |= 1024; //synthesize ZONEBIT } out.writeShort(z); @@ -2266,10 +2266,9 @@ public class Micropolis { int x = PRNG.nextInt(getWidth()); int y = PRNG.nextInt(getHeight()); - int tile = map[y][x]; + int tile = getTile(x, y); if (!isZoneCenter(tile) && isCombustible(tile)) { - tile &= LOMASK; if (tile > 21 && tile < LASTZONE) { setTile(x, y, (char)(FIRE + PRNG.nextInt(8))); sendMessageAt(MicropolisMessage.FIRE_REPORT, x, y); diff --git a/src/micropolisj/engine/Sprite.java b/src/micropolisj/engine/Sprite.java index 4f3d304..c51c128 100644 --- a/src/micropolisj/engine/Sprite.java +++ b/src/micropolisj/engine/Sprite.java @@ -171,19 +171,18 @@ public abstract class Sprite if (!city.testBounds(xpos, ypos)) return; - int z = city.getTileRaw(xpos, ypos); - int t = z & LOMASK; + int t = city.getTile(xpos, ypos); if (t >= TREEBASE) { - if (isBridge(z)) { + if (isBridge(t)) { city.setTile(xpos, ypos, RIVER); return; } - if (!isCombustible(z)) { + if (!isCombustible(t)) { return; //cannot destroy it } - if (isZoneCenter(z)) { - city.killZone(xpos, ypos, z); + if (isZoneCenter(t)) { + city.killZone(xpos, ypos, t); if (t > RZB) { city.makeExplosion(xpos, ypos); } diff --git a/src/micropolisj/engine/TerrainBehavior.java b/src/micropolisj/engine/TerrainBehavior.java index 56e435d..9e620be 100644 --- a/src/micropolisj/engine/TerrainBehavior.java +++ b/src/micropolisj/engine/TerrainBehavior.java @@ -78,11 +78,11 @@ class TerrainBehavior extends TileBehavior if (!city.testBounds(xtem, ytem)) continue; - int c = city.map[ytem][xtem]; + int c = city.getTile(xtem, ytem); if (isCombustible(c)) { if (isZoneCenter(c)) { city.killZone(xtem, ytem, c); - if ((c & LOMASK) > IZB) { //explode + if (c > IZB) { //explode city.makeExplosion(xtem, ytem); } } @@ -117,13 +117,13 @@ class TerrainBehavior extends TileBehavior int xx = xpos + DX[z]; int yy = ypos + DY[z]; if (city.testBounds(xx, yy)) { - int c = city.getTileRaw(xx, yy); - int t = c & LOMASK; - if (isCombustible(c) || c == DIRT || - (t >= WOODS5 && t < FLOOD)) + int t = city.getTile(xx, yy); + if (isCombustible(t) + || t == DIRT + || (t >= WOODS5 && t < FLOOD)) { - if (isZoneCenter(c)) { - city.killZone(xx, yy, c); + if (isZoneCenter(t)) { + city.killZone(xx, yy, t); } city.setTile(xx, yy, (char)(FLOOD + PRNG.nextInt(3))); } @@ -164,11 +164,11 @@ class TerrainBehavior extends TileBehavior // deteriorating roads if (PRNG.nextInt(512) == 0) { - if (!isConductive(rawTile)) + if (!isConductive(tile)) { if (city.roadEffect < PRNG.nextInt(32)) { - if (isOverWater(rawTile)) + if (isOverWater(tile)) city.setTile(xpos, ypos, RIVER); else city.setTile(xpos, ypos, (char)(RUBBLE + PRNG.nextInt(4))); @@ -178,7 +178,7 @@ class TerrainBehavior extends TileBehavior } } - if (!isCombustible(rawTile)) //bridge + if (!isCombustible(tile)) //bridge { city.roadTotal += 4; if (doBridge()) @@ -186,9 +186,9 @@ class TerrainBehavior extends TileBehavior } int tden; - if ((rawTile & LOMASK) < LTRFBASE) + if (tile < LTRFBASE) tden = 0; - else if ((rawTile & LOMASK) < HTRFBASE) + else if (tile < HTRFBASE) tden = 1; else { city.roadTotal++; @@ -220,9 +220,9 @@ class TerrainBehavior extends TileBehavior if (city.roadEffect < 30) { // deteriorating rail if (PRNG.nextInt(512) == 0) { - if (!isConductive(rawTile)) { + if (!isConductive(tile)) { if (city.roadEffect < PRNG.nextInt(32)) { - if (isOverWater(rawTile)) { + if (isOverWater(tile)) { city.setTile(xpos,ypos,RIVER); } else { city.setTile(xpos,ypos,(char)(RUBBLE + PRNG.nextInt(4)));