feat: save the mount item as live did

Every live save had <mnt a="..."/>, which
LWOMountControlComponent::LoadFromSaveData (0x00bf99c0) reads as the
character's mount item (0 on the 450 saves looked at). The server wrote
no such element.

MountControlComponent now writes it: the item of the mount being ridden,
0 on foot. The saved value is read and kept; nothing is mounted from it,
as riding does not go on over a world change. A save from before gains
<mnt a="0"/> and nothing else in it changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 15:54:54 -06:00
parent c5c90f73a2
commit 02623be7fb
5 changed files with 102 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
#include "MountControlComponent.h"
#include "Entity.h"
#include "PossessorComponent.h"
#include "tinyxml2.h"
void MountControlComponent::LoadFromSaveData(const tinyxml2::XMLDocument& doc) {
const auto* const obj = doc.FirstChildElement("obj");
const auto* const mount = obj ? obj->FirstChildElement("mnt") : nullptr;
if (mount) mount->QueryInt64Attribute("a", &m_SavedMountItemID);
}
void MountControlComponent::WriteSaveData(tinyxml2::XMLDocument& doc) {
auto* const obj = doc.FirstChildElement("obj");
if (!obj) return;
auto* mount = obj->FirstChildElement("mnt");
if (!mount) mount = obj->InsertNewChildElement("mnt");
const auto* const possessor = m_Parent->GetComponent<PossessorComponent>();
mount->SetAttribute("a", possessor ? possessor->GetMountItemID() : LWOOBJID_EMPTY);
}

View File

@@ -2,17 +2,31 @@
#define MOUNTCONTROLCOMPONENT_H
#include "Component.h"
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
/**
* Mount control (111): the character's riding of mounts, as the client's LWOMountControlComponent: the client makes it (componentID -1) with every character
* (LWOCharacterComponent::Factory). Nothing of it is sent or done on the server yet.
* (LWOCharacterComponent::Factory). It keeps the mount item in the character's save, as live did (<mnt a="item id"/>,
* 0 when not riding: all 450 live saves looked at were 0).
*/
class MountControlComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOUNT_CONTROL;
MountControlComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
// LWOMountControlComponent::LoadFromSaveData (0x00bf99c0): <mnt a>, the mount item of the save
void LoadFromSaveData(const tinyxml2::XMLDocument& doc) override;
// Writes <mnt a>: the item of the mount being ridden (PossessorComponent's), 0 when on foot
void WriteSaveData(tinyxml2::XMLDocument& doc) override;
// The mount item the save named. Riding does not go on over a world change, so nothing is mounted from it.
LWOOBJID GetSavedMountItemID() const { return m_SavedMountItemID; }
private:
LWOOBJID m_SavedMountItemID = LWOOBJID_EMPTY;
};
#endif // MOUNTCONTROLCOMPONENT_H