(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
This commit is contained in:
@@ -418,7 +418,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
MarkTileDirtyByTile(tile);
|
||||
SetSignalsOnBothDir(tile, track);
|
||||
SetSignalsOnBothDir(tile, track, _current_player);
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
}
|
||||
|
||||
@@ -441,6 +441,10 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||
if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
|
||||
trackbit = TrackToTrackBits(track);
|
||||
|
||||
/* Need to read tile owner now because it may change when the rail is removed.
|
||||
* Also, in case of floods, _current_player != owner */
|
||||
Owner owner = GetTileOwner(tile);
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_ROAD: {
|
||||
if (!IsLevelCrossing(tile) ||
|
||||
@@ -498,12 +502,12 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||
* are removing one of these pieces, we'll need to update signals for
|
||||
* both directions explicitly, as after the track is removed it won't
|
||||
* 'connect' with the other piece. */
|
||||
SetSignalsOnBothDir(tile, TRACK_X);
|
||||
SetSignalsOnBothDir(tile, TRACK_Y);
|
||||
SetSignalsOnBothDir(tile, TRACK_X, owner);
|
||||
SetSignalsOnBothDir(tile, TRACK_Y, owner);
|
||||
YapfNotifyTrackLayoutChange(tile, TRACK_X);
|
||||
YapfNotifyTrackLayoutChange(tile, TRACK_Y);
|
||||
} else {
|
||||
SetSignalsOnBothDir(tile, track);
|
||||
SetSignalsOnBothDir(tile, track, owner);
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
}
|
||||
}
|
||||
@@ -741,7 +745,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
||||
|
||||
d->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
|
||||
|
||||
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR);
|
||||
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, _current_player);
|
||||
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
|
||||
d_auto_delete.Detach();
|
||||
}
|
||||
@@ -867,7 +871,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||
}
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
SetSignalsOnBothDir(tile, track);
|
||||
SetSignalsOnBothDir(tile, track, _current_player);
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
}
|
||||
|
||||
@@ -1098,7 +1102,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint3
|
||||
SetSignalVariant(tile, INVALID_TRACK, SIG_ELECTRIC); // remove any possible semaphores
|
||||
}
|
||||
|
||||
SetSignalsOnBothDir(tile, track);
|
||||
SetSignalsOnBothDir(tile, track, GetTileOwner(tile));
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
@@ -1304,11 +1308,13 @@ static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
|
||||
return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
/* read variables before the depot is removed */
|
||||
DiagDirection dir = GetRailDepotDirection(tile);
|
||||
Owner owner = GetTileOwner(tile);
|
||||
|
||||
DoClearSquare(tile);
|
||||
delete GetDepotByTile(tile);
|
||||
UpdateSignalsOnSegment(tile, dir);
|
||||
UpdateSignalsOnSegment(tile, dir, owner);
|
||||
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir)));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user