]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Monster.cpp
switched to static type IDs
[l2e.git] / src / battle / Monster.cpp
index 498a8c6094ff181d311a334c337f1d9a70cdbf06..8ea79e676d080d4019c812a41581f0a74aee966e 100644 (file)
@@ -7,9 +7,17 @@
 
 #include "Monster.h"
 
+#include "../common/Stats.h"
+#include "../graphics/Animation.h"
+#include "../graphics/Sprite.h"
+#include "../loader/Interpreter.h"
 #include "../loader/TypeDescription.h"
 
+using common::Stats;
+using graphics::Animation;
+using graphics::Sprite;
 using loader::FieldDescription;
+using loader::Interpreter;
 using loader::TypeDescription;
 
 namespace battle {
@@ -55,30 +63,24 @@ void Monster::SubtractHealth(int amount) {
 void Monster::CreateTypeDescription() {
        Monster m;
 
-       int animationId(TypeDescription::GetTypeId("Animation"));
-       int numberId(TypeDescription::GetTypeId("Number"));
-       int spriteId(TypeDescription::GetTypeId("Sprite"));
-       int statsId(TypeDescription::GetTypeId("Stats"));
-       int stringId(TypeDescription::GetTypeId("String"));
-
-       TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
+       TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster"));
        td.SetDescription("All data of a monster.");
        td.SetConstructor(&Construct);
        td.SetSize(sizeof(Monster));
 
-       td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId).SetReferenced());
-       td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId).SetReferenced());
-       td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId));
+       td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced());
+       td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID));
 
-       td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId));
-       td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId));
-       td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId));
-       td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId));
-       td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId));
+       td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID));
+       td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID));
+       td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID));
+       td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID));
+       td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID));
 
-       td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId).SetReferenced());
-       td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId).SetReferenced());
-       td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId).SetReferenced());
+       td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
+       td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
+       td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
 }
 
 void Monster::Construct(void *data) {