mirror of https://github.com/OpenTTD/OpenTTD
(svn r764) Enumerate the houses only one per town can exist and use the enums instead of magic numbers to check for these
parent
8a3d7cce1c
commit
d51887fbed
|
@ -1,3 +1,13 @@
|
||||||
|
enum {
|
||||||
|
HOUSE_TEMP_CHURCH = 0x03,
|
||||||
|
HOUSE_STADIUM = 0x14,
|
||||||
|
HOUSE_MODERN_STADIUM = 0x20,
|
||||||
|
HOUSE_ARCT_CHURCH = 0x3c,
|
||||||
|
HOUSE_SNOW_CHURCH = 0x3d,
|
||||||
|
HOUSE_TROP_CHURCH = 0x53,
|
||||||
|
HOUSE_TOY_CHURCH = 0x5b
|
||||||
|
};
|
||||||
|
|
||||||
#define M(s1, s2, sx, sy, w, h, dz, p) {s1, s2, sx, sy, w - 1, h - 1, dz, p}
|
#define M(s1, s2, sx, sy, w, h, dz, p) {s1, s2, sx, sy, w - 1, h - 1, dz, p}
|
||||||
|
|
||||||
static const DrawTownTileStruct _town_draw_tile_data[] = {
|
static const DrawTownTileStruct _town_draw_tile_data[] = {
|
||||||
|
|
46
town_cmd.c
46
town_cmd.c
|
@ -13,6 +13,11 @@
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TOWN_HAS_CHURCH = 0x02,
|
||||||
|
TOWN_HAS_STADIUM = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
// Local
|
// Local
|
||||||
static int _grow_town_result;
|
static int _grow_town_result;
|
||||||
|
|
||||||
|
@ -1133,11 +1138,22 @@ static void DoBuildTownHouse(Town *t, uint tile)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Special houses that there can be only one of.
|
// Special houses that there can be only one of.
|
||||||
oneof = 0;
|
switch (house) {
|
||||||
if (house == 0x5B || house == 0x53 || house == 3 || house == 0x3C || house == 0x3D)
|
case HOUSE_TEMP_CHURCH:
|
||||||
oneof = 2;
|
case HOUSE_ARCT_CHURCH:
|
||||||
else if (house == 0x20 || house == 0x14)
|
case HOUSE_SNOW_CHURCH:
|
||||||
oneof = 4;
|
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)
|
if (t->flags12 & oneof)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1303,11 +1319,21 @@ static void ClearTownHouse(Town *t, uint tile) {
|
||||||
t->num_houses--;
|
t->num_houses--;
|
||||||
|
|
||||||
// Clear flags for houses that only may exist once/town.
|
// Clear flags for houses that only may exist once/town.
|
||||||
if (house == 0x5B || house == 0x53 || house == 0x3C ||
|
switch (house) {
|
||||||
house == 0x3D || house == 0x03)
|
case HOUSE_TEMP_CHURCH:
|
||||||
t->flags12 &= ~2;
|
case HOUSE_ARCT_CHURCH:
|
||||||
if (house == 0x14 || house == 0x20)
|
case HOUSE_SNOW_CHURCH:
|
||||||
t->flags12 &= ~4;
|
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
|
// Do the actual clearing of tiles
|
||||||
eflags = _housetype_extra_flags[house];
|
eflags = _housetype_extra_flags[house];
|
||||||
|
|
Loading…
Reference in New Issue