api: use masked tile number for tile-check methods
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@898 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
a8713b682e
commit
78d094c8ac
5 changed files with 40 additions and 43 deletions
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
|
|
Reference in a new issue