From bee83a3a3ed9b5249b3a9d8af6bf706cf1f5e41c Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 21 Sep 2018 14:01:00 -0400 Subject: [PATCH] Sector expansion functional --- core/src/io/anuke/mindustry/maps/Sectors.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/io/anuke/mindustry/maps/Sectors.java b/core/src/io/anuke/mindustry/maps/Sectors.java index 4b0c82eda8..373a6bba59 100644 --- a/core/src/io/anuke/mindustry/maps/Sectors.java +++ b/core/src/io/anuke/mindustry/maps/Sectors.java @@ -80,8 +80,6 @@ public class Sectors{ * @param expandX spaces in X coordinate to expand, can be negative * @param expandY spaces in Y coordinate to expand, can be negative*/ public boolean expandSector(Sector sector, int expandX, int expandY){ - sector.width += expandX; - sector.height += expandY; //remove old sector data to clear things up for(int x = sector.x; x < sector.x+sector.width; x++){ @@ -131,11 +129,9 @@ public class Sectors{ //create *new* tile array Tile[][] newTiles = new Tile[sector.width * sectorSize][sector.height * sectorSize]; - world.beginMapLoad(newTiles); - //shift existing tiles to new array - for (int x = 0; x < (sector.width - Math.abs(expandX)); x++) { - for (int y = 0; y < (sector.height - Math.abs(expandY)); y++) { + for (int x = 0; x < (sector.width - Math.abs(expandX))*sectorSize; x++) { + for (int y = 0; y < (sector.height - Math.abs(expandY))*sectorSize; y++) { Tile tile = world.rawTile(x, y); tile.x = (short)(x + shiftX); tile.y = (short)(y + shiftY); @@ -143,6 +139,8 @@ public class Sectors{ } } + world.beginMapLoad(newTiles); + //create new tiles for (int sx = 0; sx < sector.width; sx++) { for (int sy = 0; sy < sector.height; sy++) {