Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some subsystem init speedups #36632

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions code/controllers/subsystem/init/map.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ var/datum/subsystem/map/SSmap
log_startup_progress("Placing random space structures...")
generate_vaults()
generate_asteroid_secrets()
make_mining_asteroid_secrets() // loops 3 times
log_startup_progress(" Finished placing structures in [stop_watch(watch)]s.")
else
log_startup_progress("Not generating vaults - SKIP_VAULT_GENERATION found in config/config.txt")

make_mining_asteroid_secrets() // loops 3 times

//hobo shack generation, one shack will spawn, 1/3 chance of two shacks
generate_hoboshack()
if (rand(1,3) == 3)
Expand Down
6 changes: 5 additions & 1 deletion code/controllers/subsystem/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ var/list/lighting_update_overlays = list() // List of lighting overlays queued
..("L:[lighting_update_lights.len]|C:[lighting_update_corners.len]|O:[lighting_update_overlays.len]")

/datum/subsystem/lighting/Initialize(timeofday)
create_all_lighting_overlays()
for(var/area/A in areas)
if(A.dynamic_lighting)
for(var/turf/T in A.area_turfs)
if(T.dynamic_lighting)
new /atom/movable/lighting_overlay(T, TRUE)
..()

/datum/subsystem/lighting/fire(resumed=FALSE, allow_breaks=TRUE)
Expand Down
20 changes: 9 additions & 11 deletions code/controllers/subsystem/objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var/list/processing_objects = list()
/datum/subsystem/obj/Initialize()
set background=1
for(var/atom/object in world)
if(!(object.flags & ATOM_INITIALIZED))
if(~object.flags & ATOM_INITIALIZED)
var/time_start = world.timeofday
object.initialize()
var/time = (world.timeofday - time_start)
Expand All @@ -27,17 +27,15 @@ var/list/processing_objects = list()
log_debug("Slow object initialize. [object] ([object.type]) at [T?.x],[T?.y],[T?.z] took [time/10] seconds to initialize.")
else
bad_inits[object.type] = bad_inits[object.type]+1
for(var/area/A in areas)
if(A.areaapc)
A.areaapc.update()
//Toggle lights without lightswitches
//with better area organization, a lot of this headache can be limited
if(!A.requires_power || !A.haslightswitch)
for(var/obj/machinery/light/L in A.lights)
L.seton(1)
..()
spawn()
for(var/area/A in areas)
var/obj/machinery/power/apc/place_apc = A.areaapc
if(place_apc)
place_apc.update()
//Toggle lights without lightswitches
//with better area organization, a lot of this headache can be limited
if(!A.requires_power || !A.haslightswitch)
for(var/obj/machinery/light/L in A)
L.seton(1)

/datum/subsystem/obj/stat_entry()
..("P:[processing_objects.len]")
Expand Down
10 changes: 0 additions & 10 deletions code/game/area/Space Station 13 areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ var/global/list/adminbusteleportlocs = list()
power_light = 0
power_environ = 0
always_unpowered = 0
dynamic_lighting = 1
shuttle_can_crush = TRUE

/area/arrival
Expand Down Expand Up @@ -197,8 +196,6 @@ var/global/list/adminbusteleportlocs = list()

/area/shuttle
requires_power = 0
dynamic_lighting = 1 //Lighting STILL disabled, even with the new bay engine, because lighting doesn't play nice with our shuttles, might just be our shuttle code, or the small changes in the lighting engine we have from bay.
//haha fuck you we dynamic lights now
shuttle_can_crush = FALSE
flags = NO_PERSISTENCE
holomap_draw_override = HOLOMAP_DRAW_EMPTY
Expand Down Expand Up @@ -373,7 +370,6 @@ var/global/list/adminbusteleportlocs = list()
name = "\improper Nuclear Operative Shuttle"
icon_state = "yellow"
requires_power = 0
dynamic_lighting = 1
shuttle_can_crush = FALSE
flags = NO_PERSISTENCE

Expand Down Expand Up @@ -492,14 +488,12 @@ var/global/list/adminbusteleportlocs = list()
name = "\improper Vox Skipjack"
icon_state = "yellow"
requires_power = 0
dynamic_lighting = 1
holomap_draw_override = HOLOMAP_DRAW_EMPTY

/area/shuttle/lightship
name = "\improper Lightspeed Ship"
requires_power = 1
icon_state = "firingrange"
dynamic_lighting = 1
holomap_draw_override = HOLOMAP_DRAW_EMPTY

