Skip to content

Commit

Permalink
Reorganizes and splits shuttle code (tgstation#88228)
Browse files Browse the repository at this point in the history
## About The Pull Request

refer to title

No code changes were made here, i just copypasted code around
The only real difference is that I removed a pretty useless define that
depended on TESTING because it got in my way of splitting emergency.dm

tbh i didnt want a 50k line refactor pr that nobody is going to review
so im getting it out of the way in a separate PR

## Why It's Good For The Game

Shuttle code is literally all over the place please help me oh gosh

## Changelog

Nothing player facing or developer facing (at least I really hope so)
  • Loading branch information
distributivgesetz authored Dec 6, 2024
1 parent 09e3207 commit 558e652
Show file tree
Hide file tree
Showing 32 changed files with 1,944 additions and 1,944 deletions.
10 changes: 10 additions & 0 deletions code/__DEFINES/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#define ENGINE_COEFF_MIN 0.5
#define ENGINE_COEFF_MAX 2
#define ENGINE_DEFAULT_MAXSPEED_ENGINES 5
#define ENGINE_START_TIME 100

// Alert level related
#define ALERT_COEFF_AUTOEVAC_NORMAL 2.5
Expand Down Expand Up @@ -120,3 +121,12 @@
#define SHUTTLE_EVENT_MISS_SHUTTLE 1 << 0
///spawned stuff should hit the shuttle
#define SHUTTLE_EVENT_HIT_SHUTTLE 1 << 1

// Hijack stages

#define HIJACK_NOT_BEGUN 0
#define HIJACK_STAGE_1 1
#define HIJACK_STAGE_2 2
#define HIJACK_STAGE_3 3
#define HIJACK_STAGE_4 4
#define HIJACK_COMPLETED 5
52 changes: 52 additions & 0 deletions code/__HELPERS/shuttle.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/// Helper proc that tests to ensure all whiteship templates can spawn at their docking port, and logs their sizes
/// This should be a unit test, but too much of our other code breaks during shuttle movement, so not yet, not yet.
/proc/test_whiteship_sizes()
var/obj/docking_port/stationary/port_type = /obj/docking_port/stationary/picked/whiteship
var/datum/turf_reservation/docking_yard = SSmapping.request_turf_block_reservation(
initial(port_type.width),
initial(port_type.height),
1,
)
var/turf/bottom_left = docking_yard.bottom_left_turfs[1]
var/turf/spawnpoint = locate(
bottom_left.x + initial(port_type.dwidth),
bottom_left.y + initial(port_type.dheight),
bottom_left.z,
)

var/obj/docking_port/stationary/picked/whiteship/port = new(spawnpoint)
var/list/ids = port.shuttlekeys
var/height = 0
var/width = 0
var/dheight = 0
var/dwidth = 0
var/delta_height = 0
var/delta_width = 0
for(var/id in ids)
var/datum/map_template/shuttle/our_template = SSmapping.shuttle_templates[id]
// We do a standard load here so any errors will properly runtimes
var/obj/docking_port/mobile/ship = SSshuttle.action_load(our_template, port)
if(ship)
ship.jumpToNullSpace()
ship = null
// Yes this is very hacky, but we need to both allow loading a template that's too big to be an error state
// And actually get the sizing information from every shuttle
SSshuttle.load_template(our_template)
var/obj/docking_port/mobile/theoretical_ship = SSshuttle.preview_shuttle
if(theoretical_ship)
height = max(theoretical_ship.height, height)
width = max(theoretical_ship.width, width)
dheight = max(theoretical_ship.dheight, dheight)
dwidth = max(theoretical_ship.dwidth, dwidth)
delta_height = max(theoretical_ship.height - theoretical_ship.dheight, delta_height)
delta_width = max(theoretical_ship.width - theoretical_ship.dwidth, delta_width)
theoretical_ship.jumpToNullSpace()
qdel(port, TRUE)
log_world("Whiteship sizing information. Use this to set the docking port, and the map size\n\
Max Height: [height] \n\
Max Width: [width] \n\
Max DHeight: [dheight] \n\
Max DWidth: [dwidth] \n\
The following are the safest bet for map sizing. Anything smaller then this could in the worst case not fit in the docking port\n\
Max Combined Width: [height + dheight] \n\
Max Combinded Height [width + dwidth]")
Loading

0 comments on commit 558e652

Please sign in to comment.