applyZone: rewrite to use tiles.rc annotations
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@841 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
400c2942ee
commit
b22263b4b6
2 changed files with 27 additions and 20 deletions
|
@ -116,6 +116,7 @@ public class TileConstants
|
||||||
public static final char VRAILROAD = 238;
|
public static final char VRAILROAD = 238;
|
||||||
public static final char LASTRAIL = 238;
|
public static final char LASTRAIL = 238;
|
||||||
public static final char RESBASE = 240;
|
public static final char RESBASE = 240;
|
||||||
|
public static final char RESCLR = 244;
|
||||||
public static final char FREEZ = 244; //free zone?
|
public static final char FREEZ = 244; //free zone?
|
||||||
public static final char HOUSE = 249;
|
public static final char HOUSE = 249;
|
||||||
public static final char LHTHR = 249; //12 house tiles
|
public static final char LHTHR = 249; //12 house tiles
|
||||||
|
|
|
@ -70,34 +70,34 @@ public class ToolStroke
|
||||||
return applyParkTool(eff);
|
return applyParkTool(eff);
|
||||||
|
|
||||||
case RESIDENTIAL:
|
case RESIDENTIAL:
|
||||||
return applyZone(eff, 3, 3, RESBASE);
|
return applyZone(eff, RESCLR);
|
||||||
|
|
||||||
case COMMERCIAL:
|
case COMMERCIAL:
|
||||||
return applyZone(eff, 3, 3, COMBASE);
|
return applyZone(eff, COMCLR);
|
||||||
|
|
||||||
case INDUSTRIAL:
|
case INDUSTRIAL:
|
||||||
return applyZone(eff, 3, 3, INDBASE);
|
return applyZone(eff, INDCLR);
|
||||||
|
|
||||||
case FIRE:
|
case FIRE:
|
||||||
return applyZone(eff, 3, 3, FIRESTBASE);
|
return applyZone(eff, FIRESTATION);
|
||||||
|
|
||||||
case POLICE:
|
case POLICE:
|
||||||
return applyZone(eff, 3, 3, POLICESTBASE);
|
return applyZone(eff, POLICESTATION);
|
||||||
|
|
||||||
case POWERPLANT:
|
case POWERPLANT:
|
||||||
return applyZone(eff, 4, 4, COALBASE);
|
return applyZone(eff, POWERPLANT);
|
||||||
|
|
||||||
case STADIUM:
|
case STADIUM:
|
||||||
return applyZone(eff, 4, 4, STADIUMBASE);
|
return applyZone(eff, STADIUM);
|
||||||
|
|
||||||
case SEAPORT:
|
case SEAPORT:
|
||||||
return applyZone(eff, 4, 4, PORTBASE);
|
return applyZone(eff, PORT);
|
||||||
|
|
||||||
case NUCLEAR:
|
case NUCLEAR:
|
||||||
return applyZone(eff, 4, 4, NUCLEARBASE);
|
return applyZone(eff, NUCLEAR);
|
||||||
|
|
||||||
case AIRPORT:
|
case AIRPORT:
|
||||||
return applyZone(eff, 6, 6, AIRPORTBASE);
|
return applyZone(eff, AIRPORT);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// not expected
|
// not expected
|
||||||
|
@ -147,12 +147,19 @@ public class ToolStroke
|
||||||
return new CityLocation(xpos, ypos);
|
return new CityLocation(xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean applyZone(ToolEffectIfc eff, int width, int height, char tileBase)
|
boolean applyZone(ToolEffectIfc eff, int base)
|
||||||
{
|
{
|
||||||
|
assert isZoneCenter(base);
|
||||||
|
|
||||||
|
TileSpec.BuildingInfo bi = Tiles.get(base).getBuildingInfo();
|
||||||
|
if (bi == null) {
|
||||||
|
throw new Error("Cannot applyZone to #"+base);
|
||||||
|
}
|
||||||
|
|
||||||
int cost = tool.getToolCost();
|
int cost = tool.getToolCost();
|
||||||
boolean canBuild = true;
|
boolean canBuild = true;
|
||||||
for (int rowNum = 0; rowNum < height; rowNum++) {
|
for (int rowNum = 0; rowNum < bi.height; rowNum++) {
|
||||||
for (int columnNum = 0; columnNum < width; columnNum++)
|
for (int columnNum = 0; columnNum < bi.width; columnNum++)
|
||||||
{
|
{
|
||||||
int tileValue = eff.getTile(columnNum, rowNum);
|
int tileValue = eff.getTile(columnNum, rowNum);
|
||||||
tileValue = tileValue & LOMASK;
|
tileValue = tileValue & LOMASK;
|
||||||
|
@ -174,18 +181,17 @@ public class ToolStroke
|
||||||
|
|
||||||
eff.spend(cost);
|
eff.spend(cost);
|
||||||
|
|
||||||
for (int rowNum = 0; rowNum < height; rowNum++)
|
int i = 0;
|
||||||
|
for (int rowNum = 0; rowNum < bi.height; rowNum++)
|
||||||
{
|
{
|
||||||
for (int columnNum = 0; columnNum < width; columnNum++)
|
for (int columnNum = 0; columnNum < bi.width; columnNum++)
|
||||||
{
|
{
|
||||||
eff.setTile(columnNum, rowNum, (char) (
|
eff.setTile(columnNum, rowNum, (char) bi.members[i]);
|
||||||
tileBase
|
i++;
|
||||||
));
|
|
||||||
tileBase++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixBorder(eff, width, height);
|
fixBorder(eff, bi.width, bi.height);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue