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>
Fri, 9 Jun 2023 07:50:57 +0000 (10:50 +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 ab55a6c11c439135a33a94c28f3c47ca71b8b5e2..365c0444c34fcb21c0517f25ee98a8008b22ca30 100644 (file)
@@ -448,7 +448,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,
@@ -2266,6 +2266,7 @@ begin
     g_Weapon_Update();
     g_Monsters_Update();
     g_GFX_Update();
+    r_GFX_Update;
     g_Player_UpdateAll();
     g_Player_UpdatePhysicalObjects();
 
@@ -2557,7 +2558,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);
@@ -2700,7 +2700,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 1ee3fec1b60dd6f7490401081245f37770940e60..6ff6b86e6010e11caf2ba007fc645c388fe61c05 100644 (file)
@@ -93,7 +93,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;
@@ -416,8 +416,6 @@ end;
 procedure g_Items_Update ();
 var
   i, j, k: Integer;
-  ID: DWord;
-  Anim: TAnimation;
   m, ItemRespawnTime: Word;
   r, nxt: Boolean;
 begin
@@ -511,14 +509,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 f12b16d68e2cceecbae3297543b3bf31f375feff..fac6a7b5fe597e937fd30f9e2980ee79d17ca128 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,
@@ -4616,23 +4614,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 134b995a149e05af8c58a4e554d4fc1c4976e245..a2e2bc944d5ec6651f93b41a55b749e431255a5d 100644 (file)
@@ -284,7 +284,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;
@@ -1723,8 +1723,6 @@ var
   Kind: Byte;
   X, Y: Integer;
   Ang: SmallInt;
-  Anim: TAnimation;
-  ID: LongWord;
 begin
   if not gGameOn then Exit;
   Kind := M.ReadByte();
@@ -1738,72 +1736,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;
@@ -2740,11 +2706,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;
@@ -2768,12 +2732,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 7bb2248c6d7ef5dad598c0fbc095cf03f019ff39..acd49d048b697a658d07a6e02cf64f1b88789a4c 100644 (file)
@@ -659,7 +659,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,
@@ -3873,8 +3873,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;
@@ -4019,13 +4017,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;
@@ -4205,9 +4201,6 @@ begin
 end;
 
 function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
-var
-  Anim: TAnimation;
-  ID: DWORD;
 begin
   Result := False;
 
@@ -4221,17 +4214,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,
@@ -4277,12 +4267,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,
@@ -5762,9 +5753,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;
@@ -5779,37 +5768,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 da9e333696843395097630e55bcefc21a29cd24d..422f9368c6e6a546377ec22d6a6d57e15d189b58 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
@@ -898,33 +880,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;
@@ -1179,8 +1146,6 @@ var
   iid: LongWord;
   coolDown: Boolean;
   pAngle: Real;
-  FramesID: DWORD;
-  Anim: TAnimation;
   UIDType: Byte;
   TargetUID: Word;
   it: PItem;
@@ -1509,42 +1474,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,
@@ -1602,14 +1561,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,
@@ -1617,14 +1574,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,
@@ -1632,14 +1587,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 d2bb2dd451363d13a3b53a4b276bd49ee48d310f..a5114e15a613670dd90af85c54bd33668b9ce2c0 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;
@@ -2013,16 +2013,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;
@@ -2119,12 +2111,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;
@@ -2202,8 +2190,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
@@ -2219,13 +2205,9 @@ begin
                 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', cx, cy)
                 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', cx, cy);
             end
-            else if g_Frames_Get(_id, 'FRAMES_SMOKE') then
+            else
             begin
-              Anim := TAnimation.Create(_id, False, 3);
-              Anim.Alpha := 150;
-              g_GFX_OnceAnim(Obj.X-14+Random(9), cy-20+Random(9),
-                             Anim, ONCEANIM_SMOKE);
-              Anim.Free();
+              r_GFX_OnceAnim(R_GFX_SMOKE_TRANS, Obj.X-14+Random(9), cy-20+Random(9));
             end;
 
           // Ïîïàëè â êîãî-òî èëè â ñòåíó:
@@ -2240,25 +2222,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);
@@ -2303,22 +2273,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;
@@ -2336,17 +2295,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
               begin
@@ -2394,17 +2345,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;
@@ -2427,19 +2374,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;
@@ -2464,25 +2401,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;
@@ -2499,16 +2423,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;
@@ -2669,11 +2585,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;
@@ -2693,93 +2605,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;