diff options
author | rubidium <rubidium@openttd.org> | 2010-08-26 14:36:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-26 14:36:00 +0000 |
commit | 7f86dcca90b20241a210dd5f088e249a902f725c (patch) | |
tree | 6793ebbb3e7395db1e51b19fb18ea3b6e196a337 | |
parent | 193800e0faef9711b48cedcf37feb896d9e0c448 (diff) | |
download | openttd-7f86dcca90b20241a210dd5f088e249a902f725c.tar.xz |
(svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
-rw-r--r-- | docs/landscape.html | 24 | ||||
-rw-r--r-- | docs/landscape_grid.html | 9 | ||||
-rw-r--r-- | src/industry_map.h | 12 | ||||
-rw-r--r-- | src/newgrf.cpp | 2 | ||||
-rw-r--r-- | src/object_map.h | 4 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 41 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 3 | ||||
-rw-r--r-- | src/town_map.h | 61 |
8 files changed, 94 insertions, 62 deletions
diff --git a/docs/landscape.html b/docs/landscape.html index 6460dd1ef..af35fb0bc 100644 --- a/docs/landscape.html +++ b/docs/landscape.html @@ -669,7 +669,7 @@ </li> </ul> <li>m3 bit 6 : bit 8 of house type (m4), allowing 512 different types.</li> - <li>m3 bit 5 : bit 6 of current animation frame (see m6)</li> + <li>m3 bit 5 : free</li> <li>m3 bits 4..0 : triggers activated <a href="#newhouses">(newhouses)</a></li> <li>m4 : <a href="landscape_externals.html">town building type</a> (with m3[6] bit)</li> <li>m5 : see m3 bit 7</li> @@ -677,7 +677,7 @@ <ul> <li>If <a href="#newhouses">newhouses</a> is activated <ul> - <li>bits 7..2 : Current animation frame (bits 5..0); bit 6 in m3</li> + <li>bits 7..2 : Periodic processing time remaining</li> </ul> </li> <li>Standard behaviour @@ -692,7 +692,7 @@ <ul> <li>If <a href="#newhouses">newhouses</a> is activated <ul> - <li>Periodic processing time remaining</li> + <li>Current animation frame</li> </ul> </li> <li>Standard behaviour (only for houses type 04 and 05) @@ -1090,7 +1090,7 @@ </ul> </li> <li>m2: index into the array of industries</li> - <li>m3: animation state</li> + <li>m3: random bits (NewGRF)</li> <li>m4: animation loop</li> <li>m5: type (plus m6 bit 2):<br> <small>(note: this is not the same as the industry type, which is stored in the array of industries)</small> @@ -1107,7 +1107,7 @@ <tr> <td nowrap valign=top><tt>01</tt> </td> <td align=left>wheel tower when animated<br> - animation state in m3 bits 5..0; m3 bit 6 set = sound already generated</td> + animation state in m7 bits 5..0; m7 bit 6 set = sound already generated</td> </tr> </table> </td> @@ -1123,7 +1123,7 @@ </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> + <td align=left>transformer; animation progress in m7(valid range <tt>0</tt>..<tt>7</tt>)</td> </tr> </table> </td> @@ -1166,7 +1166,7 @@ </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> + <td align=left>various stages of animation; progress of animation in m7</td> </tr> </table> </td> @@ -1197,7 +1197,7 @@ </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> + <td align=left>wheel tower when animated; animation state in m7 bits 5..0; m7 bit 6 set = sound already generated</td> </tr> <tr> <td nowrap valign=top><tt>31</tt> </td> @@ -1237,7 +1237,7 @@ </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> + <td align=left>wheel tower when animated; animation state in m7 bits 5..0; m7 bit 6 set = sound already generated</td> </tr> </table></td> </tr> @@ -1332,7 +1332,7 @@ <table> <tr> <td nowrap valign=top><tt>8F</tt> </td> - <td align=left>Animated part; animation state in m3 (valid range <tt>00</tt>..<tt>31</tt>)<br> + <td align=left>Animated part; animation state in m7 (valid range <tt>00</tt>..<tt>31</tt>)<br> Tile animation is started (m4 zeroed) on the periodic processing.<br> While the animation is in progress, m4 holds the number of animation cycles that have already taken place.<br> @@ -1362,7 +1362,7 @@ </tr> <tr> <td nowrap valign=top><tt>A2</tt> </td> - <td align=left>bubble capture facility; animation state in m3 (valid range <tt>00</tt>..<tt>27</tt>)</td> + <td align=left>bubble capture facility; animation state in m7 (valid range <tt>00</tt>..<tt>27</tt>)</td> </tr> </table> </td> @@ -1400,7 +1400,7 @@ <li>m6 bits 5..3: random triggers (NewGRF)</li> <li>m6 bit 2: bit 8 of type (see m5)</li> <li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li> - <li>m7: random bits (NewGRF)</li> + <li>m7: animation frame</li> </ul> </td> </tr> diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html index 42450cb08..226b999bf 100644 --- a/docs/landscape_grid.html +++ b/docs/landscape_grid.html @@ -159,7 +159,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> <td class="bits">XXXX XXXX XXXX XXXX</td> - <td class="bits">XXX<span class="option">~ ~~</span>XX</td> + <td class="bits">XX<span class="free">O</span><span class="option">~ ~~</span>XX</td> <td class="bits">XXXX XXXX</td> <td class="bits">XXX<span class="abuse">X XXXX</span></td> <td class="bits"><span class="abuse">XXXX XX</span>XX</td> @@ -293,8 +293,7 @@ the array so you can quickly see what is used and what is not. <td>8</td> <td class="caption">industry</td> <td class="bits">XXXX XXXX</td> - <td class="bits">XXX<span class="free">O</span> <span class="abuse"> - XXXX</span></td> + <td class="bits">XXX<span class="free">O</span> <span class="abuse">XXXX</span></td> <td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td> @@ -331,11 +330,11 @@ the array so you can quickly see what is used and what is not. <td class="bits">XXXX XXXX</td> <td class="bits"><span class="free">O</span>XXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td> - <td class="bits">XXXX XXXX</td> + <td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XXXX XXXX</td> <td class="bits">XX<span class="free">OO OO</span>XX</td> - <td class="bits"><span class="free">OOOO OOOO</span></td> + <td class="bits">XXXX XXXX</td> </tr> </tbody> </table> diff --git a/src/industry_map.h b/src/industry_map.h index 8888de808..5cf335be0 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -236,7 +236,7 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count) static inline byte GetIndustryAnimationState(TileIndex tile) { assert(IsTileType(tile, MP_INDUSTRY)); - return _m[tile].m3; + return _me[tile].m7; } /** @@ -248,7 +248,7 @@ static inline byte GetIndustryAnimationState(TileIndex tile) static inline void SetIndustryAnimationState(TileIndex tile, byte state) { assert(IsTileType(tile, MP_INDUSTRY)); - _m[tile].m3 = state; + _me[tile].m7 = state; } /** @@ -261,7 +261,7 @@ static inline void SetIndustryAnimationState(TileIndex tile, byte state) static inline byte GetIndustryRandomBits(TileIndex tile) { assert(IsTileType(tile, MP_INDUSTRY)); - return _me[tile].m7; + return _m[tile].m3; } /** @@ -274,7 +274,7 @@ static inline byte GetIndustryRandomBits(TileIndex tile) static inline void SetIndustryRandomBits(TileIndex tile, byte bits) { assert(IsTileType(tile, MP_INDUSTRY)); - _me[tile].m7 = bits; + _m[tile].m3 = bits; } /** @@ -317,12 +317,12 @@ static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, SetTileType(t, MP_INDUSTRY); _m[t].m1 = 0; _m[t].m2 = index; - _m[t].m3 = 0; + SetIndustryRandomBits(t, random); // m3 _m[t].m4 = 0; SetIndustryGfx(t, gfx); // m5, part of m6 SetIndustryTriggers(t, 0); // rest of m6 - SetIndustryRandomBits(t, random); // m7 SetWaterClass(t, wc); + _me[t].m7 = 0; } #endif /* INDUSTRY_MAP_H */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index c10e40638..442b6560b 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1684,7 +1684,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt } case 0x16: // Periodic refresh multiplier - housespec->processing_time = buf->ReadByte(); + housespec->processing_time = min(buf->ReadByte(), 63); break; case 0x17: // Four random colours to use diff --git a/src/object_map.h b/src/object_map.h index d26279f88..bf6e33858 100644 --- a/src/object_map.h +++ b/src/object_map.h @@ -115,7 +115,7 @@ static inline bool IsStatueTile(TileIndex t) static inline byte GetObjectAnimationStage(TileIndex t) { assert(IsTileType(t, MP_OBJECT)); - return _m[t].m3; + return _me[t].m7; } /** @@ -127,7 +127,7 @@ static inline byte GetObjectAnimationStage(TileIndex t) static inline void SetObjectAnimationStage(TileIndex t, uint8 stage) { assert(IsTileType(t, MP_OBJECT)); - _m[t].m3 = stage; + _me[t].m7 = stage; } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 17b356aae..23b7aebfd 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1283,19 +1283,19 @@ bool AfterLoadGame() if (IsTileType(t, MP_INDUSTRY)) { switch (GetIndustryGfx(t)) { case GFX_POWERPLANT_SPARKS: - SetIndustryAnimationState(t, GB(_m[t].m1, 2, 5)); + _m[t].m3 = GB(_m[t].m1, 2, 5); break; case GFX_OILWELL_ANIMATED_1: case GFX_OILWELL_ANIMATED_2: case GFX_OILWELL_ANIMATED_3: - SetIndustryAnimationState(t, GB(_m[t].m1, 0, 2)); + _m[t].m3 = GB(_m[t].m1, 0, 2); break; case GFX_COAL_MINE_TOWER_ANIMATED: case GFX_COPPER_MINE_TOWER_ANIMATED: case GFX_GOLD_MINE_TOWER_ANIMATED: - SetIndustryAnimationState(t, _m[t].m1); + _m[t].m3 = _m[t].m1; break; default: // No animation states to change @@ -1684,7 +1684,8 @@ bool AfterLoadGame() /* Increase HouseAnimationFrame from 5 to 7 bits */ for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) { - SetHouseAnimationFrame(t, GB(_m[t].m6, 3, 5)); + SB(_m[t].m6, 2, 6, GB(_m[t].m6, 3, 5)); + SB(_m[t].m3, 5, 1, 0); } } } @@ -2249,6 +2250,38 @@ bool AfterLoadGame() } } + /* Move the animation frame to the same location (m7) for all objects. */ + if (CheckSavegameVersion(147)) { + for (TileIndex t = 0; t < map_size; t++) { + switch (GetTileType(t)) { + case MP_HOUSE: + if (GetHouseType(t) >= NEW_HOUSE_OFFSET) { + uint per_proc = _me[t].m7; + _me[t].m7 = GB(_m[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6); + SB(_m[t].m3, 5, 1, 0); + SB(_m[t].m6, 2, 6, min(per_proc, 63)); + } + break; + + case MP_INDUSTRY: { + uint rand = _me[t].m7; + _me[t].m7 = _m[t].m3; + _m[t].m3 = rand; + break; + } + + case MP_OBJECT: + _me[t].m7 = _m[t].m3; + _m[t].m3 = 0; + break; + + default: + /* For stations/airports it's already at m7 */ + break; + } + } + } + /* Road stops is 'only' updating some caches */ AfterLoadRoadStops(); AfterLoadLabelMaps(); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 935ebe61d..cd5ae3329 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -210,8 +210,9 @@ * 144 20334 * 145 20376 * 146 20446 + * 147 20621 */ -extern const uint16 SAVEGAME_VERSION = 146; ///< current savegame version of OpenTTD +extern const uint16 SAVEGAME_VERSION = 147; ///< current savegame version of OpenTTD SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/town_map.h b/src/town_map.h index c7bd2f527..41f1e96e4 100644 --- a/src/town_map.h +++ b/src/town_map.h @@ -148,7 +148,7 @@ static inline void SetLiftPosition(TileIndex t, byte pos) static inline byte GetHouseAnimationFrame(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); - return GB(_m[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6); + return _me[t].m7; } /** @@ -160,8 +160,7 @@ static inline byte GetHouseAnimationFrame(TileIndex t) static inline void SetHouseAnimationFrame(TileIndex t, byte frame) { assert(IsTileType(t, MP_HOUSE)); - SB(_m[t].m6, 2, 6, GB(frame, 0, 6)); - SB(_m[t].m3, 5, 1, GB(frame, 6, 1)); + _me[t].m7 = frame; } /** @@ -187,31 +186,6 @@ static inline void SetHouseCompleted(TileIndex t, bool status) } /** - * Make the tile a house. - * @param t tile index - * @param tid Town index - * @param counter of construction step - * @param stage of construction (used for drawing) - * @param type of house. Index into house specs array - * @param random_bits required for newgrf houses - * @pre IsTileType(t, MP_CLEAR) - */ -static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits) -{ - assert(IsTileType(t, MP_CLEAR)); - - SetTileType(t, MP_HOUSE); - _m[t].m1 = random_bits; - _m[t].m2 = tid; - _m[t].m3 = 0; - SetHouseType(t, type); - SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED); - _m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter); - SetHouseAnimationFrame(t, 0); - _me[t].m7 = HouseSpec::Get(type)->processing_time; -} - -/** * House Construction Scheme. * Construction counter, for buildings under construction. Incremented on every * periodic tile processing. @@ -365,7 +339,7 @@ static inline byte GetHouseTriggers(TileIndex t) static inline byte GetHouseProcessingTime(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); - return _me[t].m7; + return GB(_m[t].m6, 2, 6); } /** @@ -377,7 +351,7 @@ static inline byte GetHouseProcessingTime(TileIndex t) static inline void SetHouseProcessingTime(TileIndex t, byte time) { assert(IsTileType(t, MP_HOUSE)); - _me[t].m7 = time; + SB(_m[t].m6, 2, 6, time); } /** @@ -388,7 +362,32 @@ static inline void SetHouseProcessingTime(TileIndex t, byte time) static inline void DecHouseProcessingTime(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); - _me[t].m7--; + _m[t].m6 -= 1 << 2; +} + +/** + * Make the tile a house. + * @param t tile index + * @param tid Town index + * @param counter of construction step + * @param stage of construction (used for drawing) + * @param type of house. Index into house specs array + * @param random_bits required for newgrf houses + * @pre IsTileType(t, MP_CLEAR) + */ +static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits) +{ + assert(IsTileType(t, MP_CLEAR)); + + SetTileType(t, MP_HOUSE); + _m[t].m1 = random_bits; + _m[t].m2 = tid; + _m[t].m3 = 0; + SetHouseType(t, type); + SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED); + _m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter); + SetHouseAnimationFrame(t, 0); + SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time); } #endif /* TOWN_MAP_H */ |