File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ DECLARE_MESSAGE(ScreenResolutionChanged);
3535struct MessageObject
3636{
3737 IPure* Object;
38- int Prio;
38+ unsigned long Prio;
3939};
4040
4141template <class T >
@@ -44,19 +44,12 @@ class MessageRegistry
4444 bool changed, inProcess;
4545 xr_vector<MessageObject> messages;
4646
47- static int __cdecl compare (const void * e1 , const void * e2 )
48- {
49- MessageObject* p1 = (MessageObject*)e1 ;
50- MessageObject* p2 = (MessageObject*)e2 ;
51- return p2->Prio - p1->Prio ;
52- }
53-
5447public:
5548 MessageRegistry () : changed(false ), inProcess(false ) {}
5649
5750 void Clear () { messages.clear (); }
5851
59- constexpr void Add (T* object, const int priority = REG_PRIORITY_NORMAL)
52+ constexpr void Add (T* object, unsigned long priority = REG_PRIORITY_NORMAL)
6053 {
6154 Add ({ object, priority });
6255 }
@@ -117,8 +110,10 @@ class MessageRegistry
117110
118111 void Resort ()
119112 {
120- if (!messages.empty ())
121- qsort (&messages.front (), messages.size (), sizeof (MessageObject), compare);
113+ if (!messages.empty ()) {
114+ std::sort (std::begin (messages), std::end (messages),
115+ [](const auto & a, const auto & b) { return a.Prio < b.Prio ; });
116+ }
122117
123118 while (!messages.empty () && messages.back ().Prio == REG_PRIORITY_INVALID)
124119 messages.pop_back ();
You can’t perform that action at this time.
0 commit comments