From cb9acb7a521de72054118a8f4205c5922961c760 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 26 Nov 2017 22:53:41 -0500 Subject: [PATCH] Fixed some loading bugs --- core/src/io/anuke/mindustry/ai/Pathfind.java | 49 +++--------------- core/src/io/anuke/mindustry/core/Control.java | 4 ++ .../mindustry/entities/enemies/Enemy.java | 2 - core/src/io/anuke/mindustry/io/SaveIO.java | 2 +- core/src/io/anuke/mindustry/world/World.java | 3 +- desktop/mindustry-saves/3.mins | Bin 2191 -> 1502 bytes 6 files changed, 13 insertions(+), 47 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index e239913791..c8199f1e23 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -22,12 +22,15 @@ public class Pathfind{ Vector2 vector = new Vector2(); public Vector2 find(Enemy enemy){ - if(enemy.node == -1){ + if(enemy.node == -1 || enemy.node == -2){ findNode(enemy); } if(enemy.path == null){ return vector.set(enemy.x, enemy.y); + }else if(enemy.node == -2){ + enemy.node = -1; + enemy.findClosestNode(); } //-1 is only possible here if both pathfindings failed, which should NOT happen @@ -35,7 +38,6 @@ public class Pathfind{ Tile[] path = enemy.path; - //REPRODUCE BUG: load in test map, then load save 1? Tile prev = path[enemy.node - 1]; Tile target = path[enemy.node]; @@ -92,9 +94,7 @@ public class Pathfind{ public void updatePath(){ for(SpawnPoint point : Vars.control.getSpawnPoints()){ - if(point.finder == null){ - point.finder = new IndexedAStarPathFinder(graph); - } + point.finder = new IndexedAStarPathFinder(graph); point.path.clear(); @@ -103,47 +103,10 @@ public class Pathfind{ point.request = new PathFinderRequest(point.start, Vars.control.getCore(), heuristic, point.path); point.request.statusChanged = true; //IMPORTANT! } - - /* - if(paths.size == 0 || paths.size != World.spawnpoints.size){ - paths.clear(); - finders.clear(); - pathSequences = new Tile[World.spawnpoints.size][0]; - for(int i = 0; i < World.spawnpoints.size; i ++){ - SmoothGraphPath path = new SmoothGraphPath(); - paths.add(path); - finders.add(new IndexedAStarPathFinder(graph)); - } - } - - for(int i = 0; i < paths.size; i ++){ - SmoothGraphPath path = paths.get(i); - - path.clear(); - finders.get(i).searchNodePath( - World.spawnpoints.get(i), - World.core, heuristic, path); - - smoother.smoothPath(path); - - pathSequences[i] = new Tile[path.getCount()]; - - for(int node = 0; node < path.getCount(); node ++){ - Tile tile = path.get(node); - - pathSequences[i][node] = tile; - } - - - if(Vars.debug && Vars.showPaths) - for(Tile tile : path){ - Effects.effect(Fx.ind, tile.worldx(), tile.worldy()); - } - - }*/ } void findNode(Enemy enemy){ + if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){ return; } diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index c93d7add2d..507a847371 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -444,6 +444,10 @@ public class Control extends Module{ enemyGroup.clear(); } + if(Inputs.keyUp(Keys.F)){ + wavetime = 0f; + } + if(Inputs.keyUp(Keys.O)){ Vars.noclip = !Vars.noclip; } diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 91ba5b1e25..cf29ef468c 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -139,8 +139,6 @@ public class Enemy extends DestructibleEntity{ } public void findClosestNode(){ - Vars.world.pathfinder().find(this); - int index = 0; int cindex = -1; float dst = Float.MAX_VALUE; diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 990ae1fac7..8358224742 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -372,7 +372,7 @@ public class SaveIO{ Vars.renderer.clearTiles(); for(Enemy enemy : enemiesToUpdate){ - enemy.findClosestNode(); + enemy.node = -2; } for(int x = 0; x < Vars.world.width(); x ++){ diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index 34a80075d6..3d92e17c57 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -155,12 +155,13 @@ public class World extends Module{ createTiles(); }else{ - tiles = new Tile[map.width][map.height]; createTiles(); } + Vars.control.getSpawnPoints().clear(); + Entities.resizeTree(0, 0, map.width * tilesize, map.height * tilesize); this.seed = seed; diff --git a/desktop/mindustry-saves/3.mins b/desktop/mindustry-saves/3.mins index 2b036dbabe48a0d5e2e0c1ef6644a68d0597833c..6b1bf4bd4129aad1f223bdc099228f9aa0995697 100644 GIT binary patch literal 1502 zcmZvc%WG3X6vofJNm^2@F^{%Mn)|3}O-<5hpJ0ue$3Vp@T57d!bfF6=ZWKh_NEf2G z5ZqKPF2#jNMHEC7tF~34A_d=ng1B_yMiU$aY|nMt)s%2Ipu`?viyBb*dr&|J=#Fp)C;-A6p@jZ??h3ej=P}DJy1?jYYtlCKB!ZX zorf0d0kzD5x|G&YfY!MM)U_3qeF)mn3ral#W&1!IAA>TAHY@7yhZ`OM#T8`~B?jT9 zo`AZag7Vuy(P2>gGf;RtD6h!aNzPrf(=A`d{Oa0VKPcKNF343!!9aco-vnH9H}E(LX>%1yTUL<_e(vMaM5rPbP8g(dFS z#J^OBjB4%KjKx~b^m702Yr452-x#08s?*D=)5~^qwbyM3XJh$S;5IatR@delzjuj~ z{DFoPW#2$6CI!qO79iKDdJ) tK#>EWmN8KJBPciyTCXVdNok)!)dbZ=Lx4bkC>WpaV45We1u`&{RNGnV<=t2*@MRp`7?{%g*GY35W_P4&Z*53QMRIUAT_kD2r*?9X}`=2^~?A?p_%hP-SdELa+&wS;s*dk-N!RBjsEN{lin{mei$=Iwr zRyNCdE!zZ9^*OhzWR6|UlE^hLT;eMdhQDYipLZ%OxGNZoLJ7$Stl?+f+%6UQXf-b? z%9B(q<&ke9d92hrsKgg}ZpKnt#U81U1NWDDC{I$clt;}h2YV=w>WXu%?s0l7r>ui2 z_DUr=M^kzJ>!CcV2fkF6@~E|9kMds819!HTew*a0{w8hyJJPzPd8||q*0z*K^~YHk z?BX5;?*!qmPEcxi_VV8g4Jo+76#c*%RRf$+`-!#IK|z?I?_nzb%+atUjE24l4ZHdF zu`kad>nm%%{haG}DDaJQE5AGRgDG@S5cY^U