From 33dafa77d8c57266c11ee042feb514da70e68c72 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 20 Jan 2018 23:12:25 -0500 Subject: [PATCH] Fixed some block renderer and editor crashes --- core/src/io/anuke/mindustry/graphics/BlockRenderer.java | 8 ++++++++ core/src/io/anuke/mindustry/mapeditor/DrawOperation.java | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 5540e72dde..f3f7bcb603 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -246,6 +246,10 @@ public class BlockRenderer{ } void cacheChunk(int cx, int cy, boolean floor){ + if(cbatch == null){ + createBatch(); + } + cbatch.begin(); Graphics.useBatch(cbatch); @@ -268,6 +272,10 @@ public class BlockRenderer{ public void clearTiles(){ cache = null; + createBatch(); + } + + private void createBatch(){ if(cbatch != null) cbatch.dispose(); cbatch = new CacheBatch(Vars.world.width() * Vars.world.height() * 4); diff --git a/core/src/io/anuke/mindustry/mapeditor/DrawOperation.java b/core/src/io/anuke/mindustry/mapeditor/DrawOperation.java index 5522030b95..aa66e65858 100755 --- a/core/src/io/anuke/mindustry/mapeditor/DrawOperation.java +++ b/core/src/io/anuke/mindustry/mapeditor/DrawOperation.java @@ -17,11 +17,11 @@ public class DrawOperation implements Disposable{ } public void undo() { - pixmap.drawPixmap(from, 0, 0); + if(from != null) pixmap.drawPixmap(from, 0, 0); } public void redo() { - pixmap.drawPixmap(to, 0, 0); + if(to != null) pixmap.drawPixmap(to, 0, 0); } @Override