mirror of https://github.com/OpenTTD/OpenTTD
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
parent
c8add52504
commit
ea072322fa
|
@ -16,6 +16,7 @@
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "water.h"
|
||||||
|
|
||||||
static void ShowBuildDockStationPicker();
|
static void ShowBuildDockStationPicker();
|
||||||
static void ShowBuildDocksDepotPicker();
|
static void ShowBuildDocksDepotPicker();
|
||||||
|
|
|
@ -17,10 +17,6 @@ void DrawClearLandTile(const TileInfo *ti, byte set);
|
||||||
void DrawClearLandFence(const TileInfo *ti);
|
void DrawClearLandFence(const TileInfo *ti);
|
||||||
void TileLoopClearHelper(TileIndex tile);
|
void TileLoopClearHelper(TileIndex tile);
|
||||||
|
|
||||||
/* water_land.cpp */
|
|
||||||
void DrawShipDepotSprite(int x, int y, int image);
|
|
||||||
void TileLoop_Water(TileIndex tile);
|
|
||||||
|
|
||||||
/* players.cpp */
|
/* players.cpp */
|
||||||
bool CheckPlayerHasMoney(CommandCost cost);
|
bool CheckPlayerHasMoney(CommandCost cost);
|
||||||
void SubtractMoneyFromPlayer(CommandCost cost);
|
void SubtractMoneyFromPlayer(CommandCost cost);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
#include "transparency.h"
|
#include "transparency.h"
|
||||||
|
#include "water.h"
|
||||||
|
|
||||||
void ShowIndustryViewWindow(int industry);
|
void ShowIndustryViewWindow(int industry);
|
||||||
void BuildOilRig(TileIndex tile);
|
void BuildOilRig(TileIndex tile);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
#include "transparency.h"
|
#include "transparency.h"
|
||||||
|
#include "water.h"
|
||||||
|
|
||||||
const byte _track_sloped_sprites[14] = {
|
const byte _track_sloped_sprites[14] = {
|
||||||
14, 15, 22, 13,
|
14, 15, 22, 13,
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
#include "transparency.h"
|
#include "transparency.h"
|
||||||
|
#include "water.h"
|
||||||
|
|
||||||
DEFINE_OLD_POOL_GENERIC(Station, Station)
|
DEFINE_OLD_POOL_GENERIC(Station, Station)
|
||||||
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
|
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
|
||||||
|
@ -1899,12 +1900,7 @@ static CommandCost RemoveBuoy(Station *st, uint32 flags)
|
||||||
/* We have to set the water tile's state to the same state as before the
|
/* We have to set the water tile's state to the same state as before the
|
||||||
* buoy was placed. Otherwise one could plant a buoy on a canal edge,
|
* buoy was placed. Otherwise one could plant a buoy on a canal edge,
|
||||||
* remove it and flood the land (if the canal edge is at level 0) */
|
* remove it and flood the land (if the canal edge is at level 0) */
|
||||||
Owner o = GetTileOwner(tile);
|
MakeWaterOrCanalDependingOnSurroundings(tile, GetTileOwner(tile));
|
||||||
if (o == OWNER_WATER) {
|
|
||||||
MakeWater(tile);
|
|
||||||
} else {
|
|
||||||
MakeCanal(tile, o);
|
|
||||||
}
|
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
|
@ -2040,7 +2036,7 @@ static CommandCost RemoveDock(Station *st, uint32 flags)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
DoClearSquare(tile1);
|
DoClearSquare(tile1);
|
||||||
MakeWater(tile2);
|
MakeWaterOrCanalDependingOnSurroundings(tile2, st->owner);
|
||||||
|
|
||||||
st->rect.AfterRemoveTile(st, tile1);
|
st->rect.AfterRemoveTile(st, tile1);
|
||||||
st->rect.AfterRemoveTile(st, tile2);
|
st->rect.AfterRemoveTile(st, tile2);
|
||||||
|
@ -2064,9 +2060,6 @@ const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx)
|
||||||
return &_station_display_datas[st][gfx];
|
return &_station_display_datas[st][gfx];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For drawing canal edges on buoys */
|
|
||||||
extern void DrawCanalWater(TileIndex tile);
|
|
||||||
|
|
||||||
static void DrawTile_Station(TileInfo *ti)
|
static void DrawTile_Station(TileInfo *ti)
|
||||||
{
|
{
|
||||||
const DrawTileSprites *t = NULL;
|
const DrawTileSprites *t = NULL;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file water.h Functions related to water (management) */
|
||||||
|
|
||||||
|
#ifndef WATER_H
|
||||||
|
#define WATER_H
|
||||||
|
|
||||||
|
void TileLoop_Water(TileIndex tile);
|
||||||
|
void DrawShipDepotSprite(int x, int y, int image);
|
||||||
|
void DrawCanalWater(TileIndex tile);
|
||||||
|
void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o);
|
||||||
|
|
||||||
|
#endif /* WATER_H */
|
|
@ -55,6 +55,42 @@ static const SpriteID _water_shore_sprites[] = {
|
||||||
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile);
|
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile);
|
||||||
static void FloodVehicle(Vehicle *v);
|
static void FloodVehicle(Vehicle *v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a tile canal or water depending on the surroundings.
|
||||||
|
* This as for example docks and shipdepots do not store
|
||||||
|
* whether the tile used to be canal or 'normal' water.
|
||||||
|
* @param t the tile to change.
|
||||||
|
* @param o the owner of the new tile.
|
||||||
|
*/
|
||||||
|
void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o)
|
||||||
|
{
|
||||||
|
assert(GetTileSlope(t, NULL) == SLOPE_FLAT);
|
||||||
|
|
||||||
|
/* Non-sealevel -> canal */
|
||||||
|
if (TileHeight(t) != 0) {
|
||||||
|
MakeCanal(t, o);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_water = false;
|
||||||
|
bool has_canal = false;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_canal || !has_water) {
|
||||||
|
MakeCanal(t, o);
|
||||||
|
} else {
|
||||||
|
MakeWater(t);
|
||||||
|
}
|
||||||
|
MarkTileDirtyByTile(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Build a ship depot.
|
/** Build a ship depot.
|
||||||
* @param tile tile where ship depot is built
|
* @param tile tile where ship depot is built
|
||||||
* @param flags type of operation
|
* @param flags type of operation
|
||||||
|
@ -178,8 +214,8 @@ static CommandCost RemoveShiplift(TileIndex tile, uint32 flags)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
DoClearSquare(tile + delta);
|
MakeWaterOrCanalDependingOnSurroundings(tile + delta, _current_player);
|
||||||
DoClearSquare(tile - delta);
|
MakeWaterOrCanalDependingOnSurroundings(tile - delta, _current_player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost(_price.clear_water * 2);
|
return CommandCost(_price.clear_water * 2);
|
||||||
|
|
Loading…
Reference in New Issue