From 71cf58d8a52a19b06253f8f3e1f5dd905089657e Mon Sep 17 00:00:00 2001 From: warriorstar-orion <59303604+warriorstar-orion@users.noreply.github.com> Date: Mon, 10 Oct 2022 16:20:55 -0400 Subject: [PATCH] Only give bots HUDs when player-controlled. (#19198) * Only give bots HUDs when player-controlled. * Clean up data_hud regardless of whether or not a player is present. * No need to keep around this ref. --- .../mob/living/simple_animal/bot/bot.dm | 19 +++++++++++++++---- .../mob/living/simple_animal/bot/ed209bot.dm | 6 ------ .../mob/living/simple_animal/bot/medbot.dm | 4 ---- .../mob/living/simple_animal/bot/secbot.dm | 5 ----- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 3e2838ffa83..f3a92ab8ea3 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -77,7 +77,8 @@ var/control_freq = BOT_FREQ // bot control frequency var/bot_filter // The radio filter the bot uses to identify itself on the network. var/bot_type = 0 //The type of bot it is, for radio control. - var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC //The type of data HUD the bot uses. Diagnostic by default. + /// The type of data HUD the bot uses. Diagnostic by default. + var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC //This holds text for what the bot is mode doing, reported on the remote bot control interface. var/list/mode_name = list("In Pursuit","Preparing to Arrest", "Arresting", \ "Beginning Patrol", "Patrolling", "Summoned by PDA", \ @@ -163,15 +164,14 @@ prepare_huds() for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds) diag_hud.add_to_hud(src) - diag_hud.add_hud_to(src) permanent_huds |= diag_hud + diag_hud_set_bothealth() diag_hud_set_botstat() diag_hud_set_botmode() - // give us the hud too! + if(path_hud) path_hud.add_to_hud(src) - path_hud.add_hud_to(src) /mob/living/simple_animal/bot/med_hud_set_health() @@ -187,6 +187,11 @@ if(path_hud) QDEL_NULL(path_hud) path_hud = null + + var/datum/atom_hud/data_hud = GLOB.huds[data_hud_type] + if(data_hud) + data_hud.remove_hud_from(src) + GLOB.bots_list -= src QDEL_NULL(Radio) QDEL_NULL(access_card) @@ -957,11 +962,17 @@ Pass a positive integer as an argument to override a bot's default speed. /mob/living/simple_animal/bot/Login() . = ..() access_card.access += player_access + + var/datum/atom_hud/data_hud = GLOB.huds[data_hud_type] + if(data_hud) + data_hud.add_hud_to(src) + diag_hud_set_botmode() show_laws() /mob/living/simple_animal/bot/Logout() . = ..() + bot_reset() /mob/living/simple_animal/bot/revive(full_heal = 0, admin_revive = 0) diff --git a/code/modules/mob/living/simple_animal/bot/ed209bot.dm b/code/modules/mob/living/simple_animal/bot/ed209bot.dm index a5ec0ebde94..8e796baae79 100644 --- a/code/modules/mob/living/simple_animal/bot/ed209bot.dm +++ b/code/modules/mob/living/simple_animal/bot/ed209bot.dm @@ -70,12 +70,6 @@ else if (lasercolor == "r") name = pick("RED RAMPAGE","RED ROVER","RED KILLDEATH MURDERBOT") - //SECHUD - var/datum/atom_hud/secsensor = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] - secsensor.add_hud_to(src) - permanent_huds |= secsensor - - /mob/living/simple_animal/bot/ed209/proc/setup_access() if(access_card) var/datum/job/detective/J = new/datum/job/detective diff --git a/code/modules/mob/living/simple_animal/bot/medbot.dm b/code/modules/mob/living/simple_animal/bot/medbot.dm index bb29897db7f..a608a1334e0 100644 --- a/code/modules/mob/living/simple_animal/bot/medbot.dm +++ b/code/modules/mob/living/simple_animal/bot/medbot.dm @@ -125,10 +125,6 @@ prev_access = access_card.access qdel(J) - var/datum/atom_hud/medsensor = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - medsensor.add_hud_to(src) - permanent_huds |= medsensor - if(new_skin) skin = new_skin update_icon() diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index 0a54153248d..acdf5c02366 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -93,11 +93,6 @@ access_card.access += J.get_access() prev_access = access_card.access - //SECHUD - var/datum/atom_hud/secsensor = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] - secsensor.add_hud_to(src) - permanent_huds |= secsensor - /mob/living/simple_animal/bot/secbot/turn_on() ..() icon_state = "[base_icon][on]"