DEADSOFTWARE

render: move gfx-once objects into render code
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 4 Jan 2022 17:02:07 +0000 (20:02 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 4 Jan 2022 17:02:07 +0000 (20:02 +0300)
src/game/g_game.pas
src/game/g_gfx.pas
src/game/g_items.pas
src/game/g_monsters.pas
src/game/g_netmsg.pas
src/game/g_player.pas
src/game/g_triggers.pas
src/game/g_weapons.pas
src/game/opengl/r_gfx.pas
src/game/opengl/r_render.pas

index a0f3090746d54008a174c4864b6513d0b10ab19b..d60a96054b453b02ef495e7a612377c6a00d8ba4 100644 (file)
@@ -439,7 +439,7 @@ uses
 {$IFDEF ENABLE_HOLMES}
   g_holmes,
 {$ENDIF}
-  e_res, g_window, g_menu, r_render, r_textures, r_animations,
+  e_res, g_window, g_menu, r_render, r_textures, r_animations, r_gfx,
   e_input, e_log, g_console, r_console, g_items, g_map, g_panel,
   g_playermodel, g_gfx, g_options, Math,
   g_triggers, g_monsters, e_sound, CONFIG,
@@ -2234,6 +2234,7 @@ begin
     g_Weapon_Update();
     g_Monsters_Update();
     g_GFX_Update();
+    r_GFX_Update;
     g_Player_UpdateAll();
     g_Player_UpdatePhysicalObjects();
 
@@ -2513,7 +2514,6 @@ begin
     end;
   end;
 
-  g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False);
   g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD+':WEAPONS\PUNCH', 64, 64, 4, False);
   g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
   g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
@@ -2656,7 +2656,6 @@ begin
   g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
   g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
   g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
-  g_Frames_DeleteByName('FRAMES_TELEPORT');
   g_Frames_DeleteByName('FRAMES_PUNCH');
   g_Frames_DeleteByName('FRAMES_PUNCH_UP');
   g_Frames_DeleteByName('FRAMES_PUNCH_DN');
index 9c58759a071c0ace4bc29776649bf51d7c5998b3..29b9c2240b0e6be7746570c3cba5c6a1a397c2f8 100644 (file)
@@ -59,8 +59,6 @@ procedure g_GFX_Bubbles (fX, fY: Integer; count: Word; devX, devY: Byte);
 procedure g_GFX_SetMax (count: Integer);
 function  g_GFX_GetMax (): Integer;
 
-procedure g_GFX_OnceAnim (X, Y: Integer; Anim: TAnimation; AnimType: Byte = 0);
-
 procedure g_Mark (x, y, Width, Height: Integer; t: Byte; st: Boolean=true);
 
 procedure g_GFX_Update ();
@@ -121,16 +119,8 @@ function awmIsSetHolmes (x, y: Integer): Boolean; inline;
       procedure think (); inline;
     end;
 
-    TOnceAnim = record
-      AnimType:   Byte;
-      x, y:       Integer;
-      oldX, oldY: Integer;
-      Animation:  TAnimation;
-    end;
-
   var (* private state *)
     Particles: array of TParticle = nil;
-    OnceAnims: array of TOnceAnim = nil;
 
 implementation
 
@@ -1542,51 +1532,6 @@ begin
   result := MaxParticles;
 end;
 
-
-function FindOnceAnim (): DWORD;
-var
-  i: Integer;
-begin
-  if OnceAnims <> nil then
-    for i := 0 to High(OnceAnims) do
-      if OnceAnims[i].Animation = nil then
-      begin
-        Result := i;
-        Exit;
-      end;
-
-  if OnceAnims = nil then
-    begin
-      SetLength(OnceAnims, 16);
-      Result := 0;
-    end
-  else
-    begin
-      Result := High(OnceAnims) + 1;
-      SetLength(OnceAnims, Length(OnceAnims) + 16);
-    end;
-end;
-
-
-procedure g_GFX_OnceAnim (x, y: Integer; Anim: TAnimation; AnimType: Byte = 0);
-var
-  find_id: DWORD;
-begin
-  if not gpart_dbg_enabled then exit;
-
-  if (Anim = nil) then exit;
-
-  find_id := FindOnceAnim();
-
-  OnceAnims[find_id].AnimType := AnimType;
-  OnceAnims[find_id].Animation := TAnimation.Create(Anim.FramesID, Anim.Loop, Anim.Speed);
-  OnceAnims[find_id].Animation.Blending := Anim.Blending;
-  OnceAnims[find_id].Animation.alpha := Anim.alpha;
-  OnceAnims[find_id].x := x;
-  OnceAnims[find_id].y := y;
-end;
-
-
 // ////////////////////////////////////////////////////////////////////////// //
 procedure g_GFX_Init ();
 begin
@@ -1609,12 +1554,6 @@ begin
   for a := 0 to High(Particles) do Particles[a].die();
   CurrentParticle := 0;
 
-  if (OnceAnims <> nil) then
-  begin
-    for a := 0 to High(OnceAnims) do OnceAnims[a].Animation.Free();
-    OnceAnims := nil;
-  end;
-
   awakeMap := nil;
   // why not?
   awakeMapH := -1;
@@ -1654,34 +1593,6 @@ begin
 
   // clear awake map
   awmClear();
-
-  if OnceAnims <> nil then
-  begin
-    for a := 0 to High(OnceAnims) do
-      if OnceAnims[a].Animation <> nil then
-      begin
-        OnceAnims[a].oldx := OnceAnims[a].x;
-        OnceAnims[a].oldy := OnceAnims[a].y;
-
-        case OnceAnims[a].AnimType of
-          ONCEANIM_SMOKE:
-            begin
-              if Random(3) = 0 then
-                OnceAnims[a].x := OnceAnims[a].x-1+Random(3);
-              if Random(2) = 0 then
-                OnceAnims[a].y := OnceAnims[a].y-Random(2);
-            end;
-        end;
-
-        if OnceAnims[a].Animation.Played then
-          begin
-            OnceAnims[a].Animation.Free();
-            OnceAnims[a].Animation := nil;
-          end
-        else
-          OnceAnims[a].Animation.Update();
-      end;
-  end;
 end;
 
 end.
index 51dfc8fc2031f0b5f89765245956a92e21467fc0..dcc8b0f58ad93521ee244b86411571a5761427dc 100644 (file)
@@ -90,7 +90,7 @@ implementation
 
 uses
   Math,
