diff options
author | rubidium <rubidium@openttd.org> | 2006-09-08 22:12:57 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-09-08 22:12:57 +0000 |
commit | 6fdf0155bc9f81da71c3e817b80c44155f178201 (patch) | |
tree | 648b87ffefdb78d944606881f5c92b6d4d4507bc | |
parent | 2cb9350c405a71bc0254fb1c9907afa3310167d8 (diff) | |
download | openttd-6fdf0155bc9f81da71c3e817b80c44155f178201.tar.xz |
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
-rw-r--r-- | industry_cmd.c | 82 | ||||
-rw-r--r-- | industry_map.h | 40 |
2 files changed, 75 insertions, 47 deletions
diff --git a/industry_cmd.c b/industry_cmd.c index 8e0165c01..60734db1b 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -506,17 +506,17 @@ static void AnimateTile_Industry(TileIndex tile) } break; - case GFX_OILWELL_ANIM1: - case GFX_OILWELL_ANIM2: - case GFX_OILWELL_ANIM3: + case GFX_OILWELL_ANIMATED_1: + case GFX_OILWELL_ANIMATED_2: + case GFX_OILWELL_ANIMATED_3: if ((_tick_counter & 7) == 0) { bool b = CHANCE16(1,7); IndustryGfx gfx = GetIndustryGfx(tile); m = GB(_m[tile].m1, 0, 2) + 1; - if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIM3 + 1 && (gfx = GFX_OILWELL_ANIM1, b)) { + if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) { _m[tile].m1 = 0x83; - SetIndustryGfx(tile, GFX_OILWELL_BASE); + SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED); DeleteAnimatedTile(tile); } else { SB(_m[tile].m1, 0, 2, m); @@ -526,9 +526,9 @@ static void AnimateTile_Industry(TileIndex tile) } break; - case 88: - case 48: - case 1: { + case GFX_COAL_MINE_TOWER_ANIMATED: + case GFX_COPPER_MINE_TOWER_ANIMATED: + case GFX_GOLD_MINE_TOWER_ANIMATED: { int state = _tick_counter & 0x7FF; if ((state -= 0x400) < 0) @@ -596,12 +596,12 @@ static void MakeIndustryTileBigger(TileIndex tile) if (!IsIndustryCompleted(tile)) return; switch (GetIndustryGfx(tile)) { - case 8: + case GFX_POWERPLANT_CHIMNEY: CreateIndustryEffectSmoke(tile); break; - case 24: - if (GetIndustryGfx(tile + TileDiffXY(0, 1)) == 24) BuildOilRig(tile); + case GFX_OILRIG_BASE: + if (GetIndustryGfx(tile + TileDiffXY(0, 1)) == GFX_OILRIG_BASE) BuildOilRig(tile); break; case GFX_TOY_FACTORY: @@ -611,8 +611,14 @@ static void MakeIndustryTileBigger(TileIndex tile) SetIndustryAnimationLoop(tile, 0); 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: AddAnimatedTile(tile); break; } @@ -668,62 +674,62 @@ static void TileLoop_Industry(TileIndex tile) #define SET_AND_UNANIMATE(tile, a, b) { SetIndustryGfx(tile, a); _m[tile].m1 = b; DeleteAnimatedTile(tile); } switch (GetIndustryGfx(tile)) { - case 0x18: // coast line at oilrigs - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: + case GFX_OILRIG_1: // coast line at oilrigs + case GFX_OILRIG_2: + case GFX_OILRIG_3: + case GFX_OILRIG_4: + case GFX_OILRIG_5: TileLoop_Water(tile); break; - case 0: + case GFX_COAL_MINE_TOWER_NOT_ANIMATED: if (!(_tick_counter & 0x400) && CHANCE16(1,2)) - SET_AND_ANIMATE(tile,1,0x80); + SET_AND_ANIMATE(tile, GFX_COAL_MINE_TOWER_ANIMATED, 0x80); break; - case 47: + case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: if (!(_tick_counter & 0x400) && CHANCE16(1,2)) - SET_AND_ANIMATE(tile,0x30,0x80); + SET_AND_ANIMATE(tile, GFX_COPPER_MINE_TOWER_ANIMATED, 0x80); break; - case 79: + case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: if (!(_tick_counter & 0x400) && CHANCE16(1,2)) - SET_AND_ANIMATE(tile,0x58,0x80); + SET_AND_ANIMATE(tile, GFX_GOLD_MINE_TOWER_ANIMATED, 0x80); break; - case 29: + case GFX_OILWELL_NOT_ANIMATED: if (CHANCE16(1,6)) - SET_AND_ANIMATE(tile,0x1E,0x80); + SET_AND_ANIMATE(tile, GFX_OILWELL_ANIMATED_1, 0x80); break; - case 1: + case GFX_COAL_MINE_TOWER_ANIMATED: if (!(_tick_counter & 0x400)) - SET_AND_UNANIMATE(tile, 0, 0x83); + SET_AND_UNANIMATE(tile, GFX_COAL_MINE_TOWER_NOT_ANIMATED, 0x83); break; - case 48: + case GFX_COPPER_MINE_TOWER_ANIMATED: if (!(_tick_counter & 0x400)) - SET_AND_UNANIMATE(tile, 0x2F, 0x83); + SET_AND_UNANIMATE(tile, GFX_COPPER_MINE_TOWER_NOT_ANIMATED, 0x83); break; - case 88: + case GFX_GOLD_MINE_TOWER_ANIMATED: if (!(_tick_counter & 0x400)) - SET_AND_UNANIMATE(tile, 0x4F, 0x83); + SET_AND_UNANIMATE(tile, GFX_GOLD_MINE_TOWER_NOT_ANIMATED, 0x83); break; - case 10: + case GFX_POWERPLANT_SPARKS: if (CHANCE16(1,3)) { SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile); AddAnimatedTile(tile); } break; - case 49: + case GFX_COPPER_MINE_CHIMNEY: CreateEffectVehicleAbove(TileX(tile) * TILE_SIZE + 6, TileY(tile) * TILE_SIZE + 6, 43, EV_SMOKE); break; - case 143: { + case GFX_TOY_FACTORY: { Industry *i = GetIndustryByTile(tile); if (i->was_cargo_delivered) { i->was_cargo_delivered = false; @@ -733,15 +739,15 @@ static void TileLoop_Industry(TileIndex tile) } break; - case 161: + case GFX_BUBBLE_GENERATOR: TileLoopIndustry_BubbleGenerator(tile); break; - case 165: + case GFX_TOFFEE_QUARY: AddAnimatedTile(tile); break; - case 174: + case GFX_SUGAR_MINE_SIEVE: if (CHANCE16(1, 3)) AddAnimatedTile(tile); break; } diff --git a/industry_map.h b/industry_map.h index 5486a1528..b284ab1f0 100644 --- a/industry_map.h +++ b/industry_map.h @@ -17,15 +17,37 @@ * How to calculate the correct position ? GFXid << 2 | IndustryStage (0 to 3) */ enum { - GFX_POWERPLANT_SPARKS = 10, - GFX_OILWELL_BASE = 29, - GFX_OILWELL_ANIM1 = 30, - GFX_OILWELL_ANIM2 = 31, - GFX_OILWELL_ANIM3 = 32, - GFX_BUBBLE_CATCHER = 162, - GFX_TOFFEE_QUARY = 165, - GFX_SUGAR_MINE_SIEVE = 174, - GFX_TOY_FACTORY = 143 + GFX_COAL_MINE_TOWER_NOT_ANIMATED = 0, + GFX_COAL_MINE_TOWER_ANIMATED = 1, + GFX_POWERPLANT_CHIMNEY = 8, + GFX_POWERPLANT_SPARKS = 10, + GFX_OILRIG_1 = 24, + GFX_OILRIG_2 = 25, + GFX_OILRIG_3 = 26, + GFX_OILRIG_4 = 27, + GFX_OILRIG_5 = 28, + GFX_OILWELL_NOT_ANIMATED = 29, + GFX_OILWELL_ANIMATED_1 = 30, + GFX_OILWELL_ANIMATED_2 = 31, + GFX_OILWELL_ANIMATED_3 = 32, + GFX_COPPER_MINE_TOWER_NOT_ANIMATED = 47, + GFX_COPPER_MINE_TOWER_ANIMATED = 48, + GFX_COPPER_MINE_CHIMNEY = 49, + GFX_GOLD_MINE_TOWER_NOT_ANIMATED = 79, + GFX_GOLD_MINE_TOWER_ANIMATED = 88, + GFX_TOY_FACTORY = 143, + GFX_PLASTIC_FOUNTAIN_ANIMATED_1 = 148, + GFX_PLASTIC_FOUNTAIN_ANIMATED_2 = 149, + GFX_PLASTIC_FOUNTAIN_ANIMATED_3 = 150, + GFX_PLASTIC_FOUNTAIN_ANIMATED_4 = 151, + GFX_PLASTIC_FOUNTAIN_ANIMATED_5 = 152, + GFX_PLASTIC_FOUNTAIN_ANIMATED_6 = 153, + GFX_PLASTIC_FOUNTAIN_ANIMATED_7 = 154, + GFX_PLASTIC_FOUNTAIN_ANIMATED_8 = 155, + GFX_BUBBLE_GENERATOR = 161, + GFX_BUBBLE_CATCHER = 162, + GFX_TOFFEE_QUARY = 165, + GFX_SUGAR_MINE_SIEVE = 174, }; static inline IndustryID GetIndustryIndex(TileIndex t) |