]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
CA: Forbid spawning players in a more correct way, adding a hook for it; visually...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 0c6f66a2cc2cbc23347298bf54582a29d827ecdb..0c48324254d567bc20c2ede64e6f1df0544bca3c 100644 (file)
@@ -159,7 +159,8 @@ void ClientData_Touch(entity e)
 
 .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;
+       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
@@ -515,6 +517,7 @@ void PutClientInServer(entity this)
                }
 
                TRANSMUTE(Player, this);
+
                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;
                }
+               SetSpectatee_status(this, 0);
 
                this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
 
@@ -729,7 +733,7 @@ void ClientInit_misc(entity this)
        else
                WriteString(channel, "");
        WriteByte(channel, this.count * 255.0); // g_balance_armor_blockpercent
-       WriteByte(channel, serverflags); // client has to know if it should zoom or not
+       WriteByte(channel, serverflags);
        WriteCoord(channel, autocvar_g_trueaim_minrange);
 }
 
@@ -1694,7 +1698,7 @@ void SpectateCopy(entity this, entity spectatee)
 bool SpectateUpdate(entity this)
 {
        if(!this.enemy)
-           return false;
+               return false;
 
        if(!IS_PLAYER(this.enemy) || this == this.enemy)
        {
@@ -1726,6 +1730,18 @@ bool SpectateSet(entity this)
        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;
@@ -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); }
 }
@@ -1842,12 +1861,8 @@ void ShowRespawnCountdown(entity this)
        }
 }
 
-.float caplayer;
-
 void LeaveSpectatorMode(entity this)
 {
-       if(this.caplayer)
-               return;
        if(nJoinAllowed(this, this))
        {
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
@@ -1990,8 +2005,9 @@ void ObserverThink(entity this)
                MinigameImpulse(this, this.impulse);
                this.impulse = 0;
        }
+
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) && !this.version_mismatch) {
@@ -2030,8 +2046,9 @@ void SpectatorThink(entity this)
                        return;
                }
        }
+
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) || this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209)) {
@@ -2433,19 +2450,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;
@@ -2496,20 +2500,11 @@ void DrownPlayer(entity this)
 
 void Player_Physics(entity this)
 {
-       set_movetype(this, ((this.move_qcphysics) ? MOVETYPE_NONE : this.move_movetype));
+       set_movetype(this, this.move_movetype);
 
        if(!this.move_qcphysics)
                return;
 
-       int mt = this.move_movetype;
-
-       if(mt == MOVETYPE_PUSH || mt == MOVETYPE_FAKEPUSH || mt == MOVETYPE_PHYSICS)
-       {
-               this.move_qcphysics = false;
-               set_movetype(this, mt);
-               return;
-       }
-
        if(!frametime && !this.pm_frametime)
                return;