DEADSOFTWARE

models: remove superfluous fire state
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 16 Jan 2022 17:22:21 +0000 (20:22 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 16 Jan 2022 17:22:21 +0000 (20:22 +0300)
src/game/g_player.pas
src/game/g_playermodel.pas
src/game/opengl/r_playermodel.pas

index c2605a092509cd28d1f5bbf36c64a5e7fb7a1014..72766a7600dfb533dcd8ba085812a85f0c2d3d3a 100644 (file)
@@ -4680,7 +4680,7 @@ begin
   if (FModel.AnimState.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
   then SetAction(A_STAND, True);
 
   if (FModel.AnimState.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
   then SetAction(A_STAND, True);
 
-  if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.Fire) then FModel.Update;
+  if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.GetFire()) then FModel.Update;
 
   for b := Low(FKeys) to High(FKeys) do
     if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
 
   for b := Low(FKeys) to High(FKeys) do
     if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
index 34fc9e71ef620206bbe9a4eda0a0f21923294519..393e07d6fa7f426cfad03d5b3f83f82033ed89bf 100644 (file)
@@ -110,7 +110,6 @@ type
     FAnimState:        TAnimationState;
     FCurrentWeapon:    Byte;
     FFlag:             Byte;
     FAnimState:        TAnimationState;
     FCurrentWeapon:    Byte;
     FFlag:             Byte;
-    FFire:             Boolean;
     FFireCounter:      Byte;
     FID:               Integer;
 
     FFireCounter:      Byte;
     FID:               Integer;
 
@@ -120,7 +119,8 @@ type
     procedure   SetColor(Red, Green, Blue: Byte);
     procedure   SetWeapon(Weapon: Byte);
     procedure   SetFlag(Flag: Byte);
     procedure   SetColor(Red, Green, Blue: Byte);
     procedure   SetWeapon(Weapon: Byte);
     procedure   SetFlag(Flag: Byte);
-    procedure   SetFire(Fire: Boolean);
+    procedure   SetFire (Fire: Boolean);
+    function    GetFire (): Boolean;
     function    PlaySound(SoundType, Level: Byte; X, Y: Integer): Boolean;
     procedure   Update();
 
     function    PlaySound(SoundType, Level: Byte; X, Y: Integer): Boolean;
     procedure   Update();
 
@@ -128,7 +128,6 @@ type
     function GetName (): String;
 
   published
     function GetName (): String;
 
   published
-    property    Fire: Boolean read FFire;
     property    Direction: TDirection read FDirection write FDirection;
     property    Animation: Byte read FCurrentAnimation;
     property    Weapon: Byte read FCurrentWeapon;
     property    Direction: TDirection read FDirection write FDirection;
     property    Animation: Byte read FCurrentAnimation;
     property    Weapon: Byte read FCurrentWeapon;
@@ -876,14 +875,18 @@ begin
   FColor.B := Blue;
 end;
 
   FColor.B := Blue;
 end;
 
-procedure TPlayerModel.SetFire(Fire: Boolean);
-begin
-  FFire := Fire;
-  if FFire then
-    FFireCounter := PlayerModelsArray[FID].ModelSpeed[A_ATTACK] * PlayerModelsArray[FID].Anim[TDirection.D_RIGHT, A_ATTACK].Frames
-  else
-    FFireCounter := 0
-end;
+  procedure TPlayerModel.SetFire (Fire: Boolean);
+  begin
+    if Fire then
+      FFireCounter := PlayerModelsArray[FID].ModelSpeed[A_ATTACK] * PlayerModelsArray[FID].Anim[TDirection.D_RIGHT, A_ATTACK].Frames
+    else
+      FFireCounter := 0
+  end;
+
+  function TPlayerModel.GetFire (): Boolean;
+  begin
+    Result := FFireCounter > 0
+  end;
 
   procedure TPlayerModel.SetFlag (Flag: Byte);
   begin
 
   procedure TPlayerModel.SetFlag (Flag: Byte);
   begin
@@ -911,8 +914,6 @@ end;
       FAnimState.Update;
     if FFireCounter > 0 then
       Dec(FFireCounter)
       FAnimState.Update;
     if FFireCounter > 0 then
       Dec(FFireCounter)
-    else
-      FFire := False
   end;
 
   procedure g_PlayerModel_LoadAll;
   end;
 
   procedure g_PlayerModel_LoadAll;
index b90ed0514249c89a076237d89b6016c38bef7740..0914bd007798e7991277bddd9ee3c43cae32b4cc 100644 (file)
@@ -242,7 +242,7 @@ begin
       else
         pos := W_POS_NORMAL;
 
       else
         pos := W_POS_NORMAL;
 
-    if (pm.CurrentAnimation in [A_ATTACK, A_ATTACKUP, A_ATTACKDOWN]) or pm.Fire then
+    if (pm.CurrentAnimation in [A_ATTACK, A_ATTACKUP, A_ATTACKDOWN]) or pm.GetFire() then
       act := W_ACT_FIRE
     else
       act := W_ACT_NORMAL;
       act := W_ACT_FIRE
     else
       act := W_ACT_NORMAL;