-  g_basic, g_sound, g_gfx, g_map, r_textures, r_animations,
+  g_basic, g_sound, g_gfx, g_map, r_animations, r_gfx,
   g_game, g_triggers, g_console, g_player, g_net, g_netmsg,
   e_log, g_options,
   g_grid, binheap, idpool, utils, xstreams;
@@ -392,8 +392,6 @@ end;
 procedure g_Items_Update ();
 var
   i, j, k: Integer;
-  ID: DWord;
-  Anim: TAnimation;
   m, ItemRespawnTime: Word;
   r, nxt: Boolean;
 begin
@@ -487,14 +485,7 @@ begin
         if (RespawnTime = 0) and (not alive) then
         begin
           if not QuietRespawn then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', InitX, InitY);
-
-          if g_Frames_Get(ID, 'FRAMES_ITEM_RESPAWN') then
-          begin
-            Anim := TAnimation.Create(ID, False, 4);
-            g_GFX_OnceAnim(InitX+(Obj.Rect.Width div 2)-16, InitY+(Obj.Rect.Height div 2)-16, Anim);
-            Anim.Free();
-          end;
-
+          r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, InitX + (Obj.Rect.Width div 2) - 16, InitY + (Obj.Rect.Height div 2) - 16);
           Obj.oldX := InitX;
           Obj.oldY := InitY;
           Obj.X := InitX;
index d8c3fba04e3a4be5adae33bd8cd43d68d671475e..eabd05d7dff7ef4670fb23cf1f44536201a75933 100644 (file)
@@ -488,7 +488,7 @@ var
 implementation
 
 uses
-  e_log, g_sound, g_gfx, g_player, g_game, r_textures, r_animations,
+  e_log, g_sound, g_gfx, g_player, g_game, r_textures, r_animations, r_gfx,
   g_weapons, g_triggers, g_items, g_options,
   g_console, g_map, Math, g_menu, wadreader,
   g_language, g_netmsg, idpool, utils, xstreams;
@@ -2294,9 +2294,6 @@ begin
 end;
 
 function TMonster.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
-var
-  TA: TAnimation;
-  FramesID: DWORD;
 begin
   Result := False;
 
@@ -2309,16 +2306,15 @@ begin
     Exit;
   end;
 
-  TA := nil;
-
 // Эффект телепорта в позиции монстра:
   if not silent then
   begin
-    if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
-      TA := TAnimation.Create(FramesID, False, 6);
     g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Obj.X, Obj.Y);
-    g_GFX_OnceAnim(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
-                   FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-32, TA);
+    r_GFX_OnceAnim(
+      R_GFX_TELEPORT,
+      FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
+      FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-32
+    );
 
     if g_Game_IsServer and g_Game_IsNet then
       MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
@@ -2347,11 +2343,13 @@ begin
       end;
 
 // Эффект телепорта в точке назначения:
-  if not silent and (TA <> nil) then
+  if not silent then
   begin
-    g_GFX_OnceAnim(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
-                   FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-32, TA);
-    TA.Free();
+    r_GFX_OnceAnim(
+      R_GFX_TELEPORT,
+      FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
+      FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-32
+    );
 
     if g_Game_IsServer and g_Game_IsNet then
      MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-32,
@@ -4612,23 +4610,16 @@ begin
 end;
 
 procedure TMonster.OnFireFlame(Times: DWORD = 1);
-var
-  id, i: DWORD;
-  Anim: TAnimation;
+  var i: DWORD; x, y: Integer;
 begin
   if (Random(10) = 1) and (Times = 1) then
     Exit;
 
-  if g_Frames_Get(id, 'FRAMES_FLAME') then
+  for i := 1 to Times do
   begin
-    for i := 1 to Times do
-    begin
-      Anim := TAnimation.Create(id, False, 3);
-      Anim.Alpha := 0;
-      g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
-                   Obj.Y+8+Random(8+Times*2)+IfThen(FState = MONSTATE_DEAD, 16, 0), Anim, ONCEANIM_SMOKE);
-      Anim.Free();
-    end;
+    x := Obj.X + Obj.Rect.X + Random(Obj.Rect.Width + Times * 2) - (R_GFX_FLAME_WIDTH div 2);
+    y := Obj.Y + 8 + Random(8 + Times * 2) + IfThen(FState = MONSTATE_DEAD, 16, 0);
+    r_GFX_OnceAnim(R_GFX_FLAME, x, y);
   end;
 end;
 
index c699c4b53ccbea82609e6a47e6c2898be4b9988e..bdcd38c0e10721756aa391592059a3a0642ce8ff 100644 (file)
@@ -276,7 +276,7 @@ function IsValidFilePath(const S: String): Boolean;
 implementation
 
 uses
-  Math, ENet, e_input, e_log, g_base, g_basic, r_textures, r_animations,
+  Math, ENet, e_input, e_log, g_base, g_basic, r_animations, r_gfx,
   g_textures, g_gfx, g_sound, g_console, g_options,
   g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
   g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
@@ -1543,8 +1543,6 @@ var
   Kind: Byte;
   X, Y: Integer;
   Ang: SmallInt;
-  Anim: TAnimation;
-  ID: LongWord;
 begin
   if not gGameOn then Exit;
   Kind := M.ReadByte();
@@ -1558,72 +1556,40 @@ begin
 
     NET_GFX_TELE:
     begin
-      if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
-      begin
-        Anim := TAnimation.Create(ID, False, 3);
-        g_GFX_OnceAnim(X, Y, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_TELEPORT_FAST, X, Y);
       if Ang = 1 then
         g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
     end;
 
     NET_GFX_EXPLODE:
     begin
-      if g_Frames_Get(ID, 'FRAMES_EXPLODE_ROCKET') then
-      begin
-        Anim := TAnimation.Create(ID, False, 6);
-        Anim.Blending := False;
-        g_GFX_OnceAnim(X-64, Y-64, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, X - 64, Y - 64);
       if Ang = 1 then
         g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', X, Y);
     end;
 
     NET_GFX_BFGEXPL:
     begin
-      if g_Frames_Get(ID, 'FRAMES_EXPLODE_BFG') then
-      begin
-        Anim := TAnimation.Create(ID, False, 6);
-        Anim.Blending := False;
-        g_GFX_OnceAnim(X-64, Y-64, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_EXPLODE_BFG, X - 64, Y - 64);
       if Ang = 1 then
         g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', X, Y);
     end;
 
     NET_GFX_BFGHIT:
     begin
