From 1dd3bb45328e9df18b2a32a06da51be0ee33c5b5 Mon Sep 17 00:00:00 2001 From: Neerti Date: Wed, 12 Dec 2018 20:54:35 -0500 Subject: [PATCH] Stops initialization from grinding to a halt when loading maps --- code/controllers/subsystem.dm | 2 ++ code/controllers/subsystems/mapping.dm | 29 +++++++++++++++++++ .../admin/verbs/map_template_loadverb.dm | 10 +++---- code/modules/maps/tg/map_template.dm | 24 ++++----------- code/world.dm | 14 ++++----- vorestation.dme | 4 +++ 6 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 code/controllers/subsystems/mapping.dm diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index dcb52a8cb3..8c0b6fa5de 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -6,6 +6,7 @@ var/priority = FIRE_PRIORITY_DEFAULT //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep var/flags = 0 //see MC.dm in __DEFINES Most flags must be set on world start to take full effect. (You can also restart the mc to force them to process again) + var/subsystem_initialized = FALSE //set to TRUE after it has been initialized, will obviously never be set if the subsystem doesn't initialize var/runlevels = RUNLEVELS_DEFAULT //points of the game at which the SS can fire //set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later @@ -154,6 +155,7 @@ //used to initialize the subsystem AFTER the map has loaded /datum/controller/subsystem/Initialize(start_timeofday) + subsystem_initialized = TRUE var/time = (REALTIMEOFDAY - start_timeofday) / 10 var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!" to_chat(world, "[msg]") diff --git a/code/controllers/subsystems/mapping.dm b/code/controllers/subsystems/mapping.dm new file mode 100644 index 0000000000..445a291628 --- /dev/null +++ b/code/controllers/subsystems/mapping.dm @@ -0,0 +1,29 @@ +// Handles map-related tasks, mostly here to ensure it does so after the MC initializes. +SUBSYSTEM_DEF(mapping) + name = "Mapping" + init_order = INIT_ORDER_MAPPING + flags = SS_NO_FIRE + + var/list/map_templates = list() + var/dmm_suite/maploader = null + +/datum/controller/subsystem/mapping/Initialize(timeofday) + if(subsystem_initialized) + return + maploader = new() + load_map_templates() + + if(config.generate_map) + // Map-gen is still very specific to the map, however putting it here should ensure it loads in the correct order. + if(using_map.perform_map_generation()) + using_map.refresh_mining_turfs() + + +/datum/controller/subsystem/mapping/proc/load_map_templates() + for(var/T in subtypesof(/datum/map_template)) + var/datum/map_template/template = T + if(!(initial(template.mappath))) // If it's missing the actual path its probably a base type or being used for inheritence. + continue + template = new T() + map_templates[template.name] = template + return TRUE diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm index d0504e0223..85147c275b 100644 --- a/code/modules/admin/verbs/map_template_loadverb.dm +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -5,10 +5,10 @@ var/datum/map_template/template - var/map = input(usr, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in map_templates + var/map = input(usr, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in SSmapping.map_templates if(!map) return - template = map_templates[map] + template = SSmapping.map_templates[map] var/orientation = text2dir(input(usr, "Choose an orientation for this Map Template.", "Orientation") as null|anything in list("North", "South", "East", "West")) if(!orientation) @@ -41,10 +41,10 @@ var/datum/map_template/template - var/map = input(usr, "Choose a Map Template to place on a new Z-level.","Place Map Template") as null|anything in map_templates + var/map = input(usr, "Choose a Map Template to place on a new Z-level.","Place Map Template") as null|anything in SSmapping.map_templates if(!map) return - template = map_templates[map] + template = SSmapping.map_templates[map] var/orientation = text2dir(input(usr, "Choose an orientation for this Map Template.", "Orientation") as null|anything in list("North", "South", "East", "West")) if(!orientation) @@ -76,7 +76,7 @@ var/datum/map_template/M = new(map, "[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 + SSmapping.map_templates[M.name] = M message_admins("[key_name_admin(usr)] has uploaded a map template ([map])") else to_chat(usr, "Map template '[map]' failed to load properly") diff --git a/code/modules/maps/tg/map_template.dm b/code/modules/maps/tg/map_template.dm index 6606072c55..f91dfdb813 100644 --- a/code/modules/maps/tg/map_template.dm +++ b/code/modules/maps/tg/map_template.dm @@ -1,15 +1,3 @@ -var/list/global/map_templates = list() - -// Called when the world starts, in world.dm -/proc/load_map_templates() - for(var/T in subtypesof(/datum/map_template)) - var/datum/map_template/template = T - if(!(initial(template.mappath))) // If it's missing the actual path its probably a base type or being used for inheritence. - continue - template = new T() - map_templates[template.name] = template - return TRUE - /datum/map_template var/name = "Default Template Name" var/desc = "Some text should go here. Maybe." @@ -27,8 +15,6 @@ var/list/global/map_templates = list() var/allow_duplicates = FALSE // If false, only one map template will be spawned by the game. Doesn't affect admins spawning then manually. 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. - var/static/dmm_suite/maploader = new - /datum/map_template/New(path = null, rename = null) if(path) mappath = path @@ -39,7 +25,7 @@ var/list/global/map_templates = list() name = rename /datum/map_template/proc/preload_size(path, orientation = SOUTH) - var/bounds = maploader.load_map(file(path), 1, 1, 1, cropMap=FALSE, measureOnly=TRUE, orientation=orientation) + var/bounds = SSmapping.maploader.load_map(file(path), 1, 1, 1, cropMap=FALSE, measureOnly=TRUE, orientation=orientation) if(bounds) width = bounds[MAP_MAXX] // Assumes all templates are rectangular, have a single Z level, and begin at 1,1,1 height = bounds[MAP_MAXY] @@ -91,7 +77,7 @@ var/list/global/map_templates = list() x = round((world.maxx - width)/2) y = round((world.maxy - height)/2) - var/list/bounds = maploader.load_map(file(mappath), x, y, no_changeturf = TRUE, orientation=orientation) + var/list/bounds = SSmapping.maploader.load_map(file(mappath), x, y, no_changeturf = TRUE, orientation=orientation) if(!bounds) return FALSE @@ -117,7 +103,7 @@ var/list/global/map_templates = list() if(annihilate) annihilate_bounds(old_T, centered, orientation) - var/list/bounds = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, orientation = orientation) + var/list/bounds = SSmapping.maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, orientation = orientation) if(!bounds) return @@ -176,8 +162,8 @@ var/list/global/map_templates = list() var/list/priority_submaps = list() // Submaps that will always be placed. // Lets go find some submaps to make. - for(var/map in map_templates) - var/datum/map_template/MT = map_templates[map] + for(var/map in SSmapping.map_templates) + var/datum/map_template/MT = SSmapping.map_templates[map] if(!MT.allow_duplicates && MT.loaded > 0) // This probably won't be an issue but we might as well. continue if(!istype(MT, desired_map_template_type)) // Not the type wanted. diff --git a/code/world.dm b/code/world.dm index 7bcf361ac4..604e598e7e 100644 --- a/code/world.dm +++ b/code/world.dm @@ -85,13 +85,6 @@ var/global/datum/global_init/init = new () // This is kinda important. Set up details of what the hell things are made of. populate_material_list() - // Loads all the pre-made submap templates. - load_map_templates() - - if(config.generate_map) - if(using_map.perform_map_generation()) - using_map.refresh_mining_turfs() - // Create frame types. populate_frame_types() @@ -427,12 +420,17 @@ var/world_topic_spam_protect_time = world.timeofday /*spawn(0) world << sound(pick('sound/AI/newroundsexy.ogg','sound/misc/apcdestroyed.ogg','sound/misc/bangindonk.ogg')) // random end sounds!! - LastyBatsy */ +<<<<<<< HEAD + + log_world("World rebooted at [time_stamp()]") + ..() + if (reason || fast_track) //special reboot, do none of the normal stuff if (usr) log_admin("[key_name(usr)] Has requested an immediate world restart via client side debugging tools") message_admins("[key_name_admin(usr)] Has requested an immediate world restart via client side debugging tools") world << "[key_name_admin(usr)] has requested an immediate world restart via client side debugging tools" - + else world << "Rebooting world immediately due to host request" else diff --git a/vorestation.dme b/vorestation.dme index 3806fae488..7f04cda0b9 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -223,8 +223,12 @@ #include "code\controllers\subsystems\inactivity.dm" #include "code\controllers\subsystems\lighting.dm" #include "code\controllers\subsystems\machines.dm" +<<<<<<< HEAD:vorestation.dme #include "code\controllers\subsystems\mapping_vr.dm" #include "code\controllers\subsystems\mobs.dm" +======= +#include "code\controllers\subsystems\mapping.dm" +>>>>>>> ec4e2be... Merge pull request #5778 from Neerti/emergency_maploader_fix:polaris.dme #include "code\controllers\subsystems\orbits.dm" #include "code\controllers\subsystems\overlays.dm" #include "code\controllers\subsystems\persist_vr.dm"