Skip to content

Commit

Permalink
improvement for cryo squad marines cryoning and some minor QOL for ra…
Browse files Browse the repository at this point in the history
…dnomiz_squad proc (#7911)

# About the pull request
Fix issue with marines without squad and prev strange code, that
unlocked prev by my own mistake locked code

# Explain why it's good for the game
Less bugs, better

# Changelog

:cl:
code: randomize_squad code qol
fix: In case if for some reason we have less open slots in squads for
jobs than jobs aval in total, we put in to cryo squad in assumption that
this their marine did cryo
/:cl:

Closes #8055
Closes #7283
  • Loading branch information
blackcrystall authored Jan 23, 2025
1 parent 05c9d66 commit 79cb17f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions code/game/jobs/role_authority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -545,32 +545,26 @@ 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)
if(slot_check && !isnull(squad.roles_cap[slot_check]) && !skip_limit)
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)
Expand Down

0 comments on commit 79cb17f

Please sign in to comment.