mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 14:08:31 +01:00
[MIRROR] Fixes hearing messages from speakers on another z level (515 fix) [MDB IGNORE] (#25217)
* Fixes hearing messages from speakers on another z level (515 fix) (#79888) 515 changed get_dist to return inf when either end is on another z level, instead of just the maximum range. `/mob/living/Hear` early returns when the speaker is too far away to hear. Previously we would get around this by passing in INFINITY as the range for the message, but the INFINITY define is just a very large number instead of real infinity which is what byond gives back for get_dist. I also improved the unit test a little while debugging this. * Fixes hearing messages from speakers on another z level (515 fix) --------- Co-authored-by: Emmett Gaines <ninjanomnom@gmail.com>
This commit is contained in:
co-authored by
Emmett Gaines
parent
81b5dd07aa
commit
80a53e9407
@@ -310,6 +310,8 @@
|
||||
#define COMSIG_RADIO_NEW_FREQUENCY "radio_new_frequency"
|
||||
///called from base of /obj/item/radio/proc/talk_into(): (atom/movable/M, message, channel)
|
||||
#define COMSIG_RADIO_NEW_MESSAGE "radio_new_message"
|
||||
///called from base of /obj/item/radio/proc/on_receive_messgae(): (list/data)
|
||||
#define COMSIG_RADIO_RECEIVE_MESSAGE "radio_receive_message"
|
||||
|
||||
// /obj/item/pen signals
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
radios += independent_radio
|
||||
|
||||
for(var/obj/item/radio/called_radio as anything in radios)
|
||||
called_radio.on_recieve_message()
|
||||
called_radio.on_recieve_message(data)
|
||||
|
||||
// From the list of radios, find all mobs who can hear those.
|
||||
var/list/receive = get_hearers_in_radio_ranges(radios)
|
||||
|
||||
@@ -388,7 +388,8 @@
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/item/radio/proc/on_recieve_message()
|
||||
/obj/item/radio/proc/on_recieve_message(list/data)
|
||||
SEND_SIGNAL(src, COMSIG_RADIO_RECEIVE_MESSAGE, data)
|
||||
flick_overlay_view(overlay_speaker_active, 5 SECONDS)
|
||||
|
||||
/obj/item/radio/ui_state(mob/user)
|
||||
|
||||
@@ -283,7 +283,7 @@ GLOBAL_LIST_INIT(message_modes_stat_limits, list(
|
||||
var/dist = get_dist(speaker, src) - message_range
|
||||
if(dist > 0 && dist <= EAVESDROP_EXTRA_RANGE && !HAS_TRAIT(src, TRAIT_GOOD_HEARING) && !isobserver(src)) // ghosts can hear all messages clearly
|
||||
raw_message = stars(raw_message)
|
||||
if (dist > EAVESDROP_EXTRA_RANGE && !HAS_TRAIT(src, TRAIT_GOOD_HEARING) && !isobserver(src))
|
||||
if (message_range != INFINITY && dist > EAVESDROP_EXTRA_RANGE && !HAS_TRAIT(src, TRAIT_GOOD_HEARING) && !isobserver(src))
|
||||
return FALSE // Too far away and don't have good hearing, you can't hear anything
|
||||
|
||||
// we need to send this signal before compose_message() is used since other signals need to modify
|
||||
|
||||
@@ -58,12 +58,15 @@
|
||||
|
||||
/// This runs some simple speech tests on a speaker and listener and determines if a person can hear whispering or speaking as they are moved a distance away
|
||||
/datum/unit_test/speech
|
||||
var/list/handle_speech_result = null
|
||||
var/list/handle_hearing_result = null
|
||||
var/mob/living/carbon/human/speaker
|
||||
var/mob/living/carbon/human/listener
|
||||
var/list/handle_speech_result = null
|
||||
var/list/handle_hearing_result = null
|
||||
|
||||
var/obj/item/radio/speaker_radio
|
||||
var/obj/item/radio/listener_radio
|
||||
var/speaker_radio_heard_message = FALSE
|
||||
var/listener_radio_received_message = FALSE
|
||||
|
||||
/datum/unit_test/speech/proc/handle_speech(datum/source, list/speech_args)
|
||||
SIGNAL_HANDLER
|
||||
@@ -99,6 +102,16 @@
|
||||
handle_hearing_result = list()
|
||||
handle_hearing_result += hearing_args
|
||||
|
||||
/datum/unit_test/speech/proc/handle_radio_hearing(datum/source, mob/living/user, message, channel)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
speaker_radio_heard_message = TRUE
|
||||
|
||||
/datum/unit_test/speech/proc/handle_radio_speech(datum/source, list/data)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
listener_radio_received_message = TRUE
|
||||
|
||||
/datum/unit_test/speech/Run()
|
||||
speaker = allocate(/mob/living/carbon/human/consistent)
|
||||
// Name changes to make understanding breakpoints easier
|
||||
@@ -114,7 +127,10 @@
|
||||
listener.mock_client = mock_client
|
||||
|
||||
RegisterSignal(speaker, COMSIG_MOB_SAY, PROC_REF(handle_speech))
|
||||
RegisterSignal(speaker_radio, COMSIG_RADIO_NEW_MESSAGE, PROC_REF(handle_radio_hearing))
|
||||
|
||||
RegisterSignal(listener, COMSIG_MOVABLE_HEAR, PROC_REF(handle_hearing))
|
||||
RegisterSignal(listener_radio, COMSIG_RADIO_RECEIVE_MESSAGE, PROC_REF(handle_radio_speech))
|
||||
|
||||
// speaking and whispering should be hearable
|
||||
conversation(distance = 1)
|
||||
@@ -169,6 +185,9 @@
|
||||
handle_hearing_result = null
|
||||
|
||||
/datum/unit_test/speech/proc/radio_test()
|
||||
speaker_radio_heard_message = FALSE
|
||||
listener_radio_received_message = FALSE
|
||||
|
||||
speaker.forceMove(run_loc_floor_bottom_left)
|
||||
listener.forceMove(locate((run_loc_floor_bottom_left.x + 10), run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
|
||||
|
||||
@@ -186,11 +205,15 @@
|
||||
|
||||
speaker.say(pangram_quote)
|
||||
TEST_ASSERT(handle_speech_result, "Handle speech signal was not fired (radio test)")
|
||||
TEST_ASSERT(islist(handle_hearing_result), "Listener failed to hear radio message (radio test)")
|
||||
TEST_ASSERT(speaker_radio_heard_message, "Speaker's radio did not hear them speak (radio test)")
|
||||
TEST_ASSERT_EQUAL(speaker_radio.get_frequency(), listener_radio.get_frequency(), "Radio frequencies were not equal (radio test)")
|
||||
TEST_ASSERT(listener_radio_received_message, "Listener's radio did not receive the broadcast (radio test)")
|
||||
TEST_ASSERT(islist(handle_hearing_result), "Listener failed to hear radio message (radio test)")
|
||||
|
||||
handle_speech_result = null
|
||||
handle_hearing_result = null
|
||||
speaker_radio_heard_message = FALSE
|
||||
listener_radio_received_message = FALSE
|
||||
|
||||
speaker_radio.set_frequency(FREQ_CTF_RED)
|
||||
speaker.say(pangram_quote)
|
||||
@@ -200,6 +223,8 @@
|
||||
|
||||
handle_speech_result = null
|
||||
handle_hearing_result = null
|
||||
speaker_radio_heard_message = FALSE
|
||||
listener_radio_received_message = FALSE
|
||||
speaker_radio.set_broadcasting(FALSE)
|
||||
|
||||
#undef NORMAL_HEARING_RANGE
|
||||
|
||||
Reference in New Issue
Block a user