Fix crash if region map tileset is missing

This commit is contained in:
GriffinR 2024-06-17 11:38:01 -04:00
parent 0954fe26ff
commit 4a79114b98
2 changed files with 8 additions and 12 deletions

View file

@ -79,14 +79,20 @@ bool RegionMap::loadTilemap(poryjson::Json tilemapJson) {
this->palette_path = tilemapObject["palette"].string_value(); 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)); QFile tilemapFile(fullPath(this->tilemap_path));
if (!tilemapFile.open(QIODevice::ReadOnly)) { 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; return false;
} }
if (tilemapFile.size() < tilemapBytes()) { 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; return false;
} }

View file

@ -402,16 +402,6 @@ bool RegionMapEditor::verifyConfig(poryjson::Json cfg) {
logError("Region map config json has no map list."); logError("Region map config json has no map list.");
return false; 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; return true;
} }