Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuttle datum code cleanup #36651

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions code/datums/climate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ var/list/snowstorm_ambience_volumes = list(30,40,60,80)

/datum/weather/snow/calm/execute()
..()
research_shuttle.lockdown = FALSE //note: blob can't happen on this map
mining_shuttle.lockdown = FALSE
security_shuttle.lockdown = FALSE
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = FALSE //note: blob can't happen on this map

/datum/weather/snow/light
name = "light"
Expand All @@ -213,9 +212,8 @@ var/list/snowstorm_ambience_volumes = list(30,40,60,80)

/datum/weather/snow/light/execute()
..()
research_shuttle.lockdown = FALSE
mining_shuttle.lockdown = FALSE
security_shuttle.lockdown = FALSE
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = FALSE

/datum/weather/snow/heavy
name = "<font color='orange'>heavy</font>"
Expand All @@ -228,9 +226,8 @@ var/list/snowstorm_ambience_volumes = list(30,40,60,80)

/datum/weather/snow/heavy/execute()
..()
research_shuttle.lockdown = FALSE
mining_shuttle.lockdown = FALSE
security_shuttle.lockdown = FALSE
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = FALSE

/datum/weather/snow/blizzard
name = "<font color='red'>blizzard</font>"
Expand All @@ -244,10 +241,9 @@ var/list/snowstorm_ambience_volumes = list(30,40,60,80)

/datum/weather/snow/blizzard/execute()
..()
research_shuttle.lockdown = "Under directive 1-49, surface-to-space light craft have been locked for duration of blizzard. Only escape-class shuttles are rated for stability in blizzards."
mining_shuttle.lockdown = "Under directive 1-49, surface-to-space light craft have been locked for duration of blizzard. Only escape-class shuttles are rated for stability in blizzards."
security_shuttle.lockdown = "Under directive 1-49, surface-to-space light craft have been locked for duration of blizzard. Only escape-class shuttles are rated for stability in blizzards."

for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = "Under directive 1-49, surface-to-space light craft have been locked for duration of blizzard. Only escape-class shuttles are rated for stability in blizzards."

/datum/weather/snow/blizzard/omega
name = "<font color='purple'>dark season</font>"
next_weather = list(/datum/weather/snow/heavy = 100)
Expand Down
8 changes: 4 additions & 4 deletions code/datums/gamemode/factions/blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
var/law = "The station is under quarantine. Do not permit anyone to leave so long as blob overminds are present. Disregard all other laws if necessary to preserve quarantine."
aiPlayer.set_zeroth_law(law)
to_chat(aiPlayer, "Laws Updated: [law]")
research_shuttle.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice." //LOCKDOWN THESE SHUTTLES
mining_shuttle.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice."
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice." //LOCKDOWN THESE SHUTTLES
emergency_shuttle_lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice."
stage = FACTION_ACTIVE

