evalLot: replace hardcode tile number comparisons with isRoad/isRail
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@792 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
ecba1ff5f9
commit
471b77a562
2 changed files with 15 additions and 10 deletions
|
@ -936,10 +936,8 @@ class MapScanner
|
|||
int evalLot(int x, int y)
|
||||
{
|
||||
// test for clear lot
|
||||
int tmp = city.getTile(x,y) & LOMASK;
|
||||
|
||||
if (tmp != DIRT && (tmp < RESBASE || tmp > RESBASE+8))
|
||||
{
|
||||
int tile = city.getTile(x,y);
|
||||
if (tile != DIRT && !isResidentialClear(tile)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -952,11 +950,13 @@ class MapScanner
|
|||
int xx = x + DX[z];
|
||||
int yy = y + DY[z];
|
||||
|
||||
if (city.testBounds(xx, yy) &&
|
||||
city.map[yy][xx] != DIRT &&
|
||||
((city.map[yy][xx] & LOMASK) <= LASTROAD)) //look for road
|
||||
{
|
||||
score++;
|
||||
// look for road
|
||||
if (city.testBounds(xx, yy)) {
|
||||
int tmp = city.getTile(xx, yy);
|
||||
if (isRoad(tmp) || isRail(tmp))
|
||||
{
|
||||
score++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class TileConstants
|
|||
public static final char LTRFBASE = 80;
|
||||
public static final char BRWV = 95; //vert bridge, open
|
||||
public static final char HTRFBASE = 144;
|
||||
public static final char LASTROAD = 206;
|
||||
private static final char LASTROAD = 206;
|
||||
public static final char POWERBASE = 208;
|
||||
public static final char HPOWER = 208; //underwater power-line
|
||||
public static final char VPOWER = 209;
|
||||
|
@ -664,6 +664,11 @@ public class TileConstants
|
|||
|| (tmp >= SMOKEBASE2 && tmp < FOOTBALLGAME1);
|
||||
}
|
||||
|
||||
public static boolean isResidentialClear(int tile)
|
||||
{
|
||||
return (tile & LOMASK) >= RESBASE && (tile & LOMASK) <= RESBASE+8;
|
||||
}
|
||||
|
||||
/** Note: does not include hospital/church.
|
||||
* @see #isHospitalOrChurch
|
||||
*/
|
||||
|
|
Reference in a new issue