mirror of https://github.com/OpenTTD/OpenTTD
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
parent
c21f588a14
commit
cbb2d39860
|
@ -945,6 +945,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m4: Owner of the water</li>
|
||||
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
|
||||
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -194,8 +194,8 @@ 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">OOOO OOOO OOOO OOOO</span></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="free">OOOO OO</span>XX</td>
|
||||
<td class="bits">XXXX XXXX</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>
|
||||
</tr>
|
||||
|
|
|
@ -2203,6 +2203,20 @@ bool AfterLoadGame()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the 'previous' owner to the ship depots so we can reset it with
|
||||
* the correct values when it gets destroyed. This prevents that
|
||||
* someone can remove canals owned by somebody else and it prevents
|
||||
* making floods using the removal of ship depots.
|
||||
*/
|
||||
if (CheckSavegameVersion(83)) {
|
||||
for (TileIndex t = 0; t < map_size; t++) {
|
||||
if (IsTileType(t, MP_WATER) && IsShipDepot(t)) {
|
||||
_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckSavegameVersion(74)) {
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "strings.h"
|
||||
#include <list>
|
||||
|
||||
extern const uint16 SAVEGAME_VERSION = 82;
|
||||
extern const uint16 SAVEGAME_VERSION = 83;
|
||||
uint16 _sl_version; ///< the major savegame version identifier
|
||||
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o)
|
|||
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
|
||||
TileIndex neighbour = TileAddByDiagDir(t, dir);
|
||||
if (IsTileType(neighbour, MP_WATER)) {
|
||||
has_water |= IsSea(neighbour) || IsCoast(neighbour);
|
||||
has_canal |= IsCanal(neighbour);
|
||||
has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER);
|
||||
has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER);
|
||||
}
|
||||
}
|
||||
if (has_canal || !has_water) {
|
||||
|
@ -116,6 +116,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||
|
||||
if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
|
||||
Owner o1 = GetTileOwner(tile);
|
||||
Owner o2 = GetTileOwner(tile2);
|
||||
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
if (CmdFailed(ret)) return CMD_ERROR;
|
||||
ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
|
@ -128,8 +130,8 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||
if (flags & DC_EXEC) {
|
||||
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
|
||||
|
||||
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis);
|
||||
MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
|
||||
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, o1);
|
||||
MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, o2);
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(tile2);
|
||||
d_auto_delete.Detach();
|
||||
|
@ -138,6 +140,15 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||
return cost.AddCost(_price.build_ship_depot);
|
||||
}
|
||||
|
||||
static void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o)
|
||||
{
|
||||
if (o == OWNER_WATER) {
|
||||
MakeWater(tile);
|
||||
} else {
|
||||
MakeCanal(tile, o);
|
||||
}
|
||||
}
|
||||
|
||||
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
|
||||
{
|
||||
TileIndex tile2;
|
||||
|
@ -154,8 +165,8 @@ static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
|
|||
/* Kill the depot, which is registered at the northernmost tile. Use that one */
|
||||
delete GetDepotByTile(tile2 < tile ? tile2 : tile);
|
||||
|
||||
MakeWater(tile);
|
||||
MakeWater(tile2);
|
||||
MakeWaterOrCanalDependingOnOwner(tile, GetShipDepotWaterOwner(tile));
|
||||
MakeWaterOrCanalDependingOnOwner(tile2, GetShipDepotWaterOwner(tile2));
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(tile2);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,11 @@ static inline DiagDirection GetShipDepotDirection(TileIndex t)
|
|||
return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1));
|
||||
}
|
||||
|
||||
static inline Owner GetShipDepotWaterOwner(TileIndex t)
|
||||
{
|
||||
return (Owner)_m[t].m4;
|
||||
}
|
||||
|
||||
static inline DiagDirection GetLockDirection(TileIndex t)
|
||||
{
|
||||
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
||||
|
@ -128,13 +133,13 @@ static inline void MakeCanal(TileIndex t, Owner o)
|
|||
_m[t].m5 = 0;
|
||||
}
|
||||
|
||||
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a)
|
||||
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, Owner original_owner)
|
||||
{
|
||||
SetTileType(t, MP_WATER);
|
||||
SetTileOwner(t, o);
|
||||
_m[t].m2 = 0;
|
||||
_m[t].m3 = 0;
|
||||
_m[t].m4 = 0;
|
||||
_m[t].m4 = original_owner;
|
||||
_m[t].m5 = base + a * 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue