--- a/ChangeLog.txt Fri Aug 10 13:16:24 2018 -0400
+++ b/ChangeLog.txt Sat Aug 11 22:33:40 2018 +0200
@@ -29,6 +29,7 @@
* Fix teleport tooltip claiming it doesn't end turn in hog placing phase with inf. attack
* Fix /hta, /hsa and /hya commands not writing message in chat
* Limit hedgehog health to 268435455 to prevent some bugs
+ * Fix Sudden Death starting in the second turn of a round rather than the first
Frontend:
+ Add setting to disable audio dampening when losing window focus
--- a/hedgewars/uGears.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uGears.pas Sat Aug 11 22:33:40 2018 +0200
@@ -135,7 +135,7 @@
dec(Gear^.Hedgehog^.InitialHealth) // does not need a minimum check since <= 1 basically disables it
end;
// Apply SD health decrease as soon as SD starts
- if (TotalRounds > cSuddenDTurns - 1) then
+ if (TotalRoundsPre > cSuddenDTurns - 1) then
begin
inc(tmp, cHealthDecrease);
if (GameFlags and gfResetHealth) <> 0 then
@@ -319,7 +319,7 @@
if (not bBetweenTurns) and (not isInMultiShoot) then
begin
// Start Sudden Death water rise in the 2nd round of Sudden Death
- if TotalRounds = cSuddenDTurns + 1 then
+ if TotalRoundsPre = cSuddenDTurns + 1 then
bWaterRising:= true;
if bWaterRising and (cWaterRise > 0) then
AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise;
@@ -337,11 +337,11 @@
begin
if (cWaterRise <> 0) or (cHealthDecrease <> 0) then
begin
- if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
+ if (TotalRoundsPre = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then
StartSuddenDeath()
- else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
+ else if (TotalRoundsPre < cSuddenDTurns) and (not isInMultiShoot) then
begin
- i:= cSuddenDTurns - TotalRounds;
+ i:= cSuddenDTurns - TotalRoundsPre;
s:= ansistring(inttostr(i));
if i = 1 then
AddCaption(trmsg[sidRoundSD], capcolDefault, capgrpGameState)
@@ -351,7 +351,7 @@
end;
if bBetweenTurns
or isInMultiShoot
- or (TotalRounds = -1) then
+ or (TotalRoundsPre = -1) then
inc(step)
else
begin
--- a/hedgewars/uGearsHandlersMess.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uGearsHandlersMess.pas Sat Aug 11 22:33:40 2018 +0200
@@ -6027,7 +6027,7 @@
end;
inc(Gear^.Timer);
end;
- if Gear^.Tag <= TotalRounds then
+ if Gear^.Tag <= TotalRoundsPre then
Gear^.Pos:= 3;
end;
--- a/hedgewars/uGearsList.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uGearsList.pas Sat Aug 11 22:33:40 2018 +0200
@@ -725,7 +725,7 @@
gear^.Radius:= 13;
gear^.Health:= 200;
gear^.Timer:= 0;
- gear^.Tag:= TotalRounds + 3;
+ gear^.Tag:= TotalRoundsPre + 3;
gear^.Pos:= 1;
end;
}
--- a/hedgewars/uScript.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uScript.pas Sat Aug 11 22:33:40 2018 +0200
@@ -3614,7 +3614,7 @@
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft);
ScriptSetInteger('GameTime', GameTicks);
-ScriptSetInteger('TotalRounds', TotalRounds);
+ScriptSetInteger('TotalRounds', TotalRoundsReal);
ScriptSetInteger('WaterLine', cWaterLine);
if isCursorVisible and (not bShowAmmoMenu) then
begin
--- a/hedgewars/uStats.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uStats.pas Sat Aug 11 22:33:40 2018 +0200
@@ -22,7 +22,8 @@
interface
uses uConsts, uTypes;
-var TotalRounds: LongInt; // Number of rounds played (-1 if game not started)
+var TotalRoundsPre: LongInt; // Helper variable for calculating start of Sudden Death and more. Starts at -1 and is incremented on the turn BEFORE the turn which marks the start of the next round. Always -1 while in hog placing phase
+ TotalRoundsReal: LongInt; // Total number of rounds played (-1 if not started or in hog placing phase). Exported to Lua as 'TotalRounds'
FinishedTurnsTotal: LongInt;
SendGameResultOn : boolean = true;
SendRankingStatsOn : boolean = true;
@@ -424,7 +425,8 @@
isTurnSkipped:= false;
vpHurtSameClan:= nil;
vpHurtEnemy:= nil;
- TotalRounds:= -1;
+ TotalRoundsPre:= -1;
+ TotalRoundsReal:= -1;
FinishedTurnsTotal:= -1;
end;
--- a/hedgewars/uTeams.pas Fri Aug 10 13:16:24 2018 -0400
+++ b/hedgewars/uTeams.pas Sat Aug 11 22:33:40 2018 +0200
@@ -51,6 +51,7 @@
var TeamsGameOver: boolean;
NextClan: boolean;
+ SwapClanPre, SwapClanReal: LongInt;
function CheckForWin: boolean;
var AliveClan: PClan;
@@ -192,27 +193,45 @@
c:= CurrentTeam^.Clan^.ClanIndex;
repeat
- with ClansArray[c]^ do
- if (GameFlags and gfTagTeam) <> 0 then
+ if (GameFlags and gfTagTeam) <> 0 then
+ begin
+ with ClansArray[c]^ do
begin
if (CurrTeam = TagTeamIndex) then
begin
- if (c = 0) and (not PlacingHogs) then
- inc(TotalRounds);
TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber;
CurrTeam:= Pred(CurrTeam) mod TeamsNumber;
inc(c);
+ if c = ClansCount then
+ c:= 0;
+ if c = SwapClanReal then
+ inc(TotalRoundsReal);
NextClan:= true;
end;
- end
- else if (c = 0) and (not PlacingHogs) then
- inc(TotalRounds);
+ end;
- if (GameFlags and gfTagTeam) = 0 then
+ with ClansArray[c]^ do
+ begin
+ if (not PlacingHogs) and ((Succ(CurrTeam) mod TeamsNumber) = TagTeamIndex) then
+ begin
+ if c = SwapClanPre then
+ inc(TotalRoundsPre);
+ end;
+ end;
+ end
+ else
+ begin
inc(c);
-
- if c = ClansCount then
- c:= 0;
+ if c = ClansCount then
+ c:= 0;
+ if (not PlacingHogs) then
+ begin
+ if c = SwapClanPre then
+ inc(TotalRoundsPre);
+ if c = SwapClanReal then
+ inc(TotalRoundsReal);
+ end;
+ end;
with ClansArray[c]^ do
begin
@@ -287,13 +306,30 @@
for i:= 0 to ClansCount do
if ClansArray[i] <> nil then
ClansArray[i]^.TurnNumber:= 0;
- ResetWeapons;
- inc(TotalRounds)
- end
- end
-else
- if TotalRounds <= -1 then
- TotalRounds:= 0;
+ ResetWeapons
+ end;
+
+ end;
+
+if not PlacingHogs then
+ if (TotalRoundsReal = -1) then
+ TotalRoundsReal:= 0;
+ if (TotalRoundsPre = -1) and (ClansCount = 1) then
+ TotalRoundsPre:= 0;
+
+// Determine clan ID to check to determine whether to increase TotalRoundsPre/TotalRoundsReal
+if (not PlacingHogs) then
+ begin
+ if SwapClanPre = -1 then
+ begin
+ if (GameFlags and gfRandomOrder) <> 0 then
+ SwapClanPre:= 0
+ else
+ SwapClanPre:= ClansCount - 1;
+ end;
+ if SwapClanReal = -1 then
+ SwapClanReal:= CurrentTeam^.Clan^.ClanIndex;
+ end;
inc(CurrentTeam^.Clan^.TurnNumber);
with CurrentTeam^.Clan^ do
@@ -881,6 +917,8 @@
LocalAmmo:= -1;
TeamsGameOver:= false;
NextClan:= true;
+SwapClanPre:= -1;
+SwapClanReal:= -1;
MaxTeamHealth:= 0;
end;
@@ -926,6 +964,8 @@
end;
TeamsCount:= 0;
ClansCount:= 0;
+SwapClanPre:= -1;
+SwapClanReal:= -1;
end;
end.