Get rid of overloaded functions in uAmmo
authorunc0rr
Tue, 24 Apr 2012 23:50:40 +0400
changeset 6924 57b66ee3bff3
parent 6923 d2405a6a86f5
child 6925 1fbf9266ba52
Get rid of overloaded functions in uAmmo
hedgewars/GSHandlers.inc
hedgewars/uAmmos.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsRender.pas
hedgewars/uScript.pas
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/GSHandlers.inc	Tue Apr 24 23:50:40 2012 +0400
@@ -3973,7 +3973,7 @@
                     begin
                     CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch);
                 
-                    CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+                    CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
                     if CurWeapon^.Pos <> 0 then
                         CurWeapon^.Pos := 0
                         
@@ -4344,7 +4344,7 @@
     if CurrentHedgehog <> nil then
         with CurrentHedgehog^ do
             begin
-            CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+            CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
             if (CurAmmoType = amPortalGun) then
                 begin
                 if not destroyGear then
@@ -4444,7 +4444,7 @@
     if CurrentHedgehog <> nil then
         with CurrentHedgehog^ do
             begin
-            CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+            CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
             // let's save the HH's dX's direction so we can decide where the "top" of the portal hole
             newPortal^.Elasticity.isNegative := CurrentHedgehog^.Gear^.dX.isNegative;
             // when doing a backjump the dx is the opposite of the facing direction
--- a/hedgewars/uAmmos.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uAmmos.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -32,7 +32,7 @@
 procedure SetAmmoReinforcement(var s: shortstring);
 procedure AssignStores;
 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
-procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
+procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
 procedure OnUsedAmmo(var Hedgehog: THedgehog);
@@ -43,7 +43,7 @@
 procedure DisableSomeWeapons;
 procedure ResetWeapons;
 function  GetAmmoByNum(num: Longword): PHHAmmo;
-function  GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
+function  GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
 function  GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
 
 var StoreCnt: Longword;
@@ -149,9 +149,9 @@
 exit(StoresList[num])
 end;
 
-function GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
+function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
 begin
-GetAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
+GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
 end;
 
 function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
@@ -200,11 +200,11 @@
 if (cnt <> AMMO_INFINITE) then
     begin
     inc(cnt, Ammoz[ammo].NumberInCase);
-    AddAmmo(Hedgehog, ammo, cnt)
+    SetAmmo(Hedgehog, ammo, cnt)
     end
 end;
 
-procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
+procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
 var ammos: TAmmoCounts;
     slot, ami: LongInt;
     hhammo: PHHAmmo;
@@ -224,7 +224,7 @@
 if ammos[ammo] > AMMO_INFINITE then ammos[ammo]:= AMMO_INFINITE;
 
 FillAmmoStore(hhammo, ammos);
-CurWeapon:= GetAmmoEntry(Hedgehog);
+CurWeapon:= GetCurAmmoEntry(Hedgehog);
 with Hedgehog, CurWeapon^ do
     if (Count = 0) or (AmmoType = amNothing) then
         begin
@@ -258,7 +258,7 @@
 procedure OnUsedAmmo(var Hedgehog: THedgehog);
 var CurWeapon: PAmmo;
 begin
-CurWeapon:= GetAmmoEntry(Hedgehog);
+CurWeapon:= GetCurAmmoEntry(Hedgehog);
 with Hedgehog do
     begin
 
@@ -352,14 +352,14 @@
     begin
     Timer:= 10;
 
-    CurWeapon:= GetAmmoEntry(Hedgehog);
+    CurWeapon:= GetCurAmmoEntry(Hedgehog);
 
     if (CurWeapon^.Count = 0) then
         SwitchToFirstLegalAmmo(Hedgehog)
     else if CurWeapon^.AmmoType = amNothing then
         Hedgehog.CurAmmoType:= amNothing;
 
-    CurWeapon:= GetAmmoEntry(Hedgehog);
+    CurWeapon:= GetCurAmmoEntry(Hedgehog);
 
     ApplyAngleBounds(Hedgehog, CurWeapon^.AmmoType);
 
--- a/hedgewars/uGearsHedgehog.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -131,7 +131,7 @@
     color: LongWord;
 begin
 Gear^.Message:= Gear^.Message and (not gmTimer);
-CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
+CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
 with Gear^.Hedgehog^ do
     if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then
         begin
@@ -178,7 +178,7 @@
 begin
 newGear:= nil;
 bShowFinger:= false;
-CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
+CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
 with Gear^,
     Gear^.Hedgehog^ do
         begin
@@ -640,7 +640,7 @@
 var PrevdX: LongInt;
     CurWeapon: PAmmo;
 begin
-CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
+CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
 if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
     begin
     if isCursorVisible then
--- a/hedgewars/uGearsRender.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uGearsRender.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -592,7 +592,7 @@
                 dec(HH^.Timer)
                 end;
             amt:= CurrentHedgehog^.CurAmmoType;
-            CurWeapon:= GetAmmoEntry(HH^);
+            CurWeapon:= GetCurAmmoEntry(HH^);
             case amt of
                 amBazooka: DrawRotated(sprHandBazooka, hx, hy, sign, aangle);
                 amSnowball: DrawRotated(sprHandSnowball, hx, hy, sign, aangle);
--- a/hedgewars/uScript.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uScript.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -1023,7 +1023,7 @@
             if lua_gettop(L) = 2 then
                 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)))
             else
-                AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3))
+                SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3))
         end
     else LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
     lc_addammo:= 0
--- a/hedgewars/uTeams.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uTeams.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -228,7 +228,7 @@
 
 inc(CurrentTeam^.Clan^.TurnNumber);
 
-CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
 if CurWeapon^.Count = 0 then
     CurrentHedgehog^.CurAmmoType:= amNothing;
 
--- a/hedgewars/uWorld.pas	Tue Apr 24 23:33:39 2012 +0400
+++ b/hedgewars/uWorld.pas	Tue Apr 24 23:50:40 2012 +0400
@@ -1585,7 +1585,7 @@
                 begin
             if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
                 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
-            i:= GetAmmoEntry(CurrentHedgehog^)^.Pos;
+            i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
             with Ammoz[CurAmmoType] do
                 if PosCount > 1 then
                     DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);