Files
fulpstation/code/modules/mob/emote.dm
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

82 lines
2.7 KiB
Plaintext

//The code execution of the emote datum is located at code/datums/emotes.dm
/mob/proc/emote(act, m_type = null, message = null, intentional = FALSE)
act = lowertext(act)
var/param = message
var/custom_param = findchar(act, " ")
if(custom_param)
param = copytext(act, custom_param + length(act[custom_param]))
act = copytext(act, 1, custom_param)
var/list/key_emotes = GLOB.emote_list[act]
if(!length(key_emotes))
if(intentional)
to_chat(src, "<span class='notice'>'[act]' emote does not exist. Say *help for a list.</span>")
return FALSE
var/silenced = FALSE
for(var/datum/emote/P in key_emotes)
if(!P.check_cooldown(src, intentional))
silenced = TRUE
continue
if(P.run_emote(src, param, m_type, intentional))
SEND_SIGNAL(src, COMSIG_MOB_EMOTE, P, act, m_type, message, intentional)
return TRUE
if(intentional && !silenced)
to_chat(src, "<span class='notice'>Unusable emote '[act]'. Say *help for a list.</span>")
return FALSE
/datum/emote/flip
key = "flip"
key_third_person = "flips"
restraint_check = TRUE
mob_type_allowed_typecache = list(/mob/living, /mob/dead/observer)
mob_type_ignore_stat_typecache = list(/mob/dead/observer)
/datum/emote/flip/run_emote(mob/user, params , type_override, intentional)
. = ..()
if(.)
user.SpinAnimation(7,1)
/datum/emote/flip/check_cooldown(mob/user, intentional)
. = ..()
if(.)
return
if(!can_run_emote(user, intentional=intentional))
return
if(isliving(user))
var/mob/living/flippy_mcgee = user
if(prob(20))
flippy_mcgee.Knockdown(1 SECONDS)
flippy_mcgee.visible_message(
"<span class='notice'>[flippy_mcgee] attempts to do a flip and falls over, what a doofus!</span>",
"<span class='notice'>You attempt to do a flip while still off balance from the last flip and fall down!</span>"
)
if(prob(50))
flippy_mcgee.adjustBruteLoss(1)
else
flippy_mcgee.visible_message(
"<span class='notice'>[flippy_mcgee] stumbles a bit after their flip.</span>",
"<span class='notice'>You stumble a bit from still being off balance from your last flip.</span>"
)
/datum/emote/spin
key = "spin"
key_third_person = "spins"
restraint_check = TRUE
mob_type_allowed_typecache = list(/mob/living, /mob/dead/observer)
mob_type_ignore_stat_typecache = list(/mob/dead/observer)
/datum/emote/spin/run_emote(mob/user, params , type_override, intentional)
. = ..()
if(.)
user.spin(20, 1)
if((iscyborg(user) || isanimal(user)) && user.has_buckled_mobs())
var/mob/living/L = user
var/datum/component/riding/riding_datum = L.GetComponent(/datum/component/riding)
if(riding_datum)
for(var/mob/M in L.buckled_mobs)
riding_datum.force_dismount(M)
else
L.unbuckle_all_mobs()