summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-11 14:14:06 +0000
committerrubidium <rubidium@openttd.org>2010-08-11 14:14:06 +0000
commitab5b0ceff219a2b12253dbd3e008cf4551608b8a (patch)
tree015b80c7c79cf97a7de8a1f8d1d82f4577895ea1
parent43d6740f2d68af2223796eb2324086be18487b88 (diff)
downloadopenttd-ab5b0ceff219a2b12253dbd3e008cf4551608b8a.tar.xz
(svn r20446) -Codechange: unify the location of the water class
-rw-r--r--docs/landscape.html27
-rw-r--r--docs/landscape_grid.html30
-rw-r--r--src/clear_map.h2
-rw-r--r--src/object_cmd.cpp2
-rw-r--r--src/object_map.h5
-rw-r--r--src/saveload/afterload.cpp41
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/station_map.h14
-rw-r--r--src/tile_map.h4
-rw-r--r--src/water_map.h22
10 files changed, 91 insertions, 59 deletions
diff --git a/docs/landscape.html b/docs/landscape.html
index 044ee7b6c..0a712df09 100644
--- a/docs/landscape.html
+++ b/docs/landscape.html
@@ -52,7 +52,7 @@
<a href="landscape_grid.html">Landscape grid</a> page.
</p>
- The <a name="OwnershipInfo">owner of a tile</a>, as frequently associated with attribute m1,
+ The <a name="OwnershipInfo">owner of a tile</a>, as frequently associated with attribute m1 bits 4..0,
can be either companies (human or AI) or "Game entities".
They are identified using:
<table border="1">
@@ -78,7 +78,7 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the tile (normally <tt>10</tt>)</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the tile (normally <tt>10</tt>)</li>
<li>m2: see fields</li>
<li>m3 bits 3..0: see fields</li>
<li>m3 bit 4: set if the tile is covered with snow</li>
@@ -183,7 +183,7 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the tile</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the tile</li>
<li>m2: see signals</li>
<li>m3 bits 7..4: see signals</li>
<li>m3 bits 3..0 = <a name="TrackType">track type</a>:
@@ -548,7 +548,7 @@
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of road type 1 (tram); OWNER_NONE (<tt>10</tt>) is stored as OWNER_TOWN (<tt>0F</tt>)
<li>m5 bit 6 clear: road
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
<li>m7 bits 3..0: counter for the roadworks</li>
<li>m5 bits 3..0: road layout road type 0 (normal road): bit set = road piece present:
<table>
@@ -587,7 +587,7 @@
</li>
<li>m5 bit 6 set: level crossing
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the railway track</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the railway track</li>
<li>m3 bits 3..0: <a href="#TrackType">railway track type</a></li>
<li>m5 bit 0: direction
<table>
@@ -610,7 +610,7 @@
</li>
<li>m5 bit 7 set, bit 6 clear: road depot
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the depot</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the depot</li>
<li>m2: Depot index</li>
<li>m5 bits 3..0: exit towards:
<table>
@@ -723,7 +723,7 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
<li>m2 bits 8..6: ground
<table>
@@ -822,12 +822,12 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the station</li>
+ <li>m1 bits 6..5: water class for buoys, water part of docks and for airport tiles</li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the station</li>
<li>m2: index into the array of stations</li>
<li>m3 bits 7..4: persistent random data for railway stations/waypoints and airports)</li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of tram tracks (road stop)</li>
<li>m3 bits 3..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
- <li>m3 bits 1..0: water class for buoys, water part of docks and for airport tiles</li>
<li>m4: custom station id; 0 means standard graphics</li>
<li>m5: graphics index (range from 0..255 for each station type):
<table>
@@ -959,9 +959,9 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> (for sea, rivers, and coasts normally <tt>11</tt>)</li>
+ <li>m1 bits 6..5 : Water class (sea, canal or river)
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> (for sea, rivers, and coasts normally <tt>11</tt>)</li>
<li>m2: Depot index (for depots only)</li>
- <li>m3 bits 1..0 : Water class (sea, canal or river)
<li>m4: Random data for canal or river tiles</li>
<li>m5: tile type:
<table>
@@ -1413,7 +1413,7 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a></li>
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a></li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of tram</li>
<li>m3 bits 3..0: <a href="#TrackType">track type</a> for railway</li>
<li>m5 bit 4: pbs reservation state for railway</li>
@@ -1566,7 +1566,8 @@
<td valign=top nowrap>&nbsp;</td>
<td>
<ul>
- <li>m1: <a href="#OwnershipInfo">owner</a> of the object (for lighthouses and transmitters normally <tt>10</tt>)</li>
+ <li>m1 bits 6..5 : Water class (sea, canal, river or land)
+ <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the object (for lighthouses and transmitters normally <tt>10</tt>)</li>
<li>m2: see company statue
<li>m3: offset to northern most tile
<li>m5: tile type:
diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html
index 9a52f3869..4f25af277 100644
--- a/docs/landscape_grid.html
+++ b/docs/landscape_grid.html
@@ -66,7 +66,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan="2">0</td>
<td class="caption">ground</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~~ ~~~~</span></td>
+ <td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits"><span class="free">OOO</span>X <span class="free">OOOO</span></td>
<td class="bits">XXXX XX<span class="free">OO</span></td>
@@ -77,7 +77,7 @@ the array so you can quickly see what is used and what is not.
<tr>
<td class="caption">farmland</td>
<td class="bits">-inherit-</td>
- <td class="bits"><span class="option">~~~~ ~~~~</span></td>
+ <td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits">-inherit-</td>
@@ -89,7 +89,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan=3>1</td>
<td class="caption">rail</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X XXXX</td>
+ <td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX <span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX</td>
@@ -123,7 +123,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan=3>2</td>
<td class="caption">road</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X XXXX</td>
+ <td class="bits"><span class="free">OOO</span>X 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>
@@ -169,7 +169,7 @@ the array so you can quickly see what is used and what is not.
<td>4</td>
<td class="caption">trees</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~~ ~~~~</span></td>
+ <td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td>
<td class="bits"><span class="free">OOOO OOO</span>X XXXX XXXX</td>
<td class="bits"><span class="option">~~</span>XX XXXX</td>
<td class="bits">XXXX XX<span class="free">OO</span></td>
@@ -181,7 +181,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan=7>5</td>
<td class="caption">rail station</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X 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">XXXX XXXX</td>
@@ -216,7 +216,7 @@ 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"><span class="free">OOOO OO</span>XX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~</span>XXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
@@ -227,7 +227,7 @@ 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">XXXX <span class="free">OO</span>XX</td>
+ <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
@@ -238,7 +238,7 @@ 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"><span class="free">OOOO OO</span>XX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~~~~</span></td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
@@ -259,9 +259,9 @@ the array so you can quickly see what is used and what is not.
<td rowspan=3>6</td>
<td class="caption">sea, shore</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X XXXX</td>
+ <td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
- <td class="bits"><span class="free">OOOO OO</span>XX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">X<span class="option">~~</span>X XXXX</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
@@ -272,7 +272,7 @@ 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"><span class="free">OOOO OOOO OOOO OOOO</span></td>
- <td class="bits"><span class="free">OOOO OO</span>XX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
@@ -283,7 +283,7 @@ 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">XXXX XXXX XXXX XXXX</td>
- <td class="bits"><span class="free">OOOO OO</span>XX</td>
+ <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">-inherit-</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
@@ -306,7 +306,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan=2>9</td>
<td class="caption">tunnel entrance</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X XXXX</td>
+ <td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
@@ -329,7 +329,7 @@ the array so you can quickly see what is used and what is not.
<td rowspan=2>A</td>
<td class="caption">objects</td>
<td class="bits">XXXX XXXX</td>
- <td class="bits"><span class="option">~~~</span>X XXXX</td>
+ <td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
diff --git a/src/clear_map.h b/src/clear_map.h
index 881e94a6e..89a444f73 100644
--- a/src/clear_map.h
+++ b/src/clear_map.h
@@ -277,6 +277,7 @@ static inline void MakeClear(TileIndex t, ClearGround g, uint density)
if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0);
SetTileType(t, MP_CLEAR);
+ _m[t].m1 = 0;
SetTileOwner(t, OWNER_NONE);
_m[t].m2 = 0;
_m[t].m3 = 0;
@@ -296,6 +297,7 @@ static inline void MakeClear(TileIndex t, ClearGround g, uint density)
static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
{
SetTileType(t, MP_CLEAR);
+ _m[t].m1 = 0;
SetTileOwner(t, OWNER_NONE);
_m[t].m2 = industry;
_m[t].m3 = field_type;
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 8a97ba310..4457b8459 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -53,7 +53,7 @@ void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, uint index)
TileArea ta(tile, GB(spec->size, 0, 4), GB(spec->size, 4, 4));
TILE_AREA_LOOP(t, ta) {
TileIndex offset = t - tile;
- MakeObject(t, type, owner, TileY(offset) << 4 | TileX(offset), index);
+ MakeObject(t, type, owner, TileY(offset) << 4 | TileX(offset), index, WATER_CLASS_INVALID);
MarkTileDirtyByTile(t);
}
}
diff --git a/src/object_map.h b/src/object_map.h
index f22331640..0f4de9915 100644
--- a/src/object_map.h
+++ b/src/object_map.h
@@ -13,6 +13,7 @@
#define OBJECT_MAP_H
#include "tile_map.h"
+#include "water_map.h"
#include "object_type.h"
/**
@@ -162,11 +163,13 @@ static inline void SetObjectOffset(TileIndex t, uint8 offset)
* @param o The new owner of the tile.
* @param offset The offset to the northern tile of this object.
* @param index Generic index associated with the object type.
+ * @param wc Water class for this obect.
*/
-static inline void MakeObject(TileIndex t, ObjectType u, Owner o, uint8 offset, uint index)
+static inline void MakeObject(TileIndex t, ObjectType u, Owner o, uint8 offset, uint index, WaterClass wc)
{
SetTileType(t, MP_OBJECT);
SetTileOwner(t, o);
+ SetWaterClass(t, wc);
_m[t].m2 = index;
_m[t].m3 = offset;
_m[t].m4 = 0;
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index ce2ef047b..12cbf2e3e 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1543,6 +1543,41 @@ bool AfterLoadGame()
}
}
+ /* The water class was moved/unified. */
+ if (CheckSavegameVersion(146)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ switch (GetTileType(t)) {
+ case MP_STATION:
+ switch (GetStationType(t)) {
+ case STATION_OILRIG:
+ case STATION_DOCK:
+ case STATION_BUOY:
+ SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
+ SB(_m[t].m3, 0, 2, 0);
+ break;
+
+ default:
+ SetWaterClass(t, WATER_CLASS_INVALID);
+ break;
+ }
+ break;
+
+ case MP_WATER:
+ SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
+ SB(_m[t].m3, 0, 2, 0);
+ break;
+
+ case MP_OBJECT:
+ SetWaterClass(t, WATER_CLASS_INVALID);
+ break;
+
+ default:
+ /* No water class. */
+ break;
+ }
+ }
+ }
+
if (CheckSavegameVersion(86)) {
for (TileIndex t = 0; t < map_size; t++) {
/* Move river flag and update canals to use water class */
@@ -2153,12 +2188,6 @@ bool AfterLoadGame()
FOR_ALL_DEPOTS(d) d->build_date = _date;
}
- if (CheckSavegameVersion(145)) {
- for (TileIndex t = 0; t < map_size; t++) {
- if (IsAirportTile(t)) SetWaterClass(t, WATER_CLASS_INVALID);
- }
- }
-
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 48c07b63e..7a9cd9eee 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -209,8 +209,9 @@
* 143 20048
* 144 20334
* 145 20376
+ * 146 20446
*/
-extern const uint16 SAVEGAME_VERSION = 145; ///< current savegame version of OpenTTD
+extern const uint16 SAVEGAME_VERSION = 146; ///< current savegame version of OpenTTD
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/station_map.h b/src/station_map.h
index 4fc85d94b..c641c6a33 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -553,7 +553,7 @@ static inline byte GetStationTileRandomBits(TileIndex t)
* @param st the type this station tile
* @param section the StationGfx to be used for this tile
*/
-static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section)
+static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WATER_CLASS_INVALID)
{
SetTileType(t, MP_STATION);
SetTileOwner(t, o);
@@ -644,8 +644,7 @@ static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner ro
*/
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
{
- MakeStation(t, o, sid, STATION_AIRPORT, section);
- SetWaterClass(t, wc);
+ MakeStation(t, o, sid, STATION_AIRPORT, section, wc);
}
/**
@@ -659,8 +658,7 @@ static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
/* Make the owner of the buoy tile the same as the current owner of the
* water tile. In this way, we can reset the owner of the water to its
* original state when the buoy gets removed. */
- MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0);
- SetWaterClass(t, wc);
+ MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0, wc);
}
/**
@@ -674,8 +672,7 @@ static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
{
MakeStation(t, o, sid, STATION_DOCK, d);
- MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
- SetWaterClass(t + TileOffsByDiagDir(d), wc);
+ MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
}
/**
@@ -686,8 +683,7 @@ static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d
*/
static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
{
- MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
- SetWaterClass(t, wc);
+ MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0, wc);
}
#endif /* STATION_MAP_H */
diff --git a/src/tile_map.h b/src/tile_map.h
index 202ad04e9..7310fc599 100644
--- a/src/tile_map.h
+++ b/src/tile_map.h
@@ -142,7 +142,7 @@ static inline Owner GetTileOwner(TileIndex tile)
assert(!IsTileType(tile, MP_HOUSE));
assert(!IsTileType(tile, MP_INDUSTRY));
- return (Owner)_m[tile].m1;
+ return (Owner)GB(_m[tile].m1, 0, 5);
}
/**
@@ -162,7 +162,7 @@ static inline void SetTileOwner(TileIndex tile, Owner owner)
assert(!IsTileType(tile, MP_HOUSE));
assert(!IsTileType(tile, MP_INDUSTRY));
- _m[tile].m1 = owner;
+ SB(_m[tile].m1, 0, 5, owner);
}
/**
diff --git a/src/water_map.h b/src/water_map.h
index d59e5eb74..55e2730a5 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -72,8 +72,8 @@ static inline WaterTileType GetWaterTileType(TileIndex t)
*/
static inline WaterClass GetWaterClass(TileIndex t)
{
- assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY));
- return (WaterClass)(IsTileType(t, MP_INDUSTRY) ? GB(_m[t].m1, 5, 2) : GB(_m[t].m3, 0, 2));
+ assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT));
+ return (WaterClass)GB(_m[t].m1, 5, 2);
}
/**
@@ -83,12 +83,8 @@ static inline WaterClass GetWaterClass(TileIndex t)
*/
static inline void SetWaterClass(TileIndex t, WaterClass wc)
{
- assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY));
- if (IsTileType(t, MP_INDUSTRY)) {
- SB(_m[t].m1, 5, 2, wc);
- } else {
- SB(_m[t].m3, 0, 2, wc);
- }
+ assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT));
+ SB(_m[t].m1, 5, 2, wc);
}
/**
@@ -251,6 +247,7 @@ static inline void MakeShore(TileIndex t)
{
SetTileType(t, MP_WATER);
SetTileOwner(t, OWNER_WATER);
+ SetWaterClass(t, WATER_CLASS_SEA);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
@@ -270,8 +267,9 @@ static inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8 random_b
{
SetTileType(t, MP_WATER);
SetTileOwner(t, o);
+ SetWaterClass(t, wc);
_m[t].m2 = 0;
- _m[t].m3 = wc;
+ _m[t].m3 = 0;
_m[t].m4 = random_bits;
_m[t].m5 = 0;
SB(_m[t].m6, 2, 4, 0);
@@ -322,8 +320,9 @@ static inline void MakeShipDepot(TileIndex t, Owner o, DepotID did, DepotPart ba
{
SetTileType(t, MP_WATER);
SetTileOwner(t, o);
+ SetWaterClass(t, original_water_class);
_m[t].m2 = did;
- _m[t].m3 = original_water_class;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = base + a * 2;
SB(_m[t].m6, 2, 4, 0);
@@ -342,8 +341,9 @@ static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass o
{
SetTileType(t, MP_WATER);
SetTileOwner(t, o);
+ SetWaterClass(t, original_water_class);
_m[t].m2 = 0;
- _m[t].m3 = original_water_class;
+ _m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = section;
SB(_m[t].m6, 2, 4, 0);