DEADSOFTWARE

gl: free player model textures
[d2df-sdl.git] / src / game / renders / opengl / r_map.pas
index 60f1ee62e66605d3bd441719db1e02cdc075ecaa..063c36b91e628b048502af9c5d2116116eaa3db6 100644 (file)
@@ -276,8 +276,32 @@ implementation
   end;
 
   procedure r_Map_Free;
-    var i, j: Integer; d: TDirection;
+    var i, j, k, a: Integer; d: TDirection;
   begin
+    for i := 1 to WP_LAST do
+    begin
+      for j := 0 to W_POS_LAST do
+      begin
+        for k := 0 to W_ACT_LAST do
+        begin
+          if WeapTextures[i, j, k] <> nil then
+            WeapTextures[i, j, k].Free;
+          WeapTextures[i, j, k] := nil;
+        end;
+      end;
+    end;
+    for d := TDirection.D_LEFT to TDirection.D_RIGHT do
+    begin
+      for a := A_STAND to A_LAST do
+      begin
+        if Models[i].anim[d, a].base <> nil then
+          Models[i].anim[d, a].base.Free;
+        if Models[i].anim[d, a].mask <> nil then
+          Models[i].anim[d, a].mask.Free;
+        Models[i].anim[d, a].base := nil;
+        Models[i].anim[d, a].mask := nil;
+      end;
+    end;
     for i := MONSTER_DEMON to MONSTER_MAN do
     begin
       for j := 0 to ANIM_LAST do
@@ -515,7 +539,7 @@ implementation
     a := pm.CurrentAnimation;
     d := pm.Direction;
     // TODO draw flag
-    if PlayerModelsArray[pm.id].HaveWeapon and not (pm.CurrentAnimation in [A_DIE1, A_DIE2, A_PAIN]) then
+    if PlayerModelsArray[pm.id].HaveWeapon and not (a in [A_DIE1, A_DIE2, A_PAIN]) then
     begin
       case a of
         A_SEEUP, A_ATTACKUP: pos := W_POS_UP;