makes radios use paths instead of new (#70252)

* makes radios initialize in Initialize instead of init()
This commit is contained in:
Fikou
2022-10-03 09:46:02 +02:00
committed by GitHub
parent deff8d5d6f
commit 9dddcb6f48
6 changed files with 59 additions and 148 deletions
@@ -57,6 +57,8 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/Initialize(mapload)
. = ..()
if(ispath(keyslot2))
keyslot2 = new keyslot2()
set_listening(TRUE)
recalculateChannels()
possibly_deactivate_in_loc()
@@ -72,7 +74,8 @@ GLOBAL_LIST_INIT(channel_tokens, list(
possibly_deactivate_in_loc()
/obj/item/radio/headset/Destroy()
QDEL_NULL(keyslot2)
if(istype(keyslot2))
QDEL_NULL(keyslot2)
return ..()
/obj/item/radio/headset/ui_data(mob/user)
@@ -123,18 +126,13 @@ GLOBAL_LIST_INIT(channel_tokens, list(
command = TRUE
/obj/item/radio/headset/binary
/obj/item/radio/headset/binary/Initialize(mapload)
. = ..()
qdel(keyslot)
keyslot = new /obj/item/encryptionkey/binary
recalculateChannels()
keyslot = /obj/item/encryptionkey/binary
/obj/item/radio/headset/headset_sec
name = "security radio headset"
desc = "This is used by your elite security force."
icon_state = "sec_headset"
keyslot = new /obj/item/encryptionkey/headset_sec
keyslot = /obj/item/encryptionkey/headset_sec
/obj/item/radio/headset/headset_sec/alt
name = "security bowman headset"
@@ -150,49 +148,49 @@ GLOBAL_LIST_INIT(channel_tokens, list(
name = "engineering radio headset"
desc = "When the engineers wish to chat like girls."
icon_state = "eng_headset"
keyslot = new /obj/item/encryptionkey/headset_eng
keyslot = /obj/item/encryptionkey/headset_eng
/obj/item/radio/headset/headset_rob
name = "robotics radio headset"
desc = "Made specifically for the roboticists, who cannot decide between departments."
icon_state = "rob_headset"
keyslot = new /obj/item/encryptionkey/headset_rob
keyslot = /obj/item/encryptionkey/headset_rob
/obj/item/radio/headset/headset_med
name = "medical radio headset"
desc = "A headset for the trained staff of the medbay."
icon_state = "med_headset"
keyslot = new /obj/item/encryptionkey/headset_med
keyslot = /obj/item/encryptionkey/headset_med
/obj/item/radio/headset/headset_sci
name = "science radio headset"
desc = "A sciency headset. Like usual."
icon_state = "sci_headset"
keyslot = new /obj/item/encryptionkey/headset_sci
keyslot = /obj/item/encryptionkey/headset_sci
/obj/item/radio/headset/headset_medsci
name = "medical research radio headset"
desc = "A headset that is a result of the mating between medical and science."
icon_state = "medsci_headset"
keyslot = new /obj/item/encryptionkey/headset_medsci
keyslot = /obj/item/encryptionkey/headset_medsci
/obj/item/radio/headset/headset_srvsec
name = "law and order headset"
desc = "In the criminal justice headset, the encryption key represents two separate but equally important groups. Sec, who investigate crime, and Service, who provide services. These are their comms."
icon_state = "srvsec_headset"
keyslot = new /obj/item/encryptionkey/headset_srvsec
keyslot = /obj/item/encryptionkey/headset_srvsec
/obj/item/radio/headset/headset_srvmed
name = "psychology headset"
desc = "A headset allowing the wearer to communicate with medbay and service."
icon_state = "med_headset"
keyslot = new /obj/item/encryptionkey/headset_srvmed
keyslot = /obj/item/encryptionkey/headset_srvmed
/obj/item/radio/headset/headset_com
name = "command radio headset"
desc = "A headset with a commanding channel."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/headset_com
keyslot = /obj/item/encryptionkey/headset_com
/obj/item/radio/headset/heads
command = TRUE
@@ -201,7 +199,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
name = "\proper the captain's headset"
desc = "The headset of the king."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/captain
keyslot = /obj/item/encryptionkey/heads/captain
/obj/item/radio/headset/heads/captain/alt
name = "\proper the captain's bowman headset"
@@ -217,13 +215,13 @@ GLOBAL_LIST_INIT(channel_tokens, list(
name = "\proper the research director's headset"
desc = "Headset of the fellow who keeps society marching towards technological singularity."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/rd
keyslot = /obj/item/encryptionkey/heads/rd
/obj/item/radio/headset/heads/hos
name = "\proper the head of security's headset"
desc = "The headset of the man in charge of keeping order and protecting the station."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/hos
keyslot = /obj/item/encryptionkey/heads/hos
/obj/item/radio/headset/heads/hos/alt
name = "\proper the head of security's bowman headset"
@@ -239,57 +237,57 @@ GLOBAL_LIST_INIT(channel_tokens, list(
name = "\proper the chief engineer's headset"
desc = "The headset of the guy in charge of keeping the station powered and undamaged."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/ce
keyslot = /obj/item/encryptionkey/heads/ce
/obj/item/radio/headset/heads/cmo
name = "\proper the chief medical officer's headset"
desc = "The headset of the highly trained medical chief."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/cmo
keyslot = /obj/item/encryptionkey/heads/cmo
/obj/item/radio/headset/heads/hop
name = "\proper the head of personnel's headset"
desc = "The headset of the guy who will one day be captain."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/hop
keyslot = /obj/item/encryptionkey/heads/hop
/obj/item/radio/headset/heads/qm
name = "\proper the quartermaster's headset"
desc = "The headset of the guy who runs the cargo department."
icon_state = "com_headset"
keyslot = new /obj/item/encryptionkey/heads/qm
keyslot = /obj/item/encryptionkey/heads/qm
/obj/item/radio/headset/headset_cargo
name = "supply radio headset"
desc = "A headset used by the QM's slaves."
icon_state = "cargo_headset"
keyslot = new /obj/item/encryptionkey/headset_cargo
keyslot = /obj/item/encryptionkey/headset_cargo
/obj/item/radio/headset/headset_cargo/mining
name = "mining radio headset"
desc = "Headset used by shaft miners."
icon_state = "mine_headset"
keyslot = new /obj/item/encryptionkey/headset_mining
keyslot = /obj/item/encryptionkey/headset_mining
/obj/item/radio/headset/headset_srv
name = "service radio headset"
desc = "Headset used by the service staff, tasked with keeping the station full, happy and clean."
icon_state = "srv_headset"
keyslot = new /obj/item/encryptionkey/headset_service
keyslot = /obj/item/encryptionkey/headset_service
/obj/item/radio/headset/headset_cent
name = "\improper CentCom headset"
desc = "A headset used by the upper echelons of Nanotrasen."
icon_state = "cent_headset"
keyslot = new /obj/item/encryptionkey/headset_com
keyslot2 = new /obj/item/encryptionkey/headset_cent
keyslot = /obj/item/encryptionkey/headset_cent
keyslot2 = /obj/item/encryptionkey/headset_com
/obj/item/radio/headset/headset_cent/empty
keyslot = null
keyslot2 = null
/obj/item/radio/headset/headset_cent/commander
keyslot = new /obj/item/encryptionkey/heads/captain
keyslot2 = /obj/item/encryptionkey/heads/captain
/obj/item/radio/headset/headset_cent/alt
name = "\improper CentCom bowman headset"
@@ -81,6 +81,8 @@
secure_radio_connections = list()
. = ..()
if(ispath(keyslot))
keyslot = new keyslot()
for(var/ch_name in channels)
secure_radio_connections[ch_name] = add_radio(src, GLOB.radiochannels[ch_name])
@@ -94,7 +96,8 @@
/obj/item/radio/Destroy()
remove_radio_all(src) //Just to be sure
QDEL_NULL(wires)
QDEL_NULL(keyslot)
if(istype(keyslot))
QDEL_NULL(keyslot)
return ..()
/obj/item/radio/proc/set_frequency(new_frequency)
@@ -141,7 +144,7 @@
/obj/item/radio/proc/make_syndie() // Turns normal radios into Syndicate radios!
qdel(keyslot)
keyslot = new /obj/item/encryptionkey/syndicate
keyslot = new /obj/item/encryptionkey/syndicate()
syndie = TRUE
recalculateChannels()
@@ -469,12 +472,6 @@
user.visible_message(span_suicide("[user] starts bouncing [src] off [user.p_their()] head! It looks like [user.p_theyre()] trying to commit suicide!"))
return BRUTELOSS
/obj/item/radio/Destroy()
remove_radio_all(src) //Just to be sure
QDEL_NULL(wires)
QDEL_NULL(keyslot)
return ..()
/obj/item/radio/proc/end_emp_effect(curremp)
if(emped != curremp) //Don't fix it if it's been EMP'd again
return FALSE
@@ -503,7 +500,7 @@
/obj/item/radio/borg/syndicate
syndie = TRUE
keyslot = new /obj/item/encryptionkey/syndicate
keyslot = /obj/item/encryptionkey/syndicate
/obj/item/radio/borg/syndicate/Initialize(mapload)
. = ..()
+1 -1
View File
@@ -178,7 +178,7 @@
log_silicon("[key_name(user)] removed the [channel] radio channel from [key_name(borg)].")
else // We're adding a channel
if (!borg.radio.keyslot) // Assert that an encryption key exists
borg.radio.keyslot = new (borg.radio)
borg.radio.keyslot = new()
borg.radio.keyslot.channels[channel] = 1
if (channel == RADIO_CHANNEL_SYNDICATE)
borg.radio.keyslot.syndie = TRUE
@@ -643,7 +643,7 @@ Congratulations! You are now trained for invasive xenobiology research!"}
icon = 'icons/obj/abductor.dmi'
icon_state = "abductor_headset"
inhand_icon_state = "abductor_headset"
keyslot2 = new /obj/item/encryptionkey/heads/captain
keyslot2 = /obj/item/encryptionkey/heads/captain
/obj/item/radio/headset/abductor/Initialize(mapload)
. = ..()
+16 -100
View File
@@ -15,14 +15,18 @@
gloves = /obj/item/clothing/gloves/combat
mask = /obj/item/clothing/mask/gas/sechailer
shoes = /obj/item/clothing/shoes/combat/swat
var/additional_radio
/datum/outfit/centcom/ert/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
var/obj/item/radio/headset/R = H.ears
R.set_frequency(FREQ_CENTCOM)
R.freqlock = TRUE
if(additional_radio)
R.keyslot2 = new additional_radio()
R.recalculateChannels()
var/obj/item/card/id/W = H.wear_id
if(W)
@@ -45,15 +49,7 @@
belt = /obj/item/storage/belt/security/full
glasses = /obj/item/clothing/glasses/hud/security/sunglasses
l_pocket = /obj/item/switchblade
/datum/outfit/centcom/ert/commander/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/heads/captain
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/captain
/datum/outfit/centcom/ert/commander/alert
name = "ERT Commander - High Alert"
@@ -81,16 +77,7 @@
belt = /obj/item/storage/belt/security/full
glasses = /obj/item/clothing/glasses/hud/security/sunglasses
gloves = /obj/item/clothing/gloves/tackler/combat/insulated
/datum/outfit/centcom/ert/security/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/heads/hos
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/hos
/datum/outfit/centcom/ert/security/alert
name = "ERT Security - High Alert"
@@ -119,16 +106,7 @@
glasses = /obj/item/clothing/glasses/hud/health
l_hand = /obj/item/storage/medkit/regular
r_hand = /obj/item/gun/energy/e_gun
/datum/outfit/centcom/ert/medic/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/heads/cmo
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/cmo
/datum/outfit/centcom/ert/medic/alert
name = "ERT Medic - High Alert"
@@ -159,16 +137,7 @@
belt = /obj/item/storage/belt/utility/full/powertools
glasses = /obj/item/clothing/glasses/meson/engine
l_pocket = /obj/item/rcd_ammo/large
/datum/outfit/centcom/ert/engineer/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/heads/ce
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/ce
/datum/outfit/centcom/ert/engineer/alert
name = "ERT Engineer - High Alert"
@@ -263,14 +232,7 @@
/obj/item/nullrod = 1,
/obj/item/storage/box/survival/engineer = 1,
)
/datum/outfit/centcom/ert/chaplain/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/heads/hop
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/hop
/datum/outfit/centcom/ert/chaplain/inquisitor
name = "Inquisition Chaplain"
@@ -302,16 +264,7 @@
l_pocket = /obj/item/grenade/chem_grenade/cleaner
r_pocket = /obj/item/grenade/chem_grenade/cleaner
l_hand = /obj/item/storage/bag/trash/bluespace
/datum/outfit/centcom/ert/janitor/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/headset_service
R.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/hop
/datum/outfit/centcom/ert/janitor/heavy
name = "ERT Janitor - Heavy Duty"
@@ -342,14 +295,12 @@
shoes = /obj/item/clothing/shoes/clown_shoes/combat
l_pocket = /obj/item/food/grown/banana
r_pocket = /obj/item/bikehorn/golden
additional_radio = /obj/item/encryptionkey/heads/hop
/datum/outfit/centcom/ert/clown/post_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/R = H.ears
R.keyslot = new /obj/item/encryptionkey/headset_service
R.recalculateChannels()
ADD_TRAIT(H, TRAIT_NAIVE, INNATE_TRAIT)
H.dna.add_mutation(/datum/mutation/human/clumsy)
for(var/datum/mutation/human/clumsy/M in H.dna.mutations)
@@ -558,15 +509,7 @@
uniform = /obj/item/clothing/under/rank/centcom/military
mask = /obj/item/clothing/mask/gas/sechailer
head = /obj/item/clothing/head/helmet/marine
/datum/outfit/centcom/ert/marine/post_equip(mob/living/carbon/human/equipper, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/headset = equipper.ears
headset.keyslot = new /obj/item/encryptionkey/heads/captain
headset.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/captain
/datum/outfit/centcom/ert/marine/security
name = "Marine Heavy"
@@ -575,16 +518,7 @@
suit = /obj/item/clothing/suit/armor/vest/marine/security
glasses = /obj/item/clothing/glasses/hud/security/sunglasses
head = /obj/item/clothing/head/helmet/marine/security
/datum/outfit/centcom/ert/marine/security/post_equip(mob/living/carbon/human/equipper, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/headset = equipper.ears
headset.keyslot = new /obj/item/encryptionkey/heads/hos
headset.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/hos
/datum/outfit/centcom/ert/marine/medic
name = "Marine Medic"
@@ -602,16 +536,7 @@
)
belt = /obj/item/storage/belt/medical/paramedic
glasses = /obj/item/clothing/glasses/hud/health/sunglasses
/datum/outfit/centcom/ert/marine/medic/post_equip(mob/living/carbon/human/equipper, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/headset = equipper.ears
headset.keyslot = new /obj/item/encryptionkey/heads/cmo
headset.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/cmo
/datum/outfit/centcom/ert/marine/engineer
name = "Marine Engineer"
@@ -624,13 +549,4 @@
uniform = /obj/item/clothing/under/rank/centcom/military/eng
belt = /obj/item/storage/belt/utility/full/powertools/rcd
glasses = /obj/item/clothing/glasses/hud/diagnostic/sunglasses
/datum/outfit/centcom/ert/marine/engineer/post_equip(mob/living/carbon/human/equipper, visualsOnly = FALSE)
..()
if(visualsOnly)
return
var/obj/item/radio/headset = equipper.ears
headset.keyslot = new /obj/item/encryptionkey/heads/ce
headset.recalculateChannels()
additional_radio = /obj/item/encryptionkey/heads/ce
@@ -241,19 +241,19 @@ GLOBAL_LIST_EMPTY(security_officer_distribution)
recalculateChannels()
/obj/item/radio/headset/headset_sec/alt/department/engi
keyslot = new /obj/item/encryptionkey/headset_sec
keyslot2 = new /obj/item/encryptionkey/headset_eng
keyslot = /obj/item/encryptionkey/headset_sec
keyslot2 = /obj/item/encryptionkey/headset_eng
/obj/item/radio/headset/headset_sec/alt/department/supply
keyslot = new /obj/item/encryptionkey/headset_sec
keyslot2 = new /obj/item/encryptionkey/headset_cargo
keyslot = /obj/item/encryptionkey/headset_sec
keyslot2 = /obj/item/encryptionkey/headset_cargo
/obj/item/radio/headset/headset_sec/alt/department/med
keyslot = new /obj/item/encryptionkey/headset_sec
keyslot2 = new /obj/item/encryptionkey/headset_med
keyslot = /obj/item/encryptionkey/headset_sec
keyslot2 = /obj/item/encryptionkey/headset_med
/obj/item/radio/headset/headset_sec/alt/department/sci
keyslot = new /obj/item/encryptionkey/headset_sec
keyslot2 = new /obj/item/encryptionkey/headset_sci
keyslot = /obj/item/encryptionkey/headset_sec
keyslot2 = /obj/item/encryptionkey/headset_sci
/// Returns the distribution of splitting the given security officers into departments.
/// Return value is an assoc list of candidate => SEC_DEPT_*.