From 8a9768cce5c9bb73af13b3fec3bf7ca39dd3821e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 27 Mar 2023 00:35:04 +0200 Subject: [PATCH] 515 DEPENDANCY UPDATES (#19873) * Experiment flag for not caching ref on 515 * Update vv_outfit.dm * MANUAL MIRROR https://github.com/tgstation/tgstation/pull/72657 * MANUAL MIRROR https://github.com/tgstation/tgstation/pull/73788 --------- Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com> Co-authored-by: lessthnthree Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com> --- .github/workflows/run_integration_tests.yml | 2 +- code/__DEFINES/_helpers.dm | 6 +- code/__DEFINES/callbacks.dm | 5 +- code/_experiments.dm | 15 +++- code/controllers/subsystem/garbage.dm | 5 +- code/datums/datum.dm | 2 + code/modules/clothing/outfits/vv_outfit.dm | 97 ++++++++++++--------- code/modules/mob/living/blood.dm | 6 +- tools/build/build.js | 6 +- 9 files changed, 88 insertions(+), 56 deletions(-) diff --git a/.github/workflows/run_integration_tests.yml b/.github/workflows/run_integration_tests.yml index 40e5e141715..79aa66ab707 100644 --- a/.github/workflows/run_integration_tests.yml +++ b/.github/workflows/run_integration_tests.yml @@ -56,7 +56,7 @@ jobs: run: | bash tools/ci/install_byond.sh source $HOME/BYOND/byond/bin/byondsetup - tools/build/build --ci dm -DCIBUILDING -DANSICOLORS + tools/build/build --ci dm -DCIBUILDING -DANSICOLORS -Werror - name: Run Tests run: | source $HOME/BYOND/byond/bin/byondsetup diff --git a/code/__DEFINES/_helpers.dm b/code/__DEFINES/_helpers.dm index bf723659588..59daf48edc7 100644 --- a/code/__DEFINES/_helpers.dm +++ b/code/__DEFINES/_helpers.dm @@ -17,10 +17,14 @@ /// Until a condition is true, sleep #define UNTIL(X) while(!(X)) stoplag() +#ifdef EXPERIMENT_515_DONT_CACHE_REF +/// Takes a datum as input, returns its ref string +#define text_ref(datum) ref(datum) +#else /// Takes a datum as input, returns its ref string, or a cached version of it /// This allows us to cache \ref creation, which ensures it'll only ever happen once per datum, saving string tree time /// It is slightly less optimal then a []'d datum, but the cost is massively outweighed by the potential savings /// It will only work for datums mind, for datum reasons /// : because of the embedded typecheck #define text_ref(datum) (isdatum(datum) ? (datum:cached_ref ||= "\ref[datum]") : ("\ref[datum]")) - +#endif diff --git a/code/__DEFINES/callbacks.dm b/code/__DEFINES/callbacks.dm index 8808c045abb..7e07c3d0541 100644 --- a/code/__DEFINES/callbacks.dm +++ b/code/__DEFINES/callbacks.dm @@ -15,9 +15,10 @@ } \ else { \ ASYNC { \ - call(proc_owner, proc_path)(##proc_arguments); \ + /* Written with `0 ||` to avoid the compiler seeing call("string"), and thinking it's a deprecated DLL */ \ + call(0 || proc_owner, proc_path)(##proc_arguments); \ }; \ - } + } /// like CALLBACK but specifically for verb callbacks #define VERB_CALLBACK new /datum/callback/verb_callback diff --git a/code/_experiments.dm b/code/_experiments.dm index 2ac066ae177..dfb7ec0a167 100644 --- a/code/_experiments.dm +++ b/code/_experiments.dm @@ -4,7 +4,10 @@ // For example, if you want to enable EXPERIMENT_MY_COOL_FEATURE, compile with -DEXPERIMENT_MY_COOL_FEATURE // EXPERIMENT_515_QDEL_HARD_REFERENCE -// - On 515, will hold a hard reference for qdeleted items, and check ref_count, rather than using refs. +// - Hold a hard reference for qdeleted items, and check ref_count, rather than using refs. Requires 515+. + +// EXPERIMENT_515_DONT_CACHE_REF +// - Avoids `text_ref` caching, aided by improvements to ref() speed in 515. #if DM_VERSION < 515 @@ -14,8 +17,18 @@ #undef EXPERIMENT_515_QDEL_HARD_REFERENCE #endif +#ifdef EXPERIMENT_515_DONT_CACHE_REF +#warn EXPERIMENT_515_DONT_CACHE_REF is only available on 515+ +#undef EXPERIMENT_515_DONT_CACHE_REF +#endif + #elif defined(UNIT_TESTS) #define EXPERIMENT_515_QDEL_HARD_REFERENCE +#define EXPERIMENT_515_DONT_CACHE_REF #endif + +#if DM_VERSION >= 516 +#error "Remove all 515 experiments" +#endif diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index e75d8541ba1..d7ad7df1fe0 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -173,7 +173,6 @@ SUBSYSTEM_DEF(garbage) continue var/queued_at_time = L[GC_QUEUE_ITEM_QUEUE_TIME] - var/GCd_at_time = L[GC_QUEUE_ITEM_GCD_DESTROYED] if(queued_at_time > cut_off_time) break // Everything else is newer, skip them count++ @@ -181,6 +180,8 @@ SUBSYSTEM_DEF(garbage) #ifdef EXPERIMENT_515_QDEL_HARD_REFERENCE var/datum/D = L[GC_QUEUE_ITEM_REF] #else + var/GCd_at_time = L[GC_QUEUE_ITEM_GCD_DESTROYED] + var/refID = L[GC_QUEUE_ITEM_REF] var/datum/D D = locate(refID) @@ -277,7 +278,7 @@ SUBSYSTEM_DEF(garbage) #endif if (D.gc_destroyed <= 0) D.gc_destroyed = queue_time - + var/list/queue = queues[level] queue[++queue.len] = list(queue_time, refid, D.gc_destroyed) // not += for byond reasons diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 2def3515b08..8b4dd37aa7b 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -40,10 +40,12 @@ /// Datum level flags var/datum_flags = NONE +#ifndef EXPERIMENT_515_DONT_CACHE_REF /// A cached version of our \ref /// The brunt of \ref costs are in creating entries in the string tree (a tree of immutable strings) /// This avoids doing that more then once per datum by ensuring ref strings always have a reference to them after they're first pulled var/cached_ref +#endif /// A weak reference to another datum var/datum/weakref/weak_reference diff --git a/code/modules/clothing/outfits/vv_outfit.dm b/code/modules/clothing/outfits/vv_outfit.dm index bedd65010f9..1740094fe3d 100644 --- a/code/modules/clothing/outfits/vv_outfit.dm +++ b/code/modules/clothing/outfits/vv_outfit.dm @@ -10,7 +10,7 @@ equipping_mob.delete_equipment() //Applying VV to wrong objects is not reccomended. return ..() -/datum/outfit/varedit/proc/set_equipement_by_slot(slot,item_path) +/datum/outfit/varedit/proc/set_equipment_by_slot(slot,item_path) switch(slot) if(ITEM_SLOT_ICLOTHING) uniform = item_path @@ -44,113 +44,128 @@ r_pocket = item_path -/proc/collect_vv(obj/item/I) +/proc/collect_vv(obj/item/item) //Temporary/Internal stuff, do not copy these. - var/static/list/ignored_vars = list("vars","x","y","z","plane","layer","override","animate_movement","pixel_step_size","screen_loc","fingerprintslast","tip_timer") + var/static/list/ignored_vars = list( + NAMEOF(item, animate_movement), +#ifndef EXPERIMENT_515_DONT_CACHE_REF + NAMEOF(item, cached_ref), +#endif + NAMEOF(item, datum_flags), + NAMEOF(item, fingerprintslast), + NAMEOF(item, layer), + NAMEOF(item, plane), + NAMEOF(item, screen_loc), + NAMEOF(item, tip_timer), + NAMEOF(item, vars), + NAMEOF(item, x), + NAMEOF(item, y), + NAMEOF(item, z), + ) - if(istype(I) && I.datum_flags & DF_VAR_EDITED) + if(istype(item) && item.datum_flags & DF_VAR_EDITED) var/list/vedits = list() - for(var/varname in I.vars) - if(!I.can_vv_get(varname)) + for(var/varname in item.vars) + if(!item.can_vv_get(varname)) continue if(varname in ignored_vars) continue - var/vval = I.vars[varname] + var/vval = item.vars[varname] //Does it even work ? - if(vval == initial(I.vars[varname])) + if(vval == initial(item.vars[varname])) continue //Only text/numbers and icons variables to make it less weirdness prone. if(!istext(vval) && !isnum(vval) && !isicon(vval)) continue - vedits[varname] = I.vars[varname] + vedits[varname] = item.vars[varname] return vedits /mob/living/carbon/human/proc/copy_outfit() - var/datum/outfit/varedit/O = new + var/datum/outfit/varedit/outfit = new //Copy equipment var/list/result = list() var/list/slots_to_check = list(ITEM_SLOT_ICLOTHING,ITEM_SLOT_BACK,ITEM_SLOT_OCLOTHING,ITEM_SLOT_BELT,ITEM_SLOT_GLOVES,ITEM_SLOT_FEET,ITEM_SLOT_HEAD,ITEM_SLOT_MASK,ITEM_SLOT_NECK,ITEM_SLOT_EARS,ITEM_SLOT_EYES,ITEM_SLOT_ID,ITEM_SLOT_SUITSTORE,ITEM_SLOT_LPOCKET,ITEM_SLOT_RPOCKET) - for(var/s in slots_to_check) - var/obj/item/I = get_item_by_slot(s) - var/vedits = collect_vv(I) + for(var/slot in slots_to_check) + var/obj/item/item = get_item_by_slot(slot) + var/vedits = collect_vv(item) if(vedits) - result["[s]"] = vedits - if(istype(I)) - O.set_equipement_by_slot(s,I.type) + result["[slot]"] = vedits + if(istype(item)) + outfit.set_equipment_by_slot(slot, item.type) //Copy access - O.stored_access = list() + outfit.stored_access = list() var/obj/item/id_slot = get_item_by_slot(ITEM_SLOT_ID) if(id_slot) - O.stored_access |= id_slot.GetAccess() + outfit.stored_access |= id_slot.GetAccess() var/obj/item/card/id/ID = id_slot.GetID() if(ID) if(ID.registered_name == real_name) - O.update_id_name = TRUE + outfit.update_id_name = TRUE if(ID.trim) - O.id_trim = ID.trim.type + outfit.id_trim = ID.trim.type //Copy hands if(held_items.len >= 2) //Not in the mood to let outfits transfer amputees var/obj/item/left_hand = held_items[1] var/obj/item/right_hand = held_items[2] if(istype(left_hand)) - O.l_hand = left_hand.type + outfit.l_hand = left_hand.type var/vedits = collect_vv(left_hand) if(vedits) result["LHAND"] = vedits if(istype(right_hand)) - O.r_hand = right_hand.type + outfit.r_hand = right_hand.type var/vedits = collect_vv(left_hand) if(vedits) result["RHAND"] = vedits - O.vv_values = result + outfit.vv_values = result //Copy backpack contents if exist. var/obj/item/backpack = get_item_by_slot(ITEM_SLOT_BACK) if(istype(backpack) && backpack.atom_storage) var/list/bp_stuff = list() var/list/typecounts = list() backpack.atom_storage.return_inv(bp_stuff, FALSE) - for(var/obj/item/I in bp_stuff) - if(typecounts[I.type]) - typecounts[I.type] += 1 + for(var/obj/item/backpack_item in bp_stuff) + if(typecounts[backpack_item.type]) + typecounts[backpack_item.type] += 1 else - typecounts[I.type] = 1 - O.backpack_contents = typecounts + typecounts[backpack_item.type] = 1 + outfit.backpack_contents = typecounts //TODO : Copy varedits from backpack stuff too. //Copy implants - O.implants = list() - for(var/obj/item/implant/I in implants) - O.implants |= I.type + outfit.implants = list() + for(var/obj/item/implant/implant in implants) + outfit.implants |= implant.type //Copy to outfit cache var/outfit_name = stripped_input(usr,"Enter the outfit name") - O.name = outfit_name - GLOB.custom_outfits += O + outfit.name = outfit_name + GLOB.custom_outfits += outfit to_chat(usr,"Outfit registered, use select equipment to equip it.") -/datum/outfit/varedit/post_equip(mob/living/carbon/human/H, visualsOnly) +/datum/outfit/varedit/post_equip(mob/living/carbon/human/human, visualsOnly) . = ..() //Apply VV for(var/slot in vv_values) var/list/edits = vv_values[slot] - var/obj/item/I + var/obj/item/item switch(slot) if("LHAND") - I = H.held_items[1] + item = human.held_items[1] if("RHAND") - I = H.held_items[2] + item = human.held_items[2] else - I = H.get_item_by_slot(text2num(slot)) + item = human.get_item_by_slot(text2num(slot)) for(var/vname in edits) - I.vv_edit_var(vname,edits[vname]) + item.vv_edit_var(vname,edits[vname]) //Apply access - var/obj/item/id_slot = H.get_item_by_slot(ITEM_SLOT_ID) + var/obj/item/id_slot = human.get_item_by_slot(ITEM_SLOT_ID) if(id_slot) var/obj/item/card/id/card = id_slot.GetID() if(istype(card)) card.add_access(stored_access, mode = FORCE_ADD_ALL) if(update_id_name) - card.registered_name = H.real_name + card.registered_name = human.real_name card.update_label() card.update_icon() diff --git a/code/modules/mob/living/blood.dm b/code/modules/mob/living/blood.dm index 9cfe90a80e8..e1d79567b29 100644 --- a/code/modules/mob/living/blood.dm +++ b/code/modules/mob/living/blood.dm @@ -32,10 +32,6 @@ adjust_nutrition(-nutrition_ratio * HUNGER_FACTOR * delta_time) blood_volume = min(blood_volume + (BLOOD_REGEN_FACTOR * nutrition_ratio * delta_time), blood_volume_normal) //SKYRAT EDIT CHANGE - // SKYRAT EDIT ADDITION START - Oversized quirk - var/blood_volume_max = max(BLOOD_VOLUME_MAXIMUM, blood_volume_normal + 1) - // SKYRAT EDIT END - //Effects of bloodloss var/word = pick("dizzy","woozy","faint") switch(blood_volume) @@ -44,7 +40,7 @@ to_chat(src, span_userdanger("Blood starts to tear your skin apart. You're going to burst!")) investigate_log("has been gibbed by having too much blood.", INVESTIGATE_DEATHS) inflate_gib() - if(blood_volume_max to BLOOD_VOLUME_EXCESS) // SKYRAT EDIT - Oversized quirk - ORIGINAL: if(BLOOD_VOLUME_MAXIMUM to BLOOD_VOLUME_EXCESS) + if(BLOOD_VOLUME_MAXIMUM to BLOOD_VOLUME_EXCESS) if(DT_PROB(5, delta_time)) to_chat(src, span_warning("You feel terribly bloated.")) if(BLOOD_VOLUME_OKAY to BLOOD_VOLUME_SAFE) diff --git a/tools/build/build.js b/tools/build/build.js index 08136185a8b..f55c525f10f 100644 --- a/tools/build/build.js +++ b/tools/build/build.js @@ -65,7 +65,7 @@ export const DmMapsIncludeTarget = new Juke.Target({ }); export const DmTarget = new Juke.Target({ - parameters: [DefineParameter, DmVersionParameter], + parameters: [DefineParameter, DmVersionParameter, WarningParameter], dependsOn: ({ get }) => [ get(DefineParameter).includes('ALL_MAPS') && DmMapsIncludeTarget, ], @@ -98,7 +98,7 @@ export const DmTarget = new Juke.Target({ }); export const DmTestTarget = new Juke.Target({ - parameters: [DefineParameter, DmVersionParameter], + parameters: [DefineParameter, DmVersionParameter, WarningParameter], dependsOn: ({ get }) => [ get(DefineParameter).includes('ALL_MAPS') && DmMapsIncludeTarget, ], @@ -132,7 +132,7 @@ export const DmTestTarget = new Juke.Target({ }); export const AutowikiTarget = new Juke.Target({ - parameters: [DefineParameter, DmVersionParameter], + parameters: [DefineParameter, DmVersionParameter, WarningParameter], dependsOn: ({ get }) => [ get(DefineParameter).includes('ALL_MAPS') && DmMapsIncludeTarget, ],