refactor(object): gate on Object::RegistryReady instead of the raw pointer

Six sites tested [VAR_LOCAL_PLAYER_PTR] for null inline to mean "the
world is up": loot/Scan, loot/Unit, loot/UnitItem, target/Nearest, the
totem tracker, and the inline-texture glue check (whose comment already
defines glue as "no local player"). Object::RegistryReady is that exact
test, named; they now call it. The remaining reads of the global use its
value (SoftTarget's manager identity, Identity's player GUID), not a
null test.
This commit is contained in:
Brues
2026-11-15 15:49:32 -06:00
parent d92203aa6e
commit 4dc7e5130a
6 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -471,7 +471,7 @@ void BuildQueue(void *player, size_t maxCount, bool skipKnownEmpty) {
bool BeginWalk(bool lootMode, size_t maxCount) {
if (s_scan.state != State::Idle)
return false;
if (*reinterpret_cast<void *volatile *>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr)
if (!Object::RegistryReady())
return false;
void *player = Game::ResolveUnitToken("player");
if (player == nullptr || Request::IsMounted(player))
+1 -1
View File
@@ -57,7 +57,7 @@ int __fastcall Script_LootUnit(void *L) {
// Object manager NULL pre-login; bail silently rather than
// crashing inside the resolver.
if (*reinterpret_cast<void *volatile *>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr)
if (!Object::RegistryReady())
return 0;
void *target = Object::ByGuid(Offsets::TYPEMASK_UNIT, guid, nullptr, 0);
+1 -1
View File
@@ -156,7 +156,7 @@ int __fastcall Script_LootUnitItem(void *L) {
Game::Lua::PushBool(L, false);
return 1;
}
if (*reinterpret_cast<void *volatile *>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr) {
if (!Object::RegistryReady()) {
Game::Lua::PushBool(L, false);
return 1;
}
+1 -1
View File
@@ -230,7 +230,7 @@ void DirectionProc(DirectionData *data, uint64_t guid) {
void TargetDirection(float facing, float angle, int mode) {
if (g_directional != 0)
return;
if (Game::Read<void *>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr)
if (!Object::RegistryReady())
return;
void *unit = const_cast<uint8_t *>(Unit::Identity::PlayerObject());
if (unit == nullptr)
+2 -2
View File
@@ -25,6 +25,7 @@
#include "frame/RegionDestruction.h"
#include "text/PtrProbe.h"
#include "tick/FrameTick.h"
#include "object/Resolve.h"
#include <windows.h> // SEH (__try/__except, EXCEPTION_EXECUTE_HANDLER)
@@ -125,8 +126,7 @@ uint32_t FsColorKey(const void *fs) {
uint32_t FadedColor(const Placement &p, uint32_t fsColor) {
const uint32_t a = ((p.color >> 24) * (fsColor >> 24)) / 0xFFu;
uint32_t rgb = p.color & 0x00FFFFFFu;
const bool inGlue =
*reinterpret_cast<void *volatile *>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr;
const bool inGlue = !Object::RegistryReady();
if (inGlue) {
const uint32_t b = fsColor & 0xFFu, g = (fsColor >> 8) & 0xFFu,
r = (fsColor >> 16) & 0xFFu;
+1 -1
View File
@@ -249,7 +249,7 @@ void OnTick() {
// Out of the world: empty every slot without an event, as 3.3.5's
// EnterWorld does. The object-manager reads below deref the manager
// unconditionally, so nothing else runs either.
if (Game::Read<void *volatile>(Offsets::VAR_LOCAL_PLAYER_PTR) == nullptr) {
if (!Object::RegistryReady()) {
for (Slot &t : g_slots)
t = Slot{};
g_dirtyMask = 0;