Restore Dynamic map error checks

This commit is contained in:
GriffinR 2025-03-17 23:56:25 -04:00
parent 8dcb66ca52
commit a406f4c210

View File

@ -1757,10 +1757,8 @@ bool Project::readMapGroups() {
QJsonObject mapGroupsObj = mapGroupsDoc.object();
QJsonArray mapGroupOrder = mapGroupsObj["group_order"].toArray();
// Save special "Dynamic" constant
const QString dynamicMapName = getDynamicMapName();
this->mapConstantsToMapNames.insert(getDynamicMapDefineName(), dynamicMapName);
this->mapNames.append(dynamicMapName);
const QString dynamicMapConstant = getDynamicMapDefineName();
// Process the map group lists
QStringList failedMapNames;
@ -1772,6 +1770,11 @@ bool Project::readMapGroups() {
// Process the names in this map group
for (int j = 0; j < mapNamesJson.size(); j++) {
const QString mapName = ParseUtil::jsonToQString(mapNamesJson.at(j));
if (mapName == dynamicMapName) {
logWarn(QString("Ignoring map with reserved name '%1'.").arg(mapName));
failedMapNames.append(mapName);
continue;
}
if (this->mapNames.contains(mapName)) {
logWarn(QString("Ignoring repeated map name '%1'.").arg(mapName));
failedMapNames.append(mapName);
@ -1793,6 +1796,11 @@ bool Project::readMapGroups() {
failedMapNames.append(mapName);
continue;
}
if (mapConstant == dynamicMapConstant) {
logWarn(QString("Ignoring map with reserved \"id\" value '%1'.").arg(mapName));
failedMapNames.append(mapName);
continue;
}
const QString expectedPrefix = projectConfig.getIdentifier(ProjectIdentifier::define_map_prefix);
if (!mapConstant.startsWith(expectedPrefix)) {
logWarn(QString("Map '%1' has invalid \"id\" value '%2' and will be ignored. Value must begin with '%3'.").arg(mapName).arg(mapConstant).arg(expectedPrefix));
@ -1846,6 +1854,10 @@ bool Project::readMapGroups() {
emit mapsExcluded(failedMapNames);
}
// Save special "Dynamic" constant
this->mapConstantsToMapNames.insert(dynamicMapConstant, dynamicMapName);
this->mapNames.append(dynamicMapName);
return true;
}