]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
added EF_DOUBLESIDED (and internally RENDER_NOCULLFACE)
[xonotic/darkplaces.git] / cl_parse.c
index 7223ce10e753ac4b58a64fcc257526210ee0faf4..8ca0b33688022bf7b946c05b70ea1d868b3cd425 100644 (file)
@@ -844,7 +844,7 @@ void CL_ParseBeam (model_t *m, int lightning)
 {
        int i, ent;
        vec3_t start, end;
-       beam_t *b;
+       beam_t *b = NULL;
 
        ent = (unsigned short) MSG_ReadShort ();
        MSG_ReadVector(start, cl.protocol);
@@ -860,37 +860,49 @@ void CL_ParseBeam (model_t *m, int lightning)
                CL_ExpandEntities(ent);
 
        // override any beam with the same entity
-       for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+       i = cl_max_beams;
+       if (ent)
+               for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+                       if (b->entity == ent)
+                               break;
+       // if the entity was not found then just replace an unused beam
+       if (i == cl_max_beams)
+               for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+                       if (!b->model || b->endtime < cl.time)
+                               break;
+       if (i < cl_max_beams)
        {
-               if (b->entity == ent && ent)
+               b->entity = ent;
+               b->lightning = lightning;
+               b->model = m;
+               b->endtime = cl.time + 0.2;
+               VectorCopy (start, b->start);
+               VectorCopy (end, b->end);
+               b->relativestartvalid = 0;
+               if (ent && cl_entities[ent].state_current.active)
                {
-                       //b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl_entities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-
-       // find a free beam
-       for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
-       {
-               if (!b->model || b->endtime < cl.time)
-               {
-                       b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl_entities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
+                       entity_state_t *p;
+                       matrix4x4_t matrix, imatrix;
+                       if (ent == cl.viewentity && cl.movement)
+                               p = &cl_entities[b->entity].state_previous;
+                       else
+                               p = &cl_entities[b->entity].state_current;
+                       // not really valid yet, we need to get the orientation now
+                       // (ParseBeam flagged this because it is received before
+                       //  entities are received, by now they have been received)
+                       // note: because players create lightning in their think
+                       // function (which occurs before movement), they actually
+                       // have some lag in it's location, so compare to the
+                       // previous player state, not the latest
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
+                       Matrix4x4_Invert_Simple(&imatrix, &matrix);
+                       Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
+                       Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
+                       b->relativestartvalid = 1;
                }
        }
-       Con_Print("beam list overflow!\n");
+       else
+               Con_Print("beam list overflow!\n");
 }
 
 void CL_ParseTempEntity(void)
@@ -914,7 +926,7 @@ void CL_ParseTempEntity(void)
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
                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_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);
                break;
@@ -924,7 +936,7 @@ void CL_ParseTempEntity(void)
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
                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_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);
                break;
@@ -933,12 +945,14 @@ void CL_ParseTempEntity(void)
                // spike hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               if (cl_particles_bulletimpacts.integer)
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 10);
+               else if (cl_particles_bulletimpacts.integer)
                {
                        CL_SparkShower(pos, vec3_origin, 15, 1);
                        CL_Smoke(pos, vec3_origin, 15);
-                       CL_BulletMark(pos);
                }
+               CL_BulletMark(pos);
                if (rand() % 5)
                        S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
@@ -956,13 +970,14 @@ void CL_ParseTempEntity(void)
                // quad spike hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               // LordHavoc: changed to spark shower
-               if (cl_particles_bulletimpacts.integer)
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 10);
+               else if (cl_particles_bulletimpacts.integer)
                {
                        CL_SparkShower(pos, vec3_origin, 15, 1);
                        CL_Smoke(pos, vec3_origin, 15);
-                       CL_BulletMark(pos);
                }
+               CL_BulletMark(pos);
                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)
@@ -982,13 +997,14 @@ void CL_ParseTempEntity(void)
                // super spike hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               // LordHavoc: changed to dust shower
-               if (cl_particles_bulletimpacts.integer)
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 20);
+               else if (cl_particles_bulletimpacts.integer)
                {
                        CL_SparkShower(pos, vec3_origin, 30, 1);
                        CL_Smoke(pos, vec3_origin, 30);
-                       CL_BulletMark(pos);
                }
+               CL_BulletMark(pos);
                if (rand() % 5)
                        S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
                else
@@ -1006,13 +1022,14 @@ void CL_ParseTempEntity(void)
                // quad super spike hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               // LordHavoc: changed to dust shower
-               if (cl_particles_bulletimpacts.integer)
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 20);
+               else if (cl_particles_bulletimpacts.integer)
                {
                        CL_SparkShower(pos, vec3_origin, 30, 1);
                        CL_Smoke(pos, vec3_origin, 30);
-                       CL_BulletMark(pos);
                }
+               CL_BulletMark(pos);
                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)
@@ -1101,8 +1118,13 @@ void CL_ParseTempEntity(void)
                // bullet hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               CL_SparkShower(pos, vec3_origin, 15, 1);
-               CL_Smoke(pos, vec3_origin, 15);
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 20);
+               else
+               {
+                       CL_SparkShower(pos, vec3_origin, 15, 1);
+                       CL_Smoke(pos, vec3_origin, 15);
+               }
                CL_BulletMark(pos);
                break;
 
@@ -1110,8 +1132,13 @@ void CL_ParseTempEntity(void)
                // quad bullet hitting wall
                MSG_ReadVector(pos, cl.protocol);
                CL_FindNonSolidLocation(pos, pos, 4);
-               CL_SparkShower(pos, vec3_origin, 15, 1);
-               CL_Smoke(pos, vec3_origin, 15);
+               if (cl_particles_quake.integer)
+                       CL_RunParticleEffect(pos, vec3_origin, 0, 20);
+               else
+               {
+                       CL_SparkShower(pos, vec3_origin, 15, 1);
+                       CL_Smoke(pos, vec3_origin, 15);
+               }
                CL_BulletMark(pos);
                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);