diff --git a/code/controllers/master_controller.dm b/code/controllers/master_controller.dm index e5970e40fb..914bad735f 100644 --- a/code/controllers/master_controller.dm +++ b/code/controllers/master_controller.dm @@ -255,11 +255,27 @@ datum/controller/game_controller/proc/process_machines() last_thing_processed = Machine.type if(Machine.process() != PROCESS_KILL) if(Machine) - if(Machine.use_power) - Machine.auto_use_power() + +// if(Machine.use_power) +// Machine.auto_use_power() + i++ continue machines.Cut(i,i+1) + i=1 + while(i<=active_areas.len) + var/area/A = active_areas[i] + if(A.powerupdate) + if(A.debug) + world << "process_machines [A] powerupdate is [A.powerupdate]" + A.powerupdate -= 1 + for(var/obj/machinery/M in A) + if(M) + if(M.use_power) + M.auto_use_power() + + i++ + datum/controller/game_controller/proc/process_objects() var/i = 1 diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index 52666e4663..7ab535b434 100755 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -14,6 +14,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station */ + /area var/fire = null var/atmos = 1 @@ -31,6 +32,8 @@ NOTE: there are two lists of areas in the end of this file: centcom and station var/eject = null + var/debug = 0 + var/powerupdate = 0 var/requires_power = 1 var/always_unpowered = 0 //this gets overriden to 1 for space in area/New() diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 9161ac9570..16a7059e51 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -13,6 +13,7 @@ master = src //moved outside the spawn(1) to avoid runtimes in lighting.dm when it references loc.loc.master ~Carn uid = ++global_uid related = list(src) + active_areas += src if(type == /area) // override defaults for space. TODO: make space areas of type /area/space rather than /area requires_power = 1 diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 1bacef1500..d92df433bf 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -67,8 +67,10 @@ Class Procs: Checks to see if area that contains the object has power available for power channel given in 'chan'. - use_power(amount, chan=EQUIP) 'modules/power/power.dm' + use_power(amount, chan=EQUIP, autocalled) 'modules/power/power.dm' Deducts 'amount' from the power channel 'chan' of the area that contains the object. + If it's autocalled then everything is normal, if something else calls use_power we are going to + need to recalculate the power two ticks in a row. power_change() 'modules/power/power.dm' Called by the area that contains the object when ever that area under goes a @@ -159,9 +161,9 @@ Class Procs: if(!powered(power_channel)) return 0 if(src.use_power == 1) - use_power(idle_power_usage,power_channel) + use_power(idle_power_usage,power_channel, 1) else if(src.use_power >= 2) - use_power(active_power_usage,power_channel) + use_power(active_power_usage,power_channel, 1) return 1 /obj/machinery/Topic(href, href_list) @@ -189,6 +191,10 @@ Class Procs: return 1 src.add_fingerprint(usr) + + var/area/A = get_area(src) + A.powerupdate = 1 + return 0 /obj/machinery/attack_ai(mob/user as mob) @@ -228,6 +234,10 @@ Class Procs: return 1 src.add_fingerprint(user) + + var/area/A = get_area(src) + A.powerupdate = 1 + return 0 /obj/machinery/proc/RefreshParts() //Placeholder proc for machines that are built using frames. diff --git a/code/global.dm b/code/global.dm index 9fb6de1ce7..077b9d9f85 100644 --- a/code/global.dm +++ b/code/global.dm @@ -6,6 +6,7 @@ var/global/obj/effect/overlay/plmaster = null var/global/obj/effect/overlay/slmaster = null +var/global/list/active_areas = list() var/global/list/machines = list() var/global/list/processing_objects = list() var/global/list/active_diseases = list() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 6e4c7e2e18..602da6dd14 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -32,6 +32,13 @@ usr.show_message(t, 1) +/mob/verb/check_area() + var/area/a = get_area(src) + if(a in active_areas) + src << "Yep [a] is in the active_areas list" + else + src << "Nope, FUCK." + /mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2) if(!client) return diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 7a5f17eeca..61c782650d 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -77,6 +77,7 @@ powernet = 0 // set so that APCs aren't found as powernet nodes //Hackish, Horrible, was like this before I changed it :( var/malfhack = 0 //New var for my changes to AI malf. --NeoFite var/mob/living/silicon/ai/malfai = null //See above --NeoFite + var/debug= 0 // luminosity = 1 var/has_electronics = 0 // 0 - none, 1 - plugged in, 2 - secured by screwdriver var/overload = 1 //used for the Blackout malf module @@ -1162,7 +1163,8 @@ lastused_light = area.usage(LIGHT) lastused_equip = area.usage(EQUIP) lastused_environ = area.usage(ENVIRON) - area.clear_usage() + if(area.powerupdate) + area.clear_usage() lastused_total = lastused_light + lastused_equip + lastused_environ @@ -1185,8 +1187,8 @@ if(terminal && terminal.powernet) perapc = terminal.powernet.perapc - //if(debug) - // world.log << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light] - Longterm: [longtermpower]" + if(debug) + world << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light]" if(cell && !shorted) diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 0a3a4d3794..f1fa25234a 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -603,9 +603,11 @@ #define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity +/* /obj/machinery/light/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY if(on) use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT) +*/ // called when area power state changes /obj/machinery/light/power_change() diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm index 33441fbe4a..7abe3aeacd 100644 --- a/code/modules/power/power.dm +++ b/code/modules/power/power.dm @@ -54,13 +54,17 @@ // increment the power usage stats for an area -/obj/machinery/proc/use_power(var/amount, var/chan = -1) // defaults to power_channel +/obj/machinery/proc/use_power(var/amount, var/chan = -1, var/autocalled = 0) // defaults to power_channel var/area/A = src.loc.loc // make sure it's in an area if(!A || !isarea(A) || !A.master) return if(chan == -1) chan = power_channel A.master.use_power(amount, chan) + if(!autocalled) + if(A.master.debug) + world << "Yeah we're setting this to 2 source: [src] / [src.type]" + A.master.powerupdate = 2 // Decremented by 2 each GC tick, since it's not auto power change we're going to update power twice. /obj/machinery/proc/power_change() // called whenever the power settings of the containing area change // by default, check equipment channel & set flag diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 1daac04fd2..876860491d 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -22,6 +22,8 @@ var/flush_every_ticks = 30 //Every 30 ticks it will look whether it is ready to flush var/flush_count = 0 //this var adds 1 once per tick. When it reaches flush_every_ticks it resets and tries to flush. var/last_sound = 0 + active_power_usage = 600 + idle_power_usage = 100 // create a new disposal // find the attached trunk (if present) and init gas resvr. @@ -340,6 +342,7 @@ // timed process // charge the gas reservoir and perform flush if ready process() + use_power = 0 if(stat & BROKEN) // nothing can happen if broken return @@ -363,13 +366,13 @@ if(stat & NOPOWER) // won't charge if no power return - use_power(100) // base power usage - + use_power = 1 + if(mode != 1) // if off or ready, no need to charge return // otherwise charge - use_power(500) // charging power usage + use_power = 2 var/atom/L = loc // recharging from loc turf