summaryrefslogtreecommitdiff
path: root/town_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-22 18:42:03 +0000
committertron <tron@openttd.org>2004-11-22 18:42:03 +0000
commitd51887fbed33af94e45c271e953cff075e2debbf (patch)
tree81d43734e00a2819a547279faccd5221fd0cef4a /town_cmd.c
parent8a3d7cce1c94fd12a4c05a1672868c56c7ff0d14 (diff)
downloadopenttd-d51887fbed33af94e45c271e953cff075e2debbf.tar.xz
(svn r764) Enumerate the houses only one per town can exist and use the enums instead of magic numbers to check for these
Diffstat (limited to 'town_cmd.c')
-rw-r--r--town_cmd.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 4536c1541..e96494a83 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -13,6 +13,11 @@
#include "economy.h"
#include "gui.h"
+enum {
+ TOWN_HAS_CHURCH = 0x02,
+ TOWN_HAS_STADIUM = 0x04
+};
+
// Local
static int _grow_town_result;
@@ -1133,11 +1138,22 @@ static void DoBuildTownHouse(Town *t, uint tile)
continue;
// Special houses that there can be only one of.
- oneof = 0;
- if (house == 0x5B || house == 0x53 || house == 3 || house == 0x3C || house == 0x3D)
- oneof = 2;
- else if (house == 0x20 || house == 0x14)
- oneof = 4;
+ switch (house) {
+ case HOUSE_TEMP_CHURCH:
+ case HOUSE_ARCT_CHURCH:
+ case HOUSE_SNOW_CHURCH:
+ case HOUSE_TROP_CHURCH:
+ case HOUSE_TOY_CHURCH:
+ oneof = TOWN_HAS_CHURCH;
+ break;
+ case HOUSE_STADIUM:
+ case HOUSE_MODERN_STADIUM:
+ oneof = TOWN_HAS_STADIUM;
+ break;
+ default:
+ oneof = 0;
+ break;
+ }
if (t->flags12 & oneof)
continue;
@@ -1303,11 +1319,21 @@ static void ClearTownHouse(Town *t, uint tile) {
t->num_houses--;
// Clear flags for houses that only may exist once/town.
- if (house == 0x5B || house == 0x53 || house == 0x3C ||
- house == 0x3D || house == 0x03)
- t->flags12 &= ~2;
- if (house == 0x14 || house == 0x20)
- t->flags12 &= ~4;
+ switch (house) {
+ case HOUSE_TEMP_CHURCH:
+ case HOUSE_ARCT_CHURCH:
+ case HOUSE_SNOW_CHURCH:
+ case HOUSE_TROP_CHURCH:
+ case HOUSE_TOY_CHURCH:
+ t->flags12 &= ~TOWN_HAS_CHURCH;
+ break;
+ case HOUSE_STADIUM:
+ case HOUSE_MODERN_STADIUM:
+ t->flags12 &= ~TOWN_HAS_STADIUM;
+ break;
+ default:
+ break;
+ }
// Do the actual clearing of tiles
eflags = _housetype_extra_flags[house];