diff --git a/code/game/jobs/role_authority.dm b/code/game/jobs/role_authority.dm index 99a08e18365c..bba8316ad778 100644 --- a/code/game/jobs/role_authority.dm +++ b/code/game/jobs/role_authority.dm @@ -545,11 +545,10 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou for(var/datum/squad/squad in squads) if(squad.roundstart && squad.usable && squad.faction == human.faction && squad.name != "Root") mixed_squads += squad - mixed_squads = shuffle(mixed_squads) - var/preferred_squad - if(human?.client?.prefs?.preferred_squad) - preferred_squad = human.client.prefs.preferred_squad + var/preferred_squad = human.client?.prefs?.preferred_squad + if(preferred_squad == "None") + preferred_squad = null var/datum/squad/lowest for(var/datum/squad/squad in mixed_squads) @@ -557,20 +556,15 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(squad.roles_in[slot_check] >= squad.roles_cap[slot_check]) continue - if(squad.name == preferred_squad || squad.equivalent_name == preferred_squad) //fav squad or faction equivalent has a spot for us, no more searching needed. + if(preferred_squad && (squad.name == preferred_squad || squad.equivalent_name == preferred_squad)) //fav squad or faction equivalent has a spot for us, no more searching needed. if(squad.put_marine_in_squad(human)) return - if(!lowest) + if(!lowest || (slot_check && lowest.roles_in[slot_check] > squad.roles_in[slot_check])) lowest = squad - - else if(slot_check) - if(squad.roles_in[slot_check] < lowest.roles_in[slot_check]) - lowest = squad - - if(!lowest || !lowest.put_marine_in_squad(human)) - to_world("Warning! Bug in get_random_squad()!") - return + if(!lowest) + lowest = locate(/datum/squad/marine/cryo) in squads + lowest.put_marine_in_squad(human) return /datum/authority/branch/role/proc/get_caste_by_text(name)