]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Hero.cpp
reordered type description creation to avoid reallocation
[l2e.git] / src / battle / Hero.cpp
index d117da078ed072bc8dfa9a00d8f70519ccc91325..fdf8125872c1df23a57c3f8187837d96da125d2f 100644 (file)
@@ -156,9 +156,6 @@ void Hero::UpdateIkariMenu(const Resources *res) {
 
 void Hero::CreateTypeDescription() {
        Hero h;
-       TypeDescription &td(TypeDescription::CreateOrGet("Hero"));
-
-       td.SetSize(sizeof(Hero));
 
        int animationId(TypeDescription::GetTypeId("Animation"));
        int numberId(TypeDescription::GetTypeId("Number"));
@@ -166,6 +163,9 @@ void Hero::CreateTypeDescription() {
        int statsId(TypeDescription::GetTypeId("Stats"));
        int stringId(TypeDescription::GetTypeId("String"));
 
+       TypeDescription &td(TypeDescription::CreateOrGet("Hero"));
+       td.SetSize(sizeof(Hero));
+
        td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId, true));
        td.AddField("sprite", FieldDescription(((char *)&h.sprite) - ((char *)&h), spriteId, true));
        td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false));