Files
kiwistation/code/modules/recycling/sortingmachinery.dm
T
MrPerson f7eb2c905b Unicode awareness Part 2 -- copytext() (#48512)
* Unicode support Part 2 -- copytext()

This is the transition of all copytext() calls to be unicode aware and also some nearby calls in the same functions. Most things are just replacing copytext() with copytext_char() as a terrible character limiter but a few others were slightly more involved.

I replaced a ton of
````
var/something = sanitize(input())
something = copytext(something, 1, MAX_MESSAGE_LEN)
````

with a single stripped_input() call. stripped_input() already calls html_encode(), trim(), and some other sanitization so there shouldn't be any major issues there.

This is still VERY rough btw; DNA is a mess, the status displays are complete ass, there's a copytext() in code\datums\shuttles.dm that I'm not sure what to do with, and I didn't touch anything in the tools folder. I haven't tested this much at all yet, I only got it to compile earlier this morning. There's also likely to be weird bugs until I get around to fixing length(), findtext(), and the rest of the string procs.

* Makes the code functional

* Assume color hex strings are always # followed by ascii.
Properly encodes and decodes the stuff in mob_helpers.dm which fixes some issues there.

* Removes ninjaspeak since it's unused
2020-01-18 13:07:22 +13:00

246 lines
8.8 KiB
Plaintext

/obj/structure/bigDelivery
name = "large parcel"
desc = "A large delivery parcel."
icon = 'icons/obj/storage.dmi'
icon_state = "deliverycloset"
density = TRUE
mouse_drag_pointer = MOUSE_ACTIVE_POINTER
var/giftwrapped = FALSE
var/sortTag = 0
var/obj/item/paper/note
/obj/structure/bigDelivery/interact(mob/user)
playsound(src.loc, 'sound/items/poster_ripped.ogg', 50, TRUE)
qdel(src)
/obj/structure/bigDelivery/Destroy()
var/turf/T = get_turf(src)
for(var/atom/movable/AM in contents)
AM.forceMove(T)
return ..()
/obj/structure/bigDelivery/contents_explosion(severity, target)
for(var/atom/movable/AM in contents)
AM.ex_act()
/obj/structure/bigDelivery/examine(mob/user)
. = ..()
if(note)
if(!in_range(user, src))
. += "There's a [note.name] attached to it. You can't read it from here."
else
. += "There's a [note.name] attached to it..."
. += note.examine(user)
/obj/structure/bigDelivery/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/destTagger))
var/obj/item/destTagger/O = W
if(sortTag != O.currTag)
var/tag = uppertext(GLOB.TAGGERLOCATIONS[O.currTag])
to_chat(user, "<span class='notice'>*[tag]*</span>")
sortTag = O.currTag
playsound(loc, 'sound/machines/twobeep_high.ogg', 100, TRUE)
else if(istype(W, /obj/item/pen))
if(!user.is_literate())
to_chat(user, "<span class='notice'>You scribble illegibly on the side of [src]!</span>")
return
var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN)
if(!user.canUseTopic(src, BE_CLOSE))
return
if(!str || !length(str))
to_chat(user, "<span class='warning'>Invalid text!</span>")
return
user.visible_message("<span class='notice'>[user] labels [src] as [str].</span>")
name = "[name] ([str])"
else if(istype(W, /obj/item/stack/wrapping_paper) && !giftwrapped)
var/obj/item/stack/wrapping_paper/WP = W
if(WP.use(3))
user.visible_message("<span class='notice'>[user] wraps the package in festive paper!</span>")
giftwrapped = TRUE
icon_state = "gift[icon_state]"
else
to_chat(user, "<span class='warning'>You need more paper!</span>")
else if(istype(W, /obj/item/paper))
if(note)
to_chat(user, "<span class='warning'>This package already has a note attached!</span>")
return
if(!user.transferItemToLoc(W, src))
to_chat(user, "<span class='warning'>For some reason, you can't attach [W]!</span>")
return
user.visible_message("<span class='notice'>[user] attaches [W] to [src].</span>", "<span class='notice'>You attach [W] to [src].</span>")
note = W
var/overlaystring = "[icon_state]_note"
if(giftwrapped)
overlaystring = copytext(overlaystring, 5) //5 == length("gift") + 1
add_overlay(overlaystring)
else
return ..()
/obj/structure/bigDelivery/relay_container_resist(mob/living/user, obj/O)
if(ismovableatom(loc))
var/atom/movable/AM = loc //can't unwrap the wrapped container if it's inside something.
AM.relay_container_resist(user, O)
return
to_chat(user, "<span class='notice'>You lean on the back of [O] and start pushing to rip the wrapping around it.</span>")
if(do_after(user, 50, target = O))
if(!user || user.stat != CONSCIOUS || user.loc != O || O.loc != src )
return
to_chat(user, "<span class='notice'>You successfully removed [O]'s wrapping !</span>")
O.forceMove(loc)
playsound(src.loc, 'sound/items/poster_ripped.ogg', 50, TRUE)
qdel(src)
else
if(user.loc == src) //so we don't get the message if we resisted multiple times and succeeded.
to_chat(user, "<span class='warning'>You fail to remove [O]'s wrapping!</span>")
/obj/item/smallDelivery
name = "parcel"
desc = "A brown paper delivery parcel."
icon = 'icons/obj/storage.dmi'
icon_state = "deliverypackage3"
item_state = "deliverypackage"
var/giftwrapped = 0
var/sortTag = 0
var/obj/item/paper/note
/obj/item/smallDelivery/contents_explosion(severity, target)
for(var/atom/movable/AM in contents)
AM.ex_act()
/obj/item/smallDelivery/attack_self(mob/user)
user.temporarilyRemoveItemFromInventory(src, TRUE)
for(var/X in contents)
var/atom/movable/AM = X
user.put_in_hands(AM)
playsound(src.loc, 'sound/items/poster_ripped.ogg', 50, TRUE)
qdel(src)
/obj/item/smallDelivery/attack_self_tk(mob/user)
if(ismob(loc))
var/mob/M = loc
M.temporarilyRemoveItemFromInventory(src, TRUE)
for(var/X in contents)
var/atom/movable/AM = X
M.put_in_hands(AM)
else
for(var/X in contents)
var/atom/movable/AM = X
AM.forceMove(src.loc)
playsound(src.loc, 'sound/items/poster_ripped.ogg', 50, TRUE)
qdel(src)
/obj/item/smallDelivery/examine(mob/user)
. = ..()
if(note)
if(!in_range(user, src))
. += "There's a [note.name] attached to it. You can't read it from here."
else
. += "There's a [note.name] attached to it..."
. += note.examine(user)
/obj/item/smallDelivery/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/destTagger))
var/obj/item/destTagger/O = W
if(sortTag != O.currTag)
var/tag = uppertext(GLOB.TAGGERLOCATIONS[O.currTag])
to_chat(user, "<span class='notice'>*[tag]*</span>")
sortTag = O.currTag
playsound(loc, 'sound/machines/twobeep_high.ogg', 100, TRUE)
else if(istype(W, /obj/item/pen))
if(!user.is_literate())
to_chat(user, "<span class='notice'>You scribble illegibly on the side of [src]!</span>")
return
var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN)
if(!user.canUseTopic(src, BE_CLOSE))
return
if(!str || !length(str))
to_chat(user, "<span class='warning'>Invalid text!</span>")
return
user.visible_message("<span class='notice'>[user] labels [src] as [str].</span>")
name = "[name] ([str])"
else if(istype(W, /obj/item/stack/wrapping_paper) && !giftwrapped)
var/obj/item/stack/wrapping_paper/WP = W
if(WP.use(1))
icon_state = "gift[icon_state]"
giftwrapped = 1
user.visible_message("<span class='notice'>[user] wraps the package in festive paper!</span>")
else
to_chat(user, "<span class='warning'>You need more paper!</span>")
else if(istype(W, /obj/item/paper))
if(note)
to_chat(user, "<span class='warning'>This package already has a note attached!</span>")
return
if(!user.transferItemToLoc(W, src))
to_chat(user, "<span class='warning'>For some reason, you can't attach [W]!</span>")
return
user.visible_message("<span class='notice'>[user] attaches [W] to [src].</span>", "<span class='notice'>You attach [W] to [src].</span>")
note = W
var/overlaystring = "[icon_state]_note"
if(giftwrapped)
overlaystring = copytext_char(overlaystring, 5) //5 == length("gift") + 1
add_overlay(overlaystring)
/obj/item/destTagger
name = "destination tagger"
desc = "Used to set the destination of properly wrapped packages."
icon = 'icons/obj/device.dmi'
icon_state = "cargotagger"
var/currTag = 0 //Destinations are stored in code\globalvars\lists\flavor_misc.dm
var/locked_destination = FALSE //if true, users can't open the destination tag window to prevent changing the tagger's current destination
w_class = WEIGHT_CLASS_TINY
item_state = "electronic"
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
flags_1 = CONDUCT_1
slot_flags = ITEM_SLOT_BELT
/obj/item/destTagger/borg
name = "cyborg destination tagger"
desc = "Used to fool the disposal mail network into thinking that you're a harmless parcel. Does actually work as a regular destination tagger as well."
/obj/item/destTagger/suicide_act(mob/living/user)
user.visible_message("<span class='suicide'>[user] begins tagging [user.p_their()] final destination! It looks like [user.p_theyre()] trying to commit suicide!</span>")
if (islizard(user))
to_chat(user, "<span class='notice'>*HELL*</span>")//lizard nerf
else
to_chat(user, "<span class='notice'>*HEAVEN*</span>")
playsound(src, 'sound/machines/twobeep_high.ogg', 100, TRUE)
return BRUTELOSS
/obj/item/destTagger/proc/openwindow(mob/user)
var/dat = "<tt><center><h1><b>TagMaster 2.2</b></h1></center>"
dat += "<table style='width:100%; padding:4px;'><tr>"
for (var/i = 1, i <= GLOB.TAGGERLOCATIONS.len, i++)
dat += "<td><a href='?src=[REF(src)];nextTag=[i]'>[GLOB.TAGGERLOCATIONS[i]]</a></td>"
if(i%4==0)
dat += "</tr><tr>"
dat += "</tr></table><br>Current Selection: [currTag ? GLOB.TAGGERLOCATIONS[currTag] : "None"]</tt>"
user << browse(dat, "window=destTagScreen;size=450x350")
onclose(user, "destTagScreen")
/obj/item/destTagger/attack_self(mob/user)
if(!locked_destination)
openwindow(user)
return
/obj/item/destTagger/Topic(href, href_list)
add_fingerprint(usr)
if(href_list["nextTag"])
var/n = text2num(href_list["nextTag"])
currTag = n
openwindow(usr)