feat(missions): keep the viewed flag of missions in progress, as the client

The client keeps a viewed flag on each mission in progress, sets it with
SetMissionViewed (LWOMissionComponent::msgSetMissionViewed 0x00bec7a0, only
for missions in progress) and reads it as v on the mission's <cur> entry
(LWOMissionComponent::LoadFromSaveData 0x00d171c0, a number or "true", false
when missing). The server now handles SetMissionViewed, saves v="1" for a
viewed mission in progress and loads it back; saves without v load as not
viewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-02 15:33:35 -05:00
parent 0c298efe4d
commit 529bacd077
10 changed files with 190 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
#include "Mission.h"
#include "ChatServerLink.h"
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include "CDClientManager.h"
@@ -37,6 +40,17 @@
namespace {
std::set<uint32_t> g_TestedMissions = { 773, 774, 775, 776, 777 }; // TODO Figure out why these missions are broken sometimes
// The client's save data bool: a non-zero number or "true" in any case
bool ReadSaveBool(const tinyxml2::XMLElement& element, const char* const name) {
const char* const value = element.Attribute(name);
if (!value) return false;
if (std::strtol(value, nullptr, 10) != 0) return true;
std::string text = value;
std::ranges::transform(text, text.begin(), [](const unsigned char c) { return static_cast<char>(std::tolower(c)); });
return text == "true";
}
}
Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
@@ -94,6 +108,9 @@ void Mission::LoadFromXmlCur(const tinyxml2::XMLElement& element) {
}
// End custom XML
// LWOMissionComponent::LoadFromSaveData (0x00d171c0): v is the viewed flag, false when missing
m_Viewed = ReadSaveBool(element, "v");
auto* task = element.FirstChildElement();
auto index = 0U;
@@ -164,6 +181,8 @@ void Mission::UpdateXmlCur(tinyxml2::XMLElement& element) {
if (IsComplete()) return;
if (m_Viewed) element.SetAttribute("v", 1);
for (const auto* const task : m_Tasks) {
auto* const child = element.InsertNewChildElement("sv");
child->SetAttribute("v", static_cast<unsigned int>(task->GetProgress()));

View File

@@ -246,6 +246,13 @@ public:
bool IsFailed() const;
/**
* Whether the player has looked at this mission in progress (LWOMissionComponent::msgSetMissionViewed 0x00bec7a0),
* saved as v on the mission's <cur> entry
*/
bool GetViewed() const { return m_Viewed; }
void SetViewed(const bool viewed) { m_Viewed = viewed; }
private:
/**
* Progresses all the newly accepted tasks for this mission after it has been accepted to reflect the state of the
@@ -292,6 +299,11 @@ private:
* The unique ID what order this mission was accepted in.
*/
uint32_t m_UniqueMissionID;
/**
* Whether the player has looked at this mission in progress
*/
bool m_Viewed{ false };
};
#endif