Skip to content

Commit

Permalink
Track singularities in a global list (tgstation#24609)
Browse files Browse the repository at this point in the history
This replaces a few operations on either the poi_list (still quite
large) or the world
  • Loading branch information
optimumtact authored and AnturK committed Mar 3, 2017
1 parent 4c8bfd8 commit 83c7390
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions code/_globalvars/lists/objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var/global/list/deliverybeacons = list() //list of all MULEbot delivery beacon
var/global/list/deliverybeacontags = list() //list of all tags associated with delivery beacons.
var/global/list/nuke_list = list()
var/global/list/alarmdisplay = list() //list of all machines or programs that can display station alerts
var/global/list/singularities = list() //list of all singularities on the station (actually technically all engines)

var/global/list/chemical_reactions_list //list of all /datum/chemical_reaction datums. Used during chemical reactions
var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
T.ratvar_act(1)
var/dir_to_step_in = pick(cardinal)
if(!prey)
for(var/obj/singularity/narsie/N in poi_list)
for(var/obj/singularity/narsie/N in singularities)
if(N.z == z)
prey = N
break
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/syndicatebeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
if(surplus() < 1500)
if(user) user << "<span class='notice'>The connected wire doesn't have enough current.</span>"
return
for(var/obj/singularity/singulo in poi_list)
for(var/obj/singularity/singulo in singularities)
if(singulo.z == z)
singulo.target = src
icon_state = "[icontype]1"
Expand All @@ -34,7 +34,7 @@


/obj/machinery/power/singularity_beacon/proc/Deactivate(mob/user = null)
for(var/obj/singularity/singulo in poi_list)
for(var/obj/singularity/singulo in singularities)
if(singulo.target == src)
singulo.target = null
icon_state = "[icontype]0"
Expand Down Expand Up @@ -90,7 +90,7 @@
add_load(1500)
if(cooldown <= world.time)
cooldown = world.time + 100
for(var/obj/singularity/singulo in poi_list)
for(var/obj/singularity/singulo in singularities)
if(singulo.z == z)
say("The [singulo] is now [get_dist(src,singulo)] standard lengths away to the [dir2text(get_dir(src,singulo))]")
else
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/singularity/field_generator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,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 world)
for(var/obj/singularity/O in singularities)
if(O.last_warning && temp)
if((world.time - O.last_warning) > 50) //to stop message-spam
temp = 0
Expand Down
2 changes: 2 additions & 0 deletions code/modules/power/singularity/singularity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
..()
START_PROCESSING(SSobj, src)
poi_list |= src
singularities |= src
for(var/obj/machinery/power/singularity_beacon/singubeacon in machines)
if(singubeacon.active)
target = singubeacon
Expand All @@ -45,6 +46,7 @@
/obj/singularity/Destroy()
STOP_PROCESSING(SSobj, src)
poi_list.Remove(src)
singularities.Remove(src)
return ..()

/obj/singularity/Move(atom/newloc, direct)
Expand Down

0 comments on commit 83c7390

Please sign in to comment.