Fix crash if region map tileset is missing
This commit is contained in:
parent
0954fe26ff
commit
4a79114b98
2 changed files with 8 additions and 12 deletions
|
@ -79,14 +79,20 @@ bool RegionMap::loadTilemap(poryjson::Json tilemapJson) {
|
|||
this->palette_path = tilemapObject["palette"].string_value();
|
||||
}
|
||||
|
||||
QFileInfo tilesetFileInfo(fullPath(this->tileset_path));
|
||||
if (!tilesetFileInfo.exists() || !tilesetFileInfo.isFile()) {
|
||||
logError(QString("Failed to open region map tileset file '%1'.").arg(tileset_path));
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile tilemapFile(fullPath(this->tilemap_path));
|
||||
if (!tilemapFile.open(QIODevice::ReadOnly)) {
|
||||
logError(QString("Failed to open region map tilemap file %1.").arg(tilemap_path));
|
||||
logError(QString("Failed to open region map tilemap file '%1'.").arg(tilemap_path));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tilemapFile.size() < tilemapBytes()) {
|
||||
logError(QString("The region map tilemap at %1 is too small.").arg(tilemap_path));
|
||||
logError(QString("The region map tilemap at '%1' is too small.").arg(tilemap_path));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -402,16 +402,6 @@ bool RegionMapEditor::verifyConfig(poryjson::Json cfg) {
|
|||
logError("Region map config json has no map list.");
|
||||
return false;
|
||||
}
|
||||
|
||||
OrderedJson::array arr = obj["region_maps"].array_items();
|
||||
|
||||
for (auto ref : arr) {
|
||||
RegionMap tempMap(this->project);
|
||||
if (!tempMap.loadMapData(ref)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue