+ else if (e->render.model->flags & EF_TRACER3)
+ trailtype = EFFECT_TR_VORESPIKE;
+ }
+ // LordHavoc: customizable glow
+ if (e->state_current.glowsize)
+ {
+ // * 4 for the expansion from 0-255 to 0-1023 range,
+ // / 255 to scale down byte colors
+ dlightradius = max(dlightradius, e->state_current.glowsize * 4);
+ VectorMA(dlightcolor, (1.0f / 255.0f), (unsigned char *)&palette_complete[e->state_current.glowcolor], dlightcolor);
+ }
+ // make the glow dlight
+ if (dlightradius > 0 && (dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) && !(e->render.flags & RENDER_VIEWMODEL))
+ {
+ //dlightmatrix = e->render.matrix;
+ // hack to make glowing player light shine on their gun
+ //if (e->state_current.number == cl.viewentity/* && !chase_active.integer*/)
+ // Matrix4x4_AdjustOrigin(&dlightmatrix, 0, 0, 30);
+ CL_AllocDlight(&e->render, &e->render.matrix, dlightradius, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ }
+ // custom rtlight
+ if (e->state_current.lightpflags & PFLAGS_FULLDYNAMIC)
+ {
+ float light[4];
+ VectorScale(e->state_current.light, (1.0f / 256.0f), light);
+ light[3] = e->state_current.light[3];
+ if (light[0] == 0 && light[1] == 0 && light[2] == 0)
+ VectorSet(light, 1, 1, 1);
+ if (light[3] == 0)
+ light[3] = 350;
+ // FIXME: add ambient/diffuse/specular scales as an extension ontop of TENEBRAE_GFX_DLIGHTS?
+ CL_AllocDlight(&e->render, &e->render.matrix, light[3], light[0], light[1], light[2], 0, 0, e->state_current.skin, e->state_current.lightstyle, !(e->state_current.lightpflags & PFLAGS_NOSHADOW), (e->state_current.lightpflags & PFLAGS_CORONA) != 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ }
+ // do trails
+ if (e->render.flags & RENDER_GLOWTRAIL)
+ trailtype = EFFECT_TR_GLOWTRAIL;
+ if (trailtype)
+ {
+ float len;
+ vec3_t vel;
+ VectorSubtract(e->state_current.origin, e->state_previous.origin, vel);
+ len = e->state_current.time - e->state_previous.time;
+ if (len > 0)
+ len = 1.0f / len;
+ VectorScale(vel, len, vel);
+ CL_ParticleEffect(trailtype, 1, e->persistent.trail_origin, origin, vel, vel, e, e->state_current.glowcolor);
+ }
+ VectorCopy(origin, e->persistent.trail_origin);
+ // tenebrae's sprites are all additive mode (weird)
+ if (gamemode == GAME_TENEBRAE && e->render.model && e->render.model->type == mod_sprite)
+ e->render.effects |= EF_ADDITIVE;
+ // player model is only shown with chase_active on
+ if (e->state_current.number == cl.viewentity)
+ e->render.flags |= RENDER_EXTERIORMODEL;
+ // transparent stuff can't be lit during the opaque stage
+ if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
+ e->render.flags |= RENDER_TRANSPARENT;
+ // double sided rendering mode causes backfaces to be visible
+ // (mostly useful on transparent stuff)
+ if (e->render.effects & EF_DOUBLESIDED)
+ e->render.flags |= RENDER_NOCULLFACE;
+ // either fullbright or lit
+ if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
+ e->render.flags |= RENDER_LIGHT;
+ // hide player shadow during intermission or nehahra movie
+ if (!(e->render.effects & EF_NOSHADOW)
+ && !(e->render.flags & (RENDER_VIEWMODEL | RENDER_TRANSPARENT))
+ && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
+ e->render.flags |= RENDER_SHADOW;
+ if (e->render.model && e->render.model->name[0] == '*' && e->render.model->TraceBox)
+ cl.brushmodel_entities[cl.num_brushmodel_entities++] = e->state_current.number;
+}
+
+
+/*
+===============
+CL_UpdateEntities
+===============
+*/
+void CL_UpdateEntities(void)
+{
+ entity_t *ent;
+ int i;
+
+// start on the entity after the world
+ for (i = 1;i < cl.num_entities;i++)
+ {
+ if (cl.entities_active[i])