Validate region map sections

This commit is contained in:
Marcus Huderle 2020-02-12 08:12:12 -06:00
parent 79c74b8814
commit a152404ce8
3 changed files with 12 additions and 5 deletions

View file

@ -130,7 +130,7 @@ public:
QStringList getVisibilities(); QStringList getVisibilities();
QMap<QString, QStringList> getTilesetLabels(); QMap<QString, QStringList> getTilesetLabels();
void readTilesetProperties(); void readTilesetProperties();
void readRegionMapSections(); bool readRegionMapSections();
void readItemNames(); void readItemNames();
void readFlagNames(); void readFlagNames();
void readVarNames(); void readVarNames();

View file

@ -597,11 +597,11 @@ void MainWindow::on_checkBox_AllowEscapeRope_clicked(bool checked)
bool MainWindow::loadDataStructures() { bool MainWindow::loadDataStructures() {
Project *project = editor->project; Project *project = editor->project;
bool success = project->readMapLayouts(); bool success = project->readMapLayouts()
&& project->readRegionMapSections();
if (!success) { if (!success) {
return false; return false;
} }
project->readRegionMapSections();
project->readItemNames(); project->readItemNames();
project->readFlagNames(); project->readFlagNames();
project->readVarNames(); project->readVarNames();

View file

@ -1728,15 +1728,22 @@ void Project::readTilesetProperties() {
} }
} }
void Project::readRegionMapSections() { bool Project::readRegionMapSections() {
this->mapSectionNameToValue.clear(); this->mapSectionNameToValue.clear();
this->mapSectionValueToName.clear(); this->mapSectionValueToName.clear();
QStringList prefixes = (QStringList() << "MAPSEC_"); 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()) { for (QString defineName : this->mapSectionNameToValue.keys()) {
this->mapSectionValueToName.insert(this->mapSectionNameToValue[defineName], defineName); this->mapSectionValueToName.insert(this->mapSectionNameToValue[defineName], defineName);
} }
return true;
} }
void Project::readHealLocations() { void Project::readHealLocations() {