api: getTile() now returns masked tile number
use getTileRaw() to get the raw tile number git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@897 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
8ce6a1fdd5
commit
a8713b682e
8 changed files with 28 additions and 24 deletions
|
@ -52,7 +52,7 @@ public class ExplosionSprite extends Sprite
|
|||
if (!city.testBounds(xpos, ypos))
|
||||
return;
|
||||
|
||||
int z = city.getTile(xpos, ypos);
|
||||
int z = city.getTileRaw(xpos, ypos);
|
||||
int t = z & LOMASK;
|
||||
if (!isCombustible(z) && t != DIRT)
|
||||
return;
|
||||
|
|
|
@ -424,13 +424,18 @@ public class Micropolis
|
|||
}
|
||||
|
||||
public char getTile(int xpos, int ypos)
|
||||
{
|
||||
return (char)(map[ypos][xpos] & LOMASK);
|
||||
}
|
||||
|
||||
public char getTileRaw(int xpos, int ypos)
|
||||
{
|
||||
return map[ypos][xpos];
|
||||
}
|
||||
|
||||
boolean isTileDozeable(ToolEffectIfc eff)
|
||||
{
|
||||
int myTile = eff.getTile(0, 0) & LOMASK;
|
||||
int myTile = eff.getTile(0, 0);
|
||||
TileSpec ts = Tiles.get(myTile);
|
||||
if (ts.canBulldoze) {
|
||||
return true;
|
||||
|
@ -440,7 +445,7 @@ public class Micropolis
|
|||
// part of a zone; only bulldozeable if the owner tile is
|
||||
// no longer intact.
|
||||
|
||||
int baseTile = eff.getTile(-ts.ownerOffsetX, -ts.ownerOffsetY) & LOMASK;
|
||||
int baseTile = eff.getTile(-ts.ownerOffsetX, -ts.ownerOffsetY);
|
||||
return !(ts.owner.tileNumber == baseTile);
|
||||
}
|
||||
|
||||
|
@ -456,7 +461,7 @@ public class Micropolis
|
|||
|
||||
public boolean isTilePowered(int xpos, int ypos)
|
||||
{
|
||||
return (getTile(xpos, ypos) & PWRBIT) == PWRBIT;
|
||||
return (getTileRaw(xpos, ypos) & PWRBIT) == PWRBIT;
|
||||
}
|
||||
|
||||
public void setTile(int xpos, int ypos, char newTile)
|
||||
|
@ -1467,7 +1472,7 @@ public class Micropolis
|
|||
|
||||
void mapScanTile(int xpos, int ypos)
|
||||
{
|
||||
int rawTile = getTile(xpos, ypos);
|
||||
int rawTile = getTileRaw(xpos, ypos);
|
||||
String behaviorStr = getTileBehavior(rawTile & LOMASK);
|
||||
if (behaviorStr == null) {
|
||||
return; //nothing to do
|
||||
|
@ -2083,11 +2088,11 @@ public class Micropolis
|
|||
for (int y = 0; y < map.length; y++) {
|
||||
for (int x = 0; x < map[y].length; x++) {
|
||||
int tile = getTile(x,y);
|
||||
if ((tile & LOMASK) == NUCLEAR) {
|
||||
if (tile == NUCLEAR) {
|
||||
nuclearCount++;
|
||||
powerPlants.add(new CityLocation(x,y));
|
||||
}
|
||||
else if ((tile & LOMASK) == POWERPLANT) {
|
||||
else if (tile == POWERPLANT) {
|
||||
coalCount++;
|
||||
powerPlants.add(new CityLocation(x,y));
|
||||
}
|
||||
|
@ -2319,7 +2324,7 @@ public class Micropolis
|
|||
int x = PRNG.nextInt(getWidth() - 19) + 10;
|
||||
int y = PRNG.nextInt(getHeight() - 9) + 5;
|
||||
int t = getTile(x, y);
|
||||
if ((t & LOMASK) == RIVER) {
|
||||
if (t == RIVER) {
|
||||
makeMonsterAt(x, y);
|
||||
return;
|
||||
}
|
||||
|
@ -2421,7 +2426,7 @@ public class Micropolis
|
|||
for (int dy = 0; dy < zoneSize.height; dy++) {
|
||||
int x = xpos - 1 + dx;
|
||||
int y = ypos - 1 + dy;
|
||||
int tile = getTile(x, y);
|
||||
int tile = getTileRaw(x, y);
|
||||
TileSpec ts = Tiles.get(tile & LOMASK);
|
||||
if (ts != null && ts.onPower != null) {
|
||||
setTile(x, y,
|
||||
|
@ -2447,7 +2452,7 @@ public class Micropolis
|
|||
for (int dy = 0; dy < zoneSize.height; dy++) {
|
||||
int x = xpos - 1 + dx;
|
||||
int y = ypos - 1 + dy;
|
||||
int tile = getTile(x, y);
|
||||
int tile = getTileRaw(x, y);
|
||||
TileSpec ts = Tiles.get(tile & LOMASK);
|
||||
if (ts != null && ts.onShutdown != null) {
|
||||
setTile(x, y,
|
||||
|
|
|
@ -145,7 +145,7 @@ class RoadLikeTool extends ToolStroke
|
|||
|
||||
int cost = RAIL_COST;
|
||||
|
||||
char tile = (char) (eff.getTile(0, 0) & LOMASK);
|
||||
char tile = (char) eff.getTile(0, 0);
|
||||
tile = neutralizeRoad(tile);
|
||||
|
||||
switch (tile)
|
||||
|
@ -250,7 +250,7 @@ class RoadLikeTool extends ToolStroke
|
|||
|
||||
int cost = ROAD_COST;
|
||||
|
||||
char tile = (char) (eff.getTile(0, 0) & LOMASK);
|
||||
char tile = (char) eff.getTile(0, 0);
|
||||
switch (tile)
|
||||
{
|
||||
case RIVER: // road on water
|
||||
|
@ -354,7 +354,7 @@ class RoadLikeTool extends ToolStroke
|
|||
|
||||
int cost = WIRE_COST;
|
||||
|
||||
char tile = (char) (eff.getTile(0, 0) & LOMASK);
|
||||
char tile = (char) eff.getTile(0, 0);
|
||||
tile = neutralizeRoad(tile);
|
||||
|
||||
switch (tile)
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ShipSprite extends Sprite
|
|||
int ypos = this.y / 16 + BDy[z];
|
||||
|
||||
if (city.testBounds(xpos, ypos)) {
|
||||
t = city.getTile(xpos, ypos) & LOMASK;
|
||||
t = city.getTile(xpos, ypos);
|
||||
if ((t == CHANNEL) || (t == BRWH) || (t == BRWV) ||
|
||||
tryOther(t, this.dir, z))
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class Sprite
|
|||
int xpos = x / 16;
|
||||
int ypos = y / 16;
|
||||
if (city.testBounds(xpos, ypos)) {
|
||||
return (city.getTile(xpos, ypos) & LOMASK);
|
||||
return city.getTile(xpos, ypos);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public abstract class Sprite
|
|||
if (!city.testBounds(xpos, ypos))
|
||||
return;
|
||||
|
||||
int z = city.getTile(xpos, ypos);
|
||||
int z = city.getTileRaw(xpos, ypos);
|
||||
int t = z & LOMASK;
|
||||
|
||||
if (t >= TREEBASE) {
|
||||
|
|
|
@ -117,7 +117,7 @@ class TerrainBehavior extends TileBehavior
|
|||
int xx = xpos + DX[z];
|
||||
int yy = ypos + DY[z];
|
||||
if (city.testBounds(xx, yy)) {
|
||||
int c = city.getTile(xx, yy);
|
||||
int c = city.getTileRaw(xx, yy);
|
||||
int t = c & LOMASK;
|
||||
if (isCombustible(c) || c == DIRT ||
|
||||
(t >= WOODS5 && t < FLOOD))
|
||||
|
|
|
@ -30,7 +30,7 @@ public abstract class TileBehavior
|
|||
{
|
||||
this.xpos = xpos;
|
||||
this.ypos = ypos;
|
||||
this.rawTile = city.getTile(xpos, ypos);
|
||||
this.rawTile = city.getTileRaw(xpos, ypos);
|
||||
this.tile = rawTile & LOMASK;
|
||||
apply();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class TrafficGen
|
|||
assert city.testBounds(mapX, mapY);
|
||||
|
||||
// check for road/rail
|
||||
int tile = city.getTile(mapX, mapY) & LOMASK;
|
||||
int tile = city.getTile(mapX, mapY);
|
||||
if (tile >= ROADBASE && tile < POWERBASE)
|
||||
{
|
||||
city.addTraffic(mapX, mapY, 50);
|
||||
|
@ -95,7 +95,6 @@ class TrafficGen
|
|||
}
|
||||
|
||||
char c = city.getTile(tx, ty);
|
||||
c &= LOMASK;
|
||||
|
||||
if (c < ROADBASE)
|
||||
return false;
|
||||
|
@ -197,25 +196,25 @@ class TrafficGen
|
|||
|
||||
if (mapY > 0)
|
||||
{
|
||||
int tile = city.getTile(mapX, mapY-1) & LOMASK;
|
||||
int tile = city.getTile(mapX, mapY-1);
|
||||
if (tile >= low && tile <= high)
|
||||
return true;
|
||||
}
|
||||
if (mapX + 1 < city.getWidth())
|
||||
{
|
||||
int tile = city.getTile(mapX + 1, mapY) & LOMASK;
|
||||
int tile = city.getTile(mapX + 1, mapY);
|
||||
if (tile >= low && tile <= high)
|
||||
return true;
|
||||
}
|
||||
if (mapY + 1 < city.getHeight())
|
||||
{
|
||||
int tile = city.getTile(mapX, mapY + 1) & LOMASK;
|
||||
int tile = city.getTile(mapX, mapY + 1);
|
||||
if (tile >= low && tile <= high)
|
||||
return true;
|
||||
}
|
||||
if (mapX > 0)
|
||||
{
|
||||
int tile = city.getTile(mapX - 1, mapY) & LOMASK;
|
||||
int tile = city.getTile(mapX - 1, mapY);
|
||||
if (tile >= low && tile <= high)
|
||||
return true;
|
||||
}
|
||||
|
|
Reference in a new issue