for(var/bad_code in world)

Removes a very large amount of world loops.
Adds a macro to painlessly generate a global list, and the needed code to modify the list when an object is made or deleted automatically.
Cleans up some commented out code.
This commit is contained in:
Neerti
2018-04-29 17:55:04 -04:00
parent 81c19c62a3
commit be73b8c36a
103 changed files with 274 additions and 403 deletions
@@ -6,5 +6,5 @@
if(!.)
return
for(var/obj/machinery/light/L in world)
for(var/obj/machinery/light/L in machines)
L.fix()
@@ -6,5 +6,5 @@
if(!.)
return
for(var/obj/item/clothing/O in world)
for(var/obj/item/clothing/O in all_clothing)
qdel(O)
@@ -6,5 +6,5 @@
if(!.)
return
for(var/obj/item/clothing/under/O in world)
for(var/obj/item/clothing/under/O in all_clothing)
qdel(O)
@@ -16,7 +16,7 @@
return
gravity_is_on = !gravity_is_on
for(var/area/A in world)
for(var/area/A in all_areas)
A.gravitychange(gravity_is_on,A)
feedback_inc("admin_secrets_fun_used",1)
+11 -11
View File
@@ -85,57 +85,57 @@
else
var/f2 = text2path(f)
if(text_starts_with(f, "/mob"))
for(var/mob/m in world)
for(var/mob/m in mob_list)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/turf/space"))
for(var/turf/space/m in world)
for(var/turf/space/m in turfs)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/turf/simulated"))
for(var/turf/simulated/m in world)
for(var/turf/simulated/m in turfs)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/turf/unsimulated"))
for(var/turf/unsimulated/m in world)
for(var/turf/unsimulated/m in turfs)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/turf"))
for(var/turf/m in world)
for(var/turf/m in turfs)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/area"))
for(var/area/m in world)
for(var/area/m in all_areas)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/obj/item"))
for(var/obj/item/m in world)
for(var/obj/item/m in all_items)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/obj/machinery"))
for(var/obj/machinery/m in world)
for(var/obj/machinery/m in machines)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/obj"))
for(var/obj/m in world)
for(var/obj/m in all_objs)
if(istype(m, f2))
from_objs += m
else if(text_starts_with(f, "/atom"))
for(var/atom/m in world)
for(var/atom/m in all_atoms)
if(istype(m, f2))
from_objs += m
/*
else
for(var/datum/m in world)
for(var/datum/m in nope)
if(istype(m, f2))
from_objs += m
*/
+1 -1
View File
@@ -21,7 +21,7 @@
else
alert("Admin jumping disabled")
/client/proc/jumptoturf(var/turf/T in world)
/client/proc/jumptoturf(var/turf/T in turfs)
set name = "Jump to Turf"
set category = "Admin"
if(!check_rights(R_ADMIN|R_MOD|R_DEBUG))
+4 -4
View File
@@ -12,23 +12,23 @@
usr << "Checking for disconnected pipes..."
//all plumbing - yes, some things might get stated twice, doesn't matter.
for (var/obj/machinery/atmospherics/plumbing in world)
for (var/obj/machinery/atmospherics/plumbing in machines)
if (plumbing.nodealert)
usr << "Unconnected [plumbing.name] located at [plumbing.x],[plumbing.y],[plumbing.z] ([get_area(plumbing.loc)])"
//Manifolds
for (var/obj/machinery/atmospherics/pipe/manifold/pipe in world)
for (var/obj/machinery/atmospherics/pipe/manifold/pipe in machines)
if (!pipe.node1 || !pipe.node2 || !pipe.node3)
usr << "Unconnected [pipe.name] located at [pipe.x],[pipe.y],[pipe.z] ([get_area(pipe.loc)])"
//Pipes
for (var/obj/machinery/atmospherics/pipe/simple/pipe in world)
for (var/obj/machinery/atmospherics/pipe/simple/pipe in machines)
if (!pipe.node1 || !pipe.node2)
usr << "Unconnected [pipe.name] located at [pipe.x],[pipe.y],[pipe.z] ([get_area(pipe.loc)])"
usr << "Checking for overlapping pipes..."
next_turf:
for(var/turf/T in world)
for(var/turf/T in turfs)
for(var/dir in cardinal)
var/list/connect_types = list(1 = 0, 2 = 0, 3 = 0)
for(var/obj/machinery/atmospherics/pipe in T)
+17 -107
View File
@@ -173,96 +173,6 @@
else
alert("Invalid mob")
/*
/client/proc/cmd_admin_monkeyize(var/mob/M in world)
set category = "Fun"
set name = "Make Monkey"
if(!ticker)
alert("Wait until the game starts")
return
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/target = M
log_admin("[key_name(src)] is attempting to monkeyize [M.key].")
spawn(10)
target.monkeyize()
else
alert("Invalid mob")
/client/proc/cmd_admin_changelinginize(var/mob/M in world)
set category = "Fun"
set name = "Make Changeling"
if(!ticker)
alert("Wait until the game starts")
return
if(istype(M, /mob/living/carbon/human))
log_admin("[key_name(src)] has made [M.key] a changeling.")
spawn(10)
M.absorbed_dna[M.real_name] = M.dna.Clone()
M.make_changeling()
if(M.mind)
M.mind.special_role = "Changeling"
else
alert("Invalid mob")
*/
/*
/client/proc/cmd_admin_abominize(var/mob/M in world)
set category = null
set name = "Make Abomination"
usr << "Ruby Mode disabled. Command aborted."
return
if(!ticker)
alert("Wait until the game starts.")
return
if(istype(M, /mob/living/carbon/human))
log_admin("[key_name(src)] has made [M.key] an abomination.")
// spawn(10)
// M.make_abomination()
*/
/*
/client/proc/make_cultist(var/mob/M in world) // -- TLE, modified by Urist
set category = "Fun"
set name = "Make Cultist"
set desc = "Makes target a cultist"
if(!cultwords["travel"])
runerandom()
if(M)
if(M.mind in ticker.mode.cult)
return
else
if(alert("Spawn that person a tome?",,"Yes","No")=="Yes")
M << "<font color='red'>You catch a glimpse of the Realm of Nar-Sie, The Geometer of Blood. You now see how flimsy the world is, you see that it should be open to the knowledge of Nar-Sie. A tome, a message from your new master, appears on the ground.</font>"
new /obj/item/weapon/book/tome(M.loc)
else
M << "<font color='red'>You catch a glimpse of the Realm of Nar-Sie, The Geometer of Blood. You now see how flimsy the world is, you see that it should be open to the knowledge of Nar-Sie.</font>"
var/glimpse=pick("1","2","3","4","5","6","7","8")
switch(glimpse)
if("1")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["travel"]] is travel...</font>"
if("2")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["blood"]] is blood...</font>"
if("3")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["join"]] is join...</font>"
if("4")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["hell"]] is Hell...</font>"
if("5")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["destroy"]] is destroy...</font>"
if("6")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["technology"]] is technology...</font>"
if("7")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["self"]] is self...</font>"
if("8")
M << "<font color='red'>You remembered one thing from the glimpse... [cultwords["see"]] is see...</font>"
if(M.mind)
M.mind.special_role = "Cultist"
ticker.mode.cult += M.mind
src << "Made [M] a cultist."
*/
//TODO: merge the vievars version into this or something maybe mayhaps
/client/proc/cmd_debug_del_all()
@@ -273,7 +183,7 @@
var/blocked = list(/obj, /mob, /mob/living, /mob/living/carbon, /mob/living/carbon/human, /mob/observer/dead, /mob/living/silicon, /mob/living/silicon/robot, /mob/living/silicon/ai)
var/hsbitem = input(usr, "Choose an object to delete.", "Delete:") as null|anything in typesof(/obj) + typesof(/mob) - blocked
if(hsbitem)
for(var/atom/O in world)
for(var/atom/O in all_atoms)
if(istype(O, hsbitem))
qdel(O)
log_admin("[key_name(src)] has deleted all instances of [hsbitem].")
@@ -431,41 +341,41 @@
var/list/areas_with_intercom = list()
var/list/areas_with_camera = list()
for(var/area/A in world)
for(var/area/A in all_areas)
if(!(A.type in areas_all))
areas_all.Add(A.type)
for(var/obj/machinery/power/apc/APC in world)
for(var/obj/machinery/power/apc/APC in machines)
var/area/A = get_area(APC)
if(!(A.type in areas_with_APC))
areas_with_APC.Add(A.type)
for(var/obj/machinery/alarm/alarm in world)
for(var/obj/machinery/alarm/alarm in machines)
var/area/A = get_area(alarm)
if(!(A.type in areas_with_air_alarm))
areas_with_air_alarm.Add(A.type)
for(var/obj/machinery/requests_console/RC in world)
for(var/obj/machinery/requests_console/RC in machines)
var/area/A = get_area(RC)
if(!(A.type in areas_with_RC))
areas_with_RC.Add(A.type)
for(var/obj/machinery/light/L in world)
for(var/obj/machinery/light/L in machines)
var/area/A = get_area(L)
if(!(A.type in areas_with_light))
areas_with_light.Add(A.type)
for(var/obj/machinery/light_switch/LS in world)
for(var/obj/machinery/light_switch/LS in machines)
var/area/A = get_area(LS)
if(!(A.type in areas_with_LS))
areas_with_LS.Add(A.type)
for(var/obj/item/device/radio/intercom/I in world)
for(var/obj/item/device/radio/intercom/I in machines)
var/area/A = get_area(I)
if(!(A.type in areas_with_intercom))
areas_with_intercom.Add(A.type)
for(var/obj/machinery/camera/C in world)
for(var/obj/machinery/camera/C in machines)
var/area/A = get_area(C)
if(!(A.type in areas_with_camera))
areas_with_camera.Add(A.type)
@@ -546,31 +456,31 @@
if(alert("Are you sure? This will start up the engine. Should only be used during debug!",,"Yes","No") != "Yes")
return
for(var/obj/machinery/power/emitter/E in world)
for(var/obj/machinery/power/emitter/E in machines)
if(istype(get_area(E), /area/space))
E.anchored = TRUE
E.state = 2
E.connect_to_network()
E.active = TRUE
for(var/obj/machinery/field_generator/F in world)
for(var/obj/machinery/field_generator/F in machines)
if(istype(get_area(F), /area/space))
F.Varedit_start = 1
for(var/obj/machinery/power/grounding_rod/GR in world)
for(var/obj/machinery/power/grounding_rod/GR in machines)
GR.anchored = TRUE
GR.update_icon()
for(var/obj/machinery/power/tesla_coil/TC in world)
for(var/obj/machinery/power/tesla_coil/TC in machines)
TC.anchored = TRUE
TC.update_icon()
for(var/obj/structure/particle_accelerator/PA in world)
for(var/obj/structure/particle_accelerator/PA in machines)
PA.anchored = TRUE
PA.construction_state = 3
PA.update_icon()
for(var/obj/machinery/particle_accelerator/PA in world)
for(var/obj/machinery/particle_accelerator/PA in machines)
PA.anchored = TRUE
PA.construction_state = 3
PA.update_icon()
for(var/obj/machinery/power/rad_collector/Rad in world)
for(var/obj/machinery/power/rad_collector/Rad in machines)
if(Rad.anchored)
if(!Rad.P)
var/obj/item/weapon/tank/phoron/Phoron = new/obj/item/weapon/tank/phoron(Rad)
@@ -597,7 +507,7 @@
var/found_the_pump = 0
var/obj/machinery/power/supermatter/SM
for(var/obj/machinery/M in world)
for(var/obj/machinery/M in machines)
if(!M)
continue
if(!M.loc)
+1 -1
View File
@@ -48,7 +48,7 @@
var/largest_click_time = 0
var/mob/largest_move_mob = null
var/mob/largest_click_mob = null
for(var/mob/M in world)
for(var/mob/M in mob_list)
if(!M.client)
continue
if(M.next_move >= largest_move_time)
+1 -1
View File
@@ -38,7 +38,7 @@
unsorted_overlays |= gas_data.tile_overlay[id]
for(var/turf/simulated/T in world)
for(var/turf/simulated/T in turfs)
T.air = null
T.overlays.Remove(unsorted_overlays)
T.zone = null
+7 -5
View File
@@ -22,6 +22,8 @@
var/camera_range_display_status = 0
var/intercom_range_display_status = 0
GLOBAL_LIST_BOILERPLATE(all_debugging_effects, /obj/effect/debugging)
/obj/effect/debugging/camera_range
icon = 'icons/480x480.dmi'
icon_state = "25percent"
@@ -54,7 +56,7 @@ var/intercom_range_display_status = 0
for(var/obj/effect/debugging/camera_range/C in world)
for(var/obj/effect/debugging/camera_range/C in all_debugging_effects)
qdel(C)
if(camera_range_display_status)
@@ -113,11 +115,11 @@ var/intercom_range_display_status = 0
else
intercom_range_display_status = 1
for(var/obj/effect/debugging/marker/M in world)
for(var/obj/effect/debugging/marker/M in all_debugging_effects)
qdel(M)
if(intercom_range_display_status)
for(var/obj/item/device/radio/intercom/I in world)
for(var/obj/item/device/radio/intercom/I in machines)
for(var/turf/T in orange(7,I))
var/obj/effect/debugging/marker/F = new/obj/effect/debugging/marker(T)
if (!(F in view(7,I.loc)))
@@ -294,7 +296,7 @@ var/list/debug_verbs = list (
var/list/atom/atom_list = list()
for(var/atom/A in world)
for(var/atom/A in all_atoms)
if(istype(A,type_path))
var/atom/B = A
while(!(isturf(B.loc)))
@@ -330,7 +332,7 @@ var/list/debug_verbs = list (
var/count = 0
for(var/atom/A in world)
for(var/atom/A in all_atoms)
if(istype(A,type_path))
count++
/*
+24 -24
View File
@@ -139,12 +139,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
@@ -155,12 +155,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
@@ -179,12 +179,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
@@ -194,12 +194,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
@@ -223,7 +223,7 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
if(variable=="light_range")
A.set_light(new_value)
@@ -231,7 +231,7 @@
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
if(variable=="light_range")
A.set_light(new_value)
@@ -248,7 +248,7 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
if(variable=="light_range")
A.set_light(new_value)
@@ -256,7 +256,7 @@
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
if(variable=="light_range")
A.set_light(new_value)
@@ -275,12 +275,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
@@ -290,12 +290,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
@@ -311,12 +311,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O.type, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O.type, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else
@@ -326,12 +326,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O.type, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O.type, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
@@ -346,12 +346,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if ( istype(A , O.type) )
A.vars[variable] = O.vars[variable]
@@ -362,12 +362,12 @@
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
for(var/obj/A in all_objs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
for(var/turf/A in turfs)
if (A.type == O.type)
A.vars[variable] = O.vars[variable]
+5 -5
View File
@@ -54,12 +54,12 @@ var/list/sounds_cache = list()
set name = "Cuban Pete Time"
message_admins("[key_name_admin(usr)] has declared Cuban Pete Time!", 1)
for(var/mob/M in world)
for(var/mob/M in player_list)
if(M.client)
if(M.client.midis)
M << 'cubanpetetime.ogg'
for(var/mob/living/carbon/human/CP in world)
for(var/mob/living/carbon/human/CP in human_mob_list)
if(CP.real_name=="Cuban Pete" && CP.key!="Rosham")
CP << "Your body can't contain the rhumba beat"
CP.gib()
@@ -70,7 +70,7 @@ var/list/sounds_cache = list()
set name = "Banana Phone"
message_admins("[key_name_admin(usr)] has activated Banana Phone!", 1)
for(var/mob/M in world)
for(var/mob/M in player_list)
if(M.client)
if(M.client.midis)
M << 'bananaphone.ogg'
@@ -81,7 +81,7 @@ client/proc/space_asshole()
set name = "Space Asshole"
message_admins("[key_name_admin(usr)] has played the Space Asshole Hymn.", 1)
for(var/mob/M in world)
for(var/mob/M in player_list)
if(M.client)
if(M.client.midis)
M << 'sound/music/space_asshole.ogg'
@@ -92,7 +92,7 @@ client/proc/honk_theme()
set name = "Honk"
message_admins("[key_name_admin(usr)] has creeped everyone out with Blackest Honks.", 1)
for(var/mob/M in world)
for(var/mob/M in player_list)
if(M.client)
if(M.client.midis)
M << 'honk_theme.ogg'*/
+1 -1
View File
@@ -704,7 +704,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
switch(alert("How would you like to ban someone today?", "Manual Ban", "Key List", "Enter Manually", "Cancel"))
if("Key List")
var/list/keys = list()
for(var/mob/M in world)
for(var/mob/M in player_list)
keys += M.client
var/selection = input("Please, select a player!", "Admin Jumping", null, null) as null|anything in keys
if(!selection)
+2 -2
View File
@@ -184,7 +184,7 @@
switch(action_type)
if("Strict type")
var/i = 0
for(var/obj/Obj in world)
for(var/obj/Obj in all_objs)
if(Obj.type == O_type)
i++
qdel(Obj)
@@ -195,7 +195,7 @@
message_admins("<span class='notice'>[key_name(usr)] deleted all objects of type [O_type] ([i] objects deleted)</span>")
if("Type and subtypes")
var/i = 0
for(var/obj/Obj in world)
for(var/obj/Obj in all_objs)
if(istype(Obj,O_type))
i++
qdel(Obj)