summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/landscape.html4
-rw-r--r--src/saveload/afterload.cpp18
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/unmovable_cmd.cpp3
-rw-r--r--src/unmovable_map.h46
5 files changed, 44 insertions, 30 deletions
diff --git a/docs/landscape.html b/docs/landscape.html
index 75ecfa798..4eca412e5 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -1568,8 +1568,7 @@
<ul>
<li>m1: <a href="#OwnershipInfo">owner</a> of the object (for lighthouses and transmitters normally <tt>10</tt>)</li>
<li>m2: see company statue
- <li>m3 bits 4..2: size of HQ
- <li>m3 bits 1..0: section identification of the HQ
+ <li>m3: offset to northern most tile
<li>m5: tile type:
<table>
<tr>
@@ -1603,6 +1602,7 @@
</table>
</li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
+ <li>m6 bits 2..5 : Animation counter</li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul>
</td>
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 2b09adfa3..db0915c3d 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1792,13 +1792,25 @@ bool AfterLoadGame()
if (IsTileType(t, MP_UNMOVABLE) && HasBit(_m[t].m5, 7)) {
/* Move size and part identification of HQ out of the m5 attribute,
* on new locations */
- uint8 old_m5 = _m[t].m5;
+ _m[t].m3 = GB(_m[t].m5, 0, 5);
_m[t].m5 = UNMOVABLE_HQ;
- SetCompanyHQSize(t, GB(old_m5, 2, 3));
- SetCompanyHQSection(t, GB(old_m5, 0, 2));
}
}
}
+ if (CheckSavegameVersion(144)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (!IsTileType(t, MP_UNMOVABLE)) continue;
+
+ /* Reordering/generalisation of the unmovable bits. */
+ UnmovableType type = GetUnmovableType(t);
+ SetCompanyHQSize(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 2, 3) : 0);
+ SetCompanyHQSection(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 1, 1) << 4 | GB(_m[t].m3, 0, 1) : 0);
+
+ /* Make sure those bits are clear as well! */
+ _m[t].m4 = 0;
+ _me[t].m7 = 0;
+ }
+ }
if (CheckSavegameVersion(113)) {
/* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 1c69a6ce9..c57cf597b 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -207,8 +207,9 @@
* 141 19799
* 142 20003
* 143 20048
+ * 144 20334
*/
-extern const uint16 SAVEGAME_VERSION = 143; ///< current savegame version of OpenTTD
+extern const uint16 SAVEGAME_VERSION = 144; ///< current savegame version of OpenTTD
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 35bc2f9a8..41249c3ea 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -255,7 +255,8 @@ static void DrawTile_Unmovable(TileInfo *ti)
PaletteID palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
- const DrawTileSprites *t = &_unmovable_display_datas[GetCompanyHQSize(ti->tile) << 2 | GetCompanyHQSection(ti->tile)];
+ uint8 offset = GetCompanyHQSection(ti->tile);
+ const DrawTileSprites *t = &_unmovable_display_datas[GetCompanyHQSize(ti->tile) << 2 | GB(offset, 4, 1) << 1 | GB(offset, 0, 1)];
DrawGroundSprite(t->ground.sprite, palette);
if (IsInvisibilitySet(TO_STRUCTURES)) break;
diff --git a/src/unmovable_map.h b/src/unmovable_map.h
index 7725ac5cb..fd88d116a 100644
--- a/src/unmovable_map.h
+++ b/src/unmovable_map.h
@@ -108,50 +108,50 @@ static inline TownID GetStatueTownID(TileIndex t)
/**
* Get the 'stage' of the HQ.
* @param t a tile of the HQ.
- * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @pre IsTileType(t, MP_UNMOVABLE)
* @return the 'stage' of the HQ.
*/
static inline byte GetCompanyHQSize(TileIndex t)
{
- assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
- return GB(_m[t].m3, 2, 3);
+ assert(IsTileType(t, MP_UNMOVABLE));
+ return GB(_m[t].m6, 2, 4);
}
/**
* Set the 'stage' of the HQ.
* @param t a tile of the HQ.
* @param size the actual stage of the HQ
- * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @pre IsTileType(t, MP_UNMOVABLE)
*/
static inline void SetCompanyHQSize(TileIndex t, uint8 size)
{
- assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
- SB(_m[t].m3, 2, 3, size);
+ assert(IsTileType(t, MP_UNMOVABLE));
+ SB(_m[t].m6, 2, 4, size);
}
/**
* Get the 'section' of the HQ.
* The scetion is in fact which side of teh HQ the tile represent
* @param t a tile of the HQ.
- * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @pre IsTileType(t, MP_UNMOVABLE)
* @return the 'section' of the HQ.
*/
static inline byte GetCompanyHQSection(TileIndex t)
{
- assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
- return GB(_m[t].m3, 0, 2);
+ assert(IsTileType(t, MP_UNMOVABLE));
+ return _m[t].m3;
}
/**
* Set the 'section' of the HQ.
* @param t a tile of the HQ.
* @param section to be set.
- * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @pre IsTileType(t, MP_UNMOVABLE)
*/
static inline void SetCompanyHQSection(TileIndex t, uint8 section)
{
- assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
- SB(_m[t].m3, 0, 2, section);
+ assert(IsTileType(t, MP_UNMOVABLE));
+ _m[t].m3 = section;
}
/**
@@ -177,16 +177,17 @@ static inline void EnlargeCompanyHQ(TileIndex t, byte size)
/**
* Make an Unmovable tile.
* @note do not use this function directly. Use one of the other Make* functions.
- * @param t the tile to make unmovable.
- * @param u the unmovable type of the tile.
- * @param o the new owner of the tile.
+ * @param t The tile to make unmovable.
+ * @param u The unmovable type of the tile.
+ * @param o The new owner of the tile.
+ * @param offset The offset to the northern tile of this object
*/
-static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
+static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o, uint8 offset = 0)
{
SetTileType(t, MP_UNMOVABLE);
SetTileOwner(t, o);
_m[t].m2 = 0;
- _m[t].m3 = 0;
+ _m[t].m3 = offset;
_m[t].m4 = 0;
_m[t].m5 = u;
SB(_m[t].m6, 2, 4, 0);
@@ -242,8 +243,7 @@ static inline void MakeOwnedLand(TileIndex t, Owner o)
*/
static inline void MakeUnmovableHQHelper(TileIndex t, uint8 section, Owner o)
{
- MakeUnmovable(t, UNMOVABLE_HQ, o);
- SetCompanyHQSection(t, section);
+ MakeUnmovable(t, UNMOVABLE_HQ, o, section);
}
/**
@@ -253,10 +253,10 @@ static inline void MakeUnmovableHQHelper(TileIndex t, uint8 section, Owner o)
*/
static inline void MakeCompanyHQ(TileIndex t, Owner o)
{
- MakeUnmovableHQHelper(t, 0, o);
- MakeUnmovableHQHelper(t + TileDiffXY(0, 1), 1, o);
- MakeUnmovableHQHelper(t + TileDiffXY(1, 0), 2, o);
- MakeUnmovableHQHelper(t + TileDiffXY(1, 1), 3, o);
+ MakeUnmovableHQHelper(t, 0x00, o);
+ MakeUnmovableHQHelper(t + TileDiffXY(0, 1), 0x01, o);
+ MakeUnmovableHQHelper(t + TileDiffXY(1, 0), 0x10, o);
+ MakeUnmovableHQHelper(t + TileDiffXY(1, 1), 0x11, o);
}
#endif /* UNMOVABLE_MAP_H */