Initialize Refactor
This commit is contained in:
+20
-10
@@ -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)
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
return ..()
|
||||
|
||||
/atom/movable/Initialize(mapload)
|
||||
..()
|
||||
. = ..()
|
||||
for(var/L in initial_languages)
|
||||
grant_language(L)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
|
||||
if (opacity)
|
||||
has_opaque_atom = TRUE
|
||||
return INITIALIZE_HINT_NORMAL
|
||||
|
||||
/turf/proc/Initalize_Atmos(times_fired)
|
||||
CalculateAdjacentTurfs()
|
||||
|
||||
Reference in New Issue
Block a user