-Fixed the stupid bug introduced by my NEX_PLAYERMODEL/NEX_PLAYERSKIN commit.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 13 Dec 2004 16:20:15 +0000 (16:20 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 13 Dec 2004 16:20:15 +0000 (16:20 +0000)
-Hopefully playermodel and playerskin work still now.

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

host_cmd.c
pr_edict.c
progdefs.h
progs.h
sv_main.c
sv_user.c

index 6272c14..882d7e7 100644 (file)
@@ -812,7 +812,8 @@ void Host_Playermodel_f (void)
 
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
-       host_client->edict->v->playermodel = PR_SetString(host_client->playermodel);
+       if( eval_playermodel )
+               GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(host_client->playermodel);
        if (strcmp(host_client->old_model, host_client->playermodel))
        {
                if (host_client->spawned)
@@ -872,7 +873,8 @@ void Host_Playerskin_f (void)
 
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
-       host_client->edict->v->playerskin = PR_SetString(host_client->playerskin);
+       if( eval_playerskin )
+               GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(host_client->playerskin);
        if (strcmp(host_client->old_skin, host_client->playerskin))
        {
                if (host_client->spawned)
index 884bff1..6268827 100644 (file)
@@ -134,6 +134,8 @@ int eval_cursor_trace_start;
 int eval_cursor_trace_endpos;
 int eval_cursor_trace_ent;
 int eval_colormod;
+int eval_playermodel;
+int eval_playerskin;
 
 mfunction_t *SV_PlayerPhysicsQC;
 mfunction_t *EndFrameQC;
@@ -200,6 +202,8 @@ void FindEdictFieldOffsets(void)
        eval_cursor_trace_endpos = FindFieldOffset("cursor_trace_endpos");
        eval_cursor_trace_ent = FindFieldOffset("cursor_trace_ent");
        eval_colormod = FindFieldOffset("colormod");
+       eval_playermodel = FindFieldOffset("playermodel");
+       eval_playerskin = FindFieldOffset("playerskin");
 
        // LordHavoc: allowing QuakeC to override the player movement code
        SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics");
@@ -236,8 +240,10 @@ void ED_ClearEdict (edict_t *e)
                if ((val = GETEDICTFIELDVALUE(e, eval_clientcolors)))
                        val->_float = svs.clients[num].colors;
                // NEXUIZ_PLAYERMODEL and NEXUIZ_PLAYERSKIN
-               e->v->playermodel = PR_SetString(svs.clients[num].playermodel);
-               e->v->playerskin = PR_SetString(svs.clients[num].playerskin);
+               if( eval_playermodel )
+                       GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(svs.clients[num].playermodel);
+               if( eval_playerskin )
+                       GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(svs.clients[num].playerskin);
        }
 }
 
@@ -1002,7 +1008,7 @@ qboolean ED_ParseEpair(edict_t *ent, ddef_t *key, const char *s)
                        Con_DPrintf("ED_ParseEpair: Can't find field %s\n", s);
                        return false;
                }
-               //val->_int = G_INT(def->ofs); AK Please check this - seems to be an org. quake bug
+               //val->_int = G_INT(def->ofs); // AK Please check this - seems to be an org. quake bug
                val->_int = def->ofs;
                break;
 
index 82b589d..14e2e91 100644 (file)
@@ -161,8 +161,6 @@ typedef struct
        string_t        noise1;
        string_t        noise2;
        string_t        noise3;
-       string_t        playermodel;
-       string_t        playerskin;
 } entvars_t;
 
 #define PROGHEADER_CRC 5927
diff --git a/progs.h b/progs.h
index 8e717d3..5e01bd8 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -131,6 +131,8 @@ extern int eval_cursor_trace_start;
 extern int eval_cursor_trace_endpos;
 extern int eval_cursor_trace_ent;
 extern int eval_colormod;
+extern int eval_playermodel;
+extern int eval_playerskin;
 
 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
 
index 48c3b91..afdd8c7 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1160,20 +1160,24 @@ void SV_UpdateToReliableMessages (void)
                }
 
                // NEXUIZ_PLAYERMODEL
-               model = PR_GetString(host_client->edict->v->playermodel);
-               if (model == NULL)
-                       model = "";
-               // always point the string back at host_client->name to keep it safe
-               strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel));
-               host_client->edict->v->playermodel = PR_SetString(host_client->playermodel);
+               if( eval_playermodel ) {
+                       model = PR_GetString(GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string);
+                       if (model == NULL)
+                               model = "";
+                       // always point the string back at host_client->name to keep it safe
+                       strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel));
+                       GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(host_client->playermodel);
+               }
 
                // NEXUIZ_PLAYERSKIN
-               skin = PR_GetString(host_client->edict->v->playerskin);
-               if (skin == NULL)
-                       skin = "";
-               // always point the string back at host_client->name to keep it safe
-               strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin));
-               host_client->edict->v->playerskin = PR_SetString(host_client->playerskin);
+               if( eval_playerskin ) {
+                       skin = PR_GetString(GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string);
+                       if (skin == NULL)
+                               skin = "";
+                       // always point the string back at host_client->name to keep it safe
+                       strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin));
+                       GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(host_client->playerskin);
+               }
 
                // frags
                host_client->frags = (int)host_client->edict->v->frags;
index b870bf5..7015dd5 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -794,7 +794,7 @@ void SV_ReadClientMessage(void)
                         || strncasecmp(s, "pmodel", 6) == 0
                         || strncasecmp(s, "rate", 4) == 0
                         || strncasecmp(s, "playermodel", 11) == 0
-                        || strncasecmp(s, "playerskin", 10) == 00
+                        || strncasecmp(s, "playerskin", 10) == 0
                         || (gamemode == GAME_NEHAHRA && (strncasecmp(s, "max", 3) == 0 || strncasecmp(s, "monster", 7) == 0 || strncasecmp(s, "scrag", 5) == 0 || strncasecmp(s, "gimme", 5) == 0 || strncasecmp(s, "wraith", 6) == 0))
                         || (gamemode != GAME_NEHAHRA && (strncasecmp(s, "god", 3) == 0 || strncasecmp(s, "notarget", 8) == 0 || strncasecmp(s, "fly", 3) == 0 || strncasecmp(s, "give", 4) == 0 || strncasecmp(s, "noclip", 6) == 0)))
                                Cmd_ExecuteString (s, src_client);