behaviors: MapScanner: s/cchr/rawTile and s/cchr9/tile
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@869 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
f3ca16a672
commit
fb4f1fee98
2 changed files with 39 additions and 39 deletions
|
@ -24,8 +24,8 @@ class MapScanner
|
||||||
final Random PRNG;
|
final Random PRNG;
|
||||||
int xpos;
|
int xpos;
|
||||||
int ypos;
|
int ypos;
|
||||||
char cchr;
|
int rawTile;
|
||||||
char cchr9;
|
int tile;
|
||||||
|
|
||||||
MapScanner(Micropolis city)
|
MapScanner(Micropolis city)
|
||||||
{
|
{
|
||||||
|
@ -60,9 +60,9 @@ class MapScanner
|
||||||
*/
|
*/
|
||||||
public void scanTile()
|
public void scanTile()
|
||||||
{
|
{
|
||||||
cchr9 = (char) (cchr & LOMASK);
|
tile = rawTile & LOMASK;
|
||||||
|
|
||||||
String behaviorStr = getTileBehavior(cchr);
|
String behaviorStr = getTileBehavior(rawTile);
|
||||||
if (behaviorStr == null) {
|
if (behaviorStr == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -154,11 +154,11 @@ class MapScanner
|
||||||
// deteriorating roads
|
// deteriorating roads
|
||||||
if (PRNG.nextInt(512) == 0)
|
if (PRNG.nextInt(512) == 0)
|
||||||
{
|
{
|
||||||
if (!isConductive(cchr))
|
if (!isConductive(rawTile))
|
||||||
{
|
{
|
||||||
if (city.roadEffect < PRNG.nextInt(32))
|
if (city.roadEffect < PRNG.nextInt(32))
|
||||||
{
|
{
|
||||||
if (isOverWater(cchr))
|
if (isOverWater(rawTile))
|
||||||
city.setTile(xpos, ypos, RIVER);
|
city.setTile(xpos, ypos, RIVER);
|
||||||
else
|
else
|
||||||
city.setTile(xpos, ypos, (char)(RUBBLE + PRNG.nextInt(4) + BULLBIT));
|
city.setTile(xpos, ypos, (char)(RUBBLE + PRNG.nextInt(4) + BULLBIT));
|
||||||
|
@ -168,7 +168,7 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCombustible(cchr)) //bridge
|
if (!isCombustible(rawTile)) //bridge
|
||||||
{
|
{
|
||||||
city.roadTotal += 4;
|
city.roadTotal += 4;
|
||||||
if (doBridge())
|
if (doBridge())
|
||||||
|
@ -176,9 +176,9 @@ class MapScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
int tden;
|
int tden;
|
||||||
if ((cchr & LOMASK) < LTRFBASE)
|
if ((rawTile & LOMASK) < LTRFBASE)
|
||||||
tden = 0;
|
tden = 0;
|
||||||
else if ((cchr & LOMASK) < HTRFBASE)
|
else if ((rawTile & LOMASK) < HTRFBASE)
|
||||||
tden = 1;
|
tden = 1;
|
||||||
else {
|
else {
|
||||||
city.roadTotal++;
|
city.roadTotal++;
|
||||||
|
@ -193,8 +193,8 @@ class MapScanner
|
||||||
|
|
||||||
if (tden != newLevel)
|
if (tden != newLevel)
|
||||||
{
|
{
|
||||||
int z = (((cchr & LOMASK) - ROADBASE) & 15) + TRAFFIC_DENSITY_TAB[newLevel];
|
int z = (((rawTile & LOMASK) - ROADBASE) & 15) + TRAFFIC_DENSITY_TAB[newLevel];
|
||||||
z += cchr & ALLBITS;
|
z += rawTile & ALLBITS;
|
||||||
|
|
||||||
city.setTile(xpos, ypos, (char) z);
|
city.setTile(xpos, ypos, (char) z);
|
||||||
}
|
}
|
||||||
|
@ -294,9 +294,9 @@ class MapScanner
|
||||||
|
|
||||||
if (city.roadEffect < 30) { // deteriorating rail
|
if (city.roadEffect < 30) { // deteriorating rail
|
||||||
if (PRNG.nextInt(512) == 0) {
|
if (PRNG.nextInt(512) == 0) {
|
||||||
if (!isConductive(cchr)) {
|
if (!isConductive(rawTile)) {
|
||||||
if (city.roadEffect < PRNG.nextInt(32)) {
|
if (city.roadEffect < PRNG.nextInt(32)) {
|
||||||
if (isOverWater(cchr)) {
|
if (isOverWater(rawTile)) {
|
||||||
city.setTile(xpos,ypos,RIVER);
|
city.setTile(xpos,ypos,RIVER);
|
||||||
} else {
|
} else {
|
||||||
city.setTile(xpos,ypos,(char)(RUBBLE + PRNG.nextInt(4)+BULLBIT));
|
city.setTile(xpos,ypos,(char)(RUBBLE + PRNG.nextInt(4)+BULLBIT));
|
||||||
|
@ -346,7 +346,7 @@ class MapScanner
|
||||||
VBRIDGE | BULLBIT, VBRIDGE | BULLBIT,
|
VBRIDGE | BULLBIT, VBRIDGE | BULLBIT,
|
||||||
RIVER };
|
RIVER };
|
||||||
|
|
||||||
if (cchr9 == BRWV) {
|
if (tile == BRWV) {
|
||||||
// vertical bridge, open
|
// vertical bridge, open
|
||||||
if (PRNG.nextInt(4) == 0 && getBoatDis() > 340/16) {
|
if (PRNG.nextInt(4) == 0 && getBoatDis() > 340/16) {
|
||||||
//close the bridge
|
//close the bridge
|
||||||
|
@ -354,7 +354,7 @@ class MapScanner
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cchr9 == BRWH) {
|
else if (tile == BRWH) {
|
||||||
// horizontal bridge, open
|
// horizontal bridge, open
|
||||||
if (PRNG.nextInt(4) == 0 && getBoatDis() > 340/16) {
|
if (PRNG.nextInt(4) == 0 && getBoatDis() > 340/16) {
|
||||||
// close the bridge
|
// close the bridge
|
||||||
|
@ -364,7 +364,7 @@ class MapScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBoatDis() < 300/16 && PRNG.nextInt(8) == 0) {
|
if (getBoatDis() < 300/16 && PRNG.nextInt(8) == 0) {
|
||||||
if ((cchr & 1) != 0) {
|
if ((rawTile & 1) != 0) {
|
||||||
// vertical bridge
|
// vertical bridge
|
||||||
if (xpos < city.getWidth()-1) {
|
if (xpos < city.getWidth()-1) {
|
||||||
// look for CHANNEL tile to right of
|
// look for CHANNEL tile to right of
|
||||||
|
@ -460,27 +460,27 @@ class MapScanner
|
||||||
|
|
||||||
boolean setZonePower()
|
boolean setZonePower()
|
||||||
{
|
{
|
||||||
// refresh cchr, cchr9, since this can get called after the
|
// refresh rawTile, tile, since this can get called after the
|
||||||
// tile's been changed
|
// tile's been changed
|
||||||
cchr = city.map[ypos][xpos];
|
this.rawTile = city.map[ypos][xpos];
|
||||||
cchr9 = (char) (cchr & LOMASK);
|
this.tile = (char) (rawTile & LOMASK);
|
||||||
|
|
||||||
boolean oldPower = (cchr & PWRBIT) == PWRBIT;
|
boolean oldPower = (rawTile & PWRBIT) == PWRBIT;
|
||||||
boolean newPower = (
|
boolean newPower = (
|
||||||
cchr9 == NUCLEAR ||
|
tile == NUCLEAR ||
|
||||||
cchr9 == POWERPLANT ||
|
tile == POWERPLANT ||
|
||||||
city.hasPower(xpos,ypos)
|
city.hasPower(xpos,ypos)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (newPower && !oldPower)
|
if (newPower && !oldPower)
|
||||||
{
|
{
|
||||||
city.setTile(xpos, ypos, (char) (cchr | PWRBIT));
|
city.setTile(xpos, ypos, (char) (rawTile | PWRBIT));
|
||||||
city.powerZone(xpos, ypos, getZoneSizeFor(cchr));
|
city.powerZone(xpos, ypos, getZoneSizeFor(rawTile));
|
||||||
}
|
}
|
||||||
else if (!newPower && oldPower)
|
else if (!newPower && oldPower)
|
||||||
{
|
{
|
||||||
city.setTile(xpos, ypos, (char) (cchr & (~PWRBIT)));
|
city.setTile(xpos, ypos, (char) (rawTile & (~PWRBIT)));
|
||||||
city.shutdownZone(xpos, ypos, getZoneSizeFor(cchr));
|
city.shutdownZone(xpos, ypos, getZoneSizeFor(rawTile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return newPower;
|
return newPower;
|
||||||
|
@ -693,7 +693,7 @@ class MapScanner
|
||||||
void doHospitalChurch()
|
void doHospitalChurch()
|
||||||
{
|
{
|
||||||
boolean powerOn = checkZonePower();
|
boolean powerOn = checkZonePower();
|
||||||
if (cchr9 == HOSPITAL)
|
if (tile == HOSPITAL)
|
||||||
{
|
{
|
||||||
city.hospitalCount++;
|
city.hospitalCount++;
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ class MapScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cchr9 == CHURCH)
|
else if (tile == CHURCH)
|
||||||
{
|
{
|
||||||
city.churchCount++;
|
city.churchCount++;
|
||||||
|
|
||||||
|
@ -778,7 +778,7 @@ class MapScanner
|
||||||
boolean powerOn = checkZonePower();
|
boolean powerOn = checkZonePower();
|
||||||
city.comZoneCount++;
|
city.comZoneCount++;
|
||||||
|
|
||||||
int tpop = commercialZonePop(cchr);
|
int tpop = commercialZonePop(rawTile);
|
||||||
city.comPop += tpop;
|
city.comPop += tpop;
|
||||||
|
|
||||||
int trafficGood;
|
int trafficGood;
|
||||||
|
@ -832,7 +832,7 @@ class MapScanner
|
||||||
boolean powerOn = checkZonePower();
|
boolean powerOn = checkZonePower();
|
||||||
city.indZoneCount++;
|
city.indZoneCount++;
|
||||||
|
|
||||||
int tpop = industrialZonePop(cchr);
|
int tpop = industrialZonePop(rawTile);
|
||||||
city.indPop += tpop;
|
city.indPop += tpop;
|
||||||
|
|
||||||
int trafficGood;
|
int trafficGood;
|
||||||
|
@ -885,13 +885,13 @@ class MapScanner
|
||||||
city.resZoneCount++;
|
city.resZoneCount++;
|
||||||
|
|
||||||
int tpop; //population of this zone
|
int tpop; //population of this zone
|
||||||
if (cchr9 == RESCLR)
|
if (tile == RESCLR)
|
||||||
{
|
{
|
||||||
tpop = city.doFreePop(xpos, ypos);
|
tpop = city.doFreePop(xpos, ypos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tpop = residentialZonePop(cchr);
|
tpop = residentialZonePop(rawTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
city.resPop += tpop;
|
city.resPop += tpop;
|
||||||
|
@ -913,7 +913,7 @@ class MapScanner
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cchr9 == RESCLR || PRNG.nextInt(8) == 0)
|
if (tile == RESCLR || PRNG.nextInt(8) == 0)
|
||||||
{
|
{
|
||||||
int locValve = evalResidential(trafficGood);
|
int locValve = evalResidential(trafficGood);
|
||||||
int zscore = city.resValve + locValve;
|
int zscore = city.resValve + locValve;
|
||||||
|
@ -951,8 +951,8 @@ class MapScanner
|
||||||
int evalLot(int x, int y)
|
int evalLot(int x, int y)
|
||||||
{
|
{
|
||||||
// test for clear lot
|
// test for clear lot
|
||||||
int tile = city.getTile(x,y);
|
int aTile = city.getTile(x,y);
|
||||||
if (tile != DIRT && !isResidentialClear(tile)) {
|
if (aTile != DIRT && !isResidentialClear(aTile)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,8 +1058,8 @@ class MapScanner
|
||||||
if (z > 128)
|
if (z > 128)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int cchr9 = cchr & LOMASK;
|
this.tile = rawTile & LOMASK;
|
||||||
if (cchr9 == RESCLR)
|
if (tile == RESCLR)
|
||||||
{
|
{
|
||||||
if (pop < 8)
|
if (pop < 8)
|
||||||
{
|
{
|
||||||
|
@ -1151,7 +1151,7 @@ class MapScanner
|
||||||
{
|
{
|
||||||
// downgrade from full-size zone to 8 little houses
|
// downgrade from full-size zone to 8 little houses
|
||||||
|
|
||||||
int pwrBit = (cchr & PWRBIT);
|
int pwrBit = (rawTile & PWRBIT);
|
||||||
city.setTile(xpos, ypos, (char)(RESCLR | BULLBIT | pwrBit));
|
city.setTile(xpos, ypos, (char)(RESCLR | BULLBIT | pwrBit));
|
||||||
for (int x = xpos-1; x <= xpos+1; x++)
|
for (int x = xpos-1; x <= xpos+1; x++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1399,7 +1399,7 @@ public class Micropolis
|
||||||
for (int y = 0; y < getHeight(); y++)
|
for (int y = 0; y < getHeight(); y++)
|
||||||
{
|
{
|
||||||
scanner.ypos = y;
|
scanner.ypos = y;
|
||||||
scanner.cchr = map[y][x];
|
scanner.rawTile = map[y][x];
|
||||||
scanner.scanTile();
|
scanner.scanTile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue