From 7c07863179658435ea34e85c77a95443eb5aee7a Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Mon, 5 Oct 2020 13:29:53 -0700 Subject: [PATCH 1/2] fix --- code/controllers/subsystem/input.dm | 12 ++++---- code/controllers/subsystem/npcpool.dm | 29 ++++++++++++++----- code/modules/keybindings/bindings_client.dm | 2 ++ code/modules/keybindings/setup.dm | 3 ++ code/modules/mob/living/say.dm | 1 + .../mob/living/simple_animal/bot/ed209bot.dm | 4 +-- .../living/simple_animal/hostile/wizard.dm | 3 ++ .../mob/living/simple_animal/parrot.dm | 15 ++++++---- 8 files changed, 47 insertions(+), 22 deletions(-) diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index 32936af9e9..bc3f6cf51b 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -64,10 +64,10 @@ SUBSYSTEM_DEF(input) // Misc macroset_classic_input["Tab"] = "\".winset \\\"mainwindow.macro=[SKIN_MACROSET_CLASSIC_HOTKEYS] map.focus=true input.background-color=[COLOR_INPUT_DISABLED]\\\"\"" macroset_classic_input["Escape"] = "\".winset \\\"input.text=\\\"\\\"\\\"\"" - + // FINALLY, WE CAN DO SOMETHING MORE NORMAL FOR THE SNOWFLAKE-BUT-LESS KEYSET. - - // HAHA - SIKE. Because of BYOND weirdness (tl;dr not specifically binding this way results in potentially duplicate chatboxes when + + // HAHA - SIKE. Because of BYOND weirdness (tl;dr not specifically binding this way results in potentially duplicate chatboxes when // conflicts occur with something like say indicator vs say), we're going to snowflake this anyways var/list/hard_binds = list( "O" = "ooc", @@ -80,7 +80,7 @@ SUBSYSTEM_DEF(input) for(var/key in hard_binds) for(var/modifier in anti_collision_modifiers) hard_bind_anti_collision["[modifier]+[key]"] = ".NONSENSICAL_VERB_THAT_DOES_NOTHING" - + macroset_classic_hotkey = list( "Any" = "\"KeyDown \[\[*\]\]\"", "Any+UP" = "\"KeyUp \[\[*\]\]\"", @@ -88,7 +88,7 @@ SUBSYSTEM_DEF(input) "Escape" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", "Back" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", ) - + macroset_classic_hotkey |= hard_binds macroset_classic_hotkey |= hard_bind_anti_collision @@ -100,7 +100,7 @@ SUBSYSTEM_DEF(input) "Escape" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", "Back" = "\".winset \\\"input.text=\\\"\\\"\\\"\"", ) - + macroset_hotkey |= hard_binds macroset_hotkey |= hard_bind_anti_collision diff --git a/code/controllers/subsystem/npcpool.dm b/code/controllers/subsystem/npcpool.dm index c67deaede1..c20820c092 100644 --- a/code/controllers/subsystem/npcpool.dm +++ b/code/controllers/subsystem/npcpool.dm @@ -5,6 +5,10 @@ SUBSYSTEM_DEF(npcpool) runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() + /// catches sleeping + var/invoking = FALSE + /// Invoke start time + var/invoke_start = 0 /datum/controller/subsystem/npcpool/stat_entry(msg) var/list/activelist = GLOB.simple_animals[AI_ON] @@ -12,7 +16,6 @@ SUBSYSTEM_DEF(npcpool) return ..() /datum/controller/subsystem/npcpool/fire(resumed = FALSE) - if (!resumed) var/list/activelist = GLOB.simple_animals[AI_ON] src.currentrun = activelist.Copy() @@ -24,12 +27,22 @@ SUBSYSTEM_DEF(npcpool) var/mob/living/simple_animal/SA = currentrun[currentrun.len] --currentrun.len - if(!SA.ckey && !SA.mob_transforming) - if(SA.stat != DEAD) - SA.handle_automated_movement() - if(SA.stat != DEAD) - SA.handle_automated_action() - if(SA.stat != DEAD) - SA.handle_automated_speech() + invoking = TRUE + invoke_start = world.time + INVOKE_ASYNC(src, .proc/invoke_process, SA) + if(invoking) + stack_trace("WARNING: [SA] ([SA.type]) slept during NPCPool processing.") + invoking = FALSE + if (MC_TICK_CHECK) return + +/datum/controller/subsystem/npcpool/proc/invoke_process(mob/living/simple_animal/SA) + if(!SA.ckey && !SA.mob_transforming) + if(SA.stat != DEAD) + SA.handle_automated_movement() + if(SA.stat != DEAD) + SA.handle_automated_action() + if(SA.stat != DEAD) + SA.handle_automated_speech() + invoking = FALSE diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm index 3a47cd2315..3d12f89cfe 100644 --- a/code/modules/keybindings/bindings_client.dm +++ b/code/modules/keybindings/bindings_client.dm @@ -1,6 +1,7 @@ // Clients aren't datums so we have to define these procs indpendently. // These verbs are called for all key press and release events /client/verb/keyDown(_key as text) + SHOULD_NOT_SLEEP(TRUE) set instant = TRUE set hidden = TRUE @@ -83,6 +84,7 @@ keyUp("[key]") /client/verb/keyUp(_key as text) + SHOULD_NOT_SLEEP(TRUE) set instant = TRUE set hidden = TRUE diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index a53820b5d2..e577fe61b0 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -1,10 +1,13 @@ /datum/proc/key_down(key, client/user) // Called when a key is pressed down initially + SHOULD_NOT_SLEEP(TRUE) return /datum/proc/key_up(key, client/user) // Called when a key is released + SHOULD_NOT_SLEEP(TRUE) return /datum/proc/keyLoop(client/user) // Called once every frame + SHOULD_NOT_SLEEP(TRUE) set waitfor = FALSE return diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 66c2cd96c7..4c03e74d70 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -82,6 +82,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list( return new_msg /mob/living/say(message, bubble_type,var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null) + set waitfor = FALSE var/static/list/crit_allowed_modes = list(MODE_WHISPER = TRUE, MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) var/static/list/unconscious_allowed_modes = list(MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE) var/talk_key = get_key(message) diff --git a/code/modules/mob/living/simple_animal/bot/ed209bot.dm b/code/modules/mob/living/simple_animal/bot/ed209bot.dm index 3f28fd6e01..8375d621d4 100644 --- a/code/modules/mob/living/simple_animal/bot/ed209bot.dm +++ b/code/modules/mob/living/simple_animal/bot/ed209bot.dm @@ -236,7 +236,7 @@ Auto Patrol[]"}, if(targets.len>0) var/mob/living/carbon/t = pick(targets) if((t.stat!=2) && (t.lying != 1) && (!t.handcuffed)) //we don't shoot people who are dead, cuffed or lying down. - shootAt(t) + INVOKE_ASYNC(src, .proc/shootAt, t) switch(mode) if(BOT_IDLE) // idle @@ -254,7 +254,7 @@ Auto Patrol[]"}, if(target) // make sure target exists if(Adjacent(target) && isturf(target.loc)) // if right next to perp - stun_attack(target) + INVOKE_ASYNC(src, .proc/stun_attack, target) mode = BOT_PREP_ARREST anchored = TRUE diff --git a/code/modules/mob/living/simple_animal/hostile/wizard.dm b/code/modules/mob/living/simple_animal/hostile/wizard.dm index b3523fc42c..59bd67e42a 100644 --- a/code/modules/mob/living/simple_animal/hostile/wizard.dm +++ b/code/modules/mob/living/simple_animal/hostile/wizard.dm @@ -62,6 +62,9 @@ /mob/living/simple_animal/hostile/wizard/handle_automated_action() . = ..() + INVOKE_ASYNC(src, .proc/AutomatedCast) + +/mob/living/simple_animal/hostile/wizard/proc/AutomatedCast() if(target && next_cast < world.time) if((get_dir(src,target) in list(SOUTH,EAST,WEST,NORTH)) && fireball.cast_check(0,src)) //Lined up for fireball src.setDir(get_dir(src,target)) diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index 3ca29b6746..1ff7e2f799 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -436,12 +436,7 @@ newspeak.Add(possible_phrase) speak = newspeak - //Search for item to steal - parrot_interest = search_for_item() - if(parrot_interest) - emote("me", EMOTE_VISIBLE, "looks in [parrot_interest]'s direction and takes flight.") - parrot_state = PARROT_SWOOP | PARROT_STEAL - icon_state = icon_living + INVOKE_ASYNC(src, .proc/attempt_item_theft) return //-----WANDERING - This is basically a 'I dont know what to do yet' state @@ -620,6 +615,14 @@ parrot_lastmove = src.loc return 0 +/mob/living/simple_animal/parrot/proc/attempt_item_theft() + //Search for item to steal + search_for_item() + if(parrot_interest) + emote("me", EMOTE_VISIBLE, "looks in [parrot_interest]'s direction and takes flight.") + parrot_state = PARROT_SWOOP | PARROT_STEAL + icon_state = icon_living + /mob/living/simple_animal/parrot/proc/search_for_item() var/item for(var/atom/movable/AM in view(src)) From a428311696c8c7c9925f929b126fdbac80bbe8e0 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Mon, 5 Oct 2020 22:05:23 -0700 Subject: [PATCH 2/2] Update setup.dm --- code/modules/keybindings/setup.dm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index e577fe61b0..47dbfd855f 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -1,15 +1,11 @@ /datum/proc/key_down(key, client/user) // Called when a key is pressed down initially SHOULD_NOT_SLEEP(TRUE) - return /datum/proc/key_up(key, client/user) // Called when a key is released SHOULD_NOT_SLEEP(TRUE) - return /datum/proc/keyLoop(client/user) // Called once every frame SHOULD_NOT_SLEEP(TRUE) - set waitfor = FALSE - return // removes all the existing macros /client/proc/erase_all_macros()