]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
-Fixed the stupid bug introduced by my NEX_PLAYERMODEL/NEX_PLAYERSKIN commit.
[xonotic/darkplaces.git] / sv_main.c
index 996aedeb2cc3674092601abd8a71cf9c85df7ef4..afdd8c7965a7843c9c1330e4d78963346999c35c 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -877,11 +877,6 @@ void SV_WriteClientdataToMessage (client_t *client, edict_t *ent, sizebuf_t *msg
                VectorCopy(val->vector, punchvector);
 
        weaponmodelindex = SV_ModelIndex(PR_GetString(ent->v->weaponmodel), 1);
-       if (!weaponmodelindex)
-       {
-               Con_DPrintf("weaponmodel \"%s\" not precached\n", PR_GetString(ent->v->weaponmodel));
-               weaponmodelindex = 0;
-       }
 
        viewzoom = 255;
        if ((val = GETEDICTFIELDVALUE(ent, eval_viewzoom)))
@@ -1124,6 +1119,8 @@ void SV_UpdateToReliableMessages (void)
        client_t *client;
        eval_t *val;
        char *name;
+       char *model;
+       char *skin;
 
 // check for changes to be sent over the reliable streams
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
@@ -1162,6 +1159,26 @@ void SV_UpdateToReliableMessages (void)
                        MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
                }
 
+               // NEXUIZ_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
+               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;
                if (host_client->old_frags != host_client->frags)
@@ -1314,30 +1331,22 @@ int SV_ModelIndex(char *s, int precachemode)
                {
                        if (precachemode)
                        {
-                               if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
+                               if (sv.state != ss_loading && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5))
                                {
-                                       // not able to precache during game
-                                       if (precachemode == 2 && sv.state != ss_loading)
-                                       {
-                                               Con_Printf("SV_ModelIndex(\"%s\"): precache_model can only be done in spawn functions\n", filename);
-                                               return 0;
-                                       }
+                                       Con_Printf("SV_ModelIndex(\"%s\"): precache_model can only be done in spawn functions\n", filename);
+                                       return 0;
                                }
-                               else
+                               if (precachemode == 1)
+                                       Con_Printf("SV_ModelIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
+                               strlcpy(sv.model_precache[i], filename, sizeof(sv.model_precache[i]));
+                               sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, false);
+                               if (sv.protocol == PROTOCOL_DARKPLACES6)
                                {
-                                       // able to precache during game
-                                       if (precachemode == 1)
-                                               Con_Printf("SV_ModelIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
-                                       strlcpy(sv.model_precache[i], filename, sizeof(sv.model_precache[i]));
-                                       sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, false);
-                                       if (sv.state != ss_loading)
-                                       {
-                                               MSG_WriteByte(&sv.reliable_datagram, svc_precache);
-                                               MSG_WriteShort(&sv.reliable_datagram, i);
-                                               MSG_WriteString(&sv.reliable_datagram, filename);
-                                       }
-                                       return i;
+                                       MSG_WriteByte(&sv.reliable_datagram, svc_precache);
+                                       MSG_WriteShort(&sv.reliable_datagram, i);
+                                       MSG_WriteString(&sv.reliable_datagram, filename);
                                }
+                               return i;
                        }
                        Con_Printf("SV_ModelIndex(\"%s\"): not precached\n", filename);
                        return 0;
@@ -1345,10 +1354,7 @@ int SV_ModelIndex(char *s, int precachemode)
                if (!strcmp(sv.model_precache[i], filename))
                        return i;
        }
-       if (precachemode)
-               Con_Printf("SV_ModelIndex(\"%s\"): i == MAX_MODELS\n", filename);
-       else
-               Con_Printf("SV_ModelIndex(\"%s\"): not precached\n", filename);
+       Con_Printf("SV_ModelIndex(\"%s\"): i (%i) == MAX_MODELS (%i)\n", filename, i, MAX_MODELS);
        return 0;
 }
 
@@ -1364,33 +1370,31 @@ int SV_SoundIndex(char *s, int precachemode)
        char filename[MAX_QPATH];
        if (!s || !*s)
                return 0;
+       // testing
+       //if (precachemode == 2)
+       //      return 0;
        strlcpy(filename, s, sizeof(filename));
        for (i = 1;i < limit;i++)
        {
                if (!sv.sound_precache[i][0])
                {
-                       if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
+                       if (precachemode)
                        {
-                               // not able to precache during game
-                               if (precachemode == 2 && sv.state != ss_loading)
+                               if (sv.state != ss_loading && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5))
                                {
                                        Con_Printf("SV_SoundIndex(\"%s\"): precache_sound can only be done in spawn functions\n", filename);
                                        return 0;
                                }
-                       }
-                       else
-                       {
-                               // able to precache during game
-                               if (precachemode)
+                               if (precachemode == 1)
+                                       Con_Printf("SV_SoundIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
+                               strlcpy(sv.sound_precache[i], filename, sizeof(sv.sound_precache[i]));
+                               if (sv.protocol == PROTOCOL_DARKPLACES6)
                                {
-                                       if (precachemode == 1)
-                                               Con_Printf("SV_SoundIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
-                                       strlcpy(sv.sound_precache[i], filename, sizeof(sv.sound_precache[i]));
                                        MSG_WriteByte(&sv.reliable_datagram, svc_precache);
                                        MSG_WriteShort(&sv.reliable_datagram, i + 32768);
                                        MSG_WriteString(&sv.reliable_datagram, filename);
-                                       return i;
                                }
+                               return i;
                        }
                        Con_Printf("SV_SoundIndex(\"%s\"): not precached\n", filename);
                        return 0;
@@ -1398,10 +1402,7 @@ int SV_SoundIndex(char *s, int precachemode)
                if (!strcmp(sv.sound_precache[i], filename))
                        return i;
        }
-       if (precachemode)
-               Con_Printf("SV_SoundIndex(\"%s\"): i == MAX_SOUNDS\n", filename);
-       else
-               Con_Printf("SV_SoundIndex(\"%s\"): not precached\n", filename);
+       Con_Printf("SV_SoundIndex(\"%s\"): i (%i) == MAX_SOUNDS (%i)\n", filename, i, MAX_SOUNDS);
        return 0;
 }