fix: decouple price book entries from news ledger snapshots (review)
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user