improve tileset label reading to silence unnecessary warnings

This commit is contained in:
garak 2019-05-05 11:45:03 -04:00 committed by huderlem
parent eb3964bcc3
commit 54e431617f

View file

@ -1407,24 +1407,19 @@ QMap<QString, QStringList> Project::getTilesetLabels() {
allTilesets.insert("primary", primaryTilesets); allTilesets.insert("primary", primaryTilesets);
allTilesets.insert("secondary", secondaryTilesets); allTilesets.insert("secondary", secondaryTilesets);
QString headers_text = readTextFile(root + "/data/tilesets/headers.inc"); QString headers_text = readTextFile(root + "/data/tilesets/headers.inc");
QList<QStringList>* commands = parseAsm(headers_text);
int i = 0;
while (i < commands->length()) {
if (commands->at(i).length() != 2)
continue;
if (commands->at(i).at(0) == ".label") { QRegularExpression re("(?<label>[A-Za-z0-9_]*):{1,2}[A-Za-z0-9_@ ]*\\s+.+\\s+\\.byte\\s+(?<isSecondary>[A-Za-z0-9_]+)");
QString tilesetLabel = commands->at(i).at(1); QRegularExpressionMatchIterator iter = re.globalMatch(headers_text);
// Advance to command specifying whether or not it is a secondary tileset
i += 2;
if (commands->at(i).at(0) != ".byte") {
logWarn(QString("Unexpected command found for secondary tileset flag in tileset '%1'. Expected '.byte', but found: '%2'").arg(tilesetLabel).arg(commands->at(i).at(0)));
continue;
}
QString secondaryTilesetValue = commands->at(i).at(1); while (iter.hasNext()) {
if (secondaryTilesetValue != "TRUE" && secondaryTilesetValue != "FALSE" && secondaryTilesetValue != "0" && secondaryTilesetValue != "1") { QRegularExpressionMatch match = iter.next();
logWarn(QString("Unexpected secondary tileset flag found. Expected \"TRUE\", \"FALSE\", \"0\", or \"1\", but found: '%1'").arg(secondaryTilesetValue)); QString tilesetLabel = match.captured("label");
QString secondaryTilesetValue = match.captured("isSecondary");
if (secondaryTilesetValue != "1" && secondaryTilesetValue != "TRUE"
&& secondaryTilesetValue != "0" && secondaryTilesetValue != "FALSE") {
logWarn(QString("Unexpected secondary tileset flag found."
"Expected \"TRUE\", \"FALSE\", \"0\", or \"1\", but found: '%1'").arg(secondaryTilesetValue));
continue; continue;
} }
@ -1435,9 +1430,6 @@ QMap<QString, QStringList> Project::getTilesetLabels() {
allTilesets["primary"].append(tilesetLabel); allTilesets["primary"].append(tilesetLabel);
} }
i++;
}
return allTilesets; return allTilesets;
} }