buildings: s/compound/building, auto-determine tile range
auto-determine tiles that make up the building by requiring that the building always be defined on the 2nd row, 2nd column git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@812 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
7069c8150c
commit
b9bdf2850c
2 changed files with 55 additions and 52 deletions
|
@ -52,7 +52,7 @@ public class TileSpec
|
|||
|
||||
public BuildingInfo getBuildingInfo()
|
||||
{
|
||||
String tmp = getAttribute("compound");
|
||||
String tmp = getAttribute("building");
|
||||
if (tmp == null) { return null; }
|
||||
|
||||
BuildingInfo bi = new BuildingInfo();
|
||||
|
@ -62,12 +62,15 @@ public class TileSpec
|
|||
|
||||
bi.width = Integer.parseInt(p2[0]);
|
||||
bi.height = Integer.parseInt(p2[1]);
|
||||
short startTile = Short.parseShort(parts[1]);
|
||||
|
||||
bi.members = new short[bi.width*bi.height];
|
||||
int startTile = tileNumber;
|
||||
if (bi.width >= 3) { startTile--; }
|
||||
if (bi.height >= 3) { startTile -= bi.width; }
|
||||
|
||||
for (int row = 0; row < bi.height; row++) {
|
||||
for (int col = 0; col < bi.width; col++) {
|
||||
bi.members[row*bi.width+col] = startTile;
|
||||
bi.members[row*bi.width+col] = (short)startTile;
|
||||
startTile++;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue