From d085e923fb8ab04bcc19f7105a9077e11c3ad5a0 Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Tue, 27 May 2025 10:16:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=90=8C=E6=AD=A5=E5=AD=98=E6=A1=A3?= =?UTF-8?q?=E9=98=B2=E5=91=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/actions.js | 1 + libs/control.js | 18 +++++++++++------- libs/core.js | 1 + runtime.d.ts | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index efe3c4e6..dc435eb3 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -2904,6 +2904,7 @@ actions.prototype._clickStorageRemove_all = function () { core.saves.cache = {}; core.ui.closePanel(); core.saves.saveIndex = 1; + core.saves.actionCount = 0; core.saves.favorite = []; core.saves.favoriteName = {}; core.control._updateFavoriteSaves(); diff --git a/libs/control.js b/libs/control.js index 97bc0fa6..4fc06dff 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2060,6 +2060,7 @@ control.prototype._replayAction_no = function (action) { ////// 自动存档 ////// control.prototype.autosave = function (removeLast) { if (core.hasFlag('__forbidSave__')) return; + core.saves.actionCount ++; var x = null; if (removeLast) { x = core.status.route.pop(); @@ -2127,6 +2128,7 @@ control.prototype._doSL_save = function (id) { } core.setLocalForage("save" + id, data, function () { core.saves.saveIndex = id; + core.saves.actionCount = 0; core.setLocalStorage('saveIndex', core.saves.saveIndex); // 恢复事件 if (!core.events.recoverEvents(core.status.event.interval)) @@ -2205,8 +2207,10 @@ control.prototype._doSL_load_afterGet = function (id, data) { core.drawTip("读档成功"); if (id != "autoSave") { core.saves.saveIndex = id; + core.saves.actionCount = 0; core.setLocalStorage('saveIndex', core.saves.saveIndex); } + else core.saves.actionCount = 1; }); } @@ -2286,19 +2290,19 @@ control.prototype.syncSave = function (type) { core.getAllSaves(callback); }, () => { core.ui.closePanel(); }); } - else { + else { // 这里的检测逻辑:每存读档一次actionCount置0, 若读的自动档, actionCount置为1, 每autosave一次actionCount+1。若actionCount不为0就会触发检测。 const index = core.saves.saveIndex; if (!index) return core.drawText("没有要同步的存档"); const callback = function (save) { - const map = core.maps.loadMap(save.maps, save.floorId); const ctx = core.createCanvas('syncSave', core.__PIXELS__ / 2 - 52, 18, 104, 104, 141); core.strokeRect(ctx, 0, 0, 104, 104, 'yellow', 2); - core.drawThumbnail(save.floorId, map.blocks, { - heroLoc: save.hero.loc, heroIcon: save.hero.image, flags: save.hero.flags, - ctx: ctx, x: 2, y: 2, size: 100, noHD: true, - }); const autosave = core.saves.autosave; - if (autosave.data instanceof Array && autosave.data.length > 0) { + if (autosave.data instanceof Array && core.saves.actionCount > 0) { + const map = core.maps.loadMap(save.maps, save.floorId); + core.drawThumbnail(save.floorId, map.blocks, { + heroLoc: save.hero.loc, heroIcon: save.hero.image, flags: save.hero.flags, + ctx: ctx, x: 2, y: 2, size: 100, noHD: true, + }); core.ui.drawConfirmBox("您正试图同步" + index + "号存档,确定是这个存档吗?\n如果不是,请返回并\r[yellow]保存当前\r状态再同步.", function () { core.control._syncSave_http(type, save); core.deleteCanvas("syncSave"); diff --git a/libs/core.js b/libs/core.js index 9f5b3fa5..67e7f4dd 100644 --- a/libs/core.js +++ b/libs/core.js @@ -117,6 +117,7 @@ function core() { } this.saves = { "saveIndex": null, + "actionCount": 0, // 每次存读档后进行了几步操作,用于同步存档前的检查 "ids": {}, "autosave": { "data": null, diff --git a/runtime.d.ts b/runtime.d.ts index 9ff24f74..e0fde997 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -3385,6 +3385,8 @@ type CoreMixin = { } readonly saves: { saveIndex: number + /** 每次存读档后进行了几步操作,用于同步存档前的检查 */ + actionCount: number readonly ids: { [key: number]: boolean } autosave: { data: Save[]