+ else
+ cl.entities_active[i] = false;
+ }
+ }
+
+ ent = &cl.viewent;
+ ent->state_previous = ent->state_current;
+ ent->state_current = defaultstate;
+ ent->state_current.time = cl.time;
+ ent->state_current.number = -1;
+ ent->state_current.active = true;
+ ent->state_current.modelindex = cl.stats[STAT_WEAPON];
+ ent->state_current.frame = cl.stats[STAT_WEAPONFRAME];
+ ent->state_current.flags = RENDER_VIEWMODEL;
+ if ((cl.stats[STAT_HEALTH] <= 0 && cl_deathnoviewmodel.integer) || cl.intermission)
+ ent->state_current.modelindex = 0;
+ else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
+ {
+ if (gamemode == GAME_TRANSFUSION)
+ ent->state_current.alpha = 128;
+ else
+ ent->state_current.modelindex = 0;
+ }
+ ent->state_current.alpha = cl.entities[cl.viewentity].state_current.alpha;
+ ent->state_current.effects = EF_NOSHADOW | (cl.entities[cl.viewentity].state_current.effects & (EF_ADDITIVE | EF_REFLECTIVE | EF_FULLBRIGHT | EF_NODEPTHTEST));
+
+ // reset animation interpolation on weaponmodel if model changed
+ if (ent->state_previous.modelindex != ent->state_current.modelindex)
+ {
+ ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
+ ent->render.frame1time = ent->render.frame2time = cl.time;
+ ent->render.framelerp = 1;
+ }
+ CL_UpdateNetworkEntity(ent, 32);
+}
+
+// note this is a recursive function, but it can never get in a runaway loop (because of the delayedlink flags)
+void CL_LinkNetworkEntity(entity_t *e)
+{
+ effectnameindex_t trailtype;
+ vec3_t origin;
+ vec3_t dlightcolor;
+ vec_t dlightradius;
+
+ // skip inactive entities and world
+ if (!e->state_current.active || e == cl.entities)
+ return;
+ if (e->render.flags & RENDER_VIEWMODEL && !e->state_current.tagentity)
+ {
+ if (!r_drawviewmodel.integer || chase_active.integer || r_refdef.envmap)
+ return;
+ }
+ else
+ {
+ // if the tag entity is currently impossible, skip it
+ if (e->state_current.tagentity >= cl.num_entities)
+ return;
+ // if the tag entity is inactive, skip it
+ if (!cl.entities[e->state_current.tagentity].state_current.active)
+ return;
+ }
+
+ // create entity dlights associated with this entity
+ if (e->render.model && e->render.model->soundfromcenter)
+ {
+ // bmodels are treated specially since their origin is usually '0 0 0'
+ vec3_t o;
+ VectorMAM(0.5f, e->render.model->normalmins, 0.5f, e->render.model->normalmaxs, o);
+ Matrix4x4_Transform(&e->render.matrix, o, origin);
+ }
+ else
+ Matrix4x4_OriginFromMatrix(&e->render.matrix, origin);
+ trailtype = EFFECT_NONE;
+ dlightradius = 0;
+ dlightcolor[0] = 0;
+ dlightcolor[1] = 0;
+ dlightcolor[2] = 0;
+ // LordHavoc: if the entity has no effects, don't check each
+ if (e->render.effects & (EF_BRIGHTFIELD | EF_DIMLIGHT | EF_BRIGHTLIGHT | EF_RED | EF_BLUE | EF_FLAME | EF_STARDUST))
+ {
+ if (e->render.effects & EF_BRIGHTFIELD)
+ {
+ if (gamemode == GAME_NEXUIZ)
+ trailtype = EFFECT_TR_NEXUIZPLASMA;