diff --git a/modular_nova/modules/cryosleep/code/job.dm b/modular_nova/modules/cryosleep/code/job.dm index 6d977a19ab0..fcd218d4739 100644 --- a/modular_nova/modules/cryosleep/code/job.dm +++ b/modular_nova/modules/cryosleep/code/job.dm @@ -6,3 +6,14 @@ if(!job) return FALSE job.current_positions = max(0, job.current_positions - 1) + +/// Used for clocking back in, re-claiming the previously freed role. Returns false if no slot is available. +/datum/controller/subsystem/job/proc/OccupyRole(rank) + if(!rank) + return FALSE + JobDebug("Occupying role: [rank]") + var/datum/job/job = GetJob(rank) + if(!job || job.current_positions >= job.total_positions) + return FALSE + job.current_positions = job.current_positions + 1 + return TRUE diff --git a/modular_nova/modules/time_clock/code/console.dm b/modular_nova/modules/time_clock/code/console.dm index 636346ff6ef..268c9377ff1 100644 --- a/modular_nova/modules/time_clock/code/console.dm +++ b/modular_nova/modules/time_clock/code/console.dm @@ -114,8 +114,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/time_clock, 28) var/current_assignment = inserted_id.assignment var/datum/id_trim/job/current_trim = inserted_id.trim var/datum/job/clocked_out_job = current_trim.job - clocked_out_job.current_positions = max(0, clocked_out_job.current_positions - 1) - + SSjob.FreeRole(clocked_out_job.title) radio.talk_into(src, "[inserted_id.registered_name], [current_assignment] has gone off-duty.", announcement_channel) update_static_data_for_all_viewers() @@ -139,10 +138,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/time_clock, 28) return FALSE var/datum/job/clocked_in_job = id_component.stored_trim.job - if(!clocked_in_job || (clocked_in_job.total_positions <= clocked_in_job.current_positions)) + if(!SSjob.OccupyRole(clocked_in_job.title)) + say("[capitalize(clocked_in_job.title)] has no free slots available, unable to clock in!") return FALSE - clocked_in_job.current_positions++ SSid_access.apply_trim_to_card(inserted_id, id_component.stored_trim.type, TRUE) inserted_id.assignment = id_component.stored_assignment diff --git a/modular_nova/modules/time_clock/code/console_tgui.dm b/modular_nova/modules/time_clock/code/console_tgui.dm index e1b53700af5..0bbcf4876f7 100644 --- a/modular_nova/modules/time_clock/code/console_tgui.dm +++ b/modular_nova/modules/time_clock/code/console_tgui.dm @@ -99,7 +99,8 @@ switch(action) if("clock_in_or_out") if(off_duty_check()) - clock_in() + if(!(clock_in())) + return log_admin("[key_name(usr)] clocked in as \an [inserted_id.assignment].") var/datum/mind/user_mind = usr.mind