mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 13:38:41 +01:00
[MIRROR] Refactors calculating shuttle bounds into a dedicated proc [MDB IGNORE] (#18011)
* Refactors calculating shuttle bounds into a dedicated proc * merge * oop Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> Co-authored-by: Tastyfish <crazychris32@gmail.com>
This commit is contained in:
co-authored by
Zephyr
Tastyfish
parent
61cbc55ada
commit
4fcc08fee6
+1
-22
@@ -67,28 +67,7 @@
|
||||
place.baseturfs = baseturfs_string_list(sanity, place)
|
||||
|
||||
for(var/obj/docking_port/mobile/port in place)
|
||||
if(!isnull(port_x_offset))
|
||||
switch(port.dir) // Yeah this looks a little ugly but mappers had to do this in their head before
|
||||
if(NORTH)
|
||||
port.width = width
|
||||
port.height = height
|
||||
port.dwidth = port_x_offset - 1
|
||||
port.dheight = port_y_offset - 1
|
||||
if(EAST)
|
||||
port.width = height
|
||||
port.height = width
|
||||
port.dwidth = height - port_y_offset
|
||||
port.dheight = port_x_offset - 1
|
||||
if(SOUTH)
|
||||
port.width = width
|
||||
port.height = height
|
||||
port.dwidth = width - port_x_offset
|
||||
port.dheight = height - port_y_offset
|
||||
if(WEST)
|
||||
port.width = height
|
||||
port.height = width
|
||||
port.dwidth = port_y_offset - 1
|
||||
port.dheight = width - port_x_offset
|
||||
port.calculate_docking_port_information(src)
|
||||
// initTemplateBounds explicitly ignores the shuttle's docking port, to ensure that it calculates the bounds of the shuttle correctly
|
||||
// so we need to manually initialize it here
|
||||
SSatoms.InitializeAtoms(list(port))
|
||||
|
||||
@@ -436,6 +436,69 @@
|
||||
|
||||
var/admin_forced = FALSE //SKYRAT EDIT ADDITION
|
||||
|
||||
#define WORLDMAXX_CUTOFF (world.maxx + 1)
|
||||
#define WORLDMAXY_CUTOFF (world.maxx + 1)
|
||||
/**
|
||||
* Calculated and populates the information used for docking and some internal vars.
|
||||
* This can also be used to calculate from shuttle_areas so that you can expand/shrink shuttles!
|
||||
*
|
||||
* Arguments:
|
||||
* * loading_from - The template that the shuttle was loaded from, if not given we iterate shuttle_areas to calculate information instead
|
||||
*/
|
||||
/obj/docking_port/mobile/proc/calculate_docking_port_information(datum/map_template/shuttle/loading_from)
|
||||
var/port_x_offset = loading_from?.port_x_offset
|
||||
var/port_y_offset = loading_from?.port_y_offset
|
||||
var/width = loading_from?.width
|
||||
var/height = loading_from?.height
|
||||
if(!loading_from)
|
||||
if(!length(shuttle_areas))
|
||||
CRASH("Attempted to calculate a docking port's information without a template before it was assigned any areas!")
|
||||
// no template given, use shuttle_areas to calculate width and height
|
||||
var/min_x = -1
|
||||
var/min_y = -1
|
||||
var/max_x = WORLDMAXX_CUTOFF
|
||||
var/max_y = WORLDMAXY_CUTOFF
|
||||
for(var/area/area as anything in shuttle_areas)
|
||||
for(var/turf/turf in area)
|
||||
min_x = max(turf.x, min_x)
|
||||
max_x = min(turf.x, max_x)
|
||||
min_y = max(turf.y, min_y)
|
||||
max_y = min(turf.y, max_y)
|
||||
CHECK_TICK
|
||||
|
||||
if(min_x == -1 || max_x == WORLDMAXX_CUTOFF)
|
||||
CRASH("Failed to locate shuttle boundaries when iterating through shuttle areas, somehow.")
|
||||
if(min_y == -1 || max_y == WORLDMAXY_CUTOFF)
|
||||
CRASH("Failed to locate shuttle boundaries when iterating through shuttle areas, somehow.")
|
||||
|
||||
width = (max_x - min_x) + 1
|
||||
height = (max_y - min_y) + 1
|
||||
port_x_offset = min_x - x
|
||||
port_y_offset = min_y - y
|
||||
|
||||
if(dir in list(EAST, WEST))
|
||||
src.width = height
|
||||
src.height = width
|
||||
else
|
||||
src.width = width
|
||||
src.height = height
|
||||
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
dwidth = port_x_offset - 1
|
||||
dheight = port_y_offset - 1
|
||||
if(EAST)
|
||||
dwidth = height - port_y_offset
|
||||
dheight = port_x_offset - 1
|
||||
if(SOUTH)
|
||||
dwidth = width - port_x_offset
|
||||
dheight = height - port_y_offset
|
||||
if(WEST)
|
||||
dwidth = port_y_offset - 1
|
||||
dheight = width - port_x_offset
|
||||
#undef WORLDMAXX_CUTOFF
|
||||
#undef WORLDMAXY_CUTOFF
|
||||
|
||||
/**
|
||||
* Actions to be taken after shuttle is loaded but before it has been moved out of transit z-level to its final location
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user