Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platoon Renaming #55

Merged
merged 9 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/signals_global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@
/// From /proc/biohazard_lockdown()
#define COMSIG_GLOB_RESEARCH_LOCKDOWN "research_lockdown_closed"
#define COMSIG_GLOB_RESEARCH_LIFT "research_lockdown_opened"

/// From /client/proc/rename_platoon()
#define COMSIG_GLOB_PLATOON_NAME_CHANGE "platoon_name_change"
12 changes: 12 additions & 0 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
//This list tracks characters spawned in the world and cannot be modified in-game. Currently referenced by respawn_character().
var/locked[] = list()

/datum/datacore/New()
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/datum/datacore/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

for(var/datum/data/record/cycled_data_record in general)
if(cycled_data_record.fields["squad"] == old_name)
cycled_data_record.fields["squad"] = new_name

/datum/datacore/proc/get_manifest(monochrome, OOC, nonHTML)
var/list/cic = ROLES_CIC.Copy()
var/list/auxil = ROLES_AUXIL_SUPPORT.Copy()
Expand Down
9 changes: 0 additions & 9 deletions code/game/gamemodes/colonialmarines/ai/colonialmarines_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
return ..()

/datum/game_mode/colonialmarines/ai/pre_setup()

//Hacky pre-setup shit since RoleAuthority sucks
RoleAuthority.squads = list()
RoleAuthority.squads_by_type = list()
for(var/cycled_squad_type in squad_limit)
var/datum/squad/cycled_squad = new cycled_squad_type()
RoleAuthority.squads += cycled_squad
RoleAuthority.squads_by_type[cycled_squad.type] = cycled_squad

RegisterSignal(SSdcs, COMSIG_GLOB_XENO_SPAWN, PROC_REF(handle_xeno_spawn))

. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/game/jobs/job/marine/squad_info.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"primary" = primary_objective,
"secondary" = secondary_objective,
)
data["partial_squad_ref"] = copytext(REF(src), 2, 12)
return data

/datum/squad/proc/get_leadership(mob/user)
Expand Down
28 changes: 27 additions & 1 deletion code/game/jobs/job/marine/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@

/datum/squad/marine
name = "Root"
usable = TRUE
active = TRUE
faction = FACTION_MARINE
lead_icon = "leader"
Expand All @@ -128,6 +127,7 @@
radio_freq = ALPHA_FREQ
minimap_color = MINIMAP_SQUAD_ALPHA
use_stripe_overlay = FALSE
usable = TRUE

/datum/squad/marine/bravo
name = SQUAD_MARINE_2
Expand Down Expand Up @@ -295,6 +295,32 @@

RegisterSignal(SSdcs, COMSIG_GLOB_MODE_POSTSETUP, PROC_REF(setup_supply_drop_list))

/datum/squad/marine/alpha/New()
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/datum/squad/marine/alpha/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

name = new_name

for(var/mob/living/carbon/human/marine in marines_list)
if(!istype(marine.wear_id, /obj/item/card/id))
continue

var/obj/item/card/id/marine_card = marine.wear_id
var/datum/weakref/marine_card_registered = marine.wear_id.registered_ref

if(!istype(marine_card_registered))
continue

if(marine != marine_card_registered.resolve())
continue

marine_card.assignment = "[new_name] [marine.job]"
marine_card.name = "[marine_card.registered_name]'s ID Card ([marine_card.assignment])"

/datum/squad/proc/setup_supply_drop_list()
SIGNAL_HANDLER

