From cea81a3357f2df420651fc8615b72c55224401b4 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Wed, 26 Apr 2017 16:03:17 -0500 Subject: [PATCH 1/2] Initialize Refactor --- code/__DEFINES/qdel.dm | 3 +- code/__DEFINES/subsystems.dm.rej | 18 +++ code/_onclick/hud/screen_objects.dm | 2 +- code/controllers/admin.dm | 4 +- code/controllers/subsystem/atoms.dm | 136 ++++++++++-------- code/controllers/subsystem/atoms.dm.rej | 9 ++ code/game/atoms.dm | 30 ++-- code/game/atoms_movable.dm | 2 +- .../miniantags/abduction/machinery/console.dm | 4 +- .../embedded_controller/access_controller.dm | 12 +- code/game/objects/items.dm.rej | 10 ++ code/game/objects/objs.dm | 2 +- code/game/objects/structures/ladders.dm | 11 +- code/game/turfs/space/space.dm | 2 + code/game/turfs/turf.dm | 1 + code/modules/admin/admin_verbs.dm.rej | 11 ++ code/modules/admin/verbs/debug.dm | 7 + code/modules/holodeck/computer.dm.rej | 47 ++++++ code/modules/mob/dead/dead.dm | 7 +- .../mob/dead/new_player/new_player.dm.rej | 9 ++ code/modules/recycling/conveyor2.dm.rej | 10 ++ code/modules/recycling/disposal-unit.dm | 22 +-- code/modules/shuttle/arrivals.dm.rej | 11 ++ code/modules/surgery/surgery.dm | 2 +- code/modules/surgery/surgery.dm.rej | 10 ++ 25 files changed, 277 insertions(+), 105 deletions(-) create mode 100644 code/__DEFINES/subsystems.dm.rej create mode 100644 code/controllers/subsystem/atoms.dm.rej create mode 100644 code/game/objects/items.dm.rej create mode 100644 code/modules/admin/admin_verbs.dm.rej create mode 100644 code/modules/holodeck/computer.dm.rej create mode 100644 code/modules/mob/dead/new_player/new_player.dm.rej create mode 100644 code/modules/recycling/conveyor2.dm.rej create mode 100644 code/modules/shuttle/arrivals.dm.rej create mode 100644 code/modules/surgery/surgery.dm.rej diff --git a/code/__DEFINES/qdel.dm b/code/__DEFINES/qdel.dm index fe19d7a559..041a6283e7 100644 --- a/code/__DEFINES/qdel.dm +++ b/code/__DEFINES/qdel.dm @@ -14,5 +14,6 @@ #define GC_QUEUED_FOR_HARD_DEL -2 #define GC_CURRENTLY_BEING_QDELETED -3 -#define QDELETED(X) (!X || X.gc_destroyed) +#define QDELING(X) (X.gc_destroyed) +#define QDELETED(X) (!X || QDELING(X)) #define QDESTROYING(X) (!X || X.gc_destroyed == GC_CURRENTLY_BEING_QDELETED) diff --git a/code/__DEFINES/subsystems.dm.rej b/code/__DEFINES/subsystems.dm.rej new file mode 100644 index 0000000000..cf39977224 --- /dev/null +++ b/code/__DEFINES/subsystems.dm.rej @@ -0,0 +1,18 @@ +diff a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm (rejected hunks) +@@ -26,4 +26,13 @@ + + #define INITIALIZE_HINT_NORMAL 0 //Nothing happens + #define INITIALIZE_HINT_LATELOAD 1 //Call LateInitialize +-#define INITIALIZE_HINT_QDEL 2 //Call qdel on the atom +\ No newline at end of file ++#define INITIALIZE_HINT_QDEL 2 //Call qdel on the atom ++ ++//type and all subtypes should always call Initialize in New() ++#define INITIALIZE_IMMEDIATE(X) ##X/New(loc, ...){\ ++ ..();\ ++ if(!initialized) {\ ++ args[1] = TRUE;\ ++ SSatoms.InitAtom(src, args);\ ++ }\ ++} +\ No newline at end of file diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index a3a60b1f31..81754efc93 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -544,7 +544,7 @@ plane = SPLASHSCREEN_PLANE var/client/holder -/obj/screen/splash/New(client/C, visible, use_previous_title) +/obj/screen/splash/New(client/C, visible, use_previous_title) //TODO: Make this use INITIALIZE_IMMEDIATE holder = C if(!visible) diff --git a/code/controllers/admin.dm b/code/controllers/admin.dm index 99f6a148a4..2be7139a27 100644 --- a/code/controllers/admin.dm +++ b/code/controllers/admin.dm @@ -3,7 +3,9 @@ name = "Initializing..." var/target -/obj/effect/statclick/New(loc, text, target) //Don't port this to Initialize it's too critical +INITIALIZE_IMMEDIATE(/obj/effect/statclick) + +/obj/effect/statclick/Initialize(mapload, text, target) //Don't port this to Initialize it's too critical ..() name = text src.target = target diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index c687a7b0e5..487946696d 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -1,6 +1,7 @@ -#define INITIALIZATION_INSSATOMS 0 //New should not call Initialize -#define INITIALIZATION_INNEW_MAPLOAD 1 //New should call Initialize(TRUE) -#define INITIALIZATION_INNEW_REGULAR 2 //New should call Initialize(FALSE) +#define BAD_INIT_QDEL_BEFORE 1 +#define BAD_INIT_DIDNT_INIT 2 +#define BAD_INIT_SLEPT 4 +#define BAD_INIT_NO_HINT 8 SUBSYSTEM_DEF(atoms) name = "Atoms" @@ -19,64 +20,82 @@ SUBSYSTEM_DEF(atoms) InitializeAtoms() return ..() -/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms = null) +/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms) if(initialized == INITIALIZATION_INSSATOMS) return - initialized = INITIALIZATION_INNEW_MAPLOAD - - var/static/list/NewQdelList = list() - - if(atoms) - for(var/I in atoms) - var/atom/A = I - if(!A.initialized) //this check is to make sure we don't call it twice on an object that was created in a previous Initialize call - if(QDELETED(A)) - if(!(NewQdelList[A.type])) - WARNING("Found new qdeletion in type [A.type]!") - NewQdelList[A.type] = TRUE - continue - var/start_tick = world.time - if(A.Initialize(TRUE)) - LAZYADD(late_loaders, A) - if(start_tick != world.time) - WARNING("[A]: [A.type] slept during it's Initialize!") - CHECK_TICK - testing("Initialized [atoms.len] atoms") - else - #ifdef TESTING - var/count = 0 - #endif - for(var/atom/A in world) - if(!A.initialized) //this check is to make sure we don't call it twice on an object that was created in a previous Initialize call - if(QDELETED(A)) - if(!(NewQdelList[A.type])) - WARNING("Found new qdeletion in type [A.type]!") - NewQdelList[A.type] = TRUE - continue - var/start_tick = world.time - if(A.Initialize(TRUE)) - LAZYADD(late_loaders, A) - #ifdef TESTING - else - ++count - #endif TESTING - if(start_tick != world.time) - WARNING("[A]: [A.type] slept during it's Initialize!") - CHECK_TICK - testing("Roundstart initialized [count] atoms") - - initialized = INITIALIZATION_INNEW_REGULAR - - for(var/I in late_loaders) - var/atom/A = I - var/start_tick = world.time - A.Initialize(FALSE) - if(start_tick != world.time) - WARNING("[A]: [A.type] slept during it's Initialize!") - CHECK_TICK - testing("Late-initialized [LAZYLEN(late_loaders)] atoms") - LAZYCLEARLIST(late_loaders) + initialized = INITIALIZATION_INNEW_MAPLOAD + + LAZYINITLIST(late_loaders) + + var/count + var/list/mapload_arg = list(TRUE) + if(atoms) + created_atoms = list() + count = atoms.len + for(var/I in atoms) + var/atom/A = I + if(!A.initialized) + if(InitAtom(I, mapload_arg)) + atoms -= I + CHECK_TICK + else + count = 0 + for(var/atom/A in world) + if(!A.initialized) + InitAtom(A, mapload_arg) + ++count + CHECK_TICK + + log_world("Initialized [count] atoms") + + initialized = INITIALIZATION_INNEW_REGULAR + + if(late_loaders.len) + for(var/I in late_loaders) + var/atom/A = I + A.LateInitialize() + testing("Late initialized [late_loaders.len] atoms") + late_loaders.Cut() + + if(atoms) + . = created_atoms + atoms + created_atoms = null + +/datum/controller/subsystem/atoms/proc/InitAtom(atom/A, list/arguments) + var/the_type = A.type + if(QDELING(A)) + BadInitializeCalls[the_type] |= BAD_INIT_QDEL_BEFORE + return TRUE + + var/start_tick = world.time + + var/result = A.Initialize(arglist(arguments)) + + if(start_tick != world.time) + BadInitializeCalls[the_type] |= BAD_INIT_SLEPT + + var/qdeleted = FALSE + + if(result != INITIALIZE_HINT_NORMAL) + switch(result) + if(INITIALIZE_HINT_LATELOAD) + if(arguments[1]) //mapload + late_loaders += A + else + A.LateInitialize() + if(INITIALIZE_HINT_QDEL) + qdel(A) + qdeleted = TRUE + else + BadInitializeCalls[the_type] |= BAD_INIT_NO_HINT + + if(!A) //possible harddel + qdeleted = TRUE + else if(!A.initialized) + BadInitializeCalls[the_type] |= BAD_INIT_DIDNT_INIT + + return qdeleted || QDELETED(A) /datum/controller/subsystem/atoms/proc/map_loader_begin() old_initialized = initialized @@ -90,6 +109,7 @@ SUBSYSTEM_DEF(atoms) if(initialized == INITIALIZATION_INNEW_MAPLOAD) InitializeAtoms() old_initialized = SSatoms.old_initialized + BadInitializeCalls = SSatoms.BadInitializeCalls /datum/controller/subsystem/atoms/proc/setupGenetics() var/list/avnums = new /list(DNA_STRUC_ENZYMES_BLOCKS) diff --git a/code/controllers/subsystem/atoms.dm.rej b/code/controllers/subsystem/atoms.dm.rej new file mode 100644 index 0000000000..4d7225164f --- /dev/null +++ b/code/controllers/subsystem/atoms.dm.rej @@ -0,0 +1,9 @@ +diff a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm (rejected hunks) +@@ -12,6 +12,7 @@ SUBSYSTEM_DEF(atoms) + var/old_initialized + + var/list/late_loaders ++ var/list/created_atoms + + var/list/BadInitializeCalls = list() + diff --git a/code/game/atoms.dm b/code/game/atoms.dm index fda74c2ac8..ab0038f7be 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -39,20 +39,21 @@ var/do_initialize = SSatoms.initialized if(do_initialize > INITIALIZATION_INSSATOMS) - if(QDELETED(src)) - CRASH("Found new qdeletion in type [type]!") - var/mapload = do_initialize == INITIALIZATION_INNEW_MAPLOAD - args[1] = mapload - if(Initialize(arglist(args)) && mapload) - LAZYADD(SSatoms.late_loaders, src) + args[1] = do_initialize == INITIALIZATION_INNEW_MAPLOAD + if(SSatoms.InitAtom(src, args)) + //we were deleted + return + + var/list/created = SSatoms.created_atoms + if(created) + created += src //Called after New if the map is being loaded. mapload = TRUE //Called from base of New if the map is being loaded. mapload = FALSE -//This base must be called or derivatives must set initialized to TRUE to prevent repeat calls -//Derivatives must not sleep -//Returning TRUE while mapload is TRUE will cause the object to be initialized again with mapload = FALSE when everything else is done -//(Useful for things that requires turfs to have air). This base may only be called once, however +//This base must be called or derivatives must set initialized to TRUE +//must not sleep //Other parameters are passed from New (excluding loc), this does not happen if mapload is TRUE +//Must return an Initialize hint. Defined in __DEFINES/subsystems.dm //Note: the following functions don't call the base for optimization and must copypasta: // /turf/Initialize @@ -75,7 +76,16 @@ if (opacity && isturf(loc)) var/turf/T = loc T.has_opaque_atom = TRUE // No need to recalculate it in this case, it's guaranteed to be on afterwards anyways. + return INITIALIZE_HINT_NORMAL +//called if Initialize returns INITIALIZE_HINT_LATELOAD +//This version shouldn't be called +/atom/proc/LateInitialize() + var/static/list/warned_types = list() + if(!warned_types[type]) + WARNING("Old style LateInitialize behaviour detected in [type]!") + warned_types[type] = TRUE + Initialize(FALSE) /atom/Destroy() if(alternate_appearances) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 2d3d19f7c0..acc64fabb0 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -45,7 +45,7 @@ return ..() /atom/movable/Initialize(mapload) - ..() + . = ..() for(var/L in initial_languages) grant_language(L) diff --git a/code/game/gamemodes/miniantags/abduction/machinery/console.dm b/code/game/gamemodes/miniantags/abduction/machinery/console.dm index 2a23c37444..27a358081d 100644 --- a/code/game/gamemodes/miniantags/abduction/machinery/console.dm +++ b/code/game/gamemodes/miniantags/abduction/machinery/console.dm @@ -135,10 +135,10 @@ /obj/machinery/abductor/console/Initialize(mapload) - if(mapload) - return TRUE //wait for machines list ..() + return INITIALIZE_HINT_LATELOAD +/obj/machinery/abductor/console/LateInitialize() if(!team) return diff --git a/code/game/machinery/embedded_controller/access_controller.dm b/code/game/machinery/embedded_controller/access_controller.dm index bc8e5972f8..562e2c5b38 100644 --- a/code/game/machinery/embedded_controller/access_controller.dm +++ b/code/game/machinery/embedded_controller/access_controller.dm @@ -19,12 +19,12 @@ /obj/machinery/doorButtons/proc/findObjsByTag() return -/obj/machinery/doorButtons/Initialize(mapload) - if(mapload) - ..() - return TRUE - else - findObjsByTag() +/obj/machinery/doorButtons/Initialize() + ..() + return INITIALIZE_HINT_LATELOAD + +/obj/machinery/doorButtons/LateInitialize() + findObjsByTag() /obj/machinery/doorButtons/emag_act(mob/user) if(!emagged) diff --git a/code/game/objects/items.dm.rej b/code/game/objects/items.dm.rej new file mode 100644 index 0000000000..7366e22899 --- /dev/null +++ b/code/game/objects/items.dm.rej @@ -0,0 +1,10 @@ +diff a/code/game/objects/items.dm b/code/game/objects/items.dm (rejected hunks) +@@ -102,7 +102,7 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s + /obj/item/Initialize() + if (!materials) + materials = list() +- ..() ++ . = ..() + for(var/path in actions_types) + new path(src) + actions_types = null diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 4c61b09ca3..e29d372a6c 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -37,7 +37,7 @@ ..() /obj/Initialize() - ..() + . = ..() if (!armor) armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 0, acid = 0) if(on_blueprints && isturf(loc)) diff --git a/code/game/objects/structures/ladders.dm b/code/game/objects/structures/ladders.dm index ec82b45a1f..5a7988e8d4 100644 --- a/code/game/objects/structures/ladders.dm +++ b/code/game/objects/structures/ladders.dm @@ -14,18 +14,15 @@ /obj/structure/ladder/Initialize(mapload) - if(!initialized) - GLOB.ladders += src - ..() - if(mapload) - return TRUE - update_link() + GLOB.ladders += src + ..() + return INITIALIZE_HINT_LATELOAD /obj/structure/ladder/Destroy() GLOB.ladders -= src . = ..() -/obj/structure/ladder/proc/update_link() +/obj/structure/ladder/LateInitialize() for(var/obj/structure/ladder/L in GLOB.ladders) if(L.id == id) if(L.height == (height - 1)) diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index 6c1e2743cd..a0940eded1 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -42,6 +42,8 @@ if (opacity) has_opaque_atom = TRUE + + return INITIALIZE_HINT_NORMAL /turf/open/space/attack_ghost(mob/dead/observer/user) if(destination_z) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 10eefc4b14..1c2d65355e 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -56,6 +56,7 @@ if (opacity) has_opaque_atom = TRUE + return INITIALIZE_HINT_NORMAL /turf/proc/Initalize_Atmos(times_fired) CalculateAdjacentTurfs() diff --git a/code/modules/admin/admin_verbs.dm.rej b/code/modules/admin/admin_verbs.dm.rej new file mode 100644 index 0000000000..e710d417c2 --- /dev/null +++ b/code/modules/admin/admin_verbs.dm.rej @@ -0,0 +1,11 @@ +diff a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm (rejected hunks) +@@ -153,7 +153,8 @@ var/list/admin_verbs_debug = list( + /client/proc/clear_dynamic_transit, + /client/proc/toggle_medal_disable, + /client/proc/view_runtimes, +- /client/proc/pump_random_event ++ /client/proc/pump_random_event, ++ /client/proc/cmd_display_init_log + ) + var/list/admin_verbs_possess = list( + /proc/possess, diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 54be219a48..c9014da3b0 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -721,6 +721,13 @@ GLOBAL_PROTECT(AdminProcCall) usr << browse(dat, "window=dellog") +/client/proc/cmd_display_init_log() + set category = "Debug" + set name = "Display Initialzie() Log" + set desc = "Displays a list of things that didn't handle Initialize() properly" + + usr << browse(replacetext(SSatoms.InitLog(), "\n", "
"), "window=initlog") + /client/proc/debug_huds(i as num) set category = "Debug" set name = "Debug HUDs" diff --git a/code/modules/holodeck/computer.dm.rej b/code/modules/holodeck/computer.dm.rej new file mode 100644 index 0000000000..7a8dcd75cd --- /dev/null +++ b/code/modules/holodeck/computer.dm.rej @@ -0,0 +1,47 @@ +diff a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm (rejected hunks) +@@ -64,25 +64,26 @@ + ..() + + /obj/machinery/computer/holodeck/Initialize(mapload) +- . = mapload //late-initialize, area_copy need turfs to have air +- if(!mapload) +- ..() +- program_cache = list() +- emag_programs = list() +- for(var/typekey in subtypesof(program_type)) +- var/area/holodeck/A = locate(typekey) +- if(!A || A == offline_program) continue +- if(A.contents.len == 0) continue // not loaded +- if(A.restricted) +- emag_programs += A +- else +- program_cache += A +- if(typekey == init_program) +- load_program(A,force=1) +- if(random_program && program_cache.len && init_program == null) +- load_program(pick(program_cache),force=1) +- else if(!program) +- load_program(offline_program) ++ ..() ++ return INITIALIZE_HINT_LATELOAD ++ ++/obj/machinery/computer/holodeck/LateInitialize() ++ program_cache = list() ++ emag_programs = list() ++ for(var/typekey in subtypesof(program_type)) ++ var/area/holodeck/A = locate(typekey) ++ if(!A || A == offline_program) continue ++ if(A.contents.len == 0) continue // not loaded ++ if(A.restricted) ++ emag_programs += A ++ else ++ program_cache += A ++ if(typekey == init_program) ++ load_program(A,force=1) ++ if(random_program && program_cache.len && init_program == null) ++ load_program(pick(program_cache),force=1) ++ else if(!program) ++ load_program(offline_program) + + /obj/machinery/computer/holodeck/power_change() + ..() diff --git a/code/modules/mob/dead/dead.dm b/code/modules/mob/dead/dead.dm index 81f36bf221..4cc57ca62f 100644 --- a/code/modules/mob/dead/dead.dm +++ b/code/modules/mob/dead/dead.dm @@ -1,9 +1,6 @@ //Dead mobs can exist whenever. This is needful -/mob/dead/New(loc) - ..() - if(!initialized) - args[1] = FALSE - Initialize(arglist(args)) //EXIST DAMN YOU!!! + +INITIALIZE_IMMEDIATE(/mob/dead) /mob/dead/dust() //ghosts can't be vaporised. return diff --git a/code/modules/mob/dead/new_player/new_player.dm.rej b/code/modules/mob/dead/new_player/new_player.dm.rej new file mode 100644 index 0000000000..9ebe59e8f8 --- /dev/null +++ b/code/modules/mob/dead/new_player/new_player.dm.rej @@ -0,0 +1,9 @@ +diff a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm (rejected hunks) +@@ -30,6 +30,7 @@ + loc = pick(newplayer_start) + else + loc = locate(1,1,1) ++ return INITIALIZE_HINT_NORMAL + + /mob/dead/new_player/proc/new_player_panel() + diff --git a/code/modules/recycling/conveyor2.dm.rej b/code/modules/recycling/conveyor2.dm.rej new file mode 100644 index 0000000000..328ac26919 --- /dev/null +++ b/code/modules/recycling/conveyor2.dm.rej @@ -0,0 +1,10 @@ +diff a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm (rejected hunks) +@@ -220,7 +220,7 @@ + id = newid + update() + +- return INITIALIZE_HINT_LATELOAD ++ return INITIALIZE_HINT_LATELOAD //for machines list + + /obj/machinery/conveyor_switch/LateInitialize() + conveyors = list() diff --git a/code/modules/recycling/disposal-unit.dm b/code/modules/recycling/disposal-unit.dm index 9b1d5e649f..5013d9d879 100644 --- a/code/modules/recycling/disposal-unit.dm +++ b/code/modules/recycling/disposal-unit.dm @@ -64,17 +64,17 @@ deconstruct() /obj/machinery/disposal/Initialize(mapload) - . = mapload //late-initialize, we need turfs to have air - if(initialized) //will only be run on late mapload initialization - //this will get a copy of the air turf and take a SEND PRESSURE amount of air from it - var/atom/L = loc - var/datum/gas_mixture/env = new - env.copy_from(L.return_air()) - var/datum/gas_mixture/removed = env.remove(SEND_PRESSURE + 1) - air_contents.merge(removed) - trunk_check() - else - ..() + ..() + return INITIALIZE_HINT_LATELOAD //we need turfs to have air + +/obj/machinery/disposal/LateInitialize() + //this will get a copy of the air turf and take a SEND PRESSURE amount of air from it + var/atom/L = loc + var/datum/gas_mixture/env = new + env.copy_from(L.return_air()) + var/datum/gas_mixture/removed = env.remove(SEND_PRESSURE + 1) + air_contents.merge(removed) + trunk_check() /obj/machinery/disposal/attackby(obj/item/I, mob/user, params) add_fingerprint(user) diff --git a/code/modules/shuttle/arrivals.dm.rej b/code/modules/shuttle/arrivals.dm.rej new file mode 100644 index 0000000000..8310a4f3db --- /dev/null +++ b/code/modules/shuttle/arrivals.dm.rej @@ -0,0 +1,11 @@ +diff a/code/modules/shuttle/arrivals.dm b/code/modules/shuttle/arrivals.dm (rejected hunks) +@@ -30,6 +30,9 @@ + ..() + + preferred_direction = dir ++ return INITIALIZE_HINT_LATELOAD //for latejoin list ++ ++/obj/docking_port/mobile/arrivals/LateInitialize() + areas = list() + + var/list/new_latejoin = list() diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index f9a3b5c0cf..93acbfbb91 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -54,7 +54,7 @@ return new step_type /datum/surgery/proc/complete() - feedback_add_details("surgeries_completed", "[type]") + feedback_add_details("surgeries_completed", type) qdel(src) diff --git a/code/modules/surgery/surgery.dm.rej b/code/modules/surgery/surgery.dm.rej new file mode 100644 index 0000000000..04205e9e66 --- /dev/null +++ b/code/modules/surgery/surgery.dm.rej @@ -0,0 +1,10 @@ +diff a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm (rejected hunks) +@@ -54,7 +54,7 @@ + return new step_type + + /datum/surgery/proc/complete() +- feedback_add_details("surgeries_completed", type) ++ feedback_add_details("surgeries_completed", "[type]") + qdel(src) + + From 085b421348c4b306fbac6da96438c579f19739f9 Mon Sep 17 00:00:00 2001 From: LetterJay Date: Fri, 28 Apr 2017 09:03:56 -0500 Subject: [PATCH 2/2] rej fixes --- code/__DEFINES/subsystems.dm | 18 +++ code/controllers/subsystem/atoms.dm | 143 +++++++++++------- code/modules/admin/admin_verbs.dm | 4 +- code/modules/holodeck/computer.dm | 84 +++++----- .../modules/mob/dead/new_player/new_player.dm | 7 +- code/modules/recycling/conveyor2.dm | 7 +- code/modules/shuttle/arrivals.dm | 14 +- code/modules/surgery/surgery.dm | 2 +- 8 files changed, 165 insertions(+), 114 deletions(-) diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 0b27e01326..c0b9a20d3b 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -20,6 +20,24 @@ #define FLIGHTSUIT_PROCESSING_NONE 0 #define FLIGHTSUIT_PROCESSING_FULL 1 +#define INITIALIZATION_INSSATOMS 0 //New should not call Initialize +#define INITIALIZATION_INNEW_MAPLOAD 1 //New should call Initialize(TRUE) +#define INITIALIZATION_INNEW_REGULAR 2 //New should call Initialize(FALSE) + +#define INITIALIZE_HINT_NORMAL 0 //Nothing happens +#define INITIALIZE_HINT_LATELOAD 1 //Call LateInitialize +#define INITIALIZE_HINT_QDEL 2 //Call qdel on the atom + +//type and all subtypes should always call Initialize in New() +#define INITIALIZE_IMMEDIATE(X) ##X/New(loc, ...){\ + ..();\ + if(!initialized) {\ + args[1] = TRUE;\ + SSatoms.InitAtom(src, args);\ + }\ +} + + // Subsystem init_order, from highest priority to lowest priority // The numbers just define the ordering, they are meaningless otherwise. diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index 487946696d..711da25889 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -2,32 +2,35 @@ #define BAD_INIT_DIDNT_INIT 2 #define BAD_INIT_SLEPT 4 #define BAD_INIT_NO_HINT 8 - -SUBSYSTEM_DEF(atoms) - name = "Atoms" + +SUBSYSTEM_DEF(atoms) + name = "Atoms" init_order = INIT_ORDER_ATOMS - flags = SS_NO_FIRE - - var/initialized = INITIALIZATION_INSSATOMS - var/old_initialized - - var/list/late_loaders - -/datum/controller/subsystem/atoms/Initialize(timeofday) - GLOB.fire_overlay.appearance_flags = RESET_COLOR - setupGenetics() //to set the mutations' place in structural enzymes, so monkey.initialize() knows where to put the monkey mutation. - initialized = INITIALIZATION_INNEW_MAPLOAD - InitializeAtoms() - return ..() - + flags = SS_NO_FIRE + + var/initialized = INITIALIZATION_INSSATOMS + var/old_initialized + + var/list/late_loaders + var/list/created_atoms + + var/list/BadInitializeCalls = list() + +/datum/controller/subsystem/atoms/Initialize(timeofday) + GLOB.fire_overlay.appearance_flags = RESET_COLOR + setupGenetics() //to set the mutations' place in structural enzymes, so monkey.initialize() knows where to put the monkey mutation. + initialized = INITIALIZATION_INNEW_MAPLOAD + InitializeAtoms() + return ..() + /datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms) - if(initialized == INITIALIZATION_INSSATOMS) - return - + if(initialized == INITIALIZATION_INSSATOMS) + return + initialized = INITIALIZATION_INNEW_MAPLOAD LAZYINITLIST(late_loaders) - + var/count var/list/mapload_arg = list(TRUE) if(atoms) @@ -57,10 +60,10 @@ SUBSYSTEM_DEF(atoms) A.LateInitialize() testing("Late initialized [late_loaders.len] atoms") late_loaders.Cut() - + if(atoms) . = created_atoms + atoms - created_atoms = null + created_atoms = null /datum/controller/subsystem/atoms/proc/InitAtom(atom/A, list/arguments) var/the_type = A.type @@ -74,7 +77,7 @@ SUBSYSTEM_DEF(atoms) if(start_tick != world.time) BadInitializeCalls[the_type] |= BAD_INIT_SLEPT - + var/qdeleted = FALSE if(result != INITIALIZE_HINT_NORMAL) @@ -89,43 +92,67 @@ SUBSYSTEM_DEF(atoms) qdeleted = TRUE else BadInitializeCalls[the_type] |= BAD_INIT_NO_HINT - + if(!A) //possible harddel qdeleted = TRUE else if(!A.initialized) BadInitializeCalls[the_type] |= BAD_INIT_DIDNT_INIT - + return qdeleted || QDELETED(A) - -/datum/controller/subsystem/atoms/proc/map_loader_begin() - old_initialized = initialized - initialized = INITIALIZATION_INSSATOMS - -/datum/controller/subsystem/atoms/proc/map_loader_stop() - initialized = old_initialized - -/datum/controller/subsystem/atoms/Recover() - initialized = SSatoms.initialized - if(initialized == INITIALIZATION_INNEW_MAPLOAD) - InitializeAtoms() - old_initialized = SSatoms.old_initialized + +/datum/controller/subsystem/atoms/proc/map_loader_begin() + old_initialized = initialized + initialized = INITIALIZATION_INSSATOMS + +/datum/controller/subsystem/atoms/proc/map_loader_stop() + initialized = old_initialized + +/datum/controller/subsystem/atoms/Recover() + initialized = SSatoms.initialized + if(initialized == INITIALIZATION_INNEW_MAPLOAD) + InitializeAtoms() + old_initialized = SSatoms.old_initialized BadInitializeCalls = SSatoms.BadInitializeCalls - -/datum/controller/subsystem/atoms/proc/setupGenetics() - var/list/avnums = new /list(DNA_STRUC_ENZYMES_BLOCKS) - for(var/i=1, i<=DNA_STRUC_ENZYMES_BLOCKS, i++) - avnums[i] = i - CHECK_TICK - - for(var/A in subtypesof(/datum/mutation/human)) - var/datum/mutation/human/B = new A() - if(B.dna_block == NON_SCANNABLE) - continue - B.dna_block = pick_n_take(avnums) - if(B.quality == POSITIVE) - GLOB.good_mutations |= B - else if(B.quality == NEGATIVE) - GLOB.bad_mutations |= B - else if(B.quality == MINOR_NEGATIVE) - GLOB.not_good_mutations |= B - CHECK_TICK + +/datum/controller/subsystem/atoms/proc/setupGenetics() + var/list/avnums = new /list(DNA_STRUC_ENZYMES_BLOCKS) + for(var/i=1, i<=DNA_STRUC_ENZYMES_BLOCKS, i++) + avnums[i] = i + CHECK_TICK + + for(var/A in subtypesof(/datum/mutation/human)) + var/datum/mutation/human/B = new A() + if(B.dna_block == NON_SCANNABLE) + continue + B.dna_block = pick_n_take(avnums) + if(B.quality == POSITIVE) + GLOB.good_mutations |= B + else if(B.quality == NEGATIVE) + GLOB.bad_mutations |= B + else if(B.quality == MINOR_NEGATIVE) + GLOB.not_good_mutations |= B + CHECK_TICK + +/datum/controller/subsystem/atoms/proc/InitLog() + . = "" + for(var/path in BadInitializeCalls) + . += "Path : [path] \n" + var/fails = BadInitializeCalls[path] + if(fails & BAD_INIT_DIDNT_INIT) + . += "- Didn't call atom/Initialize()\n" + if(fails & BAD_INIT_NO_HINT) + . += "- Didn't return an Initialize hint\n" + if(fails & BAD_INIT_QDEL_BEFORE) + . += "- Qdel'd in New()\n" + if(fails & BAD_INIT_SLEPT) + . += "- Slept during Initialize()\n" + +/datum/controller/subsystem/atoms/Shutdown() + var/initlog = InitLog() + if(initlog) + log_world(initlog) + +#undef BAD_INIT_QDEL_BEFORE +#undef BAD_INIT_DIDNT_INIT +#undef BAD_INIT_SLEPT +#undef BAD_INIT_NO_HINT diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 22045b99ff..19e2c372b3 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -166,8 +166,10 @@ GLOBAL_LIST_INIT(admin_verbs_debug, AVerbsDebug()) //citadel code /client/proc/give_humans_genitals, /client/proc/test_mammal_overlays, - /client/proc/pump_random_event + /client/proc/pump_random_event, + /client/proc/cmd_display_init_log ) + GLOBAL_PROTECT(admin_verbs_possess) GLOBAL_LIST_INIT(admin_verbs_possess, list(/proc/possess,/proc/release)) GLOBAL_PROTECT(admin_verbs_permissions) diff --git a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm index 18be292e97..7947ef4413 100644 --- a/code/modules/holodeck/computer.dm +++ b/code/modules/holodeck/computer.dm @@ -45,52 +45,52 @@ var/list/effects = list() var/last_change = 0 - + /obj/machinery/computer/holodeck/Initialize(mapload) - . = mapload //late-initialize, area_copy need turfs to have air - if(!mapload) - ..() + ..() + return INITIALIZE_HINT_LATELOAD - if(ispath(holodeck_type,/area)) - var/list/possible = get_areas(holodeck_type,subtypes = FALSE) - linked = pop(possible) - if(ispath(offline_program,/area)) - var/list/possible = get_areas(offline_program,subtypes = FALSE) - offline_program = pop(possible) - // the following is necessary for power reasons - if(!linked || !offline_program) - log_world("No matching holodeck area found") - qdel(src) - return - var/area/AS = get_area(src) - if(istype(AS,/area/holodeck)) - log_world("### MAPPING ERROR") - log_world("Holodeck computer cannot be in a holodeck.") - log_world("This would cause circular power dependency.") - qdel(src) // todo handle constructed computers - return //l-lewd... - else - linked.linked = src // todo detect multiple/constructed computers +/obj/machinery/computer/holodeck/LateInitialize() + if(ispath(holodeck_type,/area)) + var/list/possible = get_areas(holodeck_type,subtypes = FALSE) + linked = pop(possible) + if(ispath(offline_program,/area)) + var/list/possible = get_areas(offline_program,subtypes = FALSE) + offline_program = pop(possible) + // the following is necessary for power reasons + if(!linked || !offline_program) + log_world("No matching holodeck area found") + qdel(src) + return + var/area/AS = get_area(src) + if(istype(AS,/area/holodeck)) + log_world("### MAPPING ERROR") + log_world("Holodeck computer cannot be in a holodeck.") + log_world("This would cause circular power dependency.") + qdel(src) // todo handle constructed computers + return //l-lewd... + else + linked.linked = src // todo detect multiple/constructed computers - program_cache = list() - emag_programs = list() - for(var/typekey in subtypesof(program_type)) - var/area/holodeck/A = locate(typekey) - if(!A || A == offline_program) - continue - if(A.contents.len == 0) - continue // not loaded - if(A.restricted) - emag_programs += A - else - program_cache += A - if(typekey == init_program) - load_program(A,force=1) - if(random_program && program_cache.len && init_program == null) - load_program(pick(program_cache),force=1) - else if(!program) - load_program(offline_program) + program_cache = list() + emag_programs = list() + for(var/typekey in subtypesof(program_type)) + var/area/holodeck/A = locate(typekey) + if(!A || A == offline_program) + continue + if(A.contents.len == 0) + continue // not loaded + if(A.restricted) + emag_programs += A + else + program_cache += A + if(typekey == init_program) + load_program(A,force=1) + if(random_program && program_cache.len && init_program == null) + load_program(pick(program_cache),force=1) + else if(!program) + load_program(offline_program) /obj/machinery/computer/holodeck/power_change() ..() diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index 72f83bf546..e6adb53ff6 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -30,6 +30,7 @@ loc = pick(GLOB.newplayer_start) else loc = locate(1,1,1) + return INITIALIZE_HINT_NORMAL /mob/dead/new_player/proc/new_player_panel() @@ -48,11 +49,11 @@ output += "

