summaryrefslogtreecommitdiff
path: root/src/newgrf_house.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-04-25 20:50:13 +0000
committerrubidium <rubidium@openttd.org>2012-04-25 20:50:13 +0000
commit41e5c839e08bfc811b1e8d7272996567776b788f (patch)
treeeb8a74437dd42a7a57e157c6218e96b9df7fbd87 /src/newgrf_house.cpp
parentcd50c862944098753c959cc272d62a2ddc212ca8 (diff)
downloadopenttd-41e5c839e08bfc811b1e8d7272996567776b788f.tar.xz
(svn r24179) -Codechange: move some variables of Town to TownCache
Diffstat (limited to 'src/newgrf_house.cpp')
-rw-r--r--src/newgrf_house.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 760b392e8..08f198c62 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -49,6 +49,11 @@ HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
void InitializeBuildingCounts()
{
memset(&_building_counts, 0, sizeof(_building_counts));
+
+ Town *t;
+ FOR_ALL_TOWNS(t) {
+ memset(&t->cache.building_counts, 0, sizeof(t->cache.building_counts));
+ }
}
/**
@@ -63,12 +68,12 @@ void IncreaseBuildingCount(Town *t, HouseID house_id)
if (!_loaded_newgrf_features.has_newhouses) return;
- t->building_counts.id_count[house_id]++;
+ t->cache.building_counts.id_count[house_id]++;
_building_counts.id_count[house_id]++;
if (class_id == HOUSE_NO_CLASS) return;
- t->building_counts.class_count[class_id]++;
+ t->cache.building_counts.class_count[class_id]++;
_building_counts.class_count[class_id]++;
}
@@ -84,13 +89,13 @@ void DecreaseBuildingCount(Town *t, HouseID house_id)
if (!_loaded_newgrf_features.has_newhouses) return;
- if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
- if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
+ if (t->cache.building_counts.id_count[house_id] > 0) t->cache.building_counts.id_count[house_id]--;
+ if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
if (class_id == HOUSE_NO_CLASS) return;
- if (t->building_counts.class_count[class_id] > 0) t->building_counts.class_count[class_id]--;
- if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
+ if (t->cache.building_counts.class_count[class_id] > 0) t->cache.building_counts.class_count[class_id]--;
+ if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
}
static uint32 HouseGetRandomBits(const ResolverObject *object)
@@ -123,8 +128,8 @@ static uint32 GetNumHouses(HouseID house_id, const Town *town)
map_id_count = ClampU(_building_counts.id_count[house_id], 0, 255);
map_class_count = ClampU(_building_counts.class_count[class_id], 0, 255);
- town_id_count = ClampU(town->building_counts.id_count[house_id], 0, 255);
- town_class_count = ClampU(town->building_counts.class_count[class_id], 0, 255);
+ town_id_count = ClampU(town->cache.building_counts.id_count[house_id], 0, 255);
+ town_class_count = ClampU(town->cache.building_counts.class_count[class_id], 0, 255);
return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
}