From 8b9c3b2de186641ce287c3405a1b856b5bc38fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 30 Oct 2013 15:39:56 +0100 Subject: [PATCH] Fixed some compilation issues --- src/controlling/controlling.pro | 12 ++++++++ src/definition/BaseDefinition.cpp | 48 +++++++++++++++++++++++++++++++ src/definition/BaseDefinition.h | 14 +++++---- src/editing/editing.pro | 5 ++++ src/rendering/Scenery.cpp | 7 ++++- src/rendering/Scenery.h | 12 ++++---- 6 files changed, 86 insertions(+), 12 deletions(-) diff --git a/src/controlling/controlling.pro b/src/controlling/controlling.pro index 67c1b6a..eb94164 100644 --- a/src/controlling/controlling.pro +++ b/src/controlling/controlling.pro @@ -20,3 +20,15 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../system/debug/ -l else:unix: LIBS += -L$$OUT_PWD/../system/ -lpaysages_system INCLUDEPATH += $$PWD/../system DEPENDPATH += $$PWD/../system + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../basics/release/ -lpaysages_basics +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../basics/debug/ -lpaysages_basics +else:unix: LIBS += -L$$OUT_PWD/../basics/ -lpaysages_basics +INCLUDEPATH += $$PWD/../basics +DEPENDPATH += $$PWD/../basics + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../definition/release/ -lpaysages_definition +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug/ -lpaysages_definition +else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition +INCLUDEPATH += $$PWD/../definition +DEPENDPATH += $$PWD/../definition diff --git a/src/definition/BaseDefinition.cpp b/src/definition/BaseDefinition.cpp index ada1743..d3672a8 100644 --- a/src/definition/BaseDefinition.cpp +++ b/src/definition/BaseDefinition.cpp @@ -3,4 +3,52 @@ BaseDefinition::BaseDefinition(BaseDefinition* parent): parent(parent) { + if (parent) + { + root = parent->root; + } + else + { + root = this; + } +} + +BaseDefinition::~BaseDefinition() +{ + QListIterator it(children); + while (it.hasNext()) + { + delete it.next(); + } +} + +void BaseDefinition::addChild(BaseDefinition* child) +{ + if (not children.contains(child)) + { + children.append(child); + } +} + +void BaseDefinition::removeChild(BaseDefinition* child) +{ + children.removeOne(child); +} + +void BaseDefinition::save(PackStream* pack) +{ + QListIterator it(children); + while (it.hasNext()) + { + it.next()->save(pack); + } +} + +void BaseDefinition::load(PackStream* pack) +{ + QListIterator it(children); + while (it.hasNext()) + { + it.next()->load(pack); + } } diff --git a/src/definition/BaseDefinition.h b/src/definition/BaseDefinition.h index a993fb2..e38dc68 100644 --- a/src/definition/BaseDefinition.h +++ b/src/definition/BaseDefinition.h @@ -2,9 +2,9 @@ #define BASEDEFINITION_H #include "definition_global.h" -#include -class PackStream; +#include +#include "PackStream.h" // TODO Delete when c++ migration is done namespace paysages { namespace definition { @@ -18,15 +18,17 @@ public: BaseDefinition(BaseDefinition* parent); virtual ~BaseDefinition(); - void addChild(BaseDefinition* child); - void removeChild(BaseDefinition* child); - virtual void save(PackStream* pack); virtual void load(PackStream* pack); +protected: + void addChild(BaseDefinition* child); + void removeChild(BaseDefinition* child); + private: BaseDefinition* parent; - QVector children; + BaseDefinition* root; + QList children; }; } diff --git a/src/editing/editing.pro b/src/editing/editing.pro index 1adb254..08187a1 100644 --- a/src/editing/editing.pro +++ b/src/editing/editing.pro @@ -162,3 +162,8 @@ else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering INCLUDEPATH += $$PWD/../rendering DEPENDPATH += $$PWD/../rendering +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../definition/release/ -lpaysages_definition +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug/ -lpaysages_definition +else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition +INCLUDEPATH += $$PWD/../definition +DEPENDPATH += $$PWD/../definition diff --git a/src/rendering/Scenery.cpp b/src/rendering/Scenery.cpp index cc5ba94..11fd1f9 100644 --- a/src/rendering/Scenery.cpp +++ b/src/rendering/Scenery.cpp @@ -10,7 +10,8 @@ static SceneryCustomDataCallback _custom_save = NULL; static SceneryCustomDataCallback _custom_load = NULL; static void* _custom_data = NULL; -Scenery::Scenery() +Scenery::Scenery(): + BaseDefinition(NULL) { atmosphere = (AtmosphereDefinition*)AtmosphereDefinitionClass.create(); camera = cameraCreateDefinition(); @@ -32,6 +33,8 @@ Scenery::~Scenery() void Scenery::save(PackStream* stream) { + BaseDefinition::save(stream); + AtmosphereDefinitionClass.save(stream, atmosphere); cameraSave(stream, camera); CloudsDefinitionClass.save(stream, clouds); @@ -42,6 +45,8 @@ void Scenery::save(PackStream* stream) void Scenery::load(PackStream* stream) { + BaseDefinition::load(stream); + AtmosphereDefinitionClass.load(stream, atmosphere); cameraLoad(stream, camera); CloudsDefinitionClass.load(stream, clouds); diff --git a/src/rendering/Scenery.h b/src/rendering/Scenery.h index 3f7e6b6..46ed357 100644 --- a/src/rendering/Scenery.h +++ b/src/rendering/Scenery.h @@ -14,6 +14,8 @@ #ifdef __cplusplus +#include "BaseDefinition.h" + //class AtmosphereDefinition; //class CameraDefinition; //class CloudsDefinition; @@ -31,17 +33,17 @@ namespace rendering { * * This class contains the whole scenery definition. */ -class RENDERINGSHARED_EXPORT Scenery +class RENDERINGSHARED_EXPORT Scenery: private BaseDefinition { public: Scenery(); - ~Scenery(); + virtual ~Scenery(); + + virtual void save(PackStream* stream); + virtual void load(PackStream* stream); void autoPreset(int seed); - void save(PackStream* stream); - void load(PackStream* stream); - void setAtmosphere(AtmosphereDefinition* atmosphere); inline AtmosphereDefinition* getAtmosphere() {return atmosphere;} void getAtmosphere(AtmosphereDefinition* atmosphere);