Skip to content

Commit

Permalink
FINALLY makes prefixes immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Nov 29, 2024
1 parent b1564b9 commit ec85630
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
7 changes: 2 additions & 5 deletions code/controllers/subsystem/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,6 @@ SUBSYSTEM_DEF(shuttle)
for(var/obj/docking_port/mobile/M as anything in mobile)
var/list/L = list()

if(M.current_ship)
L["type"] = "[M.current_ship.source_template ? (M.current_ship.source_template.short_name ? M.current_ship.source_template.short_name : M.current_ship.source_template.name) : "Custom"]"
else
L["type"] = "???"

L["name"] = M.name
L["id"] = REF(M)
L["timer"] = M.timer
Expand All @@ -415,11 +410,13 @@ SUBSYSTEM_DEF(shuttle)
L["mode"] = capitalize(M.mode)

if(M.current_ship)
L["type"] = M.current_ship.source_template.short_name
if(M.current_ship.docked_to)
L["position"] = "Docked at [M.current_ship.docked_to.name] ([M.current_ship.docked_to.x], [M.current_ship.docked_to.y])"
else
L["position"] = "Flying At ([M.current_ship.x], [M.current_ship.y])"
else
L["type"] = "???"
L["position"] = "???"

data["shuttles"] += list(L)
Expand Down
13 changes: 9 additions & 4 deletions code/modules/overmap/helm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
return

.["calibrating"] = calibrating
.["canRename"] = COOLDOWN_FINISHED(current_ship, rename_cooldown)
.["otherInfo"] = list()
var/list/objects = current_ship.get_nearby_overmap_objects()
var/dequeue_pointer = 0
Expand Down Expand Up @@ -243,8 +244,9 @@
.["isViewer"] = viewer || (!allow_ai_control && issilicon(user))
.["mapRef"] = current_ship.token.map_name
.["shipInfo"] = list(
name = current_ship.name,
class = current_ship.source_template?.name,
name = current_ship.real_name,
prefixed = current_ship.name,
class = current_ship.source_template.name,
mass = current_ship.shuttle_port.turf_count,
sensor_range = 4
)
Expand All @@ -269,13 +271,16 @@
if(!new_name)
return
new_name = trim(new_name)
if (!length(new_name) || new_name == current_ship.name)
if (!length(new_name) || new_name == current_ship.real_name)
return
if(!reject_bad_text(new_name, MAX_CHARTER_LEN))
if(!reject_bad_text(new_name, MAX_CHARTER_LEN) || CHAT_FILTER_CHECK(new_name))
say("Error: Replacement designation rejected by system.")
return
if(tgui_alert(usr, "Are you sure you want to rename the ship to the \"[current_ship.source_template.prefix] [new_name]\"?", "Rename Confirmation", list("Yes", "No")) != "Yes")
return
if(!current_ship.Rename(new_name))
say("Error: [COOLDOWN_TIMELEFT(current_ship, rename_cooldown)/10] seconds until ship designation can be changed.")
return
update_static_data(usr, ui)
return
if("reload_ship")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/overmap/overmap_token.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if(NAMEOF(src, y))
return parent.overmap_move(parent.x, var_value)
if(NAMEOF(src, name))
parent.Rename(var_value)
parent.Rename(var_value, TRUE)
return TRUE
return ..()
/**
Expand Down
35 changes: 23 additions & 12 deletions code/modules/overmap/ships/controlled_ship_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

///The docking port of the linked shuttle. To add a port after creating a controlled ship datum, use [/datum/overmap/ship/controlled/proc/connect_new_shuttle_port].
VAR_FINAL/obj/docking_port/mobile/shuttle_port
///The map template the shuttle was spawned from, if it was indeed created from a template. CAN BE NULL (ex. custom-built ships).
///The map template the shuttle was spawned from, if it was indeed created from a template.
var/datum/map_template/shuttle/source_template
///Whether objects on the ship require an ID with ship access granted
var/unique_ship_access = FALSE
Expand Down Expand Up @@ -67,27 +67,38 @@
///Time that next job slot change can occur
COOLDOWN_DECLARE(job_slot_adjustment_cooldown)

///The ship's real name, without the prefix
var/real_name

///Stations the ship has been blacklisted from landing at, associative station = reason
var/list/blacklisted = list()

/datum/overmap/ship/controlled/Rename(new_name, force = FALSE)
var/oldname = name
if(!..() || (!COOLDOWN_FINISHED(src, rename_cooldown) && !force))
var/old_name = name
var/full_name = "[source_template.prefix] [new_name]"
if(!force && !COOLDOWN_FINISHED(src, rename_cooldown) || !..(full_name, force))
return FALSE
message_admins("[key_name_admin(usr)] renamed vessel '[oldname]' to '[new_name]'")
log_admin("[key_name(src)] has renamed vessel '[oldname]' to '[new_name]'")
SSblackbox.record_feedback("text", "ship_renames", 1, new_name)
shuttle_port?.name = new_name
ship_account.account_holder = new_name

message_admins("[key_name_admin(usr)] renamed vessel '[old_name]' to '[full_name]'")
log_admin("[key_name(src)] has renamed vessel '[old_name]' to '[full_name]'")
SSblackbox.record_feedback("text", "ship_renames", 1, full_name)

real_name = new_name
shuttle_port?.name = full_name
ship_account.account_holder = full_name

if(shipkey)
shipkey.name = "ship key ([new_name])"
shipkey.name = "ship key ([full_name])"

for(var/area/shuttle_area as anything in shuttle_port?.shuttle_areas)
shuttle_area.rename_area("[new_name] [initial(shuttle_area.name)]")
shuttle_area.rename_area("[full_name] [initial(shuttle_area.name)]")

if(!force)
COOLDOWN_START(src, rename_cooldown, 5 MINUTES)
if(shuttle_port?.virtual_z() == null)
return TRUE
priority_announce("The [oldname] has been renamed to the [new_name].", "Docking Announcement", sender_override = new_name, zlevel = shuttle_port?.virtual_z())
priority_announce("The [old_name] has been renamed to the [full_name].", "Docking Announcement", sender_override = full_name, zlevel = shuttle_port?.virtual_z())

return TRUE

/**
Expand Down Expand Up @@ -118,7 +129,7 @@
#ifdef UNIT_TESTS
Rename("[source_template]", TRUE)
#else
Rename("[source_template.prefix] [pick_list_replacements(SHIP_NAMES_FILE, pick(source_template.name_categories))]", TRUE)
Rename(pick_list_replacements(SHIP_NAMES_FILE, pick(source_template.name_categories)), TRUE)
#endif
SSovermap.controlled_ships += src

Expand Down
6 changes: 3 additions & 3 deletions tgui/packages/tgui/interfaces/HelmConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export const HelmConsole = (_props, context) => {

const SharedContent = (_props, context) => {
const { act, data } = useBackend(context);
const { isViewer, shipInfo = [], otherInfo = [] } = data;
const { isViewer, canRename, shipInfo = [], otherInfo = [] } = data;
return (
<>
<Section
title={
<Button.Input
content={decodeHtmlEntities(shipInfo.name)}
content={decodeHtmlEntities(shipInfo.prefixed)}
currentValue={shipInfo.name}
disabled={isViewer}
disabled={isViewer || !canRename}
onCommit={(_e, value) =>
act('rename_ship', {
newName: value,
Expand Down

0 comments on commit ec85630

Please sign in to comment.