X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FMonster.cpp;h=7cb4185f13209bf31cc327051718a3034dd5d004;hb=b02da898c7c8a08141df4e797774a61cf5e0163f;hp=7408eeea09939685e186f0018cfe6fcee20235a6;hpb=c45562467a2845a9f5b6942e8bf091251f5d16d6;p=l2e.git diff --git a/src/battle/Monster.cpp b/src/battle/Monster.cpp index 7408eee..7cb4185 100644 --- a/src/battle/Monster.cpp +++ b/src/battle/Monster.cpp @@ -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; +} + }