mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Fix unintended case allowing multiple AI spawns shiftstart (#59160)
This commit is contained in:
@@ -259,23 +259,20 @@ SUBSYSTEM_DEF(job)
|
|||||||
var/mob/dead/new_player/candidate = pick(candidates)
|
var/mob/dead/new_player/candidate = pick(candidates)
|
||||||
AssignRole(candidate, command_position)
|
AssignRole(candidate, command_position)
|
||||||
|
|
||||||
/datum/controller/subsystem/job/proc/FillAIPosition()
|
/// Attempts to fill out all available AI positions.
|
||||||
var/ai_selected = FALSE
|
/datum/controller/subsystem/job/proc/fill_ai_positions()
|
||||||
var/datum/job/job = GetJob("AI")
|
var/datum/job/ai_job = GetJob("AI")
|
||||||
if(!job)
|
if(!ai_job)
|
||||||
return FALSE
|
return
|
||||||
for(var/i = job.total_positions, i > 0, i--)
|
// In byond for(in to) loops, the iteration is inclusive so we need to stop at ai_job.total_positions - 1
|
||||||
|
for(var/i in ai_job.current_positions to ai_job.total_positions - 1)
|
||||||
for(var/level in level_order)
|
for(var/level in level_order)
|
||||||
var/list/candidates = list()
|
var/list/candidates = list()
|
||||||
candidates = FindOccupationCandidates(job, level)
|
candidates = FindOccupationCandidates(ai_job, level)
|
||||||
if(candidates.len)
|
if(candidates.len)
|
||||||
var/mob/dead/new_player/candidate = pick(candidates)
|
var/mob/dead/new_player/candidate = pick(candidates)
|
||||||
if(AssignRole(candidate, "AI"))
|
if(AssignRole(candidate, "AI"))
|
||||||
ai_selected++
|
|
||||||
break
|
break
|
||||||
if(ai_selected)
|
|
||||||
return TRUE
|
|
||||||
return FALSE
|
|
||||||
|
|
||||||
|
|
||||||
/** Proc DivideOccupations
|
/** Proc DivideOccupations
|
||||||
@@ -341,9 +338,9 @@ SUBSYSTEM_DEF(job)
|
|||||||
FillHeadPosition()
|
FillHeadPosition()
|
||||||
JobDebug("DO, Head Check end")
|
JobDebug("DO, Head Check end")
|
||||||
|
|
||||||
//Check for an AI
|
// Fill out any remaining AI positions.
|
||||||
JobDebug("DO, Running AI Check")
|
JobDebug("DO, Running AI Check")
|
||||||
FillAIPosition()
|
fill_ai_positions()
|
||||||
JobDebug("DO, AI Check end")
|
JobDebug("DO, AI Check end")
|
||||||
|
|
||||||
//Other jobs are now checked
|
//Other jobs are now checked
|
||||||
|
|||||||
Reference in New Issue
Block a user