Small bug fixes (started ignoring case for Spawn Group lookup, like in

the game; avoid NPE in Dialogue parser).
This commit is contained in:
Zukero
2015-10-30 12:50:03 +01:00
parent 6118fc39d8
commit f5c454807c
4 changed files with 24 additions and 3 deletions

View File

@@ -522,6 +522,13 @@ public class Project implements ProjectTreeNode, Serializable {
return gde;
}
public NPC getNPCIgnoreCase(String id) {
NPC gde = createdContent.gameData.getNPCIgnoreCase(id);
if (gde == null) gde = alteredContent.gameData.getNPCIgnoreCase(id);
if (gde == null) gde = baseContent.gameData.getNPCIgnoreCase(id);
return gde;
}
public int getNPCCount() {
return createdContent.gameData.npcs.size() + baseContent.gameData.npcs.size();
}
@@ -833,7 +840,7 @@ public class Project implements ProjectTreeNode, Serializable {
int index = -1;
while (--i >= 0) {
NPC npc = getNPC(i);
if (spawngroup_id.equals(npc.spawngroup_id)) {
if (spawngroup_id.equalsIgnoreCase(npc.spawngroup_id)) {
for (NPC present : result) {
if (present.id.equals(npc.id)) {
alreadyAdded = true;
@@ -851,7 +858,7 @@ public class Project implements ProjectTreeNode, Serializable {
}
if (result.isEmpty()) {
//Fallback case. A single NPC does not declare a spawn group, but is referred by its ID in maps' spawn areas.
NPC npc = getNPC(spawngroup_id);
NPC npc = getNPCIgnoreCase(spawngroup_id);
if (npc != null) result.add(npc);
}
return result;

View File

@@ -171,7 +171,7 @@ public class Dialogue extends JSONElement {
requirement.parent = this;
if (requirementJson.get("requireType") != null) requirement.type = RequirementType.valueOf((String) requirementJson.get("requireType"));
requirement.required_obj_id = (String) requirementJson.get("requireID");
requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
if (requirementJson.get("value") != null) requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
if (requirementJson.get("negate") != null) requirement.negated = (Boolean) requirementJson.get("negate");
requirement.state = State.parsed;
reply.requirements.add(requirement);

View File

@@ -212,6 +212,16 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
return null;
}
public NPC getNPCIgnoreCase(String id) {
if (npcs == null) return null;
for (NPC gde : npcs) {
if (id.equalsIgnoreCase(gde.id)){
return gde;
}
}
return null;
}
public Quest getQuest(String id) {
if (quests == null) return null;
for (Quest gde : quests) {

View File

@@ -102,6 +102,10 @@ public class WorldMapEditor extends Editor {
return pane;
}
public void updateXmlViewText(String text) {
editorPane.setText(text);
}
private JPanel buildSegmentTab(final WorldmapSegment worldmap) {
JPanel pane = new JPanel();