APC Area update initial commit.

Conflicts:
	code/modules/mob/mob.dm
	code/modules/power/power.dm
This commit is contained in:
Ccomp5950
2014-03-07 23:42:28 -06:00
committed by ZomgPonies
parent 0b47e16828
commit b97434054f
9 changed files with 57 additions and 15 deletions
+18 -2
View File
@@ -267,11 +267,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
+3
View File
@@ -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
@@ -32,6 +33,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()
+1
View File
@@ -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
+13 -3
View File
@@ -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
@@ -161,9 +163,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)
@@ -191,6 +193,10 @@ Class Procs:
return 1
src.add_fingerprint(usr)
var/area/A = get_area(src)
A.powerupdate = 1
return 0
/obj/machinery/attack_ai(var/mob/user as mob)
@@ -233,6 +239,10 @@ Class Procs:
return 1
src.add_fingerprint(user)
var/area/A = get_area(src)
A.powerupdate = 1
return 0
/obj/machinery/CheckParts()
+2 -1
View File
@@ -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()
@@ -300,4 +301,4 @@ var/score_dmgestkey = null
// Recall time limit: 2 hours
var/recall_time_limit=72000
var/recall_time_limit=72000
+6 -4
View File
@@ -78,6 +78,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
@@ -1049,7 +1050,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
@@ -1072,8 +1074,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)
@@ -1318,4 +1320,4 @@ obj/machinery/power/apc/proc/autoset(var/val, var/on)
else
return 0
#undef APC_UPDATE_ICON_COOLDOWN
#undef APC_UPDATE_ICON_COOLDOWN
+2
View File
@@ -602,9 +602,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()
+6 -2
View File
@@ -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
var/area/A = get_area(src) // make sure it's in an area
/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
+6 -3
View File
@@ -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