diff options
author | glx <glx@openttd.org> | 2019-04-12 17:55:35 +0200 |
---|---|---|
committer | glx22 <glx22@users.noreply.github.com> | 2019-04-18 21:49:34 +0200 |
commit | 25e534f3cf42a723f97d6fc08d582329e60a0186 (patch) | |
tree | bad57295db4b3a143ae9866620a1844f67ecbb83 /src/rail_cmd.cpp | |
parent | 0797de06be265da4f3bb06114cae4d8e5c830e71 (diff) | |
download | openttd-25e534f3cf42a723f97d6fc08d582329e60a0186.tar.xz |
Codechange: use std::vector for _sorted_railtypes
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r-- | src/rail_cmd.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index d8327c444..6964a5aaf 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -44,8 +44,7 @@ typedef std::vector<Train *> TrainList; RailtypeInfo _railtypes[RAILTYPE_END]; -RailType _sorted_railtypes[RAILTYPE_END]; -uint8 _sorted_railtypes_size; +std::vector<RailType> _sorted_railtypes; RailTypes _railtypes_hidden_mask; /** Enum holding the signal offset in the sprite sheet according to the side it is representing. */ @@ -130,9 +129,9 @@ void ResolveRailTypeGUISprites(RailtypeInfo *rti) * @param second The railtype to compare. * @return True iff the first should be sorted before the second. */ -static int CDECL CompareRailTypes(const RailType *first, const RailType *second) +static bool CompareRailTypes(const RailType &first, const RailType &second) { - return GetRailTypeInfo(*first)->sorting_order - GetRailTypeInfo(*second)->sorting_order; + return GetRailTypeInfo(first)->sorting_order < GetRailTypeInfo(second)->sorting_order; } /** @@ -146,13 +145,13 @@ void InitRailTypes() if (HasBit(rti->flags, RTF_HIDDEN)) SetBit(_railtypes_hidden_mask, rt); } - _sorted_railtypes_size = 0; + _sorted_railtypes.clear(); for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { if (_railtypes[rt].label != 0 && !HasBit(_railtypes_hidden_mask, rt)) { - _sorted_railtypes[_sorted_railtypes_size++] = rt; + _sorted_railtypes.push_back(rt); } } - QSortT(_sorted_railtypes, _sorted_railtypes_size, CompareRailTypes); + std::sort(_sorted_railtypes.begin(), _sorted_railtypes.end(), CompareRailTypes); } /** |