Skip to content

Commit

Permalink
[MIRROR] Fixes station trait jobs and bank accounts ignoring the conc…
Browse files Browse the repository at this point in the history
…ept of jobs being singletons (#2223)

* Fixes station trait jobs and bank accounts ignoring the concept of jobs being singletons (#81756)

## About The Pull Request

Jobs are singletons don't make new ones!!

Also this tweaks job station traits slightly so that traits in the
future support multiple slots without breaking

* Fixes station trait jobs and bank accounts ignoring the concept of jobs being singletons

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
  • Loading branch information
3 people authored Mar 2, 2024
1 parent f0297a7 commit 8e86dc4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
19 changes: 8 additions & 11 deletions code/datums/station_traits/job_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,18 @@
for (var/mob/dead/new_player/signee as anything in lobby_candidates)
if (isnull(signee) || !signee.client || !signee.mind || signee.ready != PLAYER_READY_TO_PLAY)
LAZYREMOVE(lobby_candidates, signee)
if (!LAZYLEN(lobby_candidates))
on_failed_assignment()
return // Nobody signed up :(
for(var/_ in 1 to position_amount)

var/datum/job/our_job = SSjob.GetJobType(job_to_add)
while(length(lobby_candidates) && position_amount > 0)
var/mob/dead/new_player/picked_player = pick_n_take(lobby_candidates)
picked_player.mind.assigned_role = new job_to_add()
lobby_candidates = null
picked_player.mind.set_assigned_role(our_job)
position_amount--

/// Called if we didn't assign a role before the round began, we add it to the latejoin menu instead
/datum/station_trait/job/proc/on_failed_assignment()
var/datum/job/our_job = SSjob.GetJob(job_to_add::title)
our_job.total_positions = position_amount
our_job.total_positions = max(0, position_amount)
lobby_candidates = null

/datum/station_trait/job/can_display_lobby_button(client/player)
var/datum/job/our_job = SSjob.GetJob(job_to_add::title)
var/datum/job/our_job = SSjob.GetJobType(job_to_add)
return our_job.player_old_enough(player) && ..()

/// Adds a gorilla to the cargo department, replacing the sloth and the mech
Expand Down
4 changes: 1 addition & 3 deletions code/game/machinery/computer/accounting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@

for(var/current_account as anything in SSeconomy.bank_accounts_by_id)
var/datum/bank_account/current_bank_account = SSeconomy.bank_accounts_by_id[current_account]
var/job_title = current_bank_account.account_job?.title
player_accounts += list(list(
"name" = current_bank_account.account_holder,
"job" = job_title ? job_title : "No Job", // because this can be null
"job" = current_bank_account.account_job?.title || "No job", // because this can be null
"balance" = round(current_bank_account.account_balance),
"modifier" = round((current_bank_account.payday_modifier * 0.9), 0.1),
))
data["PlayerAccounts"] = player_accounts
data["AuditLog"] = audit_list
data["Crashing"] = HAS_TRAIT(SSeconomy, TRAIT_MARKET_CRASHING)
return data

5 changes: 2 additions & 3 deletions code/game/objects/items/cards_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@
/obj/item/card/id/Initialize(mapload)
. = ..()

var/datum/bank_account/blank_bank_account = new /datum/bank_account("Unassigned", player_account = FALSE)
var/datum/bank_account/blank_bank_account = new("Unassigned", SSjob.GetJobType(/datum/job/unassigned), player_account = FALSE)
registered_account = blank_bank_account
blank_bank_account.account_job = new /datum/job/unassigned
registered_account.replaceable = TRUE

// Applying the trim updates the label and icon, so don't do this twice.
Expand Down Expand Up @@ -1234,7 +1233,7 @@
/obj/item/card/id/advanced/debug/Initialize(mapload)
. = ..()
registered_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
registered_account.account_job = new /datum/job/admin // so we can actually use this account without being filtered as a "departmental" card
registered_account.account_job = SSjob.GetJobType(/datum/job/admin) // so we can actually use this account without being filtered as a "departmental" card

/obj/item/card/id/advanced/prisoner
name = "prisoner ID card"
Expand Down

0 comments on commit 8e86dc4

Please sign in to comment.