]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Only remove player status effects on player disconnect
authorDr. Jaska <drjaska83@gmail.com>
Mon, 1 Jul 2024 06:57:31 +0000 (06:57 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Mon, 1 Jul 2024 06:57:31 +0000 (06:57 +0000)
qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc

index 9d97e94b697ebe918f8aaaa12a2aa9099983e4f6..2f654333dafa580d716b58ab73b2a4622bc7f7a1 100644 (file)
@@ -74,7 +74,13 @@ MUTATOR_HOOKFUNCTION(status_effects, ClientDisconnect)
 {
        entity player = M_ARGV(0, entity);
 
-       StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL); // just to get rid of the pickup sound
+       // don't delete possible spectatee's effects!
+       if(player.statuseffects && player.statuseffects.owner == player)
+       {
+               // just to get rid of the pickup sound
+               StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL);
+       }
+
        return true;
 }
 
@@ -82,8 +88,15 @@ MUTATOR_HOOKFUNCTION(status_effects, MakePlayerObserver)
 {
        entity player = M_ARGV(0, entity);
 
-       // no need to network updates, as there is no statuseffects object attached
-       StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL); // just to get rid of the pickup sound
+       // don't delete spectatee's effects!
+       if(player.statuseffects && player.statuseffects.owner == player)
+       {
+               // just to get rid of the pickup sound
+               // no need to network updates, as there is no statuseffects object attached
+               StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL);
+       }
+
+       // spectator has their own ent
        StatusEffects_clearall(player.statuseffects_store);
 
        // don't delete spectatee's effects!