Correct another bug in slot switching, adjust width of theme list, really truly fix reset of weps (I hope) should also fix infinite teleport bug in place hogs mode. Slow update of health to 5s for inf attack mode.
authornemo
Sun, 10 Oct 2010 20:16:17 -0400
changeset 3951 c9a63db3e603
parent 3949 4c4c0a2507cc
child 3953 fd7ced2071a1
Correct another bug in slot switching, adjust width of theme list, really truly fix reset of weps (I hope) should also fix infinite teleport bug in place hogs mode. Slow update of health to 5s for inf attack mode.
QTfrontend/mapContainer.cpp
hedgewars/HHHandlers.inc
hedgewars/uAmmos.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/QTfrontend/mapContainer.cpp	Sun Oct 10 16:51:40 2010 -0400
+++ b/QTfrontend/mapContainer.cpp	Sun Oct 10 20:16:17 2010 -0400
@@ -154,7 +154,7 @@
     gbTLayout->setSpacing(0);
     lwThemes = new QListWidget(this);
     lwThemes->setMinimumHeight(30);
-    lwThemes->setFixedWidth(120);
+    lwThemes->setFixedWidth(140);
     for (int i = 0; i < Themes->size(); ++i) {
         QListWidgetItem * lwi = new QListWidgetItem();
         lwi->setText(Themes->at(i));
--- a/hedgewars/HHHandlers.inc	Sun Oct 10 16:51:40 2010 -0400
+++ b/hedgewars/HHHandlers.inc	Sun Oct 10 20:16:17 2010 -0400
@@ -69,11 +69,12 @@
         inc(ammoidx);
         if (ammoidx > cMaxSlotAmmoIndex) then
             begin
-            ammoidx:= 0;
             inc(i);
-            TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
+            CurAmmoType:= amNothing;
+            ammoidx:= -1;
+            //TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
             end;
-        until (Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)
+        until ((Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) or (i = 1)
         end 
     else
         begin
--- a/hedgewars/uAmmos.pas	Sun Oct 10 16:51:40 2010 -0400
+++ b/hedgewars/uAmmos.pas	Sun Oct 10 20:16:17 2010 -0400
@@ -53,6 +53,7 @@
 type TAmmoCounts = array[TAmmoType] of Longword;
 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
+    InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts;
 
 procedure FillAmmoStore(Ammo: PHHAmmo; var cnts: TAmmoCounts);
 var mi: array[0..cMaxSlotIndex] of byte;
@@ -68,12 +69,11 @@
        begin
        TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true);
        Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
-
-       Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= cnts[a];
-       Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].InitialCount:= cnts[a];
-
-       if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
-           Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE;
+       with Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]] do
+           begin
+           Count:= cnts[a];
+           if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then Count:= AMMO_INFINITE;
+           end;
        inc(mi[Ammoz[a].Slot])
        end
     else if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
@@ -82,7 +82,6 @@
        Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
 
        Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE;
-       Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].InitialCount:= 0;
 
        inc(mi[Ammoz[a].Slot])
        end
@@ -144,11 +143,13 @@
         if ((GameFlags and gfPlaceHog) <> 0) and
             (a <> amTeleport) and (a <> amSkip) and
             (Ammoz[a].SkipTurns < 10000) then inc(Ammoz[a].SkipTurns,10000)
-        end else
-        ammos[a]:= AMMO_INFINITE
+        end 
+    else ammos[a]:= AMMO_INFINITE;
+    InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
     end;
-
-FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
+FillAmmoStore(StoresList[Pred(StoreCnt)], ammos);
+for cnt:= 0 to cMaxSlotIndex do
+    PackAmmo(StoresList[Pred(StoreCnt)], cnt)
 end;
 
 function GetAmmoByNum(num: Longword): PHHAmmo;
@@ -385,7 +386,7 @@
                 if (Propz and ammoprop_NotBorder) <> 0 then
                     begin
                     Count:= 0;
-                    InitialCount:= 0
+                    InitialCounts[i][AmmoType]:= 0
                     end;
 
         PackAmmo(StoresList[i], slot)
@@ -425,7 +426,7 @@
         begin
         for a:= 0 to cMaxSlotAmmoIndex do
             with StoresList[i]^[slot, a] do
-                Count:= InitialCount;
+                if AmmoType <> amNothing then Count:= InitialCounts[i][AmmoType];
 
         PackAmmo(StoresList[i], slot)
         end;
@@ -440,7 +441,8 @@
     ammoLoadout:= '';
     ammoProbability:= '';
     ammoDelay:= '';
-    ammoReinforcement:= ''
+    ammoReinforcement:= '';
+    FillChar(InitialCounts, sizeof(InitialCounts), 0)
 end;
 
 procedure freeModule;
--- a/hedgewars/uConsts.pas	Sun Oct 10 16:51:40 2010 -0400
+++ b/hedgewars/uConsts.pas	Sun Oct 10 20:16:17 2010 -0400
@@ -160,7 +160,6 @@
             Count: LongWord;
 (* Using for place hedgehogs mode, but for any other situation where the initial count would be needed I guess.
 For example, say, a mode where the weaponset is reset each turn, or on sudden death *)
-            InitialCount: LongWord;
             NumPerTurn: LongWord;
             Timer: LongWord;
             Pos: LongWord;
@@ -970,7 +969,6 @@
             NumberInCase: 0;
             Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Effect;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -994,7 +992,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 3000;
                 Pos: 0;
@@ -1018,7 +1015,6 @@
             NumberInCase: 3;
             Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse;
                 Count: 5;
-                InitialCount: 5;
                 NumPerTurn: 0;
                 Timer: 3000;
                 Pos: 0;
