|
@@ -1834,12 +1834,14 @@ static CommandCost RemoveAirport(Station
|
|
|
*/
|
|
|
CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
|
|
|
|
|
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
|
|
|
/* allocate and initialize new station */
|
|
|
Station *st = new Station(tile);
|
|
|
if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
|
|
|
|
|
|
/* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
|
|
|
AutoPtrT<Station> st_auto_delete(st);
|
|
@@ -1856,13 +1858,13 @@ CommandCost CmdBuildBuoy(TileIndex tile,
|
|
|
* braindead.. */
|
|
|
st->had_vehicle_of_type |= HVOT_BUOY;
|
|
|
st->owner = OWNER_NONE;
|
|
|
|
|
|
st->build_date = _date;
|
|
|
|
|
|
MakeBuoy(tile, st->index);
|
|
|
MakeBuoy(tile, st->index, GetWaterClass(tile));
|
|
|
|
|
|
UpdateStationVirtCoordDirty(st);
|
|
|
UpdateStationAcceptance(st, false);
|
|
|
RebuildStationLists();
|
|
|
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
|
@@ -1914,13 +1916,13 @@ static CommandCost RemoveBuoy(Station *s
|
|
|
|
|
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
|
|
|
|
|
/* 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,
|
|
|
* remove it and flood the land (if the canal edge is at level 0) */
|
|
|
MakeWaterOrCanalDependingOnOwner(tile, GetTileOwner(tile));
|
|
|
MakeWaterKeepingClass(tile, GetTileOwner(tile));
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
|
|
UpdateStationVirtCoordDirty(st);
|
|
|
DeleteStationIfEmpty(st);
|
|
|
}
|
|
|
|
|
@@ -1948,13 +1950,13 @@ CommandCost CmdBuildDock(TileIndex tile,
|
|
|
|
|
|
DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
|
|
|
if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
direction = ReverseDiagDir(direction);
|
|
|
|
|
|
/* Docks cannot be placed on rapids */
|
|
|
if (IsRiverTile(tile)) return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
if (IsWaterTile(tile)) return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
|
|
|
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
|
|
|
|
|
|
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
|
|
|
|
|
cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
@@ -1965,12 +1967,15 @@ CommandCost CmdBuildDock(TileIndex tile,
|
|
|
if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) {
|
|
|
return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
|
}
|
|
|
|
|
|
if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
|
|
|
|
|
/* Get the water class of the water tile before it is cleared.*/
|
|
|
WaterClass wc = GetWaterClass(tile_cur);
|
|
|
|
|
|
cost = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
if (CmdFailed(cost)) return CMD_ERROR;
|
|
|
|
|
|
tile_cur += TileOffsByDiagDir(direction);
|
|
|
if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) {
|
|
|
return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
|
@@ -2022,13 +2027,13 @@ CommandCost CmdBuildDock(TileIndex tile,
|
|
|
if (flags & DC_EXEC) {
|
|
|
st->dock_tile = tile;
|
|
|
st->AddFacility(FACIL_DOCK, tile);
|
|
|
|
|
|
st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TRY);
|
|
|
|
|
|
MakeDock(tile, st->owner, st->index, direction);
|
|
|
MakeDock(tile, st->owner, st->index, direction, wc);
|
|
|
|
|
|
UpdateStationVirtCoordDirty(st);
|
|
|
UpdateStationAcceptance(st, false);
|
|
|
RebuildStationLists();
|
|
|
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
|
@@ -2047,13 +2052,13 @@ static CommandCost RemoveDock(Station *s
|
|
|
|
|
|
if (!EnsureNoVehicleOnGround(tile1)) return CMD_ERROR;
|
|
|
if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
DoClearSquare(tile1);
|
|
|
MakeWaterOrCanalDependingOnSurroundings(tile2, st->owner);
|
|
|
MakeWaterKeepingClass(tile2, st->owner);
|
|
|
|
|
|
st->rect.AfterRemoveTile(st, tile1);
|
|
|
st->rect.AfterRemoveTile(st, tile2);
|
|
|
|
|
|
MarkTileDirtyByTile(tile2);
|
|
|
|
|
@@ -2152,13 +2157,20 @@ static void DrawTile_Station(TileInfo *t
|
|
|
if (HasBit(roadtypes, ROADTYPE_TRAM)) {
|
|
|
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
|
|
|
DrawGroundSprite((HasBit(roadtypes, ROADTYPE_ROAD) ? SPR_TRAMWAY_OVERLAY : SPR_TRAMWAY_TRAM) + (axis ^ 1), PAL_NONE);
|
|
|
DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
|
|
|
}
|
|
|
|
|
|
if (IsCanalBuoyTile(ti->tile)) DrawCanalWater(ti->tile);
|
|
|
if (IsBuoy(ti->tile)) {
|
|
|
/* Draw appropriate water edges */
|
|
|
switch (GetWaterClass(ti->tile)) {
|
|
|
case WATER_CLASS_SEA: break;
|
|
|
case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, false); break;
|
|
|
case WATER_CLASS_RIVER: DrawRiverWater(ti, false); break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const DrawTileSeqStruct *dtss;
|
|
|
foreach_draw_tile_seq(dtss, t->seq) {
|
|
|
image = dtss->image;
|
|
|
if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
|
|
|
image += total_offset;
|