feat(pets): write the active pet in the charxml as live did (pet@a)

The client reads <pet a> as its active pet's database ID with
GetInt64Attribute (LWOPetControlComponent::LoadFromSaveData 0x00c18120);
DLU never wrote it. Live wrote a="0" on every character (226 live
charxmls, 45 with pets): the charxml is only read when the player loads,
before any pet is out, and a pet summoned afterwards registers itself
(RegisterPetDBID). So a is written as 0.

The pet taming type p@t stays 0 as DLU already wrote it: it is an int
(IntAttribute), the client sets it to 0 for every pet it is given
(AddPetToPlayer in LWOPetControlComponent::HandleMessage 0x00d0fe00,
which ignores the message's elemental type) and every live pet had t="0".
Commented so it isn't "fixed" later.

Check in game: with a tamed pet, summon it, change zones and log out and
back in: the pet menu and pet naming work as before and no pet is shown
as out until you summon one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 03:31:28 -05:00
parent fd2be18161
commit 8a8fc263e1
2 changed files with 24 additions and 0 deletions

View File

@@ -1879,6 +1879,11 @@ void InventoryComponent::UpdatePetXml(tinyxml2::XMLDocument& document) {
petInventoryElement->DeleteChildren();
// The client reads a as its active pet's database ID (LWOPetControlComponent::LoadFromSaveData 0x00c18120). The
// charxml is only read when the player loads, when no pet is out yet (a pet is summoned again after the load and
// registers itself), so live wrote a="0" on every character (226 live charxmls)
petInventoryElement->SetAttribute("a", 0);
for (const auto& pet : m_Pets) {
auto* petElement = document.NewElement("p");
@@ -1886,6 +1891,8 @@ void InventoryComponent::UpdatePetXml(tinyxml2::XMLDocument& document) {
petElement->SetAttribute("l", pet.second.lot);
petElement->SetAttribute("m", pet.second.moderationState);
petElement->SetAttribute("n", pet.second.name.c_str());
// The taming type: the client sets it to 0 for every pet added (AddPetToPlayer in
// LWOPetControlComponent::HandleMessage 0x00d0fe00) and live saved 0 for every pet
petElement->SetAttribute("t", 0);
petInventoryElement->LinkEndChild(petElement);