Change all use of curslot/idx to CurAmmoType to try and avoid some bugs with use of last weapon.
NEEDS TESTING.
Also disable cheese in pro, remove some unused vars.
--- a/QTfrontend/hwconsts.cpp.in Mon Sep 06 20:40:58 2010 +0100
+++ b/QTfrontend/hwconsts.cpp.in Mon Sep 06 16:23:47 2010 -0400
@@ -47,7 +47,7 @@
"000000000000000000000000000000000000000000000000"
"131111031211111112311411111111111111121111010111"))
<< qMakePair(QString("Pro mode"), QString(
- "909000900000000000000900000000000000000000090000"
+ "909000900000000000000900000000000000000000000000"
"000000000000000000000000000000000000000000000000"
"000000000000020550000004000700400000000020000000"
"111111111111111111111111111111111111111110010111"))
--- a/hedgewars/CCHandlers.inc Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/CCHandlers.inc Mon Sep 06 16:23:47 2010 -0400
@@ -623,7 +623,7 @@
end;
{$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
State:= State and not gstHHChooseTarget;
- if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
+ if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
Message:= Message or gm_Attack;
end
else
@@ -693,7 +693,7 @@
if bShowAmmoMenu then bShowAmmoMenu:= false
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
- ((MultiShootAttacks > 0) and ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NoRoundEndHint) = 0)) or
+ ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) = 0)) or
((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
end;
if ReadyTimeLeft > 1 then ReadyTimeLeft:= 1
--- a/hedgewars/GSHandlers.inc Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/GSHandlers.inc Mon Sep 06 16:23:47 2010 -0400
@@ -697,7 +697,7 @@
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0)
and (Land[y, x] <> 0) then inc(Gear^.Damage);
if Gear^.Damage > 5 then
- if Gear^.Ammo^.AmmoType = amDEagle then
+ if Gear^.AmmoType = amDEagle then
AmmoShove(Gear, 7, 20)
else
AmmoShove(Gear, Gear^.Timer, 20);
@@ -727,7 +727,7 @@
begin
if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then
cLaserSighting := false;
- if (Gear^.Ammo^.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and
+ if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and
((GameFlags and gfArtillery) = 0) then cArtillery := false;
Gear^.doStep := @doStepShotIdle
end;
@@ -1270,7 +1270,7 @@
with PHedgehog(Gear^.Hedgehog)^ do
begin
PlaySound(sndRopeRelease);
- if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then
+ if CurAmmoType <> amParachute then
WaitCollision
else
DeleteMe
@@ -3266,22 +3266,23 @@
////////////////////////////////////////////////////////////////////////////////
procedure doPortalColorSwitch();
-var
- flags: LongWord;
+var flags: LongWord;
+ CurWeapon: PAmmo;
begin
if (CurrentHedgehog <> nil)
and (CurrentHedgehog^.Gear <> nil)
and ((CurrentHedgehog^.Gear^.Message and gm_Switch) <> 0) then
With CurrentHedgehog^ do
- if (Ammo^[CurSlot, CurAmmo].AmmoType = amPortalGun) then
+ if (CurAmmoType = amPortalGun) then
begin
CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gm_Switch;
-
- flags := Ammo^[CurSlot, CurAmmo].Timer and not 2;
+
+ CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+ flags := CurWeapon^.Timer and not 2;
if (flags and 1) = 0 then
- Ammo^[CurSlot, CurAmmo].Timer := flags or 1
+ CurWeapon^.Timer := flags or 1
else
- Ammo^[CurSlot, CurAmmo].Timer := flags and not 1;
+ CurWeapon^.Timer := flags and not 1;
end;
end;
@@ -3448,13 +3449,13 @@
{ // breaks (some) loops
if Distance(iterator^.dX, iterator^.dY) > _0_96 then
- begin
+ begin
iterator^.dX := iterator^.dX + signAs(cGravity * getRandom(1000),iterator^.dX);
iterator^.dY := iterator^.dY + signAs(cGravity * getRandom(1000),iterator^.dY);
s := _0_96 / Distance(iterator^.dX, iterator^.dY);
iterator^.dX := s * iterator^.dX;
iterator^.dY := s * iterator^.dX;
- end;
+ end;
}
end;
end;
@@ -3467,20 +3468,24 @@
procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean);
var
flags: LongWord;
+ CurWeapon: PAmmo;
begin
if CurrentHedgehog <> nil then
- With CurrentHedgehog^ do
- if (Ammo^[CurSlot, CurAmmo].AmmoType = amPortalGun) then
+ with CurrentHedgehog^ do
begin
- flags := Ammo^[CurSlot, CurAmmo].Timer;
+ CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+ if (CurAmmoType = amPortalGun) then
+ begin
+ flags := CurWeapon^.Timer;
if destroyGear xor ((oldPortal^.Tag and 2) = 0) then
flags := flags or 1
else
flags := flags and not 1;
- Ammo^[CurSlot, CurAmmo].Timer := flags and not 2;
+ CurWeapon^.Timer := flags and not 2;
// make the ball visible
+ end
end;
if destroyGear then oldPortal^.Timer:= 0;
@@ -3542,6 +3547,7 @@
var
iterator: PGear;
s: hwFloat;
+ CurWeapon: PAmmo;
begin
s:= Distance (newPortal^.dX, newPortal^.dY);
@@ -3558,6 +3564,7 @@
if CurrentHedgehog <> nil then
With CurrentHedgehog^ do
begin
+ CurWeapon:= GetAmmoEntry(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
@@ -3565,10 +3572,10 @@
newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative;
// make portal gun look unloaded
- Ammo^[CurSlot, CurAmmo].Timer := Ammo^[CurSlot, CurAmmo].Timer or 2;
+ CurWeapon^.Timer := CurWeapon^.Timer or 2;
// set portal to the currently chosen color
- if ((Ammo^[CurSlot, CurAmmo].Timer and 1) <> 0) then
+ if ((CurWeapon^.Timer and 1) <> 0) then
newPortal^.Tag := newPortal^.Tag or 2;
iterator := GearsList;
--- a/hedgewars/GearDrawing.inc Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/GearDrawing.inc Mon Sep 06 16:23:47 2010 -0400
@@ -6,6 +6,7 @@
defaultPos, HatVisible: boolean;
VertexBuffer: array [0..1] of TVertex2f;
HH: PHedgehog;
+ CurWeapon: PAmmo;
begin
HH:= PHedgehog(Gear^.Hedgehog);
if HH^.Unplaced then exit;
@@ -80,8 +81,8 @@
dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
if cLaserSighting then
begin
- lx:= GetLaunchX(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, hwSign(Gear^.dX) * m, Gear^.Angle);
- ly:= GetLaunchY(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, Gear^.Angle);
+ lx:= GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle);
+ ly:= GetLaunchY(HH^.CurAmmoType, Gear^.Angle);
// ensure we start outside the hedgehog (he's solid after all)
while abs(lx * lx + ly * ly) < (Gear^.radius * Gear^.radius) do
@@ -139,8 +140,8 @@
end;
end;
// draw crosshair
- cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, hwSign(Gear^.dX) * m, Gear^.Angle));
- cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, Gear^.Angle));
+ cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle));
+ cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
DrawRotatedTex(HH^.Team^.CrosshairTex,
12, 12, cx + WorldDx, cy + WorldDy, 0,
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
@@ -381,7 +382,8 @@
else aangle:= aangle+((240-aangle)*HH^.Timer/10);
dec(HH^.Timer)
end;
- amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
+ amt:= CurrentHedgehog^.CurAmmoType;
+ CurWeapon:= GetAmmoEntry(HH^);
case amt of
amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
@@ -392,10 +394,10 @@
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
amSineGun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
- amPortalGun: if (HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
+ amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
DrawRotatedF(sprPortalGun, hx, hy, 0, hwSign(Gear^.dX), aangle)
else
- DrawRotatedF(sprPortalGun, hx, hy, 1+(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].Timer and 1), hwSign(Gear^.dX), aangle);
+ DrawRotatedF(sprPortalGun, hx, hy, 1+(CurWeapon^.Timer and 1), hwSign(Gear^.dX), aangle);
amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
amCake: DrawRotated(sprHandCake, hx, hy, hwSign(Gear^.dX), aangle);
@@ -584,7 +586,7 @@
begin
(* if (CurAmmoGear = nil) then
begin
- amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
+ amt:= CurrentHedgehog^.CurAmmoType;
case amt of
amJetpack: DrawSprite(sprJetpack, sx-32, sy-32, 0);
end
--- a/hedgewars/HHHandlers.inc Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/HHHandlers.inc Mon Sep 06 16:23:47 2010 -0400
@@ -40,36 +40,41 @@
end
end;
+// Shouldn't more of this ammo switching stuff be moved to uAmmos ?
procedure ChangeAmmo(Gear: PGear);
-var slot, i: Longword;
+var slot, ammoidx, i: Longword;
+ CurWeapon: PAmmo;
begin
slot:= Gear^.MsgParam;
with PHedgehog(Gear^.Hedgehog)^ do
begin
Gear^.Message:= Gear^.Message and not gm_Slot;
+ ammoidx:= 0;
+ while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
+ CurWeapon:= @Ammo^[slot, ammoidx];
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
- ((MultiShootAttacks > 0) and ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NoRoundEndHint) = 0)) or
+ ((MultiShootAttacks > 0) and ((CurWeapon^.Propz and ammoprop_NoRoundEndHint) = 0)) or
((Gear^.State and gstHHDriven) = 0) then exit;
- if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NoRoundEndHint) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^);
+ if ((CurWeapon^.Propz and ammoprop_NoRoundEndHint) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^);
MultiShootAttacks:= 0;
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
-
- if CurSlot = slot then
+
+ if Ammoz[CurAmmoType].Slot = slot then
begin
i:= 0;
repeat
- inc(CurAmmo);
- if (CurAmmo > cMaxSlotAmmoIndex) then
+ inc(ammoidx);
+ if (ammoidx > cMaxSlotAmmoIndex) then
begin
- CurAmmo:= 0;
+ ammoidx:= 0;
inc(i);
TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
end;
- until (Ammo^[slot, CurAmmo].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns)
+ until (Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)
end else
begin
i:= 0;
@@ -78,22 +83,21 @@
and ((Ammo^[slot, i].Count = 0)
or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i);
- if i <= cMaxSlotAmmoIndex then
- begin
- CurSlot:= slot;
- CurAmmo:= i
- end
- end
+ if i <= cMaxSlotAmmoIndex then ammoidx:= i
+ end;
+ CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
end
end;
procedure HHSetWeapon(Gear: PGear);
var t: LongInt;
weap: TAmmoType;
+ Hedgehog: PHedgehog;
begin
weap:= TAmmoType(Gear^.MsgParam);
+Hedgehog:= PHedgehog(Gear^.Hedgehog);
-if PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet
+if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet
Gear^.MsgParam:= Ammoz[weap].Slot;
@@ -101,8 +105,8 @@
Gear^.Message:= Gear^.Message and not gm_Weapon;
-with PHedgehog(Gear^.Hedgehog)^ do
- while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do
+with Hedgehog^ do
+ while (CurAmmoType <> weap) and (t >= 0) do
begin
ChangeAmmo(Gear);
dec(t)
@@ -112,12 +116,14 @@
end;
procedure HHSetTimer(Gear: PGear);
+var CurWeapon: PAmmo;
begin
Gear^.Message:= Gear^.Message and not gm_Timer;
+CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
with PHedgehog(Gear^.Hedgehog)^ do
- if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
+ if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then
begin
- Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam;
+ CurWeapon^.Timer:= 1000 * Gear^.MsgParam;
with CurrentTeam^ do
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
end;
@@ -127,9 +133,10 @@
procedure Attack(Gear: PGear);
var xx, yy, lx, ly: hwFloat;
tmpGear: PVisualGear;
- tmpGear2: PGear;
+ CurWeapon: PAmmo;
begin
bShowFinger:= false;
+CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
with Gear^,
PHedgehog(Gear^.Hedgehog)^ do
begin
@@ -138,12 +145,12 @@
(((State and gstMoving) = 0) or
// Allow attacks while moving on ammo with AltAttack
((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or
- ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInMove) <> 0)) and
- ((TargetPoint.X <> NoPointX) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then
+ ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) and
+ ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then
begin
State:= State or gstAttacking;
if Power = cMaxPower then Message:= Message and not gm_Attack
- else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
+ else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
else begin
if Power = 0 then
begin
@@ -154,7 +161,7 @@
end;
if ((Message and gm_Attack) <> 0) then exit;
- if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
+ if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then
begin
StopSound(sndThrowPowerUp);
PlaySound(sndThrowRelease);
@@ -163,17 +170,17 @@
xx:= SignAs(AngleSin(Angle), dX);
yy:= -AngleCos(Angle);
- lx:= X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(dX), Angle)));
- ly:= Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Angle)));
+ lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle)));
+ ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle)));
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then xx:= - xx;
- if Ammo^[CurSlot, CurAmmo].AttackVoice <> sndNone then
- PlaySound(Ammo^[CurSlot, CurAmmo].AttackVoice, CurrentTeam^.voicepack);
- case Ammo^[CurSlot, CurAmmo].AmmoType of
- amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
+ if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then
+ PlaySound(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack);
+ case CurAmmoType of
+ amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
amMolotov: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
- amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
- amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
+ amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
+ amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
amBazooka: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
amBee: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBee, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
amShotgun: begin
@@ -207,12 +214,12 @@
PlaySound(sndBaseballBat) // TODO: Only play if something is hit?
end;
amParachute: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0);
- // we save Ammo^[CurSlot, CurAmmo].Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear.
- amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
- amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
+ // we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear.
+ amAirAttack: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0);
+ amMineStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0);
amBlowTorch: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
- amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
- amTeleport: CurAmmoGear:= AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtTeleport, 0, _0, _0, 0);
+ amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0);
+ amTeleport: CurAmmoGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0);
amSwitch: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0);
amMortar: begin
playSound(sndMortar);
@@ -225,9 +232,9 @@
amKamikaze: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
amCake: CurAmmoGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
amSeduction: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius * 2), hwRound(ly + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
- amWatermelon: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
+ amWatermelon: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, CurWeapon^.Timer);
amHellishBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
- amNapalm: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 2, _0, _0, 0);
+ amNapalm: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0);
amDrill: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
amBallgun: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0);
amJetpack: CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0);
@@ -258,7 +265,7 @@
amFlamethrower: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0);
end;
- uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
+ uStats.AmmoUsed(CurAmmoType);
if not (SpeechText = '') then
begin
@@ -274,15 +281,14 @@
Power:= 0;
if (CurAmmoGear <> nil)
- and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
+ and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
begin
- CurAmmoGear^.Ammo:= @(Ammo^[CurSlot, CurAmmo]);
- CurAmmoGear^.AmmoType:= CurAmmoGear^.Ammo^.AmmoType;
+ CurAmmoGear^.AmmoType:= CurAmmoType;
Message:= Message or gm_Attack;
CurAmmoGear^.Message:= Message
end else begin
if not CurrentTeam^.ExtDriven and
- ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a');
+ ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then SendIPC('a');
AfterAttack;
end
end else Message:= Message and not gm_Attack;
@@ -296,27 +302,27 @@
CurrentHedgehog^ do
begin
State:= State and not gstAttacking;
- if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_Effect) = 0 then
+ if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Effect) = 0 then
begin
Inc(MultiShootAttacks);
- if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) then
+ if (Ammoz[CurAmmoType].Ammo.NumPerTurn >= MultiShootAttacks) then
begin
- s:= inttostr(Ammo^[CurSlot, CurAmmo].NumPerTurn - MultiShootAttacks + 1);
+ s:= inttostr(Ammoz[CurAmmoType].Ammo.NumPerTurn - MultiShootAttacks + 1);
AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
end;
- if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) or
+ if (Ammoz[CurAmmoType].Ammo.NumPerTurn >= MultiShootAttacks) or
((GameFlags and gfMultiWeapon) <> 0) then
begin
isInMultiShoot:= true
end
else
begin
- if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_NoRoundEndHint) = 0 then
+ if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) = 0 then
begin
OnUsedAmmo(CurrentHedgehog^);
- TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn;
+ TurnTimeLeft:= Ammoz[CurAmmoType].TimeAfterTurn;
State:= State or gstAttacked
end
else
@@ -331,7 +337,7 @@
OnUsedAmmo(CurrentHedgehog^);
ApplyAmmoChanges(CurrentHedgehog^);
end;
- AttackBar:= 0;
+ AttackBar:= 0
end
end;
@@ -449,12 +455,14 @@
procedure HedgehogStep(Gear: PGear);
var PrevdX: LongInt;
+ CurWeapon: PAmmo;
begin
+CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
begin
if isCursorVisible then
with PHedgehog(Gear^.Hedgehog)^ do
- with Ammo^[CurSlot, CurAmmo] do
+ with CurWeapon^ do
begin
if (Gear^.Message and gm_Left ) <> 0 then
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount
@@ -583,7 +591,7 @@
var da: LongWord;
begin
with PHedgehog(Gear^.Hedgehog)^ do
- if (Ammo^[CurSlot, CurAmmo].AmmoType = amRope)
+ if (CurAmmoType = amRope)
and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1;
if (((Gear^.Message and gm_Precise) = 0) or ((GameTicks mod 5) = 1)) then
@@ -702,7 +710,9 @@
procedure doStepHedgehogDriven(Gear: PGear);
var t: PGear;
wasJumping: boolean;
+ Hedgehog: PHedgehog;
begin
+Hedgehog:= PHedgehog(Gear^.Hedgehog);
if not isInMultiShoot then
AllInactive:= false
else
@@ -722,7 +732,7 @@
if (Gear^.State and gstAnimation) <> 0 then
begin
Gear^.Message:= 0;
- if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
+ if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, Hedgehog^.Team^.voicepack);
inc(Gear^.Timer);
if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then
begin
@@ -738,10 +748,10 @@
or (StepTicks = cHHStepTicks)
or (CurAmmoGear <> nil) then // we are moving
begin
- with PHedgehog(Gear^.Hedgehog)^ do
+ with Hedgehog^ do
if (CurAmmoGear = nil)
and (Gear^.dY > _0_39)
- and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack;
+ and (CurAmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack;
// check for case with ammo
t:= CheckGearNear(Gear, gtCase, 36, 36);
if t <> nil then
@@ -753,22 +763,23 @@
or ((Gear^.State and gstAttacking) <> 0)) then
Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs
else
-else with PHedgehog(Gear^.Hedgehog)^ do
- if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
- and ((Gear^.Message and gm_LJump) <> 0)
- and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then
- begin
- Gear^.Message:= Gear^.Message and not gm_LJump;
- Attack(Gear)
- end;
+else
+ with Hedgehog^ do
+ if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
+ and ((Gear^.Message and gm_LJump) <> 0)
+ and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
+ begin
+ Gear^.Message:= Gear^.Message and not gm_LJump;
+ Attack(Gear)
+ end;
if (CurAmmoGear = nil)
- or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+ or ((Ammoz[Hedgehog^.CurAmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
begin
if ((Gear^.Message and gm_Slot) <> 0) then
begin
ChangeAmmo(Gear);
- ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^)
+ ApplyAmmoChanges(Hedgehog^)
end;
if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear);
@@ -797,7 +808,7 @@
Gear^.State:= Gear^.State or gstHHHJump;
Gear^.dY:= -_0_25;
if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX);
- PlaySound(sndJump2, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack)
+ PlaySound(sndJump2, Hedgehog^.Team^.voicepack)
end;
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
--- a/hedgewars/PascalExports.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/PascalExports.pas Mon Sep 06 16:23:47 2010 -0400
@@ -218,12 +218,9 @@
end;
function HW_isWeaponTimerable: boolean; cdecl; export;
-var CurSlot, CurAmmo: LongWord;
begin
- CurSlot:= CurrentHedgehog^.CurSlot;
- CurAmmo:= CurrentHedgehog^.CurAmmo;
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
+ exit( (CurrentHedgehog^.CurWeapon^.Propz and ammoprop_Timerable) <> 0)
else
exit(false);
end;
@@ -237,12 +234,9 @@
end;
function HW_isWeaponRope: boolean cdecl; export;
-var CurSlot, CurAmmo: LongWord;
begin
- CurSlot:= CurrentHedgehog^.CurSlot;
- CurAmmo:= CurrentHedgehog^.CurAmmo;
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amRope)
+ exit (CurrentHedgehog^.CurWeapon^.AmmoType = amRope)
else
exit(false);
end;
@@ -253,13 +247,10 @@
end;
procedure HW_setPianoSound(snd: LongInt); cdecl; export;
-var CurSlot, CurAmmo: LongWord;
begin
- CurSlot:= CurrentHedgehog^.CurSlot;
- CurAmmo:= CurrentHedgehog^.CurAmmo;
// this most likely won't work in network game
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0)
- and (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amPiano) then
+ and (CurrentHedgehog^.CurWeapon^.AmmoType = amPiano) then
case snd of
0: PlaySound(sndPiano0);
1: PlaySound(sndPiano1);
--- a/hedgewars/uAI.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uAI.pas Mon Sep 06 16:23:47 2010 -0400
@@ -71,7 +71,7 @@
if (Targets.ar[i].Score >= 0) and (not StopThinking) then
begin
with CurrentHedgehog^ do
- a:= Ammo^[CurSlot, CurAmmo].AmmoType;
+ a:= CurAmmoType;
aa:= a;
repeat
if (CanUseAmmo[a]) and
--- a/hedgewars/uAmmos.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uAmmos.pas Mon Sep 06 16:23:47 2010 -0400
@@ -42,6 +42,7 @@
procedure DisableSomeWeapons;
procedure ResetWeapons;
function GetAmmoByNum(num: Longword): PHHAmmo;
+function GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
var shoppa: boolean;
@@ -156,6 +157,18 @@
exit(StoresList[num])
end;
+function GetAmmoEntry(var Hedgehog: THedgehog): PAmmo;
+var ammoidx, slot: LongWord;
+begin
+with Hedgehog do
+ begin
+ slot:= Ammoz[CurAmmoType].Slot;
+ ammoidx:= 0;
+ while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
+ GetAmmoEntry:= @Ammo^[slot, ammoidx];
+ end
+end;
+
procedure AssignStores;
var t: LongInt;
i: Longword;
@@ -165,7 +178,10 @@
begin
for i:= 0 to cMaxHHIndex do
if Hedgehogs[i].Gear <> nil then
+ begin
Hedgehogs[i].Ammo:= GetAmmoByNum(Hedgehogs[i].AmmoStore);
+ Hedgehogs[i].CurAmmoType:= amNothing;
+ end
end
end;
@@ -213,17 +229,20 @@
end;
procedure OnUsedAmmo(var Hedgehog: THedgehog);
+var CurWeapon: PAmmo;
begin
+CurWeapon:= GetAmmoEntry(Hedgehog);
with Hedgehog do
begin
+
MultiShootAttacks:= 0;
- with Ammo^[CurSlot, CurAmmo] do
+ with CurWeapon^ do
if Count <> AMMO_INFINITE then
begin
dec(Count);
if Count = 0 then
begin
- PackAmmo(Ammo, CurSlot);
+ PackAmmo(Ammo, Ammoz[AmmoType].Slot);
SwitchNotHeldAmmo(Hedgehog)
end
end
@@ -264,33 +283,37 @@
end;
procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog);
+var slot, ammoidx: LongWord;
begin
with Hedgehog do
begin
- CurAmmo:= 0;
- CurSlot:= 0;
- while (CurSlot <= cMaxSlotIndex) and
- ((Ammo^[CurSlot, CurAmmo].Count = 0) or
- (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
+ CurAmmoType:= amNothing;
+ slot:= 0;
+ ammoidx:= 0;
+ while (slot <= cMaxSlotIndex) and
+ ((Ammo^[slot, ammoidx].Count = 0) or
+ (Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
do
begin
- while (CurAmmo <= cMaxSlotAmmoIndex) and
- ((Ammo^[CurSlot, CurAmmo].Count = 0) or
- (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
- do inc(CurAmmo);
+ while (ammoidx <= cMaxSlotAmmoIndex) and
+ ((Ammo^[slot, ammoidx].Count = 0) or
+ (Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
+ do inc(ammoidx);
- if (CurAmmo > cMaxSlotAmmoIndex) then
+ if (ammoidx > cMaxSlotAmmoIndex) then
begin
- CurAmmo:= 0;
- inc(CurSlot)
+ ammoidx:= 0;
+ inc(slot)
end
end;
- TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true)
+ TryDo(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true);
+ CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
end
end;
procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
var s: shortstring;
+ CurWeapon: PAmmo;
begin
TargetPoint.X:= NoPointX;
@@ -298,13 +321,16 @@
begin
Timer:= 10;
- if (Ammo^[CurSlot, CurAmmo].Count = 0) then
+ CurWeapon:= GetAmmoEntry(Hedgehog);
+
+ if (CurWeapon^.Count = 0) then
SwitchToFirstLegalAmmo(Hedgehog);
- //bad things could happen here in case CurSlot is overflowing
- ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
+ CurWeapon:= GetAmmoEntry(Hedgehog);
- with Ammo^[CurSlot, CurAmmo] do
+ ApplyAngleBounds(Hedgehog, CurWeapon^.AmmoType);
+
+ with CurWeapon^ do
begin
if AmmoType <> amNothing then
begin
@@ -323,8 +349,8 @@
Gear^.State:= Gear^.State and not gstHHChooseTarget;
isCursorVisible:= false
end;
- if (CurAmmoGear <> nil) and ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then
- ShowCrosshair:= (CurAmmoGear^.Ammo^.Propz and ammoprop_NoCrossHair) = 0
+ if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+ ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
else
ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0;
end
@@ -334,8 +360,8 @@
procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
begin
with Hedgehog do
- if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
- (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
+ if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_DontHold) <> 0) or
+ (Ammoz[CurAmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
SwitchToFirstLegalAmmo(Hedgehog);
end;
--- a/hedgewars/uConsts.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uConsts.pas Mon Sep 06 16:23:47 2010 -0400
@@ -125,14 +125,14 @@
sndSkip, sndSineGun, sndOoff1, sndOoff2, sndOoff3, sndWhack,
sndComeonthen);
- TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amPickHammer,
- amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip,
- amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch,
- amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake,
- amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun,
- amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime,
- amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov, amBirdy, amPortalGun,
- amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer);
+ TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amPickHammer, // 6
+ amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, // 13
+ amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch, // 18
+ amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake, // 24
+ amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun, // 30
+ amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, // 35
+ amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov, amBirdy, amPortalGun, // 42
+ amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer); // 48
TCrateType = (HealthCrate, AmmoCrate, UtilityCrate);
@@ -201,7 +201,6 @@
errmsgIncorrectUse = 'Incorrect use';
errmsgShouldntRun = 'This program shouldn''t be run manually';
errmsgWrongNumber = 'Wrong parameters number';
- errmsgSlotsOverflow = 'CurSlot overflowed';
msgLoading = 'Loading ';
msgOK = 'ok';
--- a/hedgewars/uGears.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uGears.pas Mon Sep 06 16:23:47 2010 -0400
@@ -32,8 +32,7 @@
AdvBounce: Longword;
Invulnerable: Boolean;
RenderTimer: Boolean;
- Ammo : PAmmo;
- AmmoType : TAmmoType; // Used to track AmmoType at time of Gear creation, since Ammo can be reassigned
+ AmmoType : TAmmoType;
State : Longword;
X : hwFloat;
Y : hwFloat;
@@ -996,10 +995,10 @@
begin
with PHedgehog(Gear^.Hedgehog)^ do
begin
- if not (((Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then
+ if not (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then
exit;
DrawTexture(round(sx + 16), round(sy + 16), ropeIconTex);
- DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, round(sx + 30), round(sy + 30), ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1, 1, 32, 32);
+ DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, round(sx + 30), round(sy + 30), ord(CurAmmoType) - 1, 1, 32, 32);
end;
end;
--- a/hedgewars/uLand.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uLand.pas Mon Sep 06 16:23:47 2010 -0400
@@ -66,7 +66,7 @@
procedure LogLandDigest;
var s: shortstring;
- adler, i, tmp: LongInt;
+ adler, i: LongInt;
begin
adler:= 1;
for i:= 0 to LAND_HEIGHT-1 do
--- a/hedgewars/uScript.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uScript.pas Mon Sep 06 16:23:47 2010 -0400
@@ -417,7 +417,6 @@
function lc_hogsay(L : Plua_State) : LongInt; Cdecl;
var gear : PGear;
vgear : PVisualGear;
- text : ShortString;
begin
if lua_gettop(L) <> 3 then
begin
--- a/hedgewars/uTeams.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uTeams.pas Mon Sep 06 16:23:47 2010 -0400
@@ -22,7 +22,8 @@
interface
uses uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound;
-type PHHAmmo = ^THHAmmo;
+type
+ PHHAmmo = ^THHAmmo;
THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo;
PHedgehog = ^THedgehog;
@@ -37,8 +38,8 @@
HealthTagTex,
HatTex: PTexture;
Ammo: PHHAmmo;
+ CurAmmoType: TAmmoType;
AmmoStore: Longword;
- CurSlot, CurAmmo: LongWord;
Team: PTeam;
MultiShootAttacks: Longword;
visStepPos: LongWord;
--- a/hedgewars/uVisualGears.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uVisualGears.pas Mon Sep 06 16:23:47 2010 -0400
@@ -386,7 +386,6 @@
procedure DrawVisualGears(Layer: LongWord);
var Gear: PVisualGear;
- i: LongInt;
begin
Gear:= VisualGearsList;
case Layer of
--- a/hedgewars/uWorld.pas Mon Sep 06 20:40:58 2010 +0100
+++ b/hedgewars/uWorld.pas Mon Sep 06 16:23:47 2010 -0400
@@ -190,7 +190,7 @@
Slot, Pos, STurns: LongInt;
Ammo: PHHAmmo;
begin
-if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false;
+if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false;
if bShowAmmoMenu then
begin
FollowGear:= nil;
@@ -613,8 +613,8 @@
tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
DrawSprite(sprPower,
- hwRound(Gear^.X) + GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Gear^.dX), Gear^.Angle) + round(WorldDx + tdx * (24 + i * 2)) - 16,
- hwRound(Gear^.Y) + GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Gear^.Angle) + round(WorldDy + tdy * (24 + i * 2)) - 16,
+ hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + round(WorldDx + tdx * (24 + i * 2)) - 16,
+ hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + round(WorldDy + tdy * (24 + i * 2)) - 16,
i)
end
end;
@@ -649,7 +649,7 @@
begin
with PHedgehog(CurrentHedgehog)^ do
begin
- if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then
+ if (CurAmmoType = amBee) then
DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
else
DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
@@ -987,8 +987,8 @@
with CurrentHedgehog^ do
if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
begin
- i:= Ammo^[CurSlot, CurAmmo].Pos;
- with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do
+ i:= GetAmmoEntry(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);
end;