|
@@ -577,31 +577,30 @@ int32 CmdBuildTrainDepot(TileIndex tile,
|
|
|
int32 cost, ret;
|
|
|
Slope tileh;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
|
|
|
|
|
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
|
|
/* check railtype and valid direction for depot (0 through 3), 4 in total */
|
|
|
if (!ValParamRailtype(p1) || p2 > 3) return CMD_ERROR;
|
|
|
|
|
|
tileh = GetTileSlope(tile, NULL);
|
|
|
|
|
|
/* Prohibit construction if
|
|
|
The tile is non-flat AND
|
|
|
1) The AI is "old-school"
|
|
|
2) build-on-slopes is disabled
|
|
|
3) the tile is steep i.e. spans two height levels
|
|
|
4) the exit points in the wrong direction
|
|
|
|
|
|
*/
|
|
|
* The tile is non-flat AND
|
|
|
* 1) The AI is "old-school"
|
|
|
* 2) build-on-slopes is disabled
|
|
|
* 3) the tile is steep i.e. spans two height levels
|
|
|
* 4) the exit points in the wrong direction
|
|
|
*/
|
|
|
|
|
|
if (tileh != SLOPE_FLAT && (
|
|
|
_is_old_ai_player ||
|
|
|
!_patches.build_on_slopes ||
|
|
|
IsSteepSlope(tileh) ||
|
|
|
!CanBuildDepotByTileh(p2, tileh)
|
|
|
)) {
|
|
|
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
|
|
}
|
|
|
|
|
|
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
if (CmdFailed(ret)) return CMD_ERROR;
|
|
@@ -744,49 +743,49 @@ static int32 CmdSignalTrackHelper(TileIn
|
|
|
byte semaphores = (HASBIT(p2, 3) ? 8 : 0);
|
|
|
byte signal_density = (p2 >> 24);
|
|
|
|
|
|
if (p1 >= MapSize()) return CMD_ERROR;
|
|
|
end_tile = p1;
|
|
|
if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
|
|
|
|
|
|
if (!IsTileType(tile, MP_RAILWAY)) return CMD_ERROR;
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
|
|
|
|
|
/* for vertical/horizontal tracks, double the given signals density
|
|
|
* since the original amount will be too dense (shorter tracks) */
|
|
|
* since the original amount will be too dense (shorter tracks) */
|
|
|
if (!IsDiagonalTrack(track)) signal_density *= 2;
|
|
|
|
|
|
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
|
|
|
|
|
track = TrackdirToTrack(trackdir); /* trackdir might have changed, keep track in sync */
|
|
|
|
|
|
// copy the signal-style of the first rail-piece if existing
|
|
|
if (HasSignals(tile)) {
|
|
|
signals = _m[tile].m3 & SignalOnTrack(track);
|
|
|
if (signals == 0) signals = SignalOnTrack(track); /* Can this actually occur? */
|
|
|
|
|
|
// copy signal/semaphores style (independent of CTRL)
|
|
|
semaphores = (GetSignalVariant(tile) == SIG_ELECTRIC ? 0 : 8);
|
|
|
} else { // no signals exist, drag a two-way signal stretch
|
|
|
signals = SignalOnTrack(track);
|
|
|
}
|
|
|
|
|
|
/* signal_ctr - amount of tiles already processed
|
|
|
* signals_density - patch setting to put signal on every Nth tile (double space on |, -- tracks)
|
|
|
**********
|
|
|
* trackdir - trackdir to build with autorail
|
|
|
* semaphores - semaphores or signals
|
|
|
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way)
|
|
|
and convert all others to semaphore/signal
|
|
|
* and convert all others to semaphore/signal
|
|
|
* mode - 1 remove signals, 0 build signals */
|
|
|
signal_ctr = total_cost = 0;
|
|
|
for (;;) {
|
|
|
// only build/remove signals with the specified density
|
|
|
if (signal_ctr % signal_density == 0) {
|
|
|
ret = DoCommand(tile, TrackdirToTrack(trackdir) | semaphores, signals, flags, (mode == 1) ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
|
|
|
|
|
|
/* Abort placement for any other error than NOT_SUITABLE_TRACK
|
|
|
* This includes vehicles on track, competitor's tracks, etc. */
|
|
|
if (CmdFailed(ret)) {
|
|
|
if (_error_message != STR_1005_NO_SUITABLE_RAILROAD_TRACK && mode != 1) return CMD_ERROR;
|
|
|
_error_message = INVALID_STRING_ID;
|