Skip to content

Commit

Permalink
Merge pull request #1303 from RPTools/rel-1.5.13
Browse files Browse the repository at this point in the history
Pull changes from Release 1.5.13 back to develop.
  • Loading branch information
Phergus authored Feb 21, 2020
2 parents 7ad676c + ca1261c commit 5f448a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
18 changes: 18 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ Maptool 1.6.0
[i891]: https://github.com/RPTools/maptool/issues/891
[i221]: https://github.com/RPTools/maptool/issues/221

Maptool 1.5.13
=====
**Highlights**
- Bug fix release to correct several JSON related issues.

**Bug Fixes**
- [#1296][i1296] Exception thrown when trying to read Hero Lab .por files that are missing the XML statblock. Exception caught and error reported.
- [#1236][i1236] `getTokens/getTokenNames()` was failing if `setState` or `unsetState` options were used. Fixed.
- [#1228][i1228] `getLastPath()` and other token move functions that made use of pathPointsToJsonArray were broken. Fixed.
- [#1206][i1206] Unknown json functions would return null instead of an error. Fixed.
- [#1204][i1204] Layer condition of `getTokens/getTokenNames()` weren't accepting accepting a string for a single layer. Fixed.

[i1296]: https://github.com/RPTools/maptool/issues/1296
[i1236]: https://github.com/RPTools/maptool/issues/1236
[i1228]: https://github.com/RPTools/maptool/issues/1228
[i1206]: https://github.com/RPTools/maptool/issues/1206
[i1204]: https://github.com/RPTools/maptool/issues/1204

Maptool 1.5.11/12
=====
**Highlights**
Expand Down
30 changes: 23 additions & 7 deletions src/main/java/net/rptools/maptool/util/ExtractHeroLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@
* @author Jamz
*/
public final class ExtractHeroLab {

private static final File tmpDir = AppUtil.getTmpDir();
private File finalTempDir;
private File extractComplete;
private File portfolioFile;
private static final String MISSING_XML_ERROR_MESSAGE =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<error>\n XML Data is missing from Hero Lab portfolio.\n Contact LWD Technology support at https://www.wolflair.com\n</error>";
private final File finalTempDir;
private final File extractComplete;
private final File portfolioFile;

private DocumentBuilderFactory factory;
private DocumentBuilder builder;
Expand Down Expand Up @@ -122,8 +125,11 @@ private File validatePortfolioFile(File heroLabPortfolio) {
}

private boolean isExtracted() {
if (extractComplete.exists()) return true;
else return false;
if (extractComplete.exists()) {
return true;
} else {
return false;
}
}

private void markComplete() {
Expand Down Expand Up @@ -280,7 +286,9 @@ public HeroLabData refreshCharacter(HeroLabData heroLabData) {

// Ugg, @herolableadindex is always 0 for all minions :(
String minionCriteria = "";
if (heroLabData.isMinion()) minionCriteria = "' and @name='" + heroLabData.getName();
if (heroLabData.isMinion()) {
minionCriteria = "' and @name='" + heroLabData.getName();
}

XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
Expand Down Expand Up @@ -428,6 +436,13 @@ private HashMap<String, HashMap<String, String>> getStatBlocks(
try {
xmlStatBlock = getXmlFromZip(zipPath);

// This shouldn't happen but unsupported running of Hero Lab on Linux via Wine can cause this
if (xmlStatBlock == null) {
xmlStatBlockMap.put("data", MISSING_XML_ERROR_MESSAGE);
statBlocks.put(HeroLabData.StatBlockType.XML, xmlStatBlockMap);
return statBlocks;
}

if (master == null) {
// We don't need the minion data in the main character so we will remove that
// node to save space
Expand Down Expand Up @@ -500,11 +515,12 @@ private String getStatBlockPath(XPath xpath, Node hero, String type) {
XPathExpression xPath_statBlock =
xpath.compile("statblocks/statblock[@format='" + type + "']");
Node statBlockNode = (Node) xPath_statBlock.evaluate(hero, XPathConstants.NODE);
if (statBlockNode != null)
if (statBlockNode != null) {
path =
((Element) statBlockNode).getAttribute("folder")
+ "/"
+ ((Element) statBlockNode).getAttribute("filename");
}
} catch (XPathExpressionException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 5f448a0

Please sign in to comment.