Skip to content

Commit

Permalink
tweak(jobs): move jobs to toml with map support
Browse files Browse the repository at this point in the history
  • Loading branch information
Doster-d authored Oct 13, 2023
1 parent 8e31f8e commit fb2d350
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion code/controllers/subsystems/initialization/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SUBSYSTEM_DEF(misc)

job_master = new /datum/controller/occupations()
job_master.SetupOccupations(setup_titles=1)
job_master.LoadJobs("config/jobs.txt")
job_master.LoadJobs("config/jobs.toml")

GLOB.syndicate_code_phrase = generate_code_phrase()
GLOB.code_phrase_highlight_rule = generate_code_regex(GLOB.syndicate_code_phrase, @"\u0430-\u0451") // Russian chars only
Expand Down
4 changes: 4 additions & 0 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@

/datum/job/proc/is_species_allowed(datum/species/S)
return !GLOB.using_map.is_species_job_restricted(S, src)

/datum/job/proc/set_positions(value)
total_positions = value
spawn_positions = value
4 changes: 4 additions & 0 deletions code/game/jobs/job/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
hud_icon = "hudblank"
preview_override = list("Default", 'icons/mob/hologram.dmi')

/datum/job/ai/set_positions()
. = ..()
total_positions = 0

/datum/job/ai/equip(mob/living/carbon/human/H)
if(!H) return 0
return 1
Expand Down
35 changes: 12 additions & 23 deletions code/game/jobs/job_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -546,39 +546,28 @@ var/global/datum/controller/occupations/job_master
BITSET(H.hud_updateflag, SPECIALROLE_HUD)
return H

proc/LoadJobs(jobsfile) //ran during round setup, reads info from jobs.txt -- Urist
proc/LoadJobs(jobsfile) //ran during round setup, reads info from jobs.toml -- Urist
if(!config.misc.load_jobs_from_txt)
return 0
return FALSE

var/list/jobEntries = file2list(jobsfile)
var/raw_data = FROM_TOML(return_file_text(jobsfile))

for(var/job in jobEntries)
if(!job)
continue
var/list/jobEntries = raw_data[GLOB.using_map.name]

job = trim(job)
if (!length(job))
for(var/job in jobEntries)
if(!length(job) || !isnum(jobEntries[job]))
continue

var/pos = findtext(job, "=")
var/name = null
var/value = null

if(pos)
name = copytext(job, 1, pos)
value = copytext(job, pos + 1)
else
continue
var/name = replacetext_char(job, "_", " ")
var/value = jobEntries[job]

if(name && value)
var/datum/job/J = GetJob(name)
if(!J) continue
J.total_positions = text2num(value)
J.spawn_positions = text2num(value)
if(name == "AI")//I dont like this here but it will do for now
J.total_positions = 0
if(!J)
continue
J.set_positions(value)

return 1
return TRUE


proc/HandleFeedbackGathering()
Expand Down
38 changes: 38 additions & 0 deletions config/example/jobs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[Exodus]
Captain = 1
Head_of_Personnel = 1
Head_of_Security = 1
Chief_Engineer = 1
Research_Director = 1
Chief_Medical_Officer = 1

Station_Engineer = 5
Roboticist = 1

Medical_Doctor = 5
Geneticist = 2
Virologist = 1

Scientist = 3
Chemist = 2

Bartender = 1
Botanist = 2
Chef = 1
Janitor = 1
Quartermaster = 1
Shaft_Miner = 3

Warden = 1
Detective = 1
Security_Officer = 5

Assistant = -1
Atmospheric_Technician = 4
Cargo_Technician = 3
Chaplain = 1
Lawyer = 2
Librarian = 1

AI = 1
Cyborg = 1
37 changes: 0 additions & 37 deletions config/example/jobs.txt

This file was deleted.

0 comments on commit fb2d350

Please sign in to comment.