|
@@ -828,56 +828,65 @@ int32 CmdRemoveSingleSignal(TileIndex ti
|
|
|
SetHasSignals(tile, false);
|
|
|
SetSignalVariant(tile, SIG_ELECTRIC); // remove any possible semaphores
|
|
|
}
|
|
|
|
|
|
SetSignalsOnBothDir(tile, track);
|
|
|
YapfNotifyTrackLayoutChange(tile, track);
|
|
|
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
}
|
|
|
|
|
|
return _price.remove_signals;
|
|
|
}
|
|
|
|
|
|
/** Remove signals on a stretch of track.
|
|
|
* Stub for the unified signal builder/remover
|
|
|
* @see CmdSignalTrackHelper
|
|
|
*/
|
|
|
int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
return CmdSignalTrackHelper(tile, flags, p1, SETBIT(p2, 5)); // bit 5 is remove bit
|
|
|
}
|
|
|
|
|
|
typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
|
|
|
|
|
|
/**
|
|
|
* Switches the rail type.
|
|
|
* Railtypes are stored on a per-tile basis, not on a per-track basis, so
|
|
|
* all the tracks in the given tile will be converted.
|
|
|
* @param tile The tile on which the railtype is to be convert.
|
|
|
* @param totype The railtype we want to convert to
|
|
|
* @param exec Switches between test and execute mode
|
|
|
* @return The cost and state of the operation
|
|
|
* @retval CMD_ERROR An error occured during the operation.
|
|
|
*/
|
|
|
static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
|
|
|
{
|
|
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
|
|
|
|
|
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
|
|
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
|
|
|
|
|
// tile is already of requested type?
|
|
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
|
|
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) 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;
|
|
|
|
|
|
// change type.
|
|
|
if (exec) {
|
|
|
SetRailType(tile, totype);
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
|
|
// notify YAPF about the track layout change
|
|
|
TrackBits tracks = GetTrackBits(tile);
|
|
|
while (tracks != TRACK_BIT_NONE) {
|
|
|
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
|
|
|
}
|
|
|
|
|
|
if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
|
|
|
Vehicle *v;
|
|
|
|
|
|
/* Update build vehicle window related to this depot */
|
|
|
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
|
|
|
|
|
|
/* update power of trains in this depot */
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
if (v->type == VEH_TRAIN && IsFrontEngine(v) && v->tile == tile && v->u.rail.track == 0x80) {
|