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:
Tad Hardesty
2019-01-06 20:39:27 +13:00
committed by oranges
parent 380bbad300
commit 3b2c0e27f7
22 changed files with 78 additions and 87 deletions
+1 -1
View File
@@ -522,7 +522,7 @@ GLOBAL_LIST_EMPTY(PDAs)
U << browse(null, "window=pda")
return
if("Message")
create_message(U, locate(href_list["target"]))
create_message(U, locate(href_list["target"]) in GLOB.PDAs)
if("MessageAll")
send_to_all(U)
+3 -6
View File
@@ -652,7 +652,7 @@ Code:
switch(href_list["op"])
if("control")
active_bot = locate(href_list["bot"])
active_bot = locate(href_list["bot"]) in GLOB.bots_list
if("botlist")
active_bot = null
@@ -671,10 +671,6 @@ Code:
/obj/item/cartridge/proc/bot_control()
var/mob/living/simple_animal/bot/Bot
if(active_bot)
menu += "<B>[active_bot]</B><BR> Status: (<A href='byond://?src=[REF(src)];op=control;bot=[REF(active_bot)]'>[PDAIMG(refresh)]<i>refresh</i></A>)<BR>"
menu += "Model: [active_bot.model]<BR>"
@@ -718,7 +714,8 @@ Code:
var/turf/current_turf = get_turf(src)
var/zlevel = current_turf.z
var/botcount = 0
for(Bot in GLOB.alive_mob_list) //Git da botz
for(var/B in GLOB.bots_list) //Git da botz
var/mob/living/simple_animal/bot/Bot = B
if(!Bot.on || Bot.z != zlevel || Bot.remote_disabled || !(bot_access_flags & Bot.bot_type)) //Only non-emagged bots on the same Z-level are detected!
continue //Also, the PDA must have access to the bot type.
menu += "<A href='byond://?src=[REF(src)];op=control;bot=[REF(Bot)]'><b>[Bot.name]</b> ([Bot.get_mode()])<BR>"
@@ -14,7 +14,7 @@
return " (<a href='byond://?src=[REF(loc)];choice=cart;special=virus;target=[REF(target)]'>*Send Virus*</a>)"
/obj/item/cartridge/virus/special(mob/living/user, list/params)
var/obj/item/pda/P = locate(params["target"])//Leaving it alone in case it may do something useful, I guess.
var/obj/item/pda/P = locate(params["target"]) in GLOB.PDAs //Leaving it alone in case it may do something useful, I guess.
send_virus(P,user)
/obj/item/cartridge/virus/clown
+5 -6
View File
@@ -69,17 +69,16 @@ GLOBAL_LIST_INIT(bibleitemstates, list("bible", "koran", "scrapbook", "bible", "
if(href_list["seticon"] && SSreligion && !SSreligion.bible_icon_state)
var/iconi = text2num(href_list["seticon"])
var/biblename = GLOB.biblenames[iconi]
var/obj/item/storage/book/bible/B = locate(href_list["src"])
B.icon_state = GLOB.biblestates[iconi]
B.item_state = GLOB.bibleitemstates[iconi]
icon_state = GLOB.biblestates[iconi]
item_state = GLOB.bibleitemstates[iconi]
if(B.icon_state == "honk1" || B.icon_state == "honk2")
if(icon_state == "honk1" || icon_state == "honk2")
var/mob/living/carbon/human/H = usr
H.dna.add_mutation(CLOWNMUT)
H.equip_to_slot_or_del(new /obj/item/clothing/mask/gas/clown_hat(H), SLOT_WEAR_MASK)
SSreligion.bible_icon_state = B.icon_state
SSreligion.bible_item_state = B.item_state
SSreligion.bible_icon_state = icon_state
SSreligion.bible_item_state = item_state
SSblackbox.record_feedback("text", "religion_book", 1, "[biblename]")
usr << browse(null, "window=editicon")