Skip to content

Commit

Permalink
more robust fix for flyby timer issue (#4653)
Browse files Browse the repository at this point in the history
# About the pull request

Fixes issues reported in
#4648 partially duplicates
#4649

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game

In addition to changes from #4649 refactor of code as class variable not
required
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
code: resolves flyby issues by refactoring update_equipment logic
refactor: removes unwanted code
/:cl:
  • Loading branch information
mullenpaul authored Oct 17, 2023
1 parent 9d67f6d commit 41e73a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 62 deletions.
28 changes: 7 additions & 21 deletions code/modules/shuttle/computers/dropship_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
exproof = TRUE
needs_power = FALSE

// True if we are doing a flyby
var/is_set_flyby = FALSE

// Admin disabled
var/disabled = FALSE

Expand Down Expand Up @@ -54,15 +51,15 @@
/obj/structure/machinery/computer/shuttle/dropship/flight/enable()
disabled = FALSE

/obj/structure/machinery/computer/shuttle/dropship/flight/proc/update_equipment(optimised=FALSE)
/obj/structure/machinery/computer/shuttle/dropship/flight/proc/update_equipment(optimised=FALSE, is_flyby=FALSE)
var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttleId)
if(!dropship)
return

// initial flight time
var/flight_duration = is_set_flyby ? DROPSHIP_TRANSIT_DURATION : DROPSHIP_TRANSIT_DURATION * GLOB.ship_alt
var/flight_duration = is_flyby ? DROPSHIP_TRANSIT_DURATION : DROPSHIP_TRANSIT_DURATION * GLOB.ship_alt
if(optimised)
if(is_set_flyby)
if(is_flyby)
flight_duration = DROPSHIP_TRANSIT_DURATION * 1.5
else
flight_duration = DROPSHIP_TRANSIT_DURATION * SHUTTLE_OPTIMIZE_FACTOR_TRAVEL
Expand All @@ -76,7 +73,7 @@
for(var/obj/structure/dropship_equipment/equipment as anything in dropship.equipments)
// fuel enhancer
if(istype(equipment, /obj/structure/dropship_equipment/fuel/fuel_enhancer))
if(is_set_flyby)
if(is_flyby)
flight_duration = flight_duration / SHUTTLE_FUEL_ENHANCE_FACTOR_TRAVEL
else
flight_duration = flight_duration * SHUTTLE_FUEL_ENHANCE_FACTOR_TRAVEL
Expand Down Expand Up @@ -320,7 +317,6 @@
.["target_destination"] = shuttle.in_flyby? "Flyby" : shuttle.destination.name

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

.["destinations"] = list()
Expand Down Expand Up @@ -372,12 +368,13 @@
// automatically apply optimisation if user is a pilot
if(skillcheck(user, SKILL_PILOT, SKILL_PILOT_EXPERT))
is_optimised = TRUE
update_equipment(is_optimised)

var/dock_id = params["target"]
if(dock_id == DROPSHIP_FLYBY_ID)
if(!skillcheck(user, SKILL_PILOT, SKILL_PILOT_EXPERT))
to_chat(user, SPAN_WARNING("You don't have the skill to perform a flyby."))
return FALSE
update_equipment(is_optimised, TRUE)
to_chat(user, SPAN_NOTICE("You begin the launch sequence for a flyby."))
log_ares_flight(user.name, "Launched Dropship [shuttle.name] on a flyby.")
var/log = "[key_name(user)] launched the dropship [src.shuttleId] on flyby."
Expand All @@ -386,6 +383,7 @@
shuttle.send_for_flyby()
return TRUE

