mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 21:33:51 +00:00
(svn r14776) -Fix (r14742): ListPositionMap relied on std::map having sorted the map, which is now done by a manual key sorter on SmallMap. This fixes engine ID list sorting.
This commit is contained in:
parent
3bf9e9e9c2
commit
5f4aef3c11
@ -96,6 +96,18 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
n->first = key;
|
||||
return n->second;
|
||||
}
|
||||
|
||||
FORCEINLINE void SortByKey()
|
||||
{
|
||||
qsort(this->Begin(), this->items, sizeof(Pair), KeySorter);
|
||||
}
|
||||
|
||||
static int CDECL KeySorter(const void *a, const void *b)
|
||||
{
|
||||
const Pair *pa = (const Pair*)a;
|
||||
const Pair *pb = (const Pair*)b;
|
||||
return pa->first - pb->first;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SMALLMAP_TYPE_HPP */
|
||||
|
@ -1114,6 +1114,9 @@ void CommitVehicleListOrderChanges()
|
||||
}
|
||||
}
|
||||
|
||||
/* std::map sorted by default, SmallMap does not */
|
||||
lptr_map.SortByKey();
|
||||
|
||||
/* Get the target position, if it exists */
|
||||
if (target_e != NULL) {
|
||||
uint16 target_position = target_e->list_position;
|
||||
|
Loading…
Reference in New Issue
Block a user