From 8cd140e48a9423e9d7a5913142d8782a836fe9c7 Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Tue, 9 Aug 2016 06:55:00 -0400 Subject: [PATCH] Adds in Fast Processing --- code/_globalvars/lists/objects.dm | 2 + code/controllers/Processes/fast_process.dm | 32 ++++++ code/controllers/Processes/machinery.dm | 10 +- code/game/machinery/camera/presets.dm | 2 +- code/game/machinery/computer/pod.dm | 2 - code/game/machinery/doors/airlock_control.dm | 2 +- code/game/machinery/doors/brigdoors.dm | 2 +- code/game/machinery/machinery.dm | 19 ++-- code/game/machinery/recycler.dm | 113 ++++++++++--------- code/game/machinery/syndicatebeacon.dm | 2 +- code/modules/arcade/claw_game.dm | 3 +- code/modules/mining/equipment_locker.dm | 1 + code/modules/mining/machine_stacking.dm | 3 +- code/modules/mining/machine_unloading.dm | 6 +- code/modules/mining/mint.dm | 18 +-- code/modules/recycling/conveyor2.dm | 22 ++-- paradise.dme | 1 + 17 files changed, 145 insertions(+), 95 deletions(-) create mode 100644 code/controllers/Processes/fast_process.dm diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 9204d5ec524..1d9f173dcc5 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -15,6 +15,8 @@ var/global/list/crafting_recipes = list() //list of all crafting recipes var/global/list/all_areas = list() var/global/list/machines = list() +var/global/list/machine_processing = list() +var/global/list/fast_processing = list() var/global/list/processing_power_items = list() //items that ask to be called every cycle var/global/list/rcd_list = list() //list of Rapid Construction Devices. diff --git a/code/controllers/Processes/fast_process.dm b/code/controllers/Processes/fast_process.dm new file mode 100644 index 00000000000..0954c7894b8 --- /dev/null +++ b/code/controllers/Processes/fast_process.dm @@ -0,0 +1,32 @@ +var/datum/controller/process/fast_process/fast_processes + +/datum/controller/process/fast_process + var/list/currentrun = list() + +/datum/controller/process/fast_process/setup() + name = "fast processing" + schedule_interval = 2 //every 0.2 seconds + start_delay = 9 + fast_processes = src + log_startup_progress("Fast Processing starting up.") + +/datum/controller/process/fast_process/statProcess() + ..() + stat(null, "[fast_processing.len] fast machines") + +/datum/controller/process/fast_process/doWork() + src.currentrun = fast_processing.Copy() + //cache for sanic speed (lists are references anyways) + var/list/currentrun = src.currentrun + + while(currentrun.len) + var/obj/thing = currentrun[1] + currentrun.Cut(1, 2) + if(thing) + try + thing.process() + catch(var/exception/e) + catchException(e, thing) + else + catchBadType(thing) + fast_processing -= thing \ No newline at end of file diff --git a/code/controllers/Processes/machinery.dm b/code/controllers/Processes/machinery.dm index eddccf62293..85007e4f492 100644 --- a/code/controllers/Processes/machinery.dm +++ b/code/controllers/Processes/machinery.dm @@ -7,7 +7,7 @@ /datum/controller/process/machinery/statProcess() ..() - stat(null, "[machines.len] machines") + stat(null, "[machine_processing.len] machines") stat(null, "[powernets.len] powernets, [deferred_powernet_rebuilds.len] deferred") /datum/controller/process/machinery/doWork() @@ -19,15 +19,15 @@ /datum/controller/process/machinery/proc/process_sort() if(machinery_sort_required) machinery_sort_required = 0 - machines = dd_sortedObjectList(machines) + machine_processing = dd_sortedObjectList(machine_processing) /datum/controller/process/machinery/proc/process_machines() - for(last_object in machines) + for(last_object in machine_processing) var/obj/machinery/M = last_object if(istype(M) && isnull(M.gcDestroyed)) try if(M.process() == PROCESS_KILL) - machines.Remove(M) + machine_processing.Remove(M) continue if(M.use_power) @@ -36,7 +36,7 @@ catchException(e, M) else catchBadType(M) - machines -= M + machine_processing -= M SCHECK_EVERY(100) diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 5a36a900e61..d37aa23cf64 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -81,7 +81,7 @@ assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly)) setPowerUsage() // Add it to machines that process - machines |= src + machine_processing |= src /obj/machinery/camera/proc/setPowerUsage() var/mult = 1 diff --git a/code/game/machinery/computer/pod.dm b/code/game/machinery/computer/pod.dm index 84b467d2072..cc9ff3831eb 100644 --- a/code/game/machinery/computer/pod.dm +++ b/code/game/machinery/computer/pod.dm @@ -19,8 +19,6 @@ ..() spawn(5) driver_sync() - machines += src - return /obj/machinery/computer/pod/proc/driver_sync() diff --git a/code/game/machinery/doors/airlock_control.dm b/code/game/machinery/doors/airlock_control.dm index e33d3e4d9c4..af45540c40b 100644 --- a/code/game/machinery/doors/airlock_control.dm +++ b/code/game/machinery/doors/airlock_control.dm @@ -36,7 +36,7 @@ obj/machinery/door/airlock/proc/execute_current_command() if(command_completed(cur_command)) cur_command = null else - if(!(src in machines)) + if(!(src in machine_processing)) addAtProcessing() obj/machinery/door/airlock/proc/do_command(var/command) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index b0be899942d..f5cccf01735 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -98,7 +98,7 @@ // Set releasetime releasetime = world.timeofday + timetoset - if(!(src in machines)) + if(!(src in machine_processing)) addAtProcessing() for(var/obj/machinery/door/window/brigdoor/door in targets) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 17552c3fe1c..518304fda5f 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -117,6 +117,7 @@ Class Procs: var/use_log = list() var/list/settagwhitelist = list()//WHITELIST OF VARIABLES THAT THE set_tag HREF CAN MODIFY, DON'T PUT SHIT YOU DON'T NEED ON HERE, AND IF YOU'RE GONNA USE set_tag (format_tag() proc), ADD TO THIS LIST. atom_say_verb = "beeps" + var/speed_process = 0 // Process as fast as possible? /obj/machinery/initialize() addAtProcessing() @@ -128,17 +129,17 @@ Class Procs: myArea = get_area_master(src) machines += src - -/obj/machinery/proc/removeAtProcessing() - if(myArea) - myArea = null - - machines -= src + if(!speed_process) + machine_processing += src + else + fast_processing += src /obj/machinery/Destroy() - if(src in machines) - removeAtProcessing() - + if(myArea) + myArea = null + fast_processing -= src + machine_processing -= src + machines -= src return ..() /obj/machinery/proc/locate_machinery() diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm index c7ddfc84c38..4cdc3494927 100644 --- a/code/game/machinery/recycler.dm +++ b/code/game/machinery/recycler.dm @@ -2,22 +2,23 @@ var/const/SAFETY_COOLDOWN = 100 /obj/machinery/recycler name = "recycler" - desc = "A large crushing machine which is used to recycle small items ineffeciently; there are lights on the side of it." + desc = "A large crushing machine used to recycle small items inefficiently. There are lights on the side." icon = 'icons/obj/recycling.dmi' icon_state = "grinder-o0" layer = MOB_LAYER+1 // Overhead anchored = 1 density = 1 - var/safety_mode = 0 // Temporality stops the machine if it detects a mob - var/grinding = 0 + var/safety_mode = 0 // Temporarily stops machine if it detects a mob var/icon_name = "grinder-o" var/blood = 0 var/eat_dir = WEST var/amount_produced = 1 var/datum/material_container/materials + var/crush_damage = 1000 + var/eat_victim_items = 1 + var/item_recycle_sound = 'sound/machines/recycler.ogg' /obj/machinery/recycler/New() - // On us ..() component_parts = list() component_parts += new /obj/item/weapon/circuitboard/recycler(null) @@ -56,8 +57,6 @@ var/const/SAFETY_COOLDOWN = 100 /obj/machinery/recycler/attackby(obj/item/I, mob/user, params) if(default_deconstruction_screwdriver(user, "grinder-oOpen", "grinder-o0", I)) - if(!panel_open) - update_icon() return if(exchange_parts(user, I)) @@ -69,7 +68,6 @@ var/const/SAFETY_COOLDOWN = 100 default_deconstruction_crowbar(I) ..() add_fingerprint(user) - return /obj/machinery/recycler/emag_act(mob/user) if(!emagged) @@ -77,8 +75,8 @@ var/const/SAFETY_COOLDOWN = 100 if(safety_mode) safety_mode = 0 update_icon() - playsound(src.loc, "sparks", 75, 1, -1) - to_chat(user, "You use the cryptographic sequencer on the [src.name].") + playsound(loc, "sparks", 75, 1, -1) + to_chat(user, "You use the cryptographic sequencer on the [name].") /obj/machinery/recycler/update_icon() ..() @@ -88,48 +86,51 @@ var/const/SAFETY_COOLDOWN = 100 icon_state = icon_name + "[is_powered]" + "[(blood ? "bld" : "")]" // add the blood tag at the end // This is purely for admin possession !FUN!. -/obj/machinery/recycler/Bump(var/atom/movable/AM) +/obj/machinery/recycler/Bump(atom/movable/AM) ..() if(AM) Bumped(AM) -/obj/machinery/recycler/Bumped(var/atom/movable/AM) +/obj/machinery/recycler/Bumped(atom/movable/AM) if(stat & (BROKEN|NOPOWER)) return - if(safety_mode) - return if(!anchored) return - // If we're not already grinding something. - if(!grinding) - grinding = 1 - spawn(1) - grinding = 0 - else + if(safety_mode) return var/move_dir = get_dir(loc, AM.loc) if(move_dir == eat_dir) + eat(AM) + +/obj/machinery/recycler/proc/eat(atom/AM0, sound = 1) + var/list/to_eat = list(AM0) + if(istype(AM0, /obj/item)) + to_eat += AM0.GetAllContents() + var/items_recycled = 0 + + for(var/i in to_eat) + var/atom/movable/AM = i if(isliving(AM)) if(emagged) - eat(AM) + crush_living(AM) else - stop(AM) + emergency_stop(AM) else if(istype(AM, /obj/item)) - recycle(AM) - else // Can't recycle - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) - AM.loc = src.loc + recycle_item(AM) + items_recycled++ + else + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) + AM.loc = loc -/obj/machinery/recycler/proc/recycle(obj/item/I, sound = 1) - I.loc = src.loc - if(!istype(I)) - return + if(items_recycled && sound) + playsound(loc, item_recycle_sound, 100, 0) + +/obj/machinery/recycler/proc/recycle_item(obj/item/I) + I.loc = loc - if(sound) - playsound(src.loc, 'sound/machines/recycler.ogg', 100, 0) var/material_amount = materials.get_item_material_amount(I) if(!material_amount) qdel(I) @@ -139,25 +140,26 @@ var/const/SAFETY_COOLDOWN = 100 materials.retrieve_all() -/obj/machinery/recycler/proc/stop(var/mob/living/L) - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) +/obj/machinery/recycler/proc/emergency_stop(mob/living/L) + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) safety_mode = 1 update_icon() - L.loc = src.loc + L.loc = loc + addtimer(src, "reboot", SAFETY_COOLDOWN) - spawn(SAFETY_COOLDOWN) - playsound(src.loc, 'sound/machines/ping.ogg', 50, 0) - safety_mode = 0 - update_icon() +/obj/machinery/recycler/proc/reboot() + playsound(loc, 'sound/machines/ping.ogg', 50, 0) + safety_mode = 0 + update_icon() -/obj/machinery/recycler/proc/eat(var/mob/living/L) +/obj/machinery/recycler/proc/crush_living(mob/living/L) - L.loc = src.loc + L.loc = loc if(issilicon(L)) - playsound(src.loc, 'sound/machines/recycler.ogg', 100, 0) + playsound(loc, 'sound/items/Welder.ogg', 50, 1) else - playsound(src.loc, 'sound/effects/splat.ogg', 50, 1) + playsound(loc, 'sound/effects/splat.ogg', 50, 1) var/gib = 1 // By default, the emagged recycler will gib all non-carbons. (human simple animal mobs don't count) @@ -171,10 +173,11 @@ var/const/SAFETY_COOLDOWN = 100 blood = 1 update_icon() - // Remove and recycle the equipped items. - for(var/obj/item/I in L.get_equipped_items()) - if(L.unEquip(I)) - recycle(I, 0) + // Remove and recycle the equipped items + if(eat_victim_items) + for(var/obj/item/I in L.get_equipped_items()) + if(L.unEquip(I)) + eat(I, sound = 0) // Instantly lie down, also go unconscious from the pain, before you die. L.Paralyse(5) @@ -183,7 +186,8 @@ var/const/SAFETY_COOLDOWN = 100 if(gib || emagged == 2) L.gib() else if(emagged == 1) - L.adjustBruteLoss(1000) + L.adjustBruteLoss(crush_damage) + /obj/machinery/recycler/verb/rotate() set name = "Rotate Clockwise" @@ -192,9 +196,9 @@ var/const/SAFETY_COOLDOWN = 100 var/mob/living/user = usr - if(usr.stat || !usr.canmove || usr.restrained()) + if(usr.incapacitated()) return - if(src.anchored) + if(anchored) to_chat(usr, "[src] is fastened to the floor!") return 0 eat_dir = turn(eat_dir, 270) @@ -208,15 +212,22 @@ var/const/SAFETY_COOLDOWN = 100 var/mob/living/user = usr - if(usr.stat || !usr.canmove || usr.restrained()) + if(usr.incapacitated()) return - if(src.anchored) + if(anchored) to_chat(usr, "[src] is fastened to the floor!") return 0 eat_dir = turn(eat_dir, 90) to_chat(user, "[src] will now accept items from [dir2text(eat_dir)].") return 1 + +/obj/machinery/recycler/deathtrap + name = "dangerous old crusher" + emagged = 1 + crush_damage = 120 + + /obj/item/weapon/paper/recycler name = "paper - 'garbage duty instructions'" info = "

