(svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
authorbelugas
Wed, 12 Apr 2006 18:10:54 +0000
changeset 3538 750c4ea83357
parent 3537 3e18e5360f1a
child 3539 bbc5b0e6fc41
(svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
industry_cmd.c
industry_map.h
--- a/industry_cmd.c	Wed Apr 12 17:58:58 2006 +0000
+++ b/industry_cmd.c	Wed Apr 12 18:10:54 2006 +0000
@@ -608,9 +608,14 @@
 				SndPlayTileFx(SND_2A_EXTRACT_AND_POP, tile);
 			}
 
-			if (m >= 50 && (m=0,++_m[tile].m4 >= 8)) {
-				_m[tile].m4 = 0;
-				DeleteAnimatedTile(tile);
+			if (m >= 50) {
+				int n = GetIndustryAnimationLoop(tile) + 1;
+				m = 0;
+				if (n >= 8) {
+					n = 0;
+					DeleteAnimatedTile(tile);
+				}
+				SetIndustryAnimationLoop(tile, n);
 			}
 			_m[tile].m3 = m;
 			MarkTileDirtyByTile(tile);
@@ -732,7 +737,7 @@
 	case 162:
 	case 165:
 		_m[tile].m3 = 0;
-		_m[tile].m4 = 0;
+		SetIndustryAnimationLoop(tile, 0);
 		break;
 
 	case 148: case 149: case 150: case 151:
@@ -851,7 +856,7 @@
 			Industry* i = GetIndustryByTile(tile);
 			if (i->was_cargo_delivered) {
 				i->was_cargo_delivered = false;
-				_m[tile].m4 = 0;
+				SetIndustryAnimationLoop(tile, 0);
 				AddAnimatedTile(tile);
 			}
 		}
@@ -1162,12 +1167,12 @@
 }
 
 
-static bool CheckNewIndustry_NULL(TileIndex tile, int type)
+static bool CheckNewIndustry_NULL(TileIndex tile, IndustryType type)
 {
 	return true;
 }
 
-static bool CheckNewIndustry_Forest(TileIndex tile, int type)
+static bool CheckNewIndustry_Forest(TileIndex tile, IndustryType type)
 {
 	if (_opt.landscape == LT_HILLY) {
 		if (GetTileZ(tile) < _opt.snow_line + 16U) {
@@ -1181,7 +1186,7 @@
 extern bool _ignore_restrictions;
 
 /* Oil Rig and Oil Refinery */
-static bool CheckNewIndustry_Oil(TileIndex tile, int type)
+static bool CheckNewIndustry_Oil(TileIndex tile, IndustryType type)
 {
 	if (_game_mode == GM_EDITOR && _ignore_restrictions) return true;
 	if (_game_mode == GM_EDITOR && type != IT_OIL_RIG)   return true;
@@ -1192,7 +1197,7 @@
 	return false;
 }
 
-static bool CheckNewIndustry_Farm(TileIndex tile, int type)
+static bool CheckNewIndustry_Farm(TileIndex tile, IndustryType type)
 {
 	if (_opt.landscape == LT_HILLY) {
 		if (GetTileZ(tile) + TILE_HEIGHT * 2 >= _opt.snow_line) {
@@ -1203,7 +1208,7 @@
 	return true;
 }
 
-static bool CheckNewIndustry_Plantation(TileIndex tile, int type)
+static bool CheckNewIndustry_Plantation(TileIndex tile, IndustryType type)
 {
 	if (GetTropicZone(tile) == TROPICZONE_DESERT) {
 		_error_message = STR_0239_SITE_UNSUITABLE;
@@ -1213,7 +1218,7 @@
 	return true;
 }
 
-static bool CheckNewIndustry_Water(TileIndex tile, int type)
+static bool CheckNewIndustry_Water(TileIndex tile, IndustryType type)
 {
 	if (GetTropicZone(tile) != TROPICZONE_DESERT) {
 		_error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT;
@@ -1223,7 +1228,7 @@
 	return true;
 }
 
-static bool CheckNewIndustry_Lumbermill(TileIndex tile, int type)
+static bool CheckNewIndustry_Lumbermill(TileIndex tile, IndustryType type)
 {
 	if (GetTropicZone(tile) != TROPICZONE_RAINFOREST) {
 		_error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST;
@@ -1232,12 +1237,12 @@
 	return true;
 }
 
-static bool CheckNewIndustry_BubbleGen(TileIndex tile, int type)
+static bool CheckNewIndustry_BubbleGen(TileIndex tile, IndustryType type)
 {
 	return GetTileZ(tile) <= 32;
 }
 
-typedef bool CheckNewIndustryProc(TileIndex tile, int type);
+typedef bool CheckNewIndustryProc(TileIndex tile, IndustryType type);
 static CheckNewIndustryProc * const _check_new_industry_procs[] = {
 	CheckNewIndustry_NULL,
 	CheckNewIndustry_Forest,
@@ -1591,7 +1596,7 @@
 }
 
 
-Industry *CreateNewIndustry(TileIndex tile, int type)
+Industry *CreateNewIndustry(TileIndex tile, IndustryType type)
 {
 	const Town* t;
 	const IndustryTileTable *it;
--- a/industry_map.h	Wed Apr 12 17:58:58 2006 +0000
+++ b/industry_map.h	Wed Apr 12 18:10:54 2006 +0000
@@ -78,7 +78,7 @@
 	_m[t].m5 = gfx;
 }
 
-static inline void MakeIndustry(TileIndex t, uint index, uint gfx)
+static inline void MakeIndustry(TileIndex t, uint index, IndustryGfx gfx)
 {
 	SetTileType(t, MP_INDUSTRY);
 	_m[t].m1 = 0;
@@ -170,4 +170,27 @@
 	{167, 174}  //IT_SUGAR_MINE,
 };
 
+/**
+ * Get the animation loop number
+ * @param tile the tile to get the animation loop number of
+ * @pre IsTileType(tile, MP_INDUSTRY
+ */
+static inline byte GetIndustryAnimationLoop(TileIndex tile)
+{
+	assert(IsTileType(tile, MP_INDUSTRY));
+	return _m[tile].m4;
+}
+
+/**
+ * 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
+ */
+static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
+{
+	assert(IsTileType(tile, MP_INDUSTRY));
+	_m[tile].m4 = count;
+}
+
 #endif /* INDUSTRY_MAP_H */