From 4e0d981e4ac53468feb8ddd0a8b8cef697e6c30b Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Mon, 8 Jun 2020 11:33:17 +0800 Subject: [PATCH] Fix known bugs --- _server/MotaActionParser.js | 5 ++++- _server/editor_datapanel.js | 2 +- _server/editor_game.js | 1 + editor-mobile.html | 2 +- editor.html | 2 +- libs/maps.js | 31 ++++++++++++++++++++++++++++--- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index f555e202..5db4c9f0 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -1042,7 +1042,10 @@ ActionParser.prototype.matchId = function(args) { var Id_List = MotaActionBlocks['Id_List'].options; // [["变量", "flag"], ...] match=new RegExp('^('+Id_List.map(function(v){return v[1]}).join('|')+'):([a-zA-Z0-9_\\u4E00-\\u9FCC]+)$').exec(args[0]) if(match){ - args=[match[1],MotaActionFunctions.replaceToName_token(match[2])] + if (match[1] == 'status' || match[1] == 'item') { + match[2] = MotaActionFunctions.replaceToName_token(match[2]); + } + args=[match[1],match[2]] return rt(MotaActionBlocks['idIdList_e'].xmlText, args); } return {ret:false} diff --git a/_server/editor_datapanel.js b/_server/editor_datapanel.js index ec94b6e0..b30ba3e0 100644 --- a/_server/editor_datapanel.js +++ b/_server/editor_datapanel.js @@ -379,7 +379,7 @@ editor_datapanel_wrapper = function (editor) { } else if (cls == 'items') { if (confirm("你确定要覆盖此道具的全部属性么?这是个不可逆操作!")) { var name = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[id].name; - items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[id] = core.clone(editor.uivalues.copyEnemyItem.data[x]); + items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[id] = core.clone(editor.uivalues.copyEnemyItem.data); items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[id].id = id; items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[id].name = name; editor.file.saveSetting('items', [], function (err) { diff --git a/_server/editor_game.js b/_server/editor_game.js index c267511b..5194cce1 100644 --- a/_server/editor_game.js +++ b/_server/editor_game.js @@ -158,6 +158,7 @@ editor_game_wrapper = function (editor, main, core) { //与editor.map同形的全0 mapArray = eval('[' + Array(editor.map.length + 1).join('[' + Array(editor.map[0].length + 1).join('0,') + '],') + ']'); } + mapArray = core.maps._processInvalidMap(mapArray, editor.map[0].length, editor.map.length); editor[name] = mapArray.map(function (v) { return v.map(function (v) { var x = parseInt(v), y = editor.indexs[x]; diff --git a/editor-mobile.html b/editor-mobile.html index 8af896bf..4f0fd2ad 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -215,7 +215,7 @@ - + 开启中文名替换 diff --git a/editor.html b/editor.html index 8c88732b..77b345f7 100644 --- a/editor.html +++ b/editor.html @@ -210,7 +210,7 @@ - + 开启中文名替换 diff --git a/libs/maps.js b/libs/maps.js index 1ba632ef..772e9f2c 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -245,19 +245,44 @@ maps.prototype.compressMap = function (mapArr, floorId) { return mapArr; } +maps.prototype._processInvalidMap = function (mapArr, width, height) { + if (mapArr.length == height && mapArr[0].length == width) return mapArr; + + var allZeros = []; + for (var i = 0; i < width; ++i) { + allZeros.push(0); + } + var map = []; + for (var i = 0; i < height; ++i) { + map.push(core.clone(allZeros)); + } + for (var j = 0; j < height; ++j) { + for (var i = 0; i < width; ++i) { + if (j < mapArr.length && i < mapArr[j].length) + map[j][i] = mapArr[j][i]; + } + } + return map; +} + ////// 解压缩地图 maps.prototype.decompressMap = function (mapArr, floorId) { - var floorMap = core.floors[floorId].map; - if (!mapArr) return core.clone(floorMap); - var mw = core.floors[floorId].width; var mh = core.floors[floorId].height; + var floorMap = this._processInvalidMap(core.floors[floorId].map, mw, mh); + + if (!mapArr) return core.clone(floorMap); + for (var x = 0; x < mh; x++) { + if (x >= mapArr.length) { + mapArr.push(0); + } if (mapArr[x] === 0) { mapArr[x] = core.clone(floorMap[x]); } else { for (var y = 0; y < mw; y++) { + if (y >= mapArr[x].length) mapArr[x].push(-1); if (mapArr[x][y] === -1) { mapArr[x][y] = floorMap[x][y]; }