fix(journal): keep variable bases in the stream
The stream only carried combined values, so hydrating a session lost the raw base and rebuildReactivityFromStore re-applied tag modifiers on top of already-combined values (e.g. $hp 70 became 90). Publish the raw base alongside the combined value on var messages, persist it in variableBases, and rebuild engine state from exact bases. Derive tag activations from base tagmaps so tagmap-valued modifier targets are not re-triggered on every rebuild. Seed declared variables only after hydration and only for keys absent from the store, so persisted values are no longer clobbered on load and reloads stop appending duplicate var messages.
This commit is contained in:
@@ -236,6 +236,7 @@ function dispatchSet(
|
||||
action: "set",
|
||||
key: change.key,
|
||||
value: change.value,
|
||||
base: change.base,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -244,10 +245,15 @@ function dispatchSet(
|
||||
}
|
||||
|
||||
// Send the direct set last so cascade messages arrive first.
|
||||
// Use getCombined with stream fallback so the stream store receives the
|
||||
// correct value (base + active mods) rather than just the raw base.
|
||||
// Publish the combined value for display plus the raw base so hydrated
|
||||
// clients can rebuild the engine exactly (see rebuildReactivityFromStore).
|
||||
const combinedValue = getCombined(key, ctx.variables);
|
||||
const r1 = sendMessage("var", { action: "set", key, value: combinedValue });
|
||||
const r1 = sendMessage("var", {
|
||||
action: "set",
|
||||
key,
|
||||
value: combinedValue,
|
||||
base: newValue,
|
||||
});
|
||||
const u1 = unwrap(r1);
|
||||
if (!u1.ok) return u1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user