diff --git a/include/project.h b/include/project.h index 20458dbe..9873c60f 100644 --- a/include/project.h +++ b/include/project.h @@ -130,7 +130,7 @@ public: QStringList getVisibilities(); QMap getTilesetLabels(); void readTilesetProperties(); - void readRegionMapSections(); + bool readRegionMapSections(); void readItemNames(); void readFlagNames(); void readVarNames(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 468ef0de..20cd5b90 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -597,11 +597,11 @@ void MainWindow::on_checkBox_AllowEscapeRope_clicked(bool checked) bool MainWindow::loadDataStructures() { Project *project = editor->project; - bool success = project->readMapLayouts(); + bool success = project->readMapLayouts() + && project->readRegionMapSections(); if (!success) { return false; } - project->readRegionMapSections(); project->readItemNames(); project->readFlagNames(); project->readVarNames(); diff --git a/src/project.cpp b/src/project.cpp index c3bded77..c5bee579 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1728,15 +1728,22 @@ void Project::readTilesetProperties() { } } -void Project::readRegionMapSections() { +bool Project::readRegionMapSections() { this->mapSectionNameToValue.clear(); this->mapSectionValueToName.clear(); QStringList prefixes = (QStringList() << "MAPSEC_"); - this->mapSectionNameToValue = parser.readCDefines("include/constants/region_map_sections.h", prefixes); + QString filename = "include/constants/region_map_sections.h"; + this->mapSectionNameToValue = parser.readCDefines(filename, prefixes); + if (this->mapSectionNameToValue.isEmpty()) { + logError(QString("Failed to read region map sections from %1.").arg(filename)); + return false; + } + for (QString defineName : this->mapSectionNameToValue.keys()) { this->mapSectionValueToName.insert(this->mapSectionNameToValue[defineName], defineName); } + return true; } void Project::readHealLocations() {