From 2a00e8aee95989caa69fcc40137d2bf1637e0a2b Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 12 Sep 2018 17:44:37 -0500 Subject: [PATCH] Fix bug when saving heal locations for maps with multiple heal locations --- project.cpp | 26 ++++++++------------------ project.h | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/project.cpp b/project.cpp index 61baae72..5bd0d2bb 100755 --- a/project.cpp +++ b/project.cpp @@ -514,36 +514,27 @@ void Project::saveHealLocationStruct(Map *map) { QMap flyableMapsDupes; QSet flyableMapsUnique; - // erase old location from flyableMaps list // set flyableMapsDupes and flyableMapsUnique - for (auto it = flyableMaps->begin(); it != flyableMaps->end(); it++) { + for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) { HealLocation loc = *it; QString xname = loc.name; if (flyableMapsUnique.contains(xname)) { flyableMapsDupes[xname] = 1; } - if (xname == QString(mapNamesToMapConstants->value(map->name)).remove(0,4)) { - it = flyableMaps->erase(it) - 1; - } - else { - flyableMapsUnique.insert(xname); - } + flyableMapsUnique.insert(xname); } // set new location in flyableMapsList if (map->events["heal_event_group"].length() > 0) { - QList* flymaps = flyableMaps; - for (Event *heal : map->events["heal_event_group"]) { HealLocation hl = heal->buildHealLocation(); - flymaps->insert(hl.index - 1, hl); + flyableMaps[hl.index - 1] = hl; } - flyableMaps = flymaps; } int i = 1; - for (auto map_in : *flyableMaps) { + for (auto map_in : flyableMaps) { data_text += QString(" {MAP_GROUP(%1), MAP_NUM(%1), %2, %3},\n") .arg(map_in.name) .arg(map_in.x) @@ -1026,7 +1017,8 @@ void Project::readMapGroups() { QString hltext = readTextFile(root + QString("/src/data/heal_locations.h")); QList* hl = parser->parseHealLocs(hltext); - flyableMaps = hl; + flyableMaps = *hl; + delete hl; } Map* Project::addNewMapToGroup(QString mapName, int groupNum) { @@ -1412,12 +1404,10 @@ void Project::saveMapEvents(Map *map) { // save heal event changes if (map->events["heal_event_group"].length() > 0) { - QList* flymaps = flyableMaps; for (Event *heal : map->events["heal_event_group"]) { HealLocation hl = heal->buildHealLocation(); - flymaps->append(hl); + flyableMaps[hl.index - 1] = hl; } - flyableMaps = flymaps; } saveHealLocationStruct(map); } @@ -1492,7 +1482,7 @@ void Project::readMapEvents(Map *map) { map->events["heal_event_group"].clear(); - for (auto it = flyableMaps->begin(); it != flyableMaps->end(); it++) { + for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) { HealLocation loc = *it; diff --git a/project.h b/project.h index d965e4c6..49e348b2 100755 --- a/project.h +++ b/project.h @@ -18,7 +18,7 @@ public: QMap *map_groups; QList groupedMapNames; QStringList *mapNames = NULL; - QList *flyableMaps = NULL; // can't be a QMap because duplicates + QList flyableMaps; QMap* mapConstantsToMapNames; QMap* mapNamesToMapConstants; QList mapLayoutsTable;