]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Monster.cpp
added constructors for described types
[l2e.git] / src / battle / Monster.cpp
index 7408eeea09939685e186f0018cfe6fcee20235a6..7cb4185f13209bf31cc327051718a3034dd5d004 100644 (file)
@@ -54,9 +54,6 @@ void Monster::SubtractHealth(int amount) {
 
 void Monster::CreateTypeDescription() {
        Monster m;
-       TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
-
-       td.SetSize(sizeof(Monster));
 
        int animationId(TypeDescription::GetTypeId("Animation"));
        int numberId(TypeDescription::GetTypeId("Number"));
@@ -64,6 +61,10 @@ void Monster::CreateTypeDescription() {
        int statsId(TypeDescription::GetTypeId("Stats"));
        int stringId(TypeDescription::GetTypeId("String"));
 
+       TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Monster));
+
        td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true));
        td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true));
        td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false));
@@ -79,4 +80,8 @@ void Monster::CreateTypeDescription() {
        td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true));
 }
 
+void Monster::Construct(void *data) {
+       new (data) Monster;
+}
+
 }