--- a/src/station_cmd.cpp Sun Sep 09 21:14:29 2007 +0000
+++ b/src/station_cmd.cpp Sun Sep 23 07:37:38 2007 +0000
@@ -42,6 +42,7 @@
#include "road.h"
#include "cargotype.h"
#include "strings.h"
+#include "autoslope.h"
DEFINE_OLD_POOL_GENERIC(Station, Station)
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
@@ -375,7 +376,14 @@
}
}
-// Update the station virt coords while making the modified parts dirty.
+/**
+ * Update the station virt coords while making the modified parts dirty.
+ *
+ * This function updates the virt coords and mark the modified parts as dirty
+ *
+ * @param st The station to update the virt coords
+ * @ingroup dirty
+ */
static void UpdateStationVirtCoordDirty(Station *st)
{
st->MarkDirty();
@@ -1227,22 +1235,14 @@
*/
CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
{
- const Station* st = GetStationByTile(tile);
-
- if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR;
-
- // tile is not a railroad station?
+ /* Tile is not a railroad station? */
if (!IsRailwayStation(tile)) return CMD_ERROR;
- if (GetRailType(tile) == totype) return CMD_ERROR;
-
- // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
- if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
-
if (exec) {
SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
+ VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
}
return CommandCost(_price.build_rail / 2);
@@ -2881,6 +2881,36 @@
static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
{
+ if (_patches.build_on_slopes && AutoslopeEnabled()) {
+ /* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here.
+ * TTDP does not call it.
+ */
+ if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) {
+ switch (GetStationType(tile)) {
+ case STATION_RAIL: {
+ DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile));
+ if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
+ if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
+ return _price.terraform;
+ }
+
+ case STATION_AIRPORT:
+ return _price.terraform;
+
+ case STATION_TRUCK:
+ case STATION_BUS: {
+ DiagDirection direction = GetRoadStopDir(tile);
+ if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
+ if (IsDriveThroughStopTile(tile)) {
+ if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
+ }
+ return _price.terraform;
+ }
+
+ default: break;
+ }
+ }
+ }
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}