Skip to content

Commit

Permalink
AURORA: Handle special cases in stock NWN2 XML files
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshae authored and DrMcCoy committed Oct 28, 2018
1 parent b9301df commit eba8a11
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/aurora/xmlfixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ Common::UString XMLFixer::fixXMLValue(const Common::UString value) {

// Bypass if line is empty
if (line.size() > 0) {
// Handle unique issues
if (isFixSpecialCase(&line))
return line;

// Check for a function
it = line.findFirst('(');
if (it != line.end())
line = fixFunction(line, it);
Expand All @@ -186,10 +191,39 @@ Common::UString XMLFixer::fixXMLValue(const Common::UString value) {
return "\"" + line + "\"" + tag;
}

/**
* Address special issues found in specific NWN2 XML files
* by looking for exact matches to the problematic value
* strings then correcting the value on a match.
*/
bool XMLFixer::isFixSpecialCase(Common::UString *value) {
bool isFix = false;
const int rows = 2;
const Common::UString swap[rows][2] = {
{ "truefontfamily",
"\"true\" fontfamily" }, // examine.xml
{ "Character\"fontfamily",
"\"Character\" fontfamily" }, // multiplayer_downloadx2.xml
};

// Loop through the array
for (int i = 0; i < rows; i++) {
if (*value == swap[i][0]) {
// The strings match, so swap in the correction
*value = swap[i][1];
isFix = true;
break;
}
}

return isFix;
}

/**
* Fix a function call
*/
Common::UString XMLFixer::fixFunction(const Common::UString line, const Common::UString::iterator it) {
Common::UString XMLFixer::fixFunction(const Common::UString value, const Common::UString::iterator it) {
Common::UString line = value;
return line; // TODO
}

Expand Down
1 change: 1 addition & 0 deletions src/aurora/xmlfixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class XMLFixer {

bool isTagClose(const Common::UString value);
bool isValidXMLHeader(Common::SeekableReadStream &in);
bool isFixSpecialCase(Common::UString *value);
void readXMLStream(Common::SeekableReadStream &in, ElementList *elements);
Common::UString fixXMLElement(const Common::UString element);
Common::UString fixXMLValue(const Common::UString value);
Expand Down

0 comments on commit eba8a11

Please sign in to comment.