Remove a whole bunch of in world loops and rework machinery global lists (#3053)

Removes a whole bunch of in world loops.
Reworks SSmachinery to hold two lists: all_machines and processing_machines. all_machines contains all machines 5ever. All of them. Literally. Forever. And ever. processing_machines only contains machines that process with the SSmachinery controller.

I checked most types at runtime on the live server to see whether they're in processing_machines or in all_machines, and did debug to ensure that most machinery ends up and stays in all_machines.

Includes a basic UT to make sure all mapped in machinery types remain within the all_machines list post-init.
This commit is contained in:
skull132
2017-07-16 20:32:33 +03:00
committed by GitHub
parent 4645af8dcb
commit 0fc67f2cb9
70 changed files with 237 additions and 176 deletions
@@ -6,5 +6,5 @@
if(!.)
return
for(var/obj/machinery/light/L in machines)
for(var/obj/machinery/light/L in SSmachinery.all_machines)
L.fix()
+1 -1
View File
@@ -28,7 +28,7 @@
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)
+2 -2
View File
@@ -423,7 +423,7 @@ var/global/movement_disabled_exception //This is the client that calls the proc,
set category = "Mapping"
set name = "Find Bad Doors"
for(var/obj/machinery/door/airlock/A in machines)
for(var/obj/machinery/door/airlock/A in world)
var/turf/T = get_turf(A)
if(istype(T, /turf/space) || istype(T, /turf/simulated/floor/asteroid) || isopenturf(T) || T.density)
usr << "Airlock [A] with bad turf at ([A.x],[A.y],[A.z]) in [T.loc]."
@@ -432,7 +432,7 @@ var/global/movement_disabled_exception //This is the client that calls the proc,
set category = "Mapping"
set name = "Find Bad Fire Doors"
for(var/obj/machinery/door/firedoor/F in machines)
for(var/obj/machinery/door/firedoor/F in world)
var/turf/T = get_turf(F)
var/firelock_increment = 0
for(var/obj/machinery/door/firedoor/FD in T)
+1 -1
View File
@@ -12,7 +12,7 @@
/datum/event/brand_intelligence/start()
for(var/obj/machinery/vending/V in machines)
for(var/obj/machinery/vending/V in SSmachinery.processing_machines)
if(isNotStationLevel(V.z)) continue
vendingMachines.Add(V)
+2 -2
View File
@@ -12,7 +12,7 @@
continue
players += player.real_name
for (var/mob/living/silicon/ai/target in world)
for (var/mob/living/silicon/ai/target in silicon_mob_list)
var/random_player = "The Captain"
if(players.len)
random_player = pick(players) //Random player's name, to be used in laws.
@@ -88,7 +88,7 @@
/datum/event/ionstorm/tick()
if(botEmagChance)
for(var/obj/machinery/bot/bot in world)
for(var/obj/machinery/bot/bot in SSmachinery.all_machines)
if(prob(botEmagChance))
bot.emag_act(1)
+4 -4
View File
@@ -19,11 +19,11 @@
without intervention this attack will succeed in approximately 10 minutes. Required intervention: temporary suspension of affected accounts until the attack has ceased. \
Notifications will be sent as updates occur.<br>"
var/my_department = "[station_name()] firewall subroutines"
for(var/obj/machinery/message_server/MS in world)
for(var/obj/machinery/message_server/MS in SSmachinery.processing_machines)
if(!MS.active) continue
MS.send_rc_message("Head of Personnel's Desk", my_department, message, "", "", 2)
/datum/event/money_hacker/tick()
if(world.time >= end_time)
@@ -62,6 +62,6 @@
var/my_department = "[station_name()] firewall subroutines"
for(var/obj/machinery/message_server/MS in world)
for(var/obj/machinery/message_server/MS in SSmachinery.processing_machines)
if(!MS.active) continue
MS.send_rc_message("Head of Personnel's Desk", my_department, message, "", "", 2)
+3 -3
View File
@@ -6,7 +6,7 @@
var/list/area/areas = list() //List of areas to affect. Filled by start()
ic_name = "an imprisonment system virus"
no_fake = 1
var/eventDept = "Security" //Department name in announcement
var/list/areaName = list("Brig") //Names of areas mentioned in AI and Engineering announcements
var/list/areaType = list(/area/security/prison, /area/security/brig) //Area types to include.
@@ -43,14 +43,14 @@
/datum/event/prison_break/start()
for(var/area/A in world)
for(var/area/A in the_station_areas)
if(is_type_in_list(A,areaType) && !is_type_in_list(A,areaNotType))
areas += A
if(areas && areas.len > 0)
var/my_department = "[station_name()] firewall subroutines"
var/rc_message = "An unknown malicious program has been detected in the [english_list(areaName)] lighting and airlock control systems at [worldtime2text()]. Systems will be fully compromised within approximately three minutes. Direct intervention is required immediately.<br>"
for(var/obj/machinery/message_server/MS in machines)
for(var/obj/machinery/message_server/MS in SSmachinery.processing_machines)
MS.send_rc_message("Engineering", my_department, rc_message, "", "", 2)
for(var/mob/living/silicon/ai/A in player_list)
A << "<span class='danger'>Malicious program detected in the [english_list(areaName)] lighting and airlock control systems by [my_department].</span>"
+1 -1
View File
@@ -17,7 +17,7 @@
/datum/event/spider_infestation/start()
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in world)
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in SSmachinery.processing_machines)
if(!temp_vent.welded && temp_vent.network && temp_vent.loc.z in config.station_levels)
if(temp_vent.network.normal_members.len > 50)
vents += temp_vent
+1 -1
View File
@@ -13,7 +13,7 @@
/datum/event/vent_clog/setup()
endWhen = rand(25, 100)
for(var/obj/machinery/atmospherics/unary/vent_scrubber/temp_vent in machines)
for(var/obj/machinery/atmospherics/unary/vent_scrubber/temp_vent in SSmachinery.processing_machines)
if(!temp_vent)
continue
if(temp_vent.z in config.station_levels)//STATION ZLEVEL
+1 -1
View File
@@ -505,7 +505,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
//If we hit the limit without finding a valid one, then the best one we found is selected
var/list/found_vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/v in machines)
for(var/obj/machinery/atmospherics/unary/vent_pump/v in SSmachinery.processing_machines)
if(!v.welded && v.z == ZLevel)
found_vents.Add(v)
+13 -6
View File
@@ -938,8 +938,11 @@
src.verbs -= /mob/living/carbon/human/proc/remotesay
return
var/list/creatures = list()
for(var/mob/living/carbon/h in world)
creatures += h
for(var/hh in human_mob_list)
var/mob/living/carbon/human/H = hh
if (H.client)
creatures += hh
var/mob/target = input("Who do you want to project your mind to ?") as null|anything in creatures
if (isnull(target))
return
@@ -951,7 +954,7 @@
target.show_message("<span class='notice'>You hear a voice that seems to echo around the room: [say]</span>")
usr.show_message("<span class='notice'>You project your mind into [target.real_name]: [say]</span>")
log_say("[key_name(usr)] sent a telepathic message to [key_name(target)]: [say]",ckey=key_name(usr))
for(var/mob/dead/observer/G in world)
for(var/mob/dead/observer/G in dead_mob_list)
G.show_message("<i>Telepathic message from <b>[src]</b> to <b>[target]</b>: [say]</i>")
/mob/living/carbon/human/proc/remoteobserve()
@@ -976,9 +979,13 @@
var/list/mob/creatures = list()
for(var/mob/living/carbon/h in world)
var/turf/temp_turf = get_turf(h)
if((temp_turf.z != 1 && temp_turf.z != 5) || h.stat!=CONSCIOUS) //Not on mining or the station. Or dead
for(var/h in human_mob_list)
var/mob/living/carbon/human/H = h
if (!H.client)
continue
var/turf/temp_turf = get_turf(H)
if((temp_turf.z != 1 && temp_turf.z != 5) || H.stat!=CONSCIOUS) //Not on mining or the station. Or dead
continue
creatures += h
+1 -1
View File
@@ -393,7 +393,7 @@ var/list/ai_verbs_default = list(
// hack to display shuttle timer
if(emergency_shuttle.online())
var/obj/machinery/computer/communications/C = locate() in machines
var/obj/machinery/computer/communications/C = locate() in SSmachinery.processing_machines
if(C)
C.post_status("shuttle")
+2 -2
View File
@@ -17,8 +17,8 @@
client.screen.Add( blind, flash )
if(stat != DEAD)
for(var/obj/machinery/ai_status_display/O in machines) //change status
for(var/obj/machinery/ai_status_display/O in SSmachinery.all_status_displays) //change status
O.mode = 1
O.emotion = "Neutral"
src.view_core()
return
return
@@ -28,7 +28,7 @@
var/dat
dat += "<B>Maintenance Units</B><BR>"
for(var/mob/living/silicon/robot/drone/D in world)
for(var/mob/living/silicon/robot/drone/D in silicon_mob_list)
if(D.z != src.z)
continue
dat += "<BR>[D.real_name] ([D.stat == 2 ? "<font color='red'>INACTIVE</FONT>" : "<font color='green'>ACTIVE</FONT>"])"
@@ -70,7 +70,7 @@
else if (href_list["ping"])
usr << "<span class='notice'>You issue a maintenance request for all active drones, highlighting [drone_call_area].</span>"
for(var/mob/living/silicon/robot/drone/D in world)
for(var/mob/living/silicon/robot/drone/D in silicon_mob_list)
if(D.client && D.stat == 0)
D << "-- Maintenance drone presence requested in: [drone_call_area]."
@@ -1,6 +1,6 @@
/proc/count_drones()
var/drones = 0
for(var/mob/living/silicon/robot/drone/D in world)
for(var/mob/living/silicon/robot/drone/D in silicon_mob_list)
if(D.key && D.client)
drones++
return drones
@@ -75,9 +75,9 @@
flick("h_lathe_leave",src)
time_last_drone = world.time
if(player.mob && player.mob.mind)
if(player.mob && player.mob.mind)
player.mob.mind.reset()
var/mob/living/silicon/robot/drone/new_drone = new drone_type(get_turf(src))
new_drone.transfer_personality(player)
new_drone.master_fabricator = src
@@ -110,7 +110,7 @@
if(!fabricator)
var/list/all_fabricators = list()
for(var/obj/machinery/drone_fabricator/DF in machines)
for(var/obj/machinery/drone_fabricator/DF in SSmachinery.all_machines)
if((DF.stat & NOPOWER) || !DF.produce_drones || DF.drone_progress < 100)
continue
all_fabricators[DF.fabricator_tag] = DF
@@ -54,7 +54,7 @@
user << "The [src] is empty. Put something inside it first."
if(response == "Sync")
var/success = 0
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
for(var/datum/tech/T in files.known_tech) //Uploading
S.files.AddTech2Known(T)
for(var/datum/tech/T in S.files.known_tech) //Downloading
@@ -31,7 +31,7 @@ var/global/datum/ntnet/ntnet_global = new()
/datum/ntnet/New()
if(ntnet_global && (ntnet_global != src))
ntnet_global = src // There can be only one.
for(var/obj/machinery/ntnet_relay/R in machines)
for(var/obj/machinery/ntnet_relay/R in SSmachinery.all_machines)
relays.Add(R)
R.NTNet = src
build_software_lists()
@@ -290,7 +290,7 @@ var/last_message_id = 0
l.Add(message)
//Old console support
for (var/obj/machinery/computer/communications/comm in machines)
for (var/obj/machinery/computer/communications/comm in SSmachinery.processing_machines)
if (!(comm.stat & (BROKEN | NOPOWER)) && comm.prints_intercept)
var/obj/item/weapon/paper/intercept = new /obj/item/weapon/paper( comm.loc )
intercept.name = message_title
+3 -3
View File
@@ -19,7 +19,7 @@
log_debug("\The [src] given an unepxected req_one_access: [req_one_access]")
if(monitored_alarm_ids)
for(var/obj/machinery/alarm/alarm in machines)
for(var/obj/machinery/alarm/alarm in SSmachinery.processing_machines)
if(alarm.alarm_id && alarm.alarm_id in monitored_alarm_ids)
monitored_alarms += alarm
// machines may not yet be ordered at this point
@@ -31,7 +31,7 @@
if(href_list["alarm"])
if(ui_ref)
var/obj/machinery/alarm/alarm = locate(href_list["alarm"]) in (monitored_alarms.len ? monitored_alarms : machines)
var/obj/machinery/alarm/alarm = locate(href_list["alarm"]) in (monitored_alarms.len ? monitored_alarms : SSmachinery.processing_machines)
if(alarm)
var/datum/topic_state/TS = generate_state(alarm)
alarm.ui_interact(usr, master_ui = ui_ref, state = TS)
@@ -42,7 +42,7 @@
var/alarms[0]
// TODO: Move these to a cache, similar to cameras
for(var/obj/machinery/alarm/alarm in (monitored_alarms.len ? monitored_alarms : machines))
for(var/obj/machinery/alarm/alarm in (monitored_alarms.len ? monitored_alarms : SSmachinery.processing_machines))
alarms[++alarms.len] = list("name" = sanitize(alarm.name), "ref"= "\ref[alarm]", "danger" = max(alarm.danger_level, alarm.alarm_area.atmosalm))
data["alarms"] = alarms
+3 -3
View File
@@ -9,7 +9,7 @@ var/list/ship_engines = list()
/datum/ship_engine/New(var/obj/machinery/holder)
engine = holder
zlevel = holder.z
for(var/obj/machinery/computer/engines/E in machines)
for(var/obj/machinery/computer/engines/E in SSmachinery.processing_machines)
if (E.z == zlevel && !(src in E.engines))
E.engines += src
break
@@ -53,8 +53,8 @@ var/list/ship_engines = list()
return 1
/datum/ship_engine/proc/die()
for(var/obj/machinery/computer/engines/E in machines)
for(var/obj/machinery/computer/engines/E in SSmachinery.processing_machines)
if (E.z == zlevel)
E.engines -= src
break
qdel(src)
qdel(src)
+3 -3
View File
@@ -16,11 +16,11 @@
/obj/effect/map/ship/Initialize()
. = ..()
for(var/obj/machinery/computer/engines/E in machines)
for(var/obj/machinery/computer/engines/E in SSmachinery.processing_machines)
if (E.z == map_z)
eng_control = E
break
for(var/obj/machinery/computer/helm/H in machines)
for(var/obj/machinery/computer/helm/H in SSmachinery.processing_machines)
if (H.z == map_z)
nav_control = H
break
@@ -112,5 +112,5 @@
var/turf/newloc = locate(x + deltas[1], y + deltas[2], z)
if(newloc)
Move(newloc)
if(rotate)
if(rotate)
rotate(get_heading())
+1 -1
View File
@@ -44,7 +44,7 @@ proc/cardinalrange(var/center)
controllerscan()
return
link_control(AMC)
remove_machine(src)
remove_machine(src, FALSE)
if (mapload)
. = INITIALIZE_HINT_LATELOAD
else
+1 -1
View File
@@ -124,7 +124,7 @@
for(var/area/A in gravity_generator:localareas)
var/obj/machinery/gravity_generator/G
for(G in machines)
for(G in SSmachinery.processing_machines)
if((A in G.localareas) && (G.on))
break
if(!G)
@@ -312,7 +312,7 @@ field_generator power level display
//I want to avoid using global variables.
spawn(1)
var/temp = 1 //stops spam
for(var/obj/singularity/O in machines)
for(var/obj/singularity/O in SSmachinery.processing_machines)
if(O.last_warning && temp)
if((world.time - O.last_warning) > 50) //to stop message-spam
temp = 0
@@ -39,7 +39,7 @@
..()
START_PROCESSING(SScalamity, src)
for(var/obj/machinery/power/singularity_beacon/singubeacon in machines)
for(var/obj/machinery/power/singularity_beacon/singubeacon in SSmachinery.processing_machines)
if(singubeacon.active)
target = singubeacon
break
@@ -516,4 +516,4 @@
/obj/singularity/proc/zMove(direction)
var/turf/destination = (direction == UP) ? GetAbove(src) : GetBelow(src)
if(destination)
forceMove(destination)
forceMove(destination)
+2 -2
View File
@@ -219,11 +219,11 @@
/obj/machinery/computer/turbine_computer/New()
..()
spawn(5)
for(var/obj/machinery/compressor/C in machines)
for(var/obj/machinery/compressor/C in SSmachinery.all_machines)
if(id == C.comp_id)
compressor = C
doors = new /list()
for(var/obj/machinery/door/blast/P in machines)
for(var/obj/machinery/door/blast/P in SSmachinery.all_machines)
if(P.id == id)
doors += P
+4 -4
View File
@@ -98,7 +98,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
return
/obj/machinery/computer/rdconsole/proc/griefProtection() //Have it automatically push research to the centcomm server so wild griffins can't fuck up R&D's work
for(var/obj/machinery/r_n_d/server/centcom/C in machines)
for(var/obj/machinery/r_n_d/server/centcom/C in SSmachinery.all_machines)
for(var/datum/tech/T in files.known_tech)
C.files.AddTech2Known(T)
for(var/datum/design/D in files.known_designs)
@@ -109,7 +109,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
. = ..()
files = new /datum/research(src) //Setup the research data holder.
if(!id)
for(var/obj/machinery/r_n_d/server/centcom/S in machines)
for(var/obj/machinery/r_n_d/server/centcom/S in SSmachinery.all_machines)
S.setup()
break
SyncRDevices()
@@ -278,7 +278,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
griefProtection() //Putting this here because I dont trust the sync process
spawn(30)
if(src)
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
var/server_processed = 0
if((id in S.id_with_upload) || istype(S, /obj/machinery/r_n_d/server/centcom))
for(var/datum/tech/T in files.known_tech)
@@ -411,7 +411,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
info += GetResearchListInfo()
else
info += GetResearchLevelsInfo()
PR.set_content_unsafe(pname, info)
print(PR)
spawn(10)
+6 -6
View File
@@ -82,7 +82,7 @@
//Backup files to centcomm to help admins recover data after greifer attacks
/obj/machinery/r_n_d/server/proc/griefProtection()
for(var/obj/machinery/r_n_d/server/centcom/C in machines)
for(var/obj/machinery/r_n_d/server/centcom/C in SSmachinery.all_machines)
for(var/datum/tech/T in files.known_tech)
C.files.AddTech2Known(T)
for(var/datum/design/D in files.known_designs)
@@ -128,7 +128,7 @@
..()
var/list/no_id_servers = list()
var/list/server_ids = list()
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
switch(S.server_id)
if(-1)
continue
@@ -179,20 +179,20 @@
temp_server = null
consoles = list()
servers = list()
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
if(S.server_id == text2num(href_list["access"]) || S.server_id == text2num(href_list["data"]) || S.server_id == text2num(href_list["transfer"]))
temp_server = S
break
if(href_list["access"])
screen = 1
for(var/obj/machinery/computer/rdconsole/C in machines)
for(var/obj/machinery/computer/rdconsole/C in SSmachinery.all_machines)
if(C.sync)
consoles += C
else if(href_list["data"])
screen = 2
else if(href_list["transfer"])
screen = 3
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
if(S == src)
continue
servers += S
@@ -242,7 +242,7 @@
if(0) //Main Menu
dat += "Connected Servers:<BR><BR>"
for(var/obj/machinery/r_n_d/server/S in machines)
for(var/obj/machinery/r_n_d/server/S in SSmachinery.all_machines)
if(istype(S, /obj/machinery/r_n_d/server/centcom) && !badmin)
continue
dat += "[S.name] || "
@@ -111,7 +111,7 @@
/obj/machinery/keycard_auth/proc/broadcast_request()
icon_state = "auth_on"
for(var/obj/machinery/keycard_auth/KA in world)
for(var/obj/machinery/keycard_auth/KA in SSmachinery.all_machines)
if(KA == src) continue
KA.reset()
spawn()
@@ -50,7 +50,7 @@
SSnightlight.temp_disable()
var/newlevel = get_security_level()
for(var/obj/machinery/firealarm/FA in machines)
for(var/obj/machinery/firealarm/FA in SSmachinery.processing_machines)
if(FA.z in config.contact_levels)
FA.set_security_level(newlevel)