Prevent wrapping of turn time when using extra time
authorWuzzy <Wuzzy2@mail.ru>
Tue, 14 Aug 2018 13:43:04 +0200
changeset 13663 91d48cbae927
parent 13662 841ad2ad341d
child 13664 85506d95977d
Prevent wrapping of turn time when using extra time
ChangeLog.txt
hedgewars/uConsts.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uScript.pas
--- a/ChangeLog.txt	Tue Aug 14 09:26:32 2018 +0200
+++ b/ChangeLog.txt	Tue Aug 14 13:43:04 2018 +0200
@@ -102,6 +102,7 @@
  + New global: NoPointX. Value of CursorX and CursorY if cursor is inactive
  + New global: AMMO_INFINITE. Value for infinite ammo count for AddAmmo and other functions
  + New global: cMaxHogHealth. Maximum possible hedgehog health
+ + New global: cMaxTurnTime. Maximum possible turn time
  + New global: EXPLForceDraw. Flag for Explode function, forces land removal even with gfSolidLand on
  + New globals: capcolDefault, capcolSetting: Default caption colors
  * Changed global: lfCurrentHog becomes lfCurHogCrate
--- a/hedgewars/uConsts.pas	Tue Aug 14 09:26:32 2018 +0200
+++ b/hedgewars/uConsts.pas	Tue Aug 14 13:43:04 2018 +0200
@@ -209,6 +209,8 @@
 
     cDefaultBuildMaxDist = 256; // default max. building distance with girder/rubber
 
+    ExtraTime = 30000; // amount of time (ms) given for using Extra Time
+
     // do not change this value
     cDefaultZoomLevel = 2.0;
 
@@ -389,6 +391,8 @@
 
     cMaxLaserSightWraps = 1; // maximum number of world wraps of laser sight
 
+    cMaxTurnTime = Pred(High(LongInt)); // maximum possible turn time
+
 implementation
 
 end.
--- a/hedgewars/uGearsHedgehog.pas	Tue Aug 14 09:26:32 2018 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Tue Aug 14 13:43:04 2018 +0200
@@ -469,7 +469,10 @@
                                  end;
                     amExtraTime: begin
                                  PlaySound(sndExtraTime);
-                                 TurnTimeLeft:= TurnTimeLeft + 30000
+                                 if TurnTimeLeft <= (cMaxTurnTime - ExtraTime) then
+                                     TurnTimeLeft:= TurnTimeLeft + ExtraTime
+                                 else
+                                     TurnTimeLeft:= cMaxTurnTime;
                                  end;
                    amLaserSight: begin
                                  PlaySound(sndLaserSight);
--- a/hedgewars/uScript.pas	Tue Aug 14 09:26:32 2018 +0200
+++ b/hedgewars/uScript.pas	Tue Aug 14 13:43:04 2018 +0200
@@ -3927,6 +3927,7 @@
 ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE);
 ScriptSetInteger('NoPointX', NoPointX);
 ScriptSetInteger('cMaxHogHealth', cMaxHogHealth);
+ScriptSetInteger('cMaxTurnTime', cMaxTurnTime);
 
 // register gear types
 for at:= Low(TGearType) to High(TGearType) do