mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
FIX: TraceRestrictSlots: Fix crash when removing vehicle from slot. Invalid iterator got used. (it was no longer valid after calling erase with it)
(cherry picked from commit 3571f1bc898b9ffd8b124040882caa5357085f42) Fixes: #37
This commit is contained in:
parent
6c631c6679
commit
2f3e4044b7
@ -1462,8 +1462,11 @@ void TraceRestrictSlot::DeIndex(VehicleID id)
|
||||
auto range = slot_vehicle_index.equal_range(id);
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
if (it->second == this->index) {
|
||||
bool is_first_in_range = (it == range.first);
|
||||
|
||||
auto next = slot_vehicle_index.erase(it);
|
||||
if (it == range.first && next == range.second) {
|
||||
|
||||
if (is_first_in_range && next == range.second) {
|
||||
/* Only one item, which we've just erased, clear the vehicle flag */
|
||||
ClrBit(Train::Get(id)->flags, VRF_HAVE_SLOT);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user