mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Implement SSatoms
* Moves proc/initialize() from being on /atom/movable, /are and /turf/simulated to being on /atom - Now turfs can initialize too * Added the SSatoms subsystem which controls initialization of atoms at roundstart and during normal conditions. * Disabled the old auto_init = 0 behavior, ALL atoms should get initialized() called on them now. * Refactored the way initialize() is called during /New() to utilize SSatoms instead of SScreation * Removed SScreation, as it was only a stop-gap until SSatoms could be ported. * Updated the maploader to inform SSatoms when it is loading maps instead of SScreation. * Updated the template map loader to use SSatoms to perform initTemplateBounds * Renamed 'initialized' var in seed_storage to deconflict. * Removed usage of auto_init = 0, replaced with a no-op initialize() proc for atoms that don't need initialization.
This commit is contained in:
@@ -36,7 +36,7 @@ datum/controller/game_controller/New()
|
||||
datum/controller/game_controller/proc/setup()
|
||||
|
||||
setup_objects()
|
||||
setupgenetics()
|
||||
// setupgenetics() Moved to SSatoms
|
||||
SetupXenoarch()
|
||||
|
||||
transfer_controller = new
|
||||
@@ -59,6 +59,7 @@ datum/controller/game_controller/proc/setup_objects()
|
||||
//Set up spawn points.
|
||||
populate_spawn_points()
|
||||
|
||||
/*
|
||||
admin_notice("<span class='danger'>Initializing Floor Decals</span>", R_DEBUG)
|
||||
var/list/turfs_with_decals = list()
|
||||
for(var/obj/effect/floor_decal/D in world)
|
||||
@@ -111,3 +112,4 @@ datum/controller/game_controller/proc/setup_objects()
|
||||
if(!QDELETED(lift))
|
||||
lift.initialize()
|
||||
CHECK_SLEEP_MASTER
|
||||
*/
|
||||
145
code/controllers/subsystems/atoms.dm
Normal file
145
code/controllers/subsystems/atoms.dm
Normal file
@@ -0,0 +1,145 @@
|
||||
#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"
|
||||
init_order = INIT_ORDER_ATOMS
|
||||
flags = SS_NO_FIRE
|
||||
|
||||
var/initialized = INITIALIZATION_INSSATOMS
|
||||
// var/list/created_atoms // This is never used, so don't bother. ~Leshana
|
||||
var/old_initialized
|
||||
|
||||
var/list/late_loaders
|
||||
var/list/created_atoms
|
||||
|
||||
var/list/BadInitializeCalls = list()
|
||||
|
||||
/datum/controller/subsystem/atoms/Initialize(timeofday)
|
||||
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)
|
||||
InitializeAtoms()
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms)
|
||||
if(initialized == INITIALIZATION_INSSATOMS)
|
||||
return
|
||||
|
||||
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()
|
||||
CHECK_TICK
|
||||
testing("Late initialized [late_loaders.len] atoms")
|
||||
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)
|
||||
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 || QDELING(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
|
||||
BadInitializeCalls = SSatoms.BadInitializeCalls
|
||||
|
||||
/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)
|
||||
//text2file(initlog, "[GLOB.log_directory]/initialize.log")
|
||||
var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day")
|
||||
text2file(initlog, "data/logs/[date_string]-initialize.log")
|
||||
|
||||
#undef BAD_INIT_QDEL_BEFORE
|
||||
#undef BAD_INIT_DIDNT_INIT
|
||||
#undef BAD_INIT_SLEPT
|
||||
#undef BAD_INIT_NO_HINT
|
||||
28
code/controllers/subsystems/floor_decals.dm
Normal file
28
code/controllers/subsystems/floor_decals.dm
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Floor Decals Initialization Subsystem
|
||||
// This is part of the giant decal hack that works around a BYOND bug where DreamDaemon will crash if you
|
||||
// update overlays on turfs too much.
|
||||
// The master_controller on Polaris used to init decals prior to initializing areas (which initilized turfs)
|
||||
// Now that we switched to subsystems we still want to do the same thing, so this takes care of it.
|
||||
//
|
||||
SUBSYSTEM_DEF(floor_decals)
|
||||
name = "Floor Decals"
|
||||
init_order = INIT_ORDER_DECALS
|
||||
flags = SS_NO_FIRE
|
||||
|
||||
/datum/controller/subsystem/floor_decals/Initialize(timeofday)
|
||||
if(floor_decals_initialized)
|
||||
return ..()
|
||||
to_world_log("Initializing Floor Decals")
|
||||
admin_notice("<span class='danger'>Initializing Floor Decals</span>", R_DEBUG)
|
||||
var/list/turfs_with_decals = list()
|
||||
for(var/obj/effect/floor_decal/D in world)
|
||||
var/T = D.add_to_turf_decals()
|
||||
if(T) turfs_with_decals |= T
|
||||
CHECK_TICK
|
||||
for(var/item in turfs_with_decals)
|
||||
var/turf/T = item
|
||||
if(T.decals) T.apply_decals()
|
||||
CHECK_TICK
|
||||
floor_decals_initialized = TRUE
|
||||
return ..()
|
||||
@@ -33,8 +33,9 @@ SUBSYSTEM_DEF(machines)
|
||||
var/list/current_run = list()
|
||||
|
||||
/datum/controller/subsystem/machines/Initialize(timeofday)
|
||||
SSmachines.makepowernets()
|
||||
// TODO - Move world-creation time setup of atmos machinery and pipenets to here
|
||||
makepowernets()
|
||||
admin_notice("<span class='danger'>Initializing atmos machinery.</span>", R_DEBUG)
|
||||
setup_atmos_machinery(global.machines)
|
||||
fire()
|
||||
..()
|
||||
|
||||
@@ -53,13 +54,33 @@ SUBSYSTEM_DEF(machines)
|
||||
for(var/datum/powernet/PN in powernets)
|
||||
qdel(PN)
|
||||
powernets.Cut()
|
||||
setup_powernets_for_cables(cable_list)
|
||||
|
||||
for(var/obj/structure/cable/PC in cable_list)
|
||||
/datum/controller/subsystem/machines/proc/setup_powernets_for_cables(list/cables)
|
||||
for(var/obj/structure/cable/PC in cables)
|
||||
if(!PC.powernet)
|
||||
var/datum/powernet/NewPN = new()
|
||||
NewPN.add_cable(PC)
|
||||
propagate_network(PC,PC.powernet)
|
||||
|
||||
/datum/controller/subsystem/machines/proc/setup_atmos_machinery(list/atmos_machines)
|
||||
for(var/obj/machinery/atmospherics/machine in atmos_machines)
|
||||
machine.atmos_init()
|
||||
CHECK_TICK
|
||||
|
||||
for(var/obj/machinery/atmospherics/machine in atmos_machines)
|
||||
machine.build_network()
|
||||
CHECK_TICK
|
||||
|
||||
for(var/obj/machinery/atmospherics/unary/U in atmos_machines)
|
||||
if(istype(U, /obj/machinery/atmospherics/unary/vent_pump))
|
||||
var/obj/machinery/atmospherics/unary/vent_pump/T = U
|
||||
T.broadcast_status()
|
||||
else if(istype(U, /obj/machinery/atmospherics/unary/vent_scrubber))
|
||||
var/obj/machinery/atmospherics/unary/vent_scrubber/T = U
|
||||
T.broadcast_status()
|
||||
CHECK_TICK
|
||||
|
||||
/datum/controller/subsystem/machines/stat_entry()
|
||||
var/msg = list()
|
||||
msg += "C:{"
|
||||
|
||||
Reference in New Issue
Block a user