From 5406a47cf13ec720c39094765a75906c7ed1cdbc Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 8 Sep 2012 14:38:21 +0200 Subject: [PATCH] added type description of Ikari --- src/common/Ikari.cpp | 23 +++++++++++++++++++++++ src/common/Ikari.h | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/common/Ikari.cpp b/src/common/Ikari.cpp index 6f7da0c..408b0f8 100644 --- a/src/common/Ikari.cpp +++ b/src/common/Ikari.cpp @@ -7,6 +7,11 @@ #include "Ikari.h" +#include "../loader/TypeDescription.h" + +using loader::FieldDescription; +using loader::TypeDescription; + namespace common { Ikari::Ikari() @@ -16,4 +21,22 @@ Ikari::Ikari() } + +void Ikari::CreateTypeDescription() { + Ikari i; + TypeDescription &td(TypeDescription::CreateOrGet("Ikari")); + + td.SetSize(sizeof(Ikari)); + + int boolId(TypeDescription::GetTypeId("Boolean")); + int numberId(TypeDescription::GetTypeId("Number")); // FIXME: need small number type + int stringId(TypeDescription::GetTypeId("String")); + int targetsId(TypeDescription::GetTypeId("TargetingMode")); + + td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId, true)); + td.AddField("cost", FieldDescription(((char *)&i.cost) - ((char *)&i), numberId, false)); + td.AddField("targets", FieldDescription(((char *)&i.targetingMode) - ((char *)&i), targetsId, false)); + td.AddField("physical", FieldDescription(((char *)&i.isPhysical) - ((char *)&i), boolId, true)); +} + } diff --git a/src/common/Ikari.h b/src/common/Ikari.h index 2999538..76730de 100644 --- a/src/common/Ikari.h +++ b/src/common/Ikari.h @@ -35,10 +35,12 @@ public: void SetMagical() { isPhysical = false; } void SetPhysical() { isPhysical = true; } + static void CreateTypeDescription(); + private: const char *name; - Uint8 cost; + int cost; TargetingMode targetingMode; bool isPhysical; -- 2.39.2