Ports /tg/ spatial grid system, refactors telecomms, destroys lag (#15140)

This commit is contained in:
Wildkins
2022-12-09 12:35:33 +01:00
committed by GitHub
parent d3f8f12fea
commit 2fcfa8adb7
158 changed files with 4068 additions and 3263 deletions
+2 -2
View File
@@ -187,7 +187,7 @@
. = list()
var/turf/pos = get_turf(source)
if(pos)
for(var/turf/T in hear(range, pos))
for(var/turf/T in get_hear(range, pos))
. += T
#undef UPDATE_BUFFER
#undef UPDATE_BUFFER
+3 -8
View File
@@ -127,7 +127,7 @@
if(vr_mob)
to_chat(vr_mob, "[time] [message]")
/mob/proc/hear_radio(var/message, var/verb="says", var/datum/language/language=null, var/part_a, var/part_b, var/part_c, var/mob/speaker = null, var/hard_to_hear = 0, var/vname ="")
/mob/proc/hear_radio(var/message, var/verb="says", var/datum/language/language=null, var/part_a, var/part_b, var/part_c, var/mob/speaker = null, var/hard_to_hear = 0)
if(!client && !vr_mob)
return
@@ -165,13 +165,8 @@
else
speaker_name = "Unknown"
if(istype(speaker, /mob/living/carbon/human))
var/mob/living/carbon/human/H = speaker
if(H.voice)
speaker_name = H.voice
if(vname)
speaker_name = vname
if(ishuman(speaker) && speaker.GetVoice() != real_name)
speaker_name = speaker.GetVoice()
if(hard_to_hear)
speaker_name = "Unknown"
+5 -5
View File
@@ -236,7 +236,7 @@
/obj/item/device/mmi/radio_enabled/Initialize()
. = ..()
radio = new(src)//Spawns a radio inside the MMI.
radio.broadcasting = TRUE//So it's broadcasting from the start.
radio.set_broadcasting(TRUE) //So it's broadcasting from the start.
//Allows the brain to toggle the radio functions.
/obj/item/device/mmi/radio_enabled/verb/Toggle_Broadcasting()
@@ -249,8 +249,8 @@
if(brainmob.stat)//Only the brainmob will trigger these so no further check is necessary.
to_chat(brainmob, "Can't do that while incapacitated or dead.")
radio.broadcasting = radio.broadcasting==1 ? 0 : 1
to_chat(brainmob, SPAN_NOTICE("Radio is [radio.broadcasting==1 ? "now" : "no longer"] broadcasting."))
radio.set_broadcasting(!radio.get_broadcasting())
to_chat(brainmob, SPAN_NOTICE("Radio is [radio.get_broadcasting() ? "now" : "no longer"] broadcasting."))
/obj/item/device/mmi/radio_enabled/verb/Toggle_Listening()
set name = "Toggle Listening"
@@ -262,8 +262,8 @@
if(brainmob.stat)
to_chat(brainmob, "Can't do that while incapacitated or dead.")
radio.listening = radio.listening==1 ? 0 : 1
to_chat(brainmob, SPAN_NOTICE("Radio is [radio.listening==1 ? "now" : "no longer"] receiving broadcast."))
radio.set_listening(!radio.get_listening())
to_chat(brainmob, SPAN_NOTICE("Radio is [radio.get_listening() ? "now" : "no longer"] receiving broadcast."))
/obj/item/device/mmi/emp_act(severity)
if(!brainmob)
+16 -22
View File
@@ -161,7 +161,7 @@
return headsets[headsets[1]]
return null
/mob/living/carbon/human/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper, var/is_singing = FALSE)
/mob/living/carbon/human/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper, var/is_singing = FALSE)
if(!whisper && (paralysis || InStasis()))
whisper(message, speaking)
return TRUE
@@ -170,53 +170,48 @@
for(var/obj/item/device/radio/intercom/I in view(1))
I.add_fingerprint(src)
used_radios += I
if(I.talk_into(src, message, null, verb, speaking))
successful_radio += I
I.talk_into(src, message, null, verb, speaking)
if("headset")
var/obj/item/device/radio/R = get_radio()
if(R)
used_radios += R
if(R.talk_into(src, message, null, verb, speaking))
successful_radio += R
R.talk_into(src, message, null, verb, speaking)
if("right ear")
var/obj/item/device/radio/R
var/has_radio = 0
var/has_radio = FALSE
if(istype(r_ear,/obj/item/device/radio))
R = r_ear
has_radio = 1
has_radio = TRUE
if(istype(r_hand, /obj/item/device/radio))
R = r_hand
has_radio = 1
has_radio = TRUE
if(has_radio)
used_radios += R
if(R.talk_into(src,message,null,verb,speaking))
successful_radio += R
R.talk_into(src,message,null,verb,speaking)
if("left ear")
var/obj/item/device/radio/R
var/has_radio = 0
var/has_radio = FALSE
if(istype(l_ear, /obj/item/device/radio))
R = l_ear
has_radio = 1
has_radio = TRUE
if(istype(l_hand, /obj/item/device/radio))
R = l_hand
has_radio = 1
has_radio = TRUE
if(has_radio)
used_radios += R
if(R.talk_into(src,message,null,verb,speaking))
successful_radio += R
R.talk_into(src,message,null,verb,speaking)
if("wrist")
var/obj/item/device/radio/R
var/has_radio = 0
var/has_radio = FALSE
if(istype(wrists,/obj/item/device/radio))
R = wrists
has_radio = 1
has_radio = TRUE
if(istype(r_hand, /obj/item/device/radio))
R = wrists
has_radio = 1
has_radio = TRUE
if(has_radio)
used_radios += R
if(R.talk_into(src,message,null,verb,speaking))
successful_radio += R
R.talk_into(src,message,null,verb,speaking)
if("whisper")
whisper(message, speaking, is_singing)
return TRUE
@@ -224,8 +219,7 @@
var/obj/item/device/radio/R = get_radio()
if(R)
used_radios += R
if(R.talk_into(src, message, message_mode, verb, speaking))
successful_radio += R
R.talk_into(src, message, message_mode, verb, speaking)
/mob/living/carbon/human/handle_speech_sound()
var/list/returns = ..()
+24 -22
View File
@@ -16,7 +16,7 @@ var/list/department_radio_keys = list(
":x" = "Raider", ".x" = "Raider",
":b" = "Burglar", ".b" = "Burglar",
":j" = "Bluespace", ".j" = "Bluespace",
":y" = "Ship", ".y" = "Ship",
":y" = "Hailing", ".y" = "Hailing",
":q" = "Ninja", ".q" = "Ninja",
":u" = "Operations", ".u" = "Operations",
":v" = "Service", ".v" = "Service",
@@ -39,7 +39,7 @@ var/list/department_radio_keys = list(
":X" = "Raider", ".X" = "Raider",
":B" = "Burglar", ".B" = "Burglar",
":J" = "Bluespace", ".J" = "Bluespace",
":Y" = "Ship", ".Y" = "Ship",
":Y" = "Hailing", ".Y" = "Hailing",
":Q" = "Ninja", ".Q" = "Ninja",
":U" = "Operations", ".U" = "Operations",
":V" = "Service", ".V" = "Service",
@@ -129,16 +129,17 @@ proc/get_radio_key_from_channel(var/channel)
/mob/living/proc/get_stutter_verbs()
return list("stammers", "stutters")
/mob/living/proc/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper)
/mob/living/proc/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper)
if(message_mode == "intercom")
for(var/obj/item/device/radio/intercom/I in view(1, null))
for(var/obj/item/device/radio/intercom/I in view(1, src))
used_radios += I
if(I.talk_into(src, message, verb, speaking))
successful_radio += I
I.talk_into(src, message, verb, speaking)
if(message_mode == "whisper" && !whisper)
whisper(message, speaking)
return TRUE
return 0
return FALSE
/mob/living/proc/handle_speech_sound()
var/list/returns[3]
@@ -250,34 +251,28 @@ proc/get_radio_key_from_channel(var/channel)
return say_signlang(message, pick(speaking.signlang_verb), speaking, speaking.sign_adv_length)
var/list/obj/item/used_radios = new
var/list/successful_radio = new // passes a list because standard vars don't work when passed
if(handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper, is_singing))
return 1
if(handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper, is_singing))
return TRUE
var/list/handle_v = handle_speech_sound()
var/sound/speech_sound = handle_v[1]
var/sound_vol = handle_v[2]
var/italics = handle_v[3]
//speaking into radios
if(length(used_radios))
italics = 1
message_range = 1
if(speaking)
message_range = speaking.get_talkinto_msg_range(message)
var/msg
if(!speaking || !(speaking.flags & NO_TALK_MSG))
msg = "<span class='notice'>\The [src] [length(successful_radio) ? "talks into" : "tries talking into"] \the [used_radios[1]]</span>."
for(var/mob/living/M in hearers(5, src) - src)
if(msg)
M.show_message(msg)
var/msg = SPAN_NOTICE("\The [src] talks into \the [used_radios[1]].")
for (var/mob/living/L in get_hearers_in_view(5, src) - src)
L.show_message(msg)
if(speech_sound)
sound_vol *= 0.5
var/list/listening = list()
var/list/listening_obj = list()
var/turf/T = get_turf(src)
if(whisper)
@@ -296,14 +291,21 @@ proc/get_radio_key_from_channel(var/channel)
italics = 1
sound_vol *= 0.5 //muffle the sound a bit, so it's like we're actually talking through contact
get_mobs_or_objs_in_view(T, message_range, listening, listening_obj, ghost_hearing)
listening = get_hearers_in_view(message_range, src)
if(client)
for (var/mob/player_mob in player_list)
if(!player_mob || player_mob.stat != DEAD || (player_mob in listening))
continue
if(player_mob.client?.prefs.toggles & CHAT_GHOSTEARS)
listening |= player_mob
var/list/hear_clients = list()
for(var/m in listening)
var/mob/M = m
for(var/mob/M in listening)
var/heard_say = M.hear_say(message, verb, speaking, alt_name, italics, src, speech_sound, sound_vol, get_font_size_modifier())
if(heard_say && M.client)
hear_clients += M.client
listening -= M
var/speech_bubble_test = say_test(message)
var/image/speech_bubble = image(get_talk_bubble(),src,"h[speech_bubble_test]")
@@ -313,7 +315,7 @@ proc/get_radio_key_from_channel(var/channel)
var/bypass_listen_obj = (speaking && (speaking.flags & PASSLISTENOBJ))
if(!bypass_listen_obj)
for(var/obj/O as anything in listening_obj)
for(var/obj/O as anything in listening)
if(O) //It's possible that it could be deleted in the meantime.
INVOKE_ASYNC(O, /obj/.proc/hear_talk, src, message, verb, speaking)
@@ -136,9 +136,9 @@
if(common_radio)
if(!is_component_functioning("radio"))
common_radio.on = FALSE
common_radio.set_on(FALSE)
else
common_radio.on = TRUE
common_radio.set_on(TRUE)
if(is_component_functioning("camera"))
blinded = FALSE
@@ -342,4 +342,4 @@
/mob/living/silicon/robot/fire_act()
if(!on_fire) // Silicons don't gain stacks from hotspots, but hotspots can ignite them.
IgniteMob()
IgniteMob()
+4 -4
View File
@@ -20,7 +20,7 @@
returns[4] = world.view
return returns
/mob/living/silicon/robot/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper)
/mob/living/silicon/robot/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper)
if(message_mode == "whisper" && !whisper)
whisper(message, speaking)
return TRUE
@@ -36,7 +36,7 @@
/mob/living/silicon/robot/drone/handle_message_mode()
return null
/mob/living/silicon/ai/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper)
/mob/living/silicon/ai/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper)
if(message_mode == "whisper" && !whisper)
whisper(message, speaking)
return TRUE
@@ -52,7 +52,7 @@
log_say("[key_name(src)] : [message]",ckey=key_name(src))
return ai_radio.talk_into(src, message, message_mode, verb, speaking)
/mob/living/silicon/pai/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper)
/mob/living/silicon/pai/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper)
if(message_mode)
if(message_mode == "whisper" && !whisper)
whisper(message, speaking)
@@ -120,7 +120,7 @@
var/turf/T = get_turf(H)
if(T)
var/list/hear = hear(7, T)
var/list/hear = get_hear(7, T)
var/list/hearturfs = list()
for(var/I in hear)
@@ -339,7 +339,7 @@
/mob/living/simple_animal/spiderbot/get_bullet_impact_effect_type(var/def_zone)
return BULLET_IMPACT_METAL
/mob/living/simple_animal/spiderbot/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, successful_radio, whisper)
/mob/living/simple_animal/spiderbot/handle_message_mode(message_mode, message, verb, speaking, used_radios, alt_name, whisper)
switch(message_mode)
if("whisper")
if(!whisper)
@@ -72,7 +72,7 @@
/mob/living/simple_animal/hostile/hivebotbeacon/proc/generate_warp_destinations()
destinations.Cut()
for(var/turf/simulated/floor/T in circlerange(src,10))
for(var/turf/simulated/floor/T in circle_range(src,10))
if(turf_clear(T))
destinations += T
var/area/A = get_area(src)
@@ -271,4 +271,4 @@
#undef RAPID
#undef BOMBER
#undef GUARDIAN
#undef HARVESTER
#undef HARVESTER
+3
View File
@@ -90,6 +90,9 @@
winset(src, null, "mainwindow.macro=macro hotkey_toggle.is-checked=false input.focus=true input.background-color=#D3B5B5")
MOB_STOP_THINKING(src)
clear_important_client_contents(client)
enable_client_mobs_in_contents(client)
update_client_color()
add_click_catcher()
+2
View File
@@ -6,6 +6,8 @@
disconnect_time = world.realtime
log_access("Logout: [key_name(src)]",ckey=key_name(src))
SSfeedback.update_status()
if(client)
clear_important_client_contents(client)
if(admin_datums[src.ckey])
var/datum/admins/A = admin_datums[src.ckey]
+10 -20
View File
@@ -79,7 +79,9 @@
if (!ckey && mob_thinks)
MOB_START_THINKING(src)
/mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
become_hearing_sensitive()
/mob/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
if(!client) return
@@ -196,29 +198,17 @@
// deaf_message (optional) is what deaf people will see.
// hearing_distance (optional) is the range, how many tiles away the message can be heard.
/mob/audible_message(var/message, var/deaf_message, var/hearing_distance, var/self_message, var/ghost_hearing = GHOSTS_ALL_HEAR)
if(!hearing_distance)
hearing_distance = world.view
var/range = world.view
if(hearing_distance)
range = hearing_distance
var/list/hearers = get_hearers_in_view(hearing_distance, src)
var/turf/T = get_turf(src)
var/list/mobs = list()
var/list/objs = list()
get_mobs_or_objs_in_view(T, range, mobs, objs, ghost_hearing)
for(var/m in mobs)
var/mob/M = m
if(self_message && M==src)
M.show_message("[get_accent_icon(null, M)] [self_message]", 2, deaf_message, 1)
for (var/atom/movable/AM as anything in hearers)
if(self_message && AM == src)
AM.show_message("[get_accent_icon(null, src)] [self_message]", 2, deaf_message, 1)
continue
M.show_message("[get_accent_icon(null, M)] [message]", 2, deaf_message,1)
for(var/o in objs)
var/obj/O = o
O.show_message("[get_accent_icon(null, src)] [message]", 2, deaf_message, 1)
AM.show_message("[get_accent_icon(null, src)] [message]", 2, deaf_message, 1)
/mob/proc/findname(msg)
for(var/mob/M in mob_list)