From 3fb4003534dd66e7909568069e117438f88638b8 Mon Sep 17 00:00:00 2001 From: belugas Date: Tue, 15 May 2007 21:36:58 +0000 Subject: (svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses. Basically, it is more a gathering of IDs from grf files and ingame data. --- src/town_cmd.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/town_cmd.cpp') diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 4f1e29b8d..942b65c85 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -38,6 +38,7 @@ #include "newgrf.h" #include "newgrf_callbacks.h" #include "newgrf_house.h" +#include "newgrf_commons.h" /** * Called if a new block is added to the town-pool @@ -2371,19 +2372,19 @@ static const SaveLoad _town_desc[] = { /* Save and load the mapping between the house id on the map, and the grf file * it came from. */ static const SaveLoad _house_id_mapping_desc[] = { - SLE_VAR(HouseIDMapping, grfid, SLE_UINT32), - SLE_VAR(HouseIDMapping, house_id, SLE_UINT8), - SLE_VAR(HouseIDMapping, substitute_id, SLE_UINT8), + SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), + SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8), + SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8), SLE_END() }; static void Save_HOUSEIDS() { - uint i; + uint j = _house_mngr.GetMaxMapping(); - for (i = 0; i != lengthof(_house_id_mapping); i++) { + for (uint i = 0; i < j; i++) { SlSetArrayIndex(i); - SlObject(&_house_id_mapping[i], _house_id_mapping_desc); + SlObject(&_house_mngr.mapping_ID[i], _house_id_mapping_desc); } } @@ -2391,11 +2392,12 @@ static void Load_HOUSEIDS() { int index; - ResetHouseIDMapping(); + _house_mngr.ResetMapping(); + uint max_id = _house_mngr.GetMaxMapping(); while ((index = SlIterateArray()) != -1) { - if ((uint)index >= lengthof(_house_id_mapping)) break; - SlObject(&_house_id_mapping[index], _house_id_mapping_desc); + if ((uint)index >= max_id) break; + SlObject(&_house_mngr.mapping_ID[index], _house_id_mapping_desc); } } -- cgit v1.2.3-70-g09d2