[nexuiz-commits] r6502 - trunk/data/qcsrc/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Apr 16 06:03:37 EDT 2009


Author: div0
Date: 2009-04-16 06:03:36 -0400 (Thu, 16 Apr 2009)
New Revision: 6502

Modified:
   trunk/data/qcsrc/client/particles.qc
Log:
bgmscript: fix rewinding at end of music


Modified: trunk/data/qcsrc/client/particles.qc
===================================================================
--- trunk/data/qcsrc/client/particles.qc	2009-04-16 09:58:22 UTC (rev 6501)
+++ trunk/data/qcsrc/client/particles.qc	2009-04-16 10:03:36 UTC (rev 6502)
@@ -78,7 +78,8 @@
 .float scriptline0;
 .float scriptvelocity;
 .float scripttime;
-.float switchedon;
+.float scriptstate;
+.float just_toggled;
 void PointparticlesScript_InitEntity(entity e)
 {
 	if(e.bgmscript != "")
@@ -115,7 +116,7 @@
 	if(cvar("bgmvolume") <= 0)
 		return 0.5;
 
-	e.switchedon = FALSE;
+	e.just_toggled = FALSE;
 
 	t = gettime(GETTIME_CDTRACK);
 
@@ -136,25 +137,19 @@
 		// time code reached!
 		e.scriptvelocity = stof(argv(2));
 		if(e.scriptvelocity > 0)
-		{
-			e.switchedon = TRUE;
-			e.scripttime = stof(argv(1));
-		}
+			e.just_toggled = e.scriptstate = TRUE;
 		else
-			e.scripttime = 0;
+			e.just_toggled = e.scriptstate = FALSE;
 		e.scriptline += 1;
+		e.scripttime = stof(argv(1));
 	}
 
-	if(e.scripttime)
+	if(e.scriptstate)
 	{
 		if(e.bgmscriptdecay >= 1)
-		{
-			return e.switchedon;
-		}
+			return e.just_toggled;
 		else
-		{
 			return pow(0.5, (t - e.scripttime) * (e.bgmscriptdecay / (1 - e.bgmscriptdecay))) * e.scriptvelocity;
-		}
 	}
 	else
 		return 0;
@@ -173,7 +168,7 @@
 	if(n == 0)
 		return;
 	fail = 0;
-	for(i = random(); (self.switchedon || i <= n) && fail <= 64*n; ++i)
+	for(i = random(); (self.just_toggled || i <= n) && fail <= 64*n; ++i)
 	{
 		p = o + self.mins;
 		p_x += random() * sz_x;
@@ -194,7 +189,7 @@
 				self.origin = p;
 				sound(self, CHAN_AUTO, self.noise, VOL_BASE * self.volume, self.atten);
 			}
-			self.switchedon = 0;
+			self.just_toggled = 0;
 		}
 		else if(self.absolute)
 		{
@@ -224,7 +219,7 @@
 	{
 		i = ReadCoord(); // density (<0: point, >0: volume)
 		if(i && !self.impulse)
-			self.switchedon = 1;
+			self.just_toggled = 1;
 		self.impulse = i;
 	}
 	if(f & 4)



More information about the nexuiz-commits mailing list