Skip to content

Commit

Permalink
Ship/Shuttle Terminal Access Checks (#20227)
Browse files Browse the repository at this point in the history
Ship consoles such as targeting and sensors now check for access.

Emagging a ship console disables access checks

Horizon shuttles given access requirements (bridge crew can access any
ship)

Went through most offships and added access requirements, likely missed
some however.

For access requirements, I only added them for helm control, targetting,
and shuttle control consoles

---------

Signed-off-by: Ben <[email protected]>
Co-authored-by: Ben10083 <[email protected]>
Co-authored-by: Fluffy <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent 25569ce commit a13f33a
Show file tree
Hide file tree
Showing 41 changed files with 1,065 additions and 641 deletions.
91 changes: 86 additions & 5 deletions code/modules/overmap/ships/computers/ship.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,70 @@ with an /obj/effect/overmap/visitable/ship present elsewhere on that z level, or
somewhere on that shuttle. Subtypes of these can be then used to perform ship overmap movement functions.
*/
/obj/machinery/computer/ship
var/list/viewers // Weakrefs to mobs in direct-view mode.
var/extra_view = 0 // how much the view is increased by when the mob is in overmap mode.
var/obj/effect/overmap/visitable/ship/connected //The ship we're attached to. This is a typecheck for linked, to ensure we're linked to a ship and not a sector
var/targeting = FALSE //Are we targeting anything right now?
desc_antag = "These consoles, especially the ones that handle piloting and weaponry, may be access-locked.\
You can remove this lock with <b>wirecutters</b>, but it would take awhile! Alternatively, you can also use a cryptographic sequencer (emag) for instant removal."
/// Weakrefs to mobs in direct-view mode.
var/list/viewers
/// How much the view is increased by when the mob is in overmap mode.
var/extra_view = 0
/// The ship we're attached to. This is a typecheck for linked, to ensure we're linked to a ship and not a sector
var/obj/effect/overmap/visitable/ship/connected
/// Are we targeting anything right now?
var/targeting = FALSE
var/linked_type = /obj/effect/overmap/visitable/ship

/// For hotwiring, how many cycles are needed. This decreases by 1 each cycle and triggers at 0
var/hotwire_progress = 8


/obj/machinery/computer/ship/proc/display_reconnect_dialog(var/mob/user, var/flavor)
var/datum/browser/popup = new (user, "[src]", "[src]")
popup.set_content("<center><strong><font color = 'red'>Error</strong></font><br>Unable to connect to [flavor].<br><a href='?src=[REF(src)];sync=1'>Reconnect</a></center>")
popup.open()

/obj/machinery/computer/ship/attackby(obj/item/attacking_item, mob/user)
if(attacking_item.iscoil()) // Repair from hotwire
var/obj/item/stack/cable_coil/C = attacking_item
if(hotwire_progress >= initial(hotwire_progress))
to_chat(usr, SPAN_BOLD("\The [src] does not require repairs."))
else
to_chat(usr, SPAN_BOLD("You attempt to replace some cabling for \the [src]..."))
while(C.can_use(2, user))
if(do_after(user, 15 SECONDS, src, DO_UNIQUE))
if(hotwire_progress < initial(hotwire_progress))
C.use(2)
hotwire_progress++
if(hotwire_progress >= initial(hotwire_progress))
restore_access(user)
return
to_chat(usr, SPAN_BOLD("You replace some broken cabling of \the [src] <b>([(hotwire_progress / initial(hotwire_progress)) * 100]%)</b>."))
playsound(src.loc, 'sound/items/Deconstruct.ogg', 30, TRUE)
return

if(attacking_item.iswirecutter()) // Hotwiring
if(!req_access && !req_one_access && !emagged) // Already hacked/no need to hack
to_chat(user, SPAN_BOLD("[src] is not access-locked."))
return
// Begin hotwire
user.visible_message("<b>[user]</b> opens a panel underneath \the [src] and starts snipping wires...", SPAN_BOLD("You open the maintenance panel and attempt to hotwire \the [src]..."))
while(hotwire_progress > 0)
if(do_after(user, 15 SECONDS, src, DO_UNIQUE))
hotwire_progress--
if(hotwire_progress <= 0)
emag_act(user=user, hotwired=TRUE)
return
to_chat(user, SPAN_BOLD("You snip some cabling from \the [src] <b>([((initial(hotwire_progress)-hotwire_progress) / initial(hotwire_progress)) * 100]%)</b>."))
playsound(src.loc, 'sound/items/Wirecutter.ogg', 30, TRUE)
else
return
return ..()

/obj/machinery/computer/ship/attack_hand(mob/user)
if(use_check_and_message(user))
return

if(!emagged && !allowed(user))
to_chat(user, SPAN_WARNING("Access denied."))
return FALSE
user.set_machine(src)
ui_interact(user)

Expand All @@ -28,6 +77,38 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov
src.add_hiddenprint(user)
ui_interact(user)

/obj/machinery/computer/ship/get_examine_text(mob/user, distance, is_adjacent, infix, suffix)
. = ..()
if(initial(hotwire_progress) != hotwire_progress)
if(hotwire_progress != 0)
. += SPAN_ITALIC("The bottom panel appears open with wires hanging out. It can be repaired with additional cabling. <i>Current progress: [(hotwire_progress / initial(hotwire_progress)) * 100]%</i>")
else
. += SPAN_ITALIC("The bottom panel appears open with wires hanging out. It can be repaired with additional cabling.")

/obj/machinery/computer/ship/emag_act(var/remaining_charges, var/mob/user, var/emag_source, var/hotwired = FALSE)
if(emagged)
to_chat(user, SPAN_WARNING("\The [src] has already been subverted."))
return FALSE
emagged = TRUE
if(hotwired)
user.visible_message(SPAN_WARNING("\The [src] sparks as a panel suddenly opens and burnt cabling spills out!"),SPAN_BOLD("You short out the console's ID checking system. It's now available to everyone!"))
else
user.visible_message(SPAN_WARNING("\The [src] sparks!"),SPAN_BOLD("You short out the console's ID checking system. It's now available to everyone!"))
spark(src, 2, 0)
hotwire_progress = 0
return TRUE

/// Used to restore access removed from emag_act() by setting access from req_access_old and req_one_access_old
/obj/machinery/computer/ship/proc/restore_access(var/mob/user)
if(!emagged)
to_chat(user, SPAN_WARNING("There is no access to restore for \the [src]!"))
return FALSE
emagged = FALSE
to_chat(user, "You repair out the console's ID checking system. It's access restrictions have been restored.")
playsound(loc, 'sound/machines/ping.ogg', 50, FALSE)
hotwire_progress = initial(hotwire_progress)
return TRUE

/obj/machinery/computer/ship/Topic(href, href_list)
if(..())
return TOPIC_HANDLED
Expand Down
90 changes: 80 additions & 10 deletions code/modules/shuttles/shuttle_console.dm
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/obj/machinery/computer/shuttle_control
name = "shuttle control console"
desc_antag = "Consoles like these are typically access-locked.\
You can remove this lock with <b>wirecutters</b>, but it would take awhile! Alternatively, you can also use a cryptographic sequencer (emag) for instant removal."
icon_screen = "shuttle"
icon_keyboard = "cyan_key"
icon_keyboard_emis = "cyan_key_mask"
light_color = LIGHT_COLOR_CYAN

var/shuttle_tag // Used to coordinate data in shuttle controller.
var/hacked = FALSE // Has been emagged, no access restrictions.
/// Used to coordinate data in shuttle controller.
var/shuttle_tag

var/ui_template = "ShuttleControlConsole"
var/list/linked_helmets = list()
var/can_rename_ship = FALSE

/// For hotwiring, how many cycles are needed. This decreases by 1 each cycle and triggers at 0
var/hotwire_progress = 8

/obj/machinery/computer/shuttle_control/Initialize()
. = ..()
if(SSshuttle.shuttles[shuttle_tag])
Expand All @@ -34,16 +39,56 @@
if(istype(attacking_item, /obj/item/clothing/head/helmet/pilot))
var/obj/item/clothing/head/helmet/pilot/PH = attacking_item
if(attacking_item in linked_helmets)
to_chat(user, SPAN_NOTICE("You unlink \the [attacking_item] from \the [src]."))
to_chat(user, SPAN_BOLD("You unlink \the [attacking_item] from \the [src]."))
PH.set_console(null)
else
to_chat(user, SPAN_NOTICE("You link \the [attacking_item] to \the [src]."))
to_chat(user, SPAN_BOLD("You link \the [attacking_item] to \the [src]."))
PH.set_console(src)
PH.set_hud_maptext("Shuttle Status: [get_shuttle_status(SSshuttle.shuttles[shuttle_tag])]")
return
if(attacking_item.iscoil()) // Repair from hotwire
var/obj/item/stack/cable_coil/C = attacking_item
if(hotwire_progress >= initial(hotwire_progress))
to_chat(usr, SPAN_BOLD("\The [src] does not require repairs."))
else
to_chat(usr, SPAN_BOLD("You attempt to replace some cabling for \the [src]..."))
while(C.can_use(2, user))
if(do_after(user, 15 SECONDS, src, DO_UNIQUE))
if(hotwire_progress < initial(hotwire_progress))
C.use(2)
hotwire_progress++
if(hotwire_progress >= initial(hotwire_progress))
restore_access(user)
return
to_chat(usr, SPAN_BOLD("You replace some broken cabling of \the [src] <b>([(hotwire_progress / initial(hotwire_progress)) * 100]%)</b>."))
playsound(src.loc, 'sound/items/Deconstruct.ogg', 30, TRUE)
return

if(attacking_item.iswirecutter()) // Hotwiring
if(!req_access && !req_one_access && !emagged) // Already hacked/no need to hack
to_chat(user, SPAN_BOLD("[src] is not access-locked."))
return
// Begin hotwire
user.visible_message("<b>[user]</b> opens a panel underneath \the [src] and starts snipping wires...", SPAN_BOLD("You open the maintenance panel and attempt to hotwire \the [src]..."))
while(hotwire_progress > 0)
if(do_after(user, 15 SECONDS, src, DO_UNIQUE))
hotwire_progress--
if(hotwire_progress <= 0)
emag_act(user=user, hotwired=TRUE)
return
to_chat(user, SPAN_BOLD("You snip some cabling from \the [src] <b>([((initial(hotwire_progress)-hotwire_progress) / initial(hotwire_progress)) * 100]%)</b>."))
playsound(src.loc, 'sound/items/Wirecutter.ogg', 30, TRUE)
else
return
return ..()

/obj/machinery/computer/shuttle_control/attack_hand(mob/user)
if(use_check_and_message(user))
return
if(!emagged && !allowed(user))
to_chat(user, SPAN_WARNING("Access denied."))
return FALSE
user.set_machine(src)
ui_interact(user)

/obj/machinery/computer/shuttle_control/attack_ai(mob/user)
Expand Down Expand Up @@ -159,12 +204,37 @@
for(var/obj/item/clothing/head/helmet/pilot/PH as anything in linked_helmets)
PH.set_hud_maptext("Shuttle Status: [shuttle_status]")

/obj/machinery/computer/shuttle_control/emag_act(var/remaining_charges, var/mob/user)
if(!hacked)
req_access = list()
hacked = TRUE
to_chat(user, "You short out the console's ID checking system. It's now available to everyone!")
return TRUE
/obj/machinery/computer/shuttle_control/get_examine_text(mob/user, distance, is_adjacent, infix, suffix)
. = ..()
if(initial(hotwire_progress) != hotwire_progress)
if(hotwire_progress != 0)
. += SPAN_ITALIC("The bottom panel appears open with wires hanging out. It can be repaired with additional cabling. <i>Current progress: [(hotwire_progress / initial(hotwire_progress)) * 100]%</i>")
else
. += SPAN_ITALIC("The bottom panel appears open with wires hanging out. It can be repaired with additional cabling.")

/obj/machinery/computer/shuttle_control/emag_act(var/remaining_charges, var/mob/user, var/emag_source, var/hotwired = FALSE)
if(emagged)
to_chat(user, SPAN_WARNING("\The [src] has already been subverted."))
return FALSE
emagged = TRUE
if(hotwired)
user.visible_message(SPAN_WARNING("\The [src] sparks as a panel suddenly opens and burnt cabling spills out!"),SPAN_BOLD("You short out the console's ID checking system. It's now available to everyone!"))
else
user.visible_message(SPAN_WARNING("\The [src] sparks!"),SPAN_BOLD("You short out the console's ID checking system. It's now available to everyone!"))
spark(src, 2, 0)
hotwire_progress = 0
return TRUE

/// Used to restore access removed from emag_act() by setting access from req_access_old and req_one_access_old
/obj/machinery/computer/shuttle_control/proc/restore_access(var/mob/user)
if(!emagged)
to_chat(user, SPAN_WARNING("There is no access to restore for \the [src]!"))
return FALSE
emagged = FALSE
to_chat(user, "You repair out the console's ID checking system. It's access restrictions have been restored.")
playsound(loc, 'sound/machines/ping.ogg', 50, FALSE)
hotwire_progress = initial(hotwire_progress)
return TRUE

/obj/machinery/computer/shuttle_control/ex_act()
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/shuttles/shuttle_emergency.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@

return 1

/obj/machinery/computer/shuttle_control/emergency/emag_act(var/remaining_charges, var/mob/user)
/obj/machinery/computer/shuttle_control/emergency/emag_act(var/remaining_charges, var/mob/user, var/hotwired = FALSE)
if (!emagged)
to_chat(user, SPAN_NOTICE("You short out \the [src]'s authorization protocols."))
emagged = 1
Expand Down
61 changes: 61 additions & 0 deletions html/changelogs/Ben10083 - Ship Access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################

# Your name.
author: Ben10083

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- code_imp: "Adds ID check functionality to ship/shuttle consoles."
- rscadd: "ID Checks added to SCCV Horizon ship/shuttle consoles. Bridge Crew given access to all shuttles."
- balance: "Emagging or using wirecutters on a ship console will allow it to be usable by anyone."
- rscadd: "Many offships and their shuttles given access checks."
15 changes: 10 additions & 5 deletions maps/away/away_site/tajara/peoples_station/peoples_station.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@
/area/peoples_station/hangar)
"dG" = (
/obj/machinery/computer/ship/helm/terminal{
dir = 1
dir = 1;
req_access = list(209)
},
/turf/simulated/floor/plating{
temperature = 278.15
Expand Down Expand Up @@ -4375,7 +4376,8 @@
dir = 10
},
/obj/machinery/computer/ship/targeting/terminal{
dir = 1
dir = 1;
req_access = list(209)
},
/turf/simulated/floor/tiled/dark{
temperature = 278.15
Expand Down Expand Up @@ -7428,7 +7430,8 @@
/area/peoples_station)
"BN" = (
/obj/machinery/computer/shuttle_control/explore/terminal/peoples_station_fang{
dir = 8
dir = 8;
req_access = list(209)
},
/obj/machinery/light/small{
dir = 4
Expand Down Expand Up @@ -8665,7 +8668,8 @@
/area/peoples_station/hangar)
"Go" = (
/obj/machinery/computer/ship/helm/terminal{
dir = 1
dir = 1;
req_access = list(209)
},
/turf/simulated/floor/carpet/rubber,
/area/shuttle/peoples_station_transport)
Expand Down Expand Up @@ -12915,7 +12919,8 @@
/area/peoples_station/fang)
"Xy" = (
/obj/machinery/computer/ship/targeting/terminal{
dir = 4
dir = 4;
req_access = list(209)
},
/obj/machinery/light/small{
dir = 8
Expand Down
11 changes: 8 additions & 3 deletions maps/away/away_site/uueoaesa/reclamation/ihss_reclamation.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,9 @@
dir = 4;
color = "#941307"
},
/obj/machinery/computer/shuttle_control/explore/ihss_reclamation,
/obj/machinery/computer/shuttle_control/explore/ihss_reclamation{
req_one_access = list(113)
},
/turf/simulated/floor/tiled/dark,
/area/shuttle/ihss_reclamation)
"iW" = (
Expand Down Expand Up @@ -4632,7 +4634,9 @@
/turf/simulated/floor/plating,
/area/ihss_reclamation/dock)
"wx" = (
/obj/machinery/computer/ship/helm,
/obj/machinery/computer/ship/helm{
req_one_access = list(113)
},
/obj/effect/floor_decal/corner/red/diagonal{
dir = 4;
color = "#941307"
Expand Down Expand Up @@ -8750,7 +8754,8 @@
color = "#941307"
},
/obj/machinery/computer/ship/targeting{
dir = 4
dir = 4;
req_one_access = list(113)
},
/turf/simulated/floor/tiled/dark,
/area/shuttle/ihss_reclamation)
Expand Down
Loading

0 comments on commit a13f33a

Please sign in to comment.