From 0517e0f1455959e05f8c67e5eba2d2550635e186 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 15 May 2018 00:02:35 +0800 Subject: [PATCH] Fix flyrange bug --- _server/fs.js | 41 ++++++++++++++++++++++++++++++++++++++++- libs/events.js | 8 ++++---- 更新说明.txt | 1 + 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/_server/fs.js b/_server/fs.js index 31b24811..59bd1441 100644 --- a/_server/fs.js +++ b/_server/fs.js @@ -1,8 +1,47 @@ (function () { fs = {}; + + + var _http = function (type, url, formData, success, error, mimeType, responseType) { + var xhr = new XMLHttpRequest(); + xhr.open(type, url, true); + if (core.isset(mimeType)) + xhr.overrideMimeType(mimeType); + if (core.isset(responseType)) + xhr.responseType = responseType; + xhr.onload = function(e) { + if (xhr.status==200) { + if (core.isset(success)) { + success(xhr.response); + } + } + else { + if (core.isset(error)) + error("HTTP "+xhr.status); + } + }; + xhr.onabort = function () { + if (core.isset(error)) + error("Abort"); + } + xhr.ontimeout = function() { + if (core.isset(error)) + error("Timeout"); + } + xhr.onerror = function() { + if (core.isset(error)) + error("Error on Connection"); + } + if (core.isset(formData)) + xhr.send(formData); + else xhr.send(); + } + + var postsomething = function (data, _ip, callback) { if (typeof(data) == typeof([][0]) || data == null) data = JSON.stringify({1: 2}); - core.http("POST", _ip, data, function (data) { + + _http("POST", _ip, data, function (data) { if (data.slice(0, 6) == 'error:') { callback(data, null); } diff --git a/libs/events.js b/libs/events.js index 8cf62d64..786499af 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1033,10 +1033,10 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback } } if (core.status.maps[floorId].canFlyTo && core.status.hero.flyRange.indexOf(floorId)<0) { - if (core.floorIds.indexOf(floorId)>core.floorIds.indexOf(core.status.floorId)) - core.status.hero.flyRange.push(floorId); - else - core.status.hero.flyRange.unshift(floorId); + core.status.hero.flyRange.push(floorId); + core.status.hero.flyRange.sort(function (a, b) { + return core.floorIds.indexOf(a) - core.floorIds.indexOf(b); + }) } window.setTimeout(function () { diff --git a/更新说明.txt b/更新说明.txt index a5c4c77a..d38375a7 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -11,6 +11,7 @@ 增添自定义装备的教程(个性化-自定义装备) √ 重写教程的快速上手 √ 修复转向触发事件的朝向Bug √ +修复flyRange的顺序问题 √ 部分细节优化 √ -----------------------------------------------------------------------