Merge pull request #10741 from Kyep/hear_say_annoyance

Fixes hear_say.dm runtime: list index out of bounds
This commit is contained in:
variableundefined
2019-01-27 10:04:28 +08:00
committed by GitHub
+12 -10
View File
@@ -70,7 +70,7 @@
sound_vol *= 0.5
if(sleeping || stat == UNCONSCIOUS)
hear_sleep(message_pieces)
hear_sleep(multilingual_to_message(message_pieces))
return 0
var/speaker_name = speaker.name
@@ -97,7 +97,7 @@
if(!can_hear())
// INNATE is the flag for audible-emote-language, so we don't want to show an "x talks but you cannot hear them" message if it's set
// if(!language || !(language.flags & INNATE))
// if(!language || !(language.flags & INNATE))
if(speaker == src)
to_chat(src, "<span class='warning'>You cannot hear yourself speak!</span>")
else
@@ -158,14 +158,16 @@
message = strip_html_properly(message)
var/list/punctuation = list(",", "!", ".", ";", "?")
var/list/messages = splittext(message, " ")
var/R = rand(1, messages.len)
var/heardword = messages[R]
if(copytext(heardword,1, 1) in punctuation)
heardword = copytext(heardword,2)
if(copytext(heardword,-1) in punctuation)
heardword = copytext(heardword,1,lentext(heardword))
heard = "<span class='game say'>...<i>You hear something about<i>... '[heardword]'...</span>"
if(messages.len > 0)
var/R = rand(1, messages.len)
var/heardword = messages[R]
if(copytext(heardword,1, 1) in punctuation)
heardword = copytext(heardword,2)
if(copytext(heardword,-1) in punctuation)
heardword = copytext(heardword,1,lentext(heardword))
heard = "<span class='game say'>...<i>You hear something about<i>... '[heardword]'...</span>"
else
heard = "<span class='game say'>...<i>You almost hear something...</i>...</span>"
else
heard = "<span class='game say'>...<i>You almost hear someone talking</i>...</span>"