toolstroke: cleanup: rename 'engine' variable to 'city' variable

for consistency

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@621 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-05-16 23:36:11 +00:00
parent 8901474800
commit 6438791974

View file

@ -80,14 +80,14 @@ public class ToolStroke
}
}
ToolResult apply3x3buildingTool(Micropolis engine, int xpos, int ypos, char tileBase)
ToolResult apply3x3buildingTool(Micropolis city, int xpos, int ypos, char tileBase)
{
int mapH = xpos - 1;
int mapV = ypos - 1;
if (!(mapH >= 0 && mapH + 2 < engine.getWidth()))
if (!(mapH >= 0 && mapH + 2 < city.getWidth()))
return ToolResult.UH_OH;
if (!(mapV >= 0 && mapV + 2 < engine.getHeight()))
if (!(mapV >= 0 && mapV + 2 < city.getHeight()))
return ToolResult.UH_OH;
int cost = 0;
@ -98,11 +98,11 @@ public class ToolStroke
{
int x = mapH + columnNum;
int y = mapV + rowNum;
char tileValue = (char) (engine.getTile(x,y) & LOMASK);
char tileValue = (char) (city.getTile(x,y) & LOMASK);
if (tileValue != DIRT)
{
if (engine.autoBulldoze)
if (city.autoBulldoze)
{
if (canAutoBulldozeZ(tileValue))
cost++;
@ -120,17 +120,17 @@ public class ToolStroke
cost += tool.getToolCost();
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
// take care of the money situation here
engine.spend(cost);
city.spend(cost);
for (int rowNum = 0; rowNum <= 2; rowNum++)
{
for (int columnNum = 0; columnNum <= 2; columnNum++)
{
engine.setTile(mapH + columnNum, mapV + rowNum, (char) (
city.setTile(mapH + columnNum, mapV + rowNum, (char) (
tileBase + BNCNBIT +
(columnNum == 1 && rowNum == 1 ? ZONEBIT : 0)
));
@ -138,18 +138,18 @@ public class ToolStroke
}
}
fixBorder(engine, mapH, mapV, mapH + 2, mapV + 2);
fixBorder(city, mapH, mapV, mapH + 2, mapV + 2);
return ToolResult.SUCCESS;
}
ToolResult apply4x4buildingTool(Micropolis engine, int xpos, int ypos, char tileBase)
ToolResult apply4x4buildingTool(Micropolis city, int xpos, int ypos, char tileBase)
{
int mapH = xpos - 1;
int mapV = ypos - 1;
if (!(mapH >= 0 && mapH + 3 < engine.getWidth()))
if (!(mapH >= 0 && mapH + 3 < city.getWidth()))
return ToolResult.UH_OH;
if (!(mapV >= 0 && mapV + 3 < engine.getHeight()))
if (!(mapV >= 0 && mapV + 3 < city.getHeight()))
return ToolResult.UH_OH;
int cost = 0;
@ -160,11 +160,11 @@ public class ToolStroke
{
int x = mapH + columnNum;
int y = mapV + rowNum;
char tileValue = (char) (engine.getTile(x,y) & LOMASK);
char tileValue = (char) (city.getTile(x,y) & LOMASK);
if (tileValue != DIRT)
{
if (engine.autoBulldoze)
if (city.autoBulldoze)
{
if (canAutoBulldozeZ(tileValue))
cost++;
@ -182,17 +182,17 @@ public class ToolStroke
cost += tool.getToolCost();
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
// take care of the money situation here
engine.spend(cost);
city.spend(cost);
for (int rowNum = 0; rowNum <= 3; rowNum++)
{
for (int columnNum = 0; columnNum <= 3; columnNum++)
{
engine.setTile(mapH + columnNum, mapV + rowNum, (char) (
city.setTile(mapH + columnNum, mapV + rowNum, (char) (
tileBase + BNCNBIT +
(columnNum == 1 && rowNum == 1 ? ZONEBIT : 0) +
(columnNum == 1 && rowNum == 2 ? ANIMBIT : 0)
@ -201,18 +201,18 @@ public class ToolStroke
}
}
fixBorder(engine, mapH, mapV, mapH + 3, mapV + 3);
fixBorder(city, mapH, mapV, mapH + 3, mapV + 3);
return ToolResult.SUCCESS;
}
ToolResult apply6x6buildingTool(Micropolis engine, int xpos, int ypos, char tileBase)
ToolResult apply6x6buildingTool(Micropolis city, int xpos, int ypos, char tileBase)
{
int mapH = xpos - 1;
int mapV = ypos - 1;
if (!(mapH >= 0 && mapH + 5 < engine.getWidth()))
if (!(mapH >= 0 && mapH + 5 < city.getWidth()))
return ToolResult.UH_OH;
if (!(mapV >= 0 && mapV + 5 < engine.getHeight()))
if (!(mapV >= 0 && mapV + 5 < city.getHeight()))
return ToolResult.UH_OH;
int cost = 0;
@ -223,11 +223,11 @@ public class ToolStroke
{
int x = mapH + columnNum;
int y = mapV + rowNum;
char tileValue = (char) (engine.getTile(x,y) & LOMASK);
char tileValue = (char) (city.getTile(x,y) & LOMASK);
if (tileValue != DIRT)
{
if (engine.autoBulldoze)
if (city.autoBulldoze)
{
if (canAutoBulldozeZ(tileValue))
cost++;
@ -245,17 +245,17 @@ public class ToolStroke
cost += tool.getToolCost();
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
// take care of the money situation here
engine.spend(cost);
city.spend(cost);
for (int rowNum = 0; rowNum <= 5; rowNum++)
{
for (int columnNum = 0; columnNum <= 5; columnNum++)
{
engine.setTile(mapH + columnNum, mapV + rowNum, (char) (
city.setTile(mapH + columnNum, mapV + rowNum, (char) (
tileBase + BNCNBIT +
(columnNum == 1 && rowNum == 1 ? ZONEBIT : 0)
));
@ -263,51 +263,51 @@ public class ToolStroke
}
}
fixBorder(engine, mapH, mapV, mapH + 5, mapV + 5);
fixBorder(city, mapH, mapV, mapH + 5, mapV + 5);
return ToolResult.SUCCESS;
}
void fixBorder(Micropolis engine, int left, int top, int right, int bottom)
void fixBorder(Micropolis city, int left, int top, int right, int bottom)
{
for (int x = left; x <= right; x++)
{
fixZone(engine, x, top);
fixZone(engine, x, bottom);
fixZone(city, x, top);
fixZone(city, x, bottom);
}
for (int y = top + 1; y <= bottom - 1; y++)
{
fixZone(engine, left, y);
fixZone(engine, right, y);
fixZone(city, left, y);
fixZone(city, right, y);
}
}
ToolResult applyBulldozer(Micropolis engine, int xpos, int ypos)
ToolResult applyBulldozer(Micropolis city, int xpos, int ypos)
{
if (!engine.testBounds(xpos, ypos))
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
char currTile = engine.getTile(xpos, ypos);
char currTile = city.getTile(xpos, ypos);
char tmp = (char)(currTile & LOMASK);
if ((currTile & ZONEBIT) != 0)
{
// zone center bit is set
if (engine.budget.totalFunds >= 1)
if (city.budget.totalFunds >= 1)
{
engine.spend(1);
city.spend(1);
switch (checkSize(tmp))
{
case 3:
engine.makeSound(xpos, ypos, Sound.EXPLOSION_HIGH);
putRubble(engine, xpos, ypos, 3, 3);
city.makeSound(xpos, ypos, Sound.EXPLOSION_HIGH);
putRubble(city, xpos, ypos, 3, 3);
break;
case 4:
engine.makeSound(xpos, ypos, Sound.EXPLOSION_LOW);
putRubble(engine, xpos, ypos, 4, 4);
city.makeSound(xpos, ypos, Sound.EXPLOSION_LOW);
putRubble(city, xpos, ypos, 4, 4);
break;
case 6:
engine.makeSound(xpos, ypos, Sound.EXPLOSION_BOTH);
putRubble(engine, xpos, ypos, 6, 6);
city.makeSound(xpos, ypos, Sound.EXPLOSION_BOTH);
putRubble(city, xpos, ypos, 6, 6);
break;
default:
assert false;
@ -333,14 +333,14 @@ public class ToolStroke
tmp == REDGE ||
tmp == CHANNEL)
{
if (engine.budget.totalFunds >= 6)
if (city.budget.totalFunds >= 6)
{
ToolResult result = layDoze(engine, xpos, ypos);
if (tmp != (engine.getTile(xpos, ypos) & LOMASK))
ToolResult result = layDoze(city, xpos, ypos);
if (tmp != (city.getTile(xpos, ypos) & LOMASK))
{
// tile changed
engine.spend(5);
fixZone(engine, xpos, ypos);
city.spend(5);
fixZone(city, xpos, ypos);
}
return result;
}
@ -350,46 +350,46 @@ public class ToolStroke
}
else
{
ToolResult result = layDoze(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
ToolResult result = layDoze(city, xpos, ypos);
fixZone(city, xpos, ypos);
return result;
}
}
ToolResult applyRailTool(Micropolis engine, int xpos, int ypos)
ToolResult applyRailTool(Micropolis city, int xpos, int ypos)
{
if (!engine.testBounds(xpos, ypos))
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
ToolResult result = layRail(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
ToolResult result = layRail(city, xpos, ypos);
fixZone(city, xpos, ypos);
return result;
}
ToolResult applyRoadTool(Micropolis engine, int xpos, int ypos)
ToolResult applyRoadTool(Micropolis city, int xpos, int ypos)
{
if (!engine.testBounds(xpos, ypos))
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
ToolResult result = layRoad(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
ToolResult result = layRoad(city, xpos, ypos);
fixZone(city, xpos, ypos);
return result;
}
ToolResult applyParkTool(Micropolis engine, int xpos, int ypos)
ToolResult applyParkTool(Micropolis city, int xpos, int ypos)
{
if (!engine.testBounds(xpos, ypos))
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
int cost = tool.getToolCost();
if (engine.getTile(xpos, ypos) != DIRT) {
if (city.getTile(xpos, ypos) != DIRT) {
// some sort of bulldozing is necessary
if (!engine.autoBulldoze) {
if (!city.autoBulldoze) {
return ToolResult.UH_OH;
}
if (isRubble(engine.getTile(xpos, ypos))) {
if (isRubble(city.getTile(xpos, ypos))) {
// this tile can be auto-bulldozed
cost++;
}
@ -399,11 +399,11 @@ public class ToolStroke
}
}
if (engine.budget.totalFunds < cost) {
if (city.budget.totalFunds < cost) {
return ToolResult.INSUFFICIENT_FUNDS;
}
int z = engine.PRNG.nextInt(5);
int z = city.PRNG.nextInt(5);
int tile;
if (z < 4) {
tile = (WOODS2 + z) | BURNBIT | BULLBIT;
@ -411,18 +411,18 @@ public class ToolStroke
tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT;
}
engine.spend(cost);
engine.setTile(xpos, ypos, (char) tile);
city.spend(cost);
city.setTile(xpos, ypos, (char) tile);
return ToolResult.SUCCESS;
}
ToolResult applyWireTool(Micropolis engine, int xpos, int ypos)
ToolResult applyWireTool(Micropolis city, int xpos, int ypos)
{
if (!engine.testBounds(xpos, ypos))
if (!city.testBounds(xpos, ypos))
return ToolResult.UH_OH;
ToolResult result = layWire(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
ToolResult result = layWire(city, xpos, ypos);
fixZone(city, xpos, ypos);
return result;
}
@ -434,12 +434,12 @@ public class ToolStroke
return tile;
}
private ToolResult layDoze(Micropolis engine, int xpos, int ypos)
private ToolResult layDoze(Micropolis city, int xpos, int ypos)
{
if (engine.budget.totalFunds <= 0)
if (city.budget.totalFunds <= 0)
return ToolResult.INSUFFICIENT_FUNDS;
char tile = engine.getTile(xpos, ypos);
char tile = city.getTile(xpos, ypos);
// check dozeable bit
if ((tile & BULLBIT) == 0)
@ -449,28 +449,28 @@ public class ToolStroke
if (isOverWater(tile))
{
// dozing over water, replace with water.
engine.setTile(xpos, ypos, RIVER);
city.setTile(xpos, ypos, RIVER);
}
else
{
// dozing on land, replace with land. Simple, eh?
engine.setTile(xpos, ypos, DIRT);
city.setTile(xpos, ypos, DIRT);
}
engine.spend(1);
city.spend(1);
return ToolResult.SUCCESS;
}
private ToolResult layRail(Micropolis engine, int xpos, int ypos)
private ToolResult layRail(Micropolis city, int xpos, int ypos)
{
final int RAIL_COST = 20;
final int TUNNEL_COST = 100;
int cost = RAIL_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
char tile = (char) (engine.getTile(xpos, ypos) & LOMASK);
char tile = (char) (city.getTile(xpos, ypos) & LOMASK);
switch (tile)
{
case RIVER: // rail on water
@ -478,53 +478,53 @@ public class ToolStroke
case CHANNEL:
cost = TUNNEL_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
char eTile = neutralizeRoad(engine.getTile(xpos + 1, ypos));
char eTile = neutralizeRoad(city.getTile(xpos + 1, ypos));
if (eTile == RAILHPOWERV ||
eTile == HRAIL ||
(eTile >= LHRAIL && eTile <= HRAILROAD))
{
engine.setTile(xpos, ypos, (char) (HRAIL | BULLBIT));
city.setTile(xpos, ypos, (char) (HRAIL | BULLBIT));
break;
}
}
if (xpos > 0)
{
char wTile = neutralizeRoad(engine.getTile(xpos - 1, ypos));
char wTile = neutralizeRoad(city.getTile(xpos - 1, ypos));
if (wTile == RAILHPOWERV ||
wTile == HRAIL ||
(wTile > VRAIL && wTile < VRAILROAD))
{
engine.setTile(xpos, ypos, (char) (HRAIL | BULLBIT));
city.setTile(xpos, ypos, (char) (HRAIL | BULLBIT));
break;
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
char sTile = neutralizeRoad(engine.getTile(xpos, ypos + 1));
char sTile = neutralizeRoad(city.getTile(xpos, ypos + 1));
if (sTile == RAILVPOWERH ||
sTile == VRAILROAD ||
(sTile > HRAIL && sTile < HRAILROAD))
{
engine.setTile(xpos, ypos, (char) (VRAIL | BULLBIT));
city.setTile(xpos, ypos, (char) (VRAIL | BULLBIT));
break;
}
}
if (ypos > 0)
{
char nTile = neutralizeRoad(engine.getTile(xpos, ypos - 1));
char nTile = neutralizeRoad(city.getTile(xpos, ypos - 1));
if (nTile == RAILVPOWERH ||
nTile == VRAILROAD ||
(nTile > HRAIL && nTile < HRAILROAD))
{
engine.setTile(xpos, ypos, (char) (VRAIL | BULLBIT));
city.setTile(xpos, ypos, (char) (VRAIL | BULLBIT));
break;
}
}
@ -533,24 +533,24 @@ public class ToolStroke
return ToolResult.NONE;
case LHPOWER: // rail on power
engine.setTile(xpos, ypos, (char) (RAILVPOWERH | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (RAILVPOWERH | CONDBIT | BURNBIT | BULLBIT));
break;
case LVPOWER: // rail on power
engine.setTile(xpos, ypos, (char) (RAILHPOWERV | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (RAILHPOWERV | CONDBIT | BURNBIT | BULLBIT));
break;
case TileConstants.ROADS: // rail on road (case 1)
engine.setTile(xpos, ypos, (char) (VRAILROAD | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VRAILROAD | BURNBIT | BULLBIT));
break;
case ROADS2: // rail on road (case 2)
engine.setTile(xpos, ypos, (char) (HRAILROAD | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HRAILROAD | BURNBIT | BULLBIT));
break;
default:
if (tile != DIRT) {
if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) {
if (city.autoBulldoze && canAutoBulldozeRRW(tile)) {
cost += 1; //autodoze cost
}
else {
@ -560,24 +560,24 @@ public class ToolStroke
}
//rail on dirt
engine.setTile(xpos, ypos, (char) (LHRAIL | BULLBIT | BURNBIT));
city.setTile(xpos, ypos, (char) (LHRAIL | BULLBIT | BURNBIT));
break;
}
engine.spend(cost);
city.spend(cost);
return ToolResult.SUCCESS;
}
private ToolResult layRoad(Micropolis engine, int xpos, int ypos)
private ToolResult layRoad(Micropolis city, int xpos, int ypos)
{
final int ROAD_COST = 10;
final int BRIDGE_COST = 50;
int cost = ROAD_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
char tile = (char) (engine.getTile(xpos, ypos) & LOMASK);
char tile = (char) (city.getTile(xpos, ypos) & LOMASK);
switch (tile)
{
case RIVER: // road on water
@ -585,53 +585,53 @@ public class ToolStroke
case CHANNEL: // check how to build bridges, if possible.
cost = BRIDGE_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
char eTile = neutralizeRoad(engine.getTile(xpos + 1, ypos));
char eTile = neutralizeRoad(city.getTile(xpos + 1, ypos));
if (eTile == VRAILROAD ||
eTile == HBRIDGE ||
(eTile >= TileConstants.ROADS && eTile <= HROADPOWER))
{
engine.setTile(xpos, ypos, (char) (HBRIDGE | BULLBIT));
city.setTile(xpos, ypos, (char) (HBRIDGE | BULLBIT));
break;
}
}
if (xpos > 0)
{
char wTile = neutralizeRoad(engine.getTile(xpos - 1, ypos));
char wTile = neutralizeRoad(city.getTile(xpos - 1, ypos));
if (wTile == VRAILROAD ||
wTile == HBRIDGE ||
(wTile >= TileConstants.ROADS && wTile <= INTERSECTION))
{
engine.setTile(xpos, ypos, (char) (HBRIDGE | BULLBIT));
city.setTile(xpos, ypos, (char) (HBRIDGE | BULLBIT));
break;
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
char sTile = neutralizeRoad(engine.getTile(xpos, ypos + 1));
char sTile = neutralizeRoad(city.getTile(xpos, ypos + 1));
if (sTile == HRAILROAD ||
sTile == VROADPOWER ||
(sTile >= VBRIDGE && sTile <= INTERSECTION))
{
engine.setTile(xpos, ypos, (char) (VBRIDGE | BULLBIT));
city.setTile(xpos, ypos, (char) (VBRIDGE | BULLBIT));
break;
}
}
if (ypos > 0)
{
char nTile = neutralizeRoad(engine.getTile(xpos, ypos - 1));
char nTile = neutralizeRoad(city.getTile(xpos, ypos - 1));
if (nTile == HRAILROAD ||
nTile == VROADPOWER ||
(nTile >= VBRIDGE && nTile <= INTERSECTION))
{
engine.setTile(xpos, ypos, (char) (VBRIDGE | BULLBIT));
city.setTile(xpos, ypos, (char) (VBRIDGE | BULLBIT));
break;
}
}
@ -640,24 +640,24 @@ public class ToolStroke
return ToolResult.NONE;
case LHPOWER: //road on power
engine.setTile(xpos, ypos, (char) (VROADPOWER | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VROADPOWER | CONDBIT | BURNBIT | BULLBIT));
break;
case LVPOWER: //road on power #2
engine.setTile(xpos, ypos, (char) (HROADPOWER | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HROADPOWER | CONDBIT | BURNBIT | BULLBIT));
break;
case LHRAIL: //road on rail
engine.setTile(xpos, ypos, (char) (HRAILROAD | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HRAILROAD | BURNBIT | BULLBIT));
break;
case LVRAIL: //road on rail #2
engine.setTile(xpos, ypos, (char) (VRAILROAD | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VRAILROAD | BURNBIT | BULLBIT));
break;
default:
if (tile != DIRT) {
if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) {
if (city.autoBulldoze && canAutoBulldozeRRW(tile)) {
cost += 1; //autodoze cost
}
else {
@ -667,24 +667,24 @@ public class ToolStroke
}
// road on dirt
engine.setTile(xpos, ypos, (char) (TileConstants.ROADS | BULLBIT | BURNBIT));
city.setTile(xpos, ypos, (char) (TileConstants.ROADS | BULLBIT | BURNBIT));
break;
}
engine.spend(cost);
city.spend(cost);
return ToolResult.SUCCESS;
}
private ToolResult layWire(Micropolis engine, int xpos, int ypos)
private ToolResult layWire(Micropolis city, int xpos, int ypos)
{
final int WIRE_COST = 5;
final int UNDERWATER_WIRE_COST = 25;
int cost = WIRE_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
char tile = (char) (engine.getTile(xpos, ypos) & LOMASK);
char tile = (char) (city.getTile(xpos, ypos) & LOMASK);
tile = neutralizeRoad(tile);
switch (tile)
@ -694,12 +694,12 @@ public class ToolStroke
case CHANNEL:
cost = UNDERWATER_WIRE_COST;
if (engine.budget.totalFunds < cost)
if (city.budget.totalFunds < cost)
return ToolResult.INSUFFICIENT_FUNDS;
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
char tmp = engine.getTile(xpos + 1, ypos);
char tmp = city.getTile(xpos + 1, ypos);
char tmpn = neutralizeRoad(tmp);
if ((tmp & CONDBIT) != 0 &&
@ -707,14 +707,14 @@ public class ToolStroke
tmpn != RAILHPOWERV &&
tmpn != HPOWER)
{
engine.setTile(xpos, ypos, (char) (VPOWER | CONDBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VPOWER | CONDBIT | BULLBIT));
break;
}
}
if (xpos > 0)
{
char tmp = engine.getTile(xpos - 1, ypos);
char tmp = city.getTile(xpos - 1, ypos);
char tmpn = neutralizeRoad(tmp);
if ((tmp & CONDBIT) != 0 &&
@ -722,14 +722,14 @@ public class ToolStroke
tmpn != RAILHPOWERV &&
tmpn != HPOWER)
{
engine.setTile(xpos, ypos, (char) (VPOWER | CONDBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VPOWER | CONDBIT | BULLBIT));
break;
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
char tmp = engine.getTile(xpos, ypos + 1);
char tmp = city.getTile(xpos, ypos + 1);
char tmpn = neutralizeRoad(tmp);
if ((tmp & CONDBIT) != 0 &&
@ -737,14 +737,14 @@ public class ToolStroke
tmpn != RAILVPOWERH &&
tmpn != VPOWER)
{
engine.setTile(xpos, ypos, (char) (HPOWER | CONDBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HPOWER | CONDBIT | BULLBIT));
break;
}
}
if (ypos > 0)
{
char tmp = engine.getTile(xpos, ypos - 1);
char tmp = city.getTile(xpos, ypos - 1);
char tmpn = neutralizeRoad(tmp);
if ((tmp & CONDBIT) != 0 &&
@ -752,7 +752,7 @@ public class ToolStroke
tmpn != RAILVPOWERH &&
tmpn != VPOWER)
{
engine.setTile(xpos, ypos, (char) (HPOWER | CONDBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HPOWER | CONDBIT | BULLBIT));
break;
}
}
@ -761,24 +761,24 @@ public class ToolStroke
return ToolResult.NONE;
case TileConstants.ROADS: // wire on E/W road
engine.setTile(xpos, ypos, (char) (HROADPOWER | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (HROADPOWER | CONDBIT | BURNBIT | BULLBIT));
break;
case ROADS2: // wire on N/S road
engine.setTile(xpos, ypos, (char) (VROADPOWER | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (VROADPOWER | CONDBIT | BURNBIT | BULLBIT));
break;
case LHRAIL: // wire on E/W railroad tracks
engine.setTile(xpos, ypos, (char) (RAILHPOWERV | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (RAILHPOWERV | CONDBIT | BURNBIT | BULLBIT));
break;
case LVRAIL: // wire on N/S railroad tracks
engine.setTile(xpos, ypos, (char) (RAILVPOWERH | CONDBIT | BURNBIT | BULLBIT));
city.setTile(xpos, ypos, (char) (RAILVPOWERH | CONDBIT | BURNBIT | BULLBIT));
break;
default:
if (tile != DIRT) {
if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) {
if (city.autoBulldoze && canAutoBulldozeRRW(tile)) {
cost += 1; //autodoze cost
}
else {
@ -788,30 +788,30 @@ public class ToolStroke
}
//wire on dirt
engine.setTile(xpos, ypos, (char) (LHPOWER | CONDBIT | BULLBIT | BURNBIT));
city.setTile(xpos, ypos, (char) (LHPOWER | CONDBIT | BULLBIT | BURNBIT));
break;
}
engine.spend(cost);
city.spend(cost);
return ToolResult.SUCCESS;
}
private void fixZone(Micropolis engine, int xpos, int ypos)
private void fixZone(Micropolis city, int xpos, int ypos)
{
fixSingle(engine, xpos, ypos);
fixSingle(city, xpos, ypos);
if (ypos > 0)
fixSingle(engine, xpos, ypos - 1);
fixSingle(city, xpos, ypos - 1);
if (xpos > 0)
fixSingle(engine, xpos - 1, ypos);
if (xpos + 1 < engine.getWidth())
fixSingle(engine, xpos + 1, ypos);
if (ypos + 1 < engine.getHeight())
fixSingle(engine, xpos, ypos + 1);
fixSingle(city, xpos - 1, ypos);
if (xpos + 1 < city.getWidth())
fixSingle(city, xpos + 1, ypos);
if (ypos + 1 < city.getHeight())
fixSingle(city, xpos, ypos + 1);
}
private void fixSingle(Micropolis engine, int xpos, int ypos)
private void fixSingle(Micropolis city, int xpos, int ypos)
{
char tile = (char) (engine.getTile(xpos, ypos) & LOMASK);
char tile = (char) (city.getTile(xpos, ypos) & LOMASK);
tile = neutralizeRoad(tile);
if (tile >= TileConstants.ROADS && tile <= INTERSECTION)
@ -821,7 +821,7 @@ public class ToolStroke
if (ypos > 0)
{
tile = engine.getTile(xpos, ypos - 1);
tile = city.getTile(xpos, ypos - 1);
tile = neutralizeRoad(tile);
if (((tile == HRAILROAD) ||
(tile >= ROADBASE && tile <= VROADPOWER)
@ -834,9 +834,9 @@ public class ToolStroke
}
}
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
tile = engine.getTile(xpos + 1, ypos);
tile = city.getTile(xpos + 1, ypos);
tile = neutralizeRoad(tile);
if (((tile == VRAILROAD) ||
(tile >= ROADBASE && tile <= VROADPOWER)
@ -849,9 +849,9 @@ public class ToolStroke
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
tile = engine.getTile(xpos, ypos + 1);
tile = city.getTile(xpos, ypos + 1);
tile = neutralizeRoad(tile);
if (((tile == HRAILROAD) ||
(tile >= ROADBASE && tile <= VROADPOWER)
@ -867,7 +867,7 @@ public class ToolStroke
if (xpos > 0)
{
tile = engine.getTile(xpos - 1, ypos);
tile = city.getTile(xpos - 1, ypos);
tile = neutralizeRoad(tile);
if (((tile == VRAILROAD) ||
(tile >= ROADBASE && tile <= VROADPOWER)
@ -880,7 +880,7 @@ public class ToolStroke
}
}
engine.setTile(xpos, ypos, (char)(RoadTable[adjTile] | BULLBIT | BURNBIT));
city.setTile(xpos, ypos, (char)(RoadTable[adjTile] | BULLBIT | BURNBIT));
return;
} //endif on a road tile
@ -891,7 +891,7 @@ public class ToolStroke
if (ypos > 0)
{
tile = engine.getTile(xpos, ypos - 1);
tile = city.getTile(xpos, ypos - 1);
tile = neutralizeRoad(tile);
if (tile >= RAILHPOWERV && tile <= VRAILROAD &&
tile != RAILHPOWERV &&
@ -902,9 +902,9 @@ public class ToolStroke
}
}
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
tile = engine.getTile(xpos + 1, ypos);
tile = city.getTile(xpos + 1, ypos);
tile = neutralizeRoad(tile);
if (tile >= RAILHPOWERV && tile <= VRAILROAD &&
tile != RAILVPOWERH &&
@ -915,9 +915,9 @@ public class ToolStroke
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
tile = engine.getTile(xpos, ypos + 1);
tile = city.getTile(xpos, ypos + 1);
tile = neutralizeRoad(tile);
if (tile >= RAILHPOWERV && tile <= VRAILROAD &&
tile != RAILHPOWERV &&
@ -930,7 +930,7 @@ public class ToolStroke
if (xpos > 0)
{
tile = engine.getTile(xpos - 1, ypos);
tile = city.getTile(xpos - 1, ypos);
tile = neutralizeRoad(tile);
if (tile >= RAILHPOWERV && tile <= VRAILROAD &&
tile != RAILVPOWERH &&
@ -941,7 +941,7 @@ public class ToolStroke
}
}
engine.setTile(xpos, ypos, (char)(RailTable[adjTile] | BULLBIT | BURNBIT));
city.setTile(xpos, ypos, (char)(RailTable[adjTile] | BULLBIT | BURNBIT));
return;
} //end if on a rail tile
@ -952,7 +952,7 @@ public class ToolStroke
if (ypos > 0)
{
tile = engine.getTile(xpos, ypos - 1);
tile = city.getTile(xpos, ypos - 1);
char ntile = neutralizeRoad(tile);
if ((tile & CONDBIT) != 0 &&
ntile != VPOWER &&
@ -963,9 +963,9 @@ public class ToolStroke
}
}
if (xpos + 1 < engine.getWidth())
if (xpos + 1 < city.getWidth())
{
tile = engine.getTile(xpos + 1, ypos);
tile = city.getTile(xpos + 1, ypos);
char ntile = neutralizeRoad(tile);
if ((tile & CONDBIT) != 0 &&
ntile != HPOWER &&
@ -976,9 +976,9 @@ public class ToolStroke
}
}
if (ypos + 1 < engine.getHeight())
if (ypos + 1 < city.getHeight())
{
tile = engine.getTile(xpos, ypos + 1);
tile = city.getTile(xpos, ypos + 1);
char ntile = neutralizeRoad(tile);
if ((tile & CONDBIT) != 0 &&
ntile != VPOWER &&
@ -991,7 +991,7 @@ public class ToolStroke
if (xpos > 0)
{
tile = engine.getTile(xpos - 1, ypos);
tile = city.getTile(xpos - 1, ypos);
char ntile = neutralizeRoad(tile);
if ((tile & CONDBIT) != 0 &&
ntile != HPOWER &&
@ -1002,21 +1002,21 @@ public class ToolStroke
}
}
engine.setTile(xpos, ypos, (char)(WireTable[adjTile] | BULLBIT | BURNBIT | CONDBIT));
city.setTile(xpos, ypos, (char)(WireTable[adjTile] | BULLBIT | BURNBIT | CONDBIT));
return;
} //end if on a rail tile
}
void putRubble(Micropolis engine, int xpos, int ypos, int w, int h)
void putRubble(Micropolis city, int xpos, int ypos, int w, int h)
{
for (int xx = xpos - 1; xx <= xpos + w-2; xx++) {
for (int yy = ypos - 1; yy <= ypos + h-2; yy++) {
if (engine.testBounds(xx, yy)) {
int tile = engine.getTile(xx,yy) & LOMASK;
if (city.testBounds(xx, yy)) {
int tile = city.getTile(xx,yy) & LOMASK;
if (tile != RADTILE && tile != DIRT) {
int nTile = (TINYEXP + engine.PRNG.nextInt(3))
int nTile = (TINYEXP + city.PRNG.nextInt(3))
| ANIMBIT | BULLBIT;
engine.setTile(xx, yy, (char)nTile);
city.setTile(xx, yy, (char)nTile);
}
}
}