From 322d4effc5d1cf1f81620d7948eeae4274e452ee Mon Sep 17 00:00:00 2001 From: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:29:32 +0530 Subject: [PATCH] Removes `REAGENT_NOSPLIT` flag (#91526) ## About The Pull Request Because it does nothing. The only reagents that had this flag were inverse reagents & some medicines but those reagents already had their `inverse_chem` set to null meaning they are incapable of splitting even without this flag. From the comments it said the flag had something to do with stomachs constantly calling `on_mob_add()` which would split the reagent twice however upon inspecting stomach code no such thing exists so it didn't create any problems. Once the reagent enters the mob it splits just once because purity is preserved when transferring the reagent to different organs so this flag never had a chance to do anything Less code to worry about ## Changelog :cl: code: removed `REAGENT_NOSPLIT` flag /:cl: --- code/__DEFINES/reagents.dm | 22 +++++++-------- code/_globalvars/bitfields.dm | 1 - .../plumbing/plumbers/_plumb_reagents.dm | 4 +-- .../reagents/chemistry/fermi_readme.md | 3 +- .../reagents/chemistry/holder/holder.dm | 28 ++++++------------- .../reagents/chemistry/holder/mob_life.dm | 15 +++++----- code/modules/reagents/chemistry/reagents.dm | 2 +- .../chemistry/reagents/impure_reagents.dm | 8 +++--- .../impure_medicine_reagents.dm | 14 +++++----- 9 files changed, 40 insertions(+), 57 deletions(-) diff --git a/code/__DEFINES/reagents.dm b/code/__DEFINES/reagents.dm index ccd883011ad..963a2f0c236 100644 --- a/code/__DEFINES/reagents.dm +++ b/code/__DEFINES/reagents.dm @@ -102,31 +102,29 @@ //reagent bitflags, used for altering how they works ///allows on_mob_dead() if present in a dead body #define REAGENT_DEAD_PROCESS (1<<0) -///Do not split the chem at all during processing - ignores all purity effects -#define REAGENT_DONOTSPLIT (1<<1) ///Doesn't appear on handheld health analyzers. -#define REAGENT_INVISIBLE (1<<2) +#define REAGENT_INVISIBLE (1<<1) ///When inverted, the inverted chem uses the name of the original chem -#define REAGENT_SNEAKYNAME (1<<3) +#define REAGENT_SNEAKYNAME (1<<2) ///Retains initial volume of chem when splitting for purity effects -#define REAGENT_SPLITRETAINVOL (1<<4) +#define REAGENT_SPLITRETAINVOL (1<<3) ///Lets a given reagent be synthesized important for random reagents and things like the odysseus syringe gun(Replaces the old can_synth variable) -#define REAGENT_CAN_BE_SYNTHESIZED (1<<5) +#define REAGENT_CAN_BE_SYNTHESIZED (1<<4) ///Allows a reagent to work on a mob regardless of stasis -#define REAGENT_IGNORE_STASIS (1<<6) +#define REAGENT_IGNORE_STASIS (1<<5) ///This reagent won't be used in most randomized recipes. Meant for reagents that could be synthetized but are normally inaccessible or TOO hard to get. -#define REAGENT_NO_RANDOM_RECIPE (1<<7) +#define REAGENT_NO_RANDOM_RECIPE (1<<6) ///Does this reagent clean things? -#define REAGENT_CLEANS (1<<8) +#define REAGENT_CLEANS (1<<7) ///Does this reagent affect wounds? Used to check if some procs should be ran. -#define REAGENT_AFFECTS_WOUNDS (1<<9) +#define REAGENT_AFFECTS_WOUNDS (1<<8) /// If present, when metabolizing out of a mob, we divide by the mob's metabolism rather than multiply. /// Without this flag: Higher metabolism means the reagent exits the system faster. /// With this flag: Higher metabolism means the reagent exits the system slower. -#define REAGENT_REVERSE_METABOLISM (1<<10) +#define REAGENT_REVERSE_METABOLISM (1<<9) /// If present, this reagent will not be affected by the mob's metabolism at all, meaning it exits at a fixed rate for all mobs. /// Supercedes [REAGENT_REVERSE_METABOLISM]. -#define REAGENT_UNAFFECTED_BY_METABOLISM (1<<11) +#define REAGENT_UNAFFECTED_BY_METABOLISM (1<<10) //Chemical reaction flags, for determining reaction specialties ///Convert into impure/pure on reaction completion diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 30055e2f730..b037d877d4a 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -399,7 +399,6 @@ DEFINE_BITFIELD(zap_flags, list( DEFINE_BITFIELD(chemical_flags, list( "REAGENT_DEAD_PROCESS" = REAGENT_DEAD_PROCESS, - "REAGENT_DONOTSPLIT" = REAGENT_DONOTSPLIT, "REAGENT_INVISIBLE" = REAGENT_INVISIBLE, "REAGENT_SNEAKYNAME" = REAGENT_SNEAKYNAME, "REAGENT_SPLITRETAINVOL" = REAGENT_SPLITRETAINVOL, diff --git a/code/modules/plumbing/plumbers/_plumb_reagents.dm b/code/modules/plumbing/plumbers/_plumb_reagents.dm index a19b5e492cd..1f9a2e5e961 100644 --- a/code/modules/plumbing/plumbers/_plumb_reagents.dm +++ b/code/modules/plumbing/plumbers/_plumb_reagents.dm @@ -89,7 +89,7 @@ target_holder.update_total() continue - transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, copy_data(reagent), chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) //we only handle reaction after every reagent has been transferred. + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, copy_data(reagent), chem_temp, reagent.purity, reagent.ph, no_react = TRUE) //we only handle reaction after every reagent has been transferred. if(!transfered_amount) continue total_transfered_amount += transfered_amount @@ -237,7 +237,7 @@ target_holder.update_total() continue - transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, copy_data(reagent), chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) //we only handle reaction after every reagent has been transferred. + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, copy_data(reagent), chem_temp, reagent.purity, reagent.ph, no_react = TRUE) //we only handle reaction after every reagent has been transferred. if(!transfered_amount) continue total_transfered_amount += transfered_amount diff --git a/code/modules/reagents/chemistry/fermi_readme.md b/code/modules/reagents/chemistry/fermi_readme.md index b0b694fdc3c..cfde8c37126 100644 --- a/code/modules/reagents/chemistry/fermi_readme.md +++ b/code/modules/reagents/chemistry/fermi_readme.md @@ -188,8 +188,7 @@ See above for purity mechanics, but this is where you set the reagents that are The flags you can set for `var/chemical_flags` are: ```dm -#define REAGENT_DEAD_PROCESS (1<<0) //allows on_mob_dead() if present in a dead body -#define REAGENT_DONOTSPLIT (1<<1) //Do not split the chem at all during processing - ignores all purity effects +#define REAGENT_DEAD_PROCESS (1<<0) //allows on_mob_dead() if present in a dead body effects #define REAGENT_INVISIBLE (1<<2) //Doesn't appear on handheld health analyzers. #define REAGENT_SNEAKYNAME (1<<3) //When inverted, the inverted chem uses the name of the original chem #define REAGENT_SPLITRETAINVOL (1<<4) //Retains initial volume of chem when splitting for purity effects diff --git a/code/modules/reagents/chemistry/holder/holder.dm b/code/modules/reagents/chemistry/holder/holder.dm index 0f4535e6839..f3661b72f88 100644 --- a/code/modules/reagents/chemistry/holder/holder.dm +++ b/code/modules/reagents/chemistry/holder/holder.dm @@ -80,7 +80,6 @@ * * added_purity - override to force a purity when added * * added_ph - override to force a pH when added * * override_base_ph - ingore the present pH of the reagent, and instead use the default (i.e. if buffers/reactions alter it) - * * ignore splitting - Don't call the process that handles reagent spliting in a mob (impure/inverse) - generally leave this false unless you care about REAGENTS_DONOTSPLIT flags (see reagent defines) * * list/reagent_added - If not null use this as an holder to store and retrive the reagent datum that was just added without having to locate it after this proc returns. Clear the list to erase old values * * creation_callback - Callback to invoke when the reagent is created */ @@ -93,7 +92,6 @@ added_ph = null, no_react = FALSE, override_base_ph = FALSE, - ignore_splitting = FALSE, list/reagent_added = null, datum/callback/creation_callback = null, ) @@ -109,23 +107,16 @@ if(!glob_reagent) stack_trace("[my_atom] attempted to add a reagent called '[reagent_type]' which doesn't exist. ([usr])") return FALSE - if(isnull(added_purity)) //Because purity additions can be 0 + if(!added_purity) //Because purity additions can be 0 added_purity = glob_reagent.creation_purity //Usually 1 if(!added_ph) added_ph = glob_reagent.ph //Split up the reagent if it's in a mob - var/has_split = FALSE - if(!ignore_splitting && (flags & REAGENT_HOLDER_ALIVE)) //Stomachs are a pain - they will constantly call on_mob_add unless we split on addition to stomachs, but we also want to make sure we don't double split - var/adjusted_vol = process_mob_reagent_purity(glob_reagent, amount, added_purity, reagent_added) - if(!adjusted_vol) //If we're inverse or FALSE cancel addition - return amount - /* We return true here because of #63301 - The only cases where this will be false or 0 if its an inverse chem, an impure chem of 0 purity (highly unlikely if even possible), or if glob_reagent is null (which shouldn't happen at all as there's a check for that a few lines up), - In the first two cases, we would want to return TRUE so trans_to and other similar methods actually delete the corresponding chemical from the original reagent holder. - */ - amount = adjusted_vol - has_split = TRUE + if(flags & REAGENT_HOLDER_ALIVE) + amount = process_mob_reagent_purity(glob_reagent, amount, added_purity, reagent_added) + if(amount <= 0) //Inverse or nothing was added. return true amount + return amount * -1 var/cached_total = total_volume if(cached_total + amount > maximum_volume) @@ -186,9 +177,6 @@ if(isliving(my_atom)) new_reagent.on_mob_add(my_atom, amount) //Must occur before it could posibly run on_mob_delete - if(has_split) //prevent it from splitting again - new_reagent.chemical_flags |= REAGENT_DONOTSPLIT - update_total() if(reagtemp != cached_temp) var/new_heat_capacity = heat_capacity() @@ -510,7 +498,7 @@ update_total() target_holder.update_total() continue - transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount * multiplier, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT, reagent_added = r_to_send, creation_callback = CALLBACK(src, PROC_REF(_on_transfer_creation), reagent, target_holder)) //we only handle reaction after every reagent has been transferred. + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount * multiplier, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, reagent_added = r_to_send, creation_callback = CALLBACK(src, PROC_REF(_on_transfer_creation), reagent, target_holder)) //we only handle reaction after every reagent has been transferred. if(!transfered_amount) continue reagents_to_remove[reagent] = transfer_amount @@ -605,7 +593,7 @@ transfer_amount = reagent.volume * part * multiplier if(preserve_data) trans_data = copy_data(reagent) - transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE) if(copy_methods && !no_react) reagent.on_transfer(target, copy_methods, transfer_amount) if(!transfered_amount) @@ -648,7 +636,7 @@ reagent_change = reagent.volume * change if(change > 0) - add_reagent(reagent.type, reagent_change, added_purity = reagent.purity, added_ph = reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) + add_reagent(reagent.type, reagent_change, added_purity = reagent.purity, added_ph = reagent.ph, no_react = TRUE) else reagent.volume += reagent_change diff --git a/code/modules/reagents/chemistry/holder/mob_life.dm b/code/modules/reagents/chemistry/holder/mob_life.dm index 129faf8aa7c..3bc73492355 100644 --- a/code/modules/reagents/chemistry/holder/mob_life.dm +++ b/code/modules/reagents/chemistry/holder/mob_life.dm @@ -170,22 +170,21 @@ /datum/reagents/proc/process_mob_reagent_purity(datum/reagent/reagent, added_volume, added_purity, list/reagent_datum) PRIVATE_PROC(TRUE) + //no splitting when purity is perfect if(added_purity == 1) return added_volume - if(reagent.chemical_flags & REAGENT_DONOTSPLIT) - return added_volume - if(added_purity < 0) - stack_trace("Purity below 0 for chem on mob splitting: [reagent.type]!") - added_purity = 0 - if(reagent.inverse_chem_val > added_purity && reagent.inverse_chem)//Turns all of a added reagent into the inverse chem + //Turns all of a added reagent into the inverse chem + if(reagent.inverse_chem_val > added_purity && reagent.inverse_chem) if(isnull(reagent_datum)) reagent_datum = list() - add_reagent(reagent.inverse_chem, added_volume, FALSE, added_purity = reagent.get_inverse_purity(reagent.creation_purity), reagent_added = reagent_datum) + var/added_amount = add_reagent(reagent.inverse_chem, added_volume, FALSE, added_purity = reagent.get_inverse_purity(reagent.creation_purity), reagent_added = reagent_datum) var/datum/reagent/inverse_reagent = reagent_datum[reagent_datum.len] if(inverse_reagent.chemical_flags & REAGENT_SNEAKYNAME) inverse_reagent.name = reagent.name //Negative effects are hidden - return FALSE //prevent addition + return added_amount * -1 + + //reagent did not split because purity was above inverse value return added_volume /** diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 448c79dd75c..4e0544f6ba2 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -46,7 +46,7 @@ var/list/reagent_removal_skip_list = list() ///The set of exposure methods this penetrates skin with. var/penetrates_skin = VAPOR - /// See fermi_readme.dm REAGENT_DEAD_PROCESS, REAGENT_DONOTSPLIT, REAGENT_INVISIBLE, REAGENT_SNEAKYNAME, REAGENT_SPLITRETAINVOL, REAGENT_CANSYNTH, REAGENT_IMPURE + /// See fermi_readme.dm REAGENT_DEAD_PROCESS, REAGENT_INVISIBLE, REAGENT_SNEAKYNAME, REAGENT_SPLITRETAINVOL, REAGENT_CANSYNTH, REAGENT_IMPURE var/chemical_flags = NONE /// If the impurity is below 0.5, replace ALL of the chem with inverse_chem upon metabolising var/inverse_chem_val = 0.25 diff --git a/code/modules/reagents/chemistry/reagents/impure_reagents.dm b/code/modules/reagents/chemistry/reagents/impure_reagents.dm index 2b9ad32d97c..09da3851e22 100644 --- a/code/modules/reagents/chemistry/reagents/impure_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/impure_reagents.dm @@ -7,7 +7,7 @@ name = "Chemical Isomers" description = "Impure chemical isomers made from suboptimal reactions. Causes mild liver damage" //by default, it will stay hidden on splitting, but take the name of the source on inverting. Cannot be fractioned down either if the reagent is somehow isolated. - chemical_flags = REAGENT_SNEAKYNAME | REAGENT_DONOTSPLIT | REAGENT_CAN_BE_SYNTHESIZED //impure can be synthed, and is one of the only ways to get almost pure impure + chemical_flags = REAGENT_SNEAKYNAME | REAGENT_CAN_BE_SYNTHESIZED //impure can be synthed, and is one of the only ways to get almost pure impure ph = 3 inverse_chem = null inverse_chem_val = 0 @@ -32,7 +32,7 @@ name = "Toxic Monomers" description = "Inverse reagents are created when a reagent's purity is below it's inverse threshold. The are created either during ingestion - which will then replace their associated reagent, or some can be created during the reaction process." ph = 2 - chemical_flags = REAGENT_SNEAKYNAME | REAGENT_DONOTSPLIT //Inverse generally cannot be synthed - they're difficult to get + chemical_flags = REAGENT_SNEAKYNAME //Inverse generally cannot be synthed - they're difficult to get //Mostly to be safe - but above flags will take care of this. Also prevents it from showing these on reagent lookups in the ui inverse_chem = null ///how much this reagent does for tox damage too @@ -64,7 +64,7 @@ name = "Eigenswap" description = "This reagent is known to swap the handedness of a patient." ph = 3.3 - chemical_flags = REAGENT_DONOTSPLIT + chemical_flags = NONE tox_damage = 0 /datum/reagent/inverse/eigenswap/on_mob_life(mob/living/carbon/affected_mob) @@ -94,7 +94,7 @@ color = "#03dbfc" taste_description = "your tongue freezing, shortly followed by your thoughts. Brr!" ph = 14 - chemical_flags = REAGENT_DEAD_PROCESS | REAGENT_IGNORE_STASIS | REAGENT_DONOTSPLIT | REAGENT_UNAFFECTED_BY_METABOLISM + chemical_flags = REAGENT_DEAD_PROCESS | REAGENT_IGNORE_STASIS | REAGENT_UNAFFECTED_BY_METABOLISM metabolization_rate = 1 * REM /datum/reagent/inverse/cryostylane/on_transfer(atom/transfered_thing, methods, trans_volume) diff --git a/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm index dc430c6e4ef..c0b7667ac65 100644 --- a/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm @@ -9,14 +9,14 @@ /datum/reagent/impurity/healing name = "Healing Impure Reagent" description = "Not all impure reagents are bad! Sometimes you might want to specifically make these!" - chemical_flags = REAGENT_DONOTSPLIT + chemical_flags = NONE addiction_types = list(/datum/addiction/medicine = 3.5) liver_damage = 0 /datum/reagent/inverse/healing name = "Healing Inverse Reagent" description = "Not all impure reagents are bad! Sometimes you might want to specifically make these!" - chemical_flags = REAGENT_DONOTSPLIT + chemical_flags = NONE addiction_types = list(/datum/addiction/medicine = 3) tox_damage = 0 @@ -125,7 +125,7 @@ Basically, we fill the time between now and 2s from now with hands based off the /datum/reagent/inverse/libitoil name = "Libitoil" description = "Temporarily interferes with a patient's ability to process alcohol." - chemical_flags = REAGENT_DONOTSPLIT + chemical_flags = NONE ph = 13.5 addiction_types = list(/datum/addiction/medicine = 4) tox_damage = 0 @@ -277,7 +277,7 @@ Basically, we fill the time between now and 2s from now with hands based off the description = "This will send the patient to sleep, adding a bonus to the efficacy of all reagents administered." ph = 12.5 //sleeping is a basic need of all lifeformsa self_consuming = TRUE //No pesky liver shenanigans - chemical_flags = REAGENT_DONOTSPLIT | REAGENT_DEAD_PROCESS + chemical_flags = REAGENT_DEAD_PROCESS var/cached_reagent_list = list() addiction_types = list(/datum/addiction/medicine = 5) @@ -397,7 +397,7 @@ Basically, we fill the time between now and 2s from now with hands based off the name = "Technetium 99" description = "A radioactive tracer agent that can improve a scanner's ability to detect internal organ damage. Will poison the patient when present very slowly, purging or using a low dose is recommended after use." metabolization_rate = 0.3 * REM - chemical_flags = REAGENT_DONOTSPLIT //Do show this on scanner + chemical_flags = NONE //Do show this on scanner tox_damage = 0 var/time_until_next_poison = 0 @@ -417,7 +417,7 @@ Basically, we fill the time between now and 2s from now with hands based off the name = "Syrinifergus" description = "This reagent reduces the impurity of all non medicines within the patient, reducing their negative effects." self_consuming = TRUE //No pesky liver shenanigans - chemical_flags = REAGENT_DONOTSPLIT | REAGENT_DEAD_PROCESS + chemical_flags = REAGENT_DEAD_PROCESS ///The list of reagents we've affected var/cached_reagent_list = list() addiction_types = list(/datum/addiction/medicine = 1.75) @@ -480,7 +480,7 @@ Basically, we fill the time between now and 2s from now with hands based off the addiction_types = list(/datum/addiction/medicine = 12) overdose_threshold = 20 self_consuming = TRUE //No pesky liver shenanigans - chemical_flags = REAGENT_DONOTSPLIT | REAGENT_DEAD_PROCESS + chemical_flags = REAGENT_DEAD_PROCESS affected_organ_flags = NONE ///If we brought someone back from the dead var/back_from_the_dead = FALSE