]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/SimpleAnimation.cpp
reordered type description creation to avoid reallocation
[l2e.git] / src / graphics / SimpleAnimation.cpp
index 4e16b81658ec4a6dee2eec4a0eaeaffd7a7c2e01..17a0857832ce8dcfbe75b297f9113515aad4f8a3 100644 (file)
@@ -17,13 +17,14 @@ namespace graphics {
 void SimpleAnimation::CreateTypeDescription() {
        SimpleAnimation sa;
        Animation *a(&sa);
-       TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation"));
-
-       td.SetSize(sizeof(SimpleAnimation));
-       td.AddSupertype(TypeDescription::GetTypeId("Animation"), ((char *)a) - ((char *)&sa));
 
+       int animationId(TypeDescription::GetTypeId("Animation"));
        int numberId(TypeDescription::GetTypeId("Number"));
 
+       TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation"));
+       td.SetSize(sizeof(SimpleAnimation));
+       td.AddSupertype(animationId, ((char *)a) - ((char *)&sa));
+
        td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false));
        td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false));
        td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false));