@@ -1042,7 +1038,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Power or ammoprop_AltUse;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1066,7 +1061,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget or ammoprop_DontHold;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1090,7 +1084,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 1;
                 Timer: 0;
                 Pos: 0;
@@ -1114,7 +1107,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInMove or ammoprop_NoCrosshair or ammoprop_DontHold;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1138,7 +1130,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1166,7 +1157,6 @@
                           ammoprop_Utility or
                           ammoprop_AltAttack;
                     Count: 5;
-                    InitialCount: 5;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1190,7 +1180,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1214,7 +1203,6 @@
             NumberInCase: 2;
             Ammo: (Propz: 0;
                 Count: 3;
-                InitialCount: 3;
                 NumPerTurn: 3;
                 Timer: 0;
                 Pos: 0;
@@ -1238,7 +1226,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1262,7 +1249,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or ammoprop_AttackInMove;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1286,7 +1272,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1310,7 +1295,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_DontHold;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1340,7 +1324,6 @@
                           ammoprop_Utility or
                           ammoprop_AltAttack;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1368,7 +1351,6 @@
                             ammoprop_DontHold or
                             ammoprop_NotBorder;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1396,7 +1378,6 @@
                             ammoprop_DontHold or
                             ammoprop_NotBorder;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1420,7 +1401,6 @@
             NumberInCase: 2;
             Ammo: (Propz: ammoprop_ForwMsgs;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1448,7 +1428,6 @@
                           ammoprop_Utility or
                           ammoprop_AttackingPut;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1477,7 +1456,6 @@
                           ammoprop_Utility or
                           ammoprop_DontHold;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1505,7 +1483,6 @@
                           ammoprop_Utility or
                           ammoprop_DontHold;
                     Count: 3;
-                    InitialCount: 3;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1529,7 +1506,6 @@
             NumberInCase: 4;
             Ammo: (Propz: 0;
                 Count: 4;
-                InitialCount: 4;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1553,7 +1529,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_AttackInMove;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1577,7 +1552,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NoCrosshair or ammoprop_DontHold;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1601,7 +1575,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1625,7 +1598,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse;
                 Count: 0;
-                InitialCount: 0;
                 NumPerTurn: 0;
                 Timer: 3000;
                 Pos: 0;
@@ -1649,7 +1621,6 @@
             NumberInCase: 1;
             Ammo: (Propz:  ammoprop_Power or ammoprop_AltUse;
                 Count: 0;
-                InitialCount: 0;
                 NumPerTurn: 0;
                 Timer: 5000;
                 Pos: 0;
@@ -1677,7 +1648,6 @@
                             ammoprop_DontHold or
                             ammoprop_NotBorder;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1701,7 +1671,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Power or ammoprop_AltUse;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1725,7 +1694,6 @@
             NumberInCase: 1;
             Ammo: (Propz:  ammoprop_ForwMsgs or ammoprop_DontHold;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 5001;
                 Pos: 0;
@@ -1751,7 +1719,6 @@
                             ammoprop_DontHold or
                             ammoprop_AltAttack};
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -1780,7 +1747,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1809,7 +1775,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1838,7 +1803,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1867,7 +1831,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1896,7 +1859,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1925,7 +1887,6 @@
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
-                    InitialCount: 1;
                     NumPerTurn: 0;
                     Timer: 0;
                     Pos: 0;
@@ -1949,7 +1910,6 @@
             NumberInCase: 2;
             Ammo: (Propz: 0;
                 Count: 2;
-                InitialCount: 2;
                 NumPerTurn: 1;
                 Timer: 0;
                 Pos: 0;
@@ -1979,7 +1939,6 @@
                           ammoprop_Utility or
                           ammoprop_AltAttack;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -2003,7 +1962,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Power or ammoprop_AltUse;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 3000;
                 Pos: 0;
@@ -2029,7 +1987,6 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -2056,7 +2013,6 @@
                           ammoprop_DontHold or
                           ammoprop_Utility;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 3;
                 Timer: 0;
                 Pos: 0;
@@ -2084,7 +2040,6 @@
                             ammoprop_DontHold or
                             ammoprop_NotBorder;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -2108,7 +2063,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse;
                 Count: AMMO_INFINITE;
-                InitialCount: AMMO_INFINITE;
                 NumPerTurn: 0;
                 Timer: 3000;
                 Pos: 0;
@@ -2132,7 +2086,6 @@
             NumberInCase: 2;
             Ammo: (Propz: ammoprop_AttackInMove;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
@@ -2156,7 +2109,6 @@
             NumberInCase: 1;
             Ammo: (Propz:  ammoprop_ForwMsgs or ammoprop_DontHold;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 5001;
                 Pos: 0;
@@ -2180,7 +2132,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_Power or ammoprop_AltUse;
                 Count: 1;
-                InitialCount: 0;
                 NumPerTurn: 1;
                 Timer: 0;
                 Pos: 0;
@@ -2204,7 +2155,6 @@
             NumberInCase: 1;
             Ammo: (Propz: ammoprop_NoCrosshair;
                 Count: 1;
-                InitialCount: 1;
                 NumPerTurn: 0;
                 Timer: 0;
                 Pos: 0;
--- a/hedgewars/uGears.pas	Sun Oct 10 16:51:40 2010 -0400
+++ b/hedgewars/uGears.pas	Sun Oct 10 20:16:17 2010 -0400
@@ -846,13 +846,14 @@
 else if ((GameFlags and gfInfAttack) <> 0) then
     begin
     if delay2 = 0 then
-        delay2:= cInactDelay 
+        delay2:= cInactDelay * 4
     else
         dec(delay2);
 
+    if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then 
+        CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstAttacked;
     if delay2 = 0 then
         begin
-        if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstAttacked;
         CheckNoDamage;
         CheckForWin
         end