Expand Down Expand Up @@ -201,8 +201,8 @@
command_alert(/datum/command_alert/biohazard_station_unlock)
send_intercept(FACTION_DEFEATED)
emergency_shuttle_lockdown = null
research_shuttle.lockdown = null
mining_shuttle.lockdown = null
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = null
declared = FALSE
world << sound('sound/misc/notice1.ogg')
if(stage >= FACTION_ENDGAME)
Expand Down
4 changes: 4 additions & 0 deletions code/datums/gamemode/factions/vox_shoal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ var/list/potential_bonus_items = list(

var/total_points = 0
var/list/our_bounty_lockers = list()
var/datum/shuttle/vox/vox_shuttle

/datum/faction/vox_shoal/New()
..()
load_dungeon(/datum/map_element/dungeon/vox_shuttle)
vox_shuttle = locate() in shuttles
if(!vox_shuttle)
CRASH("Vox raiders fired with no vox shuttle found! Report this to coders")
vox_shuttle.initialize() //As the area isn't loaded until the above call, its docking ports aren't populated until we call this

/datum/faction/vox_shoal/forgeObjectives()
Expand Down
12 changes: 6 additions & 6 deletions code/datums/gamemode/factions/xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@
var/law = "The station is under quarantine. Do not permit anyone to leave so long the alien threat is present. Disregard all other laws if necessary to preserve quarantine."
aiPlayer.set_zeroth_law(law)
to_chat(aiPlayer, "Laws Updated: [law]")
research_shuttle.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice." //LOCKDOWN THESE SHUTTLES
mining_shuttle.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice."
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = "Under directive 7-10, [station_name()] is quarantined until further notice." //LOCKDOWN THESE SHUTTLES
emergency_shuttle.shutdown = TRUE //Quarantine

/datum/faction/xenomorph/proc/LiftQuarantine()
if(emergency_shuttle.shutdown == FALSE)
return
emergency_shuttle.shutdown = FALSE
research_shuttle.lockdown = null
mining_shuttle.lockdown = null
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = null
world << sound('sound/misc/notice1.ogg')
for(var/mob/living/silicon/ai/aiPlayer in player_list)
aiPlayer.set_zeroth_law("")
Expand All @@ -159,8 +159,8 @@
world << sound('sound/AI/aimalf.ogg')
command_alert(/datum/command_alert/xenomorph_station_deathsquad)
emergency_shuttle.shutdown = FALSE
research_shuttle.lockdown = null
mining_shuttle.lockdown = null
for(var/datum/shuttle/S in outpost_shuttles)
S.lockdown = null
for(var/mob/living/silicon/ai/aiPlayer in player_list)
aiPlayer.set_zeroth_law("")
to_chat(aiPlayer, "$/!@--LAWS UPDATED###%$$")
Expand Down
46 changes: 23 additions & 23 deletions code/datums/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,25 @@

/datum/shuttle/New(var/area/starting_area)
.=..()

if(starting_area)
if(ispath(starting_area))
linked_area = locate(starting_area)
linked_area = locate(starting_area) in areas
else if(isarea(starting_area))
linked_area = starting_area
else
linked_area = starting_area
warning("Unable to find area [starting_area] in world - [src.type] ([src.name]) won't be able to function properly.")
else if(ispath(linked_area))
linked_area = locate(linked_area) in areas
else
warning("Unable to find area [linked_area] in world - [src.type] ([src.name]) won't be able to function properly.")

if(istype(linked_area)) //Only add the shuttle to the list if its area exists and it has something in it
shuttles |= src
if(password)
password = rand(10000,99999)
if (ticker && ticker.current_state == GAME_STATE_PLAYING)
initialize()

//initialize() proc - called automatically in proc/setup_shuttles() below.
//Returns INIT_SUCCESS, INIT_NO_AREA, INIT_NO_START or INIT_NO_PORT, depending on whether there were any errors
Expand Down Expand Up @@ -825,34 +830,29 @@
AM.map_element_rotate(rotate)

/proc/setup_shuttles()

var/watch = start_watch()
var/msg
for(var/datum/shuttle/S in shuttles)
msg = null
switch(S.initialize())
if(INIT_NO_AREA)
if(S.is_special())
var/msg = S.linked_area ? "- \"[S.linked_area]\" was given as a starting area." : ""
warning("Invalid or missing starting area for [S.name] ([S.type]) [msg]")
else
var/msg = S.linked_area ? "- \"[S.linked_area]\" was given as a starting area." : ""
world.log << "Invalid or missing starting area for [S.name] ([S.type]) [msg]"
msg = "Invalid or missing starting area for [S.name] ([S.type]) [S.linked_area ? "- \"[S.linked_area]\" was given as a starting area." : ""]"
if(INIT_NO_PORT)
if(S.is_special())
warning("Couldn't find a shuttle docking port for [S.name] ([S.type]).")
else
world.log << "Couldn't find a shuttle docking port for [S.name] ([S.type])."
msg = "Couldn't find a shuttle docking port for [S.name] ([S.type])."
if(INIT_NO_START)
if(S.is_special())
warning("[S.name] ([S.type]) couldn't connect to a destination port on init - unless this is intended, there might be problems.")
else
world.log << "[S.name] ([S.type]) couldn't connect to a destination port on init - unless this is intended, there might be problems."

msg = "[S.name] ([S.type]) couldn't connect to a destination port on init - unless this is intended, there might be problems."
if(msg)
if(S.is_special())
warning(msg)
else
world.log << msg

//THE MOST IMPORTANT PIECE OF CODE HERE
emergency_shuttle.shuttle = escape_shuttle

if(!emergency_shuttle || !emergency_shuttle.shuttle)
warning("Emergency shuttle is broken.")

if(!emergency_shuttle)
warning("Emergency shuttle handler does not exist!")
else if(!emergency_shuttle.shuttle)
warning("Emergency shuttle datum does not exist!")
log_debug("Initialized shuttles in [stop_watch(watch)]s.", FALSE)
//Custom shuttles
/datum/shuttle/custom
name = "custom shuttle"
Expand Down
21 changes: 15 additions & 6 deletions code/game/machinery/computer/shuttle_computers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
//used for admin-only shuttles so that borgs cant hijack 'em

var/obj/item/weapon/disk/shuttle_coords/disk
var/emag_disables_access = TRUE //If emags do anything to it

//Variables used for custom destinations
var/custom_x = 0
Expand All @@ -159,8 +160,9 @@

/obj/machinery/computer/shuttle_control/New()
if(shuttle)
if(ispath(shuttle))
link_to()
name = "[shuttle.name] console"

.=..()

/obj/machinery/computer/shuttle_control/Destroy()
Expand Down Expand Up @@ -583,16 +585,23 @@
if(src in shuttle.control_consoles)
shuttle.control_consoles -= src

