Merge branch 'terencehill/respawn_timer_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 9c19574..ad9a1ec 100644 (file)
@@ -196,7 +196,7 @@ void PutObserverInServer()
     }
 
     {
-        entity spot = SelectSpawnPoint(true);
+        entity spot = SelectSpawnPoint(this, true);
         if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
         this.angles = spot.angles;
         this.angles_z = 0;
@@ -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;
@@ -471,7 +471,7 @@ void PutClientInServer()
                if (this.team < 0)
                        JoinBestTeam(this, false, true);
 
-               entity spot = SelectSpawnPoint(false);
+               entity spot = SelectSpawnPoint(this, false);
                if (!spot) {
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
                        return; // spawn failed
@@ -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;
@@ -656,7 +656,7 @@ void PutClientInServer()
        }
 }
 
-void ClientInit_misc();
+void ClientInit_misc(entity this);
 
 .float ebouncefactor, ebouncestop; // electro's values
 // TODO do we need all these fields, or should we stop autodetecting runtime
@@ -670,12 +670,11 @@ bool ClientInit_SendEntity(entity this, entity to, int sf)
        // TODO: make easier to use
        Registry_send_all();
        W_PROP_reload(MSG_ONE, to);
-       ClientInit_misc();
+       ClientInit_misc(this);
        MUTATOR_CALLHOOK(Ent_Init);
 }
-void ClientInit_misc()
+void ClientInit_misc(entity this)
 {
-    SELFPARAM();
        int channel = MSG_ONE;
        WriteHeader(channel, ENT_CLIENT_INIT);
        WriteByte(channel, g_nexball_meter_period * 32);
@@ -697,8 +696,8 @@ void ClientInit_misc()
        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)
        {
@@ -708,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));
 }
 
 /*
@@ -812,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;
@@ -893,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);
@@ -909,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);
@@ -1142,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))
@@ -1224,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)
        {
@@ -1260,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');
@@ -1884,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));
                        }
                }
        }
@@ -2066,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 ()