From: fred-boy Date: Wed, 25 Apr 2018 14:35:12 +0000 (+0700) Subject: Fix NPE after loading game X-Git-Tag: alpha0.4~99 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=e14d8af238926a5cbfc067cfc9a9b032e51f1cac;p=cavedroid.git Fix NPE after loading game --- diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 648e785..38c79f1 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -54,7 +54,7 @@ public class GameRenderer extends Renderer { if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight(); for (int y=minY; y0) { + if (gameProc.world.getForeMap(x,y)>0 && !Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).background) { spriteBatch.draw( Assets.blockTextures[Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture()], x * 16 - camera.position.x,y * 16 - camera.position.y); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index aab81f5..2b5b906 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -2,6 +2,7 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.utils.ArrayMap; import ru.deadsoftware.cavecraft.CaveGame; import java.io.*; @@ -78,6 +79,7 @@ public class GameSaver { loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav")), loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav")) ); + gameProc.world.metaMap = new ArrayMap(); gameProc.physics = new GamePhysics(gameProc); gameProc.resetRenderer(); } catch (Exception e) { diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index fc0c247..5f5a407 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -8,7 +8,7 @@ public class GameWorld { private int WIDTH, HEIGHT; - private ArrayMap metaMap; + public ArrayMap metaMap; private int[][] foreMap; private int[][] backMap;