diff --git a/docs/landscape.html b/docs/landscape.html
index 30f71dff4f..18d524a7e8 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -440,13 +440,13 @@ Industry tile
00..06 | coal mine
00 | wheel tower when not animated |
-01 | wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated |
+01 | wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
|
07..0A | power station
08 | chimney |
-0A | transformer; animation progress in m1 bits 5..2 (valid range 0..7) |
+0A | transformer; animation progress in m3(valid range 0..7) |
|
0B..0F | sawmill |
@@ -460,7 +460,7 @@ Industry tile
1D..20 | oil wells
1D | not animated |
-1E..20 | various stages of animation; progress of animation in m1 bits 1..0 |
+1E..20 | various stages of animation; progress of animation in m3 |
|
21..26 | farm |
@@ -469,7 +469,7 @@ Industry tile
2F..33 | copper ore mine
2F | wheel tower when not animated |
-30 | wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated |
+30 | wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
31 | chimney |
|
@@ -480,7 +480,7 @@ Industry tile
48..58 | gold mine
4F | wheel tower when not animated |
-58 | wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated |
+58 | wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
|
59..5A | bank (sub-arctic or sub-tropical climate) |
@@ -538,10 +538,10 @@ while the animation is in progress (see the array
- m1 bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
-
m1 bits 1..0: stage of construction (3 = completed), incremented when the construction counter wraps around
the meaning is different for some animated tiles which are never under construction (types 01, 1E..20, 30, 58; see above)
+
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index cf0aa2eaaf..88988d9d25 100644
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -170,7 +170,7 @@ the array so you can quickly see what is used and what is not.
XXXX XXXX |
- 8 |
+ 8 |
industry |
XOOX XXXX |
XXXX XXXX XXXX XXXX |
@@ -180,7 +180,7 @@ the array so you can quickly see what is used and what is not.
XXXX XXXX |
- bubble/sugar/toffee |
+ bubble/sugar/toffee, gold/copper/coal, oil wells, power station |
XOOO OOOO |
-inherit- |
XXXX XXXX |
@@ -197,33 +197,6 @@ the array so you can quickly see what is used and what is not.
-inherit- |
-inherit- |
-
- gold/copper/coal |
- XXOO OOXX |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
-
-
- oil wells |
- XOOO OOXX |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
-
-
- power station |
- XOXX XXOO |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
- -inherit- |
-
9 |
tunnel |
diff --git a/industry_cmd.c b/industry_cmd.c
index a200ccf4e8..38e2c516b4 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -203,6 +203,7 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
static void DrawTile_Industry(TileInfo *ti)
{
+ const IndustryGfx gfx = GetIndustryGfx(ti->tile);
const Industry *ind;
const DrawBuildingsTileStruct *dits;
byte z;
@@ -213,7 +214,9 @@ static void DrawTile_Industry(TileInfo *ti)
ormod = GENERAL_SPRITE_COLOR(ind->random_color);
/* Retrieve pointer to the draw industry tile struct */
- dits = &_industry_draw_tile_data[GetIndustryGfx(ti->tile) << 2 | GetIndustryConstructionStage(ti->tile)];
+ dits = &_industry_draw_tile_data[gfx << 2 | (_industry_section_draw_animation_state[gfx] ?
+ GetIndustryAnimationState(ti->tile) & 3 :
+ GetIndustryConstructionStage(ti->tile))];
image = dits->ground;
if (image & PALETTE_MODIFIER_COLOR && (image & PALETTE_SPRITE_MASK) == 0)
@@ -496,7 +499,7 @@ static void AnimateTile_Industry(TileIndex tile)
if (state < 0x20 || state >= 0x180) {
m = GetIndustryAnimationState(tile);
if (!(m & 0x40)) {
- SetIndustryAnimationState(tile, m |= 0x40);
+ SetIndustryAnimationState(tile, m | 0x40);
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
}
if (state & 7)
diff --git a/industry_map.h b/industry_map.h
index b55ecd7496..5a3512fd38 100644
--- a/industry_map.h
+++ b/industry_map.h
@@ -241,24 +241,7 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
static inline byte GetIndustryAnimationState(TileIndex tile)
{
assert(IsTileType(tile, MP_INDUSTRY));
- switch (GetIndustryGfx(tile)) {
- case GFX_POWERPLANT_SPARKS:
- return GB(_m[tile].m1, 2, 5);
- break;
-
- case GFX_OILWELL_ANIMATED_1:
- case GFX_OILWELL_ANIMATED_2:
- case GFX_OILWELL_ANIMATED_3:
- return GB(_m[tile].m1, 0, 2);
-
- case GFX_COAL_MINE_TOWER_ANIMATED:
- case GFX_COPPER_MINE_TOWER_ANIMATED:
- case GFX_GOLD_MINE_TOWER_ANIMATED:
- return _m[tile].m1;
-
- default:
- return _m[tile].m3;
- }
+ return _m[tile].m3;
}
/**
@@ -270,27 +253,7 @@ static inline byte GetIndustryAnimationState(TileIndex tile)
static inline void SetIndustryAnimationState(TileIndex tile, byte state)
{
assert(IsTileType(tile, MP_INDUSTRY));
- switch (GetIndustryGfx(tile)) {
- case GFX_POWERPLANT_SPARKS:
- SB(_m[tile].m1, 2, 5, state);
- break;
-
- case GFX_OILWELL_ANIMATED_1:
- case GFX_OILWELL_ANIMATED_2:
- case GFX_OILWELL_ANIMATED_3:
- SB(_m[tile].m1, 0, 2, state);
- break;
-
- case GFX_COAL_MINE_TOWER_ANIMATED:
- case GFX_COPPER_MINE_TOWER_ANIMATED:
- case GFX_GOLD_MINE_TOWER_ANIMATED:
- _m[tile].m1 = state;
- break;
-
- default:
- _m[tile].m3 = state;
- break;
- }
+ _m[tile].m3 = state;
}
#endif /* INDUSTRY_MAP_H */
diff --git a/openttd.c b/openttd.c
index b3865da42e..023d9588bf 100644
--- a/openttd.c
+++ b/openttd.c
@@ -60,6 +60,7 @@
#include "rail_map.h"
#include "road_map.h"
#include "water_map.h"
+#include "industry_map.h"
#include
@@ -1632,6 +1633,33 @@ bool AfterLoadGame(void)
SettingsDisableElrail(_patches.disable_elrails);
}
+ if (CheckSavegameVersion(43)) {
+ BEGIN_TILE_LOOP(tile_cur, MapSizeX(), MapSizeY(), 0) {
+ if (IsTileType(tile_cur, MP_INDUSTRY)) {
+ switch (GetIndustryGfx(tile_cur)) {
+ case GFX_POWERPLANT_SPARKS:
+ SetIndustryAnimationState(tile_cur, GB(_m[tile_cur].m1, 2, 5));
+ break;
+
+ case GFX_OILWELL_ANIMATED_1:
+ case GFX_OILWELL_ANIMATED_2:
+ case GFX_OILWELL_ANIMATED_3:
+ SetIndustryAnimationState(tile_cur, GB(_m[tile_cur].m1, 0, 2));
+ break;
+
+ case GFX_COAL_MINE_TOWER_ANIMATED:
+ case GFX_COPPER_MINE_TOWER_ANIMATED:
+ case GFX_GOLD_MINE_TOWER_ANIMATED:
+ SetIndustryAnimationState(tile_cur, _m[tile_cur].m1);
+ break;
+
+ default: /* No animation states to change */
+ break;
+ }
+ }
+ } END_TILE_LOOP(tile_cur, MapSizeX(), MapSizeY(), 0)
+ }
+
return true;
}
diff --git a/saveload.c b/saveload.c
index bb821ccda4..d21d452893 100644
--- a/saveload.c
+++ b/saveload.c
@@ -30,7 +30,7 @@
#include "variables.h"
#include
-const uint16 SAVEGAME_VERSION = 42;
+const uint16 SAVEGAME_VERSION = 43;
uint16 _sl_version; /// the major savegame version identifier
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
diff --git a/table/industry_land.h b/table/industry_land.h
index 22d731706d..60beb74fbe 100644
--- a/table/industry_land.h
+++ b/table/industry_land.h
@@ -989,3 +989,34 @@ static const byte _industry_section_bits[NUM_INDUSTRY_GFXES] = {
16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16,
};
+
+/**
+ * When true, the tile has to be drawn using the animation
+ * state instead of the construction state.
+ * The indices into this table are the ones as described by
+ * the enum with GFX_*s in industry_map.h.
+ */
+static const bool _industry_section_draw_animation_state[NUM_INDUSTRY_GFXES] = {
+ false, true, false, false, false, false, false, false, // <- animated wheel tower of coal mine
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, true, true, // <- animated oil well
+ true, false, false, false, false, false, false, false, // <- animated oil well
+ false, false, false, false, false, false, false, false,
+ true, false, false, false, false, false, false, false, // <- animated wheel tower of copper mine
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ true, false, false, false, false, false, false, false, // <- animated wheel tower of gold mine
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false,
+};