mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 19:02:21 +01:00
too much stuff
fix s3, fix health + backpack bug on 1.11, change replciation, fix 7.20 & 12.61, fix backpack on >S9, probably some other stuff i forgot
This commit is contained in:
@@ -32,7 +32,173 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename InElementType> //, typename KeyFuncs, typename Allocator>
|
||||
template <typename SetType>
|
||||
class TSet
|
||||
{
|
||||
private:
|
||||
friend TSparseArray;
|
||||
|
||||
public:
|
||||
typedef TSetElement<SetType> ElementType;
|
||||
typedef TSparseArrayElementOrListLink<ElementType> ArrayElementType;
|
||||
|
||||
public:
|
||||
TSparseArray<ElementType> Elements;
|
||||
|
||||
mutable TInlineAllocator<1>::ForElementType<int> Hash;
|
||||
mutable int32 HashSize;
|
||||
|
||||
public:
|
||||
class FBaseIterator
|
||||
{
|
||||
private:
|
||||
TSet<SetType>& IteratedSet;
|
||||
TSparseArray<ElementType>::FBaseIterator ElementIt;
|
||||
|
||||
public:
|
||||
FORCEINLINE FBaseIterator(const TSet<SetType>& InSet, TSparseArray<TSetElement<SetType>>::FBaseIterator InElementIt)
|
||||
: IteratedSet(const_cast<TSet<SetType>&>(InSet))
|
||||
, ElementIt(InElementIt)
|
||||
{
|
||||
}
|
||||
|
||||
FORCEINLINE explicit operator bool() const
|
||||
{
|
||||
return (bool)ElementIt;
|
||||
}
|
||||
FORCEINLINE TSet<SetType>::FBaseIterator& operator++()
|
||||
{
|
||||
++ElementIt;
|
||||
return *this;
|
||||
}
|
||||
FORCEINLINE bool operator==(const TSet<SetType>::FBaseIterator& OtherIt) const
|
||||
{
|
||||
return ElementIt == OtherIt.ElementIt;
|
||||
}
|
||||
FORCEINLINE bool operator!=(const TSet<SetType>::FBaseIterator& OtherIt) const
|
||||
{
|
||||
return ElementIt != OtherIt.ElementIt;
|
||||
}
|
||||
FORCEINLINE TSet<SetType>::FBaseIterator& operator=(TSet<SetType>::FBaseIterator& OtherIt)
|
||||
{
|
||||
return ElementIt = OtherIt.ElementIt;
|
||||
}
|
||||
FORCEINLINE SetType& operator*()
|
||||
{
|
||||
return (*ElementIt).Value;
|
||||
}
|
||||
FORCEINLINE const SetType& operator*() const
|
||||
{
|
||||
return &((*ElementIt).Value);
|
||||
}
|
||||
FORCEINLINE SetType* operator->()
|
||||
{
|
||||
return &((*ElementIt).Value);
|
||||
}
|
||||
FORCEINLINE const SetType* operator->() const
|
||||
{
|
||||
return &(*ElementIt).Value;
|
||||
}
|
||||
FORCEINLINE const int32 GetIndex() const
|
||||
{
|
||||
return ElementIt.GetIndex();
|
||||
}
|
||||
FORCEINLINE ElementType& GetSetElement()
|
||||
{
|
||||
return *ElementIt;
|
||||
}
|
||||
FORCEINLINE const ElementType& GetSetElement() const
|
||||
{
|
||||
return *ElementIt;
|
||||
}
|
||||
FORCEINLINE bool IsElementValid() const
|
||||
{
|
||||
return ElementIt.IsElementValid();
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
FORCEINLINE TSet<SetType>::FBaseIterator begin()
|
||||
{
|
||||
return TSet<SetType>::FBaseIterator(*this, Elements.begin());
|
||||
}
|
||||
FORCEINLINE const TSet<SetType>::FBaseIterator begin() const
|
||||
{
|
||||
return TSet<SetType>::FBaseIterator(*this, Elements.begin());
|
||||
}
|
||||
FORCEINLINE TSet<SetType>::FBaseIterator end()
|
||||
{
|
||||
return TSet<SetType>::FBaseIterator(*this, Elements.end());
|
||||
}
|
||||
FORCEINLINE const TSet<SetType>::FBaseIterator end() const
|
||||
{
|
||||
return TSet<SetType>::FBaseIterator(*this, Elements.end());
|
||||
}
|
||||
|
||||
FORCEINLINE SetType& operator[](int Index)
|
||||
{
|
||||
return Elements[Index].ElementData.Value;
|
||||
}
|
||||
|
||||
FORCEINLINE int32 Num() const
|
||||
{
|
||||
return Elements.Num();
|
||||
}
|
||||
FORCEINLINE bool IsValid() const
|
||||
{
|
||||
return Elements.Data.Data != nullptr && Elements.AllocationFlags.MaxBits > 0;
|
||||
}
|
||||
FORCEINLINE TSparseArray<ElementType>& GetElements()
|
||||
{
|
||||
return Elements;
|
||||
}
|
||||
FORCEINLINE const TSparseArray<ElementType>& GetElements() const
|
||||
{
|
||||
return Elements;
|
||||
}
|
||||
FORCEINLINE const TBitArray& GetAllocationFlags() const
|
||||
{
|
||||
return Elements.GetAllocationFlags();
|
||||
}
|
||||
FORCEINLINE bool IsIndexValid(int32 IndexToCheck) const
|
||||
{
|
||||
return Elements.IsIndexValid(IndexToCheck);
|
||||
}
|
||||
FORCEINLINE const bool Contains(const SetType& ElementToLookFor) const
|
||||
{
|
||||
if (Num() <= 0)
|
||||
return false;
|
||||
|
||||
for (SetType Element : *this)
|
||||
{
|
||||
if (Element == ElementToLookFor)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
FORCEINLINE const int32 Find(const SetType& ElementToLookFor) const
|
||||
{
|
||||
for (auto It = this->begin(); It != this->end(); ++It)
|
||||
{
|
||||
if (*It == ElementToLookFor)
|
||||
{
|
||||
return It.GetIndex();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
FORCEINLINE bool Remove(const SetType& ElementToRemove)
|
||||
{
|
||||
return Elements.RemoveAt(Find(ElementToRemove));
|
||||
}
|
||||
FORCEINLINE bool Remove(int Index)
|
||||
{
|
||||
return Elements.RemoveAt(Index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* template<typename InElementType> //, typename KeyFuncs, typename Allocator>
|
||||
class TSet
|
||||
{
|
||||
public:
|
||||
@@ -43,4 +209,4 @@ public:
|
||||
|
||||
mutable TInlineAllocator<1>::ForElementType<int> Hash;
|
||||
mutable int32 HashSize;
|
||||
};
|
||||
}; */
|
||||
Reference in New Issue
Block a user