Files
Project-Reboot-3.0/Project Reboot 3.0/NameTypes.h
Milxnor a2d621560a level
level showing up on items now, fix s19, improve performance, fix big issue on s5
2023-05-21 00:38:59 -04:00

75 lines
1.8 KiB
C++

#pragma once
#include "inc.h"
struct FNameEntryId
{
uint32 Value;
FNameEntryId() : Value(0) {}
FNameEntryId(uint32 value) : Value(value) {}
bool operator<(FNameEntryId Rhs) const { return Value < Rhs.Value; }
bool operator>(FNameEntryId Rhs) const { return Rhs.Value < Value; }
bool operator==(FNameEntryId Rhs) const { return Value == Rhs.Value; }
bool operator!=(FNameEntryId Rhs) const { return Value != Rhs.Value; }
};
#define WITH_CASE_PRESERVING_NAME 1 // ??
struct FName
{
FNameEntryId ComparisonIndex;
uint32 Number;
FORCEINLINE int32 GetNumber() const
{
return Number;
}
FORCEINLINE FNameEntryId GetComparisonIndexFast() const
{
return ComparisonIndex;
}
std::string ToString() const;
std::string ToString();
FName() : ComparisonIndex(0), Number(0) {}
FName(uint32 Value) : ComparisonIndex(Value), Number(0) {}
bool IsValid() { return ComparisonIndex.Value > 0; } // for real
FORCEINLINE bool operator==(const FName& Other) const // HMM??
{
#if WITH_CASE_PRESERVING_NAME
return GetComparisonIndexFast() == Other.GetComparisonIndexFast() && GetNumber() == Other.GetNumber();
#else
// static_assert(sizeof(CompositeComparisonValue) == sizeof(*this), "ComparisonValue does not cover the entire FName state");
// return CompositeComparisonValue == Other.CompositeComparisonValue;
#endif
}
int32 Compare(const FName& Other) const;
/* FORCEINLINE bool operator<(const FName& Other) const
{
return Compare(Other) < 0;
} */
FORCEINLINE bool operator<(const FName& Other) const
{
return GetComparisonIndexFast() < Other.GetComparisonIndexFast();
// (Milxnor) BRO IDK
if (GetComparisonIndexFast() == Other.GetComparisonIndexFast())
{
return GetNumber() - Other.GetNumber();
}
return GetComparisonIndexFast() < Other.GetComparisonIndexFast();
}
};