Console Opened & Save Hashcode

This commit is contained in:
oc 2018-10-26 19:36:48 +08:00
parent 082f57303f
commit 9b159f045d
3 changed files with 60 additions and 6 deletions

View File

@ -190,6 +190,11 @@ control.prototype.setRequestAnimationFrame = function () {
// 执行用户的并行事件处理内容 // 执行用户的并行事件处理内容
functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.parallelDo(timestamp); functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.parallelDo(timestamp);
// 检查控制台状态
if (core.utils.consoleOpened()) {
core.setFlag('consoleOpened', true);
}
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
} }
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
@ -2213,7 +2218,12 @@ control.prototype.doSL = function (id, type) {
} }
}, function(err) { }, function(err) {
console.info(err); console.info(err);
core.drawTip("存档失败,请将控制台的报错信息反馈给管理员。"); if (core.platform.useLocalForage) {
alert("存档失败,请将控制台的报错信息反馈给管理员。");
}
else {
alert("存档空间不足,请先使用垃圾存档清理工具进行清理!");
}
}) })
return; return;
} }
@ -2222,7 +2232,11 @@ control.prototype.doSL = function (id, type) {
core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) { core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) {
if (!core.isset(data)) { if (!core.isset(data)) {
core.drawTip("无效的存档"); alert("无效的存档");
return;
}
if (core.isset(data.hashCode) && data.hashCode != core.utils.hashCode(data.hero)) {
alert("存档校验失败,请勿修改存档文件!");
return; return;
} }
if (data.version != core.firstData.version) { if (data.version != core.firstData.version) {
@ -2250,7 +2264,7 @@ control.prototype.doSL = function (id, type) {
}); });
}, function(err) { }, function(err) {
console.log(err); console.log(err);
core.drawTip("无效的存档"); alert("无效的存档");
}) })
return; return;
@ -2270,6 +2284,10 @@ control.prototype.doSL = function (id, type) {
core.drawTip("游戏难度不匹配!"); core.drawTip("游戏难度不匹配!");
return; return;
} }
if (core.isset(data.hashCode) && data.hashCode != core.utils.hashCode(data.hero)) {
alert("存档校验失败,请勿修改存档文件!");
return;
}
var route = core.subarray(core.status.route, core.decodeRoute(data.route)); var route = core.subarray(core.status.route, core.decodeRoute(data.route));
if (!core.isset(route) || data.hero.flags.seed!=core.getFlag('seed')) { if (!core.isset(route) || data.hero.flags.seed!=core.getFlag('seed')) {
core.drawTip("无法从此存档回放录像"); core.drawTip("无法从此存档回放录像");
@ -2389,6 +2407,9 @@ control.prototype.syncLoad = function () {
////// 存档到本地 ////// ////// 存档到本地 //////
control.prototype.saveData = function() { control.prototype.saveData = function() {
var hero = core.clone(core.status.hero);
var hashCode = core.utils.hashCode(hero);
var data = { var data = {
'floorId': core.status.floorId, 'floorId': core.status.floorId,
'hero': core.clone(core.status.hero), 'hero': core.clone(core.status.hero),
@ -2398,7 +2419,8 @@ control.prototype.saveData = function() {
'values': core.clone(core.values), 'values': core.clone(core.values),
'shops': {}, 'shops': {},
'version': core.firstData.version, 'version': core.firstData.version,
"time": new Date().getTime() "time": new Date().getTime(),
"hashCode": hashCode
}; };
// set shop times // set shop times
for (var shop in core.status.shops) { for (var shop in core.status.shops) {

View File

@ -242,6 +242,11 @@ events.prototype.gameOver = function (ending, fromReplay, norank) {
core.restart(); core.restart();
}) })
} }
else if (core.hasFlag('consoleOpened')) {
core.drawText("\t[系统提示]本存档开启过控制台,无法上传成绩", function () {
core.restart();
})
}
else { else {
confirmUpload(); confirmUpload();
} }

View File

@ -127,8 +127,12 @@ utils.prototype.removeLocalStorage = function (key) {
utils.prototype.setLocalForage = function (key, value, successCallback, errorCallback) { utils.prototype.setLocalForage = function (key, value, successCallback, errorCallback) {
if (!core.platform.useLocalForage) { if (!core.platform.useLocalForage) {
this.setLocalStorage(key, value); if (this.setLocalStorage(key, value)) {
if (core.isset(successCallback)) successCallback(); if (core.isset(successCallback)) successCallback();
}
else {
if (core.isset(errorCallback)) errorCallback();
}
return; return;
} }
@ -722,6 +726,29 @@ utils.prototype.hide = function (obj, speed, callback) {
}, speed); }, speed);
} }
utils.prototype.consoleOpened = function () {
var threshold = 160;
var widthThreshold = window.outerWidth - window.innerWidth > threshold;
var heightThreshold = window.outerHeight - window.innerHeight > threshold;
return !(heightThreshold && widthThreshold) &&
((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized)
|| widthThreshold || heightThreshold);
}
utils.prototype.hashCode = function (obj) {
if (typeof obj == 'string') {
var hash = 0, i, chr;
if (obj.length === 0) return hash;
for (i = 0; i < obj.length; i++) {
chr = obj.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0;
}
return hash;
}
return this.hashCode(JSON.stringify(obj).split("").sort().join(""));
}
utils.prototype._export = function (floorIds) { utils.prototype._export = function (floorIds) {
if (!core.isset(floorIds)) floorIds = [core.status.floorId]; if (!core.isset(floorIds)) floorIds = [core.status.floorId];
else if (floorIds=='all') floorIds = core.clone(core.floorIds); else if (floorIds=='all') floorIds = core.clone(core.floorIds);