-      if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
-      begin
-        Anim := TAnimation.Create(ID, False, 4);
-        g_GFX_OnceAnim(X-32, Y-32, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_BFG_HIT, X - 32, Y - 32);
     end;
 
     NET_GFX_FIRE:
     begin
-      if g_Frames_Get(ID, 'FRAMES_FIRE') then
-      begin
-        Anim := TAnimation.Create(ID, False, 4);
-        g_GFX_OnceAnim(X, Y, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_FIRE, X, Y);
       if Ang = 1 then
         g_Sound_PlayExAt('SOUND_FIRE', X, Y);
     end;
 
     NET_GFX_RESPAWN:
     begin
-      if g_Frames_Get(ID, 'FRAMES_ITEM_RESPAWN') then
-      begin
-        Anim := TAnimation.Create(ID, False, 4);
-        g_GFX_OnceAnim(X, Y, Anim);
-        Anim.Free();
-      end;
+      r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, X, Y);
       if Ang = 1 then
         g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
     end;
@@ -2542,11 +2508,9 @@ end;
 procedure MC_RECV_ItemSpawn(var M: TMsg);
 var
   ID: Word;
-  AID: DWord;
   X, Y, VX, VY: Integer;
   T: Byte;
   Quiet, Fall{, Resp}: Boolean;
-  Anim: TAnimation;
   it: PItem;
 begin
   if not gGameOn then Exit;
@@ -2570,12 +2534,7 @@ begin
   if not Quiet then
   begin
     g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
-    if g_Frames_Get(AID, 'FRAMES_ITEM_RESPAWN') then
-    begin
-      Anim := TAnimation.Create(AID, False, 4);
-      g_GFX_OnceAnim(X+(it.Obj.Rect.Width div 2)-16, Y+(it.Obj.Rect.Height div 2)-16, Anim);
-      Anim.Free();
-    end;
+    r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, X+(it.Obj.Rect.Width div 2)-16, Y+(it.Obj.Rect.Height div 2)-16);
   end;
 end;
 
index b346d3b1e35904b4f689c30ae1e78b29077a740d..7499754329dac902458811598b024c4a3ebf2aef 100644 (file)
@@ -635,7 +635,7 @@ uses
 {$IFDEF ENABLE_HOLMES}
   g_holmes,
 {$ENDIF}
-  e_log, g_map, g_items, g_console, g_gfx, Math, r_textures, r_animations,
+  e_log, g_map, g_items, g_console, g_gfx, Math, r_textures, r_animations, r_gfx,
   g_options, g_triggers, g_menu, g_game, g_grid, e_res,
   wadreader, g_monsters, CONFIG, g_language,
   g_net, g_netmsg,
@@ -3794,8 +3794,6 @@ procedure TPlayer.Respawn(Silent: Boolean; Force: Boolean = False);
 var
   RespawnPoint: TRespawnPoint;
   a, b, c: Byte;
-  Anim: TAnimation;
-  ID: DWORD;
 begin
   FSlopeOld := 0;
   FIncCamOld := 0;
@@ -3940,13 +3938,11 @@ begin
 
 // Анимация возрождения:
   if (not gLoadGameMode) and (not Silent) then
-    if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
-    begin
-      Anim := TAnimation.Create(ID, False, 3);
-      g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
-                     FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
-      Anim.Free();
-    end;
+    r_GFX_OnceAnim(
+      R_GFX_TELEPORT_FAST,
+      FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+      FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+    );
 
   FSpectator := False;
   FGhost := False;
@@ -4126,9 +4122,6 @@ begin
 end;
 
 function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
-var
-  Anim: TAnimation;
-  ID: DWORD;
 begin
   Result := False;
 
@@ -4142,17 +4135,14 @@ begin
 
   FJustTeleported := True;
 
-  Anim := nil;
   if not silent then
   begin
-    if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
-    begin
-      Anim := TAnimation.Create(ID, False, 3);
-    end;
-
     g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj.X, FObj.Y);
-    g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
-                   FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
+    r_GFX_OnceAnim(
+      R_GFX_TELEPORT_FAST,
+      FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+      FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+    );
     if g_Game_IsServer and g_Game_IsNet then
       MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
                      FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 1,
@@ -4198,12 +4188,13 @@ begin
         end;
   end;
 
-  if not silent and (Anim <> nil) then
+  if not silent then
   begin
-    g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
-                   FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
-    Anim.Free();
-
+    r_GFX_OnceAnim(
+      R_GFX_TELEPORT_FAST,
+      FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
+      FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32
+    );
     if g_Game_IsServer and g_Game_IsNet then
       MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
                      FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 0,
@@ -5681,9 +5672,7 @@ begin
 end;
 
 procedure TPlayer.FlySmoke(Times: DWORD = 1);
-var
-  id, i: DWORD;
-  Anim: TAnimation;
+  var i: DWORD;
 begin
   if (Random(5) = 1) and (Times = 1) then
     Exit;
@@ -5699,37 +5688,29 @@ begin
     Exit;
   end;
 
-  if g_Frames_Get(id, 'FRAMES_SMOKE') then
+  for i := 1 to Times do
   begin
-    for i := 1 to Times do
-    begin
-      Anim := TAnimation.Create(id, False, 3);
-      Anim.Alpha := 150;
-      g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
-                   Obj.Y+Obj.Rect.Height-4+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
-      Anim.Free();
-    end;
+    r_GFX_OnceAnim(
+      R_GFX_SMOKE_TRANS,
+      Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_SMOKE_WIDTH div 2),
+      Obj.Y+Obj.Rect.Height-4+Random(8+Times*2)
+    );
   end;
 end;
 
 procedure TPlayer.OnFireFlame(Times: DWORD = 1);
-var
-  id, i: DWORD;
-  Anim: TAnimation;
+  var i: DWORD;
 begin
   if (Random(10) = 1) and (Times = 1) then
     Exit;
 
-  if g_Frames_Get(id, 'FRAMES_FLAME') then
+  for i := 1 to Times do
   begin
-    for i := 1 to Times do
-    begin
-      Anim := TAnimation.Create(id, False, 3);
-      Anim.Alpha := 0;
-      g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
-                   Obj.Y+8+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
-      Anim.Free();
-    end;
+    r_GFX_OnceAnim(
+      R_GFX_FLAME,
+      Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_FLAME_WIDTH div 2),
+      Obj.Y+8+Random(8+Times*2)
+    );
   end;
 end;
 
