summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/industry_map.h12
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/object_map.h4
-rw-r--r--src/saveload/afterload.cpp41
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/town_map.h61
6 files changed, 78 insertions, 45 deletions
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 */