equal
deleted
inserted
replaced
875 cost = CommandCost(); |
875 cost = CommandCost(); |
876 } |
876 } |
877 } |
877 } |
878 |
878 |
879 if (flags & DC_EXEC) { |
879 if (flags & DC_EXEC) { |
|
880 Vehicle *v = NULL; |
|
881 /* The new/changed signal could block our path. As this can lead to |
|
882 * stale reservations, we clear the path reservation here and try |
|
883 * to redo it later on. */ |
|
884 if (HasReservedTracks(tile, TrackToTrackBits(track))) { |
|
885 v = GetTrainForReservation(tile, track); |
|
886 if (v != NULL) FreeTrainTrackReservation(v); |
|
887 } |
|
888 |
880 if (!HasSignals(tile)) { |
889 if (!HasSignals(tile)) { |
881 /* there are no signals at all on this tile yet */ |
890 /* there are no signals at all on this tile yet */ |
882 SetHasSignals(tile, true); |
891 SetHasSignals(tile, true); |
883 SetSignalStates(tile, 0xF); // all signals are on |
892 SetSignalStates(tile, 0xF); // all signals are on |
884 SetPresentSignals(tile, 0); // no signals built by default |
893 SetPresentSignals(tile, 0); // no signals built by default |
936 SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? (uint)-1 : 0) & mask)); |
945 SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? (uint)-1 : 0) & mask)); |
937 } |
946 } |
938 MarkTileDirtyByTile(tile); |
947 MarkTileDirtyByTile(tile); |
939 AddTrackToSignalBuffer(tile, track, _current_player); |
948 AddTrackToSignalBuffer(tile, track, _current_player); |
940 YapfNotifyTrackLayoutChange(tile, track); |
949 YapfNotifyTrackLayoutChange(tile, track); |
|
950 if (v != NULL) TryPathReserve(v, true); |
941 } |
951 } |
942 |
952 |
943 return cost; |
953 return cost; |
944 } |
954 } |
945 |
955 |
1164 /* Only water can remove signals from anyone */ |
1174 /* Only water can remove signals from anyone */ |
1165 if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR; |
1175 if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR; |
1166 |
1176 |
1167 /* Do it? */ |
1177 /* Do it? */ |
1168 if (flags & DC_EXEC) { |
1178 if (flags & DC_EXEC) { |
|
1179 Vehicle *v = NULL; |
|
1180 if (HasReservedTracks(tile, TrackToTrackBits(track))) { |
|
1181 v = GetTrainForReservation(tile, track); |
|
1182 } |
1169 SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track)); |
1183 SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track)); |
1170 |
1184 |
1171 /* removed last signal from tile? */ |
1185 /* removed last signal from tile? */ |
1172 if (GetPresentSignals(tile) == 0) { |
1186 if (GetPresentSignals(tile) == 0) { |
1173 SetSignalStates(tile, 0); |
1187 SetSignalStates(tile, 0); |
1175 SetSignalVariant(tile, INVALID_TRACK, SIG_ELECTRIC); // remove any possible semaphores |
1189 SetSignalVariant(tile, INVALID_TRACK, SIG_ELECTRIC); // remove any possible semaphores |
1176 } |
1190 } |
1177 |
1191 |
1178 AddTrackToSignalBuffer(tile, track, GetTileOwner(tile)); |
1192 AddTrackToSignalBuffer(tile, track, GetTileOwner(tile)); |
1179 YapfNotifyTrackLayoutChange(tile, track); |
1193 YapfNotifyTrackLayoutChange(tile, track); |
|
1194 if (v != NULL) TryPathReserve(v, false); |
1180 |
1195 |
1181 MarkTileDirtyByTile(tile); |
1196 MarkTileDirtyByTile(tile); |
1182 } |
1197 } |
1183 |
1198 |
1184 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_signals); |
1199 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_signals); |