From 2c4d8e9b6aa906b5c01bfb972467fc1456150ea4 Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Sun, 3 Jul 2016 15:36:38 -0700 Subject: [PATCH] You can now load the cyberiad runtime-free --- code/LINDA/LINDA_system.dm | 4 +- code/controllers/Processes/air.dm | 2 +- code/controllers/master_controller.dm | 5 - code/datums/helper_datums/map_template.dm | 18 +- code/game/atoms_movable.dm | 9 +- .../atmoalter/portable_atmospherics.dm | 4 + code/game/machinery/doors/door.dm | 4 +- code/game/machinery/doors/spacepod.dm | 4 +- code/game/machinery/machinery.dm | 2 +- code/game/machinery/shieldgen.dm | 5 +- code/game/objects/effects/aliens.dm | 10 +- code/game/objects/effects/effect_system.dm | 2 +- .../objects/effects/spawners/windowspawner.dm | 7 +- code/game/objects/structures/inflatable.dm | 2 +- code/game/objects/structures/mineral_doors.dm | 263 +++++++++--------- code/game/objects/structures/window.dm | 17 +- .../admin/verbs/map_template_loadverb.dm | 8 +- code/modules/awaymissions/maploader/reader.dm | 27 +- code/modules/awaymissions/zlevel.dm | 21 ++ code/modules/shuttle/supply.dm | 4 +- 20 files changed, 241 insertions(+), 177 deletions(-) diff --git a/code/LINDA/LINDA_system.dm b/code/LINDA/LINDA_system.dm index 2584192e7b4..491c56206b7 100644 --- a/code/LINDA/LINDA_system.dm +++ b/code/LINDA/LINDA_system.dm @@ -78,7 +78,7 @@ turf/CanPass(atom/movable/mover, turf/target, height=1.5,air_group=0) if(T.atmos_adjacent_turfs & counterdir) T.atmos_adjacent_turfs_amount -= 1 T.atmos_adjacent_turfs &= ~counterdir - + //returns a list of adjacent turfs that can share air with this one. //alldir includes adjacent diagonal tiles that can share // air with both of the related adjacent cardinal tiles @@ -184,4 +184,4 @@ var/const/SPAWN_AIR = 256 G.nitrogen += MOLES_N2STANDARD * amount air.merge(G) - air_master.add_to_active(src, 0) \ No newline at end of file + air_master.add_to_active(src, 0) diff --git a/code/controllers/Processes/air.dm b/code/controllers/Processes/air.dm index 4846b850790..ab8dd1a6906 100644 --- a/code/controllers/Processes/air.dm +++ b/code/controllers/Processes/air.dm @@ -146,4 +146,4 @@ var/global/datum/controller/process/air_system/air_master icemaster.icon = 'icons/turf/overlays.dmi' icemaster.icon_state = "snowfloor" icemaster.layer = TURF_LAYER+0.1 - icemaster.mouse_opacity = 0 \ No newline at end of file + icemaster.mouse_opacity = 0 diff --git a/code/controllers/master_controller.dm b/code/controllers/master_controller.dm index c616ad5637d..ba958a17377 100644 --- a/code/controllers/master_controller.dm +++ b/code/controllers/master_controller.dm @@ -42,11 +42,6 @@ var/global/pipe_processing_killed = 0 world.tick_lag = config.Ticklag preloadTemplates() - var/tm = start_watch() - log_startup_progress("Re-loading the cyberiad...") - maploader.load_map(file("_maps/map_files/cyberiad/cyberiad.dmm")) - late_setup_level(block(locate(1, 1, world.maxz), locate(world.maxx, world.maxy, world.maxz))) - log_startup_progress("Finished loading the cyberiad, took [stop_watch(tm)]s") // if(!config.disable_away_missions) // createRandomZlevel() // if(!config.disable_space_ruins) diff --git a/code/datums/helper_datums/map_template.dm b/code/datums/helper_datums/map_template.dm index 78636f4bd79..1e755f64b09 100644 --- a/code/datums/helper_datums/map_template.dm +++ b/code/datums/helper_datums/map_template.dm @@ -37,16 +37,24 @@ if(!T) return 0 - var/turf/bot_left = locate(max(0, min_x), max(0, min_y), placement.z) + var/turf/bot_left = locate(max(1, min_x), max(1, min_y), placement.z) var/turf/top_right = locate(min(world.maxx, max_x), min(world.maxy, max_y), placement.z) // 1 bigger, to update the turf smoothing - var/turf/ST_bot_left = locate(max(0, min_x-1), max(0, min_y-1), placement.z) + var/turf/ST_bot_left = locate(max(1, min_x-1), max(1, min_y-1), placement.z) var/turf/ST_top_right = locate(min(world.maxx, max_x+1), min(world.maxy, max_y+1), placement.z) - var/list/bounds = maploader.load_map(get_file(), min_x, min_y, placement.z, cropMap = 1) if(!bounds) return 0 + if(bot_left == null || top_right == null) + log_debug("One of the late setup corners is bust") + else + log_debug("Late Setup from ([bot_left.x],[bot_left.y]) to ([top_right.x],[top_right.y])") + + if(ST_bot_left == null || ST_top_right == null) + log_debug("One of the smoothing corners is bust") + else + log_debug("Tile smoothing from ([ST_bot_left.x],[ST_bot_left.y]) to ([ST_top_right.x],[ST_top_right.y])") late_setup_level( block(bot_left, top_right), block(ST_bot_left, ST_top_right)) @@ -73,7 +81,7 @@ var/max_x = min_x + width-1 var/max_y = min_y + height-1 - placement = locate(max(min_x,0), max(min_y,0), placement.z) + placement = locate(max(min_x,1), max(min_y,1), placement.z) return block(placement, locate(min(max_x, world.maxx), min(max_y, world.maxy), placement.z)) /datum/map_template/proc/fits_in_map_bounds(turf/T, centered = 0) @@ -86,7 +94,7 @@ var/max_x = min_x + width-1 var/max_y = min_y + height-1 - if(min_x < 0 || min_y < 0 || max_x > world.maxx || max_y > world.maxy) + if(min_x < 1 || min_y < 1 || max_x > world.maxx || max_y > world.maxy) return 0 else return 1 diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 0692ad31601..477e1ff9972 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -20,15 +20,18 @@ var/auto_init = 1 -// TODO: Make this less deliciously fragile and world-affecting // This is used in the map loader to defer initialization once all entities // are placed, so that pipes and window spawners correctly function // when plunked down mid-game -var/defer_auto_init = 0 +var/list/dirty_z_levels = list() /atom/movable/New() . = ..() areaMaster = get_area_master(src) - if(!defer_auto_init && auto_init && ticker && ticker.current_state == GAME_STATE_PLAYING) + var/turf/T = get_turf(src) + + // If you're wondering what goofery this is, this is for things that need the environment + // around them set up - like `air_update_turf` and the like + if(!(T && T.z in dirty_z_levels) && auto_init && ticker && ticker.current_state == GAME_STATE_PLAYING) initialize() /atom/movable/Destroy() diff --git a/code/game/machinery/atmoalter/portable_atmospherics.dm b/code/game/machinery/atmoalter/portable_atmospherics.dm index 21eee7b52ac..26cd0e3cfbd 100644 --- a/code/game/machinery/atmoalter/portable_atmospherics.dm +++ b/code/game/machinery/atmoalter/portable_atmospherics.dm @@ -57,6 +57,10 @@ //Perform the connection connected_port = new_port connected_port.connected_device = src + // To avoid a chicken-egg thing where pipes need to + // be initialized before the atmos cans are + if(!connected_port.parent) + connected_port.build_network() connected_port.parent.reconcile_air() anchored = 1 //Prevent movement diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index fd5f1b19219..6c9537667fb 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -45,11 +45,13 @@ bound_width = world.icon_size bound_height = width * world.icon_size - air_update_turf(1) update_freelook_sight() airlocks += src return +/obj/machinery/door/initialize() + air_update_turf(1) + ..() /obj/machinery/door/Destroy() density = 0 diff --git a/code/game/machinery/doors/spacepod.dm b/code/game/machinery/doors/spacepod.dm index 244642021ad..021509a13ed 100644 --- a/code/game/machinery/doors/spacepod.dm +++ b/code/game/machinery/doors/spacepod.dm @@ -7,7 +7,7 @@ density = 0 anchored = 1 -/obj/structure/spacepoddoor/New() +/obj/structure/spacepoddoor/initialize() ..() air_update_turf(1) @@ -21,4 +21,4 @@ /obj/structure/spacepoddoor/CanPass(atom/movable/A, turf/T) if(istype(A, /obj/spacepod)) return ..() - else return 0 \ No newline at end of file + else return 0 diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index f19e37f051a..65332a1df72 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -117,7 +117,7 @@ Class Procs: var/use_log = list() var/list/settagwhitelist = list()//WHITELIST OF VARIABLES THAT THE set_tag HREF CAN MODIFY, DON'T PUT SHIT YOU DON'T NEED ON HERE, AND IF YOU'RE GONNA USE set_tag (format_tag() proc), ADD TO THIS LIST. -/obj/machinery/New() +/obj/machinery/initialize() addAtProcessing() return ..() diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm index f402551c842..ef27a7ab606 100644 --- a/code/game/machinery/shieldgen.dm +++ b/code/game/machinery/shieldgen.dm @@ -13,7 +13,10 @@ /obj/machinery/shield/New() src.dir = pick(1,2,3,4) ..() + +/obj/machinery/shield/initialize() air_update_turf(1) + ..() /obj/machinery/shield/Destroy() opacity = 0 @@ -605,4 +608,4 @@ if (istype(mover, /obj/item/projectile)) return prob(10) else - return !src.density \ No newline at end of file + return !src.density diff --git a/code/game/objects/effects/aliens.dm b/code/game/objects/effects/aliens.dm index 320ec09a2ee..b23d1248615 100644 --- a/code/game/objects/effects/aliens.dm +++ b/code/game/objects/effects/aliens.dm @@ -31,11 +31,13 @@ var/resintype = null smooth = SMOOTH_TRUE - -/obj/structure/alien/resin/New(location) - ..() +/obj/structure/alien/resin/initialize() air_update_turf(1) - return + ..() + +/obj/structure/alien/resin/Destroy() + air_update_turf(1) + return ..() /obj/structure/alien/resin/Move() var/turf/T = loc diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index d73edde1525..abbcfa2aebc 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -1075,7 +1075,7 @@ steam.start() -- spawns the effect desc = "A lightweight foamed metal wall." var/metal = MFOAM_ALUMINUM -/obj/structure/foamedmetal/New() +/obj/structure/foamedmetal/initialize() ..() air_update_turf(1) diff --git a/code/game/objects/effects/spawners/windowspawner.dm b/code/game/objects/effects/spawners/windowspawner.dm index 31b352a7fbc..d3d2822423d 100644 --- a/code/game/objects/effects/spawners/windowspawner.dm +++ b/code/game/objects/effects/spawners/windowspawner.dm @@ -5,10 +5,15 @@ var/useFull = 0 var/useGrille = 1 var/windowtospawn = /obj/structure/window/basic + anchored = 1 // No sliding out while you prime /obj/effect/spawner/window/initialize() spawn(0) - for(var/obj/structure/grille/G in get_turf(src)) qdel(G) //just in case mappers don't know what they are doing + var/turf/T = get_turf(src) + for(var/obj/structure/grille/G in get_turf(src)) + // Complain noisily + log_debug("Extra grille on turf: ([T.x],[T.y],[T.z])") + qdel(G) //just in case mappers don't know what they are doing if(!useFull) for(var/cdir in cardinal) diff --git a/code/game/objects/structures/inflatable.dm b/code/game/objects/structures/inflatable.dm index 299f776c4f7..a1a9e47ce15 100644 --- a/code/game/objects/structures/inflatable.dm +++ b/code/game/objects/structures/inflatable.dm @@ -25,7 +25,7 @@ var/health = 50.0 -/obj/structure/inflatable/New(location) +/obj/structure/inflatable/initialize(location) ..() air_update_turf(1) diff --git a/code/game/objects/structures/mineral_doors.dm b/code/game/objects/structures/mineral_doors.dm index 01c9442ea33..52a150e0727 100644 --- a/code/game/objects/structures/mineral_doors.dm +++ b/code/game/objects/structures/mineral_doors.dm @@ -16,152 +16,155 @@ var/hardness = 1 var/oreAmount = 7 - New(location) - ..() - icon_state = mineralType - name = "[mineralType] door" - air_update_turf(1) +/obj/structure/mineral_door/New(location) + ..() + icon_state = mineralType + name = "[mineralType] door" - Destroy() - density = 0 - air_update_turf(1) - return ..() +/obj/structure/mineral_door/initialize() + ..() + air_update_turf(1) - Move() - var/turf/T = loc - ..() - move_update_air(T) +/obj/structure/mineral_door/Destroy() + density = 0 + air_update_turf(1) + return ..() - Bumped(atom/user) - ..() - if(!state) - return TryToSwitchState(user) - return +/obj/structure/mineral_door/Move() + var/turf/T = loc + ..() + move_update_air(T) - attack_ai(mob/user as mob) //those aren't machinery, they're just big fucking slabs of a mineral - if(isAI(user)) //so the AI can't open it - return - else if(isrobot(user)) //but cyborgs can - if(get_dist(user,src) <= 1) //not remotely though - return TryToSwitchState(user) - - attack_hand(mob/user as mob) +/obj/structure/mineral_door/Bumped(atom/user) + ..() + if(!state) return TryToSwitchState(user) + return - CanPass(atom/movable/mover, turf/target, height=0, air_group=0) - if(air_group) return 0 - if(istype(mover, /obj/effect/beam)) - return !opacity - return !density +/obj/structure/mineral_door/attack_ai(mob/user as mob) //those aren't machinery, they're just big fucking slabs of a mineral + if(isAI(user)) //so the AI can't open it + return + else if(isrobot(user)) //but cyborgs can + if(get_dist(user,src) <= 1) //not remotely though + return TryToSwitchState(user) - CanAtmosPass() - return !density +/obj/structure/mineral_door/attack_hand(mob/user as mob) + return TryToSwitchState(user) - proc/TryToSwitchState(atom/user) - if(isSwitchingStates) return - if(ismob(user)) - var/mob/M = user - if(world.time - user.last_bumped <= 60) return //NOTE do we really need that? - if(M.client) - if(iscarbon(M)) - var/mob/living/carbon/C = M - if(!C.handcuffed) - SwitchState() - else +/obj/structure/mineral_door/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) + if(air_group) return 0 + if(istype(mover, /obj/effect/beam)) + return !opacity + return !density + +/obj/structure/mineral_door/CanAtmosPass() + return !density + +/obj/structure/mineral_door/proc/TryToSwitchState(atom/user) + if(isSwitchingStates) return + if(ismob(user)) + var/mob/M = user + if(world.time - user.last_bumped <= 60) return //NOTE do we really need that? + if(M.client) + if(iscarbon(M)) + var/mob/living/carbon/C = M + if(!C.handcuffed) SwitchState() - else if(istype(user, /obj/mecha)) - SwitchState() + else + SwitchState() + else if(istype(user, /obj/mecha)) + SwitchState() - proc/SwitchState() - if(state) - Close() - else - Open() - - proc/Open() - isSwitchingStates = 1 - playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1) - flick("[mineralType]opening",src) - sleep(10) - density = 0 - opacity = 0 - state = 1 - update_icon() - isSwitchingStates = 0 - air_update_turf(1) - - proc/Close() - isSwitchingStates = 1 - playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1) - flick("[mineralType]closing",src) - sleep(10) - density = 1 - opacity = 1 - state = 0 - update_icon() - isSwitchingStates = 0 - air_update_turf(1) +/obj/structure/mineral_door/proc/SwitchState() + if(state) + Close() + else + Open() +/obj/structure/mineral_door/proc/Open() + isSwitchingStates = 1 + playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1) + flick("[mineralType]opening",src) + sleep(10) + density = 0 + opacity = 0 + state = 1 update_icon() - if(state) - icon_state = "[mineralType]open" - else - icon_state = mineralType + isSwitchingStates = 0 + air_update_turf(1) - attackby(obj/item/weapon/W as obj, mob/user as mob, params) - if(istype(W,/obj/item/weapon/pickaxe)) - var/obj/item/weapon/pickaxe/digTool = W - to_chat(user, "You start digging the [name].") - if(do_after(user,digTool.digspeed*hardness, target = src) && src) - to_chat(user, "You finished digging.") - Dismantle() - else if(istype(W,/obj/item/weapon)) //not sure, can't not just weapons get passed to this proc? - hardness -= W.force/100 - to_chat(user, "You hit the [name] with your [W.name]!") - CheckHardness() - else - attack_hand(user) - return +/obj/structure/mineral_door/proc/Close() + isSwitchingStates = 1 + playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1) + flick("[mineralType]closing",src) + sleep(10) + density = 1 + opacity = 1 + state = 0 + update_icon() + isSwitchingStates = 0 + air_update_turf(1) - proc/CheckHardness() - if(hardness <= 0) +/obj/structure/mineral_door/update_icon() + if(state) + icon_state = "[mineralType]open" + else + icon_state = mineralType + +/obj/structure/mineral_door/attackby(obj/item/weapon/W as obj, mob/user as mob, params) + if(istype(W,/obj/item/weapon/pickaxe)) + var/obj/item/weapon/pickaxe/digTool = W + to_chat(user, "You start digging the [name].") + if(do_after(user,digTool.digspeed*hardness, target = src) && src) + to_chat(user, "You finished digging.") + Dismantle() + else if(istype(W,/obj/item/weapon)) //not sure, can't not just weapons get passed to this proc? + hardness -= W.force/100 + to_chat(user, "You hit the [name] with your [W.name]!") + CheckHardness() + else + attack_hand(user) + return + +/obj/structure/mineral_door/proc/CheckHardness() + if(hardness <= 0) + Dismantle(1) + +/obj/structure/mineral_door/proc/Dismantle(devastated = 0) + if(!devastated) + if (mineralType == "metal") + var/ore = /obj/item/stack/sheet/metal + for(var/i = 1, i <= oreAmount, i++) + new ore(get_turf(src)) + else + var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]") + for(var/i = 1, i <= oreAmount, i++) + new ore(get_turf(src)) + else + if (mineralType == "metal") + var/ore = /obj/item/stack/sheet/metal + for(var/i = 3, i <= oreAmount, i++) + new ore(get_turf(src)) + else + var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]") + for(var/i = 3, i <= oreAmount, i++) + new ore(get_turf(src)) + qdel(src) + +/obj/structure/mineral_door/ex_act(severity = 1) + switch(severity) + if(1) Dismantle(1) - - proc/Dismantle(devastated = 0) - if(!devastated) - if (mineralType == "metal") - var/ore = /obj/item/stack/sheet/metal - for(var/i = 1, i <= oreAmount, i++) - new ore(get_turf(src)) - else - var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]") - for(var/i = 1, i <= oreAmount, i++) - new ore(get_turf(src)) - else - if (mineralType == "metal") - var/ore = /obj/item/stack/sheet/metal - for(var/i = 3, i <= oreAmount, i++) - new ore(get_turf(src)) - else - var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]") - for(var/i = 3, i <= oreAmount, i++) - new ore(get_turf(src)) - qdel(src) - - ex_act(severity = 1) - switch(severity) - if(1) + if(2) + if(prob(20)) Dismantle(1) - if(2) - if(prob(20)) - Dismantle(1) - else - hardness-- - CheckHardness() - if(3) - hardness -= 0.1 + else + hardness-- CheckHardness() - return + if(3) + hardness -= 0.1 + CheckHardness() + return /obj/structure/mineral_door/iron mineralType = "metal" @@ -285,4 +288,4 @@ CheckHardness() playsound(loc, 'sound/effects/attackblob.ogg', 100, 1) - ..() \ No newline at end of file + ..() diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index e078fa2295e..91003f20016 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -338,10 +338,13 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f ini_dir = dir if(!color && !istype(src,/obj/structure/window/plasmabasic) && !istype(src,/obj/structure/window/plasmareinforced)) color = color_windows(src) - air_update_turf(1) update_nearby_icons() return +/obj/structure/window/initialize() + air_update_turf(1) + return ..() + /obj/structure/window/Destroy() density = 0 air_update_turf(1) @@ -402,10 +405,13 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f /obj/structure/window/plasmabasic/New(Loc,re=0) ..() ini_dir = dir - air_update_turf(1) update_nearby_icons() return +/obj/structure/window/plasmabasic/initialize() + ..() + air_update_turf(1) + /obj/structure/window/plasmabasic/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume) if(exposed_temperature > T0C + 32000) hit(round(exposed_volume / 1000), 0) @@ -433,10 +439,13 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f /obj/structure/window/plasmareinforced/New(Loc,re=0) ..() ini_dir = dir - air_update_turf(1) update_nearby_icons() return +/obj/structure/window/plasmareinforced/initialize() + ..() + air_update_turf(1) + /obj/structure/window/plasmareinforced/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume) return @@ -516,4 +525,4 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f toggle_tint() /obj/machinery/button/windowtint/update_icon() - icon_state = "light[active]" \ No newline at end of file + icon_state = "light[active]" diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm index 6f5befec63e..f447810d860 100644 --- a/code/modules/admin/verbs/map_template_loadverb.dm +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -24,8 +24,10 @@ preview += image('icons/turf/overlays.dmi',S,"greenOverlay") usr.client.images += preview if(alert(usr,"Confirm location.","Template Confirm","Yes","No") == "Yes") + var/timer = start_watch() + message_admins("[key_name_admin(usr)] has started to place the map template ([template.name]) at (JMP)") if(template.load(T, centered = TRUE)) - message_admins("[key_name_admin(usr)] has placed a map template ([template.name]) at (JMP)") + message_admins("[key_name_admin(usr)] has placed a map template ([template.name]) at (JMP). Took [stop_watch(timer)]s.") else to_chat(usr, "Failed to place map") usr.client.images -= preview @@ -41,10 +43,12 @@ to_chat(usr, "Bad map file: [map]") return + var/timer = start_watch() + message_admins("[key_name_admin(usr)] has begun uploading a map template ([map])") var/datum/map_template/M = new(map=map, rename="[map]") if(M.preload_size(map)) to_chat(usr, "Map template '[map]' ready to place ([M.width]x[M.height])") map_templates[M.name] = M - message_admins("[key_name_admin(usr)] has uploaded a map template ([map])") + message_admins("[key_name_admin(usr)] has uploaded a map template ([map]). Took [stop_watch(timer)]s.") else to_chat(usr, "Map template '[map]' failed to load properly") diff --git a/code/modules/awaymissions/maploader/reader.dm b/code/modules/awaymissions/maploader/reader.dm index 62d69ef3142..6f5dc2837a4 100644 --- a/code/modules/awaymissions/maploader/reader.dm +++ b/code/modules/awaymissions/maploader/reader.dm @@ -25,6 +25,8 @@ var/global/dmm_suite/preloader/_preloader = new * e.g aa = /turf/unsimulated/wall{icon_state = "rock"} * 2) Read the map line by line, parsing the result (using parse_grid) * + * If `measureOnly` is set, then no atoms will be created, and all this will do + * is return the bounds after parsing the file */ /dmm_suite/load_map(dmm_file as file, x_offset as num, y_offset as num, z_offset as num, cropMap as num, measureOnly as num) var/tfile = dmm_file//the map file we're creating @@ -41,12 +43,14 @@ var/global/dmm_suite/preloader/_preloader = new var/list/bounds = list(1.#INF, 1.#INF, 1.#INF, -1.#INF, -1.#INF, -1.#INF) var/list/grid_models = list() var/key_len = 0 + // This ain't re-entrant + // Meaning - don't load more than one map at once, using `spawn` or whatever + var/list/old_dirty_z_levels = deepCopyList(dirty_z_levels) var/dmm_suite/loaded_map/LM = new - // It is *VERY* important that this is reset to 0 when we are done here - // Otherwise lots of things will fall apart like a milkless lich - defer_auto_init = 1 + // This try-catch is used as a budget "Finally" clause, as the "touched_z_levels" + // var needs to be reset try dmmRegex.next = 1 while(dmmRegex.Find(tfile, dmmRegex.next)) @@ -74,6 +78,8 @@ var/global/dmm_suite/preloader/_preloader = new var/xcrd var/ycrd = text2num(dmmRegex.group[4]) + y_offset - 1 var/zcrd = text2num(dmmRegex.group[5]) + z_offset - 1 + if(!measureOnly) + dirty_z_levels |= zcrd if(zcrd > world.maxz) if(cropMap) @@ -138,10 +144,13 @@ var/global/dmm_suite/preloader/_preloader = new CHECK_TICK catch(var/exception/e) - // Can't let this stay 1 or the world falls apart - defer_auto_init = 0 + if(!measureOnly) + dirty_z_levels = old_dirty_z_levels throw e - defer_auto_init = 0 + + // This *might* leak memory? Whatever it's a trivial quantity + if(!measureOnly) + dirty_z_levels = old_dirty_z_levels qdel(LM) if(bounds[MAP_MINX] == 1.#INF) // Shouldn't need to check every item log_startup_progress("Min x: bounds[MAP_MINX]") @@ -273,15 +282,11 @@ var/global/dmm_suite/preloader/_preloader = new index = first_turf_index + 1 while(index <= members.len - 1) // Last item is an /area var/underlay - if(istype(T, /turf)) // I blame this on the stupid clown who mis-mapped the solar panels + if(istype(T, /turf)) // I blame this on the stupid clown who coded the BYOND map editor underlay = T.appearance T = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)//instance new turf if(ispath(members[index],/turf)) T.underlays += underlay - else - log_debug("The maps on tile ([xcrd],[ycrd],[zcrd]) have out-of-order turfs.") - // Make them cry - message_admins("The maps on tile ([xcrd],[ycrd],[zcrd]) have out-of-order turfs.") index++ diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index 453bd019d1d..32a136b835f 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -1,11 +1,18 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away_mission_config.txt") /proc/late_setup_level(turfs, smoothTurfs) + var/total_timer = start_watch() + var/subtimer = start_watch() if(!smoothTurfs) smoothTurfs = turfs + log_debug("Setting up atmos") if(air_master) air_master.setup_allturfs(turfs) + log_debug("\tTook [stop_watch(subtimer)]s") + + subtimer = start_watch() + log_debug("Initializing objects and lighting") for(var/turf/T in turfs) if(T.dynamic_lighting) T.lighting_build_overlays() @@ -13,6 +20,10 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away makepowernet_for(PC) for(var/atom/movable/AM in T) AM.initialize() + log_debug("\tTook [stop_watch(subtimer)]s") + + subtimer = start_watch() + log_debug("Smoothing tiles") for(var/turf/T in smoothTurfs) if(T.smooth) smooth_icon(T) @@ -20,6 +31,16 @@ var/global/list/potentialRandomZlevels = generateMapList(filename = "config/away var/atom/A = R if(A.smooth) smooth_icon(A) + log_debug("\tTook [stop_watch(subtimer)]s") + + log_debug("Initializing pipenets") + // We do this once we're finished initializing since otherwise the pipes + // won't have finished connecting + for(var/turf/T in turfs) + for(var/obj/machinery/atmospherics/machine in T) + machine.build_network() + log_debug("\tTook [stop_watch(subtimer)]s") + log_debug("Late setup finished - took [stop_watch(total_timer)]s") /proc/createRandomZlevel() if(awaydestinations.len) //crude, but it saves another var! diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 3245f6872dc..ba372eb4cde 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -843,7 +843,7 @@ name = "\improper Airtight plastic flaps" desc = "Heavy duty, airtight, plastic flaps." -/obj/structure/plasticflaps/mining/New() +/obj/structure/plasticflaps/mining/initialize() air_update_turf(1) ..() @@ -857,4 +857,4 @@ #undef ORDER_SCREEN_WIDTH #undef ORDER_SCREEN_HEIGHT #undef SUPPLY_SCREEN_WIDTH -#undef SUPPLY_SCREEN_HEIGHT \ No newline at end of file +#undef SUPPLY_SCREEN_HEIGHT