Observe

" if(!IsGuestKey(src.key)) - if (SSdbcore.Connect()) + if (SSdbcore.Connect()) var/isadmin = 0 if(src.client && src.client.holder) isadmin = 1 - var/datum/DBQuery/query_get_new_polls = SSdbcore.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM [format_table_name("poll_vote")] WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM [format_table_name("poll_textreply")] WHERE ckey = \"[ckey]\")") + var/datum/DBQuery/query_get_new_polls = SSdbcore.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM [format_table_name("poll_vote")] WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM [format_table_name("poll_textreply")] WHERE ckey = \"[ckey]\")") if(!query_get_new_polls.Execute()) return var/newpoll = 0 @@ -302,7 +303,7 @@ if(!IsJobAvailable(rank)) alert(src, "[rank] is not available. Please try another.") return 0 - + if(SSticker.late_join_disabled) alert(src, "An administrator has disabled late join spawning.") return FALSE diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 264b6a167d..68190f5e45 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -212,13 +212,14 @@ /obj/machinery/conveyor_switch/Initialize(mapload, newid) - if(mapload) - return TRUE //need machines list - . = ..() + ..() if(!id) id = newid update() + return INITIALIZE_HINT_LATELOAD //for machines list + +/obj/machinery/conveyor_switch/LateInitialize() conveyors = list() for(var/obj/machinery/conveyor/C in GLOB.machines) if(C.id == id) diff --git a/code/modules/shuttle/arrivals.dm b/code/modules/shuttle/arrivals.dm index b4af9d9e17..6b0279e859 100644 --- a/code/modules/shuttle/arrivals.dm +++ b/code/modules/shuttle/arrivals.dm @@ -22,20 +22,22 @@ var/perma_docked = FALSE //highlander with RESPAWN??? OH GOD!!! /obj/docking_port/mobile/arrivals/Initialize(mapload) - if(mapload) - return TRUE //late initialize to make sure the latejoin list is populated - preferred_direction = dir if(SSshuttle.arrivals) WARNING("More than one arrivals docking_port placed on map!") - qdel(src) - return + + return INITIALIZE_HINT_QDEL SSshuttle.arrivals = src - . = ..() + . = ..() + preferred_direction = dir + return INITIALIZE_HINT_LATELOAD //for latejoin list + + +/obj/docking_port/mobile/arrivals/LateInitialize() areas = list() var/list/new_latejoin = list() diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index 93acbfbb91..f9a3b5c0cf 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -54,7 +54,7 @@ return new step_type /datum/surgery/proc/complete() - feedback_add_details("surgeries_completed", type) + feedback_add_details("surgeries_completed", "[type]") qdel(src)