]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve end of warmup countdown abort (when player count drops too low)
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 20 Oct 2022 15:29:14 +0000 (01:29 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 6 Jan 2023 07:16:10 +0000 (17:16 +1000)
Respects g_warmup_allguns 1.
Previously players were left with only shotgun and blaster in the
resumed warmup when sv_ready_restart_after_countdown 0.

Fixes incomplete countdown abort when sv_ready_restart_after_countdown 1.

Allows bots to start playing again immediately when countdown is aborted.

qcsrc/server/bot/default/bot.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/vote.qc

index b81507890f302da772d225f28f44c12a73ac85ae..d7cf429d74e150a8324c0c30bfe0245d683658f1 100644 (file)
@@ -118,7 +118,6 @@ void bot_think(entity this)
                        W_NextWeapon(this, 0, weaponentity);
                // block the bot during the countdown to game start
                CS(this).movement = '0 0 0';
-               this.bot_nextthink = game_starttime;
                return;
        }
 
index 6d8ef921b1f4b9bc0679cb97feb3ed7aafe7c0d1..5b7509e484d5fecec7e6f49a852de6ea218e39e9 100644 (file)
@@ -536,6 +536,19 @@ void FixPlayermodel(entity player)
                                setcolor(player, stof(autocvar_sv_defaultplayercolors));
 }
 
+void GiveWarmupResources(entity this)
+{
+       SetResource(this, RES_SHELLS, warmup_start_ammo_shells);
+       SetResource(this, RES_BULLETS, warmup_start_ammo_nails);
+       SetResource(this, RES_ROCKETS, warmup_start_ammo_rockets);
+       SetResource(this, RES_CELLS, warmup_start_ammo_cells);
+       SetResource(this, RES_PLASMA, warmup_start_ammo_plasma);
+       SetResource(this, RES_FUEL, warmup_start_ammo_fuel);
+       SetResource(this, RES_HEALTH, warmup_start_health);
+       SetResource(this, RES_ARMOR, warmup_start_armorvalue);
+       STAT(WEAPONS, this) = WARMUP_START_WEAPONS;
+}
+
 void PutPlayerInServer(entity this)
 {
        if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE);
@@ -578,17 +591,10 @@ void PutPlayerInServer(entity this)
        this.takedamage = DAMAGE_AIM;
        this.effects = EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
 
-       if (warmup_stage) {
-               SetResource(this, RES_SHELLS, warmup_start_ammo_shells);
-               SetResource(this, RES_BULLETS, warmup_start_ammo_nails);
-               SetResource(this, RES_ROCKETS, warmup_start_ammo_rockets);
-               SetResource(this, RES_CELLS, warmup_start_ammo_cells);
-               SetResource(this, RES_PLASMA, warmup_start_ammo_plasma);
-               SetResource(this, RES_FUEL, warmup_start_ammo_fuel);
-               SetResource(this, RES_HEALTH, warmup_start_health);
-               SetResource(this, RES_ARMOR, warmup_start_armorvalue);
-               STAT(WEAPONS, this) = WARMUP_START_WEAPONS;
-       } else {
+       if (warmup_stage)
+               GiveWarmupResources(this);
+       else
+       {
                SetResource(this, RES_SHELLS, start_ammo_shells);
                SetResource(this, RES_BULLETS, start_ammo_nails);
                SetResource(this, RES_ROCKETS, start_ammo_rockets);
index 56cce52a996dd338b551cb08441425f32ce957a0..eebf016f7500716881fcaa6c8fb44f88b02e91df 100644 (file)
@@ -393,6 +393,8 @@ void SetSpectatee_status(entity this, int spectatee_num);
 
 void FixPlayermodel(entity player);
 
+void GiveWarmupResources(entity this);
+
 void ClientInit_misc(entity this);
 
 int GetPlayerLimit();
index c4aec35b6d6e2d48387812e6bf106cb378e97ede..795ea09e5242f12fc0297a500e2b8a29efc8d601 100644 (file)
@@ -419,7 +419,8 @@ void reset_map(bool dorespawn, bool is_fake_round_start)
 // Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
 void ReadyRestart_think(entity this)
 {
-       reset_map(true, false);
+       if (!warmup_stage) // if the countdown was not aborted
+               reset_map(true, false);
        delete(this);
 }
 
@@ -536,6 +537,8 @@ void ReadyCount()
                        warmup_stage = autocvar_g_warmup; // CAN change it AFTER calling Nagger_ReadyCounted() this frame
                        game_starttime = time;
                        Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, COUNTDOWN_STOP, minplayers);
+                       if (!sv_ready_restart_after_countdown) // if we ran reset_map() at start of countdown
+                               FOREACH_CLIENT(IS_PLAYER(it), { GiveWarmupResources(it); });
                }
                if (warmup_limit > 0)
                        warmup_limit = -1;