r6032 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Mar 1 14:08:24 EST 2009


Author: div0
Date: 2009-03-01 14:08:18 -0500 (Sun, 01 Mar 2009)
New Revision: 6032

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/havocbot.qc
Log:
fix bot weapon priority lists of full length


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-03-01 11:31:57 UTC (rev 6031)
+++ trunk/data/qcsrc/server/bots.qc	2009-03-01 19:08:18 UTC (rev 6032)
@@ -1568,40 +1568,43 @@
 	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_far")," ");
 
 	c = 0;
-	for(i=0; i < tokens && i < WEP_LAST; ++i){
+	for(i=0; i < tokens && c < WEP_COUNT; ++i){
 		w = stof(argv(i));
 		if ( w >= WEP_FIRST && w <= WEP_LAST) {
 			bot_weapons_far[c] = w;
 			++c;
 		}
 	}
-	bot_weapons_far[c] = -1;
+	if(c < WEP_COUNT)
+		bot_weapons_far[c] = -1;
 
 	// Parse mid distance weapon priorities
 	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_mid")," ");
 
 	c = 0;
-	for(i=0; i < tokens && i < WEP_LAST; ++i){
+	for(i=0; i < tokens && c < WEP_COUNT; ++i){
 		w = stof(argv(i));
 		if ( w >= WEP_FIRST && w <= WEP_LAST) {
 			bot_weapons_mid[c] = w;
 			++c;
 		}
 	}
-	bot_weapons_mid[c] = -1;
+	if(c < WEP_COUNT)
+		bot_weapons_mid[c] = -1;
 
 	// Parse close distance weapon priorities
 	tokens = tokenizebyseparator(cvar_string("bot_ai_custom_weapon_priority_close")," ");
 
 	c = 0;
-	for(i=0; i < tokens && i < WEP_LAST; ++i){
+	for(i=0; i < tokens && i < WEP_COUNT; ++i){
 		w = stof(argv(i));
 		if ( w >= WEP_FIRST && w <= WEP_LAST) {
 			bot_weapons_close[c] = w;
 			++c;
 		}
 	}
-	bot_weapons_close[c] = -1;
+	if(c < WEP_COUNT)
+		bot_weapons_close[c] = -1;
 
 	bot_custom_weapon = TRUE;
 };

Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc	2009-03-01 11:31:57 UTC (rev 6031)
+++ trunk/data/qcsrc/server/havocbot.qc	2009-03-01 19:08:18 UTC (rev 6032)
@@ -587,7 +587,7 @@
 
 		// Choose weapons for far distance
 		if ( distance > bot_distance_far ) {
-			for(i=0; i < WEP_LAST && bot_weapons_far[i] != -1 ; ++i){
+			for(i=0; i < WEP_COUNT && bot_weapons_far[i] != -1 ; ++i){
 				w = bot_weapons_far[i];
 				if ( client_hasweapon(self, w, TRUE, FALSE) ){
 					if ( self.weapon == w){
@@ -603,7 +603,7 @@
 
 		// Choose weapons for mid distance
 		if ( distance > bot_distance_close ) {
-			for(i=0; i < WEP_LAST && bot_weapons_mid[i] != -1 ; ++i){
+			for(i= 0; i < WEP_COUNT && bot_weapons_mid[i] != -1 ; ++i){
 				w = bot_weapons_mid[i];
 				if ( client_hasweapon(self, w, TRUE, FALSE) ){
 					if ( self.weapon == w){
@@ -618,7 +618,7 @@
 		}
 
 		// Choose weapons for close distance
-		for(i=0; i < WEP_LAST && bot_weapons_close[i] != -1 ; ++i){
+		for(i= 0; i < WEP_COUNT && bot_weapons_close[i] != -1 ; ++i){
 			w = bot_weapons_close[i];
 			if ( client_hasweapon(self, w, TRUE, FALSE) ){
 				if ( self.weapon == w){
@@ -907,4 +907,4 @@
 	self.goalcounter++;
 }
 
-#endif
\ No newline at end of file
+#endif




More information about the nexuiz-commits mailing list