Skip to content

Commit

Permalink
Misc. Fixes (#5475)
Browse files Browse the repository at this point in the history
* Make matterforge update static data when blackbox is inserted

* Make sinks use do_after instead of sleep

* Fix nanoword improperly sanitizing things during editing

* Make autolathe/matterforge use fixed height for materials

* Make RCON output use kw text too

* Recompile TGUI and make vending work for big descs
  • Loading branch information
ShadowLarkens authored Jun 24, 2024
1 parent 58971f7 commit 9aad7bb
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 64 deletions.
3 changes: 2 additions & 1 deletion code/game/machinery/autolathe/matterforge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
user.drop_item(I)
I.forceMove(src)
power_source = I
update_static_data_for_all_viewers()
return

if(power_source)
Expand Down Expand Up @@ -409,7 +410,7 @@
next_file()

update_icon()
SSnano.update_uis(src)
SStgui.update_uis(src)



Expand Down
56 changes: 35 additions & 21 deletions code/game/objects/structures/watercloset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -477,23 +477,28 @@
to_chat(user, SPAN_WARNING("Someone's already washing here."))
return

to_chat(usr, SPAN_NOTICE("You start washing your hands."))

user.visible_message(
SPAN_NOTICE("[user] starts washing their hands using [src]."),
SPAN_NOTICE("You start washing your hands using [src].")
)
playsound(loc, 'sound/effects/watersplash.ogg', 100, 1)

busy = 1
sleep(40)
busy = 0

if(!Adjacent(user)) return //Person has moved away from the sink
busy = TRUE
if(!do_after(user, 40, src))
busy = FALSE
return
busy = FALSE

amount_of_reagents -= 40
user.clean_blood()
if(ishuman(user))
user:update_inv_gloves()
for(var/mob/V in viewers(src, null))
V.show_message(SPAN_NOTICE("[user] washes their hands using \the [src]."))
var/mob/living/carbon/human/H = user
H.update_inv_gloves()

user.visible_message(
SPAN_NOTICE("[user] washes their hands using [src]."),
SPAN_NOTICE("You wash your hands using [src].")
)

/obj/structure/sink/attackby(obj/item/O as obj, mob/living/user as mob)
if(busy)
Expand Down Expand Up @@ -540,29 +545,38 @@
if(!isturf(location)) return

var/obj/item/I = O
if(!I || !istype(I,/obj/item)) return
if(!istype(I))
return

to_chat(usr, SPAN_NOTICE("You start washing \the [I]."))
user.visible_message(
SPAN_NOTICE("[user] starts washing [I] using [src]"),
SPAN_NOTICE("You start washing [I] using [src].")
)

if(amount_of_reagents < 40)
to_chat(user, SPAN_WARNING("The water pressure seems too low to wash with."))
return

busy = 1
sleep(40)
busy = 0
busy = TRUE
if(!do_after(user, 40, src))
busy = FALSE
return
busy = FALSE

if(limited_reagents)
amount_of_reagents -= 40

if(user.loc != location) return //User has moved
if(!I) return //Item's been destroyed while washing
if(user.get_active_hand() != I) return //Person has switched hands or the item in their hands
if(QDELETED(I))
return //Item's been destroyed while washing

if(user.get_active_hand() != I)
return //Person has switched hands or the item in their hands

O.clean_blood()
user.visible_message( \
SPAN_NOTICE("[user] washes \a [I] using \the [src]."), \
SPAN_NOTICE("You wash \a [I] using \the [src]."))
user.visible_message(
SPAN_NOTICE("[user] washes \a [I] using \the [src]."),
SPAN_NOTICE("You wash \a [I] using \the [src].")
)

/obj/structure/sink/AltClick(var/mob/living/user)
var/H = user.get_active_hand()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
available_on_ntnet = TRUE
var/browsing
var/open_file
// WARNING: UNSANITIZED VARIABLE
// THIS MUST BE SANITIZED BEFORE BEING SENT ANYWHERE VULNERABLE TO HTML
var/loaded_data = ""
var/error
var/is_edited
Expand Down Expand Up @@ -74,8 +76,9 @@
data["usbfiles"] = usbfiles

data["open_file"] = open_file
data["loaded_data"] = replacetext(loaded_data, "\[br\]", "\n")
data["loaded_data_html"] = pencode2html(loaded_data)
data["loaded_data"] = loaded_data
data["loaded_data_html"] = pencode2html(sanitize(replacetext(loaded_data, "\n", "\[br\]"), MAX_TEXTFILE_LENGTH))
data["max_length"] = MAX_TEXTFILE_LENGTH

return data

Expand Down Expand Up @@ -131,14 +134,14 @@
. = TRUE

if("PRG_editfile")
loaded_data = sanitize(params["text"], MAX_TEXTFILE_LENGTH)
loaded_data = copytext(params["text"], 1, MAX_TEXTFILE_LENGTH)
return TRUE

if("PRG_printfile")
if(!computer.printer)
error = "Missing Hardware: Your computer does not have the required hardware to complete this operation."
return TRUE
if(!computer.printer.print_text(pencode2html(loaded_data)))
if(!computer.printer.print_text(pencode2html(sanitize(replacetext(loaded_data, "\n", "\[br\]"), MAX_TEXTFILE_LENGTH))))
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
return TRUE
. = TRUE
5 changes: 4 additions & 1 deletion tgui/packages/tgui/interfaces/Matterforge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ export type MaterialData = {
};

export const LoadedMaterials = (props: MaterialData) => {
const { act, data } = useBackend<MaterialData>();
const { act } = useBackend<MaterialData>();

const { materials, mat_capacity } = props;

return (
<Section
fill
scrollable
height={materials.length <= 1 ? 5 : 18}
title="Loaded Materials"
buttons={
<Button
Expand Down
15 changes: 9 additions & 6 deletions tgui/packages/tgui/interfaces/Ntos/NtosRcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,17 @@ const Smes = (props: { smes: SMESData }) => {
}
>
<Slider
value={smes.output_val}
value={smes.output_val / 1000}
minValue={0}
maxValue={smes.output_max}
fillValue={smes.output_load}
step={1000}
format={(val) => formatPower(round(val, 2))}
maxValue={smes.output_max / 1000}
fillValue={smes.output_load / 1000}
step={1}
format={(val) => formatPower(round(val * 1000, 2))}
onChange={(e, value) =>
act('smes_out_set', { smes: smes.RCON_tag, value })
act('smes_out_set', {
smes: smes.RCON_tag,
value: value * 1000,
})
}
>
{formatPower(round(smes.output_load, 2))} Load /{' '}
Expand Down
8 changes: 5 additions & 3 deletions tgui/packages/tgui/interfaces/Ntos/NtosWord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Data = {
loaded_data: string;
/** Loaded Data for open file but passed through pencode2html */
loaded_data_html: string;
max_length: number;
};

export const NtosWord = (props) => {
Expand Down Expand Up @@ -129,7 +130,7 @@ export const FileBrowser = (props: { uiControl: MetaUIControlProps }) => {
export const Word = (props: { uiControl: MetaUIControlProps }) => {
const { act, data } = useBackend<Data>();
const { setShowFileBrowser, edited, setEdited } = props.uiControl;
const { open_file, loaded_data, loaded_data_html } = data;
const { open_file, loaded_data, loaded_data_html, max_length } = data;

const [showPreview, setShowPreview] = useState(false);
const [showHelp, setShowHelp] = useState(false);
Expand Down Expand Up @@ -234,13 +235,14 @@ export const Word = (props: { uiControl: MetaUIControlProps }) => {
scrollbar
fluid
height="100%"
maxLength={max_length}
multilineEnter
value={loaded_data}
onInput={(e, val) => {
setEdited(true);
}}
onChange={(e, val) => {
act('PRG_editfile', { text: val.replaceAll('\n', '[br]') });
onChange={(e, text) => {
act('PRG_editfile', { text });
setEdited(true);
}}
/>
Expand Down
4 changes: 3 additions & 1 deletion tgui/packages/tgui/styles/interfaces/Vending.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
}
&--modal {
width: 30rem;
max-height: 30rem;
overflow: hidden;
overflow-y: auto;
border-radius: 0.5rem;
}
&--cancel {
height: 4ch;
text-align: center;
font-weight: bold;
}
}
}
2 changes: 1 addition & 1 deletion tgui/public/tgui.bundle.css

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit 9aad7bb

Please sign in to comment.