diff options
author | peter1138 <peter1138@openttd.org> | 2008-12-30 21:04:09 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-12-30 21:04:09 +0000 |
commit | 766bf8deaaf0eb0e79b5712027422e54c22066f7 (patch) | |
tree | 1f6c1f3657b9f105bc316a47f529d5ab2be21955 /src/core/smallmap_type.hpp | |
parent | af624ae1571b4430d4b58eef2473c138a1e00716 (diff) | |
download | openttd-766bf8deaaf0eb0e79b5712027422e54c22066f7.tar.xz |
(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.
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r-- | src/core/smallmap_type.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index 681cacdff..cc2533dd0 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -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 */ |