fix: decouple price book entries from news ledger snapshots (review)

This commit is contained in:
2026-06-12 14:36:39 +00:00
parent 06957c65e1
commit 2da0bee712
+2 -1
View File
@@ -13,7 +13,8 @@ export function playerKnownPrices(world, planetId) {
const book = p.priceBook[planetId] ?? null; const book = p.priceBook[planetId] ?? null;
let best = book; let best = book;
if (news && (!best || news.time > best.time)) best = news; if (news && (!best || news.time > best.time)) best = news;
if (best && (!book || best.time > book.time)) p.priceBook[planetId] = best; // Copy the envelope so the price book never aliases NewsLedger's stored snapshots.
if (best && (!book || best.time > book.time)) p.priceBook[planetId] = { time: best.time, prices: best.prices };
return best ? { time: best.time, prices: best.prices, ageDays: world.t - best.time } : null; return best ? { time: best.time, prices: best.prices, ageDays: world.t - best.time } : null;
} }