Null checks & cleanup of upgrade pathing
This commit is contained in:
@@ -1162,11 +1162,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(diagonal){
|
||||
Tile start = world.tile(startX, startY);
|
||||
Tile end = world.tile(endX, endY);
|
||||
if(block != null && block instanceof Autotiler
|
||||
&& start.build instanceof ChainedBuilding && end.build instanceof ChainedBuilding
|
||||
&& block.canReplace(end.build.block) && block.canReplace(start.build.block)){
|
||||
var start = world.build(startX, startY);
|
||||
var end = world.build(endX, endY);
|
||||
if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding
|
||||
&& block.canReplace(end.block) && block.canReplace(start.block)){
|
||||
points = Placement.upgradeLine(startX, startY, endX, endY);
|
||||
}else{
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
|
||||
|
||||
@@ -5,7 +5,6 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
@@ -58,13 +57,12 @@ public class Placement{
|
||||
public static Seq<Point2> upgradeLine(int startX, int startY, int endX, int endY){
|
||||
Pools.freeAll(points);
|
||||
points.clear();
|
||||
Building building = world.tile(startX, startY).build;
|
||||
var build = world.build(startX, startY);
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(startX, startY));
|
||||
while(building.tile.x != endX || building.tile.y != endY){
|
||||
ChainedBuilding chained = (ChainedBuilding)building;
|
||||
if(chained.next() == null) return pathfindLine(true, startX, startY, endX, endY);
|
||||
building = chained.next();
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(building.tile.x, building.tile.y));
|
||||
while(build instanceof ChainedBuilding chain && (build.tile.x != endX || build.tile.y != endY)){
|
||||
if(chain.next() == null) return pathfindLine(true, startX, startY, endX, endY);
|
||||
build = chain.next();
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(build.tile.x, build.tile.y));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user