/area/shuttle/lightship/start
Expand All @@ -509,7 +503,6 @@ var/global/list/adminbusteleportlocs = list()
name = "\improper Broken UFO"
requires_power = 1
icon_state = "firingrange"
dynamic_lighting = 1
holomap_draw_override = HOLOMAP_DRAW_EMPTY

/area/shuttle/brokeufo/start
Expand Down Expand Up @@ -1371,7 +1364,6 @@ var/global/list/adminbusteleportlocs = list()

/area/solar
requires_power = 0
dynamic_lighting = 1
holomap_color = HOLOMAP_AREACOLOR_ENGINEERING
shuttle_can_crush = FALSE

Expand Down Expand Up @@ -2605,7 +2597,6 @@ var/global/list/adminbusteleportlocs = list()
/area/awaymission/beach
name = "Beach"
icon_state = "null"
dynamic_lighting = 1
requires_power = 0

/area/awaymission/leviathan
Expand Down Expand Up @@ -2846,7 +2837,6 @@ var/list/shack_names = list("abandoned","deserted","forsaken","stranded","isolat
name = "shack"
requires_power = 0
icon_state = "firingrange"
dynamic_lighting = 1

holomap_draw_override = HOLOMAP_DRAW_FULL

Expand Down
8 changes: 2 additions & 6 deletions code/game/objects/structures/catwalk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
layer = CATWALK_LAYER

/obj/structure/catwalk/canSmoothWith()
var/static/list/smoothables = list(/obj/structure/catwalk)
return smoothables
return 1

/obj/structure/catwalk/relativewall()
icon_state = "catwalk[..()]"

/obj/structure/catwalk/isSmoothableNeighbor(atom/A)

if(istype(A, /turf/space))
return 0
return ..()
return !istype(A, /turf/space) && istype(A, /obj/structure/catwalk)

/obj/structure/catwalk/ex_act(severity)
switch(severity)
Expand Down
23 changes: 8 additions & 15 deletions code/game/objects/structures/crates_lockers/closets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
w_type = RECYK_METAL
ignoreinvert = 1

var/time_initialized_at = 0

/obj/structure/closet/splashable()
return FALSE

Expand Down Expand Up @@ -70,20 +68,15 @@
return 1

/obj/structure/closet/initialize()
..()
if (!time_initialized_at)
time_initialized_at = world.time
//haha, so you'd like to initialize twice huh? you got some explaining to do kid.
if(~flags & ATOM_INITIALIZED)
spawn_contents()
else
//haha, so you'd like to initialize twice huh? you got some explaining to do kid.
message_admins("[src] at ([x],[y],[z]) tried to initialize at time = [world.time] despite having already initialized at time = [time_initialized_at]")
ASSERT(!time_initialized_at)
return
if(!opened) // if closed, any item at the crate's loc is put in the contents
if(!ticker || ticker.current_state < GAME_STATE_PLAYING)
take_contents()
else
setDensity(FALSE)
if(!opened) // if closed, any item at the crate's loc is put in the contents
if(!ticker || ticker.current_state < GAME_STATE_PLAYING)
take_contents()
else
setDensity(FALSE)
..()

/obj/structure/closet/spawned_by_map_element()
..()
Expand Down
9 changes: 2 additions & 7 deletions code/game/objects/structures/grille.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
var/grille_material = /obj/item/stack/rods

/obj/structure/grille/canSmoothWith()
var/static/list/smoothables = list(
/obj/structure/grille,
)
return smoothables
return 1

/obj/structure/grille/relativewall()
if(broken)
Expand All @@ -28,9 +25,7 @@
/obj/structure/grille/isSmoothableNeighbor(atom/A)
if(istype(A,/obj/structure/grille))
var/obj/structure/grille/G = A
if(G.broken)
return 0
return ..()
return !G.broken

/obj/structure/grille/examine(mob/user)

Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/structures/railings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@
return 1

/obj/structure/railing/canSmoothWith()
return list(/obj/structure/railing)
return 1

/obj/structure/railing/isSmoothableNeighbor(atom/A)
if(istype(A,/obj/structure/railing))
var/obj/structure/railing/O = A
return O.anchored && O.dir == src.dir && ..()
if(A?.dir == src.dir && istype(A,/obj/structure/railing))
var/atom/movable/O = A
return O.anchored

/obj/structure/railing/relativewall()
if(anchored)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/structures/window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ var/list/one_way_windows
return unsmoothables

/obj/structure/window/isSmoothableNeighbor(atom/A)
if(isobj(A))
var/obj/O = A
return ..() && O.anchored && O.density
if(A?.density && ismovable(A))
var/atom/movable/O = A
return O.anchored && ..()

/obj/structure/window/relativewall()
icon_state = anchored && density ? "[base_state][..()]" : initial(icon_state)
Expand Down
26 changes: 13 additions & 13 deletions code/game/smoothwall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@
// OTHER FUNCTION SOME BORDER ITEMS MIGHT LIKE TO USE
/atom/proc/findSmoothingOnTurf()
. = 0
var/turf/T = get_turf(src)
if(!T)
return 0
for(var/cdir in cardinal)
if((flow_flags & ON_BORDER) && !bordersmooth_override && (dir == cdir || opposite_dirs[dir] == cdir))
continue
var/turf/T = get_turf(src)
if(isSmoothableNeighbor(T,0) && T.dir == cdir)
if(T.dir == cdir && isSmoothableNeighbor(T,0))
. |= cdir
continue // NO NEED FOR FURTHER SEARCHING IN THIS TILE
for(var/atom/A in T)
if(isSmoothableNeighbor(A,0) && A.dir == cdir)
if(A.dir == cdir && isSmoothableNeighbor(A,0))
. |= cdir
break // NO NEED FOR FURTHER SEARCHING IN THIS TILE

/atom/proc/isSmoothableNeighbor(atom/A, bordercheck = TRUE)
if(!A)
return 0
if(bordercheck && (flow_flags & ON_BORDER) && (A.flow_flags & ON_BORDER) && !bordersmooth_override && A.dir != dir)
return 0
return is_type_in_list(A, canSmoothWith()) && !(is_type_in_list(A, cannotSmoothWith()))
return is_type_in_list(A, canSmoothWith()) && !(cannotSmoothWith() && (is_type_in_list(A, cannotSmoothWith())))

/turf/simulated/wall/isSmoothableNeighbor(atom/A)
if(!A)
return 0
if(is_type_in_list(A, canSmoothWith()) && !(is_type_in_list(A, cannotSmoothWith())))
if(istype(A, /turf/simulated/wall))
var/turf/simulated/wall/W = A
if(src.mineral == W.mineral)
return 1
else
return 1

return 0
if(istype(A, /turf/simulated/wall))
var/turf/simulated/wall/W = A
return src.mineral == W.mineral && !(cannotSmoothWith() && is_type_in_list(A, cannotSmoothWith()))
return is_type_in_list(A, canSmoothWith()) && !(cannotSmoothWith() && (is_type_in_list(A, cannotSmoothWith())))


/**
* WALL SMOOTHING SHIT
Expand Down
3 changes: 1 addition & 2 deletions code/game/turfs/simulated/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
/turf/simulated/wall/shuttle/isSmoothableNeighbor(atom/A)
if (get_area(A) != get_area(src))
return 0

return ..()
return is_type_in_list(A, canSmoothWith()) && !(cannotSmoothWith() && (is_type_in_list(A, cannotSmoothWith())))

/turf/simulated/wall/shuttle/attackby(obj/item/weapon/W as obj, mob/user as mob)
user.delayNextAttack(8)
Expand Down
9 changes: 4 additions & 5 deletions code/game/turfs/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
if(!parallax_appearances)
parallax_appearances = list()
for(var/i in 0 to 25)
var/I = "[i]"
icon_state = I
var/image/parallax_overlay = image('icons/turf/space_parallax1.dmi', I)
icon_state = "[i]"
var/image/parallax_overlay = image('icons/turf/space_parallax1.dmi', icon_state)
parallax_overlay.plane = SPACE_DUST_PLANE
parallax_overlay.alpha = 80
parallax_overlay.blend_mode = BLEND_ADD
overlays += parallax_overlay
parallax_appearances[I] = appearance
parallax_appearances += appearance
overlays.Cut()
appearance = parallax_appearances["[((x + y) ^ ~(x * y) + z) % 26]"]
appearance = parallax_appearances[rand(1,26)]

/turf/space/spawned_by_map_element(var/datum/map_element/ME, var/list/objects)
initialize()
Expand Down
Loading
Loading