tiles: helper functions- isFire, isRadioactive, isFlood

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@679 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-05-28 01:52:27 +00:00
parent d708cdb0f2
commit 6794888026
2 changed files with 39 additions and 24 deletions

View file

@ -39,13 +39,7 @@ class MapScanner
*/ */
public void scanTile() public void scanTile()
{ {
cchr9 = (char) (cchr & LOMASK); if (isFire(cchr))
if (cchr9 >= FLOOD)
{
if (cchr9 < ROADBASE)
{
if (cchr9 >= FIREBASE)
{ {
city.firePop++; city.firePop++;
if (PRNG.nextInt(4) == 0) if (PRNG.nextInt(4) == 0)
@ -55,18 +49,21 @@ class MapScanner
} }
return; return;
} }
else if (isFlood(cchr))
if (cchr9 < RADTILE)
{ {
doFlood(); doFlood();
return;
} }
else else if (isRadioactive(cchr))
{ {
doRadioactiveTile(); doRadioactiveTile();
}
return; return;
} }
cchr9 = (char) (cchr & LOMASK);
if (cchr9 >= FLOOD)
{
if (city.newPower && ((cchr & CONDBIT) != 0)) if (city.newPower && ((cchr & CONDBIT) != 0))
{ {
setZonePower(); setZonePower();

View file

@ -297,6 +297,18 @@ public class TileConstants
&& ((tile & BURNBIT) == 0)); && ((tile & BURNBIT) == 0));
} }
public static boolean isFire(int tile)
{
int tmp = tile & LOMASK;
return (tmp >= FIREBASE && tmp < ROADBASE);
}
public static boolean isRadioactive(int tile)
{
int tmp = tile & LOMASK;
return (tmp >= RADTILE && tmp < FIREBASE);
}
public static boolean isOverWater(char cell) public static boolean isOverWater(char cell)
{ {
switch (cell & LOMASK) switch (cell & LOMASK)
@ -384,6 +396,12 @@ public class TileConstants
return tile >= 0 && (tile & BULLBIT) != 0; return tile >= 0 && (tile & BULLBIT) != 0;
} }
public static boolean isFlood(int tile)
{
int tmp = tile & LOMASK;
return (tmp >= FLOOD && tmp < RADTILE);
}
static boolean isFloodable(int tile) static boolean isFloodable(int tile)
{ {
return (tile == DIRT || ((tile & BULLBIT) != 0 && (tile & BURNBIT) != 0)); return (tile == DIRT || ((tile & BULLBIT) != 0 && (tile & BURNBIT) != 0));