(svn r1768) -Codechange: Store town index in _map2 of town tiles

Moved house type from _map2 to _map3_hi for MP_HOUSE
  Moved foundation and roadworks from _map2 to _map3 for
MP_STREET
  This increases game speed by a factor of around 15(!) if many cities are around.
  Converting an old game is done automagically, but can take a while
This commit is contained in:
celestar
2005-02-02 14:17:13 +00:00
parent 03095f85bc
commit 30a328705e
5 changed files with 77 additions and 37 deletions

21
ttd.c
View File

@@ -1407,6 +1407,27 @@ bool AfterLoadGame(uint version)
UpdateOilRig();
}
if (version <= 0x600) {
BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) {
if (IsTileType(tile, MP_HOUSE)) {
_map3_hi[tile] = _map2[tile];
//XXX magic
SetTileType(tile, MP_VOID);
_map2[tile] = ClosestTownFromTile(tile,(uint)-1)->index;
SetTileType(tile, MP_HOUSE);
} else if (IsTileType(tile, MP_STREET)) {
//XXX magic
SetTileType(tile, MP_VOID);
_map3_hi[tile] |= (_map2[tile] << 4);
if ( _map_owner[tile] == OWNER_TOWN)
_map2[tile] = ClosestTownFromTile(tile,(uint)-1)->index;
else
_map2[tile] = 0;
SetTileType(tile, MP_STREET);
}
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0);
}
return true;
}