]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
got rid of Mod_CheckLoaded, changed how model system restart works to make this work...
[xonotic/darkplaces.git] / cl_parse.c
index 232ae69ae966a550283eeb4a002e53bd470928f3..5933c8639fb24803942c28792bdacfc3c5439bbb 100644 (file)
@@ -29,7 +29,7 @@ char *svc_strings[128] =
        "svc_nop",
        "svc_disconnect",
        "svc_updatestat",
-       "svc_version",          // [long] server version
+       "svc_version",          // [int] server version
        "svc_setview",          // [short] entity number
        "svc_sound",                    // <see code>
        "svc_time",                     // [float] server time
@@ -38,7 +38,7 @@ char *svc_strings[128] =
                                                // the string should be \n terminated
        "svc_setangle",         // [vec3] set the view angle to this absolute value
 
-       "svc_serverinfo",               // [long] version
+       "svc_serverinfo",               // [int] version
                                                // [string] signon string
                                                // [string]..[0]model cache [string]...[0]sounds cache
                                                // [string]..[0]item cache
@@ -280,29 +280,29 @@ Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
 
        case 2:
                MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
+               MSG_WriteString (&cls.message, va("name \"%s\"", cl_name.string));
 
                MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("color %i %i\n", cl_color.integer >> 4, cl_color.integer & 15));
+               MSG_WriteString (&cls.message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
 
                if (cl_pmodel.integer)
                {
                        MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("pmodel %i\n", cl_pmodel.integer));
+                       MSG_WriteString (&cls.message, va("pmodel %i", cl_pmodel.integer));
                }
                if (*cl_playermodel.string)
                {
                        MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("playermodel %s\n", cl_playermodel.string));
+                       MSG_WriteString (&cls.message, va("playermodel %s", cl_playermodel.string));
                }
                if (*cl_playerskin.string)
                {
                        MSG_WriteByte (&cls.message, clc_stringcmd);
-                       MSG_WriteString (&cls.message, va("playerskin %s\n", cl_playerskin.string));
+                       MSG_WriteString (&cls.message, va("playerskin %s", cl_playerskin.string));
                }
 
                MSG_WriteByte (&cls.message, clc_stringcmd);
-               MSG_WriteString (&cls.message, va("rate %i\n", cl_rate.integer));
+               MSG_WriteString (&cls.message, va("rate %i", cl_rate.integer));
 
                MSG_WriteByte (&cls.message, clc_stringcmd);
                MSG_WriteString (&cls.message, "spawn");
@@ -366,7 +366,7 @@ void CL_ParseServerInfo (void)
                Host_Error("Bad maxclients (%u) from server\n", cl.maxclients);
                return;
        }
-       cl.scores = Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
+       cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
 
 // parse gametype
        cl.gametype = MSG_ReadByte ();
@@ -423,11 +423,26 @@ void CL_ParseServerInfo (void)
        Mod_ClearUsed();
        for (i = 1;i < nummodels;i++)
                Mod_FindName(parse_model_precache[i]);
+       // precache any models used by the client (this also marks them used)
+       cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
+       cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
+       cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
+       cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
        Mod_PurgeUnused();
 
        // do the same for sounds
+       // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
        S_ServerSounds (parse_sound_precache, numsounds);
 
+       // precache any sounds used by the client
+       cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
+       cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
+       cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
+       cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
+       cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
+       cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
+       cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
+
        // now we try to load everything that is new
 
        // world model
@@ -460,6 +475,7 @@ void CL_ParseServerInfo (void)
        ent->render.model = cl.worldmodel = cl.model_precache[1];
        ent->render.scale = 1; // some of the renderer still relies on scale
        ent->render.alpha = 1;
+       ent->render.colormap = -1; // no special coloring
        ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
        Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, 0, 0, 0, 0, 0, 0, 1);
        Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
@@ -495,7 +511,6 @@ void CL_ValidateState(entity_state_t *s)
        }
 
        model = cl.model_precache[s->modelindex];
