fix: mod parsing of 'String-fied' version (i.e. OpenBlocks)

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-17 11:21:43 -03:00
parent 4e6978ff6f
commit a53ee2e35c
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -4,6 +4,7 @@
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QString>
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <toml.h>
@ -71,7 +72,13 @@ std::shared_ptr<ModDetails> ReadMCModInfo(QByteArray contents)
if(val.isUndefined()) {
val = jsonDoc.object().value("modListVersion");
}
int version = val.toDouble();
int version = Json::ensureInteger(val, -1);
// Some mods set the number with "", so it's a String instead
if (version < 0)
version = Json::ensureString(val, "").toInt();
if (version != 2)
{
qCritical() << "BAD stuff happened to mod json:";