+ {
+ f = dl->radius - time * dl->decay;
+ if (cl.time < dl->die && f > 0)
+ {
+ dl->radius = dl->radius - time * dl->decay;
+ cl.num_dlights = i + 1;
+ }
+ else
+ dl->radius = 0;
+ }
+ }
+}
+
+// called after entity relinking
+void CL_UpdateLights(void)
+{
+ int i, j, k, l;
+ dlight_t *dl;
+ float frac, f;
+
+ r_refdef.numlights = 0;
+ if (r_dynamic.integer)
+ {
+ for (i = 0, dl = cl.dlights;i < cl.num_dlights;i++, dl++)
+ {
+ if (dl->radius)
+ {
+ R_RTLight_Update(dl, false);
+ r_refdef.lights[r_refdef.numlights++] = dl;
+ }
+ }
+ }
+
+// light animations
+// 'm' is normal light, 'a' is no light, 'z' is double bright
+ f = cl.time * 10;
+ i = (int)floor(f);
+ frac = f - i;
+ for (j = 0;j < cl.max_lightstyle;j++)
+ {
+ if (!cl.lightstyle || !cl.lightstyle[j].length)
+ {
+ r_refdef.lightstylevalue[j] = 256;
+ continue;
+ }
+ k = i % cl.lightstyle[j].length;
+ l = (i-1) % cl.lightstyle[j].length;
+ k = cl.lightstyle[j].map[k] - 'a';
+ l = cl.lightstyle[j].map[l] - 'a';
+ r_refdef.lightstylevalue[j] = ((k*frac)+(l*(1-frac)))*22;
+ }
+}
+
+void CL_AddQWCTFFlagModel(entity_t *player, int skin)
+{
+ float f;
+ entity_t *flag;
+ matrix4x4_t flagmatrix;
+
+ // this code taken from QuakeWorld
+ f = 14;
+ if (player->render.frame2 >= 29 && player->render.frame2 <= 40)
+ {
+ if (player->render.frame2 >= 29 && player->render.frame2 <= 34)
+ { //axpain
+ if (player->render.frame2 == 29) f = f + 2;
+ else if (player->render.frame2 == 30) f = f + 8;
+ else if (player->render.frame2 == 31) f = f + 12;
+ else if (player->render.frame2 == 32) f = f + 11;
+ else if (player->render.frame2 == 33) f = f + 10;
+ else if (player->render.frame2 == 34) f = f + 4;
+ }
+ else if (player->render.frame2 >= 35 && player->render.frame2 <= 40)
+ { // pain
+ if (player->render.frame2 == 35) f = f + 2;
+ else if (player->render.frame2 == 36) f = f + 10;
+ else if (player->render.frame2 == 37) f = f + 10;
+ else if (player->render.frame2 == 38) f = f + 8;
+ else if (player->render.frame2 == 39) f = f + 4;
+ else if (player->render.frame2 == 40) f = f + 2;
+ }
+ }
+ else if (player->render.frame2 >= 103 && player->render.frame2 <= 118)
+ {
+ if (player->render.frame2 >= 103 && player->render.frame2 <= 104) f = f + 6; //nailattack
+ else if (player->render.frame2 >= 105 && player->render.frame2 <= 106) f = f + 6; //light
+ else if (player->render.frame2 >= 107 && player->render.frame2 <= 112) f = f + 7; //rocketattack
+ else if (player->render.frame2 >= 112 && player->render.frame2 <= 118) f = f + 7; //shotattack
+ }
+ // end of code taken from QuakeWorld
+
+ flag = CL_NewTempEntity();
+ if (!flag)
+ return;
+
+ flag->render.model = cl.model_precache[cl.qw_modelindex_flag];
+ flag->render.skinnum = skin;
+ flag->render.colormap = -1; // no special coloring
+ flag->render.alpha = 1;
+ VectorSet(flag->render.colormod, 1, 1, 1);
+ // attach the flag to the player matrix
+ Matrix4x4_CreateFromQuakeEntity(&flagmatrix, -f, -22, 0, 0, 0, -45, 1);
+ Matrix4x4_Concat(&flag->render.matrix, &player->render.matrix, &flagmatrix);
+ Matrix4x4_Invert_Simple(&flag->render.inversematrix, &flag->render.matrix);
+ R_LerpAnimation(&flag->render);
+ CL_BoundingBoxForEntity(&flag->render);