-       Mod_CheckLoaded(model);
        if (model && model->type && s->frame >= model->numframes)
        {
                Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
@@ -825,35 +840,6 @@ void CL_ParseEffect2 (void)
        CL_Effect(org, modelindex, startframe, framecount, framerate);
 }
 
-model_t *cl_model_bolt = NULL;
-model_t *cl_model_bolt2 = NULL;
-model_t *cl_model_bolt3 = NULL;
-model_t *cl_model_beam = NULL;
-
-sfx_t *cl_sfx_wizhit;
-sfx_t *cl_sfx_knighthit;
-sfx_t *cl_sfx_tink1;
-sfx_t *cl_sfx_ric1;
-sfx_t *cl_sfx_ric2;
-sfx_t *cl_sfx_ric3;
-sfx_t *cl_sfx_r_exp3;
-
-/*
-=================
-CL_ParseTEnt
-=================
-*/
-void CL_InitTEnts (void)
-{
-       cl_sfx_wizhit = S_PrecacheSound ("sound/wizard/hit.wav", false, true);
-       cl_sfx_knighthit = S_PrecacheSound ("sound/hknight/hit.wav", false, true);
-       cl_sfx_tink1 = S_PrecacheSound ("sound/weapons/tink1.wav", false, true);
-       cl_sfx_ric1 = S_PrecacheSound ("sound/weapons/ric1.wav", false, true);
-       cl_sfx_ric2 = S_PrecacheSound ("sound/weapons/ric2.wav", false, true);
-       cl_sfx_ric3 = S_PrecacheSound ("sound/weapons/ric3.wav", false, true);
-       cl_sfx_r_exp3 = S_PrecacheSound ("sound/weapons/r_exp3.wav", false, true);
-}
-
 void CL_ParseBeam (model_t *m, int lightning)
 {
        int i, ent;
@@ -876,7 +862,7 @@ void CL_ParseBeam (model_t *m, int lightning)
        // override any beam with the same entity
        for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
        {
-               if (b->entity == ent)
+               if (b->entity == ent && ent)
                {
                        //b->entity = ent;
                        b->lightning = lightning;
@@ -930,7 +916,7 @@ void CL_ParseTempEntity(void)
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 100, 0.12f, 0.50f, 0.12f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                CL_RunParticleEffect(pos, vec3_origin, 20, 30);
-               S_StartSound(-1, 0, cl_sfx_wizhit, pos, 1, 1);
+               S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
                break;
 
        case TE_KNIGHTSPIKE:
@@ -940,7 +926,7 @@ void CL_ParseTempEntity(void)
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 100, 0.50f, 0.30f, 0.10f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                CL_RunParticleEffect(pos, vec3_origin, 226, 20);
-               S_StartSound(-1, 0, cl_sfx_knighthit, pos, 1, 1);
+               S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
                break;
 
        case TE_SPIKE:
@@ -954,16 +940,16 @@ void CL_ParseTempEntity(void)
                        CL_BulletMark(pos);
                }
                if (rand() % 5)
-                       S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
+                       S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
                {
                        rnd = rand() & 3;
                        if (rnd == 1)
-                               S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
                        else if (rnd == 2)
-                               S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
                        else
-                               S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
                }
                break;
        case TE_SPIKEQUAD:
@@ -979,18 +965,17 @@ void CL_ParseTempEntity(void)
                }
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 100, 0.15f, 0.15f, 1.5f, 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
                if (rand() % 5)
-                       S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
+                       S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
                {
                        rnd = rand() & 3;
                        if (rnd == 1)
-                               S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
                        else if (rnd == 2)
-                               S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
                        else
-                               S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
                }
                break;
        case TE_SUPERSPIKE:
@@ -1005,16 +990,16 @@ void CL_ParseTempEntity(void)
                        CL_BulletMark(pos);
                }
                if (rand() % 5)
-                       S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
+                       S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
                {
                        rnd = rand() & 3;
                        if (rnd == 1)
-                               S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
                        else if (rnd == 2)
-                               S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
                        else
-                               S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
                }
                break;
        case TE_SUPERSPIKEQUAD:
