Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Mar 6, 2024
1 parent ed04b5c commit 2023f17
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.crschnick.pdxu.app.info.SavegameData;
import com.crschnick.pdxu.app.installation.GameFileContext;
import com.crschnick.pdxu.app.util.CascadeDirectoryHelper;
import com.crschnick.pdxu.app.util.ImageHelper;
import com.crschnick.pdxu.io.node.Node;
import com.crschnick.pdxu.io.parser.TextFormatParser;
import com.crschnick.pdxu.model.GameColor;
Expand Down Expand Up @@ -59,6 +60,10 @@ static Map<String, javafx.scene.paint.Color> getPredefinedColors(GameFileContext
}

public static Image realmImage(SavegameData<Ck3Tag> data, Ck3Tag tag) {
if (data == null) {
return ImageHelper.DEFAULT_IMAGE;
}

var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class);
var cachedImg = cache.realms.get(tag);
if (cachedImg != null) {
Expand All @@ -72,6 +77,10 @@ public static Image realmImage(SavegameData<Ck3Tag> data, Ck3Tag tag) {
}

public static Image houseImage(Ck3House house, GameFileContext ctx) {
if (house == null) {
return ImageHelper.DEFAULT_IMAGE;
}

var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class);
var cachedImg = cache.houses.get(house);
if (cachedImg != null) {
Expand All @@ -83,6 +92,10 @@ public static Image houseImage(Ck3House house, GameFileContext ctx) {
}

public static Image titleImage(Ck3Title title, GameFileContext ctx) {
if (title == null) {
return ImageHelper.DEFAULT_IMAGE;
}

var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class);
var cachedImg = cache.titles.get(title);
if (cachedImg != null) {
Expand Down

0 comments on commit 2023f17

Please sign in to comment.