From: terencehill <piuntn@gmail.com>
Date: Thu, 17 Jun 2010 18:34:50 +0000 (+0200)
Subject: numbered bots FIX
X-Git-Tag: xonotic-v0.1.0preview~532^2
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=091db94fed51362320e122b4e1745626c4f929d7;p=xonotic%2Fxonotic-data.pk3dir.git

numbered bots FIX
- Bots were created already numbered (1) when the previous map ended cause of expired time.
- In the algorithm that determines the priority of bot name creation, check the field 'cleanname' instead of 'prefix + name + suffix', as the latter changes when the bot name gets numbered.

---
(Sorry, I meant include this (old) fix too in the previous commit, but I didn't realize I didn't...)
---

diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc
index 940782c823..3ef50481dc 100644
--- a/qcsrc/server/bot/bot.qc
+++ b/qcsrc/server/bot/bot.qc
@@ -136,7 +136,8 @@ void bot_setnameandstuff()
 			prio = 1;
 			FOR_EACH_CLIENT(p)
 			{
-				if(strcat(prefix, s, suffix) == p.netname)
+				if(clienttype(p) == CLIENTTYPE_BOT)
+				if(s == p.cleanname)
 				{
 					prio = 0;
 					break;
@@ -200,8 +201,6 @@ void bot_setnameandstuff()
 	else
 		name = bot_name;
 
-	self.cleanname = strzone(name);
-
 	// number bots with identical names
 	float i;
 	i = 0;
@@ -212,7 +211,11 @@ void bot_setnameandstuff()
 				++i;
 	}
 	if (i)
-		name = strcat(name, "(", ftos(i), ")");
+		self.netname = self.netname_freeme = strzone(strcat(prefix, name, "(", ftos(i), ")", suffix));
+	else
+		self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
+
+	self.cleanname = strzone(name);
 
 	// pick the model and skin
 	if(substring(bot_model, -4, 1) != ".")
@@ -220,8 +223,6 @@ void bot_setnameandstuff()
 	self.playermodel = self.playermodel_freeme = strzone(strcat("models/player/", bot_model));
 	self.playerskin = self.playerskin_freeme = strzone(bot_skin);
 
-	self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
-
 	self.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the world
 	self.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
 };