@@ -1031,16 +1016,16 @@ void CL_ParseTempEntity(void)
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 100, 0.15f, 0.15f, 1.5f, 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                if (rand() % 5)
-                       S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
+                       S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
                {
                        rnd = rand() & 3;
                        if (rnd == 1)
-                               S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
                        else if (rnd == 2)
-                               S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
                        else
-                               S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
+                               S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
                }
                break;
                // LordHavoc: added for improved blood splatters
@@ -1140,7 +1125,8 @@ void CL_ParseTempEntity(void)
                // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 350, 4.0f, 2.0f, 0.50f, 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_EXPLOSIONQUAD:
@@ -1150,7 +1136,8 @@ void CL_ParseTempEntity(void)
                CL_ParticleExplosion(pos);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 350, 2.5f, 2.0f, 4.0f, 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_EXPLOSION3:
@@ -1163,7 +1150,8 @@ void CL_ParseTempEntity(void)
                color[1] = MSG_ReadCoord(cl.protocol) * (2.0f / 1.0f);
                color[2] = MSG_ReadCoord(cl.protocol) * (2.0f / 1.0f);
                CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_EXPLOSIONRGB:
@@ -1176,7 +1164,8 @@ void CL_ParseTempEntity(void)
                color[2] = MSG_ReadByte() * (2.0f / 255.0f);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_TAREXPLOSION:
@@ -1185,8 +1174,8 @@ void CL_ParseTempEntity(void)
                CL_FindNonSolidLocation(pos, pos, 10);
                CL_BlobExplosion(pos);
 
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 600, 1.6f, 0.8f, 2.0f, 1200, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                break;
@@ -1219,31 +1208,23 @@ void CL_ParseTempEntity(void)
 
        case TE_LIGHTNING1:
                // lightning bolts
-               if (!cl_model_bolt)
-                       cl_model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
-               CL_ParseBeam(cl_model_bolt, true);
+               CL_ParseBeam(cl.model_bolt, true);
                break;
 
        case TE_LIGHTNING2:
                // lightning bolts
-               if (!cl_model_bolt2)
-                       cl_model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
-               CL_ParseBeam(cl_model_bolt2, true);
+               CL_ParseBeam(cl.model_bolt2, true);
                break;
 
        case TE_LIGHTNING3:
                // lightning bolts
-               if (!cl_model_bolt3)
-                       cl_model_bolt3 = Mod_ForName("progs/bolt3.mdl", true, false, false);
-               CL_ParseBeam(cl_model_bolt3, false);
+               CL_ParseBeam(cl.model_bolt3, false);
                break;
 
 // PGM 01/21/97
        case TE_BEAM:
                // grappling hook beam
-               if (!cl_model_beam)
-                       cl_model_beam = Mod_ForName("progs/beam.mdl", true, false, false);
-               CL_ParseBeam(cl_model_beam, false);
+               CL_ParseBeam(cl.model_beam, false);
                break;
 // PGM 01/21/97
 
@@ -1277,7 +1258,8 @@ void CL_ParseTempEntity(void)
                color[2] = tempcolor[2] * (2.0f / 255.0f);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_TEI_G3:
@@ -1301,7 +1283,8 @@ void CL_ParseTempEntity(void)
                CL_ParticleExplosion(pos);
                Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
                CL_AllocDlight(NULL, &tempmatrix, 500, 2.5f, 2.0f, 1.0f, 500, 9999, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
-               S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
+               if (gamemode != GAME_NEXUIZ)
+                       S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
                break;
 
        case TE_TEI_PLASMAHIT:
@@ -1506,7 +1489,7 @@ void CL_ParseServerMessage(void)
                                Host_Error ("svc_lightstyle >= MAX_LIGHTSTYLES");
                        strlcpy (cl_lightstyle[i].map,  MSG_ReadString(), sizeof (cl_lightstyle[i].map));
                        cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
-                       cl_lightstyle[i].length = strlen(cl_lightstyle[i].map);
+                       cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
                        break;
 
                case svc_sound: