From f593849ce526b0c09fd93eb597b697ae053e87a0 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:15:59 +0200 Subject: [PATCH] [MIRROR] makes get_hearers_in_view() faster AGAIN, fixes issue with previous optimization (#6979) * makes get_hearers_in_view() faster AGAIN, fixes issue with previous optimization * Mirror! Co-authored-by: Kylerace Co-authored-by: Funce --- code/__DEFINES/flags.dm | 45 ++++++++--------- .../__DEFINES/important_recursive_contents.dm | 4 ++ code/__DEFINES/traits.dm | 2 + code/__HELPERS/_lists.dm | 1 + code/__HELPERS/game.dm | 46 ++++------------- code/_globalvars/bitfields.dm | 1 - code/_onclick/hud/parallax.dm | 9 ++-- code/game/area/areas.dm | 12 +++-- code/game/atoms_movable.dm | 50 ++++++++++++++----- code/game/machinery/doors/passworddoor.dm | 2 +- code/game/machinery/hologram.dm | 5 +- .../game/objects/items/devices/radio/radio.dm | 4 +- .../objects/items/devices/taperecorder.dm | 2 +- code/game/objects/items/eightball.dm | 2 +- code/modules/assembly/voice.dm | 5 +- .../carbon/human/species_types/dullahan.dm | 16 +++--- code/modules/mob/living/silicon/silicon.dm | 2 +- .../hostile/megafauna/colossus.dm | 2 +- .../hostile/megafauna/megafauna.dm | 2 +- .../simple_animal/hostile/space_dragon.dm | 4 +- code/modules/mob/mob.dm | 1 + code/modules/mob/mob_defines.dm | 1 - .../research/nanites/nanite_programmer.dm | 5 +- code/modules/shuttle/shuttle.dm | 7 ++- code/modules/vehicles/mecha/_mecha.dm | 2 +- code/modules/wiremod/components/atom/hear.dm | 4 +- tgstation.dme | 1 + 27 files changed, 128 insertions(+), 109 deletions(-) create mode 100644 code/__DEFINES/important_recursive_contents.dm diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index 3b0b2848b6d..f28f861d369 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -18,47 +18,46 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 //FLAGS BITMASK // scroll down before changing the numbers on these -/// This flag is what recursive_hear_check() uses to determine wether to add an item to the hearer list or not. -#define HEAR_1 (1<<0) /// Is this object currently processing in the atmos object list? -#define ATMOS_IS_PROCESSING_1 (1<<1) +#define ATMOS_IS_PROCESSING_1 (1<<0) /// conducts electricity (metal etc.) -#define CONDUCT_1 (1<<2) +#define CONDUCT_1 (1<<1) /// For machines and structures that should not break into parts, eg, holodeck stuff -#define NODECONSTRUCT_1 (1<<3) +#define NODECONSTRUCT_1 (1<<2) /// atom queued to SSoverlay -#define OVERLAY_QUEUED_1 (1<<4) +#define OVERLAY_QUEUED_1 (1<<3) /// item has priority to check when entering or leaving -#define ON_BORDER_1 (1<<5) +#define ON_BORDER_1 (1<<4) ///Whether or not this atom shows screentips when hovered over -#define NO_SCREENTIPS_1 (1 << 6) +#define NO_SCREENTIPS_1 (1<<5) /// Prevent clicking things below it on the same turf eg. doors/ fulltile windows -#define PREVENT_CLICK_UNDER_1 (1<<7) -#define HOLOGRAM_1 (1<<8) +#define PREVENT_CLICK_UNDER_1 (1<<6) +///specifies that this atom is a hologram that isnt real +#define HOLOGRAM_1 (1<<7) /// Prevents mobs from getting chainshocked by teslas and the supermatter -#define SHOCKED_1 (1<<9) +#define SHOCKED_1 (1<<8) ///Whether /atom/Initialize() has already run for the object -#define INITIALIZED_1 (1<<10) +#define INITIALIZED_1 (1<<9) /// was this spawned by an admin? used for stat tracking stuff. -#define ADMIN_SPAWNED_1 (1<<11) +#define ADMIN_SPAWNED_1 (1<<10) /// should not get harmed if this gets caught by an explosion? -#define PREVENT_CONTENTS_EXPLOSION_1 (1<<12) +#define PREVENT_CONTENTS_EXPLOSION_1 (1<<11) /// should the contents of this atom be acted upon -#define RAD_PROTECT_CONTENTS_1 (1 << 13) +#define RAD_PROTECT_CONTENTS_1 (1<<12) /// should this object be allowed to be contaminated -#define RAD_NO_CONTAMINATE_1 (1 << 14) +#define RAD_NO_CONTAMINATE_1 (1<<13) /// Should this object be paintable with very dark colors? -#define ALLOW_DARK_PAINTS_1 (1 << 15) +#define ALLOW_DARK_PAINTS_1 (1<<14) /// Should this object be unpaintable? -#define UNPAINTABLE_1 (1 << 16) +#define UNPAINTABLE_1 (1<<15) /// Is the thing currently spinning? -#define IS_SPINNING_1 (1 << 17) -#define IS_ONTOP_1 (1 << 18) -#define SUPERMATTER_IGNORES_1 (1 << 19) +#define IS_SPINNING_1 (1<<16) +#define IS_ONTOP_1 (1<<17) +#define SUPERMATTER_IGNORES_1 (1<<18) /// If a turf can be made dirty at roundstart. This is also used in areas. -#define CAN_BE_DIRTY_1 (1<<20) +#define CAN_BE_DIRTY_1 (1<<19) /// Should we use the initial icon for display? Mostly used by overlay only objects -#define HTML_USE_INITAL_ICON_1 (1<<21) +#define HTML_USE_INITAL_ICON_1 (1<<20) // Update flags for [/atom/proc/update_appearance] /// Update the atom's name diff --git a/code/__DEFINES/important_recursive_contents.dm b/code/__DEFINES/important_recursive_contents.dm new file mode 100644 index 00000000000..f1dc0bd3ea1 --- /dev/null +++ b/code/__DEFINES/important_recursive_contents.dm @@ -0,0 +1,4 @@ +///the area channel of the important_recursive_contents list, everything in here will be sent a signal when their last holding object changes areas +#define RECURSIVE_CONTENTS_AREA_SENSITIVE "recursive_contents_area_sensitive" +///the hearing channel of the important_recursive_contents list, everything in here will count as a hearing atom +#define RECURSIVE_CONTENTS_HEARING_SENSITIVE "recursive_contents_hearing_sensitive" diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 72c3ec4d3a4..f2cb8e67d44 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -409,6 +409,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai */ #define TRAIT_AREA_SENSITIVE "area-sensitive" +#define TRAIT_HEARING_SENSITIVE "hearing_sensitive" + /// Climbable trait, given and taken by the climbable element when added or removed. Exists to be easily checked via HAS_TRAIT(). #define TRAIT_CLIMBABLE "trait_climbable" diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 49be273325a..329b422a1b8 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -17,6 +17,7 @@ #define LAZYADD(L, I) if(!L) { L = list(); } L += I; #define LAZYOR(L, I) if(!L) { L = list(); } L |= I; #define LAZYFIND(L, V) (L ? L.Find(V) : 0) +///returns L[I] if L exists and I is a valid index of L, runtimes if L is not a list #define LAZYACCESS(L, I) (L ? (isnum(I) ? (I > 0 && I <= length(L) ? L[I] : null) : L[I]) : null) #define LAZYSET(L, K, V) if(!L) { L = list(); } L[K] = V; #define LAZYLEN(L) length(L) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index a95d78031da..e9ad9d00c35 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -162,20 +162,6 @@ turfs += T return turfs - -//This is the new version of recursive_mob_check, used for say(). -//The other proc was left intact because morgue trays use it. -//Sped this up again for real this time -/proc/recursive_hear_check(O) - var/list/processing_list = list(O) - . = list() - var/i = 0 - while(i < length(processing_list)) - var/atom/A = processing_list[++i] - if(A.flags_1 & HEAR_1) - . += A - processing_list += A.contents - /** recursive_organ_check * inputs: O (object to start with) * outputs: @@ -213,34 +199,20 @@ return -/// Returns a list of hearers in view(view_radius) from source (ignoring luminosity). recursively checks contents for hearers +/// Returns a list of hearers in view(view_radius) from source (ignoring luminosity). uses important_recursive_contents[RECURSIVE_CONTENTS_HEARING_SENSITIVE] /proc/get_hearers_in_view(view_radius, atom/source) - var/turf/center_turf = get_turf(source) . = list() if(!center_turf) return - var/list/processing_list = list() - if (view_radius == 0) // if the range is zero, we know exactly where to look for, we can skip view - processing_list += center_turf.contents // We can shave off one iteration by assuming turfs cannot hear - else - var/lum = center_turf.luminosity - center_turf.luminosity = 6 // This is the maximum luminosity - var/target = source.loc == center_turf ? source : center_turf //this is reasonably faster if true, and very slightly slower if false - for(var/atom/movable/movable in view(view_radius, target)) - if(movable.flags_1 & HEAR_1) //dont add the movables returned by view() to processing_list to reduce recursive iterations, just check them - . += movable - SEND_SIGNAL(movable, COMSIG_ATOM_HEARER_IN_VIEW, processing_list, .) - processing_list += movable.contents - center_turf.luminosity = lum - - var/i = 0 - while(i < length(processing_list)) // recursive_hear_check inlined here, the large majority of the work is in this part for big contents trees - var/atom/atom_to_check = processing_list[++i] - if(atom_to_check.flags_1 & HEAR_1) - . += atom_to_check - SEND_SIGNAL(atom_to_check, COMSIG_ATOM_HEARER_IN_VIEW, processing_list, .) - processing_list += atom_to_check.contents + var/lum = center_turf.luminosity + center_turf.luminosity = 6 // This is the maximum luminosity + for(var/atom/movable/movable in view(view_radius, center_turf)) + var/list/recursive_contents = LAZYACCESS(movable.important_recursive_contents, RECURSIVE_CONTENTS_HEARING_SENSITIVE) + if(recursive_contents) + . += recursive_contents + SEND_SIGNAL(movable, COMSIG_ATOM_HEARER_IN_VIEW, .) + center_turf.luminosity = lum /proc/get_mobs_in_radio_ranges(list/obj/item/radio/radios) . = list() diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 48630a10d03..00a8990e9ad 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -110,7 +110,6 @@ DEFINE_BITFIELD(flags_1, list( "ATMOS_IS_PROCESSING_1" = ATMOS_IS_PROCESSING_1, "CAN_BE_DIRTY_1" = CAN_BE_DIRTY_1, "CONDUCT_1" = CONDUCT_1, - "HEAR_1" = HEAR_1, "HOLOGRAM_1" = HOLOGRAM_1, "INITIALIZED_1" = INITIALIZED_1, "IS_ONTOP_1" = IS_ONTOP_1, diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index 0fdb537d37d..f131500c155 100755 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -201,7 +201,7 @@ else L.offset_x -= offset_x * L.speed L.offset_y -= offset_y * L.speed - + if(L.offset_x > 240) L.offset_x -= 480 if(L.offset_x < -240) @@ -215,10 +215,9 @@ /atom/movable/proc/update_parallax_contents() if(length(client_mobs_in_contents)) - for(var/thing in client_mobs_in_contents) - var/mob/M = thing - if(M?.client && M.hud_used && length(M.client.parallax_layers)) - M.hud_used.update_parallax() + for(var/mob/client_mob as anything in client_mobs_in_contents) + if(length(client_mob?.client?.parallax_layers) && client_mob.hud_used) + client_mob.hud_used.update_parallax() /mob/proc/update_parallax_teleport() //used for arrivals shuttle if(client?.eye && hud_used && length(client.parallax_layers)) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 7a1e0848554..5e390f83b4a 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -590,7 +590,6 @@ GLOBAL_LIST_EMPTY(teleportlocs) if(AREA_USAGE_DYNAMIC_START to AREA_USAGE_DYNAMIC_END) power_usage[chan] += amount - /** * Call back when an atom enters an area * @@ -601,8 +600,11 @@ GLOBAL_LIST_EMPTY(teleportlocs) /area/Entered(atom/movable/arrived, area/old_area) set waitfor = FALSE SEND_SIGNAL(src, COMSIG_AREA_ENTERED, arrived, old_area) - for(var/atom/movable/recipient as anything in arrived.area_sensitive_contents) + if(!LAZYACCESS(arrived.important_recursive_contents, RECURSIVE_CONTENTS_AREA_SENSITIVE)) + return + for(var/atom/movable/recipient as anything in arrived.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE]) SEND_SIGNAL(recipient, COMSIG_ENTER_AREA, src) + if(!isliving(arrived)) return @@ -614,6 +616,8 @@ GLOBAL_LIST_EMPTY(teleportlocs) if(L.client?.prefs.toggles & SOUND_SHIP_AMBIENCE) SEND_SOUND(L, sound('sound/ambience/shipambience.ogg', repeat = 1, wait = 0, volume = 35, channel = CHANNEL_BUZZ)) + + ///Divides total beauty in the room by roomsize to allow us to get an average beauty per tile. /area/proc/update_beauty() if(!areasize) @@ -632,7 +636,9 @@ GLOBAL_LIST_EMPTY(teleportlocs) */ /area/Exited(atom/movable/gone, direction) SEND_SIGNAL(src, COMSIG_AREA_EXITED, gone, direction) - for(var/atom/movable/recipient as anything in gone.area_sensitive_contents) + if(!LAZYACCESS(gone.important_recursive_contents, RECURSIVE_CONTENTS_AREA_SENSITIVE)) + return + for(var/atom/movable/recipient as anything in gone.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE]) SEND_SIGNAL(recipient, COMSIG_EXIT_AREA, src) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 6b309a9dc3b..663d5041978 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -38,8 +38,13 @@ var/moving_diagonally = 0 //0: not doing a diagonal move. 1 and 2: doing the first/second step of the diagonal move var/atom/movable/moving_from_pull //attempt to resume grab after moving instead of before. var/list/client_mobs_in_contents // This contains all the client mobs within this container - var/list/area_sensitive_contents // A (nested) list of contents that need to be sent signals to when moving between areas. Can include src. var/datum/forced_movement/force_moving = null //handled soley by forced_movement.dm + /** + * an associative lazylist of relevant nested contents by "channel", the list is of the form: list(channel = list(important nested contents of that type)) + * each channel has a specific purpose and is meant to replace potentially expensive nested contents iteration + * do NOT add channels to this for little reason as it can add considerable memory usage. + */ + var/list/important_recursive_contents /** * In case you have multiple types, you automatically use the most useful one. @@ -140,7 +145,7 @@ //We add ourselves to this list, best to clear it out //DO it after moveToNullspace so memes can be had - LAZYCLEARLIST(area_sensitive_contents) + LAZYCLEARLIST(important_recursive_contents) vis_contents.Cut() @@ -639,23 +644,37 @@ /atom/movable/Exited(atom/movable/gone, direction) . = ..() - if(gone.area_sensitive_contents) - for(var/atom/movable/location as anything in get_nested_locs(src) + src) - LAZYREMOVE(location.area_sensitive_contents, gone.area_sensitive_contents) + + if(LAZYLEN(gone.important_recursive_contents)) + var/list/nested_locs = get_nested_locs(src) + src + for(var/channel in gone.important_recursive_contents) + for(var/atom/movable/location as anything in nested_locs) + LAZYREMOVEASSOC(location.important_recursive_contents, channel, gone.important_recursive_contents[channel]) /atom/movable/Entered(atom/movable/arrived, atom/old_loc, list/atom/old_locs) . = ..() - if(arrived.area_sensitive_contents) - for(var/atom/movable/location as anything in get_nested_locs(src) + src) - //We can't make the assumption that objects won't become area sensitive in the process of entering us - LAZYOR(location.area_sensitive_contents, arrived.area_sensitive_contents) -/// See traits.dm. Use this in place of ADD_TRAIT. + if(LAZYLEN(arrived.important_recursive_contents)) + var/list/nested_locs = get_nested_locs(src) + src + for(var/channel in arrived.important_recursive_contents) + for(var/atom/movable/location as anything in nested_locs) + LAZYORASSOCLIST(location.important_recursive_contents, channel, arrived.important_recursive_contents[channel]) + +///allows this movable to hear and adds itself to the important_recursive_contents list of itself and every movable loc its in +/atom/movable/proc/become_hearing_sensitive(trait_source = TRAIT_GENERIC) + if(!HAS_TRAIT(src, TRAIT_HEARING_SENSITIVE)) + RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_HEARING_SENSITIVE), .proc/on_hearing_sensitive_trait_loss) + for(var/atom/movable/location as anything in get_nested_locs(src) + src) + LAZYADDASSOCLIST(location.important_recursive_contents, RECURSIVE_CONTENTS_HEARING_SENSITIVE, src) + ADD_TRAIT(src, TRAIT_HEARING_SENSITIVE, trait_source) + + +///allows this movable to know when it has "entered" another area no matter how many movable atoms its stuffed into, uses important_recursive_contents /atom/movable/proc/become_area_sensitive(trait_source = TRAIT_GENERIC) if(!HAS_TRAIT(src, TRAIT_AREA_SENSITIVE)) RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_AREA_SENSITIVE), .proc/on_area_sensitive_trait_loss) for(var/atom/movable/location as anything in get_nested_locs(src) + src) - LAZYADD(location.area_sensitive_contents, src) + LAZYADDASSOCLIST(location.important_recursive_contents, RECURSIVE_CONTENTS_AREA_SENSITIVE, src) ADD_TRAIT(src, TRAIT_AREA_SENSITIVE, trait_source) /atom/movable/proc/on_area_sensitive_trait_loss() @@ -663,7 +682,14 @@ UnregisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_AREA_SENSITIVE)) for(var/atom/movable/location as anything in get_nested_locs(src) + src) - LAZYREMOVE(location.area_sensitive_contents, src) + LAZYREMOVE(location.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE], src) + +/atom/movable/proc/on_hearing_sensitive_trait_loss() + SIGNAL_HANDLER + + UnregisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_HEARING_SENSITIVE)) + for(var/atom/movable/location as anything in get_nested_locs(src) + src) + LAZYREMOVE(location.important_recursive_contents[RECURSIVE_CONTENTS_HEARING_SENSITIVE], src) ///Sets the anchored var and returns if it was sucessfully changed or not. /atom/movable/proc/set_anchored(anchorvalue) diff --git a/code/game/machinery/doors/passworddoor.dm b/code/game/machinery/doors/passworddoor.dm index c6b13af7640..4537484ad8b 100644 --- a/code/game/machinery/doors/passworddoor.dm +++ b/code/game/machinery/doors/passworddoor.dm @@ -20,7 +20,7 @@ /obj/machinery/door/password/Initialize(mapload) . = ..() if(voice_activated) - flags_1 |= HEAR_1 + become_hearing_sensitive() /obj/machinery/door/password/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods = list()) . = ..() diff --git a/code/game/machinery/hologram.dm b/code/game/machinery/hologram.dm index 4ad79a5731a..c0e34d39738 100644 --- a/code/game/machinery/hologram.dm +++ b/code/game/machinery/hologram.dm @@ -34,7 +34,6 @@ Possible to do for anyone motivated enough: base_icon_state = "holopad" layer = LOW_OBJ_LAYER plane = FLOOR_PLANE - flags_1 = HEAR_1 req_access = list(ACCESS_KEYCARD_AUTH) //Used to allow for forced connecting to other (not secure) holopads. Anyone can make a call, though. use_power = IDLE_POWER_USE idle_power_usage = 5 @@ -80,6 +79,10 @@ Possible to do for anyone motivated enough: /// If we are currently calling another holopad var/calling = FALSE +/obj/machinery/holopad/Initialize() + . = ..() + become_hearing_sensitive() + /obj/machinery/holopad/secure name = "secure holopad" desc = "It's a floor-mounted device for projecting holographic images. This one will refuse to auto-connect incoming calls." diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 3532f1024e8..39a130a06f4 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -9,7 +9,7 @@ desc = "A basic handheld radio that communicates with local telecommunication networks." dog_fashion = /datum/dog_fashion/back - flags_1 = CONDUCT_1 | HEAR_1 + flags_1 = CONDUCT_1 slot_flags = ITEM_SLOT_BELT throw_speed = 3 throw_range = 7 @@ -102,6 +102,8 @@ for(var/ch_name in channels) secure_radio_connections[ch_name] = add_radio(src, GLOB.radiochannels[ch_name]) + become_hearing_sensitive(ROUNDSTART_TRAIT) + /obj/item/radio/ComponentInitialize() . = ..() AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) diff --git a/code/game/objects/items/devices/taperecorder.dm b/code/game/objects/items/devices/taperecorder.dm index 9eada837962..18c04f4da0e 100644 --- a/code/game/objects/items/devices/taperecorder.dm +++ b/code/game/objects/items/devices/taperecorder.dm @@ -8,7 +8,6 @@ lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' w_class = WEIGHT_CLASS_SMALL - flags_1 = HEAR_1 slot_flags = ITEM_SLOT_BELT custom_materials = list(/datum/material/iron=60, /datum/material/glass=30) force = 2 @@ -38,6 +37,7 @@ mytape = new starting_tape_type(src) soundloop = new(src) update_appearance() + become_hearing_sensitive() /obj/item/taperecorder/Destroy() QDEL_NULL(soundloop) diff --git a/code/game/objects/items/eightball.dm b/code/game/objects/items/eightball.dm index 61b62d86672..02ad916819e 100644 --- a/code/game/objects/items/eightball.dm +++ b/code/game/objects/items/eightball.dm @@ -97,7 +97,6 @@ /obj/item/toy/eightball/haunted shake_time = 30 SECONDS cooldown_time = 3 MINUTES - flags_1 = HEAR_1 var/last_message var/selected_message //these kind of store the same thing but one is easier to work with. @@ -137,6 +136,7 @@ for (var/answer in haunted_answers) votes[answer] = 0 AddElement(/datum/element/point_of_interest) + become_hearing_sensitive() /obj/item/toy/eightball/haunted/MakeHaunted() return FALSE diff --git a/code/modules/assembly/voice.dm b/code/modules/assembly/voice.dm index c876883d694..29a9e77f30b 100644 --- a/code/modules/assembly/voice.dm +++ b/code/modules/assembly/voice.dm @@ -8,7 +8,6 @@ desc = "A small electronic device able to record a voice sample, and send a signal when that sample is repeated." icon_state = "voice" custom_materials = list(/datum/material/iron=500, /datum/material/glass=50) - flags_1 = HEAR_1 attachable = TRUE verb_say = "beeps" verb_ask = "beeps" @@ -25,6 +24,10 @@ drop_sound = 'sound/items/handling/component_drop.ogg' pickup_sound = 'sound/items/handling/component_pickup.ogg' +/obj/item/assembly/voice/Initialize() + . = ..() + become_hearing_sensitive(ROUNDSTART_TRAIT) + /obj/item/assembly/voice/examine(mob/user) . = ..() . += span_notice("Use a multitool to swap between \"inclusive\", \"exclusive\", \"recognizer\", and \"voice sensor\" mode.") diff --git a/code/modules/mob/living/carbon/human/species_types/dullahan.dm b/code/modules/mob/living/carbon/human/species_types/dullahan.dm index 00d033a2961..6ae250827d0 100644 --- a/code/modules/mob/living/carbon/human/species_types/dullahan.dm +++ b/code/modules/mob/living/carbon/human/species_types/dullahan.dm @@ -29,7 +29,7 @@ /datum/species/dullahan/on_species_gain(mob/living/carbon/human/H, datum/species/old_species) . = ..() - H.flags_1 &= ~HEAR_1 + REMOVE_TRAIT(src, TRAIT_HEARING_SENSITIVE, TRAIT_GENERIC) var/obj/item/bodypart/head/head = H.get_bodypart(BODY_ZONE_HEAD) if(head) head.drop_limb() @@ -43,7 +43,7 @@ H.set_safe_hunger_level() /datum/species/dullahan/on_species_loss(mob/living/carbon/human/H) - H.flags_1 |= HEAR_1 + H.become_hearing_sensitive() H.reset_perspective(H) if(myhead) var/obj/item/dullahan_relay/DR = myhead @@ -120,7 +120,6 @@ /obj/item/dullahan_relay name = "dullahan relay" var/mob/living/owner - flags_1 = HEAR_1 /obj/item/dullahan_relay/Initialize(mapload, mob/living/carbon/human/new_owner) . = ..() @@ -132,6 +131,7 @@ RegisterSignal(src, COMSIG_ATOM_HEARER_IN_VIEW, .proc/include_owner) RegisterSignal(owner, COMSIG_LIVING_REGENERATE_LIMBS, .proc/unlist_head) RegisterSignal(owner, COMSIG_LIVING_REVIVE, .proc/retrieve_head) + become_hearing_sensitive(ROUNDSTART_TRAIT) /obj/item/dullahan_relay/process() if(!istype(loc, /obj/item/bodypart/head) || QDELETED(owner)) @@ -143,18 +143,18 @@ if(user.client.eye == src) return COMPONENT_ALLOW_EXAMINATE -//Adds the owner to the list of hearers in hearers_in_view(), for visible/hearable on top of say messages -/obj/item/dullahan_relay/proc/include_owner(datum/source, list/processing_list, list/hearers) +///Adds the owner to the list of hearers in hearers_in_view(), for visible/hearable on top of say messages +/obj/item/dullahan_relay/proc/include_owner(datum/source, list/hearers) SIGNAL_HANDLER if(!QDELETED(owner)) hearers += owner -//Stops dullahans from gibbing when regenerating limbs +///Stops dullahans from gibbing when regenerating limbs /obj/item/dullahan_relay/proc/unlist_head(datum/source, noheal = FALSE, list/excluded_zones) SIGNAL_HANDLER excluded_zones |= BODY_ZONE_HEAD -//Retrieving the owner's head for better ahealing. +///Retrieving the owner's head for better ahealing. /obj/item/dullahan_relay/proc/retrieve_head(datum/source, full_heal, admin_revive) SIGNAL_HANDLER if(admin_revive) @@ -171,4 +171,4 @@ D.myhead = null owner.gib() owner = null - ..() + return ..() diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 7c1208a8501..aa67d88409d 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -12,7 +12,7 @@ mob_biotypes = MOB_ROBOTIC deathsound = 'sound/voice/borg_deathsound.ogg' speech_span = SPAN_ROBOT - flags_1 = PREVENT_CONTENTS_EXPLOSION_1 | HEAR_1 | RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1 + flags_1 = PREVENT_CONTENTS_EXPLOSION_1 | RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1 examine_cursor_icon = null var/datum/ai_laws/laws = null//Now... THEY ALL CAN ALL HAVE LAWS var/last_lawchange_announce = 0 diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm index 68a4f5375b5..6fefe2b1c74 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm @@ -402,7 +402,6 @@ GLOBAL_DATUM(blackbox, /obj/machinery/smartfridge/black_box) use_power = NO_POWER_USE anchored = FALSE density = TRUE - flags_1 = HEAR_1 var/activation_method var/list/possible_methods = list(ACTIVATE_TOUCH, ACTIVATE_SPEECH, ACTIVATE_HEAT, ACTIVATE_BULLET, ACTIVATE_ENERGY, ACTIVATE_BOMB, ACTIVATE_MOB_BUMP, ACTIVATE_WEAPON, ACTIVATE_MAGIC) @@ -416,6 +415,7 @@ GLOBAL_DATUM(blackbox, /obj/machinery/smartfridge/black_box) . = ..() if(!activation_method) activation_method = pick(possible_methods) + become_hearing_sensitive(trait_source = ROUNDSTART_TRAIT) /obj/machinery/anomalous_crystal/examine(mob/user) . = ..() diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm index 7a3549dd3e5..94030c7ca66 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm @@ -26,7 +26,7 @@ mob_size = MOB_SIZE_HUGE layer = LARGE_MOB_LAYER //Looks weird with them slipping under mineral walls and cameras and shit otherwise mouse_opacity = MOUSE_OPACITY_OPAQUE // Easier to click on in melee, they're giant targets anyway - flags_1 = PREVENT_CONTENTS_EXPLOSION_1 | HEAR_1 + flags_1 = PREVENT_CONTENTS_EXPLOSION_1 /// Crusher loot dropped when the megafauna is killed with a crusher var/list/crusher_loot /// Achievement given to surrounding players when the megafauna is killed diff --git a/code/modules/mob/living/simple_animal/hostile/space_dragon.dm b/code/modules/mob/living/simple_animal/hostile/space_dragon.dm index 41b2dc14686..d7972636439 100644 --- a/code/modules/mob/living/simple_animal/hostile/space_dragon.dm +++ b/code/modules/mob/living/simple_animal/hostile/space_dragon.dm @@ -46,8 +46,8 @@ health_doll_icon = "spacedragon" obj_damage = 50 environment_smash = ENVIRONMENT_SMASH_NONE - flags_1 = PREVENT_CONTENTS_EXPLOSION_1 | HEAR_1 - melee_damage_upper = 40 //SKYRAT EDIT ORIGINAL VAL (30) - Space dragon rebalance + flags_1 = PREVENT_CONTENTS_EXPLOSION_1 + melee_damage_upper = 40 //SKYRAT EDIT ORIGINAL VAL (35) - Space dragon rebalance melee_damage_lower = 35 mob_size = MOB_SIZE_LARGE armour_penetration = 34 //SKYRAT EDIT ORIGINAL VAL (30) - Space dragon rebalance diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 442c407a735..0cca15ca286 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -87,6 +87,7 @@ update_config_movespeed() initialize_actionspeed() update_movespeed(TRUE) + become_hearing_sensitive() /** * Generate the tag for this mob diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 2bb1179dc35..caa49c97eb6 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -11,7 +11,6 @@ density = TRUE layer = MOB_LAYER animate_movement = SLIDE_STEPS - flags_1 = HEAR_1 hud_possible = list(ANTAG_HUD) pressure_resistance = 8 mouse_drag_pointer = MOUSE_ACTIVE_POINTER diff --git a/code/modules/research/nanites/nanite_programmer.dm b/code/modules/research/nanites/nanite_programmer.dm index 589d423b659..f06c21aa79f 100644 --- a/code/modules/research/nanites/nanite_programmer.dm +++ b/code/modules/research/nanites/nanite_programmer.dm @@ -8,9 +8,12 @@ use_power = IDLE_POWER_USE anchored = TRUE density = TRUE - flags_1 = HEAR_1 circuit = /obj/item/circuitboard/machine/nanite_programmer +/obj/machinery/nanite_programmer/Initialize() + . = ..() + become_hearing_sensitive(trait_source = ROUNDSTART_TRAIT) + /obj/machinery/nanite_programmer/update_overlays() . = ..() if((machine_stat & (NOPOWER|MAINT|BROKEN)) || panel_open) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index e2cbe353fe7..643ab976200 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -730,10 +730,9 @@ var/turf/T = thing if(!T || !istype(T.loc, area_type)) continue - for (var/thing2 in T) - var/atom/movable/AM = thing2 - if (length(AM.client_mobs_in_contents)) - AM.update_parallax_contents() + for (var/atom/movable/movable as anything in T) + if (length(movable.client_mobs_in_contents)) + movable.update_parallax_contents() /obj/docking_port/mobile/proc/check_transit_zone() if(assigned_transit) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 65d545dfac1..6111f000ca9 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -22,7 +22,6 @@ desc = "Exosuit" icon = 'icons/mecha/mecha.dmi' resistance_flags = FIRE_PROOF | ACID_PROOF - flags_1 = HEAR_1 max_integrity = 300 armor = list(MELEE = 20, BULLET = 10, LASER = 0, ENERGY = 0, BOMB = 10, BIO = 0, RAD = 0, FIRE = 100, ACID = 100) movedelay = 1 SECONDS @@ -213,6 +212,7 @@ update_appearance() AddElement(/datum/element/atmos_sensitive, mapload) + become_hearing_sensitive(trait_source = ROUNDSTART_TRAIT) /obj/vehicle/sealed/mecha/Destroy() for(var/ejectee in occupants) diff --git a/code/modules/wiremod/components/atom/hear.dm b/code/modules/wiremod/components/atom/hear.dm index 322253001e3..a8e3d917047 100644 --- a/code/modules/wiremod/components/atom/hear.dm +++ b/code/modules/wiremod/components/atom/hear.dm @@ -7,8 +7,6 @@ display_name = "Voice Activator" display_desc = "A component that listens for messages. Requires a shell." - flags_1 = HEAR_1 - /// The message heard var/datum/port/output/message_port /// The language heard @@ -24,6 +22,8 @@ language_port = add_output_port("Language", PORT_TYPE_STRING) speaker_port = add_output_port("Speaker", PORT_TYPE_ATOM) trigger_port = add_output_port("Triggered", PORT_TYPE_SIGNAL) + become_hearing_sensitive(ROUNDSTART_TRAIT) + /obj/item/circuit_component/hear/Destroy() diff --git a/tgstation.dme b/tgstation.dme index feabafbd5c7..c301d7282a9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -71,6 +71,7 @@ #include "code\__DEFINES\hud.dm" #include "code\__DEFINES\icon_smoothing.dm" #include "code\__DEFINES\id_cards.dm" +#include "code\__DEFINES\important_recursive_contents.dm" #include "code\__DEFINES\injection.dm" #include "code\__DEFINES\instruments.dm" #include "code\__DEFINES\interaction_flags.dm"