feat(xml): read inherits as a template list, and CreateFrame's id

4.3.4 reads `inherits` as a list. CSimpleFrame::LoadXML tokenizes it
on " ," and loads each template, left to right, before the node's own
content, so later templates override earlier ones; FindParent walks the
same list for a `parent`. Vanilla's frame loader, child-frames builder
and builder parent walk each look the whole string up as one name, so
XML `inherits="A, B"` failed with "Couldn't find inherited node".

Each of the three steps now takes a list the same way: every name in
order through the engine's own step, then the node itself. A single
name keeps the engine's path untouched. Textures and font strings keep
one template, as in 4.3.4.

CreateFrame is now 4.3.4's Script_CreateFrame on vanilla's builder:
- every name in a template list must resolve, or it raises the engine's
  "Couldn't find inherited node" error; the whole list goes on the
  request node, so the frame is built through the list path above with
  all templates applied before OnLoad. The old hook built with the
  first template and grafted the rest after OnLoad, and it skipped
  missing names.
- the 5th argument `id` is set on the node, so GetID() in OnLoad
  returns it.
The id has to be on the request node before the builder runs, and
vanilla builds and frees that node in its own body, so the function is
replaced, with the engine's node constructor, attribute setter,
builder, status object and error strings.

Verified in-game (1.12.1 via VanillaFixes) with a throwaway test addon:
XML and CreateFrame lists apply left to right (B's size over A's), both
templates' regions and children exist when the last template's OnLoad
runs, a missing name is skipped in XML and an error in CreateFrame, a
space-separated list takes its parent from a template, CreateFrame's id
reaches OnLoad, and CreateFrame("Cooldown") still reports "Cooldown".
This commit is contained in:
Brues
2026-10-18 23:54:14 -05:00
parent 6f55df19fa
commit 4ea0223f34
8 changed files with 479 additions and 243 deletions
+7 -1
View File
@@ -14,6 +14,7 @@
#include "xml/FrameLoad.h"
#include "Game.h"
#include "xml/Inherits.h"
#include "Offsets.h"
#include <cstdint>
@@ -23,6 +24,7 @@ namespace Xml {
namespace {
using GetAttr_t = const char *(__thiscall *)(const void *node, const char *name);
using TemplateLookup_t = const void *(__fastcall *)(const char *name);
using SStrCmpI_t = int(__stdcall *)(const char *a, const char *b, int n);
using StatusAdd_t = void(__cdecl *)(void *status, int level, const char *fmt, ...);
@@ -50,6 +52,10 @@ const char *Attr(const void *node, const char *name) {
return reinterpret_cast<GetAttr_t>(Offsets::FUN_XML_NODE_GET_ATTRIBUTE)(node, name);
}
const void *Template(const char *name) {
return reinterpret_cast<TemplateLookup_t>(Offsets::FUN_XML_TEMPLATE_LOOKUP)(name);
}
void Warn(void *status, const char *fmt, const char *a, const char *b) {
if (status == nullptr)
return;
@@ -94,7 +100,7 @@ Loader_t g_orig = nullptr;
// `__thiscall` modelled as `__fastcall` with a dummy edx.
uintptr_t __fastcall Hook(void *self, void *edx, const void *node, void *status) {
const uintptr_t r = g_orig(self, edx, node, status);
const uintptr_t r = Inherits::LoadFrame(g_orig, self, edx, node, status);
if (self != nullptr && node != nullptr) {
void *object = static_cast<uint8_t *>(self) - Offsets::OFF_XML_LOADER_SUBOBJECT;
for (AutoSubscribe *s = g_head; s != nullptr; s = s->next)