summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-05-15 21:36:58 +0000
committerbelugas <belugas@openttd.org>2007-05-15 21:36:58 +0000
commit3fb4003534dd66e7909568069e117438f88638b8 (patch)
tree70f568a4e7749c7071ef405f07b8f2998266f606 /src/town_cmd.cpp
parentd2776ccde91e64b0402af22b512a8f6677fca86e (diff)
downloadopenttd-3fb4003534dd66e7909568069e117438f88638b8.tar.xz
(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.
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp20
1 files changed, 11 insertions, 9 deletions
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);
}
}