mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-30 03:52:52 +00:00
Machinery performance tweaks (#1744)
changes: Machines' process() has been separated from auto_use_power(). Lights no longer process() and instead use auto_use_power() for power calculations. Computers that didn't really need to process() no longer process(). Airlocks now use the scheduler to auto-close instead of process()ing. Fixed a bug where clicking on an AI Status display to set its status did not work.
This commit is contained in:
@@ -96,3 +96,12 @@ var/list/restricted_camera_networks = list(NETWORK_ERT,NETWORK_MERCENARY,"Secret
|
||||
#define ATMOS_DEFAULT_VOLUME_FILTER 200 // L.
|
||||
#define ATMOS_DEFAULT_VOLUME_MIXER 200 // L.
|
||||
#define ATMOS_DEFAULT_VOLUME_PIPE 70 // L.
|
||||
|
||||
|
||||
// Misc process flags.
|
||||
#define M_PROCESSES 0x1
|
||||
#define M_USES_POWER 0x2
|
||||
|
||||
// If this is returned from a machine's process() proc, the machine will stop processing but
|
||||
// will continue to have power calculations done.
|
||||
#define M_NO_PROCESS 27
|
||||
|
||||
@@ -285,3 +285,4 @@
|
||||
)
|
||||
|
||||
#define get_turf(A) (get_step(A, 0))
|
||||
#define NULL_OR_GC(TARGET) (!TARGET || TARGET.gcDestroyed)
|
||||
|
||||
@@ -1,16 +1,39 @@
|
||||
/var/global/machinery_sort_required = 0
|
||||
/var/global/machinery_sort_required = 0
|
||||
var/global/list/power_using_machines = list()
|
||||
var/global/list/ticking_machines = list()
|
||||
|
||||
#define STAGE_NONE 0
|
||||
#define STAGE_MACHINERY 1
|
||||
#define STAGE_POWERNET 2
|
||||
#define STAGE_POWERSINK 3
|
||||
#define STAGE_PIPENET 4
|
||||
#define STAGE_MACHINERY_PROCESS 1
|
||||
#define STAGE_MACHINERY_POWER 2
|
||||
#define STAGE_POWERNET 3
|
||||
#define STAGE_POWERSINK 4
|
||||
#define STAGE_PIPENET 5
|
||||
|
||||
/proc/add_machine(var/obj/machinery/M)
|
||||
if (NULL_OR_GC(M))
|
||||
return
|
||||
|
||||
var/type = M.get_process_type()
|
||||
if (type)
|
||||
machines += M
|
||||
|
||||
if (type & M_PROCESSES)
|
||||
ticking_machines += M
|
||||
|
||||
if (type & M_USES_POWER)
|
||||
power_using_machines += M
|
||||
|
||||
/proc/remove_machine(var/obj/machinery/M)
|
||||
machines -= M
|
||||
power_using_machines -= M
|
||||
ticking_machines -= M
|
||||
|
||||
/datum/controller/process/machinery
|
||||
var/tmp/list/processing_machinery = list()
|
||||
var/tmp/list/processing_powernets = list()
|
||||
var/tmp/list/processing_powersinks = list()
|
||||
var/tmp/list/processing_pipenets = list()
|
||||
var/tmp/list/processing_machinery = list()
|
||||
var/tmp/list/processing_power_users = list()
|
||||
var/tmp/list/processing_powernets = list()
|
||||
var/tmp/list/processing_powersinks = list()
|
||||
var/tmp/list/processing_pipenets = list()
|
||||
var/stage = STAGE_NONE
|
||||
|
||||
/datum/controller/process/machinery/setup()
|
||||
@@ -21,20 +44,37 @@
|
||||
/datum/controller/process/machinery/doWork()
|
||||
// If we're starting a new tick, setup.
|
||||
if (stage == STAGE_NONE)
|
||||
processing_machinery = machines.Copy()
|
||||
stage = STAGE_MACHINERY
|
||||
processing_machinery = ticking_machines.Copy()
|
||||
stage = STAGE_MACHINERY_PROCESS
|
||||
|
||||
// Process machinery.
|
||||
while (processing_machinery.len)
|
||||
var/obj/machinery/M = processing_machinery[processing_machinery.len]
|
||||
processing_machinery.len--
|
||||
|
||||
if (!M || M.gcDestroyed)
|
||||
machines -= M
|
||||
if (NULL_OR_GC(M))
|
||||
remove_machine(M)
|
||||
continue
|
||||
|
||||
if (M.process() == PROCESS_KILL)
|
||||
machines -= M
|
||||
switch (M.process())
|
||||
if (PROCESS_KILL)
|
||||
remove_machine(M)
|
||||
|
||||
if (M_NO_PROCESS)
|
||||
ticking_machines -= M
|
||||
|
||||
F_SCHECK
|
||||
|
||||
if (stage == STAGE_MACHINERY_PROCESS)
|
||||
processing_power_users = power_using_machines.Copy()
|
||||
stage = STAGE_MACHINERY_POWER
|
||||
|
||||
while (processing_power_users.len)
|
||||
var/obj/machinery/M = processing_power_users[processing_power_users.len]
|
||||
processing_power_users.len--
|
||||
|
||||
if (NULL_OR_GC(M))
|
||||
remove_machine(M)
|
||||
continue
|
||||
|
||||
if (M.use_power)
|
||||
@@ -42,7 +82,7 @@
|
||||
|
||||
F_SCHECK
|
||||
|
||||
if (stage == STAGE_MACHINERY)
|
||||
if (stage == STAGE_MACHINERY_POWER)
|
||||
processing_powernets = powernets.Copy()
|
||||
stage = STAGE_POWERNET
|
||||
|
||||
@@ -50,7 +90,7 @@
|
||||
var/datum/powernet/PN = processing_powernets[processing_powernets.len]
|
||||
processing_powernets.len--
|
||||
|
||||
if (!PN || PN.gcDestroyed)
|
||||
if (NULL_OR_GC(PN))
|
||||
powernets -= PN
|
||||
continue
|
||||
|
||||
@@ -65,7 +105,7 @@
|
||||
var/obj/item/I = processing_powersinks[processing_powersinks.len]
|
||||
processing_powersinks.len--
|
||||
|
||||
if (!I || !I.pwr_drain())
|
||||
if (NULL_OR_GC(I) || !I.pwr_drain())
|
||||
processing_power_items -= I
|
||||
|
||||
F_SCHECK
|
||||
@@ -78,7 +118,8 @@
|
||||
var/datum/pipe_network/PN = processing_pipenets[processing_pipenets.len]
|
||||
processing_pipenets.len--
|
||||
|
||||
if (!PN || PN.gcDestroyed)
|
||||
if (NULL_OR_GC(PN))
|
||||
pipe_networks -= PN
|
||||
continue
|
||||
|
||||
PN.process()
|
||||
@@ -93,13 +134,16 @@
|
||||
|
||||
/datum/controller/process/machinery/statProcess()
|
||||
..()
|
||||
stat(null, "[machines.len] machines, [processing_machinery.len] queued")
|
||||
stat(null, "[machines.len] total machines")
|
||||
stat(null, "[ticking_machines.len] ticking machines, [processing_machinery.len] queued")
|
||||
stat(null, "[power_using_machines.len] power-using machines, [processing_power_users.len] queued")
|
||||
stat(null, "[powernets.len] powernets, [processing_powernets.len] queued")
|
||||
stat(null, "[processing_power_items.len] power items, [processing_powersinks.len] queued")
|
||||
stat(null, "[pipe_networks.len] pipenets, [processing_pipenets.len] queued")
|
||||
|
||||
#undef STAGE_NONE
|
||||
#undef STAGE_MACHINERY
|
||||
#undef STAGE_MACHINERY_PROCESS
|
||||
#undef STAGE_MACHINERY_POWER
|
||||
#undef STAGE_POWERNET
|
||||
#undef STAGE_POWERSINK
|
||||
#undef STAGE_PIPENET
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
/datum/controller/process/scheduler/setup()
|
||||
name = "scheduler"
|
||||
schedule_interval = 3 SECONDS
|
||||
schedule_interval = 2 SECONDS
|
||||
scheduled_tasks = list()
|
||||
scheduler = src
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ obj/machinery/computer/general_air_control/Destroy()
|
||||
onclose(user, "computer")
|
||||
|
||||
/obj/machinery/computer/general_air_control/process()
|
||||
..()
|
||||
src.updateUsrDialog()
|
||||
if (operable())
|
||||
src.updateUsrDialog()
|
||||
|
||||
/obj/machinery/computer/general_air_control/receive_signal(datum/signal/signal)
|
||||
if(!signal || signal.encryption) return
|
||||
|
||||
@@ -174,11 +174,7 @@ var/global/list/engineering_networks = list(
|
||||
assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly))
|
||||
setPowerUsage()
|
||||
if(!(src in machines))
|
||||
if(!machinery_sort_required && ticker)
|
||||
dd_insertObjectList(machines, src)
|
||||
else
|
||||
machines += src
|
||||
machinery_sort_required = 1
|
||||
add_machine(src)
|
||||
update_coverage()
|
||||
|
||||
/obj/machinery/camera/proc/setPowerUsage()
|
||||
|
||||
@@ -80,5 +80,5 @@
|
||||
|
||||
|
||||
/obj/machinery/computer/operating/process()
|
||||
if(..())
|
||||
if(operable())
|
||||
src.updateDialog()
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
crew_announcement.newscast = 1
|
||||
|
||||
/obj/machinery/computer/communications/process()
|
||||
if(..())
|
||||
if(operable())
|
||||
if(state != STATE_STATUSDISPLAY)
|
||||
src.updateDialog()
|
||||
|
||||
|
||||
@@ -23,11 +23,6 @@
|
||||
power_change()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/computer/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/emp_act(severity)
|
||||
if(prob(20/severity)) set_broken()
|
||||
..()
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
|
||||
|
||||
/obj/machinery/computer/pod/process()
|
||||
if(!..())
|
||||
if(inoperable())
|
||||
return
|
||||
if(timing)
|
||||
if(time > 0)
|
||||
|
||||
@@ -1073,7 +1073,7 @@ About the new airlock wires panel:
|
||||
|
||||
// playsound(src.loc, 'sound/machines/buzz-two.ogg', 50, 0)
|
||||
// next_beep_at = world.time + SecondsToTicks(10)
|
||||
close_door_at = world.time + 6
|
||||
close_door_in(6)
|
||||
return
|
||||
for(var/turf/turf in locs)
|
||||
for(var/atom/movable/AM in turf)
|
||||
|
||||
@@ -29,8 +29,9 @@
|
||||
var/hitsound_light = 'sound/effects/Glasshit.ogg'//Sound door makes when hit very gently
|
||||
var/obj/item/stack/material/steel/repairing
|
||||
var/block_air_zones = 1 //If set, air zones cannot merge across the door even when it is opened.
|
||||
var/close_door_at = 0 //When to automatically close the door, if possible
|
||||
var/open_duration = 150//How long it stays open
|
||||
var/datum/scheduled_task/close_task
|
||||
var/datum/scheduled_task/hatch_task
|
||||
|
||||
var/hashatch = 0//If 1, this door has hatches, and certain small creatures can move through them without opening the door
|
||||
var/hatchstate = 0//0: closed, 1: open
|
||||
@@ -41,8 +42,6 @@
|
||||
var/hatch_open_sound = 'sound/machines/hatch_open.ogg'
|
||||
var/hatch_close_sound = 'sound/machines/hatch_close.ogg'
|
||||
|
||||
var/hatchclosetime //A world.time value to tell us when the hatch should close
|
||||
|
||||
var/image/hatch_image
|
||||
|
||||
//Multi-tile doors
|
||||
@@ -107,7 +106,7 @@
|
||||
hatchstate = 1
|
||||
update_icon()
|
||||
playsound(src.loc, hatch_open_sound, 40, 1, -1)
|
||||
hatchclosetime = world.time + 29
|
||||
close_hatch_in(29)
|
||||
|
||||
if (istype(mover, /mob/living))
|
||||
var/mob/living/S = mover
|
||||
@@ -125,15 +124,31 @@
|
||||
..()
|
||||
return
|
||||
|
||||
/obj/machinery/door/process()
|
||||
if(close_door_at && world.time >= close_door_at)
|
||||
if(autoclose)
|
||||
close_door_at = next_close_time()
|
||||
close()
|
||||
else
|
||||
close_door_at = 0
|
||||
if (hatchstate && world.time > hatchclosetime)
|
||||
close_hatch()
|
||||
/obj/machinery/door/proc/close_door_in(var/time = 5 SECONDS)
|
||||
if (time < 2 SECONDS) // Too short duration for the scheduler.
|
||||
spawn(time)
|
||||
src.auto_close()
|
||||
|
||||
else if (close_task)
|
||||
// Update the time.
|
||||
close_task.trigger_task_in(time)
|
||||
else
|
||||
close_task = schedule_task_with_source_in(time, src, /obj/machinery/door/proc/auto_close)
|
||||
|
||||
/obj/machinery/door/proc/close_hatch_in(var/time = 5 SECONDS)
|
||||
if (hatch_task)
|
||||
// Update the time.
|
||||
hatch_task.trigger_task_in(time)
|
||||
else
|
||||
hatch_task = schedule_task_with_source_in(time, src, /obj/machinery/door/proc/auto_close_hatch)
|
||||
|
||||
/obj/machinery/door/proc/auto_close()
|
||||
close()
|
||||
close_task = null
|
||||
|
||||
/obj/machinery/door/proc/auto_close_hatch()
|
||||
close_hatch()
|
||||
hatch_task = null
|
||||
|
||||
/obj/machinery/door/proc/can_open()
|
||||
if(!density || operating || !ticker)
|
||||
@@ -489,19 +504,19 @@
|
||||
operating = 0
|
||||
|
||||
if(autoclose)
|
||||
close_door_at = next_close_time()
|
||||
close_door_in(next_close_time())
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/door/proc/next_close_time()
|
||||
return world.time + (normalspeed ? open_duration : 5)
|
||||
return (normalspeed ? open_duration : 5)
|
||||
|
||||
/obj/machinery/door/proc/close(var/forced = 0)
|
||||
if(!can_close(forced))
|
||||
return
|
||||
operating = 1
|
||||
|
||||
close_door_at = 0
|
||||
qdel(close_task)
|
||||
do_animate("closing")
|
||||
sleep(3)
|
||||
src.density = 1
|
||||
|
||||
@@ -118,14 +118,11 @@ Class Procs:
|
||||
..(l)
|
||||
if(d)
|
||||
set_dir(d)
|
||||
if(!machinery_sort_required && ticker)
|
||||
dd_insertObjectList(machines, src)
|
||||
else
|
||||
machines += src
|
||||
machinery_sort_required = 1
|
||||
|
||||
add_machine(src)
|
||||
|
||||
/obj/machinery/Destroy()
|
||||
machines -= src
|
||||
remove_machine(src)
|
||||
if(component_parts)
|
||||
for(var/atom/A in component_parts)
|
||||
if(A.loc == src) // If the components are inside the machine, delete them.
|
||||
@@ -141,7 +138,12 @@ Class Procs:
|
||||
if(!(use_power || idle_power_usage || active_power_usage))
|
||||
return PROCESS_KILL
|
||||
|
||||
return
|
||||
return M_NO_PROCESS
|
||||
|
||||
/obj/machinery/proc/get_process_type()
|
||||
. |= M_PROCESSES
|
||||
if (use_power || idle_power_usage || active_power_usage)
|
||||
. |= M_USES_POWER
|
||||
|
||||
/obj/machinery/emp_act(severity)
|
||||
if(use_power && stat == 0)
|
||||
|
||||
@@ -37,8 +37,7 @@ var/list/ai_status_emotions = list(
|
||||
return emotions
|
||||
|
||||
/proc/set_ai_status_displays(mob/user as mob)
|
||||
var/list/ai_emotions = get_ai_emotions(user.ckey)
|
||||
var/emote = input("Please, select a status!", "AI Status", null, null) in ai_emotions
|
||||
var/emote = get_ai_emotion(user)
|
||||
for (var/obj/machinery/M in machines) //change status
|
||||
if(istype(M, /obj/machinery/ai_status_display))
|
||||
var/obj/machinery/ai_status_display/AISD = M
|
||||
@@ -69,26 +68,24 @@ var/list/ai_status_emotions = list(
|
||||
var/emotion = "Neutral"
|
||||
|
||||
/obj/machinery/ai_status_display/attack_ai/(mob/user as mob)
|
||||
var/list/ai_emotions = get_ai_emotions(user.ckey)
|
||||
var/emote = input("Please, select a status!", "AI Status", null, null) in ai_emotions
|
||||
var/emote = get_ai_emotion(user)
|
||||
src.emotion = emote
|
||||
src.update()
|
||||
|
||||
/obj/machinery/ai_status_display/process()
|
||||
return
|
||||
/proc/get_ai_emotion(mob/user as mob)
|
||||
return input(user, "Please, select a status!", "AI Status", null, null) in get_ai_emotions(user.ckey)
|
||||
|
||||
/obj/machinery/ai_status_display/proc/update()
|
||||
if(mode==0) //Blank
|
||||
overlays.Cut()
|
||||
return
|
||||
switch (mode)
|
||||
if (0) // Blank
|
||||
overlays.Cut()
|
||||
|
||||
if(mode==1) // AI emoticon
|
||||
var/datum/ai_emotion/ai_emotion = ai_status_emotions[emotion]
|
||||
set_picture(ai_emotion.overlay)
|
||||
return
|
||||
if (1) // AI emoticon
|
||||
var/datum/ai_emotion/ai_emotion = ai_status_emotions[emotion]
|
||||
set_picture(ai_emotion.overlay)
|
||||
|
||||
if(mode==2) // BSOD
|
||||
set_picture("ai_bsod")
|
||||
return
|
||||
if (2) // BSOD
|
||||
set_picture("ai_bsod")
|
||||
|
||||
/obj/machinery/ai_status_display/proc/set_picture(var/state)
|
||||
picture_state = state
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
holographic_mobs -= C
|
||||
C.derez()
|
||||
|
||||
if(!..())
|
||||
if(inoperable())
|
||||
return
|
||||
if(active)
|
||||
use_power(item_power_usage * (holographic_objs.len + holographic_mobs.len))
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
known_sectors += R
|
||||
|
||||
/obj/machinery/computer/helm/process()
|
||||
..()
|
||||
if (autopilot && dx && dy)
|
||||
var/turf/T = locate(dx,dy,1)
|
||||
if(linked.loc == T)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//
|
||||
// consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light)
|
||||
|
||||
#define LIGHTING_POWER_FACTOR 40 //20W per unit luminosity
|
||||
|
||||
// status values shared between lighting fixtures and items
|
||||
#define LIGHT_OK 0
|
||||
@@ -249,7 +250,6 @@
|
||||
|
||||
// update the icon_state and luminosity of the light depending on its state
|
||||
/obj/machinery/light/proc/update(var/trigger = 1)
|
||||
|
||||
update_icon()
|
||||
if(on)
|
||||
if (check_update())
|
||||
@@ -269,6 +269,7 @@
|
||||
set_light(0)
|
||||
else
|
||||
use_power = 2
|
||||
active_power_usage = light_range * LIGHTING_POWER_FACTOR
|
||||
if (supports_nightmode && nightmode)
|
||||
set_light(night_brightness_range, night_brightness_power, brightness_color)
|
||||
else
|
||||
@@ -571,20 +572,6 @@
|
||||
broken()
|
||||
return
|
||||
|
||||
//blob effect
|
||||
|
||||
|
||||
// timed process
|
||||
// use power
|
||||
|
||||
#define LIGHTING_POWER_FACTOR 40 //20W per unit luminosity
|
||||
|
||||
|
||||
/obj/machinery/light/process()
|
||||
if(on)
|
||||
use_power(light_range * LIGHTING_POWER_FACTOR, LIGHT)
|
||||
|
||||
|
||||
// called when area power state changes
|
||||
/obj/machinery/light/power_change()
|
||||
spawn(10)
|
||||
|
||||
@@ -78,8 +78,7 @@
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/centrifuge/process()
|
||||
..()
|
||||
if (stat & (NOPOWER|BROKEN)) return
|
||||
if (inoperable()) return
|
||||
|
||||
if (curing)
|
||||
curing -= 1
|
||||
|
||||
@@ -66,9 +66,7 @@
|
||||
return
|
||||
|
||||
/obj/machinery/computer/curer/process()
|
||||
..()
|
||||
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
if (inoperable())
|
||||
return
|
||||
use_power(500)
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/diseasesplicer/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
if (inoperable())
|
||||
return
|
||||
|
||||
if(scanning)
|
||||
|
||||
Reference in New Issue
Block a user