Sprite: cleanup logic for how to destroy a tile

and remove the dependency on tile numbers
This commit is contained in:
Jason Long 2014-09-21 14:20:19 -04:00
parent f944e5293c
commit ac1dc2bf92
2 changed files with 18 additions and 24 deletions

View file

@ -179,28 +179,28 @@ public abstract class Sprite
return;
int t = city.getTile(xpos, ypos);
if (isOverWater(t)) {
// becomes water
city.setTile(xpos, ypos, RIVER);
return;
}
if (t >= TREEBASE) {
if (isBridge(t)) {
city.setTile(xpos, ypos, RIVER);
if (!isCombustible(t)) {
// cannot destroy it
return;
}
if (isZoneCenter(t)) {
city.killZone(xpos, ypos, t);
CityDimension d = getZoneSizeFor(t);
if (d.width >= 3 && d.height >= 3) {
city.makeExplosion(xpos, ypos);
return;
}
if (!isCombustible(t)) {
return; //cannot destroy it
}
if (isZoneCenter(t)) {
city.killZone(xpos, ypos, t);
if (t > RZB) {
city.makeExplosion(xpos, ypos);
}
}
if (isOverWater(t)) {
city.setTile(xpos, ypos, RIVER);
}
else {
city.setTile(xpos, ypos, TINYEXP);
}
}
city.setTile(xpos, ypos, TINYEXP);
}
/**

View file

@ -275,12 +275,6 @@ public class TileConstants
);
}
//used by Sprite::destroyTile
public static boolean isBridge(int tile)
{
return isRoad(tile) && !isCombustible(tile);
}
public static boolean isCombustible(int tile)
{
assert (tile & LOMASK) == tile;