diff --git a/docs/landscape.html b/docs/landscape.html
index 6460dd1ef3..af35fb0bc6 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -669,7 +669,7 @@
m3 bit 6 : bit 8 of house type (m4), allowing 512 different types.
- m3 bit 5 : bit 6 of current animation frame (see m6)
+ m3 bit 5 : free
m3 bits 4..0 : triggers activated (newhouses)
m4 : town building type (with m3[6] bit)
m5 : see m3 bit 7
@@ -677,7 +677,7 @@
- If newhouses is activated
- - bits 7..2 : Current animation frame (bits 5..0); bit 6 in m3
+ - bits 7..2 : Periodic processing time remaining
- Standard behaviour
@@ -692,7 +692,7 @@
- If newhouses is activated
- - Periodic processing time remaining
+ - Current animation frame
- Standard behaviour (only for houses type 04 and 05)
@@ -1090,7 +1090,7 @@
- m2: index into the array of industries
- - m3: animation state
+ - m3: random bits (NewGRF)
- m4: animation loop
- m5: type (plus m6 bit 2):
(note: this is not the same as the industry type, which is stored in the array of industries)
@@ -1107,7 +1107,7 @@
01 |
wheel tower when animated
- animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
+ animation state in m7 bits 5..0; m7 bit 6 set = sound already generated
@@ -1123,7 +1123,7 @@
0A |
- transformer; animation progress in m3(valid range 0..7) |
+ transformer; animation progress in m7(valid range 0..7) |
@@ -1166,7 +1166,7 @@
1E..20 |
- various stages of animation; progress of animation in m3 |
+ various stages of animation; progress of animation in m7 |
@@ -1197,7 +1197,7 @@
30 |
- wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
+ wheel tower when animated; animation state in m7 bits 5..0; m7 bit 6 set = sound already generated |
31 |
@@ -1237,7 +1237,7 @@
58 |
- wheel tower when animated; animation state in m3 bits 5..0; m3 bit 6 set = sound already generated |
+ wheel tower when animated; animation state in m7 bits 5..0; m7 bit 6 set = sound already generated |
@@ -1332,7 +1332,7 @@
8F |
- Animated part; animation state in m3 (valid range 00..31)
+ | Animated part; animation state in m7 (valid range 00..31)
Tile animation is started (m4 zeroed) on the periodic processing.
While the animation is in progress, m4 holds the number
of animation cycles that have already taken place.
@@ -1362,7 +1362,7 @@
|
A2 |
- bubble capture facility; animation state in m3 (valid range 00..27) |
+ bubble capture facility; animation state in m7 (valid range 00..27) |
@@ -1400,7 +1400,7 @@
- m6 bits 5..3: random triggers (NewGRF)
- m6 bit 2: bit 8 of type (see m5)
- m6 bits 1..0 : Tropic zone definition
- - m7: random bits (NewGRF)
+ - m7: animation frame
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index 42450cb08b..226b999bfd 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.
XXXX XXXX |
XXXX XXXX |
XXXX XXXX XXXX XXXX |
- XXX~ ~~XX |
+ XXO~ ~~XX |
XXXX XXXX |
XXXX XXXX |
XXXX XXXX |
@@ -293,8 +293,7 @@ the array so you can quickly see what is used and what is not.
8 |
industry |
XXXX XXXX |
- XXXO
- XXXX |
+ XXXO XXXX |
XXXX XXXX XXXX XXXX |
XXXX XXXX |
XXXX XXXX |
@@ -331,11 +330,11 @@ the array so you can quickly see what is used and what is not.
XXXX XXXX |
OXXX XXXX |
XXXX XXXX XXXX XXXX |
- XXXX XXXX |
+ OOOO OOOO |
OOOO OOOO |
XXXX XXXX |
XXOO OOXX |
- OOOO OOOO |
+ XXXX XXXX |
diff --git a/src/industry_map.h b/src/industry_map.h
index 8888de808a..5cf335be0f 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 c10e406380..442b6560bd 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 d26279f880..bf6e338584 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 17b356aae2..23b7aebfdb 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 935ebe61da..cd5ae3329b 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 c7bd2f5275..41f1e96e4f 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;
}
/**
@@ -186,31 +185,6 @@ static inline void SetHouseCompleted(TileIndex t, bool status)
SB(_m[t].m3, 7, 1, !!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
@@ -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 */