index 1c8e0c778d77f6a573818596ff3f6d4df02d8537..3c21cfef4df5cf2d0fc5419194bf2bdb115a2864 100644 (file)
@@ -103,7 +103,7 @@ implementation
 
 uses
   Math,
-  g_player, g_map, g_panel, g_gfx, g_game, g_textures, r_textures, r_animations,
+  g_player, g_map, g_panel, g_gfx, g_game, r_animations, r_gfx,
   g_console, g_monsters, g_items, g_phys, g_weapons,
   wadreader, e_log, g_language, e_res,
   g_options, g_net, g_netmsg, utils, xparser, xstreams;
@@ -664,11 +664,8 @@ function tr_SpawnShot (ShotType: Integer; wx, wy, dx, dy: Integer; ShotSound: Bo
 var
   snd: string;
   Projectile: Boolean;
-  TextureID: DWORD;
-  Anim: TAnimation;
 begin
   result := -1;
-  TextureID := DWORD(-1);
   snd := 'SOUND_WEAPON_FIREROCKET';
   Projectile := true;
 
@@ -779,13 +776,7 @@ begin
 
     TRIGGER_SHOT_EXPL:
       begin
-        if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
-        begin
-          Anim := TAnimation.Create(TextureID, False, 6);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(wx-64, wy-64, Anim);
-          Anim.Free();
-        end;
+        r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, wx - 64, wy - 64);
         Projectile := False;
         g_Weapon_Explode(wx, wy, 60, 0);
         snd := 'SOUND_WEAPON_EXPLODEROCKET';
@@ -793,13 +784,7 @@ begin
 
     TRIGGER_SHOT_BFGEXPL:
       begin
-        if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
-        begin
-          Anim := TAnimation.Create(TextureID, False, 6);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(wx-64, wy-64, Anim);
-          Anim.Free();
-        end;
+        r_GFX_OnceAnim(R_GFX_EXPLODE_BFG, wx - 64, wy - 64);
         Projectile := False;
         g_Weapon_BFG9000(wx, wy, 0);
         snd := 'SOUND_WEAPON_EXPLODEBFG';
@@ -866,9 +851,6 @@ end;
 
 
 procedure tr_MakeEffect (X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean);
-var
-  FramesID: DWORD;
-  Anim: TAnimation;
 begin
   if T = TRIGGER_EFFECT_PARTICLE then
   begin
@@ -892,33 +874,18 @@ begin
   begin
     case ST of
       EFFECT_TELEPORT: begin
-        if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
-        begin
-          Anim := TAnimation.Create(FramesID, False, 3);
-          if not Silent then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
-          g_GFX_OnceAnim(X-32, Y-32, Anim);
-          Anim.Free();
-        end;
+        if not Silent then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
+        r_GFX_OnceAnim(R_GFX_TELEPORT_FAST, X - 32, Y - 32);
         if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X, Y, Byte(not Silent), NET_GFX_TELE);
       end;
       EFFECT_RESPAWN: begin
-        if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
-        begin
-          Anim := TAnimation.Create(FramesID, False, 4);
-          if not Silent then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
-          g_GFX_OnceAnim(X-16, Y-16, Anim);
-          Anim.Free();
-        end;
+        if not Silent then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
+        r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, X - 16, Y - 16);
         if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X-16, Y-16, Byte(not Silent), NET_GFX_RESPAWN);
       end;
       EFFECT_FIRE: begin
-        if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
-        begin
-          Anim := TAnimation.Create(FramesID, False, 4);
-          if not Silent then g_Sound_PlayExAt('SOUND_FIRE', X, Y);
-          g_GFX_OnceAnim(X-32, Y-128, Anim);
-          Anim.Free();
-        end;
+        if not Silent then g_Sound_PlayExAt('SOUND_FIRE', X, Y);
+        r_GFX_OnceAnim(R_GFX_FIRE, X - 32, Y - 128);
         if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X-32, Y-128, Byte(not Silent), NET_GFX_FIRE);
       end;
     end;
@@ -1173,8 +1140,6 @@ var
   iid: LongWord;
   coolDown: Boolean;
   pAngle: Real;
-  FramesID: DWORD;
-  Anim: TAnimation;
   UIDType: Byte;
   TargetUID: Word;
   it: PItem;
@@ -1503,42 +1468,36 @@ begin
 
               case tgcEffect of
                 EFFECT_TELEPORT: begin
-                  if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
-                  begin
-                    Anim := TAnimation.Create(FramesID, False, 3);
-                    g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
-                    g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
-                                   mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, Anim);
-                    Anim.Free();
-                  end;
+                  g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
+                  r_GFX_OnceAnim(
+                    R_GFX_TELEPORT_FAST,
+                    mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
+                    mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32
+                  );
                   if g_Game_IsServer and g_Game_IsNet then
                     MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
                                    mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, 1,
                                    NET_GFX_TELE);
                 end;
                 EFFECT_RESPAWN: begin
-                  if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
-                  begin
-                    Anim := TAnimation.Create(FramesID, False, 4);
-                    g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
-                    g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16,
-                                   mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, Anim);
-                    Anim.Free();
-                  end;
+                  g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
+                  r_GFX_OnceAnim(
+                    R_GFX_ITEM_RESPAWN,
+                    mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16,
+                    mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16
+                  );
                   if g_Game_IsServer and g_Game_IsNet then
                     MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16,
                                    mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, 1,
                                    NET_GFX_RESPAWN);
                 end;
                 EFFECT_FIRE: begin
-                  if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
-                  begin
-                    Anim := TAnimation.Create(FramesID, False, 4);
-                    g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
-                    g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
-                                   mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, Anim);
-                    Anim.Free();
-                  end;
+                  g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
+                  r_GFX_OnceAnim(
+                    R_GFX_FIRE,
+                    mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
+                    mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128
+                  );
                   if g_Game_IsServer and g_Game_IsNet then
                     MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
                                    mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, 1,
@@ -1596,14 +1555,12 @@ begin
                 case tgcEffect of
                   EFFECT_TELEPORT: begin
                     it := g_Items_ByIdx(iid);
-                    if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
-                    begin
-                      Anim := TAnimation.Create(FramesID, False, 3);
-                      g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
-                      g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
-                                     it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, Anim);
-                      Anim.Free();
-                    end;
+                    g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
+                    r_GFX_OnceAnim(
+                      R_GFX_TELEPORT_FAST,
+                      it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
+                      it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32
+                    );
                     if g_Game_IsServer and g_Game_IsNet then
                       MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
                                      it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, 1,
