From c8de0c8f77f7bf633cd51d4f0dd76cd20fa5c225 Mon Sep 17 00:00:00 2001 From: Oskar Wiksten Date: Fri, 29 Mar 2013 20:03:33 +0100 Subject: [PATCH] Minor bugfixes to resource loaders * Fail harder when TileManager hasn't allocated enough tiles for the preloaded icons. * Minor tweak to misplaced tile on hauntedhouse3 * Weaken "strength" condition (prefer to control effect through magnitude instead) * Load icons for "items_weapons_2". * Do not require items to have "base market cost" (for example, when they are automatically priced) --- AndorsTrail/res/raw/actorconditions_v069.json | 4 +- AndorsTrail/res/xml/hauntedhouse3.tmx | 83 +++++++++---------- .../conversation/ConversationCollection.java | 5 +- .../conversation/ConversationLoader.java | 5 +- .../model/item/ItemTypeCollection.java | 1 + .../AndorsTrail/resource/ResourceLoader.java | 1 + .../resource/parsers/ItemTypeParser.java | 2 +- .../resource/parsers/ResourceParserUtils.java | 5 +- .../resource/tiles/TileManager.java | 3 +- 9 files changed, 59 insertions(+), 50 deletions(-) diff --git a/AndorsTrail/res/raw/actorconditions_v069.json b/AndorsTrail/res/raw/actorconditions_v069.json index 279f5ce8d..835391f71 100644 --- a/AndorsTrail/res/raw/actorconditions_v069.json +++ b/AndorsTrail/res/raw/actorconditions_v069.json @@ -30,8 +30,8 @@ "isPositive": 1, "abilityEffect": { "increaseAttackDamage": { - "min": 2, - "max": 2 + "min": 1, + "max": 1 } } }, diff --git a/AndorsTrail/res/xml/hauntedhouse3.tmx b/AndorsTrail/res/xml/hauntedhouse3.tmx index fba65f23a..b27bc6100 100644 --- a/AndorsTrail/res/xml/hauntedhouse3.tmx +++ b/AndorsTrail/res/xml/hauntedhouse3.tmx @@ -1,129 +1,128 @@ - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - eJydVcENgzAMjIrUKbICdISEESgrdFhG6Qh9tohYOlk+2+rjxINzzj4fod9K6QNLAt1AVPMEtKB2VXzBHGi8Bt5TKZuhKbzHDzvwEZYG9nncL3ym64m1G9SvwNXQGjjv7NRhvczAON68ol8BWHv6JxpeHziv5rJdoX8ZDTwrq4HeWxrWWS2p0cf5u6PB+kW/mIZkQe9Wa7B+mT5qSBZYrnS/nob2Osq+9d7yhOU8yv5C3rOdsJ1bM1f1TWU88XLFMog5y3hy7qkRX1FD7kXhWjnz5t8SuZR7UbhWzjwNb6cZ7j91+G1kz8YsZOr0HVUDsH9chv8FpO/wcw== + eJydVdsJwzAQMw10Cq+QdAQ7I6RZocNmlI7QzzbEB+I43R39EIVGsu6hOP1WSh9YEugGIs0T0ALtqviCOfB4DbynUjbDU3iPH3bgIywPrPO4X/hM1y9qN9CvwNXQHtjv7OhQLz0wjtev+FcAas/5iYdXB/aruWxXOL+MB56V9cDZWx7WWS3p0cf5u+PB6sV5MQ/Jgt6t9mD1Mn/8T7LAcqXr9Tz0rKPsW8+tmbCcR9lfyHO2E7Zzq+eq3qnMTLxcsQxizjIzOffUyFzRQ+5F4Vo58/rfErmUe1G4Vs48D2+nGe4/Onz/smdjFjI6fUfVAOwbl+F/AajT8HQ= diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationCollection.java index 4fdd0628f..9cef484d6 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationCollection.java @@ -15,7 +15,10 @@ public final class ConversationCollection { public static final String REPLY_NEXT = "N"; private final HashMap phrases = new HashMap(); - + + public boolean hasPhrase(String id) { + return phrases.containsKey(id); + } public Phrase getPhrase(String id) { if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { if (!phrases.containsKey(id)) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationLoader.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationLoader.java index 183a80fe1..97e0aff19 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationLoader.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/ConversationLoader.java @@ -16,8 +16,9 @@ public final class ConversationLoader { } public Phrase loadPhrase(String phraseID, ConversationCollection conversationCollection, Resources r) { - Phrase phrase = conversationCollection.getPhrase(phraseID); - if (phrase != null) return phrase; + if (conversationCollection.hasPhrase(phraseID)) { + return conversationCollection.getPhrase(phraseID); + } ConversationListParser conversationListParser = new ConversationListParser(); int resourceID = resourceIDsPerPhraseID.get(phraseID); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemTypeCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemTypeCollection.java index db4ff63d9..046d03817 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemTypeCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemTypeCollection.java @@ -15,6 +15,7 @@ public final class ItemTypeCollection { if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { if (!itemTypes.containsKey(id)) { L.log("WARNING: Cannot find ItemType for id \"" + id + "\"."); + return null; } } return itemTypes.get(id); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java index 44e7eb69e..a0fe44e3a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java @@ -245,6 +245,7 @@ public final class ResourceLoader { loader.prepareTileset(R.drawable.items_tometik2, "items_tometik2", new Size(10, 10), defaultTileSize); loader.prepareTileset(R.drawable.items_tometik3, "items_tometik3", new Size(8, 6), defaultTileSize); loader.prepareTileset(R.drawable.items_necklaces_1, "items_necklaces_1", new Size(10, 3), defaultTileSize); + loader.prepareTileset(R.drawable.items_weapons_2, "items_weapons_2", new Size(7, 1), defaultTileSize); loader.prepareTileset(R.drawable.items_weapons_3, "items_weapons_3", new Size(13, 5), defaultTileSize); loader.prepareTileset(R.drawable.items_armours_2, "items_armours_2", src_sz7x1, defaultTileSize); loader.prepareTileset(R.drawable.items_armours_3, "items_armours_3", new Size(10, 4), defaultTileSize); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ItemTypeParser.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ItemTypeParser.java index 0a9d5907e..5826f3ec0 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ItemTypeParser.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ItemTypeParser.java @@ -33,7 +33,7 @@ public final class ItemTypeParser extends JsonCollectionParserFor { final ItemTraits_OnUse hitEffect = itemTraitsParser.parseItemTraits_OnUse(o.optJSONObject(JsonFieldNames.ItemType.hitEffect)); final ItemTraits_OnUse killEffect = itemTraitsParser.parseItemTraits_OnUse(o.optJSONObject(JsonFieldNames.ItemType.killEffect)); - final int baseMarketCost = o.getInt(JsonFieldNames.ItemType.baseMarketCost); + final int baseMarketCost = o.optInt(JsonFieldNames.ItemType.baseMarketCost); final boolean hasManualPrice = o.optInt(JsonFieldNames.ItemType.hasManualPrice, 0) > 0; final ItemType itemType = new ItemType( id diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java index 2beb616ce..858736783 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java @@ -39,7 +39,10 @@ public final class ResourceParserUtils { public static ConstRange parseConstRange(JSONObject o) throws JSONException { if (o == null) return null; - return new ConstRange(o.getInt(JsonFieldNames.Range.max), o.getInt(JsonFieldNames.Range.min)); + return new ConstRange( + o.getInt(JsonFieldNames.Range.max), + o.optInt(JsonFieldNames.Range.min) + ); } public static final ConstRange always = one; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java index b4e84e159..e8b89853a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java @@ -62,7 +62,7 @@ public final class TileManager { public final TileCache tileCache = new TileCache(); - public final TileCollection preloadedTiles = new TileCollection(87); + public final TileCollection preloadedTiles = new TileCollection(94); public TileCollection currentMapTiles; public TileCollection adjacentMapTiles; private final HashSet preloadedTileIDs = new HashSet(); @@ -188,6 +188,7 @@ public final class TileManager { if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { if (maxTileID > preloadedTiles.maxTileID) { L.log("ERROR: TileManager.preloadedTiles needs to be initialized with at least " + maxTileID + " slots. Application will crash now."); + throw new IndexOutOfBoundsException("ERROR: TileManager.preloadedTiles needs to be initialized with at least " + maxTileID + " slots. Application will crash now."); } } for(int i = TileManager.CHAR_HERO; i <= maxTileID; ++i) {