Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example_community_patch_settings_en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,9 @@ buildings = true
# Do you want to sync Haven data?
haven = true

# Do you want to sync live fleet state (mining, docked, warping...)? Opt-in, off by default
fleets = false

# Do you want to sync inventory data?
inventory = true

Expand Down
3 changes: 3 additions & 0 deletions mods/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SyncConfig
Buffs,
Buildings,
EmeraldChain,
Fleets,
Haven,
Inventory,
Jobs,
Expand Down Expand Up @@ -51,6 +52,7 @@ class SyncConfig
bool battlelogs = false;
bool buffs = false;
bool buildings = true;
bool fleets = false;
bool haven = true;
bool inventory = false;
bool jobs = false;
Expand All @@ -74,6 +76,7 @@ constexpr std::array SyncOptions{
SyncConfig::Option{SyncConfig::Type::Buffs, "buff", "buffs", &SyncConfig::buffs},
SyncConfig::Option{SyncConfig::Type::Buildings, "module", "buildings", &SyncConfig::buildings},
SyncConfig::Option{SyncConfig::Type::EmeraldChain, "emerald_chain", "buffs", &SyncConfig::buffs},
SyncConfig::Option{SyncConfig::Type::Fleets, "fleet", "fleets", &SyncConfig::fleets},
SyncConfig::Option{SyncConfig::Type::Haven, "haven", "haven", &SyncConfig::haven},
SyncConfig::Option{SyncConfig::Type::Inventory, "inventory", "inventory", &SyncConfig::inventory},
SyncConfig::Option{SyncConfig::Type::Jobs, "job", "jobs", &SyncConfig::jobs},
Expand Down
1 change: 1 addition & 0 deletions mods/src/defaultconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ namespace Sync
constexpr bool battlelogs = false;
constexpr bool buffs = true;
constexpr bool buildings = true;
constexpr bool fleets = false; // opt-in: live fleet state from fleet_watch
constexpr bool haven = true;
constexpr bool inventory = true;
constexpr bool jobs = true;
Expand Down
20 changes: 20 additions & 0 deletions mods/src/patches/fleet_watch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ void dispatch_transition(int slot, FleetPlayerData* fleet, FleetState before, Fl
}
}

void dispatch_baseline()
{
CallbackScope callback_scope;
for (const auto& subscription : s_subscriptions) {
if (!subscription.on_baseline) {
continue;
}
try {
subscription.on_baseline();
} catch (const std::exception& error) {
spdlog::warn("[FleetWatch] baseline callback failed: {}", error.what());
} catch (...) {
spdlog::warn("[FleetWatch] baseline callback failed with an unknown exception");
}
}
}

void observe_fleet(FleetPlayerData* fleet, int requested_slot, bool publish)
{
if (!fleet || requested_slot < 0 || requested_slot >= kFleetSlotCount) {
Expand Down Expand Up @@ -360,6 +377,9 @@ void Tick()
spdlog::info("[FleetWatchProbe] established stable baseline for {} fleet slots", baseline_count);
}
#endif
if (final_scan.manager_available) {
dispatch_baseline();
}
}
}
} else if (lifetime >= kSeedLifetimeMs) {
Expand Down
5 changes: 5 additions & 0 deletions mods/src/patches/fleet_watch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ struct Transition {

using TransitionCallback = void (*)(const Transition& transition);
using FastPollPredicate = bool (*)(FleetState state);
using BaselineCallback = void (*)();

struct Subscription {
TransitionCallback on_transition = nullptr;
FastPollPredicate needs_fast_poll = nullptr;
// Optional. Runs on the game thread each time a stable baseline is established while the fleet service is available
// (after login, and again after any fleet-slot topology change). Transitions are only dispatched after a baseline, so
// a consumer that needs the complete fleet list reads FleetsManager here.
BaselineCallback on_baseline = nullptr;
};

// Registers a process-lifetime fleet-state observer. The first subscription joins the shared screen-update dispatcher;
Expand Down
Loading