update_equipment(is_optimised, FALSE)
var/list/local_data = ui_data(user)
var/found = FALSE
playsound(loc, get_sfx("terminal_button"), KEYBOARD_SOUND_VOLUME, 1)
Expand Down Expand Up @@ -426,18 +424,6 @@
else
playsound(loc, 'sound/machines/terminal_error.ogg', KEYBOARD_SOUND_VOLUME, 1)
to_chat(user, SPAN_WARNING("Door controls have been overridden. Please call technical support."))
if("set-ferry")
is_set_flyby = FALSE
log_ares_flight(user.name, "Set Dropship [shuttle.name] to transport runs.")
var/log = "[key_name(user)] set the dropship [src.shuttleId] into transport"
msg_admin_niche(log)
log_interact(user, msg = "[log]")
if("set-flyby")
is_set_flyby = TRUE
log_ares_flight(user.name, "Set Dropship [shuttle.name] to flyby runs.")
var/log = "[key_name(user)] set the dropship [src.shuttleId] into flyby."
msg_admin_niche(log)
log_interact(user, msg = "[log]")
if("set-automate")
var/almayer_lz = params["hangar_id"]
var/ground_lz = params["ground_id"]
Expand Down
38 changes: 1 addition & 37 deletions tgui/packages/tgui/interfaces/DropshipFlightControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface DropshipNavigationProps extends NavigationProps {
door_status: Array<DoorStatus>;
has_flight_optimisation?: 0 | 1;
is_flight_optimised?: 0 | 1;
flight_configuration: 'flyby' | 'ferry';
can_fly_by?: 0 | 1;
can_set_automated?: 0 | 1;
primary_lz?: string;
Expand Down Expand Up @@ -116,7 +115,7 @@ export const DropshipDestinationSelection = (_, context) => {
);
return (
<Section
title="Ferry Controls"
title="Flight Controls"
buttons={
<>
<CancelLaunchButton />
Expand Down Expand Up @@ -182,41 +181,6 @@ const DestinationSelector = (props: DestinationProps, context) => {
);
};

const FlybyControl = (props, context) => {
const { act, data } = useBackend<DropshipNavigationProps>(context);
return (
<Section
title="Flight Controls"
className="flybyControl"
buttons={
<>
{data.flight_configuration === 'flyby' && (
<Button icon="road" onClick={() => act('set-ferry')}>
Set ferry
</Button>
)}
{data.has_flyby_skill === 1 && data.flight_configuration === 'ferry' && (
<Button icon="jet-fighter" onClick={() => act('set-flyby')}>
Set flyby
</Button>
)}
{data.has_flyby_skill === 1 && data.shuttle_mode === 'called' && (
<Button onClick={() => act('cancel-flyby')}>cancel flyby</Button>
)}
{data.has_flyby_skill === 1 && data.shuttle_mode === 'idle' && (
<Button
icon="rocket"
disabled={data.flight_configuration === 'ferry'}
onClick={() => act('move')}>
Launch
</Button>
)}
</>
}
/>
);
};

export const TouchdownCooldown = (_, context) => {
const { data } = useBackend<NavigationProps>(context);
return (
Expand Down
17 changes: 13 additions & 4 deletions tgui/packages/tgui/interfaces/NavigationShuttle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const CancelLaunchButton = (_, context) => {

export const LaunchButton = (_, context) => {
const { act } = useBackend<NavigationProps>(context);
const [siteselection] = useSharedState<string | undefined>(
const [siteselection, setSiteSelection] = useSharedState<string | undefined>(
context,
'target_site',
undefined
Expand All @@ -50,7 +50,10 @@ export const LaunchButton = (_, context) => {
<Button
icon="rocket"
disabled={siteselection === undefined}
onClick={() => act('move', { target: siteselection })}>
onClick={() => {
act('move', { target: siteselection });
setSiteSelection(undefined);
}}>
Launch
</Button>
);
Expand Down Expand Up @@ -156,9 +159,15 @@ export const LaunchCountdown = (_, context) => {
};

export const InFlightCountdown = (_, context) => {
const { data } = useBackend<NavigationProps>(context);
const { data, act } = useBackend<NavigationProps>(context);
return (
<Section title={`In flight: ${data.target_destination}`}>
<Section
title={`In flight: ${data.target_destination}`}
buttons={
data.target_destination === 'Flyby' && (
<Button onClick={() => act('cancel-flyby')}>Cancel</Button>
)
}>
<div className="InFlightCountdown">
<Stack vertical>
<Stack.Item>
Expand Down

0 comments on commit 41e73a5

Please sign in to comment.