Changeset - r501:ea82b8cb5fd9
[Not reviewed]
master
0 1 0
tron - 20 years ago 2004-11-24 17:19:26
tron@openttd.org
(svn r800) Check if the data tables for houses have the correct number of elements via compile time asserts
1 file changed with 28 insertions and 13 deletions:
0 comments (0 inline, 0 general)
table/town_land.h
Show inline comments
 
@@ -2,13 +2,15 @@ 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
 
	HOUSE_TOY_CHURCH     = 0x5b,
 

	
 
	HOUSE_MAX            = 110
 
};
 

	
 
#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[] = {
 
	M(     0xf54,      0x58d,  0,  0, 14, 14,   8, 0),
 
@@ -1770,12 +1772,14 @@ static const DrawTownTileStruct _town_dr
 
	M(    0x1244,        0x0,  0,  0, 16, 16,  50, 0),
 
	M(    0x1244,     0x125a,  0,  0, 16, 16,  50, 0),
 
	M(    0x1244,     0x125a,  0,  0, 16, 16,  50, 0),
 
	M(    0x1244,     0x125a,  0,  0, 16, 16,  50, 0),
 
};
 
#undef M
 
// 4 variants * 4 build stages
 
assert_compile(lengthof(_town_draw_tile_data) == HOUSE_MAX * 4 * 4);
 

	
 

	
 
static const StringID _town_tile_names[] = {
 
	STR_200F_TALL_OFFICE_BLOCK,
 
	STR_2010_OFFICE_BLOCK,
 
	STR_2011_SMALL_BLOCK_OF_FLATS,
 
@@ -1884,14 +1888,15 @@ static const StringID _town_tile_names[]
 
	STR_201A_SHOPS_AND_OFFICES,
 
	STR_200F_TALL_OFFICE_BLOCK,
 
	STR_2016_STATUE,
 
	STR_205B_TEAPOT_HOUSE,
 
	STR_205C_PIGGY_BANK,
 
};
 
assert_compile(lengthof(_town_tile_names) == HOUSE_MAX);
 

	
 
