From 6bf009fae77419a9a1e249ddb711987422cf9822 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sun, 27 Aug 2023 10:21:16 +0000 Subject: [PATCH] feat(rage): add atArray (#2) Co-authored-by: maybegreat48 --- classes.cpp | 1 + rage/atArray.hpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 rage/atArray.hpp diff --git a/classes.cpp b/classes.cpp index 80072d8..a5c5201 100644 --- a/classes.cpp +++ b/classes.cpp @@ -7,6 +7,7 @@ #include "network/rlGamerInfoBase.hpp" #include "network/rlGamerInfo.hpp" #include "player/CPlayerInfo.hpp" +#include "rage/atArray.hpp" #include "rage/joaat.hpp" #include "rage/vector.hpp" #include "script/scriptHandlerNetComponent.hpp" diff --git a/rage/atArray.hpp b/rage/atArray.hpp new file mode 100644 index 0000000..9d2a80a --- /dev/null +++ b/rage/atArray.hpp @@ -0,0 +1,71 @@ +#pragma once +#include +#include +#include +#include + +namespace rage +{ +#pragma pack(push, 8) + template + class atArray + { + public: + atArray() : + m_data(nullptr), + m_size(0), + m_count(0) + { + + } + + T* begin() const + { + return &m_data[0]; + } + + T* end() const + { + return &m_data[m_size]; + } + + T* data() const + { + return m_data; + } + + std::uint16_t size() const + { + return m_size; + } + + std::uint16_t count() const + { + return m_count; + } + + T& operator[](std::uint16_t index) const + { + return m_data[index]; + } + + bool contains(T comparator) + { + for (auto iter_value : this) + { + if (iter_value == comparator) + { + return true; + } + } + return false; + } + + private: + T* m_data; + std::uint16_t m_size; + std::uint16_t m_count; + }; + static_assert(sizeof(rage::atArray) == 0x10, "rage::atArray is not properly sized"); +#pragma pack(pop) +} \ No newline at end of file