+void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
+{
+ int i;
+ cl_effect_t *e;
+ if (!modelindex) // sanity check
+ return;
+ for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
+ {
+ if (e->active)
+ continue;
+ e->active = true;
+ VectorCopy(org, e->origin);
+ e->modelindex = modelindex;
+ e->starttime = cl.time;
+ e->startframe = startframe;
+ e->endframe = startframe + framecount;
+ e->framerate = framerate;
+
+ e->frame = 0;
+ e->frame1time = cl.time;
+ e->frame2time = cl.time;
+ break;
+ }
+}
+
+static void CL_RelinkEffects()
+{
+ int i, intframe;
+ cl_effect_t *e;
+ entity_t *vis;
+ float frame;
+
+ for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
+ {
+ if (e->active)
+ {
+ frame = (cl.time - e->starttime) * e->framerate + e->startframe;
+ intframe = frame;
+ if (intframe < 0 || intframe >= e->endframe)
+ {
+ e->active = false;
+ memset(e, 0, sizeof(*e));
+ continue;
+ }
+
+ if (intframe != e->frame)
+ {
+ e->frame = intframe;
+ e->frame1time = e->frame2time;
+ e->frame2time = cl.time;
+ }
+
+ if ((vis = CL_NewTempEntity()))
+ {
+ // interpolation stuff
+ vis->render.frame1 = intframe;
+ vis->render.frame2 = intframe + 1;
+ if (vis->render.frame2 >= e->endframe)
+ vis->render.frame2 = -1; // disappear
+ vis->render.framelerp = frame - intframe;
+ vis->render.frame1time = e->frame1time;
+ vis->render.frame2time = e->frame2time;
+
+ // normal stuff
+ VectorCopy(e->origin, vis->render.origin);
+ vis->render.model = cl.model_precache[e->modelindex];
+ vis->render.frame = vis->render.frame2;
+ vis->render.colormap = -1; // no special coloring
+ vis->render.scale = 1;
+ vis->render.alpha = 1;
+ }
+ }
+ }
+}
+