Bots with the same name are progressively numbered
authorterencehill <piuntn@gmail.com>
Sat, 15 May 2010 22:47:34 +0000 (00:47 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 15 May 2010 22:47:34 +0000 (00:47 +0200)
In this way:
[Bot]devil{X}
[Bot]devil(1){X}
[Bot]devil(2){X}
...
[Bot]devil(666){X}
...

It works with bot_usemodelnames too.

qcsrc/server/bot/bot.qc
qcsrc/server/bot/bot.qh

index b428530..44ece52 100644 (file)
@@ -200,6 +200,20 @@ void bot_setnameandstuff()
        else
                name = bot_name;
 
+       self.cleanname = strzone(name);
+
+       // number bots with identical names
+       float i;
+       i = 0;
+       FOR_EACH_CLIENT(p)
+       {
+               if(clienttype(p) == CLIENTTYPE_BOT)
+                       if(p.cleanname == name)
+                               ++i;
+       }
+       if (i)
+               name = strcat(name, "(", ftos(i), ")");
+
        // pick the model and skin
        if(substring(bot_model, -4, 1) != ".")
                bot_model = strcat(bot_model, ".iqm");
@@ -338,12 +352,15 @@ void bot_clientdisconnect()
 {
        if (clienttype(self) != CLIENTTYPE_BOT)
                return;
+       if(self.cleanname)
+               strunzone(self.cleanname);
        if(self.netname_freeme)
                strunzone(self.netname_freeme);
        if(self.playermodel_freeme)
                strunzone(self.playermodel_freeme);
        if(self.playerskin_freeme)
                strunzone(self.playerskin_freeme);
+       self.cleanname = string_null;
        self.netname_freeme = string_null;
        self.playermodel_freeme = string_null;
        self.playerskin_freeme = string_null;
index 75619e1..0550431 100644 (file)
@@ -53,6 +53,7 @@ entity bot_list;
 entity player_list;
 .entity nextbot;
 .entity nextplayer;
+.string cleanname;
 .string netname_freeme;
 .string playermodel_freeme;
 .string playerskin_freeme;