From d9f4153a4102eb8624f5fcd14027c80d3e55674a Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Tue, 19 Oct 2021 14:52:59 +0200 Subject: [PATCH] clickon signal procs cleanup (fixes inability to examine things in certain situations). (#62180) Title. The clickon proc calls params2list only after the component signal was sent notwhitstanding clickon comsig procs also needing to access these parameters in order to work properly, which means every one of these comsig procs has its own params2list(params) call. This problem isn't exlusive to these comsig procs. For some reason the params text string is passed down to the melee click chain, afterattack and afterattack_secondary instead of the params/modifiers list... buuut we'll get there later. TL;DR params2list is being called more times than necessary because of a suboptimal old code. Another issue: Some of these comsig procs ignore parameters such as shift, which is used to examinate things and access popup menus, alt, ctrl and/or middle mouse button. This is the case of the honorbound mutation datum, shy and shy in room components, mechas and the clown car. This is of course also getting fixed. --- code/_onclick/click.dm | 6 ++++-- code/datums/components/shy.dm | 4 +++- code/datums/components/shy_in_room.dm | 4 +++- code/datums/components/tackle.dm | 8 ++++---- code/datums/mutations/holy_mutation/honorbound.dm | 10 ++++++---- code/datums/mutations/hulk.dm | 3 +-- code/modules/vehicles/cars/clowncar.dm | 7 +++++-- code/modules/vehicles/mecha/_mecha.dm | 9 +++++---- .../vehicles/mecha/equipment/mecha_equipment.dm | 2 +- .../vehicles/mecha/equipment/tools/medical_tools.dm | 6 +++--- .../vehicles/mecha/equipment/tools/mining_tools.dm | 2 +- .../vehicles/mecha/equipment/tools/other_tools.dm | 8 ++++---- .../vehicles/mecha/equipment/tools/work_tools.dm | 8 +++----- .../vehicles/mecha/equipment/weapons/weapons.dm | 11 +++++------ code/modules/wiremod/components/action/mmi.dm | 3 +-- 15 files changed, 49 insertions(+), 42 deletions(-) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index a3608069792..e59c76cf8b6 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -75,9 +75,11 @@ if(notransform) return - if(SEND_SIGNAL(src, COMSIG_MOB_CLICKON, A, params) & COMSIG_MOB_CANCEL_CLICKON) - return var/list/modifiers = params2list(params) + + if(SEND_SIGNAL(src, COMSIG_MOB_CLICKON, A, modifiers) & COMSIG_MOB_CANCEL_CLICKON) + return + if(LAZYACCESS(modifiers, SHIFT_CLICK)) if(LAZYACCESS(modifiers, MIDDLE_CLICK)) ShiftMiddleClickOn(A) diff --git a/code/datums/components/shy.dm b/code/datums/components/shy.dm index 819c9b00caa..b7587063e86 100644 --- a/code/datums/components/shy.dm +++ b/code/datums/components/shy.dm @@ -79,8 +79,10 @@ -/datum/component/shy/proc/on_clickon(datum/source, atom/target, params) +/datum/component/shy/proc/on_clickon(datum/source, atom/target, list/modifiers) SIGNAL_HANDLER + if(modifiers[SHIFT_CLICK]) //let them examine their surroundings. + return return is_shy(target) && COMSIG_MOB_CANCEL_CLICKON /datum/component/shy/proc/on_try_pull(datum/source, atom/movable/target, force) diff --git a/code/datums/components/shy_in_room.dm b/code/datums/components/shy_in_room.dm index 23b3add2d3d..acad303a1fc 100644 --- a/code/datums/components/shy_in_room.dm +++ b/code/datums/components/shy_in_room.dm @@ -52,8 +52,10 @@ to_chat(owner, span_warning("[replacetext(message, "%ROOM", room)]")) return TRUE -/datum/component/shy_in_room/proc/on_clickon(datum/source, atom/target, params) +/datum/component/shy_in_room/proc/on_clickon(datum/source, atom/target, list/modifiers) SIGNAL_HANDLER + if(modifiers[SHIFT_CLICK]) //let them examine their surroundings. + return return is_shy(target) && COMSIG_MOB_CANCEL_CLICKON /datum/component/shy_in_room/proc/on_try_pull(datum/source, atom/movable/target, force) diff --git a/code/datums/components/tackle.dm b/code/datums/components/tackle.dm index 22b207d75b3..bb37aad7901 100644 --- a/code/datums/components/tackle.dm +++ b/code/datums/components/tackle.dm @@ -68,9 +68,12 @@ tackle.thrower = user ///See if we can tackle or not. If we can, leap! -/datum/component/tackler/proc/checkTackle(mob/living/carbon/user, atom/A, params) +/datum/component/tackler/proc/checkTackle(mob/living/carbon/user, atom/A, list/modifiers) SIGNAL_HANDLER + if(modifiers[ALT_CLICK] || modifiers[SHIFT_CLICK] || modifiers[CTRL_CLICK] || modifiers[MIDDLE_CLICK]) + return + if(!user.throw_mode || user.get_active_held_item() || user.pulling || user.buckled || user.incapacitated()) return @@ -99,9 +102,6 @@ user.face_atom(A) - var/list/modifiers = params2list(params) - if(LAZYACCESS(modifiers, ALT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, MIDDLE_CLICK)) - return tackling = TRUE RegisterSignal(user, COMSIG_MOVABLE_MOVED, .proc/checkObstacle) diff --git a/code/datums/mutations/holy_mutation/honorbound.dm b/code/datums/mutations/holy_mutation/honorbound.dm index 0b97be7e468..de3e2e188ea 100644 --- a/code/datums/mutations/holy_mutation/honorbound.dm +++ b/code/datums/mutations/holy_mutation/honorbound.dm @@ -48,15 +48,17 @@ . = ..() /// Signal to see if the mutation allows us to attack a target -/datum/mutation/human/honorbound/proc/attack_honor(mob/living/carbon/human/honorbound, atom/clickingon, params) +/datum/mutation/human/honorbound/proc/attack_honor(mob/living/carbon/human/honorbound, atom/clickingon, list/modifiers) SIGNAL_HANDLER - var/obj/item/weapon = honorbound.get_active_held_item() - var/list/modifiers = params2list(params) - + if(modifiers[ALT_CLICK] || modifiers[SHIFT_CLICK] || modifiers[CTRL_CLICK] || modifiers[MIDDLE_CLICK]) + return if(!isliving(clickingon)) return + var/mob/living/clickedmob = clickingon + var/obj/item/weapon = honorbound.get_active_held_item() + if(!honorbound.DirectAccess(clickedmob) && !isgun(weapon)) return if(weapon?.item_flags & NOBLUDGEON) diff --git a/code/datums/mutations/hulk.dm b/code/datums/mutations/hulk.dm index 3e144826f50..8db638359c1 100644 --- a/code/datums/mutations/hulk.dm +++ b/code/datums/mutations/hulk.dm @@ -97,11 +97,10 @@ #define HULK_TAILTHROW_STEPS 28 /// Run a barrage of checks to see if any given click is actually able to swing -/datum/mutation/human/hulk/proc/check_swing(mob/living/carbon/human/user, atom/clicked_atom, params) +/datum/mutation/human/hulk/proc/check_swing(mob/living/carbon/human/user, atom/clicked_atom, list/modifiers) SIGNAL_HANDLER /// Basically, we only proceed if we're in throw mode with a tailed carbon in our grasp with at least a neck grab and we're not restrained in some way - var/list/modifiers = params2list(params) if(LAZYACCESS(modifiers, ALT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, MIDDLE_CLICK)) return if(!user.throw_mode || user.get_active_held_item() || user.zone_selected != BODY_ZONE_PRECISE_GROIN) diff --git a/code/modules/vehicles/cars/clowncar.dm b/code/modules/vehicles/cars/clowncar.dm index 00deb71ee39..b96d8ce255d 100644 --- a/code/modules/vehicles/cars/clowncar.dm +++ b/code/modules/vehicles/cars/clowncar.dm @@ -219,10 +219,13 @@ driver.update_mouse_pointer() ///Fires the cannon where the user clicks -/obj/vehicle/sealed/car/clowncar/proc/fire_cannon_at(mob/user, atom/A, params) +/obj/vehicle/sealed/car/clowncar/proc/fire_cannon_at(mob/user, atom/A, list/modifiers) SIGNAL_HANDLER if(cannonmode != CLOWN_CANNON_READY || !length(return_controllers_with_flag(VEHICLE_CONTROL_KIDNAPPED))) - return NONE + return + //The driver can still examine things and interact with his inventory. + if(modifiers[SHIFT_CLICK] || !isturf(A.loc)) + return var/mob/living/unlucky_sod = pick(return_controllers_with_flag(VEHICLE_CONTROL_KIDNAPPED)) mob_exit(unlucky_sod, TRUE) flick("clowncar_recoil", src) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 8dfe8b0560d..22b1540feb1 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -520,13 +520,14 @@ //////////////////////////// ///Called when a driver clicks somewhere. Handles everything like equipment, punches, etc. -/obj/vehicle/sealed/mecha/proc/on_mouseclick(mob/user, atom/target, params) +/obj/vehicle/sealed/mecha/proc/on_mouseclick(mob/user, atom/target, list/modifiers) SIGNAL_HANDLER + if(modifiers[SHIFT_CLICK]) //Allows things to be examined. + return if(!isturf(target) && !isturf(target.loc)) // Prevents inventory from being drilled return if(completely_disabled || is_currently_ejecting || (mecha_flags & CANNOT_INTERACT)) return - var/list/modifiers = params2list(params) if(isAI(user) == !LAZYACCESS(modifiers, MIDDLE_CLICK))//BASICALLY if a human uses MMB, or an AI doesn't, then do nothing. return if(phasing) @@ -557,7 +558,7 @@ return if(SEND_SIGNAL(src, COMSIG_MECHA_EQUIPMENT_CLICK, livinguser, target) & COMPONENT_CANCEL_EQUIPMENT_CLICK) return - INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, params) + INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, modifiers) return if((selected.range & MECHA_MELEE) && Adjacent(target)) if(isliving(target) && selected.harmful && HAS_TRAIT(livinguser, TRAIT_PACIFISM)) @@ -565,7 +566,7 @@ return if(SEND_SIGNAL(src, COMSIG_MECHA_EQUIPMENT_CLICK, livinguser, target) & COMPONENT_CANCEL_EQUIPMENT_CLICK) return - INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, params) + INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, modifiers) return if(!(livinguser in return_controllers_with_flag(VEHICLE_CONTROL_MELEE))) to_chat(livinguser, span_warning("You're in the wrong seat to interact with your hands.")) diff --git a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm index 1adaade6a22..7747e20d35b 100644 --- a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm +++ b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm @@ -90,7 +90,7 @@ return FALSE return TRUE -/obj/item/mecha_parts/mecha_equipment/proc/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/proc/action(mob/source, atom/target, list/modifiers) TIMER_COOLDOWN_START(chassis, COOLDOWN_MECHA_EQUIPMENT, equip_cooldown)//Cooldown is on the MECH so people dont bypass it by switching equipment send_byjax(chassis.occupants,"exosuit.browser","[REF(src)]",src.get_equip_info()) chassis.use_power(energy_drain) diff --git a/code/modules/vehicles/mecha/equipment/tools/medical_tools.dm b/code/modules/vehicles/mecha/equipment/tools/medical_tools.dm index 01ecdef02f9..9fd910ce9bd 100644 --- a/code/modules/vehicles/mecha/equipment/tools/medical_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/medical_tools.dm @@ -49,7 +49,7 @@ /obj/item/mecha_parts/mecha_equipment/medical/sleeper/Exit(atom/movable/leaving, direction) return FALSE //prevents them from leaving without being forcemoved I guess -/obj/item/mecha_parts/mecha_equipment/medical/sleeper/action(mob/source, atom/atomtarget, params) +/obj/item/mecha_parts/mecha_equipment/medical/sleeper/action(mob/source, atom/atomtarget, list/modifiers) if(!action_checks(atomtarget)) return if(!iscarbon(atomtarget)) @@ -313,7 +313,7 @@ if(output) return "[output] \[[mode? "Analyze" : "Launch"]\]
\[Syringes: [LAZYLEN(syringes)]/[max_syringes] | Reagents: [reagents.total_volume]/[reagents.maximum_volume]\]
Reagents list" -/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/action(mob/source, atom/target, list/modifiers) if(!action_checks(target)) return if(istype(target, /obj/item/reagent_containers/syringe)) @@ -531,7 +531,7 @@ return medigun.process(SSOBJ_DT) -/obj/item/mecha_parts/mecha_equipment/medical/mechmedbeam/action(mob/source, atom/movable/target, params) +/obj/item/mecha_parts/mecha_equipment/medical/mechmedbeam/action(mob/source, atom/movable/target, list/modifiers) medigun.process_fire(target, loc) diff --git a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm index 7ac70ea3472..17f9f7036dc 100644 --- a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm @@ -24,7 +24,7 @@ . = ..() AddComponent(/datum/component/butchering, 50, 100, null, null, TRUE) -/obj/item/mecha_parts/mecha_equipment/drill/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/drill/action(mob/source, atom/target, list/modifiers) // Check if we can even use the equipment to begin with. if(!action_checks(target)) return diff --git a/code/modules/vehicles/mecha/equipment/tools/other_tools.dm b/code/modules/vehicles/mecha/equipment/tools/other_tools.dm index b11f0c9f7c0..ebcdeb83f1e 100644 --- a/code/modules/vehicles/mecha/equipment/tools/other_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/other_tools.dm @@ -13,7 +13,7 @@ range = MECHA_RANGED var/teleport_range = 7 -/obj/item/mecha_parts/mecha_equipment/teleporter/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/teleporter/action(mob/source, atom/target, list/modifiers) var/area/ourarea = get_area(src) if(!action_checks(target) || ourarea.area_flags & NOTELEPORT) return @@ -35,7 +35,7 @@ range = MECHA_RANGED -/obj/item/mecha_parts/mecha_equipment/wormhole_generator/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/wormhole_generator/action(mob/source, atom/target, list/modifiers) var/area/ourarea = get_area(src) if(!action_checks(target) || ourarea.area_flags & NOTELEPORT) return @@ -81,7 +81,7 @@ var/mode = GRAVSLING_MODE -/obj/item/mecha_parts/mecha_equipment/gravcatapult/action(mob/source, atom/movable/target, params) +/obj/item/mecha_parts/mecha_equipment/gravcatapult/action(mob/source, atom/movable/target, list/modifiers) if(!action_checks(target)) return switch(mode) @@ -396,7 +396,7 @@ if(output) return "[output] \[[fuel]: [round(fuel.amount*MINERAL_MATERIAL_AMOUNT,0.1)] cm3\] - [equip_ready?"Deactivate":"Activate"]" -/obj/item/mecha_parts/mecha_equipment/generator/action(mob/source, atom/movable/target, params) +/obj/item/mecha_parts/mecha_equipment/generator/action(mob/source, atom/movable/target, list/modifiers) if(!chassis) return if(load_fuel(target, source)) diff --git a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm index 8689aa86f7b..81e761d1e94 100644 --- a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm @@ -37,7 +37,7 @@ . = ..() cargo_holder = null -/obj/item/mecha_parts/mecha_equipment/hydraulic_clamp/action(mob/living/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/hydraulic_clamp/action(mob/living/source, atom/target, list/modifiers) if(!action_checks(target)) return if(!cargo_holder) @@ -92,8 +92,6 @@ if(M.stat == DEAD) return - var/list/modifiers = params2list(params) - if(!source.combat_mode) step_away(M,chassis) if(killer_clamp) @@ -168,7 +166,7 @@ create_reagents(1000) reagents.add_reagent(/datum/reagent/water, 1000) -/obj/item/mecha_parts/mecha_equipment/extinguisher/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/extinguisher/action(mob/source, atom/target, list/modifiers) if(!action_checks(target) || get_dist(chassis, target)>3) return @@ -248,7 +246,7 @@ GLOB.rcd_list -= src return ..() -/obj/item/mecha_parts/mecha_equipment/rcd/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/rcd/action(mob/source, atom/target, list/modifiers) if(!isturf(target) && !istype(target, /obj/machinery/door/airlock)) target = get_turf(target) if(!action_checks(target) || get_dist(chassis, target)>3 || istype(target, /turf/open/space/transit)) diff --git a/code/modules/vehicles/mecha/equipment/weapons/weapons.dm b/code/modules/vehicles/mecha/equipment/weapons/weapons.dm index a206adfcda3..b1d1bcb1ef8 100644 --- a/code/modules/vehicles/mecha/equipment/weapons/weapons.dm +++ b/code/modules/vehicles/mecha/equipment/weapons/weapons.dm @@ -21,7 +21,7 @@ return TRUE return FALSE -/obj/item/mecha_parts/mecha_equipment/weapon/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/weapon/action(mob/source, atom/target, list/modifiers) if(!action_checks(target)) return FALSE var/newtonian_target = turn(chassis.dir,180) @@ -37,7 +37,6 @@ spread = round((i / projectiles_per_shot - 0.5) * variance) var/obj/projectile/projectile_obj = new projectile(get_turf(src)) - var/modifiers = params2list(params) projectile_obj.firer = chassis projectile_obj.preparePixelProjectile(target, source, modifiers, spread) if(source.client && isliving(source)) //dont want it to happen from syndie mecha npc mobs, they do direct fire anyways @@ -183,7 +182,7 @@ return FALSE -/obj/item/mecha_parts/mecha_equipment/weapon/honker/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/weapon/honker/action(mob/source, atom/target, list/modifiers) if(!action_checks(target)) return playsound(chassis, 'sound/items/airhorn.ogg', 100, TRUE) @@ -272,7 +271,7 @@ src.rearm() return -/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/action(mob/source, atom/target, list/modifiers) if(..()) projectiles -= projectiles_per_shot send_byjax(chassis.occupants,"exosuit.browser","[REF(src)]",src.get_equip_info()) @@ -366,7 +365,7 @@ var/missile_range = 30 var/diags_first = FALSE -/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/launcher/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/launcher/action(mob/source, atom/target, list/modifiers) if(!action_checks(target)) return var/obj/O = new projectile(chassis.loc) @@ -500,7 +499,7 @@ else to_chat(usr, "[icon2html(src, usr)][span_warning("Lethal Fisting Disabled.")]") -/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/launcher/punching_glove/action(mob/source, atom/target, params) +/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/launcher/punching_glove/action(mob/source, atom/target, list/modifiers) . = ..() if(.) to_chat(usr, "[icon2html(src, usr)]HONK") diff --git a/code/modules/wiremod/components/action/mmi.dm b/code/modules/wiremod/components/action/mmi.dm index e0ee407a7e1..932e4a9cce7 100644 --- a/code/modules/wiremod/components/action/mmi.dm +++ b/code/modules/wiremod/components/action/mmi.dm @@ -148,9 +148,8 @@ return TRUE -/obj/item/circuit_component/mmi/proc/handle_mmi_attack(mob/living/source, atom/target, list/mods) +/obj/item/circuit_component/mmi/proc/handle_mmi_attack(mob/living/source, atom/target, list/modifiers) SIGNAL_HANDLER - var/list/modifiers = params2list(mods) if(modifiers[RIGHT_CLICK]) clicked_atom.set_output(target) secondary_attack.set_output(COMPONENT_SIGNAL)