mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
feat(missions): keep and save the mission journal type states
The client sends SetMissionTypeState (851) for the journal's mission types and subtypes (Missions.defined_type / defined_subtype) at load and after mission updates: 650 live packets, every one with the optional state left at NEW, the subtype written before the type. DLU dropped it and never wrote the states, so the client lost them on every load. - SetMissionTypeState message struct and handler: the state is stored on the player's MissionComponent (byte-sized as the client keeps it, LWOMissionComponent::msgSetMissionTypeState 0x00c90d00). - Saved as live wrote it (226 live charxmls): after <cur>, <ts><type v="Build"><st sub="" val="1"/></type>...</ts>, <ts/> when empty. Read back per <type>; old saves without <ts> load with none. The client's reader (0x00d171c0) reads v from <ts> rather than from each <type>, so it files every state under one type; the server keeps the types apart. - Mission::SetMissionTypeState (on accept) records NEW for the mission's type instead of doing nothing. Check in game: accept missions of a few kinds (a location mission, a battle achievement), open the passport/journal, then log out and back in and change zones: the journal tabs keep their "new" markers as before, nothing errors, and the character still loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionLockState.h"
|
||||
#include "Logger.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDMissionTasksTable.h"
|
||||
@@ -493,6 +494,21 @@ void MissionComponent::LoadFromXml(const tinyxml2::XMLDocument& doc) {
|
||||
m_Missions.insert_or_assign(missionId, mission);
|
||||
}
|
||||
}
|
||||
|
||||
// Live wrote <ts><type v="Build"><st sub="" val="1"/></type>...</ts>. The client's loader
|
||||
// (LWOMissionComponent::LoadFromSaveData 0x00d171c0) reads v from <ts> instead of from each <type>, so it files
|
||||
// every state under one type; the server reads each <type> as it was written.
|
||||
m_MissionTypeStates.clear();
|
||||
const auto* const ts = mis->FirstChildElement("ts");
|
||||
if (ts) {
|
||||
for (const auto* type = ts->FirstChildElement("type"); type; type = type->NextSiblingElement("type")) {
|
||||
const char* const typeName = type->Attribute("v");
|
||||
for (const auto* st = type->FirstChildElement("st"); st; st = st->NextSiblingElement("st")) {
|
||||
const char* const subtype = st->Attribute("sub");
|
||||
SetMissionTypeState(typeName ? typeName : "", subtype ? subtype : "", static_cast<eMissionLockState>(st->IntAttribute("val")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -543,11 +559,31 @@ void MissionComponent::UpdateXml(tinyxml2::XMLDocument& doc) {
|
||||
mis->InsertFirstChild(done);
|
||||
mis->InsertEndChild(cur);
|
||||
|
||||
// Live wrote <ts> after <cur>, even when it was empty
|
||||
auto* const ts = doc.NewElement("ts");
|
||||
for (const auto& [type, subtypes] : m_MissionTypeStates) {
|
||||
auto* const typeElement = doc.NewElement("type");
|
||||
typeElement->SetAttribute("v", type.c_str());
|
||||
for (const auto& [subtype, state] : subtypes) {
|
||||
auto* const st = doc.NewElement("st");
|
||||
st->SetAttribute("sub", subtype.c_str());
|
||||
st->SetAttribute("val", static_cast<int32_t>(state));
|
||||
typeElement->LinkEndChild(st);
|
||||
}
|
||||
ts->LinkEndChild(typeElement);
|
||||
}
|
||||
mis->InsertEndChild(ts);
|
||||
|
||||
if (shouldInsertMis) {
|
||||
obj->LinkEndChild(mis);
|
||||
}
|
||||
}
|
||||
|
||||
void MissionComponent::SetMissionTypeState(const std::string& type, const std::string& subtype, const eMissionLockState state) {
|
||||
// The client keeps the state as a byte (LWOMissionComponent::msgSetMissionTypeState 0x00c90d00)
|
||||
m_MissionTypeStates[type][subtype] = static_cast<eMissionLockState>(static_cast<int8_t>(state));
|
||||
}
|
||||
|
||||
void MissionComponent::AddCollectible(int32_t collectibleID) {
|
||||
// Check if this collectible is already in the list
|
||||
if (HasCollectible(collectibleID)) {
|
||||
|
||||
Reference in New Issue
Block a user