- Formatting changes
authorunc0rr
Mon, 09 Nov 2009 20:29:21 +0000
changeset 2608 cebfea02f8b5
parent 2607 dbeaba78e676
child 2609 b67624c7d61e
- Formatting changes - Rename AttacksNum variable - Fix a bug when OnAmmoUsed wasn't called in some conditions
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/options.inc
hedgewars/uAI.pas
hedgewars/uAmmos.pas
hedgewars/uGears.pas
hedgewars/uTeams.pas
--- a/hedgewars/CCHandlers.inc	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Mon Nov 09 20:29:21 2009 +0000
@@ -581,7 +581,7 @@
           bSelected:= false;
 
           if bShowAmmoMenu then bShowAmmoMenu:= false
-          else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
+          else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (MultiShootAttacks > 0)
                or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
           end
 end;
--- a/hedgewars/GSHandlers.inc	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Nov 09 20:29:21 2009 +0000
@@ -494,7 +494,7 @@
 	or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
     begin
     if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then cLaserSighting:= false;
-    if (Gear^.Ammo^.NumPerTurn <= CurrentHedgehog^.AttacksNum) and
+    if (Gear^.Ammo^.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and
        ((GameFlags and gfArtillery) = 0) then cArtillery:= false;
 	Gear^.doStep:= @doStepShotIdle
     end;
@@ -541,10 +541,8 @@
     dec(TurnTimeLeft)
 else
     begin
-    PHedgehog(Gear^.Hedgehog)^.AttacksNum:= Gear^.Ammo^.NumPerTurn+1;
 	DeleteGear(Gear);
-	AfterAttack;
-    TurnTimeLeft:= 0
+	AfterAttack
     end;
 end;
 
--- a/hedgewars/HHHandlers.inc	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/HHHandlers.inc	Mon Nov 09 20:29:21 2009 +0000
@@ -27,7 +27,7 @@
 	Gear^.Message:= Gear^.Message and not gm_Slot;
 
 	if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0)
-		or (AttacksNum > 0)
+		or (MultiShootAttacks > 0)
 		or ((Gear^.State and gstHHDriven) = 0) then exit;
 
 	Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
@@ -242,18 +242,18 @@
 	State:= State and not gstAttacking;
 	if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_Utility) = 0 then
 		begin
-		Inc(AttacksNum);
+		Inc(MultiShootAttacks);
 		
-		if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum) then
+		if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) then
 			begin
-			s:= inttostr(Ammo^[CurSlot, CurAmmo].NumPerTurn + 1 - AttacksNum);
+			s:= inttostr(Ammo^[CurSlot, CurAmmo].NumPerTurn + 1 - MultiShootAttacks);
 			AddCaption(format(trmsg[sidRemaining], s),
 				$FFFFFF,
 				capgrpAmmostate);
 			end;
-				
-		if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum) or
-		((GameFlags and gfMultiWeapon) <> 0) then
+		
+		if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) or
+			((GameFlags and gfMultiWeapon) <> 0) then
 			begin
 			isInMultiShoot:= true
 			end
@@ -265,10 +265,10 @@
 			end;
 		end
 	else
-	begin
-	OnUsedAmmo(CurrentHedgehog^);
-	ApplyAmmoChanges(CurrentHedgehog^);
-	end;
+		begin
+		OnUsedAmmo(CurrentHedgehog^);
+		ApplyAmmoChanges(CurrentHedgehog^);
+		end;
 	AttackBar:= 0;
 	end
 end;
--- a/hedgewars/options.inc	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/options.inc	Mon Nov 09 20:29:21 2009 +0000
@@ -20,6 +20,8 @@
   {$J+}
 {$ENDIF}
 
+{$DEFINE DEBUGFILE}
+
 {$IFDEF DEBUGFILE}
   {$DEFINE DUMP}
   {$DEFINE TRACEAIACTIONS}
--- a/hedgewars/uAI.pas	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/uAI.pas	Mon Nov 09 20:29:21 2009 +0000
@@ -112,7 +112,7 @@
         if a = High(TAmmoType) then a:= Low(TAmmoType)
                                else inc(a)
        until (a = aa) or
-             (CurrentHedgehog^.AttacksNum > 0) or
+             (CurrentHedgehog^.MultiShootAttacks > 0) or // shooting same weapon
              StopThinking
        end
 end;
--- a/hedgewars/uAmmos.pas	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/uAmmos.pas	Mon Nov 09 20:29:21 2009 +0000
@@ -173,6 +173,7 @@
 begin
 with Hedgehog do
 	begin
+	MultiShootAttacks:= 0;
 	with Ammo^[CurSlot, CurAmmo] do
 		if Count <> AMMO_INFINITE then
 			begin
--- a/hedgewars/uGears.pas	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/uGears.pas	Mon Nov 09 20:29:21 2009 +0000
@@ -622,23 +622,26 @@
 			inc(step)
 			end;
 	stNTurn: begin
-			if isInMultiShoot then isInMultiShoot:= false
+			if isInMultiShoot then
+				isInMultiShoot:= false
 			else begin
-			// delayed till after 0.9.12
-			// reset to default zoom
-			//ZoomValue:= ZoomDefault;
-			ResetUtilities;
-
-			FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
+				// delayed till after 0.9.12
+				// reset to default zoom
+				//ZoomValue:= ZoomDefault;
+				with CurrentHedgehog^ do
+					if ((Gear^.State and gstAttacked) = 0)
+						and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
+				
+				ResetUtilities;
 
-			ParseCommand('/nextturn', true);
-			SwitchHedgehog;
+				FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
 
-			inc(step); // FIXME wtf is that, it overflows step, and does nothing
+				ParseCommand('/nextturn', true);
+				SwitchHedgehog;
 
-			AfterSwitchHedgehog;
-			bBetweenTurns:= false
-			end;
+				AfterSwitchHedgehog;
+				bBetweenTurns:= false
+				end;
 			step:= Low(step)
 			end;
 	end;
--- a/hedgewars/uTeams.pas	Mon Nov 09 18:44:09 2009 +0000
+++ b/hedgewars/uTeams.pas	Mon Nov 09 20:29:21 2009 +0000
@@ -46,7 +46,7 @@
 			AmmoStore: Longword;
 			CurSlot, CurAmmo: LongWord;
 			Team: PTeam;
-			AttacksNum: Longword;
+			MultiShootAttacks: Longword;
 			visStepPos: LongWord;
 			BotLevel  : LongWord; // 0 - Human player
 			HatVisibility: GLfloat;
@@ -170,7 +170,7 @@
 with CurrentHedgehog^ do
 	if Gear <> nil then
 		begin
-		AttacksNum:= 0;
+		MultiShootAttacks:= 0;
 		Gear^.Message:= 0;
 		Gear^.Z:= cHHZ;
 		RemoveGearFromList(Gear);