diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm
index dbad4bf4c9e..25091c58c12 100644
--- a/code/__DEFINES/misc.dm
+++ b/code/__DEFINES/misc.dm
@@ -305,6 +305,7 @@ GLOBAL_LIST_INIT(pda_styles, sortList(list(MONO, VT, ORBITRON, SHARE)))
#define SHELTER_DEPLOY_BAD_TURFS "bad turfs"
#define SHELTER_DEPLOY_BAD_AREA "bad area"
#define SHELTER_DEPLOY_ANCHORED_OBJECTS "anchored objects"
+#define SHELTER_DEPLOY_OUTSIDE_MAP "outside map"
//debug printing macros
#define debug_world(msg) if (GLOB.Debug2) to_chat(world, \
diff --git a/code/modules/mining/equipment/survival_pod.dm b/code/modules/mining/equipment/survival_pod.dm
index 365d9d75a31..dd2083d729f 100644
--- a/code/modules/mining/equipment/survival_pod.dm
+++ b/code/modules/mining/equipment/survival_pod.dm
@@ -49,22 +49,21 @@
switch(status)
if(SHELTER_DEPLOY_BAD_AREA)
src.loc.visible_message("\The [src] will not function in this area.")
- if(SHELTER_DEPLOY_BAD_TURFS, SHELTER_DEPLOY_ANCHORED_OBJECTS)
+ if(SHELTER_DEPLOY_BAD_TURFS, SHELTER_DEPLOY_ANCHORED_OBJECTS, SHELTER_DEPLOY_OUTSIDE_MAP)
var/width = template.width
var/height = template.height
src.loc.visible_message("\The [src] doesn't have room to deploy! You need to clear a [width]x[height] area!")
-
if(status != SHELTER_DEPLOY_ALLOWED)
used = FALSE
return
- playsound(src, 'sound/effects/phasein.ogg', 100, TRUE)
-
+ template.load(deploy_location, centered = TRUE)
var/turf/T = deploy_location
if(!is_mining_level(T.z)) //only report capsules away from the mining/lavaland level
message_admins("[ADMIN_LOOKUPFLW(usr)] activated a bluespace capsule away from the mining level! [ADMIN_VERBOSEJMP(T)]")
log_admin("[key_name(usr)] activated a bluespace capsule away from the mining level at [AREACOORD(T)]")
- template.load(deploy_location, centered = TRUE)
+
+ playsound(src, 'sound/effects/phasein.ogg', 100, TRUE)
new /obj/effect/particle_effect/smoke(get_turf(src))
qdel(src)
diff --git a/code/modules/mining/shelters.dm b/code/modules/mining/shelters.dm
index 2481634e5f1..4d99d296c1f 100644
--- a/code/modules/mining/shelters.dm
+++ b/code/modules/mining/shelters.dm
@@ -28,6 +28,15 @@
for(var/obj/O in T)
if((O.density && O.anchored) || is_type_in_typecache(O, banned_objects))
return SHELTER_DEPLOY_ANCHORED_OBJECTS
+
+ // Check if the shelter sticks out of map borders
+ var/shelter_origin_x = deploy_location.x - round(width/2)
+ if(shelter_origin_x <= 1 || shelter_origin_x+width > world.maxx)
+ return SHELTER_DEPLOY_OUTSIDE_MAP
+ var/shelter_origin_y = deploy_location.y - round(height/2)
+ if(shelter_origin_y <= 1 || shelter_origin_y+height > world.maxy)
+ return SHELTER_DEPLOY_OUTSIDE_MAP
+
return SHELTER_DEPLOY_ALLOWED
/datum/map_template/shelter/alpha