- Fix water rise
authorunc0rr
Mon, 29 Sep 2008 09:33:44 +0000
changeset 1298 18fdc25fe65d
parent 1297 78670b0c4a23
child 1299 fc801a832e0e
- Fix water rise - Fix game crash when a hedgehog which turn is next gets drawn by water rise
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
--- a/hedgewars/GSHandlers.inc	Sun Sep 28 22:49:38 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Sep 29 09:33:44 2008 +0000
@@ -1751,3 +1751,28 @@
 DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear);
 Gear^.doStep:= @doStepSeductionWear
 end;
+
+////////////////////////////////////////////////////////////////////////////////
+procedure doStepWaterUp(Gear: PGear);
+var i: LongWord;
+begin
+AllInactive:= false;
+
+inc(Gear^.Timer);
+if Gear^.Timer = 17 then
+	Gear^.Timer:= 0
+else
+	exit;
+
+if cWaterLine > 0 then
+	begin
+	dec(cWaterLine);
+	for i:= 0 to 2047 do
+		Land[cWaterLine, i]:= 0;
+	SetAllToActive
+	end;
+
+inc(Gear^.Tag);
+if (Gear^.Tag = 51) or (cWaterLine = 0) then
+	DeleteGear(Gear)
+end;
--- a/hedgewars/uConsts.pas	Sun Sep 28 22:49:38 2008 +0000
+++ b/hedgewars/uConsts.pas	Mon Sep 29 09:33:44 2008 +0000
@@ -59,7 +59,7 @@
 			gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
 			gtTeleport, gtSmallDamage, gtSwitcher, gtTarget, gtMortar,
 			gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece,
-			gtHellishBomb, gtEvilTrace);
+			gtHellishBomb, gtEvilTrace, gtWaterUp);
 
 	TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire);
 
--- a/hedgewars/uGears.pas	Sun Sep 28 22:49:38 2008 +0000
+++ b/hedgewars/uGears.pas	Mon Sep 29 09:33:44 2008 +0000
@@ -143,7 +143,8 @@
 			@doStepWatermelon,
 			@doStepCluster,
 			@doStepBomb,
-			@doStepSmokeTrace
+			@doStepSmokeTrace,
+			@doStepWaterUp
 			);
 
 procedure InsertGearToList(Gear: PGear);
@@ -427,30 +428,6 @@
 	end;
 end;
 
-function WaterMachine: boolean;
-const
-	decStep: Longword = 0;
-	LastTurn: LongInt = 0;
-var i: LongWord;
-begin
-if (decStep = 0) and (LastTurn < FinishedTurnsTotal) then
-	begin
-	LastTurn:= FinishedTurnsTotal;
-	decStep:= 40
-	end;
-
-if decStep <> 0 then
-	begin
-	dec(decStep);
-	dec(cWaterLine);
-	for i:= 0 to 2047 do
-		Land[cWaterLine, i]:= 0;
-	SetAllToActive
-	end;
-
-WaterMachine:= decStep <> 0;
-end;
-
 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear);
 begin
 if cAltDamage then
@@ -460,7 +437,7 @@
 procedure ProcessGears;
 const delay: LongWord = 0;
       step: (stDelay, stChDmg, stTurnReact,
-             stAfterDelay, stChWin, stWater, stHealth,
+             stAfterDelay, stChWin, stWater, stChWin2, stHealth,
              stSpawn, stNTurn) = stDelay;
 
 var Gear, t: PGear;
@@ -504,30 +481,21 @@
                  if delay = 0 then
                     inc(step)
                  end;
-        stChWin: if not CheckForWin then
-                    begin
-                    if not (bBetweenTurns or isInMultiShoot) then
-                       begin
-                       ParseCommand('/nextturn', true);
-                       SwitchHedgehog;
-                       end;
-                    inc(step)
-                    end else step:= stDelay;
+        stChWin: begin
+                 CheckForWin;
+                 inc(step)
+                 end;
         stWater: begin
                  if TotalRounds = 17 then bWaterRising:= true;
 
-                 if not bWaterRising then
-                    inc(step)
-                 else
-                    begin
-                    if delay = 0 then
-                       delay:= 17
-                    else
-                       dec(delay);
+                 if bWaterRising then
+                    AddGear(0, 0, gtWaterUp, 0, _0, _0, 0);
 
-                    if delay = 0 then
-                       if not WaterMachine then inc(step)
-                    end
+                 inc(step)
+                 end;
+       stChWin2: begin
+                 CheckForWin;
+                 inc(step)
                  end;
        stHealth: begin
                  if (TotalRounds = 15) and (cHealthDecrease = 0) then
@@ -553,6 +521,11 @@
         stNTurn: begin
                  if isInMultiShoot then isInMultiShoot:= false
                     else begin
+                    ParseCommand('/nextturn', true);
+                    SwitchHedgehog;
+
+                    inc(step);
+
                     AfterSwitchHedgehog;
                     bBetweenTurns:= false
                     end;
--- a/hedgewars/uMisc.pas	Sun Sep 28 22:49:38 2008 +0000
+++ b/hedgewars/uMisc.pas	Mon Sep 29 09:33:44 2008 +0000
@@ -62,7 +62,7 @@
 	cExplosionBorderColor : LongWord = $808080;
 
 	cShowFPS      : boolean = true;
-	cCaseFactor   : Longword = 1;//5;  {0..9}
+	cCaseFactor   : Longword = 5;  {0..9}
 	cLandAdditions: Longword = 4;
 	cFullScreen   : boolean = true;
 	cLocaleFName  : shortstring = 'en.txt';