From f19a517d0f5f56df473d30299e0cbef5dd7b9374 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Sun, 12 Jan 2025 08:03:47 -0700 Subject: [PATCH] [MIRROR] Fixes lateload map template cable loading (#9851) Co-authored-by: Cameron Lennox Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- code/__defines/flags.dm | 2 +- code/__defines/misc.dm | 7 ++++--- code/__defines/turfs.dm | 3 ++- code/controllers/subsystems/atoms.dm | 2 +- code/game/atoms.dm | 6 +++--- code/game/objects/structures.dm | 2 +- code/game/objects/structures/window_spawner.dm | 2 +- code/game/turfs/flooring/flooring_decals.dm | 2 +- code/game/turfs/unsimulated.dm | 3 +-- code/game/turfs/unsimulated/sky_vr.dm | 1 - code/modules/maps/tg/map_template.dm | 8 ++++---- .../living/simple_mob/subtypes/vore/shadekin/shadekin.dm | 2 +- code/modules/mob/new_player/new_player.dm | 2 +- code/modules/power/cable.dm | 5 ++++- maps/expedition_vr/beach/_beach.dm | 2 +- maps/expedition_vr/space/_debrisfield.dm | 2 +- maps/offmap_vr/common_offmaps.dm | 2 +- 17 files changed, 28 insertions(+), 25 deletions(-) diff --git a/code/__defines/flags.dm b/code/__defines/flags.dm index 3cbce52bc0..290fffe018 100644 --- a/code/__defines/flags.dm +++ b/code/__defines/flags.dm @@ -35,7 +35,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define NOREACT (1<<6) // Reagents don't react inside this container. #define OVERLAY_QUEUED (1<<7)// Atom queued to SSoverlay for COMPILE_OVERLAYS #define IS_BUSY (1<<8) // Atom has a TASK_TARGET_EXCLUSIVE do_after with it as the target. -#define ATOM_INITIALIZED (1<<14) // Atom has been initialized. Using a flag instead of a variable saves ~25mb total. //CHOMPEdit +#define ATOM_INITIALIZED (1<<23) // Atom has been initialized. Using a flag instead of a variable saves ~25mb total. //Flags for items (equipment) - Used in /obj/item/var/item_flags #define THICKMATERIAL (1<<0) // Prevents syringes, parapens and hyposprays if equipped to slot_suit or slot_head. diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 2866b84609..6963d8e3b0 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -114,11 +114,12 @@ #define AREA_BLOCK_SUIT_SENSORS 0x800 // If suit sensors are blocked in the area. #define AREA_BLOCK_TRACKING 0x1000 // If camera tracking is blocked in the area. #define AREA_BLOCK_GHOST_SIGHT 0x2000 // If an area blocks sight for ghosts +// The 0x800000 is blocked by INITIALIZED, do NOT use it! // CHOMPAdd Start/area -#define PHASE_SHIELDED 0x200000 // A less rough way to prevent phase shifting without blocking access -#define AREA_LIMIT_DARK_RESPITE 0x400000// Shadekin will die normally in those areas -#define AREA_ALLOW_CLOCKOUT 0x800000 //The PDA timeclock app can only be used in these areas +#define PHASE_SHIELDED 0x100000 // A less rough way to prevent phase shifting without blocking access +#define AREA_LIMIT_DARK_RESPITE 0x200000// Shadekin will die normally in those areas +#define AREA_ALLOW_CLOCKOUT 0x400000 //The PDA timeclock app can only be used in these areas // CHOMPAdd End // OnTopic return values diff --git a/code/__defines/turfs.dm b/code/__defines/turfs.dm index fe327cd632..57e1e37c45 100644 --- a/code/__defines/turfs.dm +++ b/code/__defines/turfs.dm @@ -8,6 +8,7 @@ #define TURF_HAS_CORNERS 128 #define TURF_IS_FRAGILE 256 #define TURF_ACID_IMMUNE 512 +// The 0x800000 is blocked by INITIALIZED, do NOT use it! //Used for floor/wall smoothing #define SMOOTH_NONE 0 //Smooth only with itself @@ -36,4 +37,4 @@ block( \ locate(max(CENTER.x-(H_RADIUS),1), max(CENTER.y-(V_RADIUS),1), CENTER.z), \ locate(min(CENTER.x+(H_RADIUS),world.maxx), min(CENTER.y+(V_RADIUS),world.maxy), CENTER.z) \ - ) \ No newline at end of file + ) diff --git a/code/controllers/subsystems/atoms.dm b/code/controllers/subsystems/atoms.dm index 3918372ce3..211ef0517d 100644 --- a/code/controllers/subsystems/atoms.dm +++ b/code/controllers/subsystems/atoms.dm @@ -39,7 +39,7 @@ SUBSYSTEM_DEF(atoms) created_atoms = list() count = atoms.len for(var/atom/A as anything in atoms) - if(!(A.flags & ATOM_INITIALIZED)) //CHOMPEdit + if(!(A.flags & ATOM_INITIALIZED)) if(InitAtom(A, mapload_arg)) atoms -= A CHECK_TICK diff --git a/code/game/atoms.dm b/code/game/atoms.dm index b282eba468..0d8378e3f9 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -39,7 +39,7 @@ //Detective Work, used for the duplicate data points kept in the scanners var/list/original_atom // Track if we are already had initialize() called to prevent double-initialization. - //var/initialized = FALSE CHOMPEdit moved to flag + //var/initialized = FALSE // using the atom flags /// Last name used to calculate a color for the chatmessage overlays var/chat_color_name @@ -91,9 +91,9 @@ /atom/proc/Initialize(mapload, ...) if(QDELETED(src)) stack_trace("GC: -- [type] had initialize() called after qdel() --") - if(flags & ATOM_INITIALIZED) //CHOMPEdit moved initialized to flag + if(flags & ATOM_INITIALIZED) stack_trace("Warning: [src]([type]) initialized multiple times!") - flags |= ATOM_INITIALIZED //CHOMPEdit moved initialized to flag + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_NORMAL /atom/Destroy() diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index ddd2ddc888..d2a05be991 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -15,7 +15,7 @@ var/list/blend_objects = null // Objects which to blend with //CHOMPEdit default null var/list/noblend_objects = null //Objects to avoid blending with (such as children of listed blend objects. //CHOMPEdit default null -/obj/structure/Initialize() +/obj/structure/Initialize(mapload) . = ..() if(climbable) verbs += /obj/structure/proc/climb_on diff --git a/code/game/objects/structures/window_spawner.dm b/code/game/objects/structures/window_spawner.dm index 4bde27a142..8841cbf30b 100644 --- a/code/game/objects/structures/window_spawner.dm +++ b/code/game/objects/structures/window_spawner.dm @@ -58,7 +58,7 @@ activated = 1 for(var/obj/effect/wingrille_spawn/other in neighbours) if(!other.activated) other.activate() - if((flags & ATOM_INITIALIZED) && !QDELETED(src)) //CHOMPEdit + if((flags & ATOM_INITIALIZED) && !QDELETED(src)) qdel(src) /obj/effect/wingrille_spawn/proc/handle_window_spawn(var/obj/structure/window/W) diff --git a/code/game/turfs/flooring/flooring_decals.dm b/code/game/turfs/flooring/flooring_decals.dm index 51e7d17da2..f82639e781 100644 --- a/code/game/turfs/flooring/flooring_decals.dm +++ b/code/game/turfs/flooring/flooring_decals.dm @@ -21,7 +21,7 @@ var/list/floor_decals = list() // abstract handler that explicitly doesn't invoke any obj behavior. /obj/effect/floor_decal/Initialize() add_to_turf_decals() - flags |= ATOM_INITIALIZED //CHOMPEdit + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_QDEL // This is a separate proc from initialize() to facilitiate its caching and other stuff. Look into it someday. diff --git a/code/game/turfs/unsimulated.dm b/code/game/turfs/unsimulated.dm index 97ee8a8af7..06cb988fdf 100644 --- a/code/game/turfs/unsimulated.dm +++ b/code/game/turfs/unsimulated.dm @@ -7,7 +7,7 @@ /turf/unsimulated/Initialize(mapload) if(skip_init) - flags |= ATOM_INITIALIZED //CHOMPEdit + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_NORMAL . = ..() @@ -17,7 +17,6 @@ icon = 'icons/turf/space.dmi' icon_state = "0" dynamic_lighting = FALSE - //initialized = FALSE CHOMP Removal (what the fuck) /turf/unsimulated/fake_space/Initialize(mapload) . = ..() diff --git a/code/game/turfs/unsimulated/sky_vr.dm b/code/game/turfs/unsimulated/sky_vr.dm index f8d464d906..e14793b659 100644 --- a/code/game/turfs/unsimulated/sky_vr.dm +++ b/code/game/turfs/unsimulated/sky_vr.dm @@ -8,7 +8,6 @@ icon = 'icons/turf/floors.dmi' icon_state = "sky_slow" dir = SOUTH - //initialized = FALSE CHOMPRemoval var/does_skyfall = TRUE var/list/skyfall_levels diff --git a/code/modules/maps/tg/map_template.dm b/code/modules/maps/tg/map_template.dm index 29bf89a74e..e2a83621e4 100644 --- a/code/modules/maps/tg/map_template.dm +++ b/code/modules/maps/tg/map_template.dm @@ -15,11 +15,12 @@ var/discard_prob = 0 // If non-zero, there is a chance that the map seeding algorithm will skip this template when selecting potential templates to use. /datum/map_template/New(path = null, rename = null) + SHOULD_CALL_PARENT(TRUE) + . = ..() if(path) mappath = path if(mappath) - spawn(1) - preload_size(mappath) + preload_size(mappath) if(rename) name = rename @@ -46,7 +47,6 @@ var/list/turf/turfs = block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]), locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])) for(var/turf/B as anything in turfs) - atoms += B areas |= B.loc for(var/A in B) atoms += A @@ -57,7 +57,7 @@ atoms |= areas admin_notice(span_danger("Initializing newly created atom(s) in submap."), R_DEBUG) - SSatoms.InitializeAtoms(atoms) + SSatoms.InitializeAtoms(areas + turfs + atoms) admin_notice(span_danger("Initializing atmos pipenets and machinery in submap."), R_DEBUG) SSmachines.setup_atmos_machinery(atmos_machines) diff --git a/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/shadekin.dm b/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/shadekin.dm index e65a64337d..1eab9c536b 100644 --- a/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/shadekin.dm +++ b/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/shadekin.dm @@ -97,7 +97,7 @@ var/new_type = pickweight(sk_types) new new_type(loc) - flags |= ATOM_INITIALIZED //CHOMPEdit + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_QDEL if(icon_state == "map_example") diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index c428b8c4f2..6363bdfd19 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -31,7 +31,7 @@ else forceMove(locate(1,1,1)) //CHOMPEdit End - flags |= ATOM_INITIALIZED // Explicitly don't use Initialize(). New players join super early and use New() //CHOMPEdit + flags |= ATOM_INITIALIZED // Explicitly don't use Initialize(). New players join super early and use New() /mob/new_player/Destroy() diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 4bce471002..3940dbc5ca 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -89,7 +89,7 @@ var/list/possible_cable_coil_colours = list( /obj/structure/cable/white color = COLOR_WHITE -/obj/structure/cable/Initialize() +/obj/structure/cable/Initialize(mapload) . = ..() // ensure d1 & d2 reflect the icon_state for entering and exiting cable @@ -158,6 +158,9 @@ var/list/possible_cable_coil_colours = list( return 1 /obj/structure/cable/update_icon() + // We rely on the icon state for the wire Initialize(), prevent any updates to the icon before init passed + if(!(flags & ATOM_INITIALIZED)) + return icon_state = "[d1]-[d2]" alpha = invisibility ? 127 : 255 diff --git a/maps/expedition_vr/beach/_beach.dm b/maps/expedition_vr/beach/_beach.dm index 1e4f3669c2..adcf7c3ca4 100644 --- a/maps/expedition_vr/beach/_beach.dm +++ b/maps/expedition_vr/beach/_beach.dm @@ -70,7 +70,7 @@ new /datum/random_map/automata/cave_system/no_cracks(null, 1, 1, Z_LEVEL_BEACH_CAVE, world.maxx, world.maxy) new /datum/random_map/noise/ore/beachmine(null, 1, 1, Z_LEVEL_BEACH_CAVE, 64, 64)*/ - initialized = TRUE + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_QDEL // Two mob spawners that are placed on the map that spawn some mobs! diff --git a/maps/expedition_vr/space/_debrisfield.dm b/maps/expedition_vr/space/_debrisfield.dm index 1a3269790f..9582426fa8 100644 --- a/maps/expedition_vr/space/_debrisfield.dm +++ b/maps/expedition_vr/space/_debrisfield.dm @@ -45,7 +45,7 @@ name = "away mission initializer - debrisfield" /obj/away_mission_init/debrisfield/Initialize() - initialized = TRUE + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_QDEL /area/tether_away/debrisfield diff --git a/maps/offmap_vr/common_offmaps.dm b/maps/offmap_vr/common_offmaps.dm index 70d577da47..e1f032a79c 100644 --- a/maps/offmap_vr/common_offmaps.dm +++ b/maps/offmap_vr/common_offmaps.dm @@ -488,7 +488,7 @@ if(!LAZYLEN(mobs_to_pick_from)) error("Mob spawner at [x],[y],[z] ([get_area(src)]) had no mobs_to_pick_from set on it!") - initialized = TRUE + flags |= ATOM_INITIALIZED return INITIALIZE_HINT_QDEL START_PROCESSING(SSobj, src)