shuttle = S
if(S)
shuttle = S
else if(ispath(shuttle))
var/spath = shuttle
shuttle = locate(shuttle) in shuttles
if(!shuttle)
shuttle = new spath
if(add_to_list)
shuttle.control_consoles |= src
req_access = shuttle.req_access
updateUsrDialog()

/obj/machinery/computer/shuttle_control/emag_act(mob/user as mob)
..()
req_access = list()
if(user)
to_chat(user, "You disable the console's access requirement.")
if(emag_disables_access)
..()
req_access = list()
if(user)
to_chat(user, "You disable the console's access requirement.")

#undef MAX_SHUTTLE_NAME_LEN
1 change: 0 additions & 1 deletion code/game/objects/items/blueprints.dm
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ these cannot rename rooms that are in by default BUT can rename rooms that are c
my_shuttle_home_base.dir = opposite_dirs[DP.dir]

var/datum/shuttle/custom/S = new(starting_area = A)
S.initialize()
S.name = name
S.linked_port.docked_with = my_shuttle_home_base

Expand Down
10 changes: 9 additions & 1 deletion code/game/objects/structures/docking_port.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ var/global/list/all_docking_ports = list()
icon_state = "docking_station"
var/turf/origin_turf = null
var/list/disk_references = list() //List of shuttle destination disks that know about this docking port

var/shuttle_type
var/base_turf_type = /turf/space
var/base_turf_icon = null
var/base_turf_icon_state = null
Expand All @@ -162,6 +162,14 @@ var/global/list/all_docking_ports = list()

/obj/docking_port/destination/New()
.=..()
if(shuttle_type)
var/already_in_shuttles = FALSE
for(var/datum/S in shuttles)
if(S.type == shuttle_type)
already_in_shuttles = TRUE
break
if(!already_in_shuttles)
new shuttle_type

origin_turf = get_turf(src)
//The following few lines exist to make shuttle corners and the syndicate base Less Shit :*
Expand Down
29 changes: 0 additions & 29 deletions code/game/shuttles/bagel.dm

This file was deleted.

14 changes: 5 additions & 9 deletions code/game/shuttles/brokeufo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

stable = 1 //Don't stun everyone and don't throw anything when moving
can_rotate = 0 //Probably just won't work with this shuttle
linked_area = /area/shuttle/brokeufo/start

/datum/shuttle/brokeufo/initialize()
.=..()
Expand All @@ -38,24 +39,19 @@

/obj/machinery/computer/shuttle_control/brokeufo
icon_state = "syndishuttle"

shuttle = /datum/shuttle/brokeufo
light_color = LIGHT_COLOR_RED

/obj/machinery/computer/shuttle_control/brokeufo/New() //Main shuttle_control code is in code/game/machinery/computer/shuttle_computer.dm

var/global/datum/shuttle/brokeufo/brokeufo_shuttle = new(starting_area=/area/shuttle/brokeufo/start)
brokeufo_shuttle.initialize()
link_to(brokeufo_shuttle)

.=..()
var/obj/item/weapon/paper/manual_ufo = new(get_turf(src))

manual_ufo.name = "GDR Scout Passcode"
manual_ufo.info = "Keep this document in a secure location. Your craft's passcode is: \"<b>[brokeufo_shuttle.password]</b>\"."
.=..()
manual_ufo.info = "Keep this document in a secure location. Your craft's passcode is: \"<b>[shuttle.password]</b>\"."

//code/game/objects/structures/docking_port.dm
/obj/docking_port/destination/brokeufo/start
areaname = "deep space"
shuttle_type = /datum/shuttle/brokeufo

/obj/docking_port/destination/brokeufo/lab
areaname = "mothership lab z12"
Expand Down
6 changes: 4 additions & 2 deletions code/game/shuttles/cargo.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var/global/datum/shuttle/supply/cargo_shuttle = new(starting_area = /area/shuttle/supply)
var/global/datum/shuttle/supply/cargo_shuttle

/datum/shuttle/supply
name = "supply shuttle"
Expand All @@ -9,7 +9,7 @@ var/global/datum/shuttle/supply/cargo_shuttle = new(starting_area = /area/shuttl
pre_flight_delay = 0
destroy_everything = 1 //The cargo shuttle should never be cancelled because of something in the way
cooldown = 0

linked_area = /area/shuttle/supply
stable = 1 //Don't stun everyone and don't throw anything when moving

/datum/shuttle/supply/is_special()
Expand All @@ -19,9 +19,11 @@ var/global/datum/shuttle/supply/cargo_shuttle = new(starting_area = /area/shuttl
.=..()
dock_centcom = add_dock(/obj/docking_port/destination/supply/centcom)
dock_station = add_dock(/obj/docking_port/destination/supply/station)
cargo_shuttle = src

/obj/docking_port/destination/supply/centcom
areaname = "centcom loading bay"
shuttle_type = /datum/shuttle/supply

/obj/docking_port/destination/supply/station
areaname = "cargo bay"
Loading
Loading