Merge branch 'master' into terencehill/spectatee_status_update
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 0c6f66a2cc2cbc23347298bf54582a29d827ecdb..06254c42a0648b877aef9adf36e4a9ca62c30aea 100644 (file)
@@ -159,7 +159,8 @@ void ClientData_Touch(entity e)
 
 .string netname_previous;
 
 
 .string netname_previous;
 
-void SetSpectatee(entity player, entity spectatee);
+void SetSpectatee(entity this, entity spectatee);
+void SetSpectatee_status(entity this, int spectatee_num);
 
 
 /*
 
 
 /*
@@ -301,6 +302,7 @@ void PutObserverInServer(entity this)
        this.teleportable = TELEPORT_SIMPLE;
        this.damagedbycontents = false;
        this.health = FRAGS_SPECTATOR;
        this.teleportable = TELEPORT_SIMPLE;
        this.damagedbycontents = false;
        this.health = FRAGS_SPECTATOR;
+       SetSpectatee_status(this, etof(this));
        this.takedamage = DAMAGE_NO;
        this.solid = SOLID_NOT;
        set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
        this.takedamage = DAMAGE_NO;
        this.solid = SOLID_NOT;
        set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
@@ -515,6 +517,7 @@ void PutClientInServer(entity this)
                }
 
                TRANSMUTE(Player, this);
                }
 
                TRANSMUTE(Player, this);
+
                this.wasplayer = true;
                this.iscreature = true;
                this.teleportable = TELEPORT_NORMAL;
                this.wasplayer = true;
                this.iscreature = true;
                this.teleportable = TELEPORT_NORMAL;
@@ -556,6 +559,7 @@ void PutClientInServer(entity this)
                        this.armorvalue = start_armorvalue;
                        this.weapons = start_weapons;
                }
                        this.armorvalue = start_armorvalue;
                        this.weapons = start_weapons;
                }
+               SetSpectatee_status(this, 0);
 
                this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
 
 
                this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
 
@@ -1726,6 +1730,18 @@ bool SpectateSet(entity this)
        return true;
 }
 
        return true;
 }
 
+void SetSpectatee_status(entity this, int spectatee_num)
+{
+       int oldspectatee_status = this.spectatee_status;
+       this.spectatee_status = spectatee_num;
+
+       if (this.spectatee_status != oldspectatee_status)
+       {
+               ClientData_Touch(this);
+               if (g_race || g_cts) race_InitSpectator();
+       }
+}
+
 void SetSpectatee(entity this, entity spectatee)
 {
        entity old_spectatee = this.enemy;
 void SetSpectatee(entity this, entity spectatee)
 {
        entity old_spectatee = this.enemy;
@@ -1753,6 +1769,9 @@ void SetSpectatee(entity this, entity spectatee)
                }
        }
 
                }
        }
 
+       if (this.enemy)
+               SetSpectatee_status(this, etof(this.enemy));
+
        // needed to update spectator list
        if(old_spectatee) { ClientData_Touch(old_spectatee); }
 }
        // needed to update spectator list
        if(old_spectatee) { ClientData_Touch(old_spectatee); }
 }
@@ -2433,19 +2452,6 @@ void PlayerPreThink (entity this)
                );
     }
 
                );
     }
 
-       int oldspectatee_status = this.spectatee_status;
-       if (IS_SPEC(this)) {
-               this.spectatee_status = etof(this.enemy);
-       } else if (IS_OBSERVER(this)) {
-               this.spectatee_status = etof(this);
-       } else {
-               this.spectatee_status = 0;
-    }
-       if (this.spectatee_status != oldspectatee_status) {
-               ClientData_Touch(this);
-               if (g_race || g_cts) race_InitSpectator();
-       }
-
        if (this.teamkill_soundtime && time > this.teamkill_soundtime)
        {
                this.teamkill_soundtime = 0;
        if (this.teamkill_soundtime && time > this.teamkill_soundtime)
        {
                this.teamkill_soundtime = 0;