summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-12-30 11:57:52 +0000
committerrubidium <rubidium@openttd.org>2006-12-30 11:57:52 +0000
commitafb5bd0bc6c00acff8c8f897369066fb2be56307 (patch)
tree208ddbfdccba148fd9aa969b5124fe9c495ba540
parent52b6d4d486d0c8961a75141049ba514558299bc1 (diff)
downloadopenttd-afb5bd0bc6c00acff8c8f897369066fb2be56307.tar.xz
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
-rw-r--r--docs/landscape.html12
-rw-r--r--docs/landscape_grid.html31
-rw-r--r--industry_cmd.c7
-rw-r--r--industry_map.h41
-rw-r--r--openttd.c28
-rw-r--r--saveload.c2
-rw-r--r--table/industry_land.h31
7 files changed, 75 insertions, 77 deletions
diff --git a/docs/landscape.html b/docs/landscape.html
index 30f71dff4..18d524a7e 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -440,13 +440,13 @@ Industry tile
<tr><td nowrap valign=top><tt>00</tt>..<tt>06</tt>&nbsp; </td><td align=left>coal mine
<table>
<tr><td nowrap valign=top><tt>00</tt>&nbsp; </td><td align=left>wheel tower when not animated</td></tr>
-<tr><td nowrap valign=top><tt>01</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
+<tr><td nowrap valign=top><tt>01</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated</td></tr>
</table>
</td></tr>
<tr><td nowrap valign=top><tt>07</tt>..<tt>0A</tt>&nbsp; </td><td align=left>power station
<table>
<tr><td nowrap valign=top><tt>08</tt>&nbsp; </td><td align=left>chimney</td></tr>
-<tr><td nowrap valign=top><tt>0A</tt>&nbsp; </td><td align=left>transformer; animation progress in m1 bits 5..2 (valid range <tt>0</tt>..<tt>7</tt>)</td></tr>
+<tr><td nowrap valign=top><tt>0A</tt>&nbsp; </td><td align=left>transformer; animation progress in m3(valid range <tt>0</tt>..<tt>7</tt>)</td></tr>
</table>
</td></tr>
<tr><td nowrap valign=top><tt>0B</tt>..<tt>0F</tt>&nbsp; </td><td align=left>sawmill</td></tr>
@@ -460,7 +460,7 @@ Industry tile
<tr><td nowrap valign=top><tt>1D</tt>..<tt>20</tt>&nbsp; </td><td align=left>oil wells
<table>
<tr><td nowrap valign=top><tt>1D</tt>&nbsp; </td><td align=left>not animated</td></tr>
-<tr><td nowrap valign=top><tt>1E</tt>..<tt>20</tt>&nbsp; </td><td align=left>various stages of animation; progress of animation in m1 bits 1..0</td></tr>
+<tr><td nowrap valign=top><tt>1E</tt>..<tt>20</tt>&nbsp; </td><td align=left>various stages of animation; progress of animation in m3</td></tr>
</table>
</td></tr>
<tr><td nowrap valign=top><tt>21</tt>..<tt>26</tt>&nbsp; </td><td align=left>farm</td></tr>
@@ -469,7 +469,7 @@ Industry tile
<tr><td nowrap valign=top><tt>2F</tt>..<tt>33</tt>&nbsp; </td><td align=left>copper ore mine
<table>
<tr><td nowrap valign=top><tt>2F</tt>&nbsp; </td><td align=left>wheel tower when not animated</td></tr>
-<tr><td nowrap valign=top><tt>30</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
+<tr><td nowrap valign=top><tt>30</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated</td></tr>
<tr><td nowrap valign=top><tt>31</tt>&nbsp; </td><td align=left>chimney</td></tr>
</table>
</td></tr>
@@ -480,7 +480,7 @@ Industry tile
<tr><td nowrap valign=top><tt>48</tt>..<tt>58</tt>&nbsp; </td><td align=left>gold mine
<table>
<tr><td nowrap valign=top><tt>4F</tt>&nbsp; </td><td align=left>wheel tower when not animated</td></tr>
-<tr><td nowrap valign=top><tt>58</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m1 bits 5..0; m1 bit 6 set = sound already generated</td></tr>
+<tr><td nowrap valign=top><tt>58</tt>&nbsp; </td><td align=left>wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated</td></tr>
</table>
</td></tr>
<tr><td nowrap valign=top><tt>59</tt>..<tt>5A</tt>&nbsp; </td><td align=left>bank (sub-arctic or sub-tropical climate)</td></tr>
@@ -538,10 +538,10 @@ while the animation is in progress (see the <a href="#_AnimatedTilesList">array
<ul>
<li>m1 bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
</li>
-</ul></li>
<li>m1 bits 1..0: stage of construction (<tt>3</tt> = completed), incremented when the construction counter wraps around
<br>the meaning is different for some animated tiles which are never under construction (types <tt>01</tt>, <tt>1E</tt>..<tt>20</tt>, <tt>30</tt>, <tt>58</tt>; see above)
</li>
+</ul></li>
</ul>
</td></tr>
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index cf0aa2eaa..88988d9d2 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.
<td class="bits">XXXX XXXX</td>
</tr>
<tr>
- <td rowspan=6>8</td>
+ <td rowspan=3>8</td>
<td class="caption">industry</td>
<td class="bits"><span class="abuse">X</span><span class="free">OO</span><span class="abuse">X XXXX</span></td>
<td class="bits">XXXX XXXX XXXX XXXX</td>
@@ -180,7 +180,7 @@ the array so you can quickly see what is used and what is not.
<td class="bits">XXXX XXXX</td>
</tr>
<tr>
- <td>bubble/sugar/toffee</td>
+ <td>bubble/sugar/toffee, gold/copper/coal, oil wells, power station</td>
<td class="bits"><span class="abuse">X</span><span class="free">OOO OOOO</span></td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX</td>
@@ -198,33 +198,6 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td>
</tr>
<tr>
- <td>gold/copper/coal</td>
- <td class="bits"><span class="abuse">XX</span><span class="free">OO OO</span><span class="abuse">XX</span></td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- </tr>
- <tr>
- <td>oil wells</td>
- <td class="bits"><span class="abuse">X</span><span class="free">OOO OO</span><span class="abuse">XX</span></td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- </tr>
- <tr>
- <td>power station</td>
- <td class="bits"><span class="abuse">X</span><span class="free">O</span><span class="abuse">XX XX</span><span class="free">OO</span></td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- <td class="bits">-inherit-</td>
- </tr>
- <tr>
<td rowspan=2>9</td>
<td class="caption">tunnel</td>
<td class="bits">XXXX XXXX</td>
diff --git a/industry_cmd.c b/industry_cmd.c
index a200ccf4e..38e2c516b 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 b55ecd749..5a3512fd3 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 b3865da42..023d9588b 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 <stdarg.h>
@@ -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 bb821ccda..d21d45289 100644
--- a/saveload.c
+++ b/saveload.c
@@ -30,7 +30,7 @@
#include "variables.h"
#include <setjmp.h>
-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 22d731706..60beb74fb 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,
+};