From 573668231681fa413a017bfa61955d6c2e06312a Mon Sep 17 00:00:00 2001 From: blevouschurverantunt <35274597+blevouschurverantunt@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:14:49 -0600 Subject: [PATCH] Sync mission acceptance requirements (opt-in mission_requirements) Add an opt-in sync option, mission_requirements, off by default, that sends one mission_requirement record per mission spec the client receives: the MissionSpecs (login, active missions) and NodeMissions (system entry) entity groups. Both merge into one stream, so a system's specs never remove the login specs. Each record lists the spec's acceptance requirements as short {t, ...} entries; an empty list is sent too. A spec is sent again only when its list changes. Example settings list the option as false. Refs #389 Co-Authored-By: Claude Fable 5.2 --- docs/FEATURES.md | 1 + .../example_community_patch_settings_da.toml | 3 + .../example_community_patch_settings_de.toml | 3 + ...munity_patch_settings_en-GB-x-cockney.toml | 3 + ...mmunity_patch_settings_en-x-minionese.toml | 3 + .../example_community_patch_settings_en.toml | 3 + .../example_community_patch_settings_es.toml | 3 + .../example_community_patch_settings_fr.toml | 3 + .../example_community_patch_settings_nl.toml | 3 + .../example_community_patch_settings_ru.toml | 3 + .../example_community_patch_settings_tlh.toml | 3 + src/mod/config.h | 40 ++++--- src/mod/sync/records.cc | 109 +++++++++++++++--- src/mod/sync/state.cc | 1 + src/mod/sync/sync.h | 2 + tests/sync_logic.cc | 46 ++++++++ zig/deps/protobuf_roots.txt | 2 + 17 files changed, 197 insertions(+), 34 deletions(-) diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 21de5b260..a431f3d1c 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -104,6 +104,7 @@ Each target has its own options and access token. | Fleets | Live fleet state: each state change with cargo, mining and timers, and the server's view of deployed fleets. Every change is sent, not just the latest; up to 300 per session. Off unless a target sets `fleets`. | | Store | Faction store offers: favor level prices, requirements and remaining purchases. Off unless a target sets `store_offers`. | | Profile | Your own level, XP, Power and Haven unlock. Other players' records are never sent. Off unless a target sets `profile`. | +| Mission requirements | Acceptance requirements of the mission specs the client receives (login, active missions, and systems you enter). Off unless a target sets `mission_requirements`. | Failed uploads retry with the latest observed values. Target changes apply on reload and trigger a fresh snapshot. diff --git a/docs/configuration/example_community_patch_settings_da.toml b/docs/configuration/example_community_patch_settings_da.toml index 58f6355ba..b9a603896 100644 --- a/docs/configuration/example_community_patch_settings_da.toml +++ b/docs/configuration/example_community_patch_settings_da.toml @@ -943,6 +943,9 @@ inventory = true # Vil du synkronisere opgavedata? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Vil du synkronisere missionsdata? missions = true diff --git a/docs/configuration/example_community_patch_settings_de.toml b/docs/configuration/example_community_patch_settings_de.toml index 2f508351d..792ff06ba 100644 --- a/docs/configuration/example_community_patch_settings_de.toml +++ b/docs/configuration/example_community_patch_settings_de.toml @@ -943,6 +943,9 @@ inventory = true # Auftragsdaten synchronisieren? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Missionsdaten synchronisieren? missions = true diff --git a/docs/configuration/example_community_patch_settings_en-GB-x-cockney.toml b/docs/configuration/example_community_patch_settings_en-GB-x-cockney.toml index 1b920543e..d5684393e 100644 --- a/docs/configuration/example_community_patch_settings_en-GB-x-cockney.toml +++ b/docs/configuration/example_community_patch_settings_en-GB-x-cockney.toml @@ -943,6 +943,9 @@ inventory = true # Do you want to sync jobs data? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Do you want to sync mission data? missions = true diff --git a/docs/configuration/example_community_patch_settings_en-x-minionese.toml b/docs/configuration/example_community_patch_settings_en-x-minionese.toml index a6900d431..ce497fff8 100644 --- a/docs/configuration/example_community_patch_settings_en-x-minionese.toml +++ b/docs/configuration/example_community_patch_settings_en-x-minionese.toml @@ -943,6 +943,9 @@ inventory = true # Do you want to sync jobs data? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Do you want to sync mission data? missions = true diff --git a/docs/configuration/example_community_patch_settings_en.toml b/docs/configuration/example_community_patch_settings_en.toml index 822f8dff6..67159804e 100644 --- a/docs/configuration/example_community_patch_settings_en.toml +++ b/docs/configuration/example_community_patch_settings_en.toml @@ -964,6 +964,9 @@ inventory = true # Do you want to sync jobs data? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Do you want to sync mission data? missions = true diff --git a/docs/configuration/example_community_patch_settings_es.toml b/docs/configuration/example_community_patch_settings_es.toml index 3a14d04f5..9115cb012 100644 --- a/docs/configuration/example_community_patch_settings_es.toml +++ b/docs/configuration/example_community_patch_settings_es.toml @@ -943,6 +943,9 @@ inventory = true # ¿Quieres sincronizar los datos de trabajos? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # ¿Quieres sincronizar los datos de misiones? missions = true diff --git a/docs/configuration/example_community_patch_settings_fr.toml b/docs/configuration/example_community_patch_settings_fr.toml index 0ab7a0255..8aa1c9a95 100644 --- a/docs/configuration/example_community_patch_settings_fr.toml +++ b/docs/configuration/example_community_patch_settings_fr.toml @@ -943,6 +943,9 @@ inventory = true # Voulez-vous synchroniser les données de tâches ? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Voulez-vous synchroniser les données des missions ? missions = true diff --git a/docs/configuration/example_community_patch_settings_nl.toml b/docs/configuration/example_community_patch_settings_nl.toml index 06bb4cd43..83e502730 100644 --- a/docs/configuration/example_community_patch_settings_nl.toml +++ b/docs/configuration/example_community_patch_settings_nl.toml @@ -943,6 +943,9 @@ inventory = true # Wil je data van je banen syncen? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Wil je data van missies syncen? missions = true diff --git a/docs/configuration/example_community_patch_settings_ru.toml b/docs/configuration/example_community_patch_settings_ru.toml index 1db798e1e..fa5ba92c5 100644 --- a/docs/configuration/example_community_patch_settings_ru.toml +++ b/docs/configuration/example_community_patch_settings_ru.toml @@ -943,6 +943,9 @@ inventory = true # Синхронизировать данные задач? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Синхронизировать данные заданий? missions = true diff --git a/docs/configuration/example_community_patch_settings_tlh.toml b/docs/configuration/example_community_patch_settings_tlh.toml index 687ca4a6e..5f2dc9a47 100644 --- a/docs/configuration/example_community_patch_settings_tlh.toml +++ b/docs/configuration/example_community_patch_settings_tlh.toml @@ -943,6 +943,9 @@ inventory = true # Do you want Daq sync jobs De'? jobs = true +# Sync mission acceptance requirement data. Requires mod 1.1.11 or newer. +mission_requirements = false + # Do you want Daq sync mission De'? missions = true diff --git a/src/mod/config.h b/src/mod/config.h index b68f9aab5..3943203cc 100644 --- a/src/mod/config.h +++ b/src/mod/config.h @@ -27,25 +27,26 @@ struct SyncConfig { }; std::string proxy; - bool verify_ssl = true; - bool away_assignments = false; - bool battlelogs = false; - bool buffs = false; - bool buildings = false; - bool fleets = false; - bool haven = false; - bool inventory = false; - bool jobs = false; - bool missions = false; - bool officers = false; - bool profile = false; - bool research = false; - bool resources = false; - bool ships = false; - bool slots = false; - bool store_offers = false; - bool tech = false; - bool traits = false; + bool verify_ssl = true; + bool away_assignments = false; + bool battlelogs = false; + bool buffs = false; + bool buildings = false; + bool fleets = false; + bool haven = false; + bool inventory = false; + bool jobs = false; + bool mission_requirements = false; + bool missions = false; + bool officers = false; + bool profile = false; + bool research = false; + bool resources = false; + bool ships = false; + bool slots = false; + bool store_offers = false; + bool tech = false; + bool traits = false; bool operator==(const SyncConfig&) const = default; }; @@ -60,6 +61,7 @@ constexpr auto SyncOptions = std::to_array({ {"haven", &SyncConfig::haven}, {"inventory", &SyncConfig::inventory}, {"jobs", &SyncConfig::jobs}, + {"mission_requirements", &SyncConfig::mission_requirements}, {"missions", &SyncConfig::missions}, {"officers", &SyncConfig::officers, "officer"}, {"profile", &SyncConfig::profile}, diff --git a/src/mod/sync/records.cc b/src/mod/sync/records.cc index a1f36bae3..a775ed93f 100644 --- a/src/mod/sync/records.cc +++ b/src/mod/sync/records.cc @@ -51,6 +51,21 @@ namespace json Seconds(bool has, int64_t seconds) { return has ? json(seconds) : json(nullptr); } + // 1234 not 1234.0, and 14.364 not 14.36400032043457. + json ShortNumber(float value) + { + if (std::trunc(value) == value && std::abs(value) < 9.0e15f) + return static_cast(value); + char buffer[32]; + double widened = value; + if (const auto [end, ec] = std::to_chars(std::begin(buffer), std::end(buffer), value); ec == std::errc{}) { + // Float from_chars needs macOS 26 in Apple's libc++; the JSON parser reads the shortest form back instead. + if (auto parsed = json::parse(std::begin(buffer), end, nullptr, false); parsed.is_number()) + return parsed; + } + return widened; + } + json AwayAssignment(const pb::AwayAssignmentInstance& instance) { // Protobuf maps are unordered; both lists go out in key order. @@ -286,6 +301,83 @@ namespace records[id] = {{"mid", id}}; }); } + // Requirement types: 3 {v: mission id}; 2 {m: module type, v: level}; 7 {min, max}; 8 {f: faction id, v: amount}; + // 0 and 1 {s: core stat, v}; 4 {h: hull type, v}; 5 {g: grade, v}; 6 {c: component, v}. An unset oneof is {t} only. + json Requirement(const pb::MissionRequirement& requirement) + { + json out{{"t", static_cast(requirement.type())}}; + switch (requirement.Params_case()) { + case pb::MissionRequirement::kAllOfficersCoreStatTotalParams: { + const auto& p = requirement.allofficerscorestattotalparams(); + out.update({{"s", static_cast(p.type())}, {"v", p.value()}}); + break; + } + case pb::MissionRequirement::kAtLeastOneOfficerWithCoreStatParams: { + const auto& p = requirement.atleastoneofficerwithcorestatparams(); + out.update({{"s", static_cast(p.type())}, {"v", p.value()}}); + break; + } + case pb::MissionRequirement::kStarbaseModuleLevelParams: { + const auto& p = requirement.starbasemodulelevelparams(); + out.update({{"m", p.type()}, {"v", p.value()}}); + break; + } + case pb::MissionRequirement::kPreviouslyCompletedMissionParams: + out["v"] = requirement.previouslycompletedmissionparams().value(); + break; + case pb::MissionRequirement::kHullTypeParams: { + const auto& p = requirement.hulltypeparams(); + out.update({{"h", static_cast(p.type())}, {"v", p.value()}}); + break; + } + case pb::MissionRequirement::kHullGradeParams: { + const auto& p = requirement.hullgradeparams(); + out.update({{"g", p.grade()}, {"v", p.value()}}); + break; + } + case pb::MissionRequirement::kComponentValueParams: { + const auto& p = requirement.componentvalueparams(); + out.update({{"c", p.type()}, {"v", ShortNumber(p.value())}}); + break; + } + case pb::MissionRequirement::kPlayerLevelRangeParams: { + const auto& p = requirement.playerlevelrangeparams(); + out.update({{"min", p.minvalue()}, {"max", p.maxvalue()}}); + break; + } + case pb::MissionRequirement::kFactionStandingParams: { + const auto& p = requirement.factionstandingparams(); + out.update({{"f", p.id()}, {"v", p.amount()}}); + break; + } + case pb::MissionRequirement::PARAMS_NOT_SET: + break; + } + return out; + } + // One record per spec, empty lists too, so a target can tell "needs nothing" from "unseen". Specs are static game + // data: the store sends a spec once, and again only when its list changes. + void AddRequirements(const google::protobuf::RepeatedPtrField& specs, RecordSet& records) + { + for (const auto& spec : specs) { + auto req = json::array(); + for (const auto& requirement : spec.acceptancerequirements()) + req.push_back(Requirement(requirement)); + records[spec.id()] = {{"mid", spec.id()}, {"req", std::move(req)}}; + } + } + void ProcessMissionSpecs(const Input& input) + { + Read(input, Stream::kMissionRequirements, [](const auto& response, auto& records) { + AddRequirements(response.missionspecs(), records); + }); + } + void ProcessNodeMissions(const Input& input) + { + Read(input, Stream::kMissionRequirements, [](const auto& response, auto& records) { + AddRequirements(response.missionspecs(), records); + }); + } void ProcessOfficers(const Input& input) { Read(input, Stream::kOfficers, [](const auto& response, auto& records) { @@ -531,21 +623,6 @@ namespace } } - // 1234 not 1234.0, and 14.364 not 14.36400032043457. - json ShortNumber(float value) - { - if (std::trunc(value) == value && std::abs(value) < 9.0e15f) - return static_cast(value); - char buffer[32]; - double widened = value; - if (const auto [end, ec] = std::to_chars(std::begin(buffer), std::end(buffer), value); ec == std::errc{}) { - // Float from_chars needs macOS 26 in Apple's libc++; the JSON parser reads the shortest form back instead. - if (auto parsed = json::parse(std::begin(buffer), end, nullptr, false); parsed.is_number()) - return parsed; - } - return widened; - } - using StatMap = google::protobuf::Map; std::optional Stat(const StatMap& stats, pb::ClientModifierType key) @@ -665,6 +742,8 @@ namespace {EntityGroup::Kind::Jobs, ProcessJobs}, {EntityGroup::Kind::ActiveMissions, ProcessActiveMissions}, {EntityGroup::Kind::CompletedMissions, ProcessCompletedMissions}, + {EntityGroup::Kind::MissionSpecs, ProcessMissionSpecs}, + {EntityGroup::Kind::NodeMissions, ProcessNodeMissions}, {EntityGroup::Kind::Officers, ProcessOfficers}, {EntityGroup::Kind::ResearchTreesState, ProcessResearch}, {EntityGroup::Kind::Resources, ProcessResources}, diff --git a/src/mod/sync/state.cc b/src/mod/sync/state.cc index c7da15b82..d93030412 100644 --- a/src/mod/sync/state.cc +++ b/src/mod/sync/state.cc @@ -46,6 +46,7 @@ namespace Spec{Stream::kJobs, &SyncConfig::jobs, "job", FullSync::kInitial, "completed_job", "uuid"}, Spec{Stream::kActiveMissions, &SyncConfig::missions, "active_mission"}, Spec{Stream::kCompletedMissions, &SyncConfig::missions, "mission"}, + Spec{Stream::kMissionRequirements, &SyncConfig::mission_requirements, "mission_requirement"}, Spec{Stream::kOfficers, &SyncConfig::officers, "officer"}, Spec{Stream::kProfile, &SyncConfig::profile, "profile", FullSync::kInitial}, Spec{Stream::kResearch, &SyncConfig::research, "research"}, diff --git a/src/mod/sync/sync.h b/src/mod/sync/sync.h index a09334c0c..804964a19 100644 --- a/src/mod/sync/sync.h +++ b/src/mod/sync/sync.h @@ -211,6 +211,8 @@ enum class Stream { kJobs, kActiveMissions, kCompletedMissions, + // Static acceptance requirements of the mission specs the client receives, one record per spec. + kMissionRequirements, kOfficers, kProfile, kResearch, diff --git a/tests/sync_logic.cc b/tests/sync_logic.cc index 9ab716dd4..300c61cbb 100644 --- a/tests/sync_logic.cc +++ b/tests/sync_logic.cc @@ -218,6 +218,51 @@ void AwayAndEmerald() Process(EntityGroup::Kind::AllianceGetGameProperties, unclaimed); Check(Send(target) == json::parse(R"([{"type":"emerald_chain","level":-1}])"), "no claimed tier is level -1"); } +void MissionRequirements() +{ + auto target = Target(); + game::MissionSpecsResponse specs; + auto* gated = specs.add_missionspecs(); + gated->set_id(20); + auto* requirement = gated->add_acceptancerequirements(); + requirement->set_type(game::MISSIONREQUIREMENTTYPE_SPREVIOUSLYCOMPLETEDMISSION); + requirement->mutable_previouslycompletedmissionparams()->set_value(10); + auto* ungated = specs.add_missionspecs(); + ungated->set_id(21); + Process(EntityGroup::Kind::MissionSpecs, specs); + Delivery missions_only; + auto options = Options(); + options.mission_requirements = false; + missions_only.Configure(options); + Check(!missions_only.Next(store, now), "mission requirements are opt-in, not part of missions"); + Check( + Send(target) + == json::parse( + R"([{"type":"mission_requirement","mid":20,"req":[{"t":3,"v":10}]},{"type":"mission_requirement","mid":21,"req":[]}])"), + "mission requirement wire fixture, empty list kept"); + Process(EntityGroup::Kind::MissionSpecs, specs); + Check(!target.Next(store, now), "unchanged mission specs are not uploaded again"); + auto* range = ungated->add_acceptancerequirements(); + range->set_type(game::MISSIONREQUIREMENTTYPE_SPLAYERLEVELRANGE); + range->mutable_playerlevelrangeparams()->set_minvalue(5); + range->mutable_playerlevelrangeparams()->set_maxvalue(60); + Process(EntityGroup::Kind::MissionSpecs, specs); + Check(Send(target) == json::parse(R"([{"type":"mission_requirement","mid":21,"req":[{"t":7,"min":5,"max":60}]}])"), + "a changed requirement list is sent again, alone"); + game::NodeMissionsResponse node; + auto* entered = node.add_missionspecs(); + entered->set_id(22); + auto* component = entered->add_acceptancerequirements(); + component->set_type(game::MISSIONREQUIREMENTTYPE_SCOMPONENTVALUE); + component->mutable_componentvalueparams()->set_type("warp"); + component->mutable_componentvalueparams()->set_value(14.364f); + Process(EntityGroup::Kind::NodeMissions, node); + Check(Send(target) + == json::parse(R"([{"type":"mission_requirement","mid":22,"req":[{"t":6,"c":"warp","v":14.364}]}])"), + "a system's mission specs are sent, floats in shortest form"); + Check(store.Contains(Stream::kMissionRequirements, 20) && store.Contains(Stream::kMissionRequirements, 21), + "and merge with the login specs instead of replacing them"); +} void Snapshots() { auto target = Target(); @@ -797,6 +842,7 @@ int main() run("presets", Presets); run("slot transports", SlotTransports); run("away and emerald", AwayAndEmerald); + run("mission requirements", MissionRequirements); run("snapshots", Snapshots); run("removals", EmptyAndRemoved); run("jobs", Jobs); diff --git a/zig/deps/protobuf_roots.txt b/zig/deps/protobuf_roots.txt index 70a62586e..5fa66e137 100644 --- a/zig/deps/protobuf_roots.txt +++ b/zig/deps/protobuf_roots.txt @@ -18,8 +18,10 @@ Digit.PrimeServer.Models.GlobalActiveBuffsResponse Digit.PrimeServer.Models.InventoryResponse Digit.PrimeServer.Models.Job Digit.PrimeServer.Models.JobResponse +Digit.PrimeServer.Models.MissionSpecsResponse # Declared by the mod in stfc.sync.proto; the game has no message for the MyDeployedFleets payload. Digit.PrimeServer.Models.MyDeployedFleetsResponse +Digit.PrimeServer.Models.NodeMissionsResponse Digit.PrimeServer.Models.OfficerTraitsResponse Digit.PrimeServer.Models.OfficersResponse Digit.PrimeServer.Models.PlanetaryBase