]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port scorekeeper to ClientState
authorMario <mario@smbclan.net>
Mon, 17 Jul 2017 23:35:38 +0000 (09:35 +1000)
committerMario <mario@smbclan.net>
Mon, 17 Jul 2017 23:35:38 +0000 (09:35 +1000)
qcsrc/common/state.qc
qcsrc/server/client.qh
qcsrc/server/scores.qc

index 9774bd5b9eb1a8a5bc7ba25eaf873e983174e2b4..cbf9eff72a8f68ad2f9e6da25d03539f1e2f4b32 100644 (file)
@@ -70,6 +70,7 @@ void PlayerScore_Detach(entity this);
 void ClientState_detach(entity this)
 {
     accuracy_free(this); // TODO: needs to be before CS() is deleted!
+    PlayerScore_Detach(this); // what ^they^ said
        delete(CS(this));
        this._cs = NULL;
 
@@ -82,5 +83,4 @@ void ClientState_detach(entity this)
     playerdemo_shutdown(this);
     entcs_detach(this);
     ClientData_Detach(this);
-    PlayerScore_Detach(this);
 }
index d24bc4aad6b454a4d60dd428030479681b89cbb7..097ba382bf93e35c881df5069c89dc0ef4feb66f 100644 (file)
@@ -103,6 +103,7 @@ CLASS(Client, Object)
     ATTRIB(Client, model_randomizer, float, this.model_randomizer);
     ATTRIB(Client, accuracy, entity, this.accuracy);
     ATTRIB(Client, hasweapon_complain_spam, float, this.hasweapon_complain_spam);
+    ATTRIB(Client, scorekeeper, entity, this.scorekeeper);
 
     METHOD(Client, m_unwind, bool(Client this));
 
index 6bfb09cc97a2978be06048928dbf4366a675a6c2..042d450ec98e9a74c41e92d1c54a42230fc71770 100644 (file)
@@ -262,7 +262,7 @@ float PlayerScore_Clear(entity player)
 
        if(MUTATOR_CALLHOOK(ForbidPlayerScore_Clear)) return 0;
 
-       sk = player.scorekeeper;
+       sk = CS(player).scorekeeper;
        FOREACH(Scores, true, {
                if(sk.(scores(it)) != 0)
                        if(scores_label(it) != "")
@@ -279,7 +279,7 @@ void Score_ClearAll()
        entity sk;
        float t;
        FOREACH_CLIENTSLOT(true, {
-               sk = it.scorekeeper;
+               sk = CS(it).scorekeeper;
                if (!sk) continue;
                FOREACH(Scores, true, {
                        if(sk.(scores(it)) != 0)
@@ -306,20 +306,20 @@ void Score_ClearAll()
 
 void PlayerScore_Attach(entity player)
 {
-       if(player.scorekeeper)
+       if(CS(player).scorekeeper)
                error("player already has a scorekeeper");
        entity sk = new_pure(scorekeeper);
        sk.owner = player;
        Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
-       player.scorekeeper = sk;
+       CS(player).scorekeeper = sk;
 }
 
 void PlayerScore_Detach(entity player)
 {
-       if(!player.scorekeeper)
+       if(!CS(player).scorekeeper)
                error("player has no scorekeeper");
-       delete(player.scorekeeper);
-       player.scorekeeper = NULL;
+       delete(CS(player).scorekeeper);
+       CS(player).scorekeeper = NULL;
 }
 
 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
@@ -332,7 +332,7 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
                score = 0;
 
        if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
-       entity s = player.scorekeeper;
+       entity s = CS(player).scorekeeper;
        if(!s)
        {
                if(game_stopped)
@@ -455,7 +455,7 @@ void WinningConditionHelper(entity this)
                winnerscorekeeper = NULL;
                secondscorekeeper = NULL;
                FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
-                       sk = it.scorekeeper;
+                       sk = CS(it).scorekeeper;
                        c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
                        if(c < 0)
                        {
@@ -589,7 +589,7 @@ string GetPlayerScoreString(entity pl, float shortString)
         });
                out = substring(out, 0, strlen(out) - 1);
        }
-       else if((sk = pl.scorekeeper))
+       else if((sk = CS(pl).scorekeeper))
        {
                FOREACH(Scores, true, {
                        if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
@@ -684,7 +684,7 @@ float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict)
                        return 0;
        }
 
-       return PlayerScore_Compare(p1.scorekeeper, p2.scorekeeper, strict);
+       return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict);
 }
 
 entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators)
@@ -696,7 +696,7 @@ entity PlayerScore_Sort(.float field, float teams, float strict, float nospectat
 
        FOREACH_CLIENT(true, LAMBDA(it.(field) = 0));
 
-       FOREACH_CLIENT(it.scorekeeper,
+       FOREACH_CLIENT(CS(it).scorekeeper,
        {
                if(nospectators)
                        if(it.frags == FRAGS_SPECTATOR)
@@ -828,7 +828,7 @@ void Score_NicePrint_Player(entity to, entity p, float w)
        float fl, sc;
        s = "  ";
 
-       sk = p.scorekeeper;
+       sk = CS(p).scorekeeper;
 
        s = strcat(s, playername(p, false));
        for (;;)
@@ -904,7 +904,7 @@ void Score_NicePrint(entity to)
 
 void PlayerScore_PlayerStats(entity p)
 {
-       entity s = p.scorekeeper;
+       entity s = CS(p).scorekeeper;
        FOREACH(Scores, true, {
                if(s.(scores(it)) != 0)
                        if(scores_label(it) != "")