mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
Scope various unscoped locate() calls (#42195)
* Scope locate calls which are immediately checked against a list * Remove silly use of locate from bible Topic * Scope various locate calls (needs testing) * More WIP * Buff up lightswitches while we're here * Tidy record browsing code * Scope a few more locates These have caused problems in the past (#41917, #39303). Continues #29349. Also cleans up lightswitch code while I was already touching it. I recommend a testmerge.
This commit is contained in:
@@ -126,7 +126,7 @@
|
||||
log_admin("[key_name(usr)] reset the thunderdome to default with delete_mobs==[delete_mobs].", 1)
|
||||
message_admins("<span class='adminnotice'>[key_name_admin(usr)] reset the thunderdome to default with delete_mobs==[delete_mobs].</span>")
|
||||
|
||||
var/area/thunderdome = locate(/area/tdome/arena)
|
||||
var/area/thunderdome = GLOB.areas_by_type[/area/tdome/arena]
|
||||
if(delete_mobs == "Yes")
|
||||
for(var/mob/living/mob in thunderdome)
|
||||
qdel(mob) //Clear mobs
|
||||
@@ -134,7 +134,7 @@
|
||||
if(!istype(obj, /obj/machinery/camera))
|
||||
qdel(obj) //Clear objects
|
||||
|
||||
var/area/template = locate(/area/tdome/arena_source)
|
||||
var/area/template = GLOB.areas_by_type[/area/tdome/arena_source]
|
||||
template.copy_contents_to(thunderdome)
|
||||
|
||||
if("clear_virus")
|
||||
|
||||
@@ -367,7 +367,7 @@ the new instance inside the host to be updated to the template's stats.
|
||||
set_following(L)
|
||||
|
||||
if(href_list["buy_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["buy_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["buy_ability"]) in unpurchased_abilities
|
||||
if(!istype(A))
|
||||
return
|
||||
if(A.CanBuy(src))
|
||||
@@ -375,7 +375,7 @@ the new instance inside the host to be updated to the template's stats.
|
||||
adaptation_menu()
|
||||
|
||||
if(href_list["refund_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["refund_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["refund_ability"]) in purchased_abilities
|
||||
if(!istype(A))
|
||||
return
|
||||
if(A.CanRefund(src))
|
||||
@@ -383,7 +383,7 @@ the new instance inside the host to be updated to the template's stats.
|
||||
adaptation_menu()
|
||||
|
||||
if(href_list["examine_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["examine_ability"])
|
||||
var/datum/disease_ability/A = locate(href_list["examine_ability"]) in GLOB.disease_ability_singletons
|
||||
if(!istype(A))
|
||||
return
|
||||
examining_ability = A
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
print_paper()
|
||||
|
||||
if("Claim")
|
||||
var/datum/bounty/B = locate(href_list["d_rec"])
|
||||
if(B in GLOB.bounties_list)
|
||||
var/datum/bounty/B = locate(href_list["d_rec"]) in GLOB.bounties_list
|
||||
if(B)
|
||||
B.claim()
|
||||
|
||||
if(href_list["refresh"])
|
||||
|
||||
@@ -333,7 +333,7 @@
|
||||
return
|
||||
switch(action)
|
||||
if("make")
|
||||
var/datum/crafting_recipe/TR = locate(params["recipe"])
|
||||
var/datum/crafting_recipe/TR = locate(params["recipe"]) in GLOB.crafting_recipes
|
||||
busy = TRUE
|
||||
ui_interact(usr) //explicit call to show the busy display
|
||||
var/fail_msg = construct_item(usr, TR)
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
flick(icon_deny, src)
|
||||
if(href_list["purchase"])
|
||||
if(istype(inserted_id))
|
||||
var/datum/data/mining_equipment/prize = locate(href_list["purchase"])
|
||||
var/datum/data/mining_equipment/prize = locate(href_list["purchase"]) in prize_list
|
||||
if (!prize || !(prize in prize_list))
|
||||
to_chat(usr, "<span class='warning'>Error: Invalid choice!</span>")
|
||||
flick(icon_deny, src)
|
||||
|
||||
@@ -330,7 +330,8 @@
|
||||
return
|
||||
switch(action)
|
||||
if("swap")
|
||||
var/mob/living/carbon/human/selected = locate(params["ref"])
|
||||
var/datum/species/jelly/slime/SS = H.dna.species
|
||||
var/mob/living/carbon/human/selected = locate(params["ref"]) in SS.bodies
|
||||
if(!can_swap(selected))
|
||||
return
|
||||
SStgui.close_uis(src)
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
unset_machine()
|
||||
src << browse(null, t1)
|
||||
if (href_list["switchcamera"])
|
||||
switchCamera(locate(href_list["switchcamera"])) in GLOB.cameranet.cameras
|
||||
switchCamera(locate(href_list["switchcamera"]) in GLOB.cameranet.cameras)
|
||||
if (href_list["showalerts"])
|
||||
ai_alerts()
|
||||
#ifdef AI_VOX
|
||||
@@ -362,7 +362,7 @@
|
||||
src << browse(last_paper_seen, "window=show_paper")
|
||||
//Carn: holopad requests
|
||||
if(href_list["jumptoholopad"])
|
||||
var/obj/machinery/holopad/H = locate(href_list["jumptoholopad"])
|
||||
var/obj/machinery/holopad/H = locate(href_list["jumptoholopad"]) in GLOB.machines
|
||||
if(H)
|
||||
H.attack_ai(src) //may as well recycle
|
||||
else
|
||||
@@ -404,7 +404,7 @@
|
||||
return
|
||||
|
||||
if (href_list["ai_take_control"]) //Mech domination
|
||||
var/obj/mecha/M = locate(href_list["ai_take_control"])
|
||||
var/obj/mecha/M = locate(href_list["ai_take_control"]) in GLOB.mechas_list
|
||||
if (!M)
|
||||
return
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
if(silent)
|
||||
return alert("Communications circuits remain uninitialized.")
|
||||
|
||||
var/target = locate(href_list["target"])
|
||||
var/target = locate(href_list["target"]) in GLOB.PDAs
|
||||
pda.create_message(src, target)
|
||||
|
||||
// Accessing medical records
|
||||
|
||||
@@ -94,14 +94,14 @@
|
||||
to_chat(usr, "<span class='notice'>You slot [W] into [src].</span>")
|
||||
|
||||
if(href_list["write"])
|
||||
var/obj/item/P = locate(href_list["write"])
|
||||
if(istype(P) && P.loc == src)
|
||||
var/obj/item/P = locate(href_list["write"]) in src
|
||||
if(istype(P))
|
||||
if(usr.get_active_held_item())
|
||||
P.attackby(usr.get_active_held_item(), usr)
|
||||
|
||||
if(href_list["remove"])
|
||||
var/obj/item/P = locate(href_list["remove"])
|
||||
if(istype(P) && P.loc == src)
|
||||
var/obj/item/P = locate(href_list["remove"]) in src
|
||||
if(istype(P))
|
||||
P.forceMove(usr.loc)
|
||||
usr.put_in_hands(P)
|
||||
if(P == toppaper)
|
||||
@@ -113,13 +113,13 @@
|
||||
toppaper = null
|
||||
|
||||
if(href_list["read"])
|
||||
var/obj/item/paper/P = locate(href_list["read"])
|
||||
if(istype(P) && P.loc == src)
|
||||
var/obj/item/paper/P = locate(href_list["read"]) in src
|
||||
if(istype(P))
|
||||
usr.examinate(P)
|
||||
|
||||
if(href_list["top"])
|
||||
var/obj/item/P = locate(href_list["top"])
|
||||
if(istype(P) && P.loc == src)
|
||||
var/obj/item/P = locate(href_list["top"]) in src
|
||||
if(istype(P))
|
||||
toppaper = P
|
||||
to_chat(usr, "<span class='notice'>You move [P.name] to the top.</span>")
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@
|
||||
if(href_list["retrieve"])
|
||||
usr << browse("", "window=filingcabinet") // Close the menu
|
||||
|
||||
var/obj/item/P = locate(href_list["retrieve"])//contents[retrieveindex]
|
||||
if(istype(P) && P.loc == src && in_range(src, usr))
|
||||
var/obj/item/P = locate(href_list["retrieve"]) in src //contents[retrieveindex]
|
||||
if(istype(P) && in_range(src, usr))
|
||||
usr.put_in_hands(P)
|
||||
updateUsrDialog()
|
||||
icon_state = "[initial(icon_state)]-open"
|
||||
|
||||
@@ -67,14 +67,14 @@
|
||||
if(usr.contents.Find(src))
|
||||
|
||||
if(href_list["remove"])
|
||||
var/obj/item/I = locate(href_list["remove"])
|
||||
if(istype(I) && I.loc == src)
|
||||
var/obj/item/I = locate(href_list["remove"]) in src
|
||||
if(istype(I))
|
||||
I.forceMove(usr.loc)
|
||||
usr.put_in_hands(I)
|
||||
|
||||
if(href_list["read"])
|
||||
var/obj/item/I = locate(href_list["read"])
|
||||
if(istype(I) && I.loc == src)
|
||||
var/obj/item/I = locate(href_list["read"]) in src
|
||||
if(istype(I))
|
||||
usr.examinate(I)
|
||||
|
||||
//Update everything
|
||||
|
||||
Reference in New Issue
Block a user