Maybe improves radio tts somewhat (hypothetically halves the cost but who really knows) (#96799)

## About The Pull Request

Right now for radio TTS we get hearers twice. 


https://github.com/tgstation/tgstation/blob/62eb74613a141f197cca1f274431b734bd064034/code/game/machinery/telecomms/broadcasting.dm#L165-L170

This is not ideal as it's quite an expensive part of radio handling

<img width="765" height="141" alt="image"
src="https://github.com/user-attachments/assets/8245183b-c810-46bf-b466-9879c33e766c"
/>

My thought is we can remove one of the calls by only calling one or the
other
- If TTS is enabled, call `get_hearers_in_radio_ranges_track_radios` and
combine the list of hearers from *that* list
- If TTS is disabled, just use `get_hearers_in_radio_ranges`

```dm
	// Flat list of mobs who can hear the message
	var/list/receive
	// Assoc list of weakref to a radio to list of weakrefs to mobs who can hear the message
	var/list/receive_radios

	if(tts_radio_id) // only do this if we have a TTS identifier to save on perf
		var/list/recieved_radios_raw = get_hearers_in_radio_ranges_track_radios(radios, frequency)
		receive = list()
		receive_radios = list()
		for(var/radio, radio_hearers in recieved_radios_raw)
			receive |= radio_hearers
			var/datum/weakref/radio_ref = WEAKREF(radio)
			for(var/mob/possible_hearer as anything in radio_hearers)
				if(!isnull(possible_hearer.client) && can_hear_radio_tts(possible_hearer, frequency))
					receive_radios[radio_ref] ||= list()
					receive_radios[radio_ref] += WEAKREF(possible_hearer)

	else
		receive = get_hearers_in_radio_ranges(radios)
```

I also went through and cleaned up TTS handling a bit to make it easier
to parse, mostly completing my reviews from
https://github.com/tgstation/tgstation/pull/95369

No I did not test it

## Changelog

🆑 Melbert
code: Cleaned up radio TTS handling a bit, maybe it'll perform better,
report anything weird
/🆑
This commit is contained in:
MrMelbert
2026-07-16 16:03:15 +02:00
committed by GitHub
parent 4fec9f5603
commit 97cb4ae3b5
6 changed files with 154 additions and 120 deletions
@@ -154,11 +154,7 @@
install_default_programs()
register_context()
update_appearance()
if(mapload)
return INITIALIZE_HINT_LATELOAD
else
if(SStts.tts_enabled)
voice = SStts.computer_voice
return INITIALIZE_HINT_LATELOAD
/obj/item/modular_computer/LateInitialize()
if(SStts.tts_enabled)