static const uint16 _housetype_flags[110] = {
 
static const uint16 _housetype_flags[] = {
 
	0x1010, 0x1018, 0x100E, 0x100F, 0x7010, 0x0810, 0x100F, 0x1014,
 
	0x0000, 0x7018, 0x7010, 0x1004, 0x1008, 0x1018, 0x101C, 0x101C,
 
	0x101C, 0x7010, 0x1010, 0x1010, 0x100F, 0x0000, 0x0000, 0x0000,
 
	0x1003, 0x1001, 0x100F, 0x101C, 0x101C, 0x101C, 0x5014, 0x1018,
 
	0x700F, 0x0000, 0x0000, 0x0000, 0x7018, 0x2003, 0x0803, 0x101C,
 
	0x101E, 0x0000, 0x0000, 0x0000, 0x201C, 0x081C, 0x200F, 0x080F,
 
@@ -1901,14 +1906,15 @@ static const uint16 _housetype_flags[110
 
	0x2018, 0x0818, 0x201C, 0x0000, 0x081C, 0x0000, 0x401E, 0x401E,
 
	0x401E, 0x4001, 0x401C, 0x400E, 0x401E, 0x401C, 0x401C, 0x4018,
 
	0x4000, 0x401C, 0x4018, 0x801F, 0x801F, 0x8003, 0x800F, 0x800F,
 
	0x800F, 0x800F, 0x801C, 0x801F, 0x0000, 0x801C, 0x8001, 0x8001,
 
	0x801C, 0x801C, 0x801C, 0x801C, 0x801F, 0x801F,
 
};
 
assert_compile(lengthof(_housetype_flags) == HOUSE_MAX);
 

	
 
static const byte _housetype_extra_flags[110] = {
 
static const byte _housetype_extra_flags[] = {
 
	 0, 0, 0, 0,32,32, 0, 8,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 0,16, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	16, 0, 0, 0, 0, 0, 0, 0,
 
	16, 0, 0, 0, 0, 0, 0, 0,
 
@@ -1918,14 +1924,15 @@ static const byte _housetype_extra_flags
 
	 0, 0, 4, 0, 4, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 4,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 8, 0, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0,
 
};
 
assert_compile(lengthof(_housetype_extra_flags) == HOUSE_MAX);
 

	
 
static const byte _housetype_population[110] = {
 
static const byte _housetype_population[] = {
 
	187,  85,  40,   5, 220, 220,  30, 140,
 
	  0,   0,   0,   0,   0, 150,  95,  95,
 
	 95, 130,   6, 110,  65,   0,   0,   0,
 
	 15,  12,  13, 100, 170, 100, 180,  35,
 
	 65,   0,   0,   0, 140,  15,  15,  35,
 
	180,   0,   0,   0,  80,  80,  16,  16,
 
@@ -1935,14 +1942,15 @@ static const byte _housetype_population[
 
	190, 190, 250,   0, 250,   0,  16,  16,
 
	 16,   7,  45,   8,  18,  90, 120, 250,
 
	  0,  80, 180,   8,  18,   7,  15,  17,
 
	 19,  21,  75,  35,   0,  85,  11,  10,
 
	 67,  86,  95,  30,  25,  18,
 
};
 
assert_compile(lengthof(_housetype_population) == HOUSE_MAX);
 

	
 
static const byte _housetype_mailamount[110] = {
 
static const byte _housetype_mailamount[] = {
 
	70, 55, 20,  2, 85, 85, 12, 22,
 
	22,  0,  0,  0,  0, 65, 48, 48,
 
	48, 50, 10, 55,  5,  5,  5,  5,
 
	 6,  7,  8, 35, 50, 40, 64, 23,
 
	 5,  5,  5,  5, 65,  6,  6, 23,
 
	 5,  5,  5,  5, 20, 20,  6,  6,
 
@@ -1952,15 +1960,15 @@ static const byte _housetype_mailamount[
 
	75, 75, 60, 60, 60, 60,  6,  6,
 
	 5,  4, 15,  3,  7, 24, 25, 80,
 
	80, 23, 90,  3,  5,  3,  6,  6,
 
	 6,  6, 20,  9,  0, 18,  3,  3,
 
	22, 23, 28, 10,  8,  7,
 
};
 

	
 
assert_compile(lengthof(_housetype_mailamount) == HOUSE_MAX);
 

	
 
static const byte _housetype_remove_cost[110] = {
 
static const byte _housetype_remove_cost[] = {
 
	 150, 140, 100,  90, 160, 160,  80, 180,
 
	 180,  65,  65,  60,  60, 130, 110, 105,
 
	 107, 200, 145, 155, 250, 250, 250, 250,
 
	  70,  75,  71, 135, 145, 132, 155, 220,
 
	 250, 250, 250, 250, 170,  70,  70, 210,
 
	 250, 250, 250, 250, 100, 100,  70,  70,
 
@@ -1970,14 +1978,15 @@ static const byte _housetype_remove_cost
 
	 190, 190, 140, 140, 140, 140,  80,  80,
 
	  80,  30, 130,  90,  80, 110, 120, 190,
 
	 190, 110, 180,  90,  90,  70,  80,  80,
 
	  80,  80, 160,  90,  90, 150,  60,  60,
 
	 140, 145, 165,  90,  75,  85,
 
};
 
assert_compile(lengthof(_housetype_remove_cost) == HOUSE_MAX);
 

	
 
static const uint16 _housetype_remove_ratingmod[110] = {
 
static const uint16 _housetype_remove_ratingmod[] = {
 
	 140, 130,  90, 230, 160, 160,  80, 150,
 
	 150,  40,  40,  75,  75, 110, 100, 100,
 
	 100, 150, 110, 110, 300, 300, 300, 300,
 
	  75,  75,  75, 100, 170, 135, 180, 230,
 
	 300, 300, 300, 300, 250,  75,  75, 230,
 
	 300, 300, 300, 300,  90,  90,  70,  70,
 
@@ -1987,19 +1996,20 @@ static const uint16 _housetype_remove_ra
 
	 135, 135, 200, 200, 200, 200,  80,  80,
 
	  80,  30,  95, 200,  80,  95,  95, 140,
 
	 140,  95, 150, 200,  90,  50,  75,  75,
 
	  75,  75, 130,  80,  80, 130,  45,  45,
 
	 130, 130, 130,  70,  65,  95,
 
};
 
assert_compile(lengthof(_housetype_remove_ratingmod) == HOUSE_MAX);
 

	
 

	
 
typedef struct {
 
	byte min,max;
 
} HousetypeYear;
 

	
 
static const HousetypeYear _housetype_years[110] = {
 
static const HousetypeYear _housetype_years[] = {
 
	{43, 255},
 
	{37, 255},
 
	{48, 255},
 
	{0,  255},
 
	{55, 255},
 
	{55, 255},
 
@@ -2105,14 +2115,15 @@ static const HousetypeYear _housetype_ye
 
	{0,  255},
 
	{0,  255},
 
	{0,  255},
 
	{0,  255},
 
	{0,  255},
 
};
 
assert_compile(lengthof(_housetype_years) == HOUSE_MAX);
 

	
 
static const byte _housetype_cargo_passengers[110] = {
 
static const byte _housetype_cargo_passengers[] = {
 
	8, 8, 8, 2, 10,10,4, 6,
 
	6, 2, 2, 2, 2, 8, 6, 6,
 
	6, 10,6, 6, 4, 4, 4, 4,
 
	3, 3, 3, 7, 8, 6, 8, 8,
 
	4, 4, 4, 4, 8, 3, 3, 8,
 
	8, 8, 8, 8, 5, 5, 3, 3,
 
@@ -2122,14 +2133,15 @@ static const byte _housetype_cargo_passe
 
	9, 9, 7, 7, 7, 7, 3, 3,
 
	3, 3, 6, 2, 3, 6, 6, 8,
 
	8, 6, 8, 2, 6, 3, 3, 3,
 
	3, 3, 8, 4, 4, 8, 3, 3,
 
	8, 8, 8, 4, 3, 3,
 
};
 
assert_compile(lengthof(_housetype_cargo_passengers) == HOUSE_MAX);
 

	
 
static const byte _housetype_cargo_mail[110] = {
 
static const byte _housetype_cargo_mail[] = {
 
	 3, 3, 3, 0, 4, 4, 1, 1,
 
	 1, 0, 0, 0, 0, 2, 2, 2,
 
	 2, 3, 3, 2, 0, 0, 0, 0,
 
	 1, 1, 1, 2, 3, 2, 3, 2,
 
	 0, 0, 0, 0, 3, 1, 1, 2,
 
	 2, 2, 2, 2, 2, 2, 1, 1,
 
@@ -2139,12 +2151,13 @@ static const byte _housetype_cargo_mail[
 
	 3, 3, 2, 2, 2, 2, 1, 1,
 
	 1, 1, 2, 0, 1, 2, 2, 3,
 
	 3, 2, 3, 0, 2, 1, 1, 1,
 
	 1, 1, 4, 1, 1, 4, 1, 1,
 
	 4, 4, 4, 1, 1, 2,
 
};
 
assert_compile(lengthof(_housetype_cargo_mail) == HOUSE_MAX);
 

	
 
static const byte _housetype_cargo_goods[] = {
 
	 4, 4, 1, 0, 6, 6, 0, 2,
 
	 2, 0, 0, 0, 0, 4, 3, 3,
 
	 3, 6, 8, 6, 0, 0, 0, 0,
 
	 0, 0, 0, 2, 3, 3, 3, 2,
 
@@ -2156,12 +2169,13 @@ static const byte _housetype_cargo_goods
 
	 4, 4, 2, 2, 2, 2, 0, 0,
 
	 0, 0, 1, 0, 0, 1, 1, 4,
 
	 4, 1, 4, 0, 2, 1, 2, 2,
 
	 2, 2, 2, 2, 2, 2, 1, 1,
 
	 0, 0, 2, 2, 2, 0
 
};
 
assert_compile(lengthof(_housetype_cargo_goods) == HOUSE_MAX);
 

	
 
static const byte _housetype_cargo_food[] = {
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
@@ -2173,14 +2187,15 @@ static const byte _housetype_cargo_food[
 
	 0, 0, 0, 0, 0, 0, 2, 2,
 
	 2, 1, 0, 0, 2, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 0, 0, 0, 0, 0, 0, 0, 0,
 
	 4, 4, 0, 0, 0, 4
 
};
 
assert_compile(lengthof(_housetype_cargo_food) == HOUSE_MAX);
 

	
 
static const byte _house_more_flags[110] = {
 
static const byte _house_more_flags[] = {
 
	  8,  8,  8,  8,  8,  8,  8, 12,
 
	  0,  8,  8,  8,  8,  8,  8,  8,
 
	  8,  8,  8,  8, 15,  0,  0,  0,
 
	  8,  8,  8,  8,  8,  8,  8,  8,
 
	 15,  0,  0,  0,  8,  8,  8,  8,
 
	 15,  0,  0,  0,  8,  8,  8,  8,
 
@@ -2190,7 +2205,7 @@ static const byte _house_more_flags[110]
 
	  8,  8, 10,  0, 10,  0,  8,  8,
 
	  8,  8,  8,  8,  8,  8,  8, 10,
 
	  0,  8,  8,  8,  8,  8,  8,  8,
 
	  8,  8,  8, 12,  0,  8,  8,  8,
 
	  8,  8,  8,  8,  8,  8,
 
};
 

	
 
assert_compile(lengthof(_house_more_flags) == HOUSE_MAX);
0 comments (0 inline, 0 general)