]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make sure number of lives is an integer and <= 999
authorterencehill <piuntn@gmail.com>
Wed, 22 Jan 2020 20:01:02 +0000 (21:01 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 22 Jan 2020 20:01:02 +0000 (21:01 +0100)
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qh

index 61a6d701bde01e03345a660b53669f60e93179b8..bff9722d08a766785229f3ea4744f58aaf94bc12 100644 (file)
@@ -10,11 +10,10 @@ int autocvar_g_lms_last_join;
 bool autocvar_g_lms_regenerate;
 
 // main functions
-float LMS_NewPlayerLives()
+int LMS_NewPlayerLives()
 {
-       float fl;
-       fl = autocvar_fraglimit;
-       if(fl == 0)
+       int fl = floor(autocvar_fraglimit);
+       if(fl == 0 || fl > 999)
                fl = 999;
 
        // first player has left the game for dying too much? Nobody else can get in.
@@ -22,7 +21,7 @@ float LMS_NewPlayerLives()
                return 0;
 
        if(!autocvar_g_lms_join_anytime)
-               if(lms_lowest_lives < fl - autocvar_g_lms_last_join)
+               if(lms_lowest_lives < fl - max(0, floor(autocvar_g_lms_last_join)))
                        return 0;
 
        return bound(1, lms_lowest_lives, fl);
@@ -447,5 +446,5 @@ MUTATOR_HOOKFUNCTION(lms, AddPlayerScore)
 
 void lms_Initialize()
 {
-       lms_lowest_lives = 9999;
+       lms_lowest_lives = 999;
 }
index 996d371fe05b84e736283ccc042251aaa60e8a3a..bf02920d2c1616207ac54545d3b331a617de90e6 100644 (file)
@@ -3,7 +3,10 @@
 #include <common/mutators/base.qh>
 #include <common/scores.qh>
 
-.float lms_spectate_warning;
+// 1 when player presses F3 to spectate for the first time (he only gets a warning)
+// 2 when player goes spectator (presses F3 to spectate for the second time)
+// 3 when player disconnects
+.int lms_spectate_warning;
 
 #define autocvar_g_lms_lives_override cvar("g_lms_lives_override")
 string autocvar_g_lms_weaponarena = "most_available";
@@ -29,5 +32,5 @@ REGISTER_MUTATOR(lms, false)
 }
 
 // lives related defs
-float lms_lowest_lives;
-float LMS_NewPlayerLives();
+int lms_lowest_lives;
+int LMS_NewPlayerLives();