From f01f33bcec8100ebdefdd87837172d581dc4e2e1 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Tue, 26 Jul 2016 06:27:12 -0700 Subject: [PATCH] Add crew manifest world/Topic Returns JSON data in the format { department: [{ name: title }, { name: title }] } --- code/game/objects/effects/datacore-effect.dm | 17 +++++----- code/world.dm | 33 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/code/game/objects/effects/datacore-effect.dm b/code/game/objects/effects/datacore-effect.dm index 5c2fe3f5167..65d873666d1 100644 --- a/code/game/objects/effects/datacore-effect.dm +++ b/code/game/objects/effects/datacore-effect.dm @@ -158,6 +158,7 @@ var/global/list/PDA_Manifest = list() var/name = sanitize(t.fields["name"]) var/rank = sanitize(t.fields["rank"]) var/real_rank = t.fields["real_rank"] + var/isactive = t.fields["p_stat"] var/department = 0 var/depthead = 0 // Department Heads will be placed at the top of their lists. @@ -165,44 +166,44 @@ var/global/list/PDA_Manifest = list() heads[++heads.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 depthead = 1 - if(rank=="Captain" && heads.len != 1) - heads.Swap(1,heads.len) + if(rank == "Captain" && heads.len != 1) + heads.Swap(1, heads.len) if(real_rank in security_positions) sec[++sec.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && sec.len != 1) - sec.Swap(1,sec.len) + sec.Swap(1, sec.len) if(real_rank in engineering_positions) eng[++eng.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && eng.len != 1) - eng.Swap(1,eng.len) + eng.Swap(1, eng.len) if(real_rank in medical_positions) med[++med.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && med.len != 1) - med.Swap(1,med.len) + med.Swap(1, med.len) if(real_rank in science_positions) sci[++sci.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && sci.len != 1) - sci.Swap(1,sci.len) + sci.Swap(1, sci.len) if(real_rank in service_positions) ser[++ser.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && ser.len != 1) - ser.Swap(1,ser.len) + ser.Swap(1, ser.len) if(real_rank in supply_positions) sup[++sup.len] = list("name" = name, "rank" = rank, "active" = isactive) department = 1 if(depthead && sup.len != 1) - sup.Swap(1,sup.len) + sup.Swap(1, sup.len) if(real_rank in nonhuman_positions) bot[++bot.len] = list("name" = name, "rank" = rank, "active" = isactive) diff --git a/code/world.dm b/code/world.dm index 6fa54acfbe7..c82b00b8e9a 100644 --- a/code/world.dm +++ b/code/world.dm @@ -154,6 +154,39 @@ var/world_topic_spam_protect_time = world.timeofday return list2params(s) + else if("manifest" in input) + var/list/positions = list() + var/list/set_names = list( + "heads" = command_positions, + "sec" = security_positions, + "eng" = engineering_positions, + "med" = medical_positions, + "sci" = science_positions, + "car" = supply_positions, + "srv" = service_positions, + "civ" = civilian_positions, + "bot" = nonhuman_positions + ) + + for(var/datum/data/record/t in data_core.general) + var/name = t.fields["name"] + var/rank = t.fields["rank"] + var/real_rank = t.fields["real_rank"] + + var/department = 0 + for(var/k in set_names) + if(real_rank in set_names[k]) + if(!positions[k]) + positions[k] = list() + positions[k][name] = rank + department = 1 + if(!department) + if(!positions["misc"]) + positions["misc"] = list() + positions["misc"][name] = rank + + return json_encode(positions) + else if("adminmsg" in input) /* We got an adminmsg from IRC bot lets split the input then validate the input.