From 4a79114b98ec7d07c1a4f286f48baec73581afc7 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 17 Jun 2024 11:38:01 -0400 Subject: [PATCH] Fix crash if region map tileset is missing --- src/core/regionmap.cpp | 10 ++++++++-- src/ui/regionmapeditor.cpp | 10 ---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/core/regionmap.cpp b/src/core/regionmap.cpp index 68da1fa7..9c66860b 100644 --- a/src/core/regionmap.cpp +++ b/src/core/regionmap.cpp @@ -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; } diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index 16ea4a5a..ee491a3e 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -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; }