Browse Source

Replace ArrayList picker with plain array

nosoop 6 years ago
parent
commit
3ea7809d11
1 changed files with 5 additions and 7 deletions
  1. 5 7
      scripting/botmanager.sp

+ 5 - 7
scripting/botmanager.sp

@@ -7,7 +7,7 @@
 
 #pragma newdecls required
 
-#define PLUGIN_VERSION "1.3.6"
+#define PLUGIN_VERSION "1.3.7"
 
 public Plugin myinfo = {
 	name = "[TF2] Bot Manager",
@@ -257,21 +257,19 @@ void RemoveBot() {
 		teamToKick = GetRandomInt(2, 3);
 	}
 	
-	ArrayList bots = CreateArray();
+	int botKickCandidates[MAXPLAYERS + 1], numBots;
 	for (int i = 1; i <= MaxClients; i++) {
 		if (IsClientConnected(i) && !IsClientSourceTV(i) && !IsClientReplay(i) &&
 				IsFakeClient(i) && GetClientTeam(i) == teamToKick) {
-			bots.Push(i);
+			botKickCandidates[numBots++] = i;
 		}
 	}
 	
-	if (!bots.Length) {
-		delete bots;
+	if (!numBots) {
 		return;
 	}
 	
-	int bot = bots.Get(GetRandomInt(0, bots.Length - 1));
-	delete bots;
+	int bot = botKickCandidates[ GetRandomInt(0, numBots - 1) ];
 	
 	Call_StartForward(fwdBotKick);
 	Call_PushCellRef(bot);