CardDb: be permissive when loading xmls
This commit is contained in:
parent
f217551f5f
commit
ce56e5f1a4
1 changed files with 13 additions and 1 deletions
|
@ -463,6 +463,10 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||||
setType = xml.readElementText();
|
setType = xml.readElementText();
|
||||||
else if (xml.name() == "releasedate")
|
else if (xml.name() == "releasedate")
|
||||||
releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate);
|
releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate);
|
||||||
|
else if (xml.name() != "") {
|
||||||
|
qDebug() << "[XMLReader] Unknown set property" << xml.name() << ", trying to continue anyway";
|
||||||
|
xml.skipCurrentElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CardSet * newSet = getSet(shortName);
|
CardSet * newSet = getSet(shortName);
|
||||||
|
@ -530,6 +534,10 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
loyalty = xml.readElementText().toInt();
|
loyalty = xml.readElementText().toInt();
|
||||||
else if (xml.name() == "token")
|
else if (xml.name() == "token")
|
||||||
isToken = xml.readElementText().toInt();
|
isToken = xml.readElementText().toInt();
|
||||||
|
else if (xml.name() != "") {
|
||||||
|
qDebug() << "[XMLReader] Unknown card property" << xml.name() << ", trying to continue anyway";
|
||||||
|
xml.skipCurrentElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids));
|
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids));
|
||||||
|
@ -559,7 +567,7 @@ LoadStatus CardDatabase::loadFromFile(const QString &fileName)
|
||||||
return Invalid;
|
return Invalid;
|
||||||
int version = xml.attributes().value("version").toString().toInt();
|
int version = xml.attributes().value("version").toString().toInt();
|
||||||
if (version < versionNeeded) {
|
if (version < versionNeeded) {
|
||||||
qDebug() << "loadFromFile(): Version too old: " << version;
|
qDebug() << "[XMLReader] Version too old: " << version;
|
||||||
return VersionTooOld;
|
return VersionTooOld;
|
||||||
}
|
}
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
|
@ -569,6 +577,10 @@ LoadStatus CardDatabase::loadFromFile(const QString &fileName)
|
||||||
loadSetsFromXml(xml);
|
loadSetsFromXml(xml);
|
||||||
else if (xml.name() == "cards")
|
else if (xml.name() == "cards")
|
||||||
loadCardsFromXml(xml);
|
loadCardsFromXml(xml);
|
||||||
|
else if (xml.name() != "") {
|
||||||
|
qDebug() << "[XMLReader] Unknown item" << xml.name() << ", trying to continue anyway";
|
||||||
|
xml.skipCurrentElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue