From 0c3126ffad5eb7cbb6778dd6a180d84876705b37 Mon Sep 17 00:00:00 2001 From: Leshana Date: Fri, 10 Apr 2020 09:45:57 -0400 Subject: [PATCH 1/5] Fix overmap spacemove not actually re-using deepspace sectors. --- code/modules/overmap/spacetravel.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/modules/overmap/spacetravel.dm b/code/modules/overmap/spacetravel.dm index aec5c06f75c..a51cfc3f6de 100644 --- a/code/modules/overmap/spacetravel.dm +++ b/code/modules/overmap/spacetravel.dm @@ -29,14 +29,16 @@ var/list/cached_space = list() return 1 proc/get_deepspace(x,y) - var/obj/effect/overmap/visitable/sector/temporary/res = locate(x,y,global.using_map.overmap_z) + var/turf/unsimulated/map/overmap_turf = locate(x,y,global.using_map.overmap_z) + if(!istype(overmap_turf)) + CRASH("Attempt to get deepspace at ([x],[y]) which is not on overmap: [overmap_turf]") + var/obj/effect/overmap/visitable/sector/temporary/res = locate() in overmap_turf if(istype(res)) return res else if(cached_space.len) res = cached_space[cached_space.len] cached_space -= res - res.x = x - res.y = y + res.forceMove(overmap_turf) return res else return new /obj/effect/overmap/visitable/sector/temporary(x, y, global.using_map.get_empty_zlevel()) @@ -110,5 +112,5 @@ proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A) var/obj/effect/overmap/visitable/sector/temporary/source = M if (source.can_die()) testing("Caching [M] for future use") - source.loc = null + source.moveToNullspace() cached_space += source From 796c406965c8a2d3d50e280cb36a2913f79e6ba3 Mon Sep 17 00:00:00 2001 From: Leshana Date: Wed, 15 Apr 2020 19:20:59 -0400 Subject: [PATCH 2/5] Lazily create landable ship's overmap z-level on first use. - Create the landmark as normal, but instead of allocating a z-level and placing it, register a pre_move listener on the shuttle and setup the z-level only when the shuttle is about to move to its overmap landmark. - Change when shuttles fire the shuttle_pre_move_event to before calculating translation list to give us a chance to allocate the z-level. --- code/modules/overmap/overmap_shuttle.dm | 2 +- code/modules/overmap/ships/landable.dm | 44 +++++++++++++++++++++++-- code/modules/shuttles/shuttle.dm | 10 +++--- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/code/modules/overmap/overmap_shuttle.dm b/code/modules/overmap/overmap_shuttle.dm index b614137db4f..d009c538477 100644 --- a/code/modules/overmap/overmap_shuttle.dm +++ b/code/modules/overmap/overmap_shuttle.dm @@ -42,7 +42,7 @@ if(moving_status == SHUTTLE_INTRANSIT) return FALSE //already going somewhere, current_location may be an intransit location instead of in a sector var/our_sector = waypoint_sector(current_location) - if(!our_sector && myship?.landmark && next_location == myship.landmark) + if(myship?.landmark && next_location == myship.landmark) return TRUE //We're not on the overmap yet (admin spawned probably), and we're trying to hook up with our openspace sector return get_dist(our_sector, waypoint_sector(next_location)) <= range diff --git a/code/modules/overmap/ships/landable.dm b/code/modules/overmap/ships/landable.dm index 0a28eefd8d2..fed030ba6f8 100644 --- a/code/modules/overmap/ships/landable.dm +++ b/code/modules/overmap/ships/landable.dm @@ -11,6 +11,7 @@ moving_state = "shuttle_moving" /obj/effect/overmap/visitable/ship/landable/Destroy() + GLOB.shuttle_pre_move_event.unregister(SSshuttles.shuttles[shuttle], src) GLOB.shuttle_moved_event.unregister(SSshuttles.shuttles[shuttle], src) return ..() @@ -34,13 +35,18 @@ // We autobuild our z levels. /obj/effect/overmap/visitable/ship/landable/find_z_levels() + src.landmark = new(null, shuttle) // Create in nullspace since we lazy-create overmap z + add_landmark(landmark, shuttle) + +/obj/effect/overmap/visitable/ship/landable/proc/setup_overmap_location() + if(LAZYLEN(map_z)) + return // We're already set up! for(var/i = 0 to multiz) world.increment_max_z() map_z += world.maxz var/turf/center_loc = locate(round(world.maxx/2), round(world.maxy/2), world.maxz) - landmark = new (center_loc, shuttle) - add_landmark(landmark, shuttle) + landmark.forceMove(center_loc) var/visitor_dir = fore_dir for(var/landmark_name in list("FORE", "PORT", "AFT", "STARBOARD")) @@ -51,6 +57,8 @@ if(multiz) new /obj/effect/landmark/map_data(center_loc, (multiz + 1)) + register_z_levels() + testing("Setup overmap location for \"[name]\" containing Z [english_list(map_z)]") /obj/effect/overmap/visitable/ship/landable/get_areas() var/datum/shuttle/shuttle_datum = SSshuttles.shuttles[shuttle] @@ -64,13 +72,19 @@ if(istype(shuttle_datum,/datum/shuttle/autodock/overmap)) var/datum/shuttle/autodock/overmap/oms = shuttle_datum oms.myship = src + GLOB.shuttle_pre_move_event.register(shuttle_datum, src, .proc/pre_shuttle_jump) GLOB.shuttle_moved_event.register(shuttle_datum, src, .proc/on_shuttle_jump) on_landing(landmark, shuttle_datum.current_location) // We "land" at round start to properly place ourselves on the overmap. + +// +// Center Landmark +// + /obj/effect/shuttle_landmark/ship name = "Open Space" landmark_tag = "ship" - flags = SLANDMARK_FLAG_AUTOSET | SLANDMARK_FLAG_ZERO_G + flags = SLANDMARK_FLAG_ZERO_G // *Not* AUTOSET, these must be world.turf and world.area for lazy loading to work. var/shuttle_name var/list/visitors // landmark -> visiting shuttle stationed there @@ -78,6 +92,7 @@ landmark_tag += "_[shuttle_name]" src.shuttle_name = shuttle_name . = ..() + base_turf = world.turf /obj/effect/shuttle_landmark/ship/Destroy() var/obj/effect/overmap/visitable/ship/landable/ship = get_overmap_sector(z) @@ -85,10 +100,22 @@ ship.landmark = null . = ..() +/obj/effect/shuttle_landmark/ship/is_valid(datum/shuttle/shuttle) + return (isnull(loc) || ..()) // If it doesn't exist yet, its clear + +/obj/effect/shuttle_landmark/ship/create_warning_effect(var/datum/shuttle/shuttle) + if(isnull(loc)) + return + ..() + /obj/effect/shuttle_landmark/ship/cannot_depart(datum/shuttle/shuttle) if(LAZYLEN(visitors)) return "Grappled by other shuttle; cannot manouver." +// +// Visitor Landmark +// + /obj/effect/shuttle_landmark/visiting_shuttle flags = SLANDMARK_FLAG_AUTOSET | SLANDMARK_FLAG_ZERO_G var/obj/effect/shuttle_landmark/ship/core_landmark @@ -125,6 +152,17 @@ GLOB.shuttle_moved_event.unregister(shuttle, src) LAZYREMOVE(core_landmark.visitors, src) +// +// More ship procs +// + +/obj/effect/overmap/visitable/ship/landable/proc/pre_shuttle_jump(datum/shuttle/given_shuttle, obj/effect/shuttle_landmark/from, obj/effect/shuttle_landmark/into) + if(given_shuttle != SSshuttles.shuttles[shuttle]) + return + if(into == landmark) + setup_overmap_location() // They're coming boys, better actually exist! + GLOB.shuttle_pre_move_event.unregister(SSshuttles.shuttles[shuttle], src) + /obj/effect/overmap/visitable/ship/landable/proc/on_shuttle_jump(datum/shuttle/given_shuttle, obj/effect/shuttle_landmark/from, obj/effect/shuttle_landmark/into) if(given_shuttle != SSshuttles.shuttles[shuttle]) return diff --git a/code/modules/shuttles/shuttle.dm b/code/modules/shuttles/shuttle.dm index 808a1f55e7d..dd8e9ec3f38 100644 --- a/code/modules/shuttles/shuttle.dm +++ b/code/modules/shuttles/shuttle.dm @@ -249,16 +249,16 @@ log_shuttle("Shuttle [src] aborting attempt_move() because current_location=[current_location] refuses.") return FALSE + // Observer pattern pre-move + var/old_location = current_location + GLOB.shuttle_pre_move_event.raise_event(src, old_location, destination) + current_location.shuttle_departed(src) + log_shuttle("[src] moving to [destination]. Areas are [english_list(shuttle_area)]") var/list/translation = list() for(var/area/A in shuttle_area) log_shuttle("Translating [A]") translation += get_turf_translation(get_turf(current_location), get_turf(destination), A.contents) - var/old_location = current_location - - // Observer pattern pre-move - GLOB.shuttle_pre_move_event.raise_event(src, old_location, destination) - current_location.shuttle_departed(src) // Actually do it! (This never fails) perform_shuttle_move(destination, translation) From d16b756e0724424c6effbb061dbe959ebd579102 Mon Sep 17 00:00:00 2001 From: Leshana Date: Fri, 17 Apr 2020 10:50:09 -0400 Subject: [PATCH 3/5] Fix: Forgot to include champagne.dm in dme --- vorestation.dme | 1 + 1 file changed, 1 insertion(+) diff --git a/vorestation.dme b/vorestation.dme index 7104696b6a5..a7b4957d8b4 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -2906,6 +2906,7 @@ #include "code\modules\organs\subtypes\vox_vr.dm" #include "code\modules\organs\subtypes\xenos.dm" #include "code\modules\overmap\bluespace_rift_vr.dm" +#include "code\modules\overmap\champagne.dm" #include "code\modules\overmap\helpers.dm" #include "code\modules\overmap\overmap_object.dm" #include "code\modules\overmap\overmap_shuttle.dm" From 45e71373d3ac34f6dcade79edfcfd5524af28350 Mon Sep 17 00:00:00 2001 From: Leshana Date: Fri, 17 Apr 2020 11:34:28 -0400 Subject: [PATCH 4/5] Mapped in shuttle landmarks won't append their own coordinates to their name. - Could be meta-info in some circumstances, and redundant in most well-named landmarks. Automatics still do it. --- code/modules/shuttles/landmarks.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/shuttles/landmarks.dm b/code/modules/shuttles/landmarks.dm index 38f2d41f25c..290d22a98f6 100644 --- a/code/modules/shuttles/landmarks.dm +++ b/code/modules/shuttles/landmarks.dm @@ -44,7 +44,6 @@ else base_area = locate(base_area || world.area) - name = (name + " ([x],[y])") SSshuttles.register_landmark(landmark_tag, src) /obj/effect/shuttle_landmark/LateInitialize() From 1f21e7c0f262c0552da2bd17022bfb315c375732 Mon Sep 17 00:00:00 2001 From: Leshana Date: Fri, 17 Apr 2020 11:35:34 -0400 Subject: [PATCH 5/5] Automatic landmarks respect mapped-in name overrides. If a mapper puts an automatic landmark and overrides the name var, that is now respected instead of overwritten. Note that initial(name) does *not* reset to mapped in values, but the value in code. --- code/modules/shuttles/landmarks.dm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/modules/shuttles/landmarks.dm b/code/modules/shuttles/landmarks.dm index 290d22a98f6..0c750dc2465 100644 --- a/code/modules/shuttles/landmarks.dm +++ b/code/modules/shuttles/landmarks.dm @@ -123,14 +123,16 @@ name = "Navpoint" landmark_tag = "navpoint" flags = SLANDMARK_FLAG_AUTOSET + var/original_name = null // Save our mapped-in name so we can rebuild our name when moving sectors. /obj/effect/shuttle_landmark/automatic/Initialize() + original_name = name landmark_tag += "-[x]-[y]-[z]-[random_id("landmarks",1,9999)]" return ..() /obj/effect/shuttle_landmark/automatic/sector_set(var/obj/effect/overmap/visitable/O) ..() - name = ("[O.name] - [initial(name)] ([x],[y])") + name = ("[O.name] - [original_name] ([x],[y])") //Subtype that calls explosion on init to clear space for shuttles /obj/effect/shuttle_landmark/automatic/clearing