From 083e8e6101b257a5da8badc1342b92d67cf1609b Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 24 Sep 2018 19:21:10 -0500 Subject: [PATCH] Move heal location logic out of event class --- core/event.cpp | 15 --------------- core/event.h | 2 -- core/heallocation.cpp | 15 +++++++++++++++ core/heallocation.h | 3 ++- project.cpp | 8 ++++---- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/core/event.cpp b/core/event.cpp index 5fcafd73..47c42166 100644 --- a/core/event.cpp +++ b/core/event.cpp @@ -175,21 +175,6 @@ QString Event::buildWarpEventMacro(QMap *mapNamesToMapConstant return text; } -HealLocation Event::buildHealLocation() -{ - HealLocation hl; - hl.name = this->get("loc_name"); - try { - hl.index = this->get("index").toInt(); - } - catch(...) { - hl.index = 0; - } - hl.x = this->getU16("x"); - hl.y = this->getU16("y"); - return hl; -} - QString Event::buildCoordScriptEventMacro() { QString text = ""; diff --git a/core/event.h b/core/event.h index 35a59f7d..ac5c4579 100644 --- a/core/event.h +++ b/core/event.h @@ -1,7 +1,6 @@ #ifndef EVENT_H #define EVENT_H -#include "heallocation.h" #include #include #include @@ -68,7 +67,6 @@ public: QString buildObjectEventMacro(int); QString buildWarpEventMacro(QMap*); - HealLocation buildHealLocation(); QString buildCoordScriptEventMacro(); QString buildCoordWeatherEventMacro(); QString buildSignEventMacro(); diff --git a/core/heallocation.cpp b/core/heallocation.cpp index f611098d..ba739831 100644 --- a/core/heallocation.cpp +++ b/core/heallocation.cpp @@ -8,6 +8,21 @@ HealLocation::HealLocation(QString map, int i, uint16_t x, uint16_t y) this->y = y; } +HealLocation HealLocation::fromEvent(Event *event) +{ + HealLocation hl; + hl.name = event->get("loc_name"); + try { + hl.index = event->get("index").toInt(); + } + catch(...) { + hl.index = 0; + } + hl.x = event->getU16("x"); + hl.y = event->getU16("y"); + return hl; +} + QDebug operator<<(QDebug debug, const HealLocation &hl) { debug << "HealLocation_" + hl.name << "(" << hl.x << ',' << hl.y << ")"; diff --git a/core/heallocation.h b/core/heallocation.h index 14571a3d..e8e702ae 100644 --- a/core/heallocation.h +++ b/core/heallocation.h @@ -1,6 +1,7 @@ #ifndef HEALLOCATION_H #define HEALLOCATION_H +#include "event.h" #include #include @@ -17,7 +18,7 @@ public: int index; uint16_t x; uint16_t y; - + static HealLocation fromEvent(Event*); }; #endif // HEALLOCATION_H diff --git a/project.cpp b/project.cpp index 52be0852..e7a7f900 100755 --- a/project.cpp +++ b/project.cpp @@ -534,8 +534,8 @@ void Project::saveHealLocationStruct(Map *map) { // set new location in flyableMapsList if (map->events["heal_event_group"].length() > 0) { - for (Event *heal : map->events["heal_event_group"]) { - HealLocation hl = heal->buildHealLocation(); + for (Event *healEvent : map->events["heal_event_group"]) { + HealLocation hl = HealLocation::fromEvent(healEvent); flyableMaps[hl.index - 1] = hl; } } @@ -1475,8 +1475,8 @@ void Project::saveMapEvents(Map *map) { // save heal event changes if (map->events["heal_event_group"].length() > 0) { - for (Event *heal : map->events["heal_event_group"]) { - HealLocation hl = heal->buildHealLocation(); + for (Event *healEvent : map->events["heal_event_group"]) { + HealLocation hl = HealLocation::fromEvent(healEvent); flyableMaps[hl.index - 1] = hl; } }