Skip to content

Commit

Permalink
Requested changes from wopss#177
Browse files Browse the repository at this point in the history
  • Loading branch information
googleben committed Jan 24, 2025
1 parent af8ddcd commit b10db41
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions include/RED4ext/CNamePool-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RED4EXT_INLINE void RED4ext::CNamePool::Add(const CName& aName, const CString& a

RED4EXT_INLINE const char* RED4ext::CNamePool::Get(const CName& aName)
{
static UniversalRelocFunc<const char* (*)(const CName&)> func(Detail::AddressHashes::CNamePool_Get);
static UniversalRelocFunc<const char* (*)(const CName&)> func(Detail::AddressHashes::CNamePool_GetString);
auto result = func(aName);
if (result)
{
Expand All @@ -57,7 +57,7 @@ RED4EXT_INLINE RED4ext::CNamePool* RED4ext::CNamePool::GetPool()

RED4EXT_INLINE RED4ext::CNamePoolNode* RED4ext::CNamePoolNodeInner::Outer()
{
return reinterpret_cast<RED4ext::CNamePoolNode*>(reinterpret_cast<int*>(this) - 1);
return reinterpret_cast<RED4ext::CNamePoolNode*>(reinterpret_cast<uintptr_t>(this) - offsetof(RED4ext::CNamePoolNode, inner));
}

RED4EXT_INLINE RED4ext::CNamePoolNodeInner* RED4ext::CNamePoolNodeInner::NextInList() const
Expand All @@ -67,17 +67,17 @@ RED4EXT_INLINE RED4ext::CNamePoolNodeInner* RED4ext::CNamePoolNodeInner::NextInL

RED4EXT_INLINE RED4ext::CNamePoolNodeInner* RED4ext::CNamePoolNodeInner::NextInHashBin()
{
return this->next;
return next;
}

RED4EXT_INLINE RED4ext::CNamePoolNode* RED4ext::CNamePoolNode::NextInList() const
{
return reinterpret_cast<RED4ext::CNamePoolNode*>(reinterpret_cast<int64_t>(&this->inner) + this->len);
return reinterpret_cast<RED4ext::CNamePoolNode*>(reinterpret_cast<uintptr_t>(&inner) + len);
}

RED4EXT_INLINE RED4ext::CNamePoolNode* RED4ext::CNamePoolNode::NextInHashBin()
{
return this->inner.next->Outer();
return inner.next->Outer();
}

RED4EXT_INLINE RED4ext::CNamePoolAllocator::Iterator& RED4ext::CNamePoolAllocator::Iterator::operator++()
Expand Down Expand Up @@ -122,7 +122,7 @@ RED4EXT_INLINE RED4ext::CNamePoolAllocator::Iterator RED4ext::CNamePoolAllocator

RED4EXT_INLINE RED4ext::CNamePoolNodeInner*& RED4ext::CNamePoolHashmap::operator[](const uint64_t aKey)
{
return this->nodesByHash[aKey & 0x7ffff];
return nodesByHash[aKey & 0x7ffff];
}

RED4EXT_INLINE RED4ext::CNamePoolHashmap::Iterator RED4ext::CNamePoolHashmap::Begin(const CName& aKey)
Expand All @@ -147,7 +147,7 @@ RED4EXT_INLINE RED4ext::CNamePoolHashmap::Iterator RED4ext::CNamePoolHashmap::En

RED4EXT_INLINE RED4ext::CNamePoolNodeInner*& RED4ext::CNamePoolHashmap::operator[](const CName& aKey)
{
return this->nodesByHash[aKey.hash & 0x7ffff];
return nodesByHash[aKey.hash & 0x7ffff];
}

RED4EXT_INLINE RED4ext::CNamePoolHashmap::Iterator& RED4ext::CNamePoolHashmap::Iterator::operator++()
Expand Down
30 changes: 15 additions & 15 deletions include/RED4ext/CNamePool.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "DynArray.hpp"
#include <RED4ext/DynArray.hpp>
#include <RED4ext/CName.hpp>
#include <RED4ext/CString.hpp>

Expand Down Expand Up @@ -156,28 +156,28 @@ struct CNamePoolAllocator
CNamePoolNode* listEnd; // 10
// I believe these three pointers would be used if more space than `head` has available is needed, but the amount
// of allocated space is so large that it shouldn't come up
CNamePoolNode* unkNodePtr; // 18
CNamePoolNode* unkNodePtr2; // 20
CNamePoolNode* unkNodePtr3; // 28
CNamePoolNode* unk18; // 18
CNamePoolNode* unk20; // 20
CNamePoolNode* unk28; // 28
// potentially padding
char unk[8]; // 30
// some kind of memory allocation handler, or something like that
void* unkPtr; // 38
void* unk38; // 38
// should always be 0x8_0000
uint32_t unk2; // 40
uint32_t unk40; // 40
// should always be 3
uint32_t unk3; // 44
uint32_t unk44; // 44
};
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, head, 0x00);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, endAvailableSpace, 0x08);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, listEnd, 0x10);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unkNodePtr, 0x18);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unkNodePtr2, 0x20);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unkNodePtr3, 0x28);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk18, 0x18);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk20, 0x20);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk28, 0x28);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk, 0x30);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unkPtr, 0x38);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk2, 0x40);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk3, 0x44);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk38, 0x38);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk40, 0x40);
RED4EXT_ASSERT_OFFSET(CNamePoolAllocator, unk44, 0x44);
RED4EXT_ASSERT_SIZE(CNamePoolAllocator, 0x48);

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ struct CNamePool
SharedSpinLock listLock; // 400018

// potentially padding
uint64_t unk2[4]; // 400020
uint64_t unk400020[4]; // 400020

/// @brief Essentially an allocation arena for `CNamePoolNode`s
/// @sa CNamePoolAllocator
Expand All @@ -346,7 +346,7 @@ RED4EXT_ASSERT_OFFSET(CNamePool, hashmapLock, 0x00);
RED4EXT_ASSERT_OFFSET(CNamePool, nodes, 0x08);
RED4EXT_ASSERT_OFFSET(CNamePool, hashmap, 0x18);
RED4EXT_ASSERT_OFFSET(CNamePool, listLock, 0x400018);
RED4EXT_ASSERT_OFFSET(CNamePool, unk2, 0x400020);
RED4EXT_ASSERT_OFFSET(CNamePool, unk400020, 0x400020);
RED4EXT_ASSERT_OFFSET(CNamePool, allocator, 0x400040);
RED4EXT_ASSERT_SIZE(CNamePool, 0x400088);

Expand Down
4 changes: 2 additions & 2 deletions include/RED4ext/Detail/AddressHashes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ constexpr std::uint32_t CGlobalFunction_ctor = 0xFA6B24D0;
constexpr std::uint32_t CNamePool_AddCstr = 0xA00C9B;
constexpr std::uint32_t CNamePool_AddCString = 0xFFD61709;
constexpr std::uint32_t CNamePool_AddPair = 0xD9840BD8;
constexpr std::uint32_t CNamePool_Get = 0x68DF07DC;
constexpr std::uint32_t CNamePool_GetPool = 0xC5E711D3;
constexpr std::uint32_t CNamePool_GetString = 0x68DF07DC;
constexpr std::uint32_t CNamePool_GetPool = 3320254931;
#pragma endregion

#pragma region CommandListContext
Expand Down

0 comments on commit b10db41

Please sign in to comment.