]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a missing if check for flag waypoint health
authordrjaska <drjaska83@gmail.com>
Wed, 10 Jul 2024 21:09:58 +0000 (00:09 +0300)
committerdrjaska <drjaska83@gmail.com>
Wed, 10 Jul 2024 21:09:58 +0000 (00:09 +0300)
The waypoint usage here was missing a check that it has been
initialised properly. Without waypoint updating code assumed
that the flag has >0 max_health which caused many div by zero errors.

Added the following if check:
autocvar_g_ctf_flag_return_time ||
(autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health)

qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc

index 747dbe88cbe46e1c79466685ea7b8a63524a11b5..e8360878515ef813124d584c387eed15a67914cd 100644 (file)
@@ -799,7 +799,11 @@ void ctf_CheckFlagReturn(entity flag, int returntype)
 {
        if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING))
        {
-               if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(flag, RES_HEALTH)); }
+               if (flag.wps_flagdropped
+               && (autocvar_g_ctf_flag_return_time || (autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health)))
+               {
+                       WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(flag, RES_HEALTH));
+               }
 
                if((GetResource(flag, RES_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time))
                {