[nexuiz-commits] r7636 - in branches/nexuiz-2.0: . data/qcsrc/client data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Sep 5 06:43:31 EDT 2009


Author: div0
Date: 2009-09-05 06:43:31 -0400 (Sat, 05 Sep 2009)
New Revision: 7636

Modified:
   branches/nexuiz-2.0/.patchsets
   branches/nexuiz-2.0/data/qcsrc/client/casings.qc
   branches/nexuiz-2.0/data/qcsrc/client/gibs.qc
   branches/nexuiz-2.0/data/qcsrc/client/rubble.qc
   branches/nexuiz-2.0/data/qcsrc/server/g_triggers.qc
Log:
r7612 | lordhavoc | 2009-09-03 12:27:41 -0400 (Thu, 03 Sep 2009) | 2 lines
rewrote rubble handling to fix more bugs
r7613 | lordhavoc | 2009-09-03 13:01:38 -0400 (Thu, 03 Sep 2009) | 3 lines
rewrote acceleration/damping mode in trigger_impulse to work properly
with ticrates other than 0.05
r7614 | lordhavoc | 2009-09-03 13:03:19 -0400 (Thu, 03 Sep 2009) | 3 lines
fixed a bug which prevented falloff modes from working in directional
trigger_impulse
r7615 | div0 | 2009-09-03 16:03:07 -0400 (Thu, 03 Sep 2009) | 2 lines
trigger_impulse: make it sane again (strength 1 = identity, <1 = slow down, >1 = speedup, the value is the speed change factor PER SECOND)


Modified: branches/nexuiz-2.0/.patchsets
===================================================================
--- branches/nexuiz-2.0/.patchsets	2009-09-05 10:40:32 UTC (rev 7635)
+++ branches/nexuiz-2.0/.patchsets	2009-09-05 10:43:31 UTC (rev 7636)
@@ -1,2 +1,2 @@
 master = svn://svn.icculus.org/nexuiz/trunk
-revisions_applied = 1-7563,7565-7586,7589-7589,7592-7592,7595-7595,7597-7597,7601-7602,7605-7610
+revisions_applied = 1-7563,7565-7586,7589-7589,7592-7592,7595-7595,7597-7597,7601-7602,7605-7610,7612-7615

Modified: branches/nexuiz-2.0/data/qcsrc/client/casings.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/casings.qc	2009-09-05 10:40:32 UTC (rev 7635)
+++ branches/nexuiz-2.0/data/qcsrc/client/casings.qc	2009-09-05 10:43:31 UTC (rev 7636)
@@ -1,10 +1,7 @@
-float  casecount;
-entity caselist;
 .float silent;
 
 void Casing_Delete()
 {
-    --casecount;
     remove(self);
 }
 
@@ -77,16 +74,7 @@
 {
 	entity casing;
 
-	if not(caselist)
-        caselist = spawn();
-
-	casing = RubbleNew(caselist);
-	++casecount;
-	if(casecount >= cvar_or("cl_casings_maxcount",100))
-        RubbleDrop(caselist,Casing_Delete);
-	if(wasfreed(casing))
-		return;
-
+	casing = RubbleNew("casing");
 	casing.state = ReadByte();
 	casing.silent = (casing.state & 0x80);
 	casing.state = (casing.state & 0x7F);
@@ -126,6 +114,8 @@
 	}
     else
         Casing_Delete();
+
+	RubbleLimit("casing", cvar_or("cl_casings_maxcount",100), Casing_Delete);
 }
 
 void Casings_Precache()

Modified: branches/nexuiz-2.0/data/qcsrc/client/gibs.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/gibs.qc	2009-09-05 10:40:32 UTC (rev 7635)
+++ branches/nexuiz-2.0/data/qcsrc/client/gibs.qc	2009-09-05 10:43:31 UTC (rev 7636)
@@ -1,11 +1,8 @@
-float  gibcount;
-entity giblist;
 .float silent;
 
 void Gib_Delete()
 {
-    --gibcount;
-    remove(self);
+	remove(self);
 }
 
 string species_prefix(float specnum)
