# HG changeset patch # User unc0rr # Date 1215366316 0 # Node ID 80225c6af65625862ee40ae9bdd45a6db4024318 # Parent 5dae89b2872d58e1cac27cef58cb31d1c5281fe4 - Prepare for sudden death implementation - Fix stats issues diff -r 5dae89b2872d -r 80225c6af656 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sun Jul 06 14:09:41 2008 +0000 +++ b/hedgewars/uGears.pas Sun Jul 06 17:45:16 2008 +0000 @@ -388,6 +388,20 @@ end; end; +procedure HealthMachine; +var Gear: PGear; +begin +Gear:= GearsList; + +while Gear <> nil do + begin + if Gear^.Kind = gtHedgehog then + Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); + + Gear:= Gear^.NextGear + end; +end; + procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); begin if cAltDamage then @@ -397,13 +411,14 @@ procedure ProcessGears; const delay: LongWord = 0; step: (stDelay, stChDmg, stTurnReact, - stAfterDelay, stChWin, stSpawn, stNTurn) = stDelay; + stAfterDelay, stChWin, stHealth, stSpawn, stNTurn) = stDelay; + var Gear, t: PGear; begin PrvInactive:= AllInactive; AllInactive:= true; t:= GearsList; -while t<>nil do +while t <> nil do begin Gear:= t; t:= Gear^.NextGear; @@ -423,7 +438,7 @@ end; stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; stTurnReact: begin - if not isInMultiShoot then + if (not bBetweenTurns) and (not isInMultiShoot) then begin uStats.TurnReaction; inc(step) @@ -440,6 +455,15 @@ inc(step) end; stChWin: if not CheckForWin then inc(step) else step:= stDelay; + stHealth: if (cHealthDecrease = 0) + or bBetweenTurns + or isInMultiShoot + or (FinishedTurnsTotal = 0) then inc(step) + else begin + bBetweenTurns:= true; + HealthMachine; + step:= stChDmg + end; stSpawn: begin if not isInMultiShoot then SpawnBoxOfSmth; inc(step) @@ -448,6 +472,7 @@ if isInMultiShoot then isInMultiShoot:= false else begin ParseCommand('/nextturn', true); + bBetweenTurns:= false end; step:= Low(step) end; diff -r 5dae89b2872d -r 80225c6af656 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Sun Jul 06 14:09:41 2008 +0000 +++ b/hedgewars/uMisc.pas Sun Jul 06 17:45:16 2008 +0000 @@ -20,76 +20,80 @@ interface uses uConsts, SDLh, uFloat, GL; {$INCLUDE options.inc} -var isCursorVisible : boolean = false; - isTerminated : boolean = false; - isInLag : boolean = false; - isPaused : boolean = false; - isSoundEnabled : boolean = true; - isSEBackup : boolean = true; - isInMultiShoot : boolean = false; - isSpeed : boolean = false; +var + isCursorVisible : boolean = false; + isTerminated : boolean = false; + isInLag : boolean = false; + isPaused : boolean = false; + isSoundEnabled : boolean = true; + isSEBackup : boolean = true; + isInMultiShoot : boolean = false; + isSpeed : boolean = false; - GameState : TGameState = Low(TGameState); - GameType : TGameType = gmtLocal; - GameFlags : Longword = 0; - TurnTimeLeft : Longword = 0; - cHedgehogTurnTime: Longword = 45000; - cMaxAIThinkTime : Longword = 9000; + GameState : TGameState = Low(TGameState); + GameType : TGameType = gmtLocal; + GameFlags : Longword = 0; + TurnTimeLeft : Longword = 0; + cHedgehogTurnTime: Longword = 45000; + cMaxAIThinkTime : Longword = 9000; - cCloudsNumber : LongInt = 9; - cScreenWidth : LongInt = 1024; - cScreenHeight : LongInt = 768; - cBits : LongInt = 16; - cBitsStr : string[2] = '16'; - cTagsMask : byte = 7; + cCloudsNumber : LongInt = 9; + cScreenWidth : LongInt = 1024; + cScreenHeight : LongInt = 768; + cBits : LongInt = 16; + cBitsStr : string[2] = '16'; + cTagsMask : byte = 7; - cWaterLine : LongInt = 1024; - cVisibleWater : LongInt = 128; - cGearScrEdgesDist: LongInt = 240; - cCursorEdgesDist : LongInt = 40; - cTeamHealthWidth : LongInt = 128; - cAltDamage : boolean = true; + cWaterLine : LongInt = 1024; + cVisibleWater : LongInt = 128; + cGearScrEdgesDist: LongInt = 240; + cCursorEdgesDist : LongInt = 40; + cTeamHealthWidth : LongInt = 128; + cAltDamage : boolean = true; - GameTicks : LongWord = 0; + GameTicks : LongWord = 0; + + cSkyColor : Longword = 0; + cWhiteColor : Longword = $FFFFFFFF; + cColorNearBlack : Longword = $FF000010; + cExplosionBorderColor : LongWord = $808080; - cSkyColor : Longword = 0; - cWhiteColor : Longword = $FFFFFFFF; - cColorNearBlack : Longword = $FF000010; - cExplosionBorderColor : LongWord = $808080; + cShowFPS : boolean = true; + cCaseFactor : Longword = 5; {0..9} + cLandAdditions: Longword = 4; + cFullScreen : boolean = true; + cLocaleFName : shortstring = 'en.txt'; + cSeed : shortstring = ''; + cInitVolume : LongInt = 128; + cVolumeDelta : LongInt = 0; + cTimerInterval : Longword = 5; + cHasFocus : boolean = true; + cInactDelay : Longword = 1500; - cShowFPS : boolean = true; - cCaseFactor : Longword = 5; {0..9} - cLandAdditions: Longword = 4; - cFullScreen : boolean = true; - cLocaleFName : shortstring = 'en.txt'; - cSeed : shortstring = ''; - cInitVolume : LongInt = 128; - cVolumeDelta : LongInt = 0; - cTimerInterval : Longword = 5; - cHasFocus : boolean = true; - cInactDelay : Longword = 1500; + bBetweenTurns: boolean = false; + cHealthDecrease: LongWord = 1; {$WARNINGS OFF} - cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 - cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); + cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 + cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); {$WARNINGS ON} var - cSendEmptyPacketTime : LongWord = 2000; - cSendCursorPosTime : LongWord = 50; - ShowCrosshair : boolean; - cDrownSpeed, - cMaxWindSpeed, - cWindSpeed, - cGravity: hwFloat; + cSendEmptyPacketTime : LongWord = 2000; + cSendCursorPosTime : LongWord = 50; + ShowCrosshair : boolean; + cDrownSpeed, + cMaxWindSpeed, + cWindSpeed, + cGravity: hwFloat; - flagMakeCapture: boolean = false; + flagMakeCapture: boolean = false; - InitStepsFlags: Longword = 0; + InitStepsFlags: Longword = 0; - RealTicks: Longword = 0; + RealTicks: Longword = 0; - AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP + AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP function hwSign(r: hwFloat): LongInt; function Min(a, b: LongInt): LongInt; diff -r 5dae89b2872d -r 80225c6af656 hedgewars/uStats.pas --- a/hedgewars/uStats.pas Sun Jul 06 14:09:41 2008 +0000 +++ b/hedgewars/uStats.pas Sun Jul 06 17:45:16 2008 +0000 @@ -38,6 +38,8 @@ procedure TurnReaction; procedure SendStats; +var FinishedTurnsTotal: LongInt = -1; + implementation uses uTeams, uSound, uMisc; var DamageGiven : Longword = 0; @@ -48,12 +50,13 @@ KillsTotal : LongWord = 0; AmmoUsedCount : Longword = 0; AmmoDamagingUsed : boolean = false; - FinishedTurnsTotal: LongInt = -1; SkippedTurns: LongWord = 0; isTurnSkipped: boolean = false; procedure HedgehogDamaged(Gear: PGear); begin +if bBetweenTurns then exit; + if Gear <> CurrentHedgehog^.Gear then inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); @@ -81,6 +84,8 @@ procedure TurnReaction; var i, t: LongInt; begin +TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true); + inc(FinishedTurnsTotal); if FinishedTurnsTotal = 0 then exit; @@ -112,7 +117,7 @@ else if AmmoDamagingUsed then PlaySound(sndMissed, false) -else if AmmoUsedCount > 0 then +else if (AmmoUsedCount > 0) and not isTurnSkipped then // nothing ? else if isTurnSkipped then PlaySound(sndBoring, false)