IL_PUSH(squads, new_squad);
}
- FOREACH_CLIENT(IS_PLAYER(it), {
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it), {
entity current_squad = br_SquadGetRandomAvail();
br_SquadMember_Add(current_squad, it);
GameRules_scoring_add(it, BR_SQUAD, current_squad.br_squad_id);
entity br_SquadGetRandomAvail()
{
+ int min_members = max_squad_size;
+ IL_EACH(squads, it.br_squad_members < min_members, min_members = it.br_squad_members);
+
int num_avail = 0;
- IL_EACH(squads, it.br_squad_members < max_squad_size, ++num_avail);
+ IL_EACH(squads, it.br_squad_members == min_members, ++num_avail);
if(num_avail == 0)
return NULL;
int target_id = floor(random() * num_avail);
int current_id = 0;
- IL_EACH(squads, it.br_squad_members < max_squad_size,
+ IL_EACH(squads, it.br_squad_members == min_members,
{
if(current_id == target_id)
return it;