diff --git a/public/libs/control.js b/public/libs/control.js index 66b32e3..6edad34 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -1906,7 +1906,7 @@ control.prototype._replay_save = function () { if (core.status.replay.save.length == 30) core.status.replay.save.shift(); core.status.replay.save.push({ - data: core.saveData(), + data: core.saveData(true), replay: { totalList: core.cloneArray(core.status.replay.totalList), toReplay: core.cloneArray(core.status.replay.toReplay), @@ -2242,7 +2242,7 @@ control.prototype.autosave = function (removeLast) { core.saves.autosave.data.splice( core.saves.autosave.now, 0, - core.saveData() + core.saveData(true) ); core.saves.autosave.now += 1; if (core.saves.autosave.data.length > core.saves.autosave.max) { @@ -2648,8 +2648,8 @@ control.prototype._syncLoad_write = function (data) { }; ////// 存档到本地 ////// -control.prototype.saveData = function () { - return this.controldata.saveData(); +control.prototype.saveData = function (fromAutosave) { + return this.controldata.saveData(fromAutosave); }; ////// 从本地读档 ////// diff --git a/public/libs/utils.js b/public/libs/utils.js index e5b5d29..96b8a13 100644 --- a/public/libs/utils.js +++ b/public/libs/utils.js @@ -638,7 +638,7 @@ utils.prototype.arrayToRGBA = function (color) { }; ////// 加密路线 ////// -utils.prototype.encodeRoute = function (route) { +utils.prototype.encodeRoute = function (route, compress = true) { var ans = '', lastMove = '', cnt = 0; @@ -665,7 +665,11 @@ utils.prototype.encodeRoute = function (route) { ans += lastMove.substring(0, 1).toUpperCase(); if (cnt > 1) ans += cnt; } - return LZString.compressToBase64(ans); + if (!compress) { + return '!!' + ans; + } else { + return LZString.compressToBase64(ans); + } }; utils.prototype._encodeRoute_id2number = function (id) { @@ -704,21 +708,23 @@ utils.prototype._encodeRoute_encodeOne = function (t) { utils.prototype.decodeRoute = function (route) { if (!route) return route; - // 解压缩 - try { + var decodeObj = { index: 0, ans: [] }; + if (route.startsWith('!!')) decodeObj.index = 2; + else { var v = LZString.decompressFromBase64(route); if (v != null && /^[-_a-zA-Z0-9+\/=:()]*$/.test(v)) { if (v != '' || route.length < 8) route = v; } - } catch (e) {} + } + decodeObj.route = route; - var decodeObj = { route: route, index: 0, ans: [] }; while (decodeObj.index < decodeObj.route.length) { this._decodeRoute_decodeOne( decodeObj, decodeObj.route.charAt(decodeObj.index++) ); } + return decodeObj.ans; }; diff --git a/public/project/functions.js b/public/project/functions.js index 881bd15..bcb353b 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -248,7 +248,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { } }, control: { - saveData: function () { + saveData: function (fromAutosave) { // 存档操作,此函数应该返回“具体要存档的内容” // 差异化存储values @@ -264,7 +264,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { hero: core.clone(core.status.hero, name => name !== 'chase'), hard: core.status.hard, maps: core.clone(core.maps.saveMap()), - route: core.encodeRoute(core.status.route), + route: core.encodeRoute(core.status.route, !fromAutosave), values: values, version: core.firstData.version, guid: core.getGuid(), diff --git a/src/types/control.d.ts b/src/types/control.d.ts index 1a703c0..86264f5 100644 --- a/src/types/control.d.ts +++ b/src/types/control.d.ts @@ -626,7 +626,7 @@ interface Control { /** * 存档到本地 */ - saveData(): Save; + saveData(fromAutosave: boolean): Save; /** * 从本地读档 diff --git a/src/types/function.d.ts b/src/types/function.d.ts index 9d07f86..152d7e9 100644 --- a/src/types/function.d.ts +++ b/src/types/function.d.ts @@ -12,7 +12,7 @@ interface ControlData { /** * 获取保存信息 */ - saveData(): Save; + saveData(fromAutosave: boolean): Save; /** * 读取一个存档