game,warden,assets: fix unknown player names, warden heap overlap, and Vanilla Item.dbc

- game: clear pendingNameQueries on player out-of-range and DESTROY_OBJECT so
  re-entering players get a fresh name query instead of being silently skipped
- game: add 5s periodic name resync scan that re-queries players with empty names
  and no pending query, recovering from dropped CMSG_NAME_QUERY responses
- warden: fix UC_ERR_MAP by moving HEAP_BASE from 0x200000 to 0x20000000; the old
  heap [0x200000, 0x1200000) overlapped the module at 0x400000, causing Unicorn to
  reject the heap mapping and abort emulator initialisation
- warden: add early overlap check between module and heap regions to catch future
  layout bugs at init time
- assets: add loadDBCOptional() which logs at DEBUG level when a DBC is absent,
  for files that are not distributed on all expansions
- assets: use loadDBCOptional for Item.dbc (absent on Vanilla 1.12 clients) and
  fall back to server-sent itemInfoCache displayInfoId for NPC weapon resolution
This commit is contained in:
Kelsi 2026-03-10 07:00:43 -07:00
parent dc2aab5e90
commit 3cdaf78369
5 changed files with 114 additions and 3 deletions

View file

@ -14,9 +14,11 @@ namespace game {
#ifdef HAVE_UNICORN
// Memory layout for emulated environment
// Note: heap must not overlap the module region (typically loaded at 0x400000)
// or the stack. Keep heap above 0x02000000 (32MB) to leave space for module + padding.
constexpr uint32_t STACK_BASE = 0x00100000; // 1MB
constexpr uint32_t STACK_SIZE = 0x00100000; // 1MB stack
constexpr uint32_t HEAP_BASE = 0x00200000; // 2MB
constexpr uint32_t HEAP_BASE = 0x02000000; // 32MB — well above typical module base (0x400000)
constexpr uint32_t HEAP_SIZE = 0x01000000; // 16MB heap
constexpr uint32_t API_STUB_BASE = 0x70000000; // API stub area (high memory)
@ -58,6 +60,17 @@ bool WardenEmulator::initialize(const void* moduleCode, size_t moduleSize, uint3
moduleBase_ = baseAddress;
moduleSize_ = (moduleSize + 0xFFF) & ~0xFFF; // Align to 4KB
// Detect overlap between module and heap/stack regions early.
uint32_t modEnd = moduleBase_ + moduleSize_;
if (modEnd > heapBase_ && moduleBase_ < heapBase_ + heapSize_) {
std::cerr << "[WardenEmulator] Module [0x" << std::hex << moduleBase_
<< ", 0x" << modEnd << ") overlaps heap [0x" << heapBase_
<< ", 0x" << (heapBase_ + heapSize_) << ") — adjust HEAP_BASE\n" << std::dec;
uc_close(uc_);
uc_ = nullptr;
return false;
}
// Map module memory (code + data)
err = uc_mem_map(uc_, moduleBase_, moduleSize_, UC_PROT_ALL);
if (err != UC_ERR_OK) {