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:
parent
d708cdb0f2
commit
6794888026
2 changed files with 39 additions and 24 deletions
|
@ -39,34 +39,31 @@ class MapScanner
|
||||||
*/
|
*/
|
||||||
public void scanTile()
|
public void scanTile()
|
||||||
{
|
{
|
||||||
|
if (isFire(cchr))
|
||||||
|
{
|
||||||
|
city.firePop++;
|
||||||
|
if (PRNG.nextInt(4) == 0)
|
||||||
|
{
|
||||||
|
// one in four times
|
||||||
|
doFire();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (isFlood(cchr))
|
||||||
|
{
|
||||||
|
doFlood();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (isRadioactive(cchr))
|
||||||
|
{
|
||||||
|
doRadioactiveTile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cchr9 = (char) (cchr & LOMASK);
|
cchr9 = (char) (cchr & LOMASK);
|
||||||
|
|
||||||
if (cchr9 >= FLOOD)
|
if (cchr9 >= FLOOD)
|
||||||
{
|
{
|
||||||
if (cchr9 < ROADBASE)
|
|
||||||
{
|
|
||||||
if (cchr9 >= FIREBASE)
|
|
||||||
{
|
|
||||||
city.firePop++;
|
|
||||||
if (PRNG.nextInt(4) == 0)
|
|
||||||
{
|
|
||||||
// one in four times
|
|
||||||
doFire();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cchr9 < RADTILE)
|
|
||||||
{
|
|
||||||
doFlood();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
doRadioactiveTile();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (city.newPower && ((cchr & CONDBIT) != 0))
|
if (city.newPower && ((cchr & CONDBIT) != 0))
|
||||||
{
|
{
|
||||||
setZonePower();
|
setZonePower();
|
||||||
|
|
|
@ -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));
|
||||||
|
|
Reference in a new issue