@@ -80,20 +77,8 @@
 {
 	entity gib;
 
-	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);
-	if(wasfreed(gib))
-		return;
-
-	//gib = spawn();
-
-	gib.classname = "gib";
+	gib = RubbleNew("gib");
 	gib.move_movetype = MOVETYPE_BOUNCE;
 	gib.gravity = 1;
 	gib.solid = SOLID_CORPSE;
@@ -118,6 +103,8 @@
 	gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
 
 	gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
+
+	RubbleLimit("gib", cvar_or("cl_gibs_maxcount",100), Gib_Delete);
 }
 
 void Ent_GibSplash()

Modified: branches/nexuiz-2.0/data/qcsrc/client/rubble.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/rubble.qc	2009-09-05 10:40:32 UTC (rev 7635)
+++ branches/nexuiz-2.0/data/qcsrc/client/rubble.qc	2009-09-05 10:43:31 UTC (rev 7636)
@@ -1,40 +1,59 @@
 .float creationtime;
 
-void RubbleDrop(entity list, void() deleteproc)
+// LordHavoc: rewrote this file, it was really bad code
+
+void RubbleLimit(string cname, float limit, void() deleteproc)
 {
-    float t;
-    entity rub,old_rub;
+	entity e;
+	entity oldest;
+	entity oldself;
+	float c;
+	float oldesttime;
 
-    rub = findchainentity(owner,list);
-    old_rub = rub;
-    t = rub.creationtime;
-    rub = rub.chain;
-    while(rub)
-    {
-        if(t > rub.creationtime)
-        {
-            t = rub.creationtime;
-            old_rub = rub;
-        }
-        rub = rub.chain;
-    }
+	oldself = self;
 
-    if (old_rub == world)
-        return;
+	// remove rubble of the same type if it's at the limit
+	// remove multiple rubble if the limit has been decreased
+	while(1)
+	{
+		e = findchain(classname,cname);
+		if (e == world)
+			break;
+		// walk the list and count the entities, find the oldest
+		// initialize our search with the first entity
+		c = 1;
+		oldest = e;
+		oldesttime = e.creationtime;
+		e = e.chain;
+		// compare to all other matching entities
+		while (e)
+		{
+			c = c + 1;
+			if (oldesttime > e.creationtime)
+			{
+				oldesttime = e.creationtime;
+				oldest = e;
+			}
+			e = e.chain;
+		}
 
-    rub = self;
-    self = old_rub;
-    deleteproc();
-    self = rub;
+		// stop if there are less than the limit already
+		if (c <= limit)
+			break;
+
+		// delete this oldest one and search again
+		self = oldest;
+		deleteproc();
+		self = oldself;
+	}
 }
 
-entity RubbleNew(entity list)
+entity RubbleNew(string cname)
 {
-    entity rub;
-
-    rub = spawn();
-    rub.creationtime = time;
-    rub.owner = list;
-
-    return rub;
+	entity e;
+	// spawn a new entity and return it
+	e = spawn();
+	e.classname = cname;
+	e.creationtime = time;
+	return e;
 }

Modified: branches/nexuiz-2.0/data/qcsrc/server/g_triggers.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/g_triggers.qc	2009-09-05 10:40:32 UTC (rev 7635)
+++ branches/nexuiz-2.0/data/qcsrc/server/g_triggers.qc	2009-09-05 10:43:31 UTC (rev 7636)
@@ -1137,7 +1137,7 @@
     other.lastpushtime = time;
     if(!pushdeltatime) return;
 
-    other.velocity = other.velocity + normalize(targ.origin - self.origin) * self.strength * pushdeltatime;
+    other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
 	other.flags &~= FL_ONGROUND;
 }
 
@@ -1173,10 +1173,8 @@
     other.lastpushtime = time;
     if(!pushdeltatime) return;
 
-    //if(self.strength > 1)
-        other.velocity = other.velocity * (self.strength * pushdeltatime);
-    //else
-    //    other.velocity = other.velocity - (other.velocity * self.strength * pushdeltatime);
+    // div0: ticrate independent, 1 = identity (not 20)
+    other.velocity = other.velocity * pow(self.strength, * pushdeltatime);
 }
 
 // Spherical (gravity/repulsor) mode



More information about the nexuiz-commits mailing list