New Assignment

You have been assigned to collect garbage from trash bins, located around the station. The crewmembers will put their trash into it and you will collect the said trash.

There is a recycling machine near your closet, inside maintenance; use it to recycle the trash for a small chance to get useful minerals. Then deliver these minerals to cargo or engineering. You are our last hope for a clean station, do not screw this up!" diff --git a/code/game/machinery/syndicatebeacon.dm b/code/game/machinery/syndicatebeacon.dm index 7790cf10ebc..0f702be46b0 100644 --- a/code/game/machinery/syndicatebeacon.dm +++ b/code/game/machinery/syndicatebeacon.dm @@ -133,7 +133,7 @@ singulo.target = src icon_state = "[icontype]1" active = 1 - machines |= src + machine_processing |= src if(user) to_chat(user, "You activate the beacon.") diff --git a/code/modules/arcade/claw_game.dm b/code/modules/arcade/claw_game.dm index 9d423383b08..e0fa547b5fc 100644 --- a/code/modules/arcade/claw_game.dm +++ b/code/modules/arcade/claw_game.dm @@ -19,8 +19,7 @@ 'icons/obj/arcade_images/prizeorbs.png') /obj/machinery/arcade/claw/New() - src.addAtProcessing() - + ..() machine_image = pick("_1", "_2") update_icon() diff --git a/code/modules/mining/equipment_locker.dm b/code/modules/mining/equipment_locker.dm index faf11c70825..134a6708265 100644 --- a/code/modules/mining/equipment_locker.dm +++ b/code/modules/mining/equipment_locker.dm @@ -21,6 +21,7 @@ var/point_upgrade = 1 var/list/ore_values = list(("sand" = 1), ("iron" = 1), ("plasma" = 15), ("silver" = 16), ("gold" = 18), ("uranium" = 30), ("diamond" = 50), ("bluespace crystal" = 50), ("bananium" = 60), ("tranquillite" = 60)) var/list/supply_consoles = list("Science", "Robotics", "Research Director's Desk", "Mechanic", "Engineering" = list("metal", "glass", "plasma"), "Chief Engineer's Desk" = list("metal", "glass", "plasma"), "Atmospherics" = list("metal", "glass", "plasma"), "Bar" = list("uranium", "plasma"), "Virology" = list("plasma", "uranium", "gold")) + speed_process = 1 /obj/machinery/mineral/ore_redemption/New() ..() diff --git a/code/modules/mining/machine_stacking.dm b/code/modules/mining/machine_stacking.dm index 44d7b037869..20d6a1b984a 100644 --- a/code/modules/mining/machine_stacking.dm +++ b/code/modules/mining/machine_stacking.dm @@ -69,6 +69,7 @@ var/stack_amt = 50; //ammount to stack before releassing input_dir = EAST output_dir = WEST + speed_process = 1 /obj/machinery/mineral/stacking_machine/proc/process_sheet(obj/item/stack/sheet/inp) if(!(inp.type in stack_list)) //It's the first of this sheet added @@ -89,4 +90,4 @@ if(T) for(var/obj/item/stack/sheet/S in T) process_sheet(S) - + CHECK_TICK \ No newline at end of file diff --git a/code/modules/mining/machine_unloading.dm b/code/modules/mining/machine_unloading.dm index 5214c8caec8..a5a30493faa 100644 --- a/code/modules/mining/machine_unloading.dm +++ b/code/modules/mining/machine_unloading.dm @@ -9,6 +9,7 @@ anchored = 1.0 input_dir = WEST output_dir = EAST + speed_process = 1 /obj/machinery/mineral/unloading_machine/process() var/turf/T = get_step(src,input_dir) @@ -21,8 +22,11 @@ limit++ if(limit>=10) return + CHECK_TICK + CHECK_TICK for(var/obj/item/I in T) unload_mineral(I) limit++ if(limit>=10) - return \ No newline at end of file + return + CHECK_TICK \ No newline at end of file diff --git a/code/modules/mining/mint.dm b/code/modules/mining/mint.dm index 02b69a160d7..ff78dfff274 100644 --- a/code/modules/mining/mint.dm +++ b/code/modules/mining/mint.dm @@ -21,6 +21,7 @@ var/processing = 0 var/chosen = "metal" //which material will be used to make coins var/coinsToProduce = 10 + speed_process = 1 /obj/machinery/mineral/mint/process() var/turf/T = get_step(src,input_dir) @@ -28,29 +29,28 @@ for(var/obj/item/stack/sheet/O in T) if(istype(O, /obj/item/stack/sheet/mineral/gold)) amt_gold += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/silver)) amt_silver += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/diamond)) amt_diamond += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/plasma)) amt_plasma += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/uranium)) amt_uranium += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/metal)) amt_iron += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/bananium)) amt_clown += 100 * O.amount - O.loc = null + qdel(O) if(istype(O, /obj/item/stack/sheet/mineral/tranquillite)) amt_mime += 100 * O.amount - O.loc = null - return + qdel(O) /obj/machinery/mineral/mint/attack_hand(user as mob) //TODO: Adamantine coins! -Durandan diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index b093048d5e5..6ff39d21b0d 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -17,6 +17,7 @@ var/list/affecting // the list of all items that will be moved this ptick var/id = "" // the control ID - must match controller ID var/verted = 1 // set to -1 to have the conveyour belt be inverted, so you can use the other corner icons + speed_process = 1 /obj/machinery/conveyor/centcom_auto id = "round_end_belt" @@ -105,15 +106,12 @@ use_power(100) affecting = loc.contents - src // moved items will be all in loc - spawn(1) // slight delay to prevent infinite propagation due to map order //TODO: please no spawn() in process(). It's a very bad idea - var/items_moved = 0 - for(var/atom/movable/A in affecting) - if(!A.anchored) - if(A.loc == src.loc) // prevents the object from being affected if it's not currently here. - step(A,movedir) - items_moved++ - if(items_moved >= 10) - break + sleep(1) + for(var/atom/movable/A in affecting) + if(!A.anchored) + if(A.loc == loc) // prevents the object from being affected if it's not currently here. + step(A,movedir) + CHECK_TICK // attack with item, place item on conveyor /obj/machinery/conveyor/attackby(var/obj/item/I, mob/user, params) @@ -183,7 +181,7 @@ var/list/conveyors // the list of converyors that are controlled by this switch anchored = 1 - + speed_process = 1 /obj/machinery/conveyor_switch/New() @@ -218,6 +216,7 @@ for(var/obj/machinery/conveyor/C in conveyors) C.operating = position C.setmove() + CHECK_TICK // attack with hand, switch position /obj/machinery/conveyor_switch/attack_hand(mob/user) @@ -241,10 +240,11 @@ update() // find any switches with same id as this one, and set their positions to match us - for(var/obj/machinery/conveyor_switch/S in world) + for(var/obj/machinery/conveyor_switch/S in machines) if(S.id == src.id) S.position = position S.update() + CHECK_TICK /obj/machinery/conveyor_switch/oneway var/convdir = 1 //Set to 1 or -1 depending on which way you want the convayor to go. (In other words keep at 1 and set the proper dir on the belts.) diff --git a/paradise.dme b/paradise.dme index c346f801178..dadf514ca98 100644 --- a/paradise.dme +++ b/paradise.dme @@ -167,6 +167,7 @@ #include "code\controllers\Processes\alarm.dm" #include "code\controllers\Processes\diseases.dm" #include "code\controllers\Processes\event.dm" +#include "code\controllers\Processes\fast_process.dm" #include "code\controllers\Processes\fires.dm" #include "code\controllers\Processes\garbage.dm" #include "code\controllers\Processes\inactivity.dm"