(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town

This commit is contained in:
tron
2006-06-08 18:31:54 +00:00
parent f2da689343
commit 047ee8a601
3 changed files with 37 additions and 26 deletions

View File

@@ -1210,22 +1210,22 @@ bool AfterLoadGame(void)
* all about ;) */
if (CheckSavegameVersionOldStyle(6, 1)) {
BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) {
if (IsTileType(tile, MP_HOUSE)) {
_m[tile].m4 = _m[tile].m2;
//XXX magic
SetTileType(tile, MP_VOID);
_m[tile].m2 = ClosestTownFromTile(tile,(uint)-1)->index;
SetTileType(tile, MP_HOUSE);
} else if (IsTileType(tile, MP_STREET)) {
//XXX magic
_m[tile].m4 |= (_m[tile].m2 << 4);
if (IsTileOwner(tile, OWNER_TOWN)) {
SetTileType(tile, MP_VOID);
_m[tile].m2 = ClosestTownFromTile(tile,(uint)-1)->index;
SetTileType(tile, MP_STREET);
} else {
SetTownIndex(tile, 0);
}
switch (GetTileType(tile)) {
case MP_HOUSE:
_m[tile].m4 = _m[tile].m2;
SetTownIndex(tile, CalcClosestTownFromTile(tile, (uint)-1)->index);
break;
case MP_STREET:
_m[tile].m4 |= (_m[tile].m2 << 4);
if (IsTileOwner(tile, OWNER_TOWN)) {
SetTownIndex(tile, CalcClosestTownFromTile(tile, (uint)-1)->index);
} else {
SetTownIndex(tile, 0);
}
break;
default: break;
}
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0);
}