mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
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:
1 parent
0bd7fccdf3
commit
9c4e354738
3 files changed
+41
-25
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user