/atom New() => Initialize() [MDB IGNORE] (#8298)

* Find and replace argless atom New() to Initialize().

* Manual replacement of no-arg New() to Initialize().

* Manually replacing remaining New() overrides.

* Fixing linter issues with now-removed New() args.

* Tidying area init overrides.

* Porting Neb's atom subsystem.

* Trying to isolate init problems.

* Adjusting Init code post-test.

* Merging duplicate Initialize() procs.

* Merge resolution.
This commit is contained in:
MistakeNot4892
2021-11-14 19:09:14 +11:00
committed by GitHub
parent 0051b29ead
commit 2f0a618d45
589 changed files with 2903 additions and 3005 deletions

View File

@@ -251,8 +251,8 @@ var/global/datum/emergency_shuttle_controller/emergency_shuttle = new
layer = TURF_LAYER
plane = TURF_PLANE
/obj/effect/bgstar/New()
..()
/obj/effect/bgstar/Initialize()
. = ..()
pixel_x += rand(-2,30)
pixel_y += rand(-2,30)
var/starnum = pick("1", "1", "1", "2", "3", "4")

View File

@@ -8,70 +8,66 @@ SUBSYSTEM_DEF(atoms)
init_order = INIT_ORDER_ATOMS
flags = SS_NO_FIRE
var/static/initialized = INITIALIZATION_INSSATOMS
// var/list/created_atoms // This is never used, so don't bother. ~Leshana
var/static/old_initialized
// override and GetArguments() exists for mod-override/downstream hook functionality.
// Useful for total-overhaul type modifications.
var/adjust_init_arguments = FALSE
var/atom_init_stage = INITIALIZATION_INSSATOMS
var/old_init_stage
var/list/late_loaders
var/list/created_atoms
var/list/BadInitializeCalls = list()
/datum/controller/subsystem/atoms/Initialize(timeofday)
if(!plant_controller) // Initialize seed repo for /obj/item/seed and /obj/item/weapon/grown
plant_controller = new
setupgenetics() //to set the mutations' place in structural enzymes, so initializers know where to put mutations.
initialized = INITIALIZATION_INNEW_MAPLOAD
to_world_log("Initializing objects")
admin_notice("<span class='danger'>Initializing objects</span>", R_DEBUG)
atom_init_stage = INITIALIZATION_INNEW_MAPLOAD
InitializeAtoms()
return ..()
/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms)
if(initialized == INITIALIZATION_INSSATOMS)
/datum/controller/subsystem/atoms/proc/InitializeAtoms(var/list/supplied_atoms)
if(atom_init_stage <= INITIALIZATION_INSSATOMS_LATE)
return
initialized = INITIALIZATION_INNEW_MAPLOAD
atom_init_stage = 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
var/count = LAZYLEN(supplied_atoms)
if(count)
while(supplied_atoms.len)
var/atom/A = supplied_atoms[supplied_atoms.len]
supplied_atoms.len--
if(!A.initialized)
if(InitAtom(I, mapload_arg))
atoms -= I
InitAtom(A, GetArguments(A, mapload_arg))
CHECK_TICK
else
count = 0
for(var/atom/A in world) // This must be world, since this operation adds all the atoms to their specific lists.
else if(!subsystem_initialized)
// If wondering why not just store all atoms in a list and use the block above: that turns out unbearably expensive.
// Instead, atoms without extra arguments in New created on server start are fished out of world directly.
// We do this exactly once.
for(var/atom/A in world)
if(!A.initialized)
InitAtom(A, mapload_arg)
InitAtom(A, GetArguments(A, mapload_arg, FALSE))
++count
CHECK_TICK
log_world("Initialized [count] atoms")
report_progress("Initialized [count] atom\s")
initialized = INITIALIZATION_INNEW_REGULAR
atom_init_stage = INITIALIZATION_INNEW_REGULAR
if(late_loaders.len)
for(var/I in late_loaders)
var/atom/A = I
A.LateInitialize()
CHECK_TICK
testing("Late initialized [late_loaders.len] atoms")
A.LateInitialize(arglist(late_loaders[A]))
report_progress("Late initialized [late_loaders.len] atom\s")
late_loaders.Cut()
// Nothing ever checks return value of this proc, so don't bother. If this ever changes fix code in /atom/New() ~Leshana
// if(atoms)
// . = created_atoms + atoms
// created_atoms = null
/datum/controller/subsystem/atoms/proc/InitAtom(atom/A, list/arguments)
LAZYREMOVE(global.pre_init_created_atoms, A)
var/the_type = A.type
if(QDELING(A))
BadInitializeCalls[the_type] |= BAD_INIT_QDEL_BEFORE
@@ -90,9 +86,9 @@ SUBSYSTEM_DEF(atoms)
switch(result)
if(INITIALIZE_HINT_LATELOAD)
if(arguments[1]) //mapload
late_loaders += A
late_loaders[A] = arguments
else
A.LateInitialize()
A.LateInitialize(arglist(arguments))
if(INITIALIZE_HINT_QDEL)
qdel(A)
qdeleted = TRUE
@@ -106,18 +102,37 @@ SUBSYSTEM_DEF(atoms)
return qdeleted || QDELING(A)
// override and GetArguments() exists for mod-override/downstream hook functionality.
// Useful for total-overhaul type modifications.
/atom/proc/AdjustInitializeArguments(list/arguments)
// Lists are passed by reference so can simply modify the arguments list without returning it
/datum/controller/subsystem/atoms/proc/GetArguments(atom/A, list/mapload_arg, created=TRUE)
if(!created && !adjust_init_arguments)
return mapload_arg // Performance optimization. Nothing to do.
var/list/arguments = mapload_arg.Copy()
var/extra_args = LAZYACCESS(global.pre_init_created_atoms, A)
if(created && extra_args)
arguments += extra_args
if(adjust_init_arguments)
A.AdjustInitializeArguments(arguments)
return arguments
/datum/controller/subsystem/atoms/stat_entry(msg)
..("Bad Initialize Calls:[BadInitializeCalls.len]")
/datum/controller/subsystem/atoms/proc/map_loader_begin()
old_initialized = initialized
initialized = INITIALIZATION_INSSATOMS
old_init_stage = atom_init_stage
atom_init_stage = INITIALIZATION_INSSATOMS_LATE
/datum/controller/subsystem/atoms/proc/map_loader_stop()
initialized = old_initialized
atom_init_stage = old_init_stage
/datum/controller/subsystem/atoms/Recover()
initialized = SSatoms.initialized
if(initialized == INITIALIZATION_INNEW_MAPLOAD)
atom_init_stage = SSatoms.atom_init_stage
if(atom_init_stage == INITIALIZATION_INNEW_MAPLOAD)
InitializeAtoms()
old_initialized = SSatoms.old_initialized
old_init_stage = SSatoms.old_init_stage
BadInitializeCalls = SSatoms.BadInitializeCalls
/datum/controller/subsystem/atoms/proc/InitLog()

View File

@@ -87,17 +87,6 @@ SUBSYSTEM_DEF(open_space)
// log_debug("[T] ([T.x],[T.y],[T.z]) queued for update for [src].update_icon()")
SSopen_space.add_turf(T, 1)
// Ouch... this is painful. But is there any other way?
/* - No for now
/obj/New()
. = ..()
if(open_space_initialised && !invisibility)
var/turf/T = GetAbove(src)
if(isopenspace(T))
// log_debug("[T] ([T.x],[T.y],[T.z]) queued for update for [src]New()")
OS_controller.add_turf(T, 1)
*/
// We probably should hook Destroy() If we can think of something more efficient, lets hear it.
/obj/Destroy()
if(GLOB.open_space_initialised && !invisibility && isturf(loc))

View File

@@ -425,7 +425,7 @@ var/global/datum/controller/subsystem/ticker/ticker
if(new_char)
qdel(player)
if(new_char.client)
var/obj/screen/splash/S = new(new_char.client, TRUE)
var/obj/screen/splash/S = new(null, new_char.client, TRUE)
S.Fade(TRUE)
// If they're a carbon, they can get manifested

View File

@@ -6,8 +6,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(ml, text, target)
. = ..(ml)
name = text
src.target = target