]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Item respawn fix and ready anti-flood
authorz411 <z411@omaera.org>
Fri, 16 Oct 2020 01:34:29 +0000 (22:34 -0300)
committerz411 <z411@omaera.org>
Fri, 16 Oct 2020 01:34:29 +0000 (22:34 -0300)
qcsrc/server/command/cmd.qc
qcsrc/server/command/vote.qh
qcsrc/server/items/items.qc

index 0ba8ed3006f643820086a89fbe36b55471c1af35..2772e4f2c33841bdb80b112a908e7aba1259993d 100644 (file)
@@ -376,13 +376,13 @@ void ClientCommand_physics(entity caller, int request, int argc)
        }
 }
 
-void ClientCommand_ready(entity caller, int request)  // todo: anti-spam for toggling readyness
+void ClientCommand_ready(entity caller, int request)
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if (IS_CLIENT(caller))
+                       if (IS_CLIENT(caller) && caller.last_ready < time - 3) // anti-spam
                        {
                                if (warmup_stage || sv_ready_restart || g_race_qualifying == 2)
                                {
@@ -402,6 +402,8 @@ void ClientCommand_ready(entity caller, int request)  // todo: anti-spam for tog
                                                        if(IS_PLAYER(caller) || caller.caplayer == 1)
                                                                bprint("\{1}", playername(caller, false), "^2 is ready\n");
                                                }
+                                               
+                                               caller.last_ready = time;
 
                                                // cannot reset the game while a timeout is active!
                                                if (!timeout_status) ReadyCount();
index 6c4d30d171950413f6ee241119f2353eb2aeb6f2..8d70e769350449f289309d51afde7326dca9f98f 100644 (file)
@@ -57,6 +57,7 @@ float readycount;                  // amount of players who are ready
 float readyrestart_happened;       // keeps track of whether a restart has already happened
 float restart_mapalreadyrestarted; // bool, indicates whether reset_map() was already executed
 .float ready;                      // flag for if a player is ready
+.float last_ready;                                // z411 time of the last readyup for anti-spam
 .int team_saved;                   // team number to restore upon map reset
 .void(entity this) reset;             // if set, an entity is reset using this
 .void(entity this) reset2;         // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
index 906e89aeaf71d19f2036bfeec3528ba74caeb310..93da11a478efbb8b60e0751a0f78bdd4fd8375b8 100644 (file)
@@ -222,6 +222,8 @@ void Item_Respawn(entity this)
 
 void Item_RespawnCountdown(entity this)
 {
+       if(game_timeout) { this.nextthink = time + 1; return; }
+       
        if(this.item_respawncounter >= ITEM_RESPAWN_TICKS)
        {
                if(this.waypointsprite_attached)
@@ -231,7 +233,11 @@ void Item_RespawnCountdown(entity this)
        else
        {
                this.nextthink = time + 1;
-               this.item_respawncounter += 1;
+               this.item_respawncounter = floor((time - timeout_total_time) - (this.scheduledrespawntime - ITEM_RESPAWN_TICKS)) + 1;
+               //this.item_respawncounter += 1;
+               //LOG_INFOF("Respawncounter: %d", this.item_respawncounter);
+               if(this.item_respawncounter < 1) return;
+               
                if(this.item_respawncounter == 1)
                {
                        do {
@@ -296,9 +302,12 @@ void Item_ScheduleRespawnIn(entity e, float t)
        if ((Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0)
        {
                setthink(e, Item_RespawnCountdown);
-               e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
-               e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
+               //e.nextthink = time - timeout_total_time + max(0, t - ITEM_RESPAWN_TICKS);
+               //e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
+               e.nextthink = time;
+               e.scheduledrespawntime = time - timeout_total_time + t;
                e.item_respawncounter = 0;
+               
                if(Item_ItemsTime_Allow(e.itemdef) || (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
                {
                        t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);