Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double the ref handle limit #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions skyrim64_test/src/patches/CKSSE/BSHandleRefObject_CK.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class BSHandleRefObject : public NiRefObject
{
private:
//
// 31 11 10 0
// |--------------|--------|-----------|
// | Handle Index | Active | Ref Count |
// |--------------|--------|-----------|
// 31 10 9 0
// |--------------|---------|----------|
// | Handle Index | Active |Ref Count |
// |--------------|---------|----------|
//
constexpr static uint32_t ACTIVE_BIT_INDEX = 10;
constexpr static uint32_t HANDLE_BIT_INDEX = 11;
constexpr static uint32_t ACTIVE_BIT_INDEX = 9;
constexpr static uint32_t HANDLE_BIT_INDEX = 10;
constexpr static uint32_t REF_COUNT_MASK = (1u << 10) - 1u;

public:
Expand Down
18 changes: 9 additions & 9 deletions skyrim64_test/src/patches/CKSSE/BSPointerHandleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
#include "../TES/BSReadWriteLock.h"
#include "TESForm_CK.h"

template<int IndexBits = 21, int AgeCountBits = 6>
template<int IndexBits = 25, int AgeCountBits = 6>
class BSUntypedPointerHandle
{
public:
//
// NOTE: Handle index bits increased from 20 (vanilla) to 21 (limit doubled)
// NOTE: Handle index bits increased from 20 (vanilla) to 25
//
// 31 28 27 21 0
// |--------|--------|-----|--------------|
// | Unused | Active | Age | Handle Index |
// |--------|--------|-----|--------------|
// 31 30 24 0
// |--------|--------|--------------------|
// | Active | Age | Handle Index |
// |--------|--------|--------------------|
//
constexpr static uint32_t INDEX_BITS = IndexBits;
constexpr static uint32_t AGE_BITS = AgeCountBits;
constexpr static uint32_t UNUSED_BIT_START = INDEX_BITS + AGE_BITS; // 26 in vanilla

constexpr static uint32_t INDEX_MASK = (1u << INDEX_BITS) - 1u; // 0x00FFFFF
constexpr static uint32_t AGE_MASK = ((1u << AGE_BITS) - 1u) << INDEX_BITS;// 0x3F00000
constexpr static uint32_t ACTIVE_BIT_MASK = 1u << UNUSED_BIT_START; // 0x4000000
constexpr static uint32_t INDEX_MASK = (1u << INDEX_BITS) - 1u; // 0x01FFFFFF
constexpr static uint32_t AGE_MASK = ((1u << AGE_BITS) - 1u) << INDEX_BITS;// 0x7E000000
constexpr static uint32_t ACTIVE_BIT_MASK = 1u << UNUSED_BIT_START; // 0x80000000

constexpr static uint32_t MAX_HANDLE_COUNT = 1u << INDEX_BITS;

Expand Down