From a9be1e06e219c76990e2dd48160b69365a76ccec Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Fri, 24 Apr 2020 23:00:31 +0200 Subject: [PATCH] Fixing stuff, it now should be ready. --- .../configuration/entries/game_options.dm | 2 ++ code/controllers/subsystem/mapping.dm | 12 +++++------- code/modules/awaymissions/zlevel.dm | 18 ++++++++++++------ code/modules/mapping/map_template.dm | 2 +- config/game_options.txt | 3 +++ config/vr_config.txt | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 1312183750..3c2d18d69c 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -288,6 +288,8 @@ /datum/config_entry/flag/roundstart_away //Will random away mission be loaded. +/datum/config_entry/flag/roundstart_vr //Will virtual reality missions be loaded? + /datum/config_entry/number/gateway_delay //How long the gateway takes before it activates. Default is half an hour. Only matters if roundstart_away is enabled. config_entry_value = 18000 min_val = 0 diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 34e7439c38..89155cefb3 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -1,3 +1,5 @@ +#define INIT_ANNOUNCE(X) to_chat(world, "[X]"); log_world(X) + SUBSYSTEM_DEF(mapping) name = "Mapping" init_order = INIT_ORDER_MAPPING @@ -183,7 +185,6 @@ SUBSYSTEM_DEF(mapping) z_list = SSmapping.z_list -#define INIT_ANNOUNCE(X) to_chat(world, "[X]"); log_world(X) /datum/controller/subsystem/mapping/proc/LoadGroup(list/errorList, name, path, files, list/traits, list/default_traits, silent = FALSE) . = list() var/start_time = REALTIMEOFDAY @@ -267,7 +268,6 @@ SUBSYSTEM_DEF(mapping) msg += ", [FailedZs[I]]" msg += ". Yell at your server host!" INIT_ANNOUNCE(msg) -#undef INIT_ANNOUNCE GLOBAL_LIST_EMPTY(the_station_areas) @@ -450,14 +450,12 @@ GLOBAL_LIST_EMPTY(the_station_areas) lvl_name = "[mapfile] custom" to_chat(usr,"Loading [lvl_name]...") var/datum/map_template/template = new(mapfile, choice, ztraits) - level = template.load_new_z() + level = template.load_new_z(ztraits) else lvl_name = answer to_chat(usr,"Loading [lvl_name]...") - var/datum/map_template/template = new(lvl_name, choice, ztraits) - level = template.load_new_z() - else - return + var/datum/map_template/template = new(lvl_name, choice) + level = template.load_new_z(ztraits) message_admins("Admin [key_name_admin(usr)] has loaded [lvl_name] [choice].") log_admin("Admin [key_name(usr)] has loaded [lvl_name] [choice].") diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index 55a1c9dcc4..6c8d8287d8 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -1,13 +1,19 @@ -/proc/createRandomZlevel(name = AWAY_MISSION_NAME, list/traits = list(ZTRAIT_AWAY = TRUE), list/potential_levels = potential_away_levels) - if(GLOB.random_zlevels_generated[name] || !length(potential_levels)) +/proc/createRandomZlevel(name = AWAY_MISSION_NAME, list/traits = list(ZTRAIT_AWAY = TRUE), list/potential_levels = GLOB.potential_away_levels) + if(GLOB.random_zlevels_generated[name]) + stack_trace("[name] level already generated.") + return + if(!length(potential_levels)) + stack_trace("No potential [name] level to load has been found.") return - to_chat(world, "Loading [name]...") + var/start_time = REALTIMEOFDAY var/map = pick(potential_levels) - load_new_z_level(map, name, traits) - to_chat(world, "[name] loaded.") - random_zlevels_generated[name] = TRUE + if(!load_new_z_level(map, name, traits)) + INIT_ANNOUNCE("Failed to load [name]! map filepath: [map]!") + return + INIT_ANNOUNCE("Loaded [name] in [(REALTIMEOFDAY - start_time)/10]s!") + GLOB.random_zlevels_generated[name] = TRUE /proc/reset_gateway_spawns(reset = FALSE) for(var/obj/machinery/gateway/G in world) diff --git a/code/modules/mapping/map_template.dm b/code/modules/mapping/map_template.dm index 5d8acec7e8..873c10fc02 100644 --- a/code/modules/mapping/map_template.dm +++ b/code/modules/mapping/map_template.dm @@ -123,4 +123,4 @@ //❤ - Cyberboss /proc/load_new_z_level(file, name, list/traits) var/datum/map_template/template = new(file, name) - template.load_new_z(traits) + return template.load_new_z(traits) diff --git a/config/game_options.txt b/config/game_options.txt index e1294f688a..781be6d5b1 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -288,6 +288,9 @@ MINIMUM_SECBORG_ALERT 3 ## Uncomment to load one of the missions from awaymissionconfig.txt at roundstart. #ROUNDSTART_AWAY +## Uncomment to load one of the virtual reality levels from vr_config at roundstart. +#ROUNDSTART_VR + ## How long the delay is before the Away Mission gate opens. Default is half an hour. ## 600 is one minute. GATEWAY_DELAY 18000 diff --git a/config/vr_config.txt b/config/vr_config.txt index a68a75e654..0e8532eba5 100644 --- a/config/vr_config.txt +++ b/config/vr_config.txt @@ -9,5 +9,5 @@ #DO tick the associated code file for the virtual reality levels you are enabling. Otherwise, the map will be trying to reference objects which do not exist, which will cause runtime errors! _maps/RandomZLevels/VR/murderdome.dmm -_maps/RandomZLevels/VR/snowdin_VR.dm -_maps/RandomZLevels/VR/syndicate_trainer.dm \ No newline at end of file +_maps/RandomZLevels/VR/snowdin_VR.dmm +_maps/RandomZLevels/VR/syndicate_trainer.dmm \ No newline at end of file