Expand Down
10 changes: 10 additions & 0 deletions code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ GLOBAL_LIST_INIT(frozen_items, list(SQUAD_MARINE_1 = list(), SQUAD_MARINE_2 = li
/obj/structure/machinery/computer/cryopod/alpha
cryotype = SQUAD_MARINE_1

/obj/structure/machinery/computer/cryopod/alpha/Initialize()
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/obj/structure/machinery/computer/cryopod/alpha/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

cryotype = new_name

/obj/structure/machinery/computer/cryopod/bravo
cryotype = SQUAD_MARINE_2

Expand Down
23 changes: 23 additions & 0 deletions code/game/objects/effects/landmarks/landmarks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@
else
LAZYADD(GLOB.spawns_by_job[job], src)

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/obj/effect/landmark/start/Destroy()
if(job)
if(squad)
Expand All @@ -263,6 +265,17 @@
LAZYREMOVE(GLOB.spawns_by_job[job], src)
return ..()

/obj/effect/landmark/start/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER
if(squad != old_name)
return

LAZYREMOVE(GLOB.spawns_by_squad_and_job, squad)
squad = new_name
LAZYINITLIST(GLOB.spawns_by_squad_and_job)
LAZYINITLIST(GLOB.spawns_by_squad_and_job[squad])
LAZYADD(GLOB.spawns_by_squad_and_job[squad][job], src)

/obj/effect/landmark/start/AISloc
name = "AI"

Expand Down Expand Up @@ -385,6 +398,16 @@
name = "alpha late join"
squad = SQUAD_MARINE_1

/obj/effect/landmark/late_join/alpha/Initialize(mapload, ...)
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/obj/effect/landmark/late_join/alpha/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

squad = new_name

/obj/effect/landmark/late_join/bravo
name = "bravo late join"
squad = SQUAD_MARINE_2
Expand Down
32 changes: 32 additions & 0 deletions code/game/objects/items/devices/radio/encryptionkey.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,38 @@
var/list/tracking_options
var/abstract = FALSE

/obj/item/device/encryptionkey/Initialize(mapload, ...)
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

if(!isnull(channels[SQUAD_MARINE_1]) && SQUAD_MARINE_1 != GLOB.main_platoon_name)
rename_platoon(null, GLOB.main_platoon_name, SQUAD_MARINE_1)

/obj/item/device/encryptionkey/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

var/toggled_channel = channels[old_name]

if(isnull(toggled_channel))
return

channels -= old_name

channels[new_name] = toggled_channel

if(!istype(loc, /obj/item/device/radio/headset))
return

var/obj/item/device/radio/headset/current_headset = loc

var/passed_freq = current_headset.secure_radio_connections[old_name].frequency
current_headset.secure_radio_connections -= old_name

SSradio.remove_object(current_headset, passed_freq)

current_headset.recalculateChannels()

/obj/item/device/encryptionkey/binary
icon_state = "binary_key"
translate_apollo = TRUE
Expand Down
21 changes: 16 additions & 5 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
if(radiochannels[cycled_channel] == frequency)
default_freq = cycled_channel

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

if(SQUAD_MARINE_1 == default_freq && SQUAD_MARINE_1 != GLOB.main_platoon_name)
rename_platoon(null, GLOB.main_platoon_name, SQUAD_MARINE_1)

/obj/item/device/radio/headset/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

set_frequency(frequency)

/obj/item/device/radio/headset/Destroy()
wearer = null
QDEL_NULL_LIST(keys)
Expand Down Expand Up @@ -763,11 +773,6 @@
if(istype(H, /mob/living/carbon/human))
if(H.assigned_squad)
switch(H.assigned_squad.name)
if(SQUAD_MARINE_1)
name = "[SQUAD_MARINE_1] radio headset"
desc = "This is used by [SQUAD_MARINE_1] squad members."
icon_state = "alpha_headset"
frequency = ALPHA_FREQ
if(SQUAD_MARINE_2)
name = "[SQUAD_MARINE_2] radio headset"
desc = "This is used by [SQUAD_MARINE_2] squad members."
Expand All @@ -792,6 +797,12 @@
desc = "This is used by [SQUAD_MARINE_CRYO] squad members."
frequency = CRYO_FREQ

if(H.assigned_squad.name == GLOB.main_platoon_name)
name = "[GLOB.main_platoon_name] radio headset"
desc = "This is used by [GLOB.main_platoon_name] squad members."
icon_state = "alpha_headset"
frequency = ALPHA_FREQ

switch(GET_DEFAULT_ROLE(H.job))
if(JOB_SQUAD_LEADER)
name = "marine leader " + name
Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ var/list/roundstart_mod_verbs = list(
add_verb(src, /client/proc/togglebuildmodeself)
add_verb(src, /client/proc/toggle_game_master)
add_verb(src, /client/proc/toggle_join_xeno)
add_verb(src, /client/proc/game_master_rename_platoon)
if(CLIENT_HAS_RIGHTS(src, R_SERVER))
add_verb(src, admin_verbs_server)
if(CLIENT_HAS_RIGHTS(src, R_DEBUG))
Expand Down Expand Up @@ -359,6 +360,7 @@ var/list/roundstart_mod_verbs = list(
/client/proc/togglebuildmodeself,
/client/proc/toggle_game_master,
/client/proc/toggle_join_xeno,
/client/proc/game_master_rename_platoon,
admin_verbs_admin,
admin_verbs_ban,
admin_verbs_minor_event,
Expand Down
62 changes: 62 additions & 0 deletions code/modules/admin/game_master/extra_buttons/rename_platoon.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

GLOBAL_VAR_INIT(main_platoon_name, SQUAD_MARINE_1)

/// Ability to rename the platoon
/client/proc/game_master_rename_platoon()
set name = "Rename Platoon Override"
set category = "Game Master.Extras"

if(!admin_holder || !check_rights(R_MOD, FALSE))
return

rename_platoon()

/client/proc/commander_rename_platoon()
set name = "Rename Platoon"
set category = "OOC.Commander"

if(GLOB.main_platoon_name != SQUAD_MARINE_1)
to_chat(src, SPAN_NOTICE("The platoon has already been renamed this round."))
return

rename_platoon()

/// Actually renames the platoon
/client/proc/rename_platoon()
var/new_name = tgui_input_text(mob, "New platoon name?", "Platoon Name", GLOB.main_platoon_name)
if(!new_name || !istext(new_name))
return

if(length(new_name) > 10)
to_chat(src, SPAN_NOTICE("The platoon name should be 10 characters or less."))
return

var/old_name = GLOB.main_platoon_name

var/channel = radiochannels[old_name]
radiochannels -= old_name

radiochannels[new_name] = channel

var/list/keys_to_readd = list()

for(var/key in department_radio_keys)
if(department_radio_keys[key] == old_name)
keys_to_readd += key
department_radio_keys -= key

for(var/key in keys_to_readd)
department_radio_keys[key] = new_name

ROLES_SQUAD_ALL -= old_name
ROLES_SQUAD_ALL += new_name

var/list/copy_frozen_platoon_items = GLOB.frozen_items[old_name]
GLOB.frozen_items -= old_name
GLOB.frozen_items[new_name] = copy_frozen_platoon_items

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_PLATOON_NAME_CHANGE, new_name, old_name)

log_admin("[key_name(src)] has renamed the platoon from [GLOB.main_platoon_name] to [new_name].")

GLOB.main_platoon_name = new_name
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// For PvE CM we start without the ability for people to join as xenos. This can be toggled by game masters.
/client/proc/toggle_join_xeno()
set name = "Toggle Player Xeno Joins"
set category = "Game Master"
set category = "Game Master.Extras"

if(!admin_holder || !check_rights(R_MOD, FALSE))
return
Expand Down
6 changes: 3 additions & 3 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@
list("Med", "hudsquad_med"),
list("SG", "hudsquad_gun"),
list("Spc", "hudsquad_spec"),
list("TL", "hudsquad_tl"),
list("SL", "hudsquad_leader"),
list("SqSgt", "hudsquad_tl"),
list("PltSgt", "hudsquad_leader"),
)

for(var/datum/squad/marine/squad in RoleAuthority.squads)
Expand All @@ -297,7 +297,7 @@
background.Crop(25,25,32,32)
background.Scale(16,16)

Insert("squad-[squad]-hud-[iconref[1]]", background)
Insert("squad-[copytext(REF(squad), 2, 12)]-hud-[iconref[1]]", background)
return ..()

/datum/asset/spritesheet/vending_products
Expand Down
9 changes: 5 additions & 4 deletions code/modules/clothing/head/head.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@
if(istype(H))
if(H.assigned_squad)
switch(H.assigned_squad.name)
if(SQUAD_MARINE_1)
icon_state = "beret_alpha"
desc = "Often found atop heads, slightly less found on those still attached."
if(SQUAD_MARINE_2)
icon_state = "beret_bravo"
desc = "It has quite a lot of debris on it, the person wearing this probably moves less than a wall."
Expand All @@ -120,6 +117,10 @@
if(SQUAD_MARINE_INTEL)
icon_state = "beret_intel"
desc = "Looks more intellegent than the person wearing it."

if(H.assigned_squad.name == GLOB.main_platoon_name)
icon_state = "beret_alpha"
desc = "Often found atop heads, slightly less found on those still attached."
else
icon_state = "beret"
desc = initial(desc)
Expand Down Expand Up @@ -193,7 +194,7 @@
return ..()

/obj/item/clothing/head/headband/squad/proc/adapt_to_squad()
var/squad_color = "gray"
var/squad_color = "Delta"
var/mob/living/carbon/human/wearer = recursive_holder_check(src)
if(istype(wearer) && wearer.assigned_squad)
var/squad_name = lowertext(wearer.assigned_squad.name)
Expand Down
10 changes: 10 additions & 0 deletions code/modules/cm_marines/overwatch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,16 @@
icon_state = "alphadrop"
squad = SQUAD_MARINE_1

/obj/structure/supply_drop/alpha/Initialize(mapload, ...)
. = ..()

RegisterSignal(SSdcs, COMSIG_GLOB_PLATOON_NAME_CHANGE, PROC_REF(rename_platoon))

/obj/structure/supply_drop/alpha/proc/rename_platoon(datum/source, new_name, old_name)
SIGNAL_HANDLER

squad = new_name

/obj/structure/supply_drop/bravo
icon_state = "bravodrop"
squad = SQUAD_MARINE_2
Expand Down
Loading