Use lower_bound instead of equal_range in StationCargoList::ShiftCargo
Calling erase could potentially invalidate the upper_bound iterator
This commit is contained in:
@@ -906,8 +906,7 @@ void StationCargoList::Append(CargoPacket *cp, StationID next)
|
|||||||
template <class Taction>
|
template <class Taction>
|
||||||
bool StationCargoList::ShiftCargo(Taction &action, StationID next)
|
bool StationCargoList::ShiftCargo(Taction &action, StationID next)
|
||||||
{
|
{
|
||||||
std::pair<Iterator, Iterator> range(this->packets.equal_range(next));
|
for (Iterator it = this->packets.lower_bound(next); it != this->packets.end() && it.GetKey() == next;) {
|
||||||
for (Iterator it(range.first); it != range.second && it.GetKey() == next;) {
|
|
||||||
if (action.MaxMove() == 0) return false;
|
if (action.MaxMove() == 0) return false;
|
||||||
CargoPacket *cp = *it;
|
CargoPacket *cp = *it;
|
||||||
if (action(cp)) {
|
if (action(cp)) {
|
||||||
|
Reference in New Issue
Block a user