]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
when spectating in nexuiz, use the current viewentity for scoreboard
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 14 Jun 2007 00:37:15 +0000 (00:37 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 14 Jun 2007 00:37:15 +0000 (00:37 +0000)
information rather than the real player entity
(renamed cl.playerentity to cl.realplayerentity and made playerentity
update whenever viewentity is set to a valid client entity)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7412 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
client.h

index 5f41466ea59789df7e1fe5781f73862df16ae57f..31afbd1f61d8b25efb347c9085a95932f6f4e514 100644 (file)
@@ -1440,7 +1440,7 @@ void CL_ParseServerInfo (void)
                i = MSG_ReadByte();
                // cl.qw_spectator is an unneeded flag, cl.scores[cl.playerentity].qw_spectator works better (it can be updated by the server during the game)
                //cl.qw_spectator = (i & 128) != 0;
-               cl.playerentity = cl.viewentity = (i & 127) + 1;
+               cl.realplayerentity = cl.playerentity = cl.viewentity = (i & 127) + 1;
                cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
 
                // get the full level name
@@ -3493,7 +3493,10 @@ void CL_ParseServerMessage(void)
                                if (cl.viewentity >= cl.max_entities)
                                        CL_ExpandEntities(cl.viewentity);
                                // LordHavoc: assume first setview recieved is the real player entity
-                               if (!cl.playerentity)
+                               if (!cl.realplayerentity)
+                                       cl.realplayerentity = cl.viewentity;
+                               // update cl.playerentity to this one if it is a valid player
+                               if (cl.viewentity >= 1 && cl.viewentity <= cl.maxclients)
                                        cl.playerentity = cl.viewentity;
                                break;
 
index d44d2d034f7d2b2abdbbbd5a33fcab9210f202d5..52a9ce064d28248f6f998da9fd3d106f205f4297 100644 (file)
--- a/client.h
+++ b/client.h
@@ -819,6 +819,11 @@ typedef struct client_state_s
        int viewentity;
        // the real player entity (normally same as viewentity,
        // different than viewentity if mod uses chasecam or other tricks)
+       int realplayerentity;
+       // this is updated to match cl.viewentity whenever it is in the clients
+       // range, basically this is used in preference to cl.realplayerentity for
+       // most purposes because when spectating another player it should show
+       // their information rather than yours
        int playerentity;
        // max players that can be in this game
        int maxclients;
@@ -943,7 +948,7 @@ typedef struct client_state_s
        int qw_teamplay;
 
        // unused: indicates whether the player is spectating
-       // use cl.scores[cl.playerentity].qw_spectator instead
+       // use cl.scores[cl.playerentity-1].qw_spectator instead
        //qboolean qw_spectator;
 
        // movement parameters for client prediction