@@ -1611,14 +1568,12 @@ begin
                   end;
                   EFFECT_RESPAWN: begin
                     it := g_Items_ByIdx(iid);
-                    if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
-                    begin
-                      Anim := TAnimation.Create(FramesID, False, 4);
-                      g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
-                      g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16,
-                                     it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, Anim);
-                      Anim.Free();
-                    end;
+                    g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
+                    r_GFX_OnceAnim(
+                      R_GFX_ITEM_RESPAWN,
+                      it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16,
+                      it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16
+                    );
                     if g_Game_IsServer and g_Game_IsNet then
                       MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16,
                                      it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, 1,
@@ -1626,14 +1581,12 @@ begin
                   end;
                   EFFECT_FIRE: begin
                     it := g_Items_ByIdx(iid);
-                    if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
-                    begin
-                      Anim := TAnimation.Create(FramesID, False, 4);
-                      g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
-                      g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
-                                     it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, Anim);
-                      Anim.Free();
-                    end;
+                    g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
+                    r_GFX_OnceAnim(
+                      R_GFX_FIRE,
+                      it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
+                      it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128
+                    );
                     if g_Game_IsServer and g_Game_IsNet then
                       MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
                                      it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, 1,
index fb89fcc3a1f6b09871823aedd1d0183abc827243..2f157abf53ef42e5357146a6c05ed1f5152ebdbe 100644 (file)
@@ -112,7 +112,7 @@ implementation
 
 uses
   Math, g_map, g_player, g_gfx, g_sound, g_panel,
-  g_console, g_options, g_game, r_textures, r_animations,
+  g_console, g_options, g_game, r_textures, r_animations, r_gfx,
   g_triggers, MAPDEF, e_log, g_monsters, g_saveload,
   g_language, g_netmsg, g_grid,
   geom, binheap, hashtable, utils, xstreams;
@@ -1986,16 +1986,8 @@ begin
 end;
 
 procedure g_Weapon_bfghit(x, y: Integer);
-var
-  ID: DWORD;
-  Anim: TAnimation;
 begin
-  if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
-  begin
-    Anim := TAnimation.Create(ID, False, 4);
-    g_GFX_OnceAnim(x-32, y-32, Anim);
-    Anim.Free();
-  end;
+  r_GFX_OnceAnim(R_GFX_BFG_HIT, x - 32, y - 32);
 end;
 
 procedure g_Weapon_pistol(x, y, xd, yd: Integer; SpawnerUID: Word;
@@ -2074,12 +2066,8 @@ end;
 procedure g_Weapon_Update();
 var
   i, a, h, cx, cy, oldvx, oldvy, tf: Integer;
-  _id: DWORD;
-  Anim: TAnimation;
   t: DWArray;
   st: Word;
-  TextureID: DWORD = DWORD(-1);
-  s: String;
   o: TObj;
   spl: Boolean;
   Loud: Boolean;
@@ -2157,8 +2145,6 @@ begin
       cx := Obj.X + (Obj.Rect.Width div 2);
       cy := Obj.Y + (Obj.Rect.Height div 2);
 
-      TextureID := DWORD(-1); // !!!
-
       case ShotType of
         WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: // Ðàêåòû è ñíàðÿäû Ñêåëåòà
           begin
@@ -2172,15 +2158,7 @@ begin
                             Obj.Y+(Obj.Rect.Height div 2),
                             1+Random(3), 16, 16)
             else
-              if g_Frames_Get(_id, 'FRAMES_SMOKE') then
-              begin
-                Anim := TAnimation.Create(_id, False, 3);
-                Anim.Alpha := 150;
-                g_GFX_OnceAnim(Obj.X-14+Random(9),
-                               Obj.Y+(Obj.Rect.Height div 2)-20+Random(9),
-                               Anim, ONCEANIM_SMOKE);
-                Anim.Free();
-              end;
+              r_GFX_OnceAnim(R_GFX_SMOKE_TRANS, Obj.X-14+Random(9), Obj.Y+(Obj.Rect.Height div 2)-20+Random(9));
 
           // Ïîïàëè â êîãî-òî èëè â ñòåíó:
             if WordBool(st and (MOVE_HITWALL or MOVE_HITLAND or MOVE_HITCEIL)) or
@@ -2194,25 +2172,13 @@ begin
 
               if ShotType = WEAPON_SKEL_FIRE then
                 begin // Âçðûâ ñíàðÿäà Ñêåëåòà
-                  if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
-                  begin
-                    Anim := TAnimation.Create(TextureID, False, 8);
-                    Anim.Blending := False;
-                    g_GFX_OnceAnim((Obj.X+32)-58, (Obj.Y+8)-36, Anim);
-                    g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
-                    Anim.Free();
-                  end;
+                  r_GFX_OnceAnim(R_GFX_EXPLODE_SKELFIRE, Obj.X + 32 - 58, Obj.Y + 8 - 36);
+                  g_DynLightExplosion((Obj.X+32), (Obj.Y+8), 64, 1, 0, 0);
                 end
               else
                 begin // Âçðûâ Ðàêåòû
-                  if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
-                  begin
-                    Anim := TAnimation.Create(TextureID, False, 6);
-                    Anim.Blending := False;
-                    g_GFX_OnceAnim(cx-64, cy-64, Anim);
-                    g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
-                    Anim.Free();
-                  end;
+                  r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, cx - 64, cy - 64);
+                  g_DynLightExplosion(cx, cy, 64, 1, 0, 0);
                 end;
 
               g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
@@ -2257,22 +2223,11 @@ begin
                (Timeout < 1) then
             begin
               if ShotType = WEAPON_PLASMA then
-                s := 'FRAMES_EXPLODE_PLASMA'
+                r_GFX_OnceAnim(R_GFX_EXPLODE_PLASMA, cx - 16, cy - 16)
               else
-                s := 'FRAMES_EXPLODE_BSPFIRE';
-
-            // Âçðûâ Ïëàçìû:
-              if g_Frames_Get(TextureID, s) then
-              begin
-                Anim := TAnimation.Create(TextureID, False, 3);
-                Anim.Blending := False;
-                g_GFX_OnceAnim(cx-16, cy-16, Anim);
-                Anim.Free();
-                g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
-              end;
-
+                r_GFX_OnceAnim(R_GFX_EXPLODE_BSPFIRE, cx - 16, cy - 16);
+              g_DynLightExplosion(cx, cy, 32, 0, 0.5, 0.5);
               g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
