Skip to content

Commit bb595fe

Browse files
committed
NullPointer check.
1 parent 0ac71ea commit bb595fe

File tree

1 file changed

+16
-16
lines changed
  • blade-engine/src/com/bladecoder/engine/model

1 file changed

+16
-16
lines changed

blade-engine/src/com/bladecoder/engine/model/Scene.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public class Scene implements Serializable, AssetConsumer {
104104
private final TextManager textManager;
105105

106106
private World w;
107-
107+
108108
/** The current walkzone actor */
109109
private String walkZone;
110110

@@ -299,7 +299,7 @@ public void drawBBoxLines(ShapeRenderer renderer) {
299299

300300
public BaseActor getActor(String id, boolean searchInventory) {
301301

302-
if (VAR_PLAYER.equals(id))
302+
if (VAR_PLAYER.equals(id) && player != null)
303303
return actors.get(player);
304304

305305
BaseActor a = id == null ? null : actors.get(id);
@@ -579,11 +579,11 @@ public SpriteActor getCameraFollowActor() {
579579
public SceneSoundManager getSoundManager() {
580580
return soundManager;
581581
}
582-
582+
583583
public void calcWalkzone() {
584584
if (walkZone != null) {
585585
polygonalNavGraph.createInitialGraph(actors.get(walkZone), actors.values());
586-
}
586+
}
587587
}
588588

589589
@Override
@@ -604,7 +604,7 @@ public void loadAssets() {
604604
// CALC WALK GRAPH
605605
calcWalkzone();
606606
}
607-
607+
608608
@Override
609609
public void retrieveAssets() {
610610

@@ -737,7 +737,7 @@ public void write(Json json) {
737737

738738
if (player != null)
739739
json.writeValue("player", player);
740-
740+
741741
json.writeValue("walkZone", walkZone);
742742
}
743743

@@ -771,29 +771,29 @@ public void read(Json json, JsonValue jsonData) {
771771
musicDesc = json.readValue("musicDesc", MusicDesc.class, jsonData);
772772

773773
depthVector = json.readValue("depthVector", Vector2.class, jsonData);
774-
775-
if(jsonData.get("polygonalNavGraph") != null) {
776-
774+
775+
if (jsonData.get("polygonalNavGraph") != null) {
776+
777777
JsonValue jsonValuePNG = jsonData.get("polygonalNavGraph");
778-
778+
779779
float worldScale = EngineAssetManager.getInstance().getScale();
780780

781781
Polygon walkZonePol = json.readValue("walkZone", Polygon.class, jsonValuePNG);
782782
walkZonePol.setScale(worldScale, worldScale);
783783
walkZonePol.setPosition(walkZonePol.getX() * worldScale, walkZonePol.getY() * worldScale);
784-
784+
785785
WalkZoneActor wz = new WalkZoneActor();
786786
wz.setId("walkzone");
787787
wz.bbox.setVertices(walkZonePol.getVertices());
788788
wz.bbox.setScale(walkZonePol.getScaleX(), walkZonePol.getScaleY());
789-
wz.bbox.setPosition(walkZonePol.getX(), walkZonePol.getY());
789+
wz.bbox.setPosition(walkZonePol.getX(), walkZonePol.getY());
790790
wz.setScene(this);
791791
wz.setInitScene(id);
792-
792+
793793
actors.put(wz.getId(), wz);
794794
walkZone = wz.getId();
795795
}
796-
796+
797797
sceneSize = json.readValue("sceneSize", Vector2.class, jsonData);
798798

799799
} else {
@@ -849,8 +849,8 @@ public void read(Json json, JsonValue jsonData) {
849849
verbs.read(json, jsonData);
850850
state = json.readValue("state", String.class, jsonData);
851851
player = json.readValue("player", String.class, jsonData);
852-
853-
if(jsonData.get("walkZone") != null)
852+
853+
if (jsonData.get("walkZone") != null)
854854
walkZone = json.readValue("walkZone", String.class, jsonData);
855855
}
856856
}

0 commit comments

Comments
 (0)