[nexuiz-commits] r6846 - trunk/data/qcsrc/client
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Jun 2 03:47:29 EDT 2009
Author: tzork
Date: 2009-06-02 03:47:13 -0400 (Tue, 02 Jun 2009)
New Revision: 6846
Added:
trunk/data/qcsrc/client/rubble.qc
Modified:
trunk/data/qcsrc/client/casings.qc
trunk/data/qcsrc/client/gibs.qc
trunk/data/qcsrc/client/progs.src
Log:
cl_gibs_maxcount and cl_casings_maxcount
performance enhancement / config options. limits the maximum number of items of that type known to a client at any one time.
Modified: trunk/data/qcsrc/client/casings.qc
===================================================================
--- trunk/data/qcsrc/client/casings.qc 2009-06-02 07:22:02 UTC (rev 6845)
+++ trunk/data/qcsrc/client/casings.qc 2009-06-02 07:47:13 UTC (rev 6846)
@@ -1,3 +1,12 @@
+float casecount;
+entity caselist;
+
+void Casing_Delete()
+{
+ --casecount;
+ remove(self);
+}
+
void Casing_Draw()
{
if(self.move_flags & FL_ONGROUND)
@@ -8,12 +17,12 @@
}
Movetype_Physics(FALSE);
-
+
self.renderflags = 0;
self.alpha = bound(0, self.cnt - time, 1);
if(self.alpha < ALPHA_MIN_VISIBLE)
- remove(self);
+ Casing_Delete();
else
R_AddEntity(self);
}
@@ -22,7 +31,7 @@
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
- remove(self);
+ Casing_Delete();
return;
}
@@ -65,8 +74,15 @@
void Ent_Casing()
{
entity casing;
+
+ if not(caselist)
+ caselist = spawn();
- casing = spawn();
+ casing = RubbleNew(caselist);
+ ++casecount;
+ if(casecount >= cvar_or("cl_casings_maxcount",100))
+ RubbleDrop(caselist,Casing_Delete);
+
casing.state = ReadByte();
casing.origin_x = ReadCoord();
casing.origin_y = ReadCoord();
@@ -75,7 +91,7 @@
casing.angles_x = ReadByte() * 360 / 256;
casing.angles_y = ReadByte() * 360 / 256;
casing.angles_z = ReadByte() * 360 / 256;
-
+
if(cvar("cl_casings")) {
casing.draw = Casing_Draw;
casing.move_origin = casing.origin;
@@ -101,7 +117,9 @@
}
setsize(casing, '0 0 -1', '0 0 -1');
- } else remove(self);
+ }
+ else
+ Casing_Delete();
}
void Casings_Precache()
Modified: trunk/data/qcsrc/client/gibs.qc
===================================================================
--- trunk/data/qcsrc/client/gibs.qc 2009-06-02 07:22:02 UTC (rev 6845)
+++ trunk/data/qcsrc/client/gibs.qc 2009-06-02 07:47:13 UTC (rev 6846)
@@ -1,3 +1,12 @@
+float gibcount;
+entity giblist;
+
+void Gib_Delete()
+{
+ --gibcount;
+ remove(self);
+}
+
string species_prefix(float specnum)
{
switch(specnum)
@@ -23,7 +32,7 @@
void SUB_RemoveOnNoImpact()
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
- remove(self);
+ Gib_Delete();
}
void Gib_Touch()
@@ -32,14 +41,14 @@
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
- remove(self);
+ Gib_Delete();
return;
}
-
+
sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
- remove(self);
+ Gib_Delete();
}
void Gib_Draw()
@@ -50,7 +59,7 @@
Movetype_Physics(FALSE);
if(wasfreed(self))
return;
-
+
if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
else
@@ -60,7 +69,7 @@
self.alpha = bound(0, self.nextthink - time, 1);
if(self.alpha < ALPHA_MIN_VISIBLE)
- remove(self);
+ Gib_Delete();
else
R_AddEntity(self);
}
@@ -69,9 +78,17 @@
{
entity gib;
- // TODO remove some gibs according to cl_nogibs
-
- gib = spawn();
+ if not(giblist)
+ giblist = spawn();
+
+ // TODO remove some gibs according to cl_nogibs
+ gib = RubbleNew(giblist);
+ ++gibcount;
+ if(gibcount >= cvar_or("cl_gibs_maxcount",100))
+ RubbleDrop(giblist,Gib_Delete);
+
+ //gib = spawn();
+
gib.classname = "gib";
gib.move_movetype = MOVETYPE_BOUNCE;
gib.gravity = 1;
@@ -82,7 +99,7 @@
gib.skin = specnum;
setsize (gib, '-8 -8 -8', '8 8 8');
-
+
gib.draw = Gib_Draw;
if(destroyontouch)
gib.move_touch = Gib_Touch;
@@ -115,16 +132,16 @@
if(cvar("cl_gentle"))
type |= 0x80; // set gentle bit
-
+
gibfactor = 1 - cvar("cl_nogibs");
if(gibfactor <= 0)
return;
-
+
amount *= gibfactor;
if(cvar("ekg"))
amount *= 5;
-
+
self.origin = org; // for the sounds
specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..15, bit indexes 3,4,5,6)
@@ -145,7 +162,7 @@
for(c = 0; c < amount; ++c)
{
randomvalue = amount - c;
-
+
if(prandom() < randomvalue)
TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0);
if(prandom() < randomvalue)
Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src 2009-06-02 07:22:02 UTC (rev 6845)
+++ trunk/data/qcsrc/client/progs.src 2009-06-02 07:47:13 UTC (rev 6846)
@@ -28,6 +28,7 @@
sbar.qc
mapvoting.qc
+rubble.qc
hook.qc
particles.qc
laser.qc
@@ -38,6 +39,7 @@
effects.qc
wall.qc
+vehicles/spiderbot.qc
Main.qc
View.qc
interpolate.qc
Added: trunk/data/qcsrc/client/rubble.qc
===================================================================
--- trunk/data/qcsrc/client/rubble.qc (rev 0)
+++ trunk/data/qcsrc/client/rubble.qc 2009-06-02 07:47:13 UTC (rev 6846)
@@ -0,0 +1,34 @@
+.float creationtime;
+
+void RubbleDrop(entity list, void() deleteproc)
+{
+ float t,tt;
+ entity rub,old_rub;
+
+ rub = findchainentity(owner,list);
+ while(rub)
+ {
+ if(rub.creationtime > t)
+ {
+ old_rub = rub;
+ tt = t;
+ }
+ rub = rub.chain;
+ }
+
+ rub = self;
+ self = old_rub;
+ deleteproc();
+ self = rub;
+}
+
+entity RubbleNew(entity list)
+{
+ entity rub;
+
+ rub = spawn();
+ rub.creationtime = time;
+ rub.owner = list;
+
+ return rub;
+}
More information about the nexuiz-commits
mailing list