diff --git a/code/__DEFINES/dcs/signals/signals_object.dm b/code/__DEFINES/dcs/signals/signals_object.dm index c1d9e88786a..1f17b3646da 100644 --- a/code/__DEFINES/dcs/signals/signals_object.dm +++ b/code/__DEFINES/dcs/signals/signals_object.dm @@ -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 diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm index 97ecd19e470..e8ecb72393f 100644 --- a/code/game/machinery/telecomms/broadcasting.dm +++ b/code/game/machinery/telecomms/broadcasting.dm @@ -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) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 1bc96c35122..1a356686a74 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -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) diff --git a/code/modules/mob/living/living_say.dm b/code/modules/mob/living/living_say.dm index 50b4abf8035..de01642f0c6 100644 --- a/code/modules/mob/living/living_say.dm +++ b/code/modules/mob/living/living_say.dm @@ -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 diff --git a/code/modules/unit_tests/say.dm b/code/modules/unit_tests/say.dm index 3ae55a12e37..ec58dcedc88 100644 --- a/code/modules/unit_tests/say.dm +++ b/code/modules/unit_tests/say.dm @@ -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