Fix getting stuck in deep space because of bad creation of deep space temporary sectors

Deep Space temporary sectors were being created on Z1 instead of the overmap, and with a bad map_z list.
- Initialize was taking the wrong parameters, resulting in the sector being always located at 1,?,1 instead of on the overmap
  Fix by passing the first parameter to new() as the location you want the object, as is proper for BYOND.
- Also fixed map_z containing a zero, it was put there by the sector Initialize().
  Fix by setting the appropriate values *before* calling parent.
This commit is contained in:
Leshana
2021-10-18 18:35:01 -04:00
parent e667e86813
commit 73ae0c0df2
+12 -9
View File
@@ -5,15 +5,16 @@
known = FALSE
in_space = TRUE
/obj/effect/overmap/visitable/sector/temporary/Initialize(var/nx, var/ny)
/obj/effect/overmap/visitable/sector/temporary/Initialize()
if(!istype(loc, /turf/unsimulated/map))
CRASH("Attempt to create deepspace which is not on overmap: [log_info_line(loc)]")
// Tell sector initializer where are is where we want to be.
start_x = loc.x
start_y = loc.y
// But pick an empty z level to use
map_z += global.using_map.get_empty_zlevel()
. = ..()
loc = locate(nx, ny, global.using_map.overmap_z)
x = nx
y = ny
var/emptyz = global.using_map.get_empty_zlevel()
map_z += emptyz
map_sectors["[emptyz]"] = src
testing("Temporary sector at [x],[y] was created, corresponding zlevel is [emptyz].")
testing("Temporary sector at [x],[y],[z] was created, corresponding zlevel is [english_list(map_z)].")
/obj/effect/overmap/visitable/sector/temporary/Destroy()
for(var/zlevel in map_z)
@@ -43,7 +44,7 @@
var/obj/effect/overmap/visitable/sector/temporary/res = locate() in overmap_turf
if(istype(res))
return res
return new /obj/effect/overmap/visitable/sector/temporary(x, y)
return new /obj/effect/overmap/visitable/sector/temporary(overmap_turf)
/atom/movable/proc/lost_in_space()
for(var/atom/movable/AM in contents)
@@ -133,6 +134,8 @@
TM = get_deepspace(M.x,M.y)
nz = pick(TM.get_space_zlevels())
testing("spacetravel chose [nz],[ny],[nz] in sector [TM] @ ([TM.x],[TM.y],[TM.z])")
var/turf/dest = locate(nx,ny,nz)
if(istype(dest))
A.forceMove(dest)