-
               ShotType := 0;
             end;
           end;
@@ -2290,17 +2245,9 @@ begin
             begin
               if WordBool(st and MOVE_HITWATER) then
               begin
-                if g_Frames_Get(_id, 'FRAMES_SMOKE') then
-                begin
-                  Anim := TAnimation.Create(_id, False, 3);
-                  Anim.Alpha := 0;
-                  tcx := Random(8);
-                  tcy := Random(8);
-                  g_GFX_OnceAnim(cx-4+tcx-(Anim.Width div 2),
-                    cy-4+tcy-(Anim.Height div 2),
-                    Anim, ONCEANIM_SMOKE);
-                  Anim.Free();
-                end;
+                tcx := Random(8);
+                tcy := Random(8);
+                r_GFX_OnceAnim(R_GFX_SMOKE, cx-4+tcx-(R_GFX_SMOKE_WIDTH div 2), cy-4+tcy-(R_GFX_SMOKE_HEIGHT div 2));
               end
               else
                 g_GFX_Bubbles(cx, cy, 1+Random(3), 16, 16);
@@ -2343,17 +2290,13 @@ begin
 
             if (gTime mod LongWord(tf) = 0) then
             begin
-              g_Frames_Get(TextureID, 'FRAMES_FLAME');
-              Anim := TAnimation.Create(TextureID, False, 2 + Random(2));
-              Anim.Alpha := 0;
               case Stopped of
                 MOVE_HITWALL: begin tcx := cx-4+Random(8); tcy := cy-12+Random(24); end;
                 MOVE_HITLAND: begin tcx := cx-12+Random(24); tcy := cy-10+Random(8); end;
                 MOVE_HITCEIL: begin tcx := cx-12+Random(24); tcy := cy+6+Random(8); end;
                 else begin tcx := cx-4+Random(8); tcy := cy-4+Random(8); end;
               end;
-              g_GFX_OnceAnim(tcx-(Anim.Width div 2), tcy-(Anim.Height div 2), Anim, ONCEANIM_SMOKE);
-              Anim.Free();
+              r_GFX_OnceAnim(R_GFX_FLAME_RAND, tcx - (R_GFX_FLAME_WIDTH div 2), tcy - (R_GFX_FLAME_HEIGHT div 2));
               //g_DynLightExplosion(tcx, tcy, 1, 1, 0.8, 0.3);
             end;
           end;
@@ -2376,19 +2319,9 @@ begin
             begin
             // Ëó÷è BFG:
               if g_Game_IsServer then g_Weapon_BFG9000(cx, cy, SpawnerUID);
-
-            // Âçðûâ BFG:
-              if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
-              begin
-                Anim := TAnimation.Create(TextureID, False, 6);
-                Anim.Blending := False;
-                g_GFX_OnceAnim(cx-64, cy-64, Anim);
-                Anim.Free();
-                g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
-              end;
-
+              r_GFX_OnceAnim(R_GFX_EXPLODE_BFG, cx - 64, cy - 64);
+              g_DynLightExplosion(cx, cy, 96, 0, 1, 0);
               g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
-
               ShotType := 0;
             end;
           end;
@@ -2413,25 +2346,12 @@ begin
                (g_Weapon_Hit(@Obj, a, SpawnerUID, HIT_SOME) <> 0) or
                (Timeout < 1) then
             begin
-              if ShotType = WEAPON_IMP_FIRE then
-                s := 'FRAMES_EXPLODE_IMPFIRE'
-              else
-                if ShotType = WEAPON_CACO_FIRE then
-                  s := 'FRAMES_EXPLODE_CACOFIRE'
-                else
-                  s := 'FRAMES_EXPLODE_BARONFIRE';
-
-            // Âçðûâ:
-              if g_Frames_Get(TextureID, s) then
-              begin
-                Anim := TAnimation.Create(TextureID, False, 6);
-                Anim.Blending := False;
-                g_GFX_OnceAnim(cx-32, cy-32, Anim);
-                Anim.Free();
+              case ShotType of
+                WEAPON_IMP_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_IMPFIRE, cx - 32, cy - 32);
+                WEAPON_CACO_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_CACOFIRE, cx - 32, cy - 32);
+                WEAPON_BARON_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_BARONFIRE, cx - 32, cy - 32);
               end;
-
               g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
-
               ShotType := 0;
             end;
           end;
@@ -2448,16 +2368,8 @@ begin
                (Timeout < 1) then
             begin
             // Âçðûâ:
-              if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
-              begin
-                Anim := TAnimation.Create(TextureID, False, 6);
-                Anim.Blending := False;
-                g_GFX_OnceAnim(cx-64, cy-64, Anim);
-                Anim.Free();
-              end;
-
+              r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, cx - 64, cy - 64);
               g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
-
               ShotType := 0;
             end;
           end;
@@ -2618,11 +2530,7 @@ begin
 end;
 
 procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True);
-var
-  cx, cy: Integer;
-  Anim: TAnimation;
-  s: string;
-  TextureID: DWORD = DWORD(-1);
+  var cx, cy: Integer;
 begin
   if Shots = nil then
     Exit;
@@ -2642,93 +2550,48 @@ begin
         if Loud then
         begin
           if ShotType = WEAPON_SKEL_FIRE then
-          begin // Âçðûâ ñíàðÿäà Ñêåëåòà
-            if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_SKELFIRE') then
-            begin
-              Anim := TAnimation.Create(TextureID, False, 8);
-              Anim.Blending := False;
-              g_GFX_OnceAnim((Obj.X+32)-32, (Obj.Y+8)-32, Anim);
-              Anim.Free();
-            end;
-          end
+            r_GFX_OnceAnim(R_GFX_EXPLODE_SKELFIRE, (Obj.X + 32) - 32, (Obj.Y + 8) - 32)
           else
-          begin // Âçðûâ Ðàêåòû
-            if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
-            begin
-              Anim := TAnimation.Create(TextureID, False, 6);
-              Anim.Blending := False;
-              g_GFX_OnceAnim(cx-64, cy-64, Anim);
-              Anim.Free();
-            end;
-          end;
+            r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, cx - 64, cy - 64);
           g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', Obj.X, Obj.Y);
         end;
       end;
 
       WEAPON_PLASMA, WEAPON_BSP_FIRE: // Ïëàçìà, ïëàçìà Àðàõíàòðîíà
       begin
