Skip to content

Commit

Permalink
[MIRROR] LateInitialize is not allowed to call parent anymore (#1876)
Browse files Browse the repository at this point in the history
* LateInitialize is not allowed to call parent anymore (#82540)

## About The Pull Request

I've seen a few cases in the past where LateInitialize is done cause of
the init return value being set to do so for no real reason, I thought I
should try to avoid that by ensuring LateInitialize isn't ever called
without overriding.

This fixes a ton of machine's LateInitialize not calling parent
(mechpad, door buttons, message monitor, a lot of tram machines,
abductor console, holodeck computer & disposal bin), avoiding having to
set itself up to be connected to power. If they were intended to not
connect to power, they should be using ``NO_POWER_USE`` instead.

Also removes a ton of returns to LateInit when it's already getting it
from parent regardless (many cases of that in machine code).

## Why It's Good For The Game

I think this is better for coding standard reasons as well as just
making sure we're not calling this proc on things that does absolutely
nothing with them. A machine not using power can be seen evidently not
using power with ``NO_POWER_USE``, not so much if it's LateInitialize
not calling parent.

## Changelog

:cl:
fix: Mech pads, door buttons, message monitors, tram machines, abductor
consoles & holodeck computers now use power.
/:cl:

* LateInitialize is not allowed to call parent anymore

* Modular updates

---------

Co-authored-by: John Willard <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Apr 10, 2024
1 parent 69c5a41 commit 16e4d77
Show file tree
Hide file tree
Showing 75 changed files with 124 additions and 198 deletions.
2 changes: 2 additions & 0 deletions code/game/atom/atoms_initializing_EXPENSIVE.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,5 @@
*/
/atom/proc/LateInitialize()
set waitfor = FALSE
SHOULD_CALL_PARENT(FALSE)
stack_trace("[src] ([type]) called LateInitialize but has nothing on it!")
22 changes: 16 additions & 6 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,8 @@
return INITIALIZE_HINT_LATELOAD

/obj/machinery/LateInitialize()
. = ..()
power_change()
if(use_power == NO_POWER_USE)
return
update_current_power_usage()
setup_area_power_relationship()
SHOULD_NOT_OVERRIDE(TRUE)
post_machine_initialize()

/obj/machinery/Destroy(force)
SSmachines.unregister_machine(src)
Expand All @@ -200,6 +196,20 @@

return ..()

/**
* Called in LateInitialize meant to be the machine replacement to it
* This sets up power for the machine and requires parent be called,
* ensuring power works on all machines unless exempted with NO_POWER_USE.
* This is the proc to override if you want to do anything in LateInitialize.
*/
/obj/machinery/proc/post_machine_initialize()
SHOULD_CALL_PARENT(TRUE)
power_change()
if(use_power == NO_POWER_USE)
return
update_current_power_usage()
setup_area_power_relationship()

/**
* proc to call when the machine starts to require power after a duration of not requiring power
* sets up power related connections to its area if it exists and becomes area sensitive
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

/**
* Autonaming camera
* Automatically names itself after the area it's in during LateInitialize,
* Automatically names itself after the area it's in during post_machine_initialize,
* good for mappers who don't want to manually name them all.
*/
/obj/machinery/camera/autoname
Expand All @@ -76,7 +76,7 @@
..()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/camera/autoname/LateInitialize()
/obj/machinery/camera/autoname/post_machine_initialize()
. = ..()
var/static/list/autonames_in_areas = list()
var/area/camera_area = get_area(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/civilian_bounties.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
pad_ref = WEAKREF(I.buffer)
return TRUE

/obj/machinery/computer/piratepad_control/civilian/LateInitialize()
/obj/machinery/computer/piratepad_control/civilian/post_machine_initialize()
. = ..()
if(cargo_hold_id)
for(var/obj/machinery/piratepad/civilian/C as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/piratepad/civilian))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/dna_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
// Set the default tgui state
set_default_state()

/obj/machinery/computer/scan_consolenew/LateInitialize()
/obj/machinery/computer/scan_consolenew/post_machine_initialize()
. = ..()
// Link machine with research techweb. Used for discovering and accessing
// already discovered mutations
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/computer/mechlaunchpad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
SIGNAL_HANDLER
connected_mechpad = null

/obj/machinery/computer/mechpad/LateInitialize()
/obj/machinery/computer/mechpad/post_machine_initialize()
. = ..()
for(var/obj/machinery/mechpad/pad as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/mechpad))
if(pad == connected_mechpad)
continue
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/operating_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
find_table()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/computer/operating/LateInitialize()
/obj/machinery/computer/operating/post_machine_initialize()
. = ..()
if(!CONFIG_GET(flag/no_default_techweb_link) && !linked_techweb)
CONNECT_TO_RND_SERVER_ROUNDSTART(linked_techweb, src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@

return ..()

/obj/machinery/door/airlock/external/LateInitialize()
/obj/machinery/door/airlock/external/post_machine_initialize()
. = ..()
if(space_dir)
unres_sides |= space_dir
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
RegisterSignal(src, COMSIG_MACHINERY_POWER_LOST, PROC_REF(on_power_loss))
return INITIALIZE_HINT_LATELOAD

/obj/machinery/door/firedoor/LateInitialize()
/obj/machinery/door/firedoor/post_machine_initialize()
. = ..()
RegisterSignal(src, COMSIG_MERGER_ADDING, PROC_REF(merger_adding))
RegisterSignal(src, COMSIG_MERGER_REMOVING, PROC_REF(merger_removing))
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/embedded_controller/access_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
..()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/door_buttons/LateInitialize()
/obj/machinery/door_buttons/post_machine_initialize()
. = ..()
find_objects_by_tag()

/obj/machinery/door_buttons/emag_act(mob/user, obj/item/card/emag/emag_card)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

var/processing = FALSE

/obj/machinery/airlock_controller/LateInitialize()
/obj/machinery/airlock_controller/post_machine_initialize()
. = ..()

var/obj/machinery/door/interior_door = GLOB.objects_by_id_tag[interior_door_tag]
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/incident_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/incident_display/tram, 32)
..()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/incident_display/LateInitialize()
/obj/machinery/incident_display/post_machine_initialize()
. = ..()
GLOB.map_delamination_counters += src
update_delam_count(SSpersistence.rounds_since_engine_exploded, SSpersistence.delam_highscore)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/recycler.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
. = ..()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/recycler/LateInitialize()
/obj/machinery/recycler/post_machine_initialize()
. = ..()
update_appearance(UPDATE_ICON)
req_one_access = SSid_access.get_region_access_list(list(REGION_ALL_STATION, REGION_CENTCOM))
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/telecomms/computers/message.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
GLOB.telecomms_list += src
return INITIALIZE_HINT_LATELOAD

/obj/machinery/computer/message_monitor/LateInitialize()
/obj/machinery/computer/message_monitor/post_machine_initialize()
. = ..()
//Is the server isn't linked to a server, and there's a server available, default it to the first one in the list.
if(!linkedServer)
for(var/obj/machinery/telecomms/message_server/message_server in GLOB.telecomms_list)
Expand Down Expand Up @@ -280,12 +281,11 @@
name = "monitor decryption key"

/obj/item/paper/monitorkey/Initialize(mapload, obj/machinery/telecomms/message_server/server)
..()
. = ..()
if (server)
print(server)
return INITIALIZE_HINT_NORMAL
else
return INITIALIZE_HINT_LATELOAD
return INITIALIZE_HINT_LATELOAD

/**
* Handles printing the monitor key for a given server onto this piece of paper.
Expand Down
5 changes: 2 additions & 3 deletions code/game/machinery/telecomms/telecomunications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ GLOBAL_LIST_EMPTY(telecomms_list)
if(mapload && autolinkers.len)
return INITIALIZE_HINT_LATELOAD

/obj/machinery/telecomms/LateInitialize()
..()

/obj/machinery/telecomms/post_machine_initialize()
. = ..()
for(var/obj/machinery/telecomms/telecomms_machine in GLOB.telecomms_list)
if (long_range_link || IN_GIVEN_RANGE(src, telecomms_machine, 20))
add_automatic_link(telecomms_machine)
Expand Down
2 changes: 0 additions & 2 deletions code/game/objects/effects/landmarks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ INITIALIZE_IMMEDIATE(/obj/effect/landmark/start/new_player)
return ..()

/obj/effect/landmark/start/hangover/LateInitialize()
. = ..()
if(HAS_TRAIT(SSstation, STATION_TRAIT_BIRTHDAY))
party_debris += new /obj/effect/decal/cleanable/confetti(get_turf(src)) //a birthday celebration can also be a hangover
var/list/bonus_confetti = GLOB.alldirs
Expand Down Expand Up @@ -593,7 +592,6 @@ INITIALIZE_IMMEDIATE(/obj/effect/landmark/start/new_player)
return INITIALIZE_HINT_LATELOAD

/obj/effect/landmark/navigate_destination/LateInitialize()
. = ..()
if(!location)
var/obj/machinery/door/airlock/A = locate(/obj/machinery/door/airlock) in loc
location = A ? format_text(A.name) : get_area_name(src, format_text = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/puzzle_pieces.dm
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
SSqueuelinks.add_to_queue(src, id, late_initialize_pop ? 0 : queue_size)
return late_initialize_pop ? INITIALIZE_HINT_LATELOAD : .

/obj/machinery/puzzle/LateInitialize()
/obj/machinery/puzzle/post_machine_initialize()
. = ..()
if(late_initialize_pop && id && SSqueuelinks.queues[id])
SSqueuelinks.pop_link(id)
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/structures/bonfire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@

// Late init so that we can wait for air to exist in lazyloaded templates
/obj/structure/bonfire/prelit/LateInitialize()
. = ..()
start_burning()

#undef BONFIRE_FIRE_STACK_STRENGTH
1 change: 0 additions & 1 deletion code/game/objects/structures/broken_flooring.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
return INITIALIZE_HINT_LATELOAD

/obj/structure/broken_flooring/LateInitialize()
. = ..()
var/turf/turf = get_turf(src)
if(!isplatingturf(turf) && !always_floorplane) // Render as trash if not on plating
plane = GAME_PLANE
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/structures/crates_lockers/closets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)
update_appearance()

/obj/structure/closet/LateInitialize()
. = ..()
if(!opened && is_maploaded)
take_contents()

Expand Down
28 changes: 14 additions & 14 deletions code/game/objects/structures/crates_lockers/crates.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@
var/static/list/crate_paint_jobs
if(isnull(crate_paint_jobs))
crate_paint_jobs = list(
"Internals" = list("icon_state" = "o2crate"),
"Medical" = list("icon_state" = "medical"),
"Medical Plus" = list("icon_state" = "medicalcrate"),
"Radiation" = list("icon_state" = "radiation"),
"Hydrophonics" = list("icon_state" = "hydrocrate"),
"Science" = list("icon_state" = "scicrate"),
"Robotics" = list("icon_state" = "robo"),
"Solar" = list("icon_state" = "engi_e_crate"),
"Engineering" = list("icon_state" = "engi_crate"),
"Atmospherics" = list("icon_state" = "atmos"),
"Cargo" = list("icon_state" = "cargo"),
"Mining" = list("icon_state" = "mining"),
"Command" = list("icon_state" = "centcom")
)
"Internals" = list("icon_state" = "o2crate"),
"Medical" = list("icon_state" = "medical"),
"Medical Plus" = list("icon_state" = "medicalcrate"),
"Radiation" = list("icon_state" = "radiation"),
"Hydrophonics" = list("icon_state" = "hydrocrate"),
"Science" = list("icon_state" = "scicrate"),
"Robotics" = list("icon_state" = "robo"),
"Solar" = list("icon_state" = "engi_e_crate"),
"Engineering" = list("icon_state" = "engi_crate"),
"Atmospherics" = list("icon_state" = "atmos"),
"Cargo" = list("icon_state" = "cargo"),
"Mining" = list("icon_state" = "mining"),
"Command" = list("icon_state" = "centcom"),
)
if(paint_jobs)
paint_jobs = crate_paint_jobs

Expand Down
2 changes: 0 additions & 2 deletions code/game/objects/structures/morgue.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,11 @@ GLOBAL_LIST_EMPTY(bodycontainers) //Let them act as spawnpoints for revenants an
/// Minimum temperature of the internal air mixture
var/minimum_temperature = T0C - 60


/obj/structure/bodycontainer/morgue/Initialize(mapload)
..()
return INITIALIZE_HINT_LATELOAD

/obj/structure/bodycontainer/morgue/LateInitialize()
. = ..()
var/datum/gas_mixture/external_air = loc.return_air()
if(external_air)
internal_air = external_air.copy()
Expand Down
3 changes: 1 addition & 2 deletions code/game/objects/structures/plaques/static_plaques.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
. = ..()
return INITIALIZE_HINT_LATELOAD

/obj/structure/plaque/static_plaque/tram/LateInitialize(mapload)
. = ..()
/obj/structure/plaque/static_plaque/tram/LateInitialize()
link_tram()
set_tram_serial()

Expand Down
1 change: 0 additions & 1 deletion code/game/turfs/open/floor/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
return INITIALIZE_HINT_LATELOAD

/turf/open/floor/glass/LateInitialize()
. = ..()
AddElement(/datum/element/turf_z_transparency)
setup_glow()

Expand Down
1 change: 0 additions & 1 deletion code/game/turfs/open/openspace.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
return INITIALIZE_HINT_LATELOAD

/turf/open/openspace/LateInitialize()
. = ..()
AddElement(/datum/element/turf_z_transparency)

/turf/open/openspace/ChangeTurf(path, list/new_baseturfs, flags)
Expand Down
1 change: 0 additions & 1 deletion code/game/turfs/open/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ GLOBAL_LIST_EMPTY(starlight)
return INITIALIZE_HINT_LATELOAD

/turf/open/space/openspace/LateInitialize()
. = ..()
AddElement(/datum/element/turf_z_transparency)

/turf/open/space/openspace/Destroy()
Expand Down
7 changes: 2 additions & 5 deletions code/modules/antagonists/abductor/machinery/console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,8 @@
pad.teleport_target = location
to_chat(user, span_notice("Location marked as test subject release point."))

/obj/machinery/abductor/console/Initialize(mapload)
..()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/abductor/console/LateInitialize()
/obj/machinery/abductor/console/post_machine_initialize()
. = ..()
if(!team_number)
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
pad_ref = WEAKREF(I.buffer)
return TRUE

/obj/machinery/computer/piratepad_control/LateInitialize()
/obj/machinery/computer/piratepad_control/post_machine_initialize()
. = ..()
if(cargo_hold_id)
for(var/obj/machinery/piratepad/P as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/piratepad))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/atmospherics/machinery/atmosmachinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
fire = 100
acid = 70

/obj/machinery/atmospherics/LateInitialize()
/obj/machinery/atmospherics/post_machine_initialize()
. = ..()
update_name()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/atmospherics/machinery/bluespace_vendor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
AddComponent(/datum/component/payment, tank_cost, SSeconomy.get_dep_account(ACCOUNT_ENG), PAYMENT_ANGRY)
find_and_hang_on_wall( FALSE)

/obj/machinery/bluespace_vendor/LateInitialize()
/obj/machinery/bluespace_vendor/post_machine_initialize()
. = ..()
if(!map_spawned)
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/atmospherics/machinery/components/tank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

// We late initialize here so all stationary tanks have time to set up their
// initial gas mixes and signal registrations.
/obj/machinery/atmospherics/components/tank/LateInitialize()
/obj/machinery/atmospherics/components/tank/post_machine_initialize()
. = ..()
GetMergeGroup(merger_id, merger_typecache)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/bitrunning/objects/byteforge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

return INITIALIZE_HINT_LATELOAD

/obj/machinery/byteforge/LateInitialize()
/obj/machinery/byteforge/post_machine_initialize()
. = ..()

setup_particles()
Expand Down
7 changes: 1 addition & 6 deletions code/modules/bitrunning/objects/netpod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
/// Static list of outfits to select from
var/list/cached_outfits = list()

/obj/machinery/netpod/Initialize(mapload)
. = ..()

return INITIALIZE_HINT_LATELOAD

/obj/machinery/netpod/LateInitialize()
/obj/machinery/netpod/post_machine_initialize()
. = ..()

disconnect_damage = BASE_DISCONNECT_DAMAGE
Expand Down
Loading

0 comments on commit 16e4d77

Please sign in to comment.