H-uru / Plasma

Cyan Worlds's Plasma game engine
http://h-uru.github.io/Plasma/
GNU General Public License v3.0
202 stars 80 forks source link

Fix ordering operators for `plKey` #1505

Closed dgelessus closed 9 months ago

dgelessus commented 9 months ago

Fixes #1479.

This was broken by #1429 (4ef380f10fef7523761c73bc4cb2aeec68fac6fd). Previously, plKey's ordering operators were provided by the implicit conversion to plKeyImp*, meaning that plKeys were ordered by their fKeyData pointers. When this was replaced by the conversion to bool, the ordering operators unintentionally also changed - plKeys were now ordered only by their bool value, so all non-null plKeys were converted to the same value (true) and had no ordering relative to each other! This made anything that uses the ordering operators misbehave, such as stdlib containers like std::set.

This change adds explicit plKey ordering operators that match the previous behavior.

Also includes another change I made during debugging, which makes a few plKey/plKeyData*/plKeyImp* conversions more straightforward. That turned out to be irrelevant for the fix, but it makes the code cleaner, so I left it in.