Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes hearing messages from speakers on another z level (515 fix) #799

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/telecomms/broadcasting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions code/modules/unit_tests/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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))

Expand All @@ -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)
Expand All @@ -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
Expand Down
Loading