From b9124b049a47323cafa8807db4d501fb32a53297 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sun, 12 Oct 2025 17:38:12 -0300 Subject: fix problem with outfit comparisons - fixes #39 --- src/cr.hh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/cr.hh') diff --git a/src/cr.hh b/src/cr.hh index c4034e5..8bf6ce8 100644 --- a/src/cr.hh +++ b/src/cr.hh @@ -17,14 +17,18 @@ struct TPlayer; struct TOutfit{ int OutfitID; union{ - uint16 ObjectType; + int ObjectType; uint8 Colors[4]; - uint32 PackedData; }; constexpr bool operator==(const TOutfit &Other) const { + // IMPORTANT(fusion): We don't need to have special comparisson cases + // if all members of the union have the same size. This is not true + // otherwise when smaller active fields leave trailing bytes of the + // union filled with whatever data was there before. + STATIC_ASSERT(sizeof(this->ObjectType) == sizeof(this->Colors)); return this->OutfitID == Other.OutfitID - && this->PackedData == Other.PackedData; + && this->ObjectType == Other.ObjectType; } static constexpr TOutfit Invisible(void){ -- cgit v1.2.3