From 9d27ebea75d79ab8612d0aa96fdf812c669e3f77 Mon Sep 17 00:00:00 2001 From: S34N <12197162+S34NW@users.noreply.github.com> Date: Wed, 16 Nov 2022 20:14:13 +0000 Subject: [PATCH] ensures map templates don't kill server (#19690) --- code/datums/helper_datums/map_template.dm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/code/datums/helper_datums/map_template.dm b/code/datums/helper_datums/map_template.dm index 0d44c3aa3c8..ffdb439efbc 100644 --- a/code/datums/helper_datums/map_template.dm +++ b/code/datums/helper_datums/map_template.dm @@ -51,15 +51,21 @@ // if given a multi-z template // it might need to be adapted for that when that time comes GLOB.space_manager.add_dirt(placement.z) - var/list/bounds = GLOB.maploader.load_map(get_file(), min_x, min_y, placement.z, shouldCropMap = TRUE) - if(!bounds) - return 0 - if(bot_left == null || top_right == null) - stack_trace("One of the late setup corners is bust") - - if(ST_bot_left == null || ST_top_right == null) - stack_trace("One of the smoothing corners is bust") + try + var/list/bounds = GLOB.maploader.load_map(get_file(), min_x, min_y, placement.z, shouldCropMap = TRUE) + if(!bounds) + return 0 + if(bot_left == null || top_right == null) + stack_trace("One of the late setup corners is bust") + if(ST_bot_left == null || ST_top_right == null) + stack_trace("One of the smoothing corners is bust") + catch(var/exception/e) + GLOB.space_manager.remove_dirt(placement.z) + late_setup_level(block(bot_left, top_right), block(ST_bot_left, ST_top_right)) + message_admins("Map template [name] threw an error while loading. Safe exit attempted, but check for errors at [ADMIN_COORDJMP(placement)].") + log_admin("Map template [name] threw an error while loading. Safe exit attempted.") + throw e GLOB.space_manager.remove_dirt(placement.z) late_setup_level( block(bot_left, top_right),