Check the epoch on prefetched copies

An admin import or delete bumps the stored data's epoch and can start the
generations over, so a copy held from before it must not apply. The prefetch
carries the epoch like the token, and a held copy is used only when it matches
the acquire reply's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ILLISISandClaude Opus 5.5 committed 2026-10-20 12:27:34 +11:00
1 parent 0bd7fccdf3
commit 9c4e354738
3 files changed
+41 -25

No files matched your search

+3 -2
View File
@@ -286,12 +286,13 @@ export default async function(context: InstancePluginContext) {
async function handlePrefetch(event: PrefetchEvent) {
const { playerData, token } = event;
const { name, generation } = playerData;
const epoch = playerData.epoch ?? 0;
logger.verbose(`Prefetching ${name}`);
// This side doesn't know the save's cleared recipe list, so the whole stored list goes as a full delta
await sendPlayerData(playerData, undefined, (chunk, number, total, extra) => {
// Later chunks have no components argument, so nil holds its place
const tokenArg = number === 1 ? `,'${token}'` : `,nil,'${token}'`;
const args = `'${name}',${generation},'${chunk}',${number},${total}${extra}${tokenArg}`;
const copyArgs = number === 1 ? `,'${token}',${epoch}` : `,nil,'${token}',${epoch}`;
const args = `'${name}',${generation},'${chunk}',${number},${total}${extra}${copyArgs}`;
return `/sc player_sync.prefetch_inventory(${args})`;
}, true);
}