]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'terencehill/respawn_timer_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index f6918c606490422fb35afd4d6979e9b686b0c2fc..ad9a1ec542cc085844f77e1905f337da70f29a59 100644 (file)
@@ -294,7 +294,7 @@ void PutObserverInServer()
        this.superweapons_finished = 0;
        this.pushltime = 0;
        this.istypefrag = 0;
-       this.think = func_null;
+       setthink(this, func_null);
        this.nextthink = 0;
        this.hook_time = 0;
        this.deadflag = DEAD_NO;
@@ -547,7 +547,7 @@ void PutClientInServer()
                this.pain_frame = 0;
                this.pain_finished = 0;
                this.pushltime = 0;
-               this.think = func_null; // players have no think function
+               setthink(this, func_null); // players have no think function
                this.nextthink = 0;
                this.dmg_team = 0;
                this.ballistics_density = autocvar_g_ballistics_density_player;
@@ -619,7 +619,7 @@ void PutClientInServer()
 
                // reset fields the weapons may use
                FOREACH(Weapons, true, LAMBDA(
-                       it.wr_resetplayer(it);
+                       it.wr_resetplayer(it, this);
                        // reload all reloadable weapons
                        if (it.spawnflags & WEP_FLAG_RELOADABLE) {
                                this.weapon_load[it.m_id] = it.reloading_ammo;
@@ -696,8 +696,8 @@ void ClientInit_misc(entity this)
        WriteCoord(channel, autocvar_g_trueaim_minrange);
 }
 
-void ClientInit_CheckUpdate()
-{SELFPARAM();
+void ClientInit_CheckUpdate(entity this)
+{
        this.nextthink = time;
        if(this.count != autocvar_g_balance_armor_blockpercent)
        {
@@ -707,13 +707,12 @@ void ClientInit_CheckUpdate()
 }
 
 void ClientInit_Spawn()
-{SELFPARAM();
-
+{
        entity e = new_pure(clientinit);
-       e.think = ClientInit_CheckUpdate;
+       setthink(e, ClientInit_CheckUpdate);
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
-       WITHSELF(e, ClientInit_CheckUpdate());
+       WITHSELF(e, ClientInit_CheckUpdate(e));
 }
 
 /*
@@ -811,8 +810,8 @@ void ClientKill_Now()
 
        // now I am sure the player IS dead
 }
-void KillIndicator_Think()
-{SELFPARAM();
+void KillIndicator_Think(entity this)
+{
        if (gameover)
        {
                this.owner.killindicator = world;
@@ -892,7 +891,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        this.killindicator.scale = 0.5;
                        setattachment(this.killindicator, this, "");
                        setorigin(this.killindicator, '0 0 52');
-                       this.killindicator.think = KillIndicator_Think;
+                       setthink(this.killindicator, KillIndicator_Think);
                        this.killindicator.nextthink = starttime + (this.lip) * 0.05;
                        clientkilltime = max(clientkilltime, this.killindicator.nextthink + 0.05);
                        this.killindicator.cnt = ceil(killtime);
@@ -908,7 +907,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                                e.killindicator.scale = 0.5;
                                setattachment(e.killindicator, e, "");
                                setorigin(e.killindicator, '0 0 52');
-                               e.killindicator.think = KillIndicator_Think;
+                               setthink(e.killindicator, KillIndicator_Think);
                                e.killindicator.nextthink = starttime + (e.lip) * 0.05;
                                clientkilltime = max(clientkilltime, e.killindicator.nextthink + 0.05);
                                e.killindicator.cnt = ceil(killtime);
@@ -1141,7 +1140,7 @@ void ClientConnect()
                if (!autocvar_g_campaign)
                {
                        this.motd_actived_time = -1;
-                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
                }
 
                if (g_weaponarena_weapons == WEPSET(TUBA))
@@ -1223,8 +1222,8 @@ void ClientDisconnect()
        if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false);
 }
 
-void ChatBubbleThink()
-{SELFPARAM();
+void ChatBubbleThink(entity this)
+{
        this.nextthink = time;
        if ((this.owner.alpha < 0) || this.owner.chatbubbleentity != this)
        {
@@ -1259,7 +1258,7 @@ void UpdateChatBubble()
                this.chatbubbleentity = new(chatbubbleentity);
                this.chatbubbleentity.owner = this;
                this.chatbubbleentity.exteriormodeltoclient = this;
-               this.chatbubbleentity.think = ChatBubbleThink;
+               setthink(this.chatbubbleentity, ChatBubbleThink);
                this.chatbubbleentity.nextthink = time;
                setmodel(this.chatbubbleentity, MDL_CHAT); // precision set below
                //setorigin(this.chatbubbleentity, this.origin + '0 0 15' + this.maxs_z * '0 0 1');
@@ -1883,7 +1882,7 @@ void PrintWelcomeMessage(entity this)
                } else {
                        if (PHYS_INPUT_BUTTON_INFO(this)) {
                                this.motd_actived_time = time;
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
                        }
                }
        }
@@ -2065,7 +2064,6 @@ Called every frame for each client before the physics are run
 =============
 */
 .float usekeypressed;
-void() nexball_setstatus;
 .float last_vehiclecheck;
 .int items_added;
 void PlayerPreThink ()
@@ -2221,7 +2219,7 @@ void PlayerPreThink ()
                                bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this));
 
                                if (this.deadflag == DEAD_DYING) {
-                                       if ((this.respawn_flags & RESPAWN_FORCE) && !autocvar_g_respawn_delay_max) {
+                                       if ((this.respawn_flags & RESPAWN_FORCE) && !(this.respawn_time < this.respawn_time_max)) {
                                                this.deadflag = DEAD_RESPAWNING;
                                        } else if (!button_pressed) {
                                                this.deadflag = DEAD_DEAD;
@@ -2248,8 +2246,13 @@ void PlayerPreThink ()
 
                                if (this.respawn_flags & RESPAWN_SILENT)
                                        STAT(RESPAWN_TIME, this) = 0;
-                               else if ((this.respawn_flags & RESPAWN_FORCE) && autocvar_g_respawn_delay_max)
-                                       STAT(RESPAWN_TIME, this) = this.respawn_time_max;
+                               else if ((this.respawn_flags & RESPAWN_FORCE) && this.respawn_time < this.respawn_time_max)
+                               {
+                                       if (time < this.respawn_time)
+                                               STAT(RESPAWN_TIME, this) = this.respawn_time;
+                                       else if (this.deadflag != DEAD_RESPAWNING)
+                                               STAT(RESPAWN_TIME, this) = -this.respawn_time_max;
+                               }
                                else
                                        STAT(RESPAWN_TIME, this) = this.respawn_time;
                        }