mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
feat: 自动存档不会lzw压缩录像
This commit is contained in:
parent
c6b701c9ff
commit
f8a1ea503c
@ -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);
|
||||
};
|
||||
|
||||
////// 从本地读档 //////
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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(),
|
||||
|
2
src/types/control.d.ts
vendored
2
src/types/control.d.ts
vendored
@ -626,7 +626,7 @@ interface Control {
|
||||
/**
|
||||
* 存档到本地
|
||||
*/
|
||||
saveData(): Save;
|
||||
saveData(fromAutosave: boolean): Save;
|
||||
|
||||
/**
|
||||
* 从本地读档
|
||||
|
2
src/types/function.d.ts
vendored
2
src/types/function.d.ts
vendored
@ -12,7 +12,7 @@ interface ControlData {
|
||||
/**
|
||||
* 获取保存信息
|
||||
*/
|
||||
saveData(): Save;
|
||||
saveData(fromAutosave: boolean): Save;
|
||||
|
||||
/**
|
||||
* 读取一个存档
|
||||
|
Loading…
Reference in New Issue
Block a user