Commits

wifiman committed ca8ba49

Added cl_railtrail_{alpha,diameter,fade} cvars.

Comments (0)

Files changed (3)

 static cvar_t	*cl_autorecord_timestamp_format;
 
 cvar_t	*cl_railtrail;
+cvar_t	*cl_railtrail_alpha;
+cvar_t	*cl_railtrail_diameter;
+cvar_t	*cl_railtrail_fade;
 cvar_t	*cl_test = &uninitialized_cvar;
 cvar_t	*cl_test2;
 cvar_t	*cl_test3;
 
 	cl_railtrail = Cvar_Get ("cl_railtrail", "0", 0);
 	cl_railtrail->changed = _railtrail_changed;
+	cl_railtrail_alpha = Cvar_Get ("cl_railtrail_alpha", "0.3", 0);
+	cl_railtrail_diameter = Cvar_Get ("cl_railtrail_diameter", "4", 0);
+	cl_railtrail_fade = Cvar_Get ("cl_railtrail_fade", "-0.1", 0);
 
 	//misc for testing
 	cl_test = Cvar_Get ("cl_test", "0", 0);
 CL_ParseLaser
 =================
 */
-void CL_ParseLaser (int colors, vec3_t start, vec3_t end)
+void CL_ParseLaser (int colors, vec3_t start, vec3_t end, qboolean railtrail)
 {
 	laser_t	*l;
 	int		i;
 			l->ent.flags = RF_TRANSLUCENT | RF_BEAM;
 			FastVectorCopy (*start, l->ent.origin);
 			FastVectorCopy (*end, l->ent.oldorigin);
-			l->ent.alpha = 0.30f;
+			if (railtrail)
+			{
+				l->ent.alpha = cl_railtrail_fade->value > 0.0f ? cl_railtrail_alpha->value / (cl_railtrail_fade->value * -1000) : cl_railtrail_alpha->value;
+				l->ent.frame = cl_railtrail_diameter->intvalue;
+			}
+			else
+			{
+				l->ent.alpha = 0.30f;
+				l->ent.frame = 4;
+			}
 			l->ent.skinnum = (colors >> ((randomMT() % 4)*8)) & 0xff;
 			l->ent.model = NULL;
-			l->ent.frame = 4;
-			l->endtime = cl.time + 100;
+			l->endtime = cl.time + (railtrail ? fabs (cl_railtrail_fade->value) * 1000 : 100);
 			return;
 		}
 	}
 				CL_RailTrail (pos, pos2, 179);
 				break;
 			case 1:
-				CL_ParseLaser (0xf2f2f0f0, pos, pos2);
+				CL_ParseLaser (0xf2f2f0f0, pos, pos2, qtrue);
 				break;
 
 			case 2:
-				CL_ParseLaser (0xd0d1d2d3, pos, pos2);
+				CL_ParseLaser (0xd0d1d2d3, pos, pos2, qtrue);
 				break;
 
 			case 3:
-				CL_ParseLaser (0xf3f3f1f1, pos, pos2);
+				CL_ParseLaser (0xf3f3f1f1, pos, pos2, qtrue);
 				break;
 
 			case 4:
-				CL_ParseLaser (0xdcdddedf, pos, pos2);
+				CL_ParseLaser (0xdcdddedf, pos, pos2, qtrue);
 				break;
 
 			case 5:
-				CL_ParseLaser (0xe0e1e2e3, pos, pos2);
+				CL_ParseLaser (0xe0e1e2e3, pos, pos2, qtrue);
 				break;
 			default:
 				CL_RailTrail (pos, pos2, (byte)(cl_railtrail->intvalue - 6));
 			Com_Error (ERR_DROP, "CL_ParseTEnt: Insufficient bytes for TE_BFG_LASER");
 		MSG_ReadPos (&net_message, pos);
 		MSG_ReadPos (&net_message, pos2);
-		CL_ParseLaser (0xd0d1d2d3, pos, pos2);
+		CL_ParseLaser (0xd0d1d2d3, pos, pos2, qfalse);
 		break;
 
 	case TE_BUBBLETRAIL:
 
 	for (i=0, l=cl_lasers ; i< MAX_LASERS ; i++, l++)
 	{
-		if (l->endtime >= cl.time)
+		if (l->endtime < cl.time)
+			continue;
+
+		if (l->ent.alpha >= 0.0f)
 			V_AddEntity (&l->ent);
+		else
+		{
+			// ugly hack for cl_railtrail_fade
+			float fadeRate = l->ent.alpha;
+			l->ent.alpha = (l->endtime - cl.time) * -fadeRate;
+			V_AddEntity (&l->ent);
+			l->ent.alpha = fadeRate;
+		}
 	}
 }
 
 //extern	cvar_t	*cl_snaps;
 
 extern	cvar_t	*cl_railtrail;
+extern	cvar_t	*cl_railtrail_alpha;
+extern	cvar_t	*cl_railtrail_diameter;
+extern	cvar_t	*cl_railtrail_fade;
 extern	cvar_t	*cl_async;
 
 extern	cvar_t	*cl_test;