Add slot and counter support to programmable pre-signals
This commit is contained in:
@@ -1721,6 +1721,7 @@ bool TraceRestrictSlot::Occupy(VehicleID id, bool force)
|
||||
SetBit(Train::Get(id)->flags, VRF_HAVE_SLOT);
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, id);
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
||||
this->UpdateSignals();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1744,6 +1745,7 @@ void TraceRestrictSlot::Vacate(VehicleID id)
|
||||
{
|
||||
if (container_unordered_remove(this->occupants, id)) {
|
||||
this->DeIndex(id);
|
||||
this->UpdateSignals();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1756,6 +1758,13 @@ void TraceRestrictSlot::Clear()
|
||||
this->occupants.clear();
|
||||
}
|
||||
|
||||
void TraceRestrictSlot::UpdateSignals() {
|
||||
for (SignalReference sr : this->progsig_dependants) {
|
||||
AddTrackToSignalBuffer(sr.tile, sr.track, GetTileOwner(sr.tile));
|
||||
UpdateSignalsInBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
void TraceRestrictSlot::DeIndex(VehicleID id)
|
||||
{
|
||||
auto range = slot_vehicle_index.equal_range(id);
|
||||
@@ -1833,6 +1842,7 @@ void TraceRestrictRemoveVehicleFromAllSlots(VehicleID vehicle_id)
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
auto slot = TraceRestrictSlot::Get(it->second);
|
||||
container_unordered_remove(slot->occupants, vehicle_id);
|
||||
slot->UpdateSignals();
|
||||
}
|
||||
|
||||
const bool anything_to_erase = range.first != range.second;
|
||||
@@ -1908,6 +1918,13 @@ void TraceRestrictRemoveSlotID(TraceRestrictSlotID index)
|
||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||
InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE);
|
||||
}
|
||||
|
||||
for (SignalReference sr : TraceRestrictSlot::Get(index)->progsig_dependants) {
|
||||
if (IsProgrammableSignal(GetSignalType(sr.tile, sr.track))) {
|
||||
extern void RemoveProgramSlotDependencies(TraceRestrictSlotID slot_being_removed, SignalReference signal_to_update);
|
||||
RemoveProgramSlotDependencies(index, sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsUniqueSlotName(const char *name)
|
||||
@@ -2013,6 +2030,7 @@ CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint3
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
slot->max_occupancy = p2;
|
||||
slot->UpdateSignals();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2021,6 +2039,7 @@ CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint3
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||
InvalidateWindowClassesData(WC_SIGNAL_PROGRAM);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -2082,6 +2101,10 @@ void TraceRestrictCounter::UpdateValue(int32 new_value)
|
||||
if (new_value != this->value) {
|
||||
this->value = new_value;
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
||||
for (SignalReference sr : this->progsig_dependants) {
|
||||
AddTrackToSignalBuffer(sr.tile, sr.track, GetTileOwner(sr.tile));
|
||||
UpdateSignalsInBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2125,6 +2148,13 @@ void TraceRestrictRemoveCounterID(TraceRestrictCounterID index)
|
||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||
InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE);
|
||||
}
|
||||
|
||||
for (SignalReference sr : TraceRestrictCounter::Get(index)->progsig_dependants) {
|
||||
if (IsProgrammableSignal(GetSignalType(sr.tile, sr.track))) {
|
||||
extern void RemoveProgramCounterDependencies(TraceRestrictCounterID ctr_being_removed, SignalReference signal_to_update);
|
||||
RemoveProgramCounterDependencies(index, sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2230,6 +2260,7 @@ CommandCost CmdAlterTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, ui
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||
InvalidateWindowClassesData(WC_SIGNAL_PROGRAM);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
Reference in New Issue
Block a user