From: Daniel Karbach Date: Mon, 10 Sep 2012 20:08:28 +0000 (+0200) Subject: removed type resolution from Animation::addFields X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=be7b4addf295d6193ba2527cdd17cdb524339aed;p=l2e.git removed type resolution from Animation::addFields --- diff --git a/src/graphics/Animation.cpp b/src/graphics/Animation.cpp index c1ba637..9bbfa1a 100644 --- a/src/graphics/Animation.cpp +++ b/src/graphics/Animation.cpp @@ -14,11 +14,7 @@ using loader::TypeDescription; namespace graphics { -void Animation::AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset) { - int boolId(TypeDescription::GetTypeId("Boolean")); - int numberId(TypeDescription::GetTypeId("Number")); - int spriteId(TypeDescription::GetTypeId("Sprite")); - +void Animation::AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset, int boolId, int numberId, int spriteId) { td.AddField("sprite", FieldDescription(((char *)&a.sprite) - ((char *)&a) - offset, spriteId, true)); td.AddField("frametime", FieldDescription(((char *)&a.frameTime) - ((char *)&a) - offset, numberId, false)); td.AddField("repeat", FieldDescription(((char *)&a.repeat) - ((char *)&a) - offset, boolId, false)); diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index ee62493..29948fe 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -49,7 +49,7 @@ public: virtual geometry::Vector Offset(int frame) const { return geometry::Vector(); } protected: - static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset); + static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset, int boolId, int numberId, int spriteId); private: const Sprite *sprite; diff --git a/src/graphics/ComplexAnimation.cpp b/src/graphics/ComplexAnimation.cpp index 253f0c4..ab19fd0 100644 --- a/src/graphics/ComplexAnimation.cpp +++ b/src/graphics/ComplexAnimation.cpp @@ -19,13 +19,16 @@ void ComplexAnimation::CreateTypeDescription() { Animation *a(&ca); int animationId(TypeDescription::GetTypeId("Animation")); + int boolId(TypeDescription::GetTypeId("Boolean")); int frameId(TypeDescription::GetTypeId("ComplexAnimationFrame")); + int numberId(TypeDescription::GetTypeId("Number")); + int spriteId(TypeDescription::GetTypeId("Sprite")); TypeDescription &td(TypeDescription::CreateOrGet("ComplexAnimation")); td.SetSize(sizeof(ComplexAnimation)); td.AddSupertype(animationId, ((char *)a) - ((char *)&ca)); - Animation::AddFields(td, ca, ((char *)a) - ((char *)&ca)); + Animation::AddFields(td, ca, ((char *)a) - ((char *)&ca), boolId, numberId, spriteId); td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), frameId, true, true)); diff --git a/src/graphics/SimpleAnimation.cpp b/src/graphics/SimpleAnimation.cpp index 17a0857..f1c1a72 100644 --- a/src/graphics/SimpleAnimation.cpp +++ b/src/graphics/SimpleAnimation.cpp @@ -19,12 +19,15 @@ void SimpleAnimation::CreateTypeDescription() { Animation *a(&sa); int animationId(TypeDescription::GetTypeId("Animation")); + int boolId(TypeDescription::GetTypeId("Boolean")); int numberId(TypeDescription::GetTypeId("Number")); + int spriteId(TypeDescription::GetTypeId("Sprite")); TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation")); td.SetSize(sizeof(SimpleAnimation)); td.AddSupertype(animationId, ((char *)a) - ((char *)&sa)); + Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa), boolId, numberId, spriteId); td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false)); td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false)); td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false));