# HG changeset patch # User nemo # Date 1288372773 14400 # Node ID e9baae83370b7825ccd7a05de846143097e5c36c # Parent c9b20ed3566f7158d6df0a6474aae06bd67eccff Avoid doing this stuff twice, even if CheckForWin is called twice diff -r c9b20ed3566f -r e9baae83370b hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Fri Oct 29 11:19:21 2010 -0400 +++ b/hedgewars/uTeams.pas Fri Oct 29 13:19:33 2010 -0400 @@ -101,6 +101,7 @@ LocalClan: LongInt; // last non-bot, non-extdriven clan LocalAmmo: LongInt; // last non-bot, non-extdriven clan's first team's ammo index CurMinAngle, CurMaxAngle: Longword; + GameOver: boolean; procedure initModule; procedure freeModule; @@ -139,31 +140,35 @@ TurnTimeLeft:= 0; ReadyTimeLeft:= 0; -if AliveCount = 0 then - begin // draw - AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); - SendStat(siGameResult, trmsg[sidDraw]); - AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) - end else // win - with AliveClan^ do - begin - if TeamsNumber = 1 then - s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins - else - s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins +if not GameOver then + begin + if AliveCount = 0 then + begin // draw + AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); + SendStat(siGameResult, trmsg[sidDraw]); + AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) + end else // win + with AliveClan^ do + begin + if TeamsNumber = 1 then + s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins + else + s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins - for j:= 0 to Pred(TeamsNumber) do - with Teams[j]^ do - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i] do - if (Gear <> nil) then - Gear^.State:= gstWinner; + for j:= 0 to Pred(TeamsNumber) do + with Teams[j]^ do + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if (Gear <> nil) then + Gear^.State:= gstWinner; - AddCaption(s, cWhiteColor, capgrpGameState); - SendStat(siGameResult, s); - AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) - end; -SendStats + AddCaption(s, cWhiteColor, capgrpGameState); + SendStat(siGameResult, s); + AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) + end; + SendStats; + end; +GameOver:= true end; procedure SwitchHedgehog; @@ -497,6 +502,7 @@ ClansCount:= 0; LocalClan:= -1; LocalAmmo:= -1; + GameOver:= false end; procedure freeModule;