[nexuiz-commits] r7721 - in trunk/data/qcsrc: client server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Sep 11 03:40:57 EDT 2009


Author: div0
Date: 2009-09-11 03:40:53 -0400 (Fri, 11 Sep 2009)
New Revision: 7721

Modified:
   trunk/data/qcsrc/client/particles.qc
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/qcsrc/server/w_common.qc
Log:
optimize zcurveparticles by combining multiple instances with same start


Modified: trunk/data/qcsrc/client/particles.qc
===================================================================
--- trunk/data/qcsrc/client/particles.qc	2009-09-11 06:41:06 UTC (rev 7720)
+++ trunk/data/qcsrc/client/particles.qc	2009-09-11 07:40:53 UTC (rev 7721)
@@ -308,13 +308,17 @@
 	start_x = ReadCoord();
 	start_y = ReadCoord();
 	start_z = ReadCoord();
-	end_x = ReadCoord();
-	end_y = ReadCoord();
-	end_z = ReadCoord();
-	end_dz = ReadCoord();
-	speed = ReadShort() * 16;
 
-	zcurveparticles(effectnum, start, end, end_dz, speed, 5); // at most 32 segments
+	do
+	{
+		end_x = ReadCoord();
+		end_y = ReadCoord();
+		end_z = ReadCoord();
+		end_dz = ReadCoord();
+		speed = ReadShort();
+		zcurveparticles(effectnum, start, end, end_dz, 16 * (speed & 0x7FFF), 5); // at most 32 segments
+	}
+	while(!(speed & 0x8000));
 }
 
 void Net_ReadNexgunBeamParticle()

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2009-09-11 06:41:06 UTC (rev 7720)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2009-09-11 07:40:53 UTC (rev 7721)
@@ -2157,39 +2157,63 @@
         return FALSE;
 }
 
+float zcurveparticles_effectno;
+vector zcurveparticles_start;
+float zcurveparticles_spd;
+
+void endzcurveparticles()
+{
+	if(zcurveparticles_effectno)
+	{
+		// terminator
+		WriteShort(zcurveparticles_spd | 0x8000);
+	}
+	zcurveparticles_effectno = 0;
+}
+
 void zcurveparticles(float effectno, vector start, vector end, float end_dz, float spd)
 {
-    WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
-    WriteByte(MSG_BROADCAST, TE_CSQC_ZCURVEPARTICLES);
-    WriteShort(MSG_BROADCAST, effectno);
-    WriteCoord(MSG_BROADCAST, start_x);
-    WriteCoord(MSG_BROADCAST, start_y);
-    WriteCoord(MSG_BROADCAST, start_z);
-    WriteCoord(MSG_BROADCAST, end_x);
-    WriteCoord(MSG_BROADCAST, end_y);
-    WriteCoord(MSG_BROADCAST, end_z);
-    WriteCoord(MSG_BROADCAST, end_dz);
-    WriteShort(MSG_BROADCAST, spd / 16);
+	spd = bound(0, floor(spd / 16), 32767);
+	if(effectno != zcurveparticles_effectno || start != zcurveparticles_start)
+	{
+		endzcurveparticles();
+		WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
+		WriteByte(MSG_BROADCAST, TE_CSQC_ZCURVEPARTICLES);
+		WriteShort(MSG_BROADCAST, effectno);
+		WriteCoord(MSG_BROADCAST, start_x);
+		WriteCoord(MSG_BROADCAST, start_y);
+		WriteCoord(MSG_BROADCAST, start_z);
+		zcurveparticles_effectno = effectno;
+		zcurveparticles_start = start;
+	}
+	else
+		WriteShort(MSG_BROADCAST, zcurveparticles_spd);
+	WriteCoord(MSG_BROADCAST, end_x);
+	WriteCoord(MSG_BROADCAST, end_y);
+	WriteCoord(MSG_BROADCAST, end_z);
+	WriteCoord(MSG_BROADCAST, end_dz);
+	zcurveparticles_spd = spd;
 }
 
 void zcurveparticles_from_tracetoss(float effectno, vector start, vector end, vector vel)
 {
-    float end_dz;
-    vector vecxy, velxy;
+	float end_dz;
+	vector vecxy, velxy;
 
-    vecxy = end - start;
-    vecxy_z = 0;
-    velxy = vel;
-    velxy_z = 0;
+	vecxy = end - start;
+	vecxy_z = 0;
+	velxy = vel;
+	velxy_z = 0;
 
-    if (vlen(velxy) < 0.000001 * fabs(vel_z))
-    {
-        trailparticles(world, effectno, start, end);
-        return;
-    }
+	if (vlen(velxy) < 0.000001 * fabs(vel_z))
+	{
+		endzcurveparticles();
+		trailparticles(world, effectno, start, end);
+		return;
+	}
 
-    end_dz = vlen(vecxy) / vlen(velxy) * vel_z - (end_z - start_z);
-    zcurveparticles(effectno, start, end, end_dz, vlen(vel));
+	end_dz = vlen(vecxy) / vlen(velxy) * vel_z - (end_z - start_z);
+	zcurveparticles(effectno, start, end, end_dz, vlen(vel));
 }
 
 string GetGametype(); // g_world.qc

Modified: trunk/data/qcsrc/server/w_common.qc
===================================================================
--- trunk/data/qcsrc/server/w_common.qc	2009-09-11 06:41:06 UTC (rev 7720)
+++ trunk/data/qcsrc/server/w_common.qc	2009-09-11 07:40:53 UTC (rev 7721)
@@ -189,6 +189,8 @@
 
 	if(other && other != self.enemy)
 	{
+		endzcurveparticles();
+
 		headshot = 0;
 		yoda = 0;
 		damage_headshotbonus = self.dmg_edge;
@@ -463,6 +465,8 @@
 		frametime = savetime;
 		self = oldself;
 
+		endzcurveparticles();
+
 		if(lag)
 			FOR_EACH_PLAYER(pl)
 				antilag_restore(pl);



More information about the nexuiz-commits mailing list