]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Remove even more self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index a749ec2def81b8b60c1faaf8b9bf55d4270fda0a..1c17abdd34b19449bd471b59f3ab1c99060bc902 100644 (file)
@@ -37,16 +37,16 @@ void Drop_Special_Items(entity player)
        MUTATOR_CALLHOOK(DropSpecialItems, player);
 }
 
-void CopyBody_Think()
-{SELFPARAM();
+void CopyBody_Think(entity this)
+{
        if(this.CopyBody_nextthink && time > this.CopyBody_nextthink)
        {
-               this.CopyBody_think();
+               this.CopyBody_think(this);
                if(wasfreed(this))
                        return;
                this.CopyBody_nextthink = this.nextthink;
-               this.CopyBody_think = this.think;
-               this.think = CopyBody_Think;
+               this.CopyBody_think = getthink(this);
+               setthink(this, CopyBody_Think);
        }
        CSQCMODEL_AUTOUPDATE(this);
        this.nextthink = time;
@@ -95,7 +95,7 @@ void CopyBody(entity this, float keepvelocity)
        clone.solid = this.solid;
        clone.ballistics_density = this.ballistics_density;
        clone.takedamage = this.takedamage;
-       clone.customizeentityforclient = this.customizeentityforclient;
+       setcefc(clone, getcefc(this));
        clone.uncustomizeentityforclient = this.uncustomizeentityforclient;
        clone.uncustomizeentityforclient_set = this.uncustomizeentityforclient_set;
        if (keepvelocity == 1)
@@ -118,9 +118,9 @@ void CopyBody(entity this, float keepvelocity)
 
        CSQCMODEL_AUTOINIT(clone);
        clone.CopyBody_nextthink = this.nextthink;
-       clone.CopyBody_think = this.think;
+       clone.CopyBody_think = getthink(this);
        clone.nextthink = time;
-       clone.think = CopyBody_Think;
+       setthink(clone, CopyBody_Think);
        // "bake" the current animation frame for clones (they don't get clientside animation)
        animdecide_load_if_needed(clone);
        animdecide_setframes(clone, false, frame, frame1time, frame2, frame2time);
@@ -556,7 +556,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                excess = frag_damage;
 
                Weapon wep = PS(this).m_weapon;
-               WITHSELF(this, wep.wr_playerdeath(wep));
+               WITHSELF(this, wep.wr_playerdeath(wep, this));
 
                RemoveGrapplingHook(this);
 
@@ -622,10 +622,10 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                // set up to fade out later
                SUB_SetFade (this, time + 6 + random (), 1);
                // reset body think wrapper broken by SUB_SetFade
-               if(this.classname == "body" && this.think != CopyBody_Think) {
-                       this.CopyBody_think = this.think;
+               if(this.classname == "body" && getthink(this) != CopyBody_Think) {
+                       this.CopyBody_think = getthink(this);
                        this.CopyBody_nextthink = this.nextthink;
-                       this.think = CopyBody_Think;
+                       setthink(this, CopyBody_Think);
                        this.nextthink = time;
                }
 
@@ -637,7 +637,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
 
                // reset fields the weapons may use just in case
                FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       WITHSELF(this, it.wr_resetplayer(it));
+                       WITHSELF(this, it.wr_resetplayer(it, this));
                        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                        {
                                ATTACK_FINISHED_FOR(this, it.m_id, slot) = 0;
@@ -657,6 +657,12 @@ void MoveToTeam(entity client, int team_colour, int type)
        LogTeamchange(client.playerid, client.team, type);
 }
 
+/** print(), but only print if the server is not local */
+void dedicated_print(string input)
+{
+       if (server_is_dedicated) print(input);
+}
+
 /**
  * message "": do not say, just test flood control
  * return value:
@@ -669,7 +675,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
        if (!teamsay && !privatesay) if (substring(msgin, 0, 1) == " ")
         msgin = substring(msgin, 1, -1); // work around DP say bug (say_team does not have this!)
 
-       msgin = formatmessage(msgin);
+       msgin = formatmessage(source, msgin);
 
     string colorstr;
        if (!IS_PLAYER(source))
@@ -857,8 +863,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                sourcecmsgstr = cmsgstr;
        }
 
-       if(!privatesay)
-       if (!IS_PLAYER(source))
+       if (!privatesay && source && !IS_PLAYER(source))
        {
                if (!intermission_running)
                        if(teamsay || (autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !(warmup_stage || gameover)))
@@ -933,15 +938,14 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                        dedicated_print(msgstr); // send to server console too
                        FOREACH_CLIENT(!IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr));
                }
-               else {
-            if (sourcemsgstr != msgstr) { // trimmed/server fixed message, sent to all players
+               else
+               {
+            if (source) {
                 sprint(source, sourcemsgstr);
                 dedicated_print(msgstr); // send to server console too
-                FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr));
-            } else { // entirely normal message, sent to all players -- bprint sends to server console too.
-                bprint(msgstr);
+                MX_Say(strcat(playername(source), "^7: ", msgin));
             }
-            if (source) MX_Say(strcat(playername(source), "^7: ", msgin));
+            FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr));
         }
        }