From c07620762d21fa3be98c6eb8378dda604cbfb964 Mon Sep 17 00:00:00 2001 From: blevouschurverantunt <35274597+blevouschurverantunt@users.noreply.github.com> Date: Wed, 14 Oct 2026 20:30:51 -0500 Subject: [PATCH] Re-emit job events when start, duration or reduction changes `job` was sent once per uuid so a job's reduction stayed frozen at first sight. `jobs_active` now keeps start_time/duration/reduction per uuid and re-sends `job` when any changes. Same event shape, `completed_job` and first-sync unchanged. Co-Authored-By: Claude Fable 5.1 --- mods/src/patches/parts/sync.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mods/src/patches/parts/sync.cc b/mods/src/patches/parts/sync.cc index 0fd2ffcff..bba2c6a2c 100644 --- a/mods/src/patches/parts/sync.cc +++ b/mods/src/patches/parts/sync.cc @@ -1652,9 +1652,10 @@ static void player_inventories(std::unique_ptr&& bytes) static void jobs(std::unique_ptr&& bytes) { using json = nlohmann::json; - static std::unordered_set jobs_active; - static std::mutex jobs_active_mtx; - static std::atomic_bool is_first_sync{true}; + using job_state = std::tuple; + static std::unordered_map jobs_active; + static std::mutex jobs_active_mtx; + static std::atomic_bool is_first_sync{true}; if (auto response = Digit::PrimeServer::Models::JobResponse(); response.ParseFromString(*bytes)) { @@ -1668,10 +1669,14 @@ static void jobs(std::unique_ptr&& bytes) const std::string& uuid = job.uuid(); uuids_in_response.insert(uuid); + const job_state state{job.starttime().seconds(), job.duration(), job.reductioninseconds()}; + bool emit = false; { std::scoped_lock lk(jobs_active_mtx); - emit = jobs_active.insert(uuid).second; + const auto [it, inserted] = jobs_active.try_emplace(uuid, state); + emit = inserted || it->second != state; + it->second = state; } if (!emit) { @@ -1720,8 +1725,8 @@ static void jobs(std::unique_ptr&& bytes) { std::scoped_lock lk(jobs_active_mtx); for (auto it = jobs_active.begin(); it != jobs_active.end();) { - if (!uuids_in_response.contains(*it)) { - job_array.push_back({{"type", "completed_" + SyncConfig::Type::Jobs}, {"uuid", *it}}); + if (!uuids_in_response.contains(it->first)) { + job_array.push_back({{"type", "completed_" + SyncConfig::Type::Jobs}, {"uuid", it->first}}); it = jobs_active.erase(it); } else { ++it;