feat: 自动存档不会lzw压缩录像

This commit is contained in:
unanmed 2024-10-03 17:56:46 +08:00
parent c6b701c9ff
commit f8a1ea503c
5 changed files with 20 additions and 14 deletions

View File

@ -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);
};
////// 从本地读档 //////

View File

@ -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;
};

View File

@ -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(),

View File

@ -626,7 +626,7 @@ interface Control {
/**
*
*/
saveData(): Save;
saveData(fromAutosave: boolean): Save;
/**
*

View File

@ -12,7 +12,7 @@ interface ControlData {
/**
*
*/
saveData(): Save;
saveData(fromAutosave: boolean): Save;
/**
*