From 3c7763fcf996f53f891e40f12bbfa8115fd612a7 Mon Sep 17 00:00:00 2001 From: PliskinDev <36959936+PliskinDev@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:49:02 +0300 Subject: [PATCH] add pgBaseMetaDataType and pgBaseMetaDataDebugNameType and pgDictionary and pgDictionaryBase (#138) --- base/pgBase.hpp | 19 ++++++++++ base/pgDictionary.hpp | 87 +++++++++++++++++++++++++++++++++++++++++++ classes.cpp | 1 + 3 files changed, 107 insertions(+) create mode 100644 base/pgDictionary.hpp diff --git a/base/pgBase.hpp b/base/pgBase.hpp index 7f4593c..25dde4e 100644 --- a/base/pgBase.hpp +++ b/base/pgBase.hpp @@ -14,4 +14,23 @@ namespace rage }; //Size: 0x0008 static_assert(sizeof(pgBase) == 0x10); + class pgBaseMetaDataType + { + public: + virtual ~pgBaseMetaDataType() = default; + virtual void Lookup(uint32_t hash) = 0; + }; //Size: 0x0008 + + class pgBaseMetaDataDebugNameType : public pgBaseMetaDataType + { + public: + virtual ~pgBaseMetaDataDebugNameType() = default; + char pad_0000[64]; + }; //Size: 0x0072 + + class pgBaseRefCounted : public pgBase + { + public: + virtual ~pgBaseRefCounted() = default; + }; //Size: 0x0008 } \ No newline at end of file diff --git a/base/pgDictionary.hpp b/base/pgDictionary.hpp new file mode 100644 index 0000000..2488012 --- /dev/null +++ b/base/pgDictionary.hpp @@ -0,0 +1,87 @@ +#pragma once + +namespace rage +{ + class pgDictionaryBase + { + public: + virtual ~pgDictionaryBase() = default; + }; //Size: 0x0008 + + template + class pgDictionary : public pgDictionaryBase + { + private: + struct Node { + T key; + Node* next; + + Node(const T& k, Node* n = nullptr) + : key(k), next(n) {} + }; + Node* head; + public: + pgDictionary() : head(nullptr) {} + ~pgDictionary() { + clearDict(); + } + + void addDict(const T& key) { + Node* newNode = new Node(key, head); + head = newNode; + } + + bool containsDict(const T& key) const { + Node* current = head; + while (current != nullptr) { + if (current->key == key) { + return true; + } + current = current->next; + } + return false; + } + + void removeDict(const T& key) { + if (head == nullptr) { + return; + } + + if (head->key == key) { + Node* temp = head; + head = head->next; + delete temp; + return; + } + + Node* current = head; + while (current->next != nullptr) { + if (current->next->key == key) { + Node* temp = current->next; + current->next = current->next->next; + delete temp; + return; + } + current = current->next; + } + } + + size_t sizeDict() const { + size_t count = 0; + Node* current = head; + while (current != nullptr) { + count++; + current = current->next; + } + return count; + } + + void clearDict() { + while (head != nullptr) { + Node* temp = head; + head = head->next; + delete temp; + } + } + }; +} \ No newline at end of file diff --git a/classes.cpp b/classes.cpp index a0f7c16..8add3f8 100644 --- a/classes.cpp +++ b/classes.cpp @@ -16,6 +16,7 @@ #include "base/phBound.hpp" #include "base/phBoundCapsule.hpp" #include "base/phBoundComposite.hpp" +#include "base/pgDictionary.hpp" #include "camera/CCameraAngles.hpp" #include "camera/CCameraManagerAngles.hpp" #include "camera/CGameCameraAngles.hpp"