Module dpmod: Change committed

havoc at icculus.org havoc at icculus.org
Thu Feb 20 04:02:31 EST 2003


Commiter   : havoc
CVSROOT    : /cvs/cvsroot/twilight
Module     : dpmod
Commit time: 2003-02-20 09:02:31 UTC

Log message:

now keeps a list of active bots to avoid using find each frame

Modified files:
     qc/havocbot.qc

------=MIME.6f674c58d46a817358c1db62e9b6a1e4
Content-Type: text/plain; name="dpmod.20030220.090231.havoc.diff"
Content-Disposition: attachment; filename="dpmod.20030220.090231.havoc.diff"
Content-Transfer-Encoding: 8bit

Index: dpmod/qc/havocbot.qc
diff -u dpmod/qc/havocbot.qc:1.3 dpmod/qc/havocbot.qc:1.4
--- dpmod/qc/havocbot.qc:1.3	Sat Sep 21 06:07:08 2002
+++ dpmod/qc/havocbot.qc	Thu Feb 20 04:02:21 2003
@@ -159,9 +159,22 @@
 
 .float isbot;
 
-float   havoccurrentbots;
-float   havocbots;
+float havoccurrentbots;
+float havocbots;
+entity havocbot_list;
+.entity nextbot;
 
+void() havocbot_relinkbotlist =
+{
+	local entity e;
+	havocbot_list = e = findchainfloat(isbot, TRUE);
+	while (e)
+	{
+		e.nextbot = e.chain;
+		e = e.chain;
+	}
+};
+
 string() havocbot_name =
 {
 	local string name;
@@ -226,6 +239,7 @@
 	newmis.c_pants = -1;
 	newmis.c_shirt = -1;
 	newmis.havocbot_role = SUB_Null;
+	havocbot_relinkbotlist();
 };
 
 void() havocbot_removenewest =
@@ -251,6 +265,7 @@
 	self = best;
 	ClientDisconnect();
 	self = saveself;
+	havocbot_relinkbotlist();
 };
 
 void() havocbot_think;
@@ -259,12 +274,11 @@
 
 void() havocbot_serverframe =
 {
-	local   entity  head, saveself;
+	local entity head, saveself;
 	if (intermission_running)
 		return;
 
-	head = findfloat(world, isbot, TRUE);
-	if (head != world)
+	if (havocbot_list)
 	{
 		maxspeed = cvar("sv_maxspeed"); // player movement speed
 		sv_accelerate = cvar("sv_accelerate"); // 10 normally
@@ -272,13 +286,14 @@
 
 		havocbot_updatedangerousobjects();
 		saveself = self;
+		head = havocbot_list;
 		while (head)
 		{
 			self = head;
 			havocbot_think();
 			PlayerPreThink();
 			PlayerPostThink();
-			head = findfloat(head, isbot, TRUE);
+			head = head.nextbot;
 		}
 		self = saveself;
 	}


More information about the twilight-commits mailing list