DEADSOFTWARE

gl: fix draw invalid texture
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Thu, 16 Feb 2023 16:48:16 +0000 (19:48 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:14:16 +0000 (12:14 +0300)
src/game/renders/opengl/r_map.pas

index 914087d80c504bc7cc438bd5560dfed3f708f787..26a15dc4881d3e97f1a621ae2dbd4a518794cd05 100644 (file)
@@ -586,24 +586,29 @@ implementation
     begin
       ASSERT(p.FCurTexture <= High(p.TextureIDs));
       Texture := p.TextureIDs[p.FCurTexture].Texture;
+      t := nil;
+      ASSERT(Texture >= -1);
       ASSERT(Texture <= High(RenTextures));
-      t := RenTextures[Texture].tex;
-      if (RenTextures[Texture].spec = 0) or (t <> nil) then
+      if Texture >= 0 then
       begin
-        count := 0; frame := 0;
-        if p.AnimTime <= gTime then
+        t := RenTextures[Texture].tex;
+        if (RenTextures[Texture].spec = 0) or (t <> nil) then
         begin
-          a := RenTextures[Texture].anim;
-          a.loop := p.AnimLoop;
-          g_Anim_GetFrameByTime(a, (gTime - p.AnimTime) DIV GAME_TICK, count, frame);
+          count := 0; frame := 0;
+          if p.AnimTime <= gTime then
+          begin
+            a := RenTextures[Texture].anim;
+            a.loop := p.AnimLoop;
+            g_Anim_GetFrameByTime(a, (gTime - p.AnimTime) DIV GAME_TICK, count, frame);
+          end;
+          if t <> nil then
+          begin
+            tex := t.GetTexture(frame);
+            r_Draw_TextureRepeat(tex, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending);
+          end
+          else
+            r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255, false);
         end;
-        if t <> nil then
-        begin
-          tex := t.GetTexture(frame);
-          r_Draw_TextureRepeat(tex, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending);
-        end
-        else
-          r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255, false);
       end;
 
       if t = nil then