add pgBaseMetaDataType and pgBaseMetaDataDebugNameType and pgDictionary and pgDictionaryBase (#138)

This commit is contained in:
PliskinDev 2023-09-10 23:49:02 +03:00 committed by GitHub
parent 7c94b4ee69
commit a736fdeedb
3 changed files with 107 additions and 0 deletions

View File

@ -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
}

87
base/pgDictionary.hpp Normal file
View File

@ -0,0 +1,87 @@
#pragma once
namespace rage
{
class pgDictionaryBase
{
public:
virtual ~pgDictionaryBase() = default;
}; //Size: 0x0008
template<typename T>
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;
}
}
};
}

View File

@ -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"