aboutsummaryrefslogtreecommitdiff
path: root/src/cr.hh
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-10-12 17:38:12 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-10-12 17:38:12 -0300
commitb9124b049a47323cafa8807db4d501fb32a53297 (patch)
tree0eb2778a68c5511a06632146c457ec7fee07f161 /src/cr.hh
parent60531bf63e9d93535e6d7ea5201a708392e738f6 (diff)
downloadgame-b9124b049a47323cafa8807db4d501fb32a53297.tar.gz
game-b9124b049a47323cafa8807db4d501fb32a53297.zip
fix problem with outfit comparisons - fixes #39
Diffstat (limited to 'src/cr.hh')
-rw-r--r--src/cr.hh10
1 files changed, 7 insertions, 3 deletions
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){