Skip to content

Commit

Permalink
resolved null shuttle start issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mullenpaul committed Mar 27, 2024
1 parent c35575b commit 956495d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
52 changes: 30 additions & 22 deletions code/modules/shuttle/computers/dropship_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
var/obj/docking_port/mobile/shuttle = SSshuttle.getShuttle(shuttleId)
ui = new(user, src, "DropshipFlightControl", "[shuttle.name] Flight Computer")
var/name = shuttle?.name
if(can_change_shuttle)
name = "Remote"
ui = new(user, src, "DropshipFlightControl", "[name] Flight Computer")
ui.open()

/obj/structure/machinery/computer/shuttle/dropship/flight/ui_status(mob/user, datum/ui_state/state)
Expand All @@ -116,7 +119,7 @@

/obj/structure/machinery/computer/shuttle/dropship/flight/ui_state(mob/user)
var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId)
if(shuttle.is_hijacked)
if(shuttle?.is_hijacked)
return GLOB.never_state
return GLOB.not_incapacitated_and_adjacent_strict_state

Expand All @@ -125,14 +128,13 @@
compatible_landing_zones = get_landing_zones()
var/obj/docking_port/mobile/shuttle = SSshuttle.getShuttle(shuttleId)
// we convert the time to seconds for rendering to ui
.["max_flight_duration"] = shuttle.callTime / 10
.["max_pre_arrival_duration"] = shuttle.prearrivalTime / 10
.["max_refuel_duration"] = shuttle.rechargeTime / 10
.["max_engine_start_duration"] = shuttle.ignitionTime / 10
.["door_data"] = list("port", "starboard", "aft")
.["can_change_shuttle"] = can_change_shuttle
if(can_change_shuttle)
.["alternative_shuttles"] = alternative_shuttles()
if(shuttle)
.["max_flight_duration"] = shuttle.callTime / 10
.["max_pre_arrival_duration"] = shuttle.prearrivalTime / 10
.["max_refuel_duration"] = shuttle.rechargeTime / 10
.["max_engine_start_duration"] = shuttle.ignitionTime / 10
.["door_data"] = list("port", "starboard", "aft")
.["alternative_shuttles"] = alternative_shuttles()

/obj/structure/machinery/computer/shuttle/dropship/flight/proc/alternative_shuttles()
. = list()
Expand All @@ -154,6 +156,10 @@

// if the dropship has crashed don't allow more interactions
var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId)
if(!shuttle)
tgui_interact(user)
return

if(shuttle.mode == SHUTTLE_CRASHED)
to_chat(user, SPAN_NOTICE("\The [src] is not responsive"))
return
Expand Down Expand Up @@ -355,27 +361,29 @@
/obj/structure/machinery/computer/shuttle/dropship/flight/ui_data(mob/user)
var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId)
. = list()
.["shuttle_id"] = shuttle.id
.["shuttle_mode"] = shuttle.mode
.["flight_time"] = shuttle.timeLeft(0)
.["is_disabled"] = disabled || shuttle.is_hijacked
.["shuttle_id"] = shuttle?.id
.["shuttle_mode"] = shuttle?.mode
.["flight_time"] = shuttle?.timeLeft(0)
.["is_disabled"] = disabled
if(shuttle?.is_hijacked)
.["is_disabled"] = TRUE
.["locked_down"] = FALSE
.["can_fly_by"] = !is_remote
.["can_set_automated"] = is_remote
.["automated_control"] = list(
"is_automated" = shuttle.automated_hangar_id != null || shuttle.automated_lz_id != null,
"hangar_lz" = shuttle.automated_hangar_id,
"ground_lz" = shuttle.automated_lz_id
"is_automated" = shuttle?.automated_hangar_id != null || shuttle?.automated_lz_id != null,
"hangar_lz" = shuttle?.automated_hangar_id,
"ground_lz" = shuttle?.automated_lz_id
)
.["primary_lz"] = SSticker.mode.active_lz?.linked_lz
if(shuttle.destination)
.["target_destination"] = shuttle.in_flyby? "Flyby" : shuttle.destination.name
if(shuttle?.destination)
.["target_destination"] = shuttle?.in_flyby? "Flyby" : shuttle?.destination.name

.["door_status"] = is_remote ? list() : shuttle.get_door_data()
.["door_status"] = is_remote ? list() : shuttle?.get_door_data()
.["has_flyby_skill"] = skillcheck(user, SKILL_PILOT, SKILL_PILOT_EXPERT)

// Launch Alarm Variables
.["playing_launch_announcement_alarm"] = shuttle.playing_launch_announcement_alarm
.["playing_launch_announcement_alarm"] = shuttle?.playing_launch_announcement_alarm

.["destinations"] = list()
// add flight
Expand All @@ -394,7 +402,7 @@
if(dock == other_shuttle.destination)
dock_reserved = TRUE
break
var/can_dock = shuttle.canDock(dock)
var/can_dock = shuttle?.canDock(dock)
var/list/dockinfo = list(
"id" = dock.id,
"name" = dock.name,
Expand Down
11 changes: 4 additions & 7 deletions tgui/packages/tgui/interfaces/DropshipFlightControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ const RenderScreen = () => {
const { data } = useBackend<DropshipNavigationProps>();
return (
<>
{data.shuttle_mode === 'idle' && data.can_change_shuttle === 1 && (
<DropshipSelector />
)}
{data.alternative_shuttles.length > 0 && <DropshipSelector />}
{data.shuttle_mode === 'idle' && <DropshipDestinationSelection />}
{data.shuttle_mode === 'idle' && data.can_set_automated === 1 && (
<AutopilotConfig />
Expand All @@ -383,7 +381,7 @@ const RenderScreen = () => {
<DropshipDestinationSelection />
)}
{data.door_status.length > 0 && <DropshipDoorControl />}
{<LaunchAnnouncementAlarm />}
{data.alternative_shuttles.length === 0 && <LaunchAnnouncementAlarm />}
</>
);
};
Expand All @@ -392,9 +390,8 @@ export const DropshipFlightControl = () => {
const { data } = useBackend<DropshipNavigationProps>();
return (
<Window theme="crtgreen" height={500} width={700}>
<Window.Content className="NavigationMenu">
{data.is_disabled === 1 && <DisabledScreen />}
{data.is_disabled === 0 && <RenderScreen />}
<Window.Content className="NavigationMenu" scrollable>
{data.is_disabled === 0 ? <RenderScreen /> : <DisabledScreen />}
</Window.Content>
</Window>
);
Expand Down

0 comments on commit 956495d

Please sign in to comment.