mirror of https://github.com/OpenTTD/OpenTTD
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
parent
c7b1fd6fc2
commit
5f88e81641
|
@ -440,13 +440,13 @@ Industry tile
|
||||||
<tr><td nowrap valign=top><tt>00</tt>..<tt>06</tt> </td><td align=left>coal mine
|
<tr><td nowrap valign=top><tt>00</tt>..<tt>06</tt> </td><td align=left>coal mine
|
||||||
<table>
|
<table>
|
||||||
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
<tr><td nowrap valign=top><tt>00</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>01</tt> </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> </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>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>07</tt>..<tt>0A</tt> </td><td align=left>power station
|
<tr><td nowrap valign=top><tt>07</tt>..<tt>0A</tt> </td><td align=left>power station
|
||||||
<table>
|
<table>
|
||||||
<tr><td nowrap valign=top><tt>08</tt> </td><td align=left>chimney</td></tr>
|
<tr><td nowrap valign=top><tt>08</tt> </td><td align=left>chimney</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>0A</tt> </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> </td><td align=left>transformer; animation progress in m3(valid range <tt>0</tt>..<tt>7</tt>)</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>0B</tt>..<tt>0F</tt> </td><td align=left>sawmill</td></tr>
|
<tr><td nowrap valign=top><tt>0B</tt>..<tt>0F</tt> </td><td align=left>sawmill</td></tr>
|
||||||
|
@ -460,7 +460,7 @@ Industry tile
|
||||||
<tr><td nowrap valign=top><tt>1D</tt>..<tt>20</tt> </td><td align=left>oil wells
|
<tr><td nowrap valign=top><tt>1D</tt>..<tt>20</tt> </td><td align=left>oil wells
|
||||||
<table>
|
<table>
|
||||||
<tr><td nowrap valign=top><tt>1D</tt> </td><td align=left>not animated</td></tr>
|
<tr><td nowrap valign=top><tt>1D</tt> </td><td align=left>not animated</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>1E</tt>..<tt>20</tt> </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> </td><td align=left>various stages of animation; progress of animation in m3</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>21</tt>..<tt>26</tt> </td><td align=left>farm</td></tr>
|
<tr><td nowrap valign=top><tt>21</tt>..<tt>26</tt> </td><td align=left>farm</td></tr>
|
||||||
|
@ -469,7 +469,7 @@ Industry tile
|
||||||
<tr><td nowrap valign=top><tt>2F</tt>..<tt>33</tt> </td><td align=left>copper ore mine
|
<tr><td nowrap valign=top><tt>2F</tt>..<tt>33</tt> </td><td align=left>copper ore mine
|
||||||
<table>
|
<table>
|
||||||
<tr><td nowrap valign=top><tt>2F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
<tr><td nowrap valign=top><tt>2F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>30</tt> </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> </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> </td><td align=left>chimney</td></tr>
|
<tr><td nowrap valign=top><tt>31</tt> </td><td align=left>chimney</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
@ -480,7 +480,7 @@ Industry tile
|
||||||
<tr><td nowrap valign=top><tt>48</tt>..<tt>58</tt> </td><td align=left>gold mine
|
<tr><td nowrap valign=top><tt>48</tt>..<tt>58</tt> </td><td align=left>gold mine
|
||||||
<table>
|
<table>
|
||||||
<tr><td nowrap valign=top><tt>4F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
<tr><td nowrap valign=top><tt>4F</tt> </td><td align=left>wheel tower when not animated</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>58</tt> </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> </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>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td nowrap valign=top><tt>59</tt>..<tt>5A</tt> </td><td align=left>bank (sub-arctic or sub-tropical climate)</td></tr>
|
<tr><td nowrap valign=top><tt>59</tt>..<tt>5A</tt> </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>
|
<ul>
|
||||||
<li>m1 bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
|
<li>m1 bits 4..2: construction counter, for buildings under construction incremented on every periodic tile processing
|
||||||
</li>
|
</li>
|
||||||
</ul></li>
|
|
||||||
<li>m1 bits 1..0: stage of construction (<tt>3</tt> = completed), incremented when the construction counter wraps around
|
<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)
|
<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>
|
</li>
|
||||||
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ the array so you can quickly see what is used and what is not.
|
||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan=6>8</td>
|
<td rowspan=3>8</td>
|
||||||
<td class="caption">industry</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"><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>
|
<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>
|
<td class="bits">XXXX XXXX</td>
|
||||||
</tr>
|
</tr>
|
||||||
<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"><span class="abuse">X</span><span class="free">OOO OOOO</span></td>
|
||||||
<td class="bits">-inherit-</td>
|
<td class="bits">-inherit-</td>
|
||||||
<td class="bits">XXXX XXXX</td>
|
<td class="bits">XXXX XXXX</td>
|
||||||
|
@ -197,33 +197,6 @@ the array so you can quickly see what is used and what is not.
|
||||||
<td class="bits">-inherit-</td>
|
<td class="bits">-inherit-</td>
|
||||||
<td class="bits">-inherit-</td>
|
<td class="bits">-inherit-</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td rowspan=2>9</td>
|
<td rowspan=2>9</td>
|
||||||
<td class="caption">tunnel</td>
|
<td class="caption">tunnel</td>
|
||||||
|
|
|
@ -203,6 +203,7 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
|
||||||
|
|
||||||
static void DrawTile_Industry(TileInfo *ti)
|
static void DrawTile_Industry(TileInfo *ti)
|
||||||
{
|
{
|
||||||
|
const IndustryGfx gfx = GetIndustryGfx(ti->tile);
|
||||||
const Industry *ind;
|
const Industry *ind;
|
||||||
const DrawBuildingsTileStruct *dits;
|
const DrawBuildingsTileStruct *dits;
|
||||||
byte z;
|
byte z;
|
||||||
|
@ -213,7 +214,9 @@ static void DrawTile_Industry(TileInfo *ti)
|
||||||
ormod = GENERAL_SPRITE_COLOR(ind->random_color);
|
ormod = GENERAL_SPRITE_COLOR(ind->random_color);
|
||||||
|
|
||||||
/* Retrieve pointer to the draw industry tile struct */
|
/* 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;
|
image = dits->ground;
|
||||||
if (image & PALETTE_MODIFIER_COLOR && (image & PALETTE_SPRITE_MASK) == 0)
|
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) {
|
if (state < 0x20 || state >= 0x180) {
|
||||||
m = GetIndustryAnimationState(tile);
|
m = GetIndustryAnimationState(tile);
|
||||||
if (!(m & 0x40)) {
|
if (!(m & 0x40)) {
|
||||||
SetIndustryAnimationState(tile, m |= 0x40);
|
SetIndustryAnimationState(tile, m | 0x40);
|
||||||
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
|
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
|
||||||
}
|
}
|
||||||
if (state & 7)
|
if (state & 7)
|
||||||
|
|
|
@ -241,24 +241,7 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
|
||||||
static inline byte GetIndustryAnimationState(TileIndex tile)
|
static inline byte GetIndustryAnimationState(TileIndex tile)
|
||||||
{
|
{
|
||||||
assert(IsTileType(tile, MP_INDUSTRY));
|
assert(IsTileType(tile, MP_INDUSTRY));
|
||||||
switch (GetIndustryGfx(tile)) {
|
return _m[tile].m3;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,27 +253,7 @@ static inline byte GetIndustryAnimationState(TileIndex tile)
|
||||||
static inline void SetIndustryAnimationState(TileIndex tile, byte state)
|
static inline void SetIndustryAnimationState(TileIndex tile, byte state)
|
||||||
{
|
{
|
||||||
assert(IsTileType(tile, MP_INDUSTRY));
|
assert(IsTileType(tile, MP_INDUSTRY));
|
||||||
switch (GetIndustryGfx(tile)) {
|
_m[tile].m3 = state;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* INDUSTRY_MAP_H */
|
#endif /* INDUSTRY_MAP_H */
|
||||||
|
|
28
openttd.c
28
openttd.c
|
@ -60,6 +60,7 @@
|
||||||
#include "rail_map.h"
|
#include "rail_map.h"
|
||||||
#include "road_map.h"
|
#include "road_map.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
|
#include "industry_map.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -1632,6 +1633,33 @@ bool AfterLoadGame(void)
|
||||||
SettingsDisableElrail(_patches.disable_elrails);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
const uint16 SAVEGAME_VERSION = 42;
|
const uint16 SAVEGAME_VERSION = 43;
|
||||||
uint16 _sl_version; /// the major savegame version identifier
|
uint16 _sl_version; /// the major savegame version identifier
|
||||||
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
|
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
|
||||||
|
|
||||||
|
|
|
@ -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, 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,
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue