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