Skip to content

Commit

Permalink
Merge pull request tgstation#4750 from Aranclanos/processloop
Browse files Browse the repository at this point in the history
Better loops for all the process tickers of the master controller.
  • Loading branch information
Giacom committed Sep 14, 2014
2 parents 1431e64 + 51f46bc commit ad0d98a
Showing 1 changed file with 19 additions and 49 deletions.
68 changes: 19 additions & 49 deletions code/controllers/master_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,83 +236,53 @@ var/global/pipe_processing_killed = 0
*/

/datum/controller/game_controller/proc/process_mobs()
var/i = 1
while(i<=mob_list.len)
var/mob/M = mob_list[i]
if(M && !M.gc_destroyed)
for(var/mob/M in mob_list)
if(!M.gc_destroyed)
last_thing_processed = M.type
M.Life()
i++
continue
mob_list.Cut(i,i+1)
mob_list -= M

/datum/controller/game_controller/proc/process_diseases()
var/i = 1
while(i<=active_diseases.len)
var/datum/disease/Disease = active_diseases[i]
if(Disease)
last_thing_processed = Disease.type
Disease.process()
i++
continue
active_diseases.Cut(i,i+1)
for(var/datum/disease/Disease in active_diseases)
last_thing_processed = Disease.type
Disease.process()

/datum/controller/game_controller/proc/process_machines()
var/i = 1
while(i<=machines.len)
var/obj/machinery/Machine = machines[i]
if(Machine && !Machine.gc_destroyed)
for(var/obj/machinery/Machine in machines)
if(!Machine.gc_destroyed)
last_thing_processed = Machine.type
if(Machine.process() != PROCESS_KILL)
if(Machine)
if(Machine.use_power)
Machine.auto_use_power()
i++
continue
machines.Cut(i,i+1)
machines -= Machine

/datum/controller/game_controller/proc/process_objects()
var/i = 1
while(i<=processing_objects.len)
var/obj/Object = processing_objects[i]
if(Object && !Object.gc_destroyed)
for(var/obj/Object in processing_objects)
if(!Object.gc_destroyed)
last_thing_processed = Object.type
Object.process()
i++
continue
processing_objects.Cut(i,i+1)
processing_objects -= Object

/datum/controller/game_controller/proc/process_pipenets()
last_thing_processed = /datum/pipe_network
var/i = 1
while(i<=pipe_networks.len)
var/datum/pipe_network/Network = pipe_networks[i]
if(Network)
Network.process()
i++
continue
pipe_networks.Cut(i,i+1)
for(var/datum/pipe_network/Network in pipe_networks)
Network.process()

/datum/controller/game_controller/proc/process_powernets()
last_thing_processed = /datum/powernet
var/i = 1
while(i<=powernets.len)
var/datum/powernet/Powernet = powernets[i]
if(Powernet)
Powernet.reset()
i++
continue
powernets.Cut(i,i+1)
for(var/datum/powernet/Powernet in powernets)
Powernet.reset()

/datum/controller/game_controller/proc/process_nano()
var/i = 1
while(i<=nanomanager.processing_uis.len)
var/datum/nanoui/ui = nanomanager.processing_uis[i]
if(ui && ui.src_object && ui.user)
for(var/datum/nanoui/ui in nanomanager.processing_uis)
if(ui.src_object && ui.user)
ui.process()
i++
continue
nanomanager.processing_uis.Cut(i,i+1)
nanomanager.processing_uis -= ui

/datum/controller/game_controller/proc/Recover() //Mostly a placeholder for now.
var/msg = "## DEBUG: [time2text(world.timeofday)] MC restarted. Reports:\n"
Expand Down

0 comments on commit ad0d98a

Please sign in to comment.