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

Tweak: Prevent send multiple messages to same radio channel #24508

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions code/game/objects/items/devices/radio/beacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
/obj/item/radio/beacon/hear_talk()
return

/obj/item/radio/beacon/talk_into(verbage)
return FALSE

/// Probably a better way of doing this, I'm lazy.
/obj/item/radio/beacon/bacon

Expand Down
25 changes: 16 additions & 9 deletions code/modules/mob/living/living_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,23 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)
else //Turf, leave speech bubbles to the mob
speech_bubble("[bubble_icon][speech_bubble_test]", src, speech_bubble_recipients)

for(var/obj/O in listening_obj)
spawn(0) // KILL THIS
if(O) //It's possible that it could be deleted in the meantime.
O.hear_talk(src, message_pieces, verb)
hear_message_obj(listening_obj, src, message_pieces, verb)

return TRUE

/proc/hear_message_obj(list/listening_obj, mob/M, list/message_pieces, verbage)
var/list/transmited_channels = list()
for(var/obj/O in listening_obj)
spawn(0) // KILL THIS
if(O) // It's possible that it could be deleted in the meantime.
if(isradio(O))
var/obj/item/radio/radio = O
if(radio.broadcasting && get_dist(radio, M) <= radio.canhear_range && !(radio.frequency in transmited_channels))
if(radio.talk_into(M, message_pieces, null, verbage))
transmited_channels += radio.frequency
else
O.hear_talk(M, message_pieces, verbage)
Comment on lines +300 to +309
Copy link
Member

@S34NW S34NW Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(var/obj/O in listening_obj)
spawn(0) // KILL THIS
if(O) // It's possible that it could be deleted in the meantime.
if(isradio(O))
var/obj/item/radio/radio = O
if(radio.broadcasting && get_dist(radio, M) <= radio.canhear_range && !(radio.frequency in transmited_channels))
if(radio.talk_into(M, message_pieces, null, verbage))
transmited_channels += radio.frequency
else
O.hear_talk(M, message_pieces, verbage)
for(var/obj/O in listening_obj)
spawn(0) // KILL THIS
if(!istype(O)) // It's possible that it could be deleted in the meantime.
return
if(!isradio(O))
O.hear_talk(M, message_pieces, verbage)
return
var/obj/item/radio/radio = O
if(!radio.broadcasting || get_dist(radio, M) > radio.canhear_range || (radio.frequency in transmited_channels))
return
if(radio.talk_into(M, message_pieces, null, verbage))
transmited_channels += radio.frequency

Tried to tidy this up, please test to make sure I've not made any mistakes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@S34NW it doesn't work, unfortunately. Message isn't sent to radio channels

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to be that the code returns, while it should continue instead, could you try that?


/obj/effect/speech_bubble
var/mob/parent

Expand Down Expand Up @@ -410,11 +420,8 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)
if(get_turf(M) in hearturfs)
listening |= M

//pass on the message to objects that can hear us.
for(var/obj/O in view(message_range, whisper_loc))
spawn(0)
if(O)
O.hear_talk(src, message_pieces, verb)
// Pass on the message to objects that can hear us.
hear_message_obj(view(message_range, whisper_loc), src, message_pieces, verb)

var/list/eavesdropping = hearers(eavesdropping_range, whisper_loc)
eavesdropping -= src
Expand Down
Loading