(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
authorrubidium
Sat, 30 Dec 2006 11:41:54 +0000
changeset 5434 4739ee9714f5
parent 5433 d98fcaa8dbc3
child 5435 ffb0c3620c6e
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
-Codechange: add a reference to the industry GFX enum and some comments to the tables
-Codechange: remove some magic numbers
industry_cmd.c
industry_map.h
table/industry_land.h
--- a/industry_cmd.c	Sat Dec 30 11:28:26 2006 +0000
+++ b/industry_cmd.c	Sat Dec 30 11:41:54 2006 +0000
@@ -451,8 +451,10 @@
 		}
 		break;
 
-	case 148: case 149: case 150: case 151:
-	case 152: case 153: case 154: case 155:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
 		if ((_tick_counter & 3) == 0) {
 			IndustryGfx gfx = GetIndustryGfx(tile);
 
@@ -567,14 +569,10 @@
 		SetIndustryAnimationLoop(tile, 0);
 		break;
 
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_5:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_7:
-	case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
+	case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
 		AddAnimatedTile(tile);
 		break;
 	}
@@ -1107,31 +1105,6 @@
 	return t;
 }
 
-static const byte _industry_section_bits[] = {
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16,  4,  2, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16,  4,  2, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16, 16,
-	16, 16, 16, 16, 16, 16, 16,
-};
-
 static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type)
 {
 	_error_message = STR_0239_SITE_UNSUITABLE;
--- a/industry_map.h	Sat Dec 30 11:28:26 2006 +0000
+++ b/industry_map.h	Sat Dec 30 11:41:54 2006 +0000
@@ -48,6 +48,7 @@
 	GFX_BUBBLE_CATCHER                 = 162,
 	GFX_TOFFEE_QUARY                   = 165,
 	GFX_SUGAR_MINE_SIEVE               = 174,
+	NUM_INDUSTRY_GFXES                 = 175,
 };
 
 static inline IndustryID GetIndustryIndex(TileIndex t)
@@ -212,7 +213,7 @@
 /**
  * Get the animation loop number
  * @param tile the tile to get the animation loop number of
- * @pre IsTileType(tile, MP_INDUSTRY
+ * @pre IsTileType(tile, MP_INDUSTRY)
  */
 static inline byte GetIndustryAnimationLoop(TileIndex tile)
 {
@@ -224,7 +225,7 @@
  * Set the animation loop number
  * @param tile the tile to set the animation loop number of
  * @param count the new animation frame number
- * @pre IsTileType(tile, MP_INDUSTRY
+ * @pre IsTileType(tile, MP_INDUSTRY)
  */
 static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
 {
--- a/table/industry_land.h	Sat Dec 30 11:28:26 2006 +0000
+++ b/table/industry_land.h	Sat Dec 30 11:41:54 2006 +0000
@@ -15,7 +15,7 @@
 
 #define M(s1, s2, sx, sy, w, h, dz, p) { s1, s2, sx, sy, w - 1, h - 1, dz, p }
 
-static const DrawBuildingsTileStruct _industry_draw_tile_data[700] = {
+static const DrawBuildingsTileStruct _industry_draw_tile_data[NUM_INDUSTRY_GFXES * 4] = {
 	M(     0xf54,      0x7db,  7,  0,  9,  9,  10, 0),
 	M(     0xf54,      0x7dc,  7,  0,  9,  9,  30, 0),
 	M(     0xf54,      0x7dd,  7,  0,  9,  9,  30, 0),
@@ -898,12 +898,16 @@
 static const byte _coal_plant_sparks_x[] = {11, 11, 14, 13, 18, 15};
 static const byte _coal_plant_sparks_y[] = {23, 11,  6,  3,  1,  0};
 
-/* next frame in an animation */
 #define N 255
-static const byte _industry_section_animation_next[] = {
+/**
+ * Next frame in an animation
+ * The indices into this table are the ones as described by
+ * the enum with GFX_*s in industry_map.h.
+ */
+static const byte _industry_section_animation_next[NUM_INDUSTRY_GFXES] = {
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
-N,   16,  N,   N,   N,   N,   N,   N,
+N,   16,  N,   N,   N,   N,   N,   N, // <- growing forest
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
@@ -917,19 +921,23 @@
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
-N,   N,   129, N,   N,   N,   N,   N,
-135, N,   N,   N,   N,   N,   N,   N,
+N,   N,   129, N,   N,   N,   N,   N, // <- growing candyfloss
+135, N,   N,   N,   N,   N,   N,   N, // <- 'growing' batteries
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,
 };
 
-/* animation to start when goods is produced */
-static const byte _industry_produce_section[] = {
+/**
+ * Animation to start when goods is produced
+ * The indices into this table are the ones as described by
+ * the enum with GFX_*s in industry_map.h.
+ */
+static const byte _industry_produce_section[NUM_INDUSTRY_GFXES] = {
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
-17,  N,   N,   N,   N,   N,   N,   N,
+17,  N,   N,   N,   N,   N,   N,   N, // <- chopping forest
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
@@ -943,7 +951,7 @@
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
-N,   130, N,   N,   N,   N,   N,   136,
+N,   130, N,   N,   N,   N,   N,   136,  // <- chopping candyfloss and reaping batteries
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
 N,   N,   N,   N,   N,   N,   N,   N,
@@ -952,3 +960,32 @@
 };
 
 #undef N
+
+/**
+ * The indices into this table are the ones as described by
+ * the enum with GFX_*s in industry_map.h.
+ */
+static const byte _industry_section_bits[NUM_INDUSTRY_GFXES] = {
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16,  4,  2, 16, 16, 16, 16, // <- temperate bank
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16,  4,  2, 16, 16, 16, 16, 16, // <- sub-arctic/sub-tropical bank
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16, 16,
+	16, 16, 16, 16, 16, 16, 16,
+};