|
58 | 58 |
|
59 | 59 | /// 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
|
60 | 60 | /datum/unit_test/speech
|
61 |
| - var/list/handle_speech_result = null |
62 |
| - var/list/handle_hearing_result = null |
63 | 61 | var/mob/living/carbon/human/speaker
|
64 | 62 | var/mob/living/carbon/human/listener
|
| 63 | + var/list/handle_speech_result = null |
| 64 | + var/list/handle_hearing_result = null |
| 65 | + |
65 | 66 | var/obj/item/radio/speaker_radio
|
66 | 67 | var/obj/item/radio/listener_radio
|
| 68 | + var/speaker_radio_heard_message = FALSE |
| 69 | + var/listener_radio_received_message = FALSE |
67 | 70 |
|
68 | 71 | /datum/unit_test/speech/proc/handle_speech(datum/source, list/speech_args)
|
69 | 72 | SIGNAL_HANDLER
|
|
99 | 102 | handle_hearing_result = list()
|
100 | 103 | handle_hearing_result += hearing_args
|
101 | 104 |
|
| 105 | +/datum/unit_test/speech/proc/handle_radio_hearing(datum/source, mob/living/user, message, channel) |
| 106 | + SIGNAL_HANDLER |
| 107 | + |
| 108 | + speaker_radio_heard_message = TRUE |
| 109 | + |
| 110 | +/datum/unit_test/speech/proc/handle_radio_speech(datum/source, list/data) |
| 111 | + SIGNAL_HANDLER |
| 112 | + |
| 113 | + listener_radio_received_message = TRUE |
| 114 | + |
102 | 115 | /datum/unit_test/speech/Run()
|
103 | 116 | speaker = allocate(/mob/living/carbon/human/consistent)
|
104 | 117 | // Name changes to make understanding breakpoints easier
|
|
114 | 127 | listener.mock_client = mock_client
|
115 | 128 |
|
116 | 129 | RegisterSignal(speaker, COMSIG_MOB_SAY, PROC_REF(handle_speech))
|
| 130 | + RegisterSignal(speaker_radio, COMSIG_RADIO_NEW_MESSAGE, PROC_REF(handle_radio_hearing)) |
| 131 | + |
117 | 132 | RegisterSignal(listener, COMSIG_MOVABLE_HEAR, PROC_REF(handle_hearing))
|
| 133 | + RegisterSignal(listener_radio, COMSIG_RADIO_RECEIVE_MESSAGE, PROC_REF(handle_radio_speech)) |
118 | 134 |
|
119 | 135 | // speaking and whispering should be hearable
|
120 | 136 | conversation(distance = 1)
|
|
169 | 185 | handle_hearing_result = null
|
170 | 186 |
|
171 | 187 | /datum/unit_test/speech/proc/radio_test()
|
| 188 | + speaker_radio_heard_message = FALSE |
| 189 | + listener_radio_received_message = FALSE |
| 190 | + |
172 | 191 | speaker.forceMove(run_loc_floor_bottom_left)
|
173 | 192 | listener.forceMove(locate((run_loc_floor_bottom_left.x + 10), run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
|
174 | 193 |
|
|
186 | 205 |
|
187 | 206 | speaker.say(pangram_quote)
|
188 | 207 | TEST_ASSERT(handle_speech_result, "Handle speech signal was not fired (radio test)")
|
189 |
| - TEST_ASSERT(islist(handle_hearing_result), "Listener failed to hear radio message (radio test)") |
| 208 | + TEST_ASSERT(speaker_radio_heard_message, "Speaker's radio did not hear them speak (radio test)") |
190 | 209 | TEST_ASSERT_EQUAL(speaker_radio.get_frequency(), listener_radio.get_frequency(), "Radio frequencies were not equal (radio test)")
|
| 210 | + TEST_ASSERT(listener_radio_received_message, "Listener's radio did not receive the broadcast (radio test)") |
| 211 | + TEST_ASSERT(islist(handle_hearing_result), "Listener failed to hear radio message (radio test)") |
191 | 212 |
|
192 | 213 | handle_speech_result = null
|
193 | 214 | handle_hearing_result = null
|
| 215 | + speaker_radio_heard_message = FALSE |
| 216 | + listener_radio_received_message = FALSE |
194 | 217 |
|
195 | 218 | speaker_radio.set_frequency(FREQ_CTF_RED)
|
196 | 219 | speaker.say(pangram_quote)
|
|
200 | 223 |
|
201 | 224 | handle_speech_result = null
|
202 | 225 | handle_hearing_result = null
|
| 226 | + speaker_radio_heard_message = FALSE |
| 227 | + listener_radio_received_message = FALSE |
203 | 228 | speaker_radio.set_broadcasting(FALSE)
|
204 | 229 |
|
205 | 230 | #undef NORMAL_HEARING_RANGE
|
|
0 commit comments