From 62da87a4e4cfaae1ccb64e1282275bbf0647d8b4 Mon Sep 17 00:00:00 2001 From: thzxx <1440196015@qq.com> Date: Sun, 13 Sep 2026 12:48:53 +0800 Subject: [PATCH] 0.1.39 P0: missionIds prune + chronicle smart trim --- .../game/engine/runtime/Systems/missions.ts | 7 ++++++- src/renderer/game/engine/runtime/World.ts | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/renderer/game/engine/runtime/Systems/missions.ts b/src/renderer/game/engine/runtime/Systems/missions.ts index 78de238..dfc1229 100644 --- a/src/renderer/game/engine/runtime/Systems/missions.ts +++ b/src/renderer/game/engine/runtime/Systems/missions.ts @@ -191,7 +191,9 @@ export function recallAll(w: World, missionId: string): void { w.log('info', '探索队伍奉命返家。') } -/** 队伍成员状态归位:伤者保持养伤,其余恢复闲居 */ +/** 队伍成员状态归位:伤者保持养伤,其余恢复闲居。 + * 0.1.39 根治:完成后从 missionIds 移除——missionIds 只跟踪活跃任务 id, + * 避免长跑 180 年后死引用堆积百条。state.missions 全量保留用于史书回看。 */ function releaseSquad(w: World, m: MissionState): void { for (const id of m.memberIds) { const c = w.memberById(id) @@ -199,6 +201,9 @@ function releaseSquad(w: World, m: MissionState): void { if (c.state === 'wounded') continue c.state = 'idle' } + // 0.1.39:从 family.missionIds 移除已完成任务的 id + const idx = w.state.family.missionIds.indexOf(m.id) + if (idx >= 0) w.state.family.missionIds.splice(idx, 1) } /** 月度巡查:亡者除名、重伤者离队疗伤;人数不足则提前收队 */ diff --git a/src/renderer/game/engine/runtime/World.ts b/src/renderer/game/engine/runtime/World.ts index 2542cb8..0616018 100644 --- a/src/renderer/game/engine/runtime/World.ts +++ b/src/renderer/game/engine/runtime/World.ts @@ -334,6 +334,13 @@ export class World { this.out.forEach((o) => o.onLog(kind, text)) } + /** + * 0.1.39 根治:chronicle 智能裁剪——保留全部 important=true 里程碑 + + * 最近 MAX_NON_IMPORTANT 条非重要记录。旧版无差别 splice 会丢失关键里程碑。 + * 裁剪在 push 后触发,对调用方透明(不改变确定性序列——裁剪不消耗 rng)。 + */ + private static readonly CHRONICLE_MAX_NON_IMPORTANT = 400 + chronicle(cat: ChronicleEntry['category'], text: string, memberId?: Id, important = false): void { const entry: ChronicleEntry = { id: this.seq(), @@ -345,7 +352,16 @@ export class World { important } this.state.chronicle.push(entry) - if (this.state.chronicle.length > 520) this.state.chronicle.splice(0, this.state.chronicle.length - 520) + // 0.1.39 智能裁剪:仅在总数超限时触发,保留全部 important +最近非 important + const max = World.CHRONICLE_MAX_NON_IMPORTANT + if (this.state.chronicle.length > max + 200) { + const important_ones = this.state.chronicle.filter((e) => e.important) + const non_important = this.state.chronicle.filter((e) => !e.important) + const trimmed_non = non_important.slice(-max) + this.state.chronicle = [...important_ones, ...trimmed_non].sort( + (a, b) => (a.year - b.year) || (a.month - b.month) || (a.id < b.id ? -1 : 1) + ) + } this.out.forEach((o) => o.onChronicle(entry, important)) }