From 942ed8d80621f522fe357a213b2495753915097f Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Fri, 10 Apr 2020 19:42:18 -0400 Subject: [PATCH] Adds an overmap helper to find what sector you're in --- code/controllers/subsystems/shuttles.dm | 2 +- code/controllers/subsystems/skybox.dm | 2 +- code/game/turfs/turf.dm | 2 +- code/modules/overmap/_defines.dm | 145 ------------------- code/modules/overmap/helpers.dm | 5 + code/modules/overmap/overmap_shuttle.dm | 2 +- code/modules/overmap/ships/computers/ship.dm | 2 +- code/modules/overmap/ships/landable.dm | 4 +- code/modules/overmap/spacetravel.dm | 2 +- code/modules/overmap/turfs.dm | 2 +- code/modules/shuttles/landmarks.dm | 6 +- code/modules/shuttles/shuttle_autodock.dm | 2 +- code/modules/shuttles/shuttle_console.dm | 2 +- vorestation.dme | 1 + 14 files changed, 20 insertions(+), 159 deletions(-) delete mode 100644 code/modules/overmap/_defines.dm create mode 100644 code/modules/overmap/helpers.dm diff --git a/code/controllers/subsystems/shuttles.dm b/code/controllers/subsystems/shuttles.dm index 27bbbae027..38ef891019 100644 --- a/code/controllers/subsystems/shuttles.dm +++ b/code/controllers/subsystems/shuttles.dm @@ -103,7 +103,7 @@ SUBSYSTEM_DEF(shuttles) try_add_landmark_tag(shuttle_landmark_tag, O) landmarks_still_needed -= shuttle_landmark_tag else if(istype(shuttle_landmark, /obj/effect/shuttle_landmark/automatic)) //These find their sector automatically - O = map_sectors["[shuttle_landmark.z]"] + O = get_overmap_sector(get_z(shuttle_landmark)) O ? O.add_landmark(shuttle_landmark, shuttle_landmark.shuttle_restricted) : (landmarks_awaiting_sector += shuttle_landmark) /datum/controller/subsystem/shuttles/proc/get_landmark(var/shuttle_landmark_tag) diff --git a/code/controllers/subsystems/skybox.dm b/code/controllers/subsystems/skybox.dm index 404525b439..356458517d 100644 --- a/code/controllers/subsystems/skybox.dm +++ b/code/controllers/subsystems/skybox.dm @@ -87,7 +87,7 @@ SUBSYSTEM_DEF(skybox) res.overlays += base if(global.using_map.use_overmap && settings.use_overmap_details) - var/obj/effect/overmap/visitable/O = map_sectors["[z]"] + var/obj/effect/overmap/visitable/O = get_overmap_sector(z) if(istype(O)) var/image/overmap = image(settings.icon) overmap.overlays += O.generate_skybox() diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index ca177403ac..187f3a2775 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -251,7 +251,7 @@ var/const/enterloopsanity = 100 /turf/proc/inertial_drift(atom/movable/A as mob|obj) if(!(A.last_move)) return - if((istype(A, /mob/) && src.x > 2 && src.x < (world.maxx - 1) && src.y > 2 && src.y < (world.maxy-1))) + if((istype(A, /mob/) && src.x > 1 && src.x < (world.maxx) && src.y > 1 && src.y < (world.maxy))) var/mob/M = A if(M.Process_Spacemove(1)) M.inertia_dir = 0 diff --git a/code/modules/overmap/_defines.dm b/code/modules/overmap/_defines.dm deleted file mode 100644 index 6cfde46793..0000000000 --- a/code/modules/overmap/_defines.dm +++ /dev/null @@ -1,145 +0,0 @@ -//How far from the edge of overmap zlevel could randomly placed objects spawn -#define OVERMAP_EDGE 2 - -#define SHIP_SIZE_TINY 1 -#define SHIP_SIZE_SMALL 2 -#define SHIP_SIZE_LARGE 3 - -//multipliers for max_speed to find 'slow' and 'fast' speeds for the ship -#define SHIP_SPEED_SLOW 1/(40 SECONDS) -#define SHIP_SPEED_FAST 3/(20 SECONDS)// 15 speed - -#define OVERMAP_WEAKNESS_NONE 0 -#define OVERMAP_WEAKNESS_FIRE 1 -#define OVERMAP_WEAKNESS_EMP 2 -#define OVERMAP_WEAKNESS_MINING 4 -#define OVERMAP_WEAKNESS_EXPLOSIVE 8 - -//Dimension of overmap (squares 4 lyfe) -var/global/list/map_sectors = list() - -/area/overmap/ - name = "System Map" - icon_state = "start" - requires_power = 0 - base_turf = /turf/unsimulated/map - -/turf/unsimulated/map - icon = 'icons/turf/space.dmi' - icon_state = "map" - initialized = FALSE // TODO - Fix unsimulated turf initialization so this override is not necessary! - -/turf/unsimulated/map/edge - opacity = 1 - density = 1 - -/turf/unsimulated/map/Initialize() - . = ..() - name = "[x]-[y]" - var/list/numbers = list() - - if(x == 1 || x == global.using_map.overmap_size) - numbers += list("[round(y/10)]","[round(y%10)]") - if(y == 1 || y == global.using_map.overmap_size) - numbers += "-" - if(y == 1 || y == global.using_map.overmap_size) - numbers += list("[round(x/10)]","[round(x%10)]") - - for(var/i = 1 to numbers.len) - var/image/I = image('icons/effects/numbers.dmi',numbers[i]) - I.pixel_x = 5*i - 2 - I.pixel_y = world.icon_size/2 - 3 - if(y == 1) - I.pixel_y = 3 - I.pixel_x = 5*i + 4 - if(y == global.using_map.overmap_size) - I.pixel_y = world.icon_size - 9 - I.pixel_x = 5*i + 4 - if(x == 1) - I.pixel_x = 5*i - 2 - if(x == global.using_map.overmap_size) - I.pixel_x = 5*i + 2 - add_overlay(I) - -//list used to track which zlevels are being 'moved' by the proc below -var/list/moving_levels = list() -//Proc to 'move' stars in spess -//yes it looks ugly, but it should only fire when state actually change. -//null direction stops movement -proc/toggle_move_stars(zlevel, direction) - if(!zlevel) - return - - if (moving_levels["[zlevel]"] != direction) - moving_levels["[zlevel]"] = direction - - var/list/spaceturfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) - for(var/turf/space/T in spaceturfs) - T.toggle_transit(direction) - CHECK_TICK -/* -//list used to cache empty zlevels to avoid nedless map bloat -var/list/cached_space = list() - -proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A) - var/obj/effect/map/M = map_sectors["[T.z]"] - if (!M) - return - var/mapx = M.x - var/mapy = M.y - var/nx = 1 - var/ny = 1 - var/nz = M.map_z - - if(T.x <= TRANSITIONEDGE) - nx = world.maxx - TRANSITIONEDGE - 2 - ny = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2) - mapx = max(1, mapx-1) - - else if (A.x >= (world.maxx - TRANSITIONEDGE - 1)) - nx = TRANSITIONEDGE + 2 - ny = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2) - mapx = min(world.maxx, mapx+1) - - else if (T.y <= TRANSITIONEDGE) - ny = world.maxy - TRANSITIONEDGE -2 - nx = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2) - mapy = max(1, mapy-1) - - else if (A.y >= (world.maxy - TRANSITIONEDGE - 1)) - ny = TRANSITIONEDGE + 2 - nx = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2) - mapy = min(world.maxy, mapy+1) - - testing("[A] moving from [M] ([M.x], [M.y]) to ([mapx],[mapy]).") - - var/turf/map = locate(mapx,mapy,OVERMAP_ZLEVEL) - var/obj/effect/map/TM = locate() in map - if(TM) - nz = TM.map_z - testing("Destination: [TM]") - else - if(cached_space.len) - var/obj/effect/map/sector/temporary/cache = cached_space[cached_space.len] - cached_space -= cache - nz = cache.map_z - cache.x = mapx - cache.y = mapy - testing("Destination: *cached* [TM]") - else - world.maxz++ - nz = world.maxz - TM = new /obj/effect/map/sector/temporary(mapx, mapy, nz) - testing("Destination: *new* [TM]") - - var/turf/dest = locate(nx,ny,nz) - if(dest) - A.loc = dest - - if(istype(M, /obj/effect/map/sector/temporary)) - var/obj/effect/map/sector/temporary/source = M - if (source.can_die()) - testing("Catching [M] for future use") - source.loc = null - cached_space += source -*/ \ No newline at end of file diff --git a/code/modules/overmap/helpers.dm b/code/modules/overmap/helpers.dm new file mode 100644 index 0000000000..e07be07ac0 --- /dev/null +++ b/code/modules/overmap/helpers.dm @@ -0,0 +1,5 @@ +/proc/get_overmap_sector(var/z) + if(using_map.use_overmap) + return map_sectors["[z]"] + else + return null diff --git a/code/modules/overmap/overmap_shuttle.dm b/code/modules/overmap/overmap_shuttle.dm index c3195c99de..b614137db4 100644 --- a/code/modules/overmap/overmap_shuttle.dm +++ b/code/modules/overmap/overmap_shuttle.dm @@ -1,4 +1,4 @@ -#define waypoint_sector(waypoint) map_sectors["[waypoint.z]"] +#define waypoint_sector(waypoint) get_overmap_sector(get_z(waypoint)) /datum/shuttle/autodock/overmap warmup_time = 10 diff --git a/code/modules/overmap/ships/computers/ship.dm b/code/modules/overmap/ships/computers/ship.dm index 4ab9d241df..f7441287ac 100644 --- a/code/modules/overmap/ships/computers/ship.dm +++ b/code/modules/overmap/ships/computers/ship.dm @@ -17,7 +17,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov return 1 /obj/machinery/computer/ship/proc/sync_linked() - var/obj/effect/overmap/visitable/ship/sector = map_sectors["[z]"] + var/obj/effect/overmap/visitable/ship/sector = get_overmap_sector(z) if(!sector) return return attempt_hook_up_recursive(sector) diff --git a/code/modules/overmap/ships/landable.dm b/code/modules/overmap/ships/landable.dm index 967fdeb571..0a28eefd8d 100644 --- a/code/modules/overmap/ships/landable.dm +++ b/code/modules/overmap/ships/landable.dm @@ -80,7 +80,7 @@ . = ..() /obj/effect/shuttle_landmark/ship/Destroy() - var/obj/effect/overmap/visitable/ship/landable/ship = map_sectors["[z]"] + var/obj/effect/overmap/visitable/ship/landable/ship = get_overmap_sector(z) if(istype(ship) && ship.landmark == src) ship.landmark = null . = ..() @@ -141,7 +141,7 @@ on_landing(from, into) /obj/effect/overmap/visitable/ship/landable/proc/on_landing(obj/effect/shuttle_landmark/from, obj/effect/shuttle_landmark/into) - var/obj/effect/overmap/visitable/target = map_sectors["[into.z]"] + var/obj/effect/overmap/visitable/target = get_overmap_sector(get_z(into)) var/datum/shuttle/shuttle_datum = SSshuttles.shuttles[shuttle] if(into.landmark_tag == shuttle_datum.motherdock) // If our motherdock is a landable ship, it won't be found properly here so we need to find it manually. for(var/obj/effect/overmap/visitable/ship/landable/landable in SSshuttles.ships) diff --git a/code/modules/overmap/spacetravel.dm b/code/modules/overmap/spacetravel.dm index adb7e80269..aec5c06f75 100644 --- a/code/modules/overmap/spacetravel.dm +++ b/code/modules/overmap/spacetravel.dm @@ -57,7 +57,7 @@ proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A) if (!T || !A) return - var/obj/effect/overmap/visitable/M = map_sectors["[T.z]"] + var/obj/effect/overmap/visitable/M = get_overmap_sector(T.z) if (!M) return diff --git a/code/modules/overmap/turfs.dm b/code/modules/overmap/turfs.dm index 3508203a6e..fc9f0b16eb 100644 --- a/code/modules/overmap/turfs.dm +++ b/code/modules/overmap/turfs.dm @@ -1,7 +1,7 @@ //Dimension of overmap (squares 4 lyfe) var/global/list/map_sectors = list() -/area/overmap/ +/area/overmap name = "System Map" icon_state = "start" requires_power = 0 diff --git a/code/modules/shuttles/landmarks.dm b/code/modules/shuttles/landmarks.dm index 99761dfe25..38f2d41f25 100644 --- a/code/modules/shuttles/landmarks.dm +++ b/code/modules/shuttles/landmarks.dm @@ -55,14 +55,14 @@ if(!istype(docking_controller)) log_error("Could not find docking controller for shuttle waypoint '[name]', docking tag was '[docking_tag]'.") if(using_map.use_overmap) - var/obj/effect/overmap/visitable/location = map_sectors["[z]"] + var/obj/effect/overmap/visitable/location = get_overmap_sector(z) if(location && location.docking_codes) docking_controller.docking_codes = location.docking_codes /obj/effect/shuttle_landmark/forceMove() - var/obj/effect/overmap/visitable/map_origin = map_sectors["[z]"] + var/obj/effect/overmap/visitable/map_origin = get_overmap_sector(z) . = ..() - var/obj/effect/overmap/visitable/map_destination = map_sectors["[z]"] + var/obj/effect/overmap/visitable/map_destination = get_overmap_sector(z) if(map_origin != map_destination) if(map_origin) map_origin.remove_landmark(src, shuttle_restricted) diff --git a/code/modules/shuttles/shuttle_autodock.dm b/code/modules/shuttles/shuttle_autodock.dm index b9b1801205..4181af5b15 100644 --- a/code/modules/shuttles/shuttle_autodock.dm +++ b/code/modules/shuttles/shuttle_autodock.dm @@ -30,7 +30,7 @@ if(active_docking_controller) set_docking_codes(active_docking_controller.docking_codes) else if(global.using_map.use_overmap) - var/obj/effect/overmap/visitable/location = map_sectors["[current_location.z]"] + var/obj/effect/overmap/visitable/location = get_overmap_sector(get_z(current_location)) if(location && location.docking_codes) set_docking_codes(location.docking_codes) dock() diff --git a/code/modules/shuttles/shuttle_console.dm b/code/modules/shuttles/shuttle_console.dm index f8c2a8210d..a3485496d2 100644 --- a/code/modules/shuttles/shuttle_console.dm +++ b/code/modules/shuttles/shuttle_console.dm @@ -159,7 +159,7 @@ GLOBAL_LIST_BOILERPLATE(papers_dockingcode, /obj/item/weapon/paper/dockingcodes) var/dockingcodes = null var/z_to_check = codes_from_z ? codes_from_z : z if(using_map.use_overmap) - var/obj/effect/overmap/visitable/location = map_sectors["[z_to_check]"] + var/obj/effect/overmap/visitable/location = get_overmap_sector(z_to_check) if(location && location.docking_codes) dockingcodes = location.docking_codes diff --git a/vorestation.dme b/vorestation.dme index d14ea1af2a..71ff78008b 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -2883,6 +2883,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\helpers.dm" #include "code\modules\overmap\overmap_object.dm" #include "code\modules\overmap\overmap_shuttle.dm" #include "code\modules\overmap\sectors.dm"