Skip to content

Commit 4c74b78

Browse files
authored
migrate all /obj/item from /New() to /Initialize() (ParadiseSS13#31232)
* migrate all /obj/item from /New() to /Initialize() * move GLOB.chemical_reagents_list creation to /world/New() * review * oops * autodoc a smart var
1 parent a0ed4b0 commit 4c74b78

89 files changed

Lines changed: 321 additions & 362 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code/__HELPERS/global_lists.dm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158

159159
GLOB.emote_list = init_emote_list()
160160

161+
GLOB.chemical_reagents_list = init_reagent_list()
162+
161163
// Set up PCWJ recipes
162164
initialize_cooking_recipes()
163165

@@ -240,3 +242,10 @@
240242
.[E.key_third_person] = list(E)
241243
else
242244
.[E.key_third_person] |= E
245+
246+
/// Initialises all of /datum/reagent into a list indexed by reagent id.
247+
/proc/init_reagent_list()
248+
. = list()
249+
for(var/path in subtypesof(/datum/reagent))
250+
var/datum/reagent/R = new path()
251+
.[R.id] = R

code/game/gamemodes/nuclear/nuclearbomb.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ GLOBAL_VAR(bomb_set)
730730
. = ..()
731731
. += SPAN_WARNING("This disk has had its safeties removed. It will not teleport back to the station if taken too far away.")
732732

733-
/obj/item/disk/nuclear/New()
734-
..()
733+
/obj/item/disk/nuclear/Initialize(mapload)
734+
. = ..()
735735
if(restricted_to_station)
736736
START_PROCESSING(SSobj, src)
737737
if(!training)

code/game/gamemodes/nuclear/pinpointer.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
var/icon_medium = "pinonmedium"
4040
var/icon_far = "pinonfar"
4141

42-
/obj/item/pinpointer/New()
43-
..()
42+
/obj/item/pinpointer/Initialize(mapload)
43+
. = ..()
4444
GLOB.pinpointer_list += src
4545

4646
/obj/item/pinpointer/Destroy()

code/game/gamemodes/wizard/artefact.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ GLOBAL_LIST_EMPTY(multiverse)
273273
var/duplicate_self = 0 //Do we want the species randomized along with equipment should the user be duplicated in their entirety?
274274
var/sword_type = /obj/item/multisword //type of sword to equip.
275275

276-
/obj/item/multisword/New()
277-
..()
276+
/obj/item/multisword/Initialize(mapload)
277+
. = ..()
278278
GLOB.multiverse |= src
279279

280280

code/game/gamemodes/wizard/godhand.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
var/on_use_sound = null
1717
var/datum/spell/touch/attached_spell
1818

19-
/obj/item/melee/touch_attack/New(spell)
19+
/obj/item/melee/touch_attack/Initialize(mapload, spell)
20+
. = ..()
2021
attached_spell = spell
21-
..()
2222

2323
/obj/item/melee/touch_attack/Destroy()
2424
if(attached_spell)

code/game/gamemodes/wizard/spellbook.dm

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@
722722
var/list/item_categories = list("Artefacts", "Weapons and Armors", "Staves", "Summons")
723723
var/list/loadout_categories = list("Standard", "Unique")
724724

725-
/obj/item/spellbook/proc/initialize()
725+
/obj/item/spellbook/proc/create_spellbook()
726726
var/entry_types = subtypesof(/datum/spellbook_entry) - /datum/spellbook_entry/item - /datum/spellbook_entry/summon - /datum/spellbook_entry/loadout
727727
for(var/T in entry_types)
728728
var/datum/spellbook_entry/E = new T
@@ -735,9 +735,9 @@
735735
main_tab = main_categories[1]
736736
tab = categories[1]
737737

738-
/obj/item/spellbook/New()
739-
..()
740-
initialize()
738+
/obj/item/spellbook/Initialize(mapload)
739+
. = ..()
740+
create_spellbook()
741741

742742
/obj/item/spellbook/attackby__legacy__attackchain(obj/item/O as obj, mob/user as mob, params)
743743
if(istype(O, /obj/item/contract))
@@ -970,13 +970,10 @@
970970
uses = 1
971971
desc = "This template spellbook was never meant for the eyes of man..."
972972

973-
/obj/item/spellbook/oneuse/New()
974-
..()
973+
/obj/item/spellbook/oneuse/Initialize(mapload)
974+
. = ..()
975975
name += spellname
976976

977-
/obj/item/spellbook/oneuse/initialize() //No need to init
978-
return
979-
980977
/obj/item/spellbook/oneuse/attack_self__legacy__attackchain(mob/user)
981978
var/datum/spell/S = new spell
982979
for(var/datum/spell/knownspell in user.mind.spell_list)
@@ -1155,7 +1152,7 @@
11551152
/obj/item/spellbook/oneuse/random
11561153
icon_state = "random_book"
11571154

1158-
/obj/item/spellbook/oneuse/random/initialize()
1155+
/obj/item/spellbook/oneuse/random/create_spellbook()
11591156
. = ..()
11601157
var/static/list/banned_spells = typesof(/obj/item/spellbook/oneuse/mime, /obj/item/spellbook/oneuse/emp)
11611158
var/real_type = pick(subtypesof(/obj/item/spellbook/oneuse) - banned_spells)

code/game/machinery/computer/communications.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@
595595
SSshuttle.autoEvac()
596596
return ..()
597597

598-
/obj/item/circuitboard/communications/New()
598+
/obj/item/circuitboard/communications/Initialize(mapload)
599+
. = ..()
599600
GLOB.shuttle_caller_list += src
600-
..()
601601

602602
/obj/item/circuitboard/communications/Destroy()
603603
GLOB.shuttle_caller_list -= src

code/game/machinery/dye_generator.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
w_class = WEIGHT_CLASS_TINY
7979
var/dye_color = "#FFFFFF"
8080

81-
/obj/item/hair_dye_bottle/New()
82-
..()
81+
/obj/item/hair_dye_bottle/Initialize(mapload)
82+
. = ..()
8383
update_icon(UPDATE_OVERLAYS)
8484

8585
/obj/item/hair_dye_bottle/update_overlays()

code/game/objects/items.dm

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,6 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
199199

200200
scatter_distance = 5
201201

202-
/obj/item/New()
203-
..()
204-
205-
if(!hitsound)
206-
if(damtype == "fire")
207-
hitsound = 'sound/items/welder.ogg'
208-
if(damtype == "brute")
209-
hitsound = "swing_hit"
210-
LAZYINITLIST(attack_verb)
211-
if(!move_resist)
212-
determine_move_resist()
213-
214202
/obj/item/Initialize(mapload)
215203
. = ..()
216204
for(var/path in actions_types)
@@ -219,6 +207,14 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
219207
in_storage = TRUE
220208
if(sharp)
221209
AddComponent(/datum/component/surgery_initiator)
210+
if(!hitsound)
211+
if(damtype == "fire")
212+
hitsound = 'sound/items/welder.ogg'
213+
if(damtype == "brute")
214+
hitsound = "swing_hit"
215+
LAZYINITLIST(attack_verb)
216+
if(!move_resist)
217+
determine_move_resist()
222218

223219
/// This proc is used to add text for items with ABSTRACT flag after default examine text.
224220
/obj/item/proc/customised_abstract_text(mob/living/carbon/owner)

code/game/objects/items/RCL.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@
152152
last = loaded.place_turf(get_turf(loc), user, turn(user.dir, 180))
153153
is_empty(user) //If we've run out, display message
154154

155-
/obj/item/rcl/pre_loaded/New() //Comes preloaded with cable, for testing stuff
156-
..()
155+
/obj/item/rcl/pre_loaded/Initialize(mapload) // Comes preloaded with cable, for testing stuff
156+
. = ..()
157157
loaded = new()
158158
loaded.max_amount = max_amount
159159
loaded.amount = max_amount

0 commit comments

Comments
 (0)