]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Merge branch 'master' into terencehill/min_spec_time
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 5a199e06dc3396c61b7de4b0ff5e24bf112bcbb8..3fd9113bdd18e73adc32d4e7bfdbfc42235af2fe 100644 (file)
@@ -308,6 +308,9 @@ void PutObserverInServer(entity this)
        if(this.bot_attack)
                IL_REMOVE(g_bot_targets, this);
        this.bot_attack = false;
+       if(this.monster_attack)
+               IL_REMOVE(g_monster_targets, this);
+       this.monster_attack = false;
     STAT(HUD, this) = HUD_NORMAL;
        TRANSMUTE(Observer, this);
        this.iscreature = false;
@@ -340,6 +343,7 @@ void PutObserverInServer(entity this)
        this.strength_finished = 0;
        this.invincible_finished = 0;
        this.superweapons_finished = 0;
+       this.dphitcontentsmask = 0;
        this.pushltime = 0;
        this.istypefrag = 0;
        setthink(this, func_null);
@@ -1215,16 +1219,7 @@ void ClientConnect(entity this)
        JoinBestTeam(this, false); // if the team number is valid, keep it
        this.playerid = playerid_save;
 
-       if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) {
-               TRANSMUTE(Observer, this);
-       } else {
-               if (!teamplay || autocvar_g_balance_teams) {
-                       TRANSMUTE(Player, this);
-                       campaign_bots_may_start = true;
-               } else {
-                       TRANSMUTE(Observer, this); // do it anyway
-               }
-       }
+       TRANSMUTE(Observer, this);
 
        PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
 
@@ -2242,43 +2237,6 @@ bool PlayerThink(entity this)
                return false;
        }
 
-       bool have_hook = false;
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-       {
-               .entity weaponentity = weaponentities[slot];
-               if(this.(weaponentity).hook.state)
-               {
-                       have_hook = true;
-                       break;
-               }
-       }
-       bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this);
-       if (have_hook) {
-               do_crouch = false;
-       } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
-               do_crouch = false;
-       } else if (this.vehicle) {
-               do_crouch = false;
-       } else if (STAT(FROZEN, this)) {
-               do_crouch = false;
-    }
-
-       if (do_crouch) {
-               if (!this.crouch) {
-                       this.crouch = true;
-                       this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, this);
-                       setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this));
-                       // setanim(this, this.anim_duck, false, true, true); // this anim is BROKEN anyway
-               }
-       } else if (this.crouch) {
-        tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, false, this);
-        if (!trace_startsolid) {
-            this.crouch = false;
-            this.view_ofs = STAT(PL_VIEW_OFS, this);
-            setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this));
-        }
-       }
-
        FixPlayermodel(this);
 
        if (this.shootfromfixedorigin != autocvar_g_shootfromfixedorigin) {
@@ -2605,7 +2563,10 @@ void PlayerPreThink (entity this)
        if (IS_REAL_CLIENT(this))
                PrintWelcomeMessage(this);
 
+       #define MIN_SPEC_TIME 1
        if (IS_PLAYER(this)) {
+               if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME)
+                       error("Client can't be spawned as player on connection!");
                if(!PlayerThink(this))
                        return;
        }
@@ -2614,6 +2575,22 @@ void PlayerPreThink (entity this)
                        IntermissionThink(this);
                return;
        }
+       else if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME + 1)
+       {
+               // don't do this in ClientConnect
+               // many things can go wrong if a client is spawned as player on connection
+               if (time > CS(this).jointime + MIN_SPEC_TIME)
+               {
+                       if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this)
+                               || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0)
+                                       && (!teamplay || autocvar_g_balance_teams)))
+                       {
+                               campaign_bots_may_start = true;
+                               Join(this);
+                               return;
+                       }
+               }
+       }
        else if (IS_OBSERVER(this)) {
                ObserverThink(this);
        }
@@ -2801,11 +2778,14 @@ void PM_UpdateButtons(entity this, entity store)
                store.impulse = this.impulse;
        this.impulse = 0;
 
-       store.button0 = this.button0;
-       store.button2 = this.button2;
-       store.button3 = this.button3;
+       bool typing = this.buttonchat;
+
+       store.button0 = (typing) ? 0 : this.button0;
+       //button1?!
+       store.button2 = (typing) ? 0 : this.button2;
+       store.button3 = (typing) ? 0 : this.button3;
        store.button4 = this.button4;
-       store.button5 = this.button5;
+       store.button5 = (typing) ? 0 : this.button5;
        store.button6 = this.button6;
        store.button7 = this.button7;
        store.button8 = this.button8;
@@ -2831,5 +2811,12 @@ void PM_UpdateButtons(entity this, entity store)
        store.ping_movementloss = this.ping_movementloss;
 
        store.v_angle = this.v_angle;
-       store.movement = this.movement;
+       store.movement = (typing) ? '0 0 0' : this.movement;
+}
+
+NET_HANDLE(fpsreport, bool)
+{
+       int fps = ReadShort();
+       PlayerScore_Set(sender, SP_FPS, fps);
+       return true;
 }