-        if ShotType = WEAPON_PLASMA then
-          s := 'FRAMES_EXPLODE_PLASMA'
-        else
-          s := 'FRAMES_EXPLODE_BSPFIRE';
-
-        if g_Frames_Get(TextureID, s) and loud then
+        if loud then
         begin
-          Anim := TAnimation.Create(TextureID, False, 3);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(cx-16, cy-16, Anim);
-          Anim.Free();
-
+          if ShotType = WEAPON_PLASMA then
+            r_GFX_OnceAnim(R_GFX_EXPLODE_PLASMA, cx - 16, cy - 16)
+          else
+            r_GFX_OnceAnim(R_GFX_EXPLODE_BSPFIRE, cx - 16, cy - 16);
           g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEPLASMA', Obj.X, Obj.Y);
         end;
       end;
 
       WEAPON_BFG: // BFG
       begin
-        // Âçðûâ BFG:
-        if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') and Loud then
-        begin
-          Anim := TAnimation.Create(TextureID, False, 6);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(cx-64, cy-64, Anim);
-          Anim.Free();
-
-          g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
-        end;
+        r_GFX_OnceAnim(R_GFX_EXPLODE_BFG, cx - 64, cy - 64);
+        g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', Obj.X, Obj.Y);
       end;
 
       WEAPON_IMP_FIRE, WEAPON_CACO_FIRE, WEAPON_BARON_FIRE: // Âûñòðåëû Áåñà, Êàêîäåìîíà Ðûöàðÿ/Áàðîíà àäà
       begin
-        if ShotType = WEAPON_IMP_FIRE then
-          s := 'FRAMES_EXPLODE_IMPFIRE'
-        else
-          if ShotType = WEAPON_CACO_FIRE then
-            s := 'FRAMES_EXPLODE_CACOFIRE'
-          else
-            s := 'FRAMES_EXPLODE_BARONFIRE';
-
-        if g_Frames_Get(TextureID, s) and Loud then
+        if loud then
         begin
-          Anim := TAnimation.Create(TextureID, False, 6);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(cx-32, cy-32, Anim);
-          Anim.Free();
-
+          case ShotType of
+            WEAPON_IMP_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_IMPFIRE, cx - 32, cy - 32);
+            WEAPON_CACO_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_CACOFIRE, cx - 32, cy - 32);
+            WEAPON_BARON_FIRE: r_GFX_OnceAnim(R_GFX_EXPLODE_BARONFIRE, cx - 32, cy - 32);
+          end;
           g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
         end;
       end;
 
       WEAPON_MANCUB_FIRE: // Âûñòðåë Ìàíêóáóñà
       begin
-        if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') and Loud then
-        begin
-          Anim := TAnimation.Create(TextureID, False, 6);
-          Anim.Blending := False;
-          g_GFX_OnceAnim(cx-64, cy-64, Anim);
-          Anim.Free();
-
-          g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
-        end;
+        r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, cx - 64, cy - 64);
+        g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBALL', Obj.X, Obj.Y);
       end;
     end; // case ShotType of...
 
index 0bd271a1f7840b3802552a83c058abac072860f4..91b9c38c670d5a0e64ddd4b042d2bb4e72ff3a22 100644 (file)
@@ -17,7 +17,38 @@ unit r_gfx;
 
 interface
 
+  const
+    R_GFX_NONE = 0;
+    R_GFX_TELEPORT = 1;
+    R_GFX_FLAME = 2;
+    R_GFX_EXPLODE_ROCKET = 3;
+    R_GFX_EXPLODE_BFG = 4;
+    R_GFX_BFG_HIT = 5;
+    R_GFX_FIRE = 6;
+    R_GFX_ITEM_RESPAWN = 7;
+    R_GFX_SMOKE = 8;
+    R_GFX_EXPLODE_SKELFIRE = 9;
+    R_GFX_EXPLODE_PLASMA = 10;
+    R_GFX_EXPLODE_BSPFIRE = 11;
+    R_GFX_EXPLODE_IMPFIRE = 12;
+    R_GFX_EXPLODE_CACOFIRE = 13;
+    R_GFX_EXPLODE_BARONFIRE = 14;
+    R_GFX_TELEPORT_FAST = 15;
+    R_GFX_SMOKE_TRANS = 16;
+    R_GFX_FLAME_RAND = 17;
+    R_GFX_LAST = 17;
+
+    R_GFX_FLAME_WIDTH = 32;
+    R_GFX_FLAME_HEIGHT = 32;
+    R_GFX_SMOKE_WIDTH = 32;
+    R_GFX_SMOKE_HEIGHT = 32;
+
+  procedure r_GFX_Load;
+  procedure r_GFX_Free;
   procedure r_GFX_Draw;
+  procedure r_GFX_Update;
+
+  procedure r_GFX_OnceAnim (AnimType, X, Y: Integer);
 
 implementation
 
@@ -26,10 +57,156 @@ implementation
     SysUtils, Classes, Math,
     utils,
     g_base, r_graphics, g_options, r_animations,
-    g_game,
+    g_game, g_textures,
     g_gfx
   ;
 
+  type
+    TOnceAnim = record
+      AnimType:   Byte;
+      x, y:       Integer;
+      oldX, oldY: Integer;
+      Animation:  TAnimationState;
+    end;
+
+  var
+    OnceAnims: array of TOnceAnim = nil;
+    gfxFrames: array [0..R_GFX_LAST] of DWORD;
+
+  procedure r_GFX_Load;
+  begin
+    g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False);
+    g_Frames_Get(gfxFrames[R_GFX_TELEPORT], 'FRAMES_TELEPORT');
+    g_Frames_Get(gfxFrames[R_GFX_FLAME], 'FRAMES_FLAME');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_ROCKET], 'FRAMES_EXPLODE_ROCKET');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BFG], 'FRAMES_EXPLODE_BFG');
+    g_Frames_Get(gfxFrames[R_GFX_BFG_HIT], 'FRAMES_BFGHIT');
+    g_Frames_Get(gfxFrames[R_GFX_FIRE], 'FRAMES_FIRE');
+    g_Frames_Get(gfxFrames[R_GFX_ITEM_RESPAWN], 'FRAMES_ITEM_RESPAWN');
+    g_Frames_Get(gfxFrames[R_GFX_SMOKE], 'FRAMES_SMOKE');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_SKELFIRE], 'FRAMES_EXPLODE_SKELFIRE');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_PLASMA], 'FRAMES_EXPLODE_PLASMA');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BSPFIRE], 'FRAMES_EXPLODE_BSPFIRE');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_IMPFIRE], 'FRAMES_EXPLODE_IMPFIRE');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_CACOFIRE], 'FRAMES_EXPLODE_CACOFIRE');
+    g_Frames_Get(gfxFrames[R_GFX_EXPLODE_BARONFIRE], 'FRAMES_EXPLODE_BARONFIRE');
+  end;
+
+  procedure r_GFX_Free;
+    var a: Integer;
+  begin
+    g_Frames_DeleteByName('FRAMES_TELEPORT');
+    if OnceAnims <> nil then
+    begin
+      for a := 0 to High(OnceAnims) do
+        OnceAnims[a].Animation.Free();
+      OnceAnims := nil;
+    end;
+  end;
+
+  function FindOnceAnim (): DWORD;
+    var i: Integer;
+  begin
+    if OnceAnims <> nil then
+      for i := 0 to High(OnceAnims) do
+        if OnceAnims[i].Animation = nil then
+        begin
+          Result := i;
+          Exit;
+        end;
+    if OnceAnims = nil then
+    begin
+      SetLength(OnceAnims, 16);
+      Result := 0;
+    end
+    else
+    begin
+      Result := High(OnceAnims) + 1;
+      SetLength(OnceAnims, Length(OnceAnims) + 16);
+    end;
+  end;
+
+  procedure r_GFX_OnceAnim (AnimType, x, y: Integer);
+    var find_id: DWORD; a: TAnimationState;
+  begin
+    if not gpart_dbg_enabled then exit;
+    find_id := FindOnceAnim();
+    case AnimType of
+      R_GFX_NONE: a := nil;
+      R_GFX_TELEPORT: a := TAnimationState.Create(false, 6, 10); // !!! speed can be 3
+      R_GFX_TELEPORT_FAST:
+      begin
+        AnimType := R_GFX_TELEPORT;
+        a := TAnimationState.Create(false, 3, 10);
+      end;
+      R_GFX_FLAME: a := TAnimationState.Create(false, 3, 11);
+      R_GFX_FLAME_RAND:
+      begin
+        AnimType := R_GFX_FLAME;
+        a := TAnimationState.Create(false, 2 + Random(2), 10);
+      end;
+      R_GFX_EXPLODE_ROCKET: a := TAnimationState.Create(false, 6, 6);
+      R_GFX_EXPLODE_BFG: a := TAnimationState.Create(false, 6, 6);
+      R_GFX_BFG_HIT: a := TAnimationState.Create(false, 4, 4);
+      R_GFX_FIRE: a := TAnimationState.Create(false, 4, 8); // !!! speed can be random
+      R_GFX_ITEM_RESPAWN: a := TAnimationState.Create(false, 4, 5);
+      R_GFX_SMOKE: a := TAnimationState.Create(false, 3, 10);
+      R_GFX_SMOKE_TRANS:
+      begin
+        AnimType := R_GFX_SMOKE;
+        a := TAnimationState.Create(false, 3, 10);
+        a.alpha := 150;
+      end;
+      R_GFX_EXPLODE_SKELFIRE: a := TAnimationState.Create(false, 8, 3);
+      R_GFX_EXPLODE_PLASMA: a := TAnimationState.Create(false, 3, 4);
+      R_GFX_EXPLODE_BSPFIRE: a := TAnimationState.Create(false, 3, 5);
+      R_GFX_EXPLODE_IMPFIRE: a := TAnimationState.Create(false, 6, 3);
+      R_GFX_EXPLODE_CACOFIRE: a := TAnimationState.Create(false, 6, 3);
+      R_GFX_EXPLODE_BARONFIRE: a := TAnimationState.Create(false, 6, 3);
+    else
+      a := nil;
+      assert(false)
+    end;
+    OnceAnims[find_id].AnimType := AnimType;
+    OnceAnims[find_id].Animation := a;
+//    OnceAnims[find_id].Animation.Blending := Anim.Blending;
+//    OnceAnims[find_id].Animation.alpha := Anim.alpha;
+    OnceAnims[find_id].x := x;
+    OnceAnims[find_id].y := y;
+  end;
+
+  procedure r_GFX_Update;
+    var a: Integer;
+  begin
+    if OnceAnims <> nil then
+    begin
+      for a := 0 to High(OnceAnims) do
+      begin
+        if OnceAnims[a].Animation <> nil then
+        begin
+          OnceAnims[a].oldx := OnceAnims[a].x;
+          OnceAnims[a].oldy := OnceAnims[a].y;
+          case OnceAnims[a].AnimType of
+            R_GFX_FLAME, R_GFX_SMOKE: (*ONCEANIM_SMOKE:*)
+            begin
+              if Random(3) = 0 then
+                OnceAnims[a].x := OnceAnims[a].x-1+Random(3);
+              if Random(2) = 0 then
+                OnceAnims[a].y := OnceAnims[a].y-Random(2);
+            end;
+          end;
+          if OnceAnims[a].Animation.Played then
+          begin
+            OnceAnims[a].Animation.Free();
+            OnceAnims[a].Animation := nil;
+          end
+          else
+            OnceAnims[a].Animation.Update();
+        end;
+      end;
+    end;
+  end;
+
 procedure r_GFX_Draw;
   var
     a, len, fx, fy: Integer;
@@ -81,7 +258,7 @@ begin
         begin
           fx := nlerp(oldx, x, gLerpFactor);
           fy := nlerp(oldy, y, gLerpFactor);
-          r_Animation_Draw(Animation, x, y, TMirrorType.None);
+          r_AnimationState_Draw(gfxFrames[AnimType], Animation, x, y, TMirrorType.None);
         end;
       end;
     end;
index c424e51771c8efddda4b51d51fa391f053d6ad8b..cac3b8f811826076175a2e4bd09e925b66ff4dfc 100644 (file)
@@ -34,7 +34,7 @@ implementation
     e_log, g_system,
     g_game, g_options, g_console,
     r_window, r_graphics, r_console, r_playermodel,
-    r_weapons, r_items
+    r_weapons, r_items, r_gfx
   ;
 
   var
@@ -77,10 +77,12 @@ implementation
   begin
     r_Weapon_Load;
     r_Items_Load;
+    r_GFX_Load;
   end;
 
   procedure r_Render_Free;
   begin
+    r_GFX_Free;
     r_Items_Free;
     r_Weapon_Free;
   end;