From 2a0ab65e640f21bf611069ae4ef6a38d2b745b28 Mon Sep 17 00:00:00 2001 From: MarinaGryphon Date: Thu, 4 Mar 2021 14:19:10 -0600 Subject: [PATCH] Bugfix Collection (#11371) --- code/controllers/subsystems/chemistry.dm | 20 ++-- code/game/machinery/rechargestation.dm | 3 +- .../modules/cargo/random_stock/t2_uncommon.dm | 6 +- .../loadout/loadout_xeno/tajara.dm | 2 +- .../machinery/cooking_machines/_appliance.dm | 16 ++- .../machinery/cooking_machines/fryer.dm | 8 +- code/modules/cooking/recipes/recipe.dm | 4 +- code/modules/detectivework/tools/rag.dm | 2 +- code/modules/hydroponics/trays/tray_tools.dm | 2 +- code/modules/makeshift/makeshift_reagents.dm | 46 ++++---- .../mob/living/carbon/human/human_movement.dm | 13 +-- code/modules/mob/living/carbon/taste.dm | 6 +- code/modules/mob/say.dm | 2 +- code/modules/reagents/Chemistry-Machinery.dm | 11 +- .../Chemistry-Reagents-Medicine.dm | 16 ++- code/modules/reagents/reagent_containers.dm | 5 + .../reagent_containers/food/snacks.dm | 102 +++++++++--------- code/unit_tests/chemistry_tests.dm | 2 +- config/example/secretchem.json | 8 +- html/changelogs/MDP-bugfixes.yml | 49 +++++++++ 20 files changed, 186 insertions(+), 137 deletions(-) create mode 100644 html/changelogs/MDP-bugfixes.yml diff --git a/code/controllers/subsystems/chemistry.dm b/code/controllers/subsystems/chemistry.dm index bc23c0106b0..4c6085b223c 100644 --- a/code/controllers/subsystems/chemistry.dm +++ b/code/controllers/subsystems/chemistry.dm @@ -87,8 +87,7 @@ var/datum/controller/subsystem/chemistry/SSchemistry initialize_codex_data() var/pre_secret_len = chemical_reactions.len log_ss("chemistry", "Found [pre_secret_len] reactions.") - load_secret_chemicals() - log_ss("chemistry", "Loaded [chemical_reactions.len - pre_secret_len] secret reactions.") + log_ss("chemistry", "Loaded [load_secret_chemicals()] secret reactions.") initialize_specific_heats() // must be after reactions ..() @@ -125,6 +124,7 @@ var/datum/controller/subsystem/chemistry/SSchemistry src.chemical_reactions = SSchemistry.chemical_reactions /datum/controller/subsystem/chemistry/proc/load_secret_chemicals() + . = 0 var/list/chemconfig = list() try chemconfig = json_decode(return_file_text("config/secretchem.json")) @@ -140,24 +140,24 @@ var/datum/controller/subsystem/chemistry/SSchemistry cc.id = chemconfig[chemical]["id"] cc.result = text2path(chemconfig[chemical]["result"]) cc.result_amount = chemconfig[chemical]["resultamount"] - cc.required_reagents = chemconfig[chemical]["required_reagents"] - if(!istype(cc.result, /decl/reagent)) + if(!ispath(cc.result, /decl/reagent)) log_debug("SSchemistry: Warning: Invalid result [cc.result] in [cc.name] reactions list.") qdel(cc) break - for(var/i in 1 to cc.required_reagents.len) - var/A = text2path(cc.required_reagents[i]) - cc.required_reagents[i] = text2path(cc.required_reagents[i]) - if(!ispath(A, /decl/reagent)) - log_debug("SSchemistry: Warning: Invalid chemical [A] in [cc.name] required reagents list.") + for(var/key in chemconfig[chemical]["required_reagents"]) + var/result_chem = text2path(key) + LAZYSET(cc.required_reagents, result_chem, chemconfig[chemical]["required_reagents"][key]) + if(!ispath(result_chem, /decl/reagent)) + log_debug("SSchemistry: Warning: Invalid chemical [key] in [cc.name] required reagents list.") qdel(cc) break - if(LAZYLEN(cc.required_reagents)) + if(LAZYLEN(cc?.required_reagents)) var/rtype = cc.required_reagents[1] LAZYINITLIST(chemical_reactions[rtype]) chemical_reactions[rtype] += cc + .++ //Chemical Reactions - Initialises all /datum/chemical_reaction into a list // It is filtered into multiple lists within a list. diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm index 70f9dc7566d..4940afc7e20 100644 --- a/code/game/machinery/rechargestation.dm +++ b/code/game/machinery/rechargestation.dm @@ -218,9 +218,10 @@ if(!hascell(M)) return + if(!M.Move(src)) + return add_fingerprint(M) M.reset_view(src) - M.forceMove(src) occupant = M update_icon() return 1 diff --git a/code/modules/cargo/random_stock/t2_uncommon.dm b/code/modules/cargo/random_stock/t2_uncommon.dm index 34ada832c7e..32d5b81355c 100644 --- a/code/modules/cargo/random_stock/t2_uncommon.dm +++ b/code/modules/cargo/random_stock/t2_uncommon.dm @@ -93,13 +93,11 @@ STOCK_ITEM_UNCOMMON(chempack, 5) for (var/i in 1 to rand(2, 4)) var/obj/item/reagent_containers/chem_disp_cartridge/C = new /obj/item/reagent_containers/chem_disp_cartridge(L) var/rname = pick(chems) - var/decl/reagent/R = decls_repository.get_decl(rname) - //If we get a drink, reroll it once. //Should result in a higher chance of getting medicines and chemicals - if (istype(R, /decl/reagent/drink) || istype(R, /decl/reagent/alcohol)) + if (ispath(rname, /decl/reagent/drink) || ispath(rname, /decl/reagent/alcohol)) rname = pick(chems) - R = decls_repository.get_decl(rname) + var/decl/reagent/R = decls_repository.get_decl(rname) C.reagents.add_reagent(rname, C.volume) C.setLabel(R.name) diff --git a/code/modules/client/preference_setup/loadout/loadout_xeno/tajara.dm b/code/modules/client/preference_setup/loadout/loadout_xeno/tajara.dm index d1e63fb721f..d1d64d172cd 100644 --- a/code/modules/client/preference_setup/loadout/loadout_xeno/tajara.dm +++ b/code/modules/client/preference_setup/loadout/loadout_xeno/tajara.dm @@ -231,7 +231,7 @@ /datum/gear/shoes/tajara/footwraps display_name = "native tajaran foot-wear" - path = /obj/item/clothing/shoes/tajara + path = /obj/item/clothing/shoes/tajara/footwraps sort_category = "Xenowear - Tajara" whitelisted = list(SPECIES_TAJARA, SPECIES_TAJARA_ZHAN, SPECIES_TAJARA_MSAI) diff --git a/code/modules/cooking/machinery/cooking_machines/_appliance.dm b/code/modules/cooking/machinery/cooking_machines/_appliance.dm index 91c83e0e5f0..b50640222e6 100644 --- a/code/modules/cooking/machinery/cooking_machines/_appliance.dm +++ b/code/modules/cooking/machinery/cooking_machines/_appliance.dm @@ -254,12 +254,11 @@ oilwork(J, CI) for (var/_R in CI.container.reagents.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if (istype(R, /decl/reagent/nutriment)) + if (ispath(_R, /decl/reagent/nutriment)) CI.max_cookwork += CI.container.reagents.reagent_volumes[_R] *2//Added reagents contribute less than those in food items due to granular form //Nonfat reagents will soak oil - if (!istype(R, /decl/reagent/nutriment/triglyceride)) + if (!ispath(_R, /decl/reagent/nutriment/triglyceride)) CI.max_oil += CI.container.reagents.reagent_volumes[_R] * 0.25 else CI.max_cookwork += CI.container.reagents.reagent_volumes[_R] @@ -275,12 +274,11 @@ var/work = 0 if (istype(S) && S.reagents) for (var/_R in S.reagents.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if (istype(R, /decl/reagent/nutriment)) + if (ispath(_R, /decl/reagent/nutriment)) work += S.reagents.reagent_volumes[_R] *3//Core nutrients contribute much more than peripheral chemicals //Nonfat reagents will soak oil - if (!istype(R, /decl/reagent/nutriment/triglyceride)) + if (!ispath(_R, /decl/reagent/nutriment/triglyceride)) CI.max_oil += S.reagents.reagent_volumes[_R] * 0.35 else work += S.reagents.reagent_volumes[_R] @@ -575,15 +573,15 @@ result.kitchen_tag = SA.kitchen_tag if (SA.meat_amount) reagent_amount = SA.meat_amount*9 // at a rate of 9 protein per meat - var/decl/reagent/digest_product = victim.get_digestion_product() + var/digest_product_type = victim.get_digestion_product() // DOES NOT RETURN A DECL, RETURNS A PATH var/list/data var/meat_name = result.kitchen_tag || victim.name if(ishuman(victim)) var/mob/living/carbon/human/CH = victim meat_name = CH.species?.name || meat_name - if(istype(digest_product, /decl/reagent/nutriment/protein)) + if(ispath(digest_product_type, /decl/reagent/nutriment/protein)) data = list("[meat_name] meat" = reagent_amount) - result.reagents.add_reagent(victim.get_digestion_product(), reagent_amount, data) + result.reagents.add_reagent(digest_product_type, reagent_amount, data) if (victim.reagents) victim.reagents.trans_to(result, victim.reagents.total_volume) diff --git a/code/modules/cooking/machinery/cooking_machines/fryer.dm b/code/modules/cooking/machinery/cooking_machines/fryer.dm index 25a4f7695ff..4de8faa54cd 100644 --- a/code/modules/cooking/machinery/cooking_machines/fryer.dm +++ b/code/modules/cooking/machinery/cooking_machines/fryer.dm @@ -102,10 +102,9 @@ for (var/obj/item/I in CI.container) if (I.reagents && I.reagents.total_volume) for (var/_R in I.reagents.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if (istype(R, /decl/reagent/nutriment/triglyceride/oil)) + if (ispath(_R, /decl/reagent/nutriment/triglyceride/oil)) total_oil += I.reagents.reagent_volumes[_R] - if (R.type != our_oil.type) + if (_R != our_oil.type) total_removed += I.reagents.reagent_volumes[_R] I.reagents.remove_reagent(_R, I.reagents.reagent_volumes[_R]) else @@ -206,8 +205,7 @@ //So for now, restrict to oil only var/amount = 0 for (var/_R in I.reagents.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if (istype(R, /decl/reagent/nutriment/triglyceride/oil)) + if (ispath(_R, /decl/reagent/nutriment/triglyceride/oil)) var/delta = REAGENTS_FREE_SPACE(oil) delta = min(delta, I.reagents.reagent_volumes[_R]) oil.add_reagent(_R, delta) diff --git a/code/modules/cooking/recipes/recipe.dm b/code/modules/cooking/recipes/recipe.dm index 0427336121f..c7e7d67e88b 100644 --- a/code/modules/cooking/recipes/recipe.dm +++ b/code/modules/cooking/recipes/recipe.dm @@ -37,7 +37,7 @@ var/list/reagents // example: = list(/decl/reagent/drink/berryjuice = 5) // do not list same reagent twice var/list/items // example: = list(/obj/item/crowbar, /obj/item/welder) // place /foo/bar before /foo var/list/fruit // example: = list("fruit" = 3) - var/decl/reagent/coating = null//Required coating on all items in the recipe. The default value of null explitly requires no coating + var/coating = null//Required coating on all items in the recipe. The default value of null explitly requires no coating //A value of -1 is permissive and cares not for any coatings //Any typepath indicates a specific coating that should be present //Coatings are used for batter, breadcrumbs, beer-batter, colonel's secret coating, etc @@ -172,7 +172,7 @@ if (coating == -1) return TRUE //-1 value doesnt care - return !coating || (S.coating.type == coating) + return !coating || (S.coating == coating) //general version /decl/recipe/proc/make(var/obj/container as obj) diff --git a/code/modules/detectivework/tools/rag.dm b/code/modules/detectivework/tools/rag.dm index f10a8a8701a..e62977e2686 100644 --- a/code/modules/detectivework/tools/rag.dm +++ b/code/modules/detectivework/tools/rag.dm @@ -144,7 +144,7 @@ for(var/_R in reagents.reagent_volumes) var/decl/reagent/R = decls_repository.get_decl(_R) var/strength = R.germ_adjust * reagents.reagent_volumes[_R]/4 - if(istype(R, /decl/reagent/alcohol)) + if(ispath(_R, /decl/reagent/alcohol)) var/decl/reagent/alcohol/A = R strength = strength * (A.strength/100) W.germ_level -= min(strength, W.germ_level)//Clean the wound a bit. diff --git a/code/modules/hydroponics/trays/tray_tools.dm b/code/modules/hydroponics/trays/tray_tools.dm index 2f8255cd6cb..9587526a4e7 100644 --- a/code/modules/hydroponics/trays/tray_tools.dm +++ b/code/modules/hydroponics/trays/tray_tools.dm @@ -114,7 +114,7 @@ dat += "
This sample contains: " for(var/_R in grown_reagents.reagent_volumes) var/decl/reagent/R = decls_repository.get_decl(_R) - dat += "
- [R.name], [REAGENT_VOLUME(grown_reagents, R.type)] unit(s)" + dat += "
- [R.name], [REAGENT_VOLUME(grown_reagents, _R)] unit(s)" dat += "

Other Data

" diff --git a/code/modules/makeshift/makeshift_reagents.dm b/code/modules/makeshift/makeshift_reagents.dm index b5243d5d39a..5730e0aae1e 100644 --- a/code/modules/makeshift/makeshift_reagents.dm +++ b/code/modules/makeshift/makeshift_reagents.dm @@ -185,46 +185,48 @@ var/obj/item/weldingtool/welder /obj/structure/distillery/dismantle() - var/obj/structure/reagent_dispensers/keg/keg = new (loc) - if (src.reagents && src.reagents.total_volume) - src.reagents.trans_to_holder(keg.reagents, src.reagents.total_volume) - new /obj/item/stack/rods(get_turf(src), 3) + var/turf/T = get_turf(src) + var/obj/structure/reagent_dispensers/keg/keg = new (T) + if (reagents?.total_volume) + reagents.trans_to_holder(keg.reagents, reagents.total_volume) + new /obj/item/stack/rods(T, 3) if(welder) - welder.forceMove(loc) + welder.forceMove(T) welder = null qdel(src) /obj/structure/distillery/proc/trans_item(obj/item/W, mob/user) if(transfer_out) if(!reagents.total_volume) - to_chat(user, SPAN_NOTICE("\The [src] is empty.")) + to_chat(user, SPAN_NOTICE("[src] is empty.")) return var/amt = reagents.trans_to_holder(W.reagents, reagents.total_volume) - to_chat(user, SPAN_NOTICE("You fill \the [W] with [amt] units from \the [src].")) + to_chat(user, SPAN_NOTICE("You fill [W] with [amt] units from [src].")) return else - if(!W.reagents || !W.reagents.total_volume) - to_chat(user, SPAN_NOTICE("\The [W] is empty.")) + if(!W.reagents?.total_volume) + to_chat(user, SPAN_NOTICE("[W] is empty.")) return - var/amt = min(10, W.reagents.total_volume) - W.reagents.trans_to_holder(src.reagents, amt) // just pour it if you can - to_chat(user, SPAN_NOTICE("You pour [amt] units from \the [W] into \the [src].")) + var/amt = 5 + if(istype(W, /obj/item/reagent_containers)) + var/obj/item/reagent_containers/reagent_container = W + amt = reagent_container.amount_per_transfer_from_this + W.reagents.trans_to_holder(reagents, amt) // just pour it if you can + to_chat(user, SPAN_NOTICE("You pour [amt] units from [W] into [src].")) return /obj/structure/distillery/proc/distill() - if(!reagents || !reagents.total_volume) // can't distill nothing + if(!reagents?.total_volume) // can't distill nothing return for(var/_R in reagents.reagent_volumes) + if(!ispath(_R, /decl/reagent/alcohol)) + continue var/decl/reagent/alcohol/AR = decls_repository.get_decl(_R) - if(!istype(AR)) - return - var/ARvol = REAGENT_VOLUME(reagents, AR.type) - reagents.add_reagent(/decl/reagent/water, (1-(AR.strength/100))*ARvol) - if(istype(AR, /decl/reagent/alcohol)) - reagents.add_reagent(/decl/reagent/alcohol, (AR.strength/100)*ARvol) - else if(istype(AR, /decl/reagent/alcohol/butanol)) - reagents.add_reagent(/decl/reagent/alcohol/butanol, (AR.strength/100)*ARvol) - reagents.remove_reagent(AR.type, ARvol) + var/ARvol = REAGENT_VOLUME(reagents, _R) + var/alcohol_fraction = AR.strength/100 + reagents.add_reagent(/decl/reagent/water, (1-alcohol_fraction)*ARvol) + reagents.add_reagent(ispath(_R, /decl/reagent/alcohol/butanol) ? /decl/reagent/alcohol/butanol : /decl/reagent/alcohol, alcohol_fraction*ARvol) + reagents.remove_reagent(_R, ARvol) icon_state = "distillery-off" /obj/structure/distillery/attackby(obj/item/W, mob/user) diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index d9e15e8b585..fb4daec6c3a 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -148,12 +148,13 @@ var/turf/T = loc var/footsound var/top_layer = 0 - for(var/obj/structure/S in T) - if(S.layer > top_layer && S.footstep_sound) - top_layer = S.layer - footsound = S.footstep_sound - if(!footsound) - footsound = T.footstep_sound + if(istype(T)) + for(var/obj/structure/S in T) + if(S.layer > top_layer && S.footstep_sound) + top_layer = S.layer + footsound = S.footstep_sound + if(!footsound) + footsound = T.footstep_sound if (client) var/turf/B = GetAbove(T) diff --git a/code/modules/mob/living/carbon/taste.dm b/code/modules/mob/living/carbon/taste.dm index f908079052a..ddf1e92f8e9 100644 --- a/code/modules/mob/living/carbon/taste.dm +++ b/code/modules/mob/living/carbon/taste.dm @@ -35,8 +35,8 @@ calculate text size per text. var/decl/reagent/R = decls_repository.get_decl(_R) if(!R.taste_mult) continue - if(R.type == /decl/reagent/nutriment) - var/list/taste_data = REAGENT_DATA(src, R.type) + if(_R == /decl/reagent/nutriment) + var/list/taste_data = REAGENT_DATA(src, _R) for(var/taste in taste_data) if(taste in tastes) tastes[taste] += taste_data[taste] @@ -44,7 +44,7 @@ calculate text size per text. tastes[taste] = taste_data[taste] else var/taste_desc = R.taste_description - var/taste_amount = REAGENT_VOLUME(src, R.type) * R.taste_mult + var/taste_amount = REAGENT_VOLUME(src, _R) * R.taste_mult if(R.taste_description in tastes) tastes[taste_desc] += taste_amount else diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index c463b6d33d1..ac8b2dd0ce9 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -161,7 +161,7 @@ if(length(message) >= 2 && is_language_prefix(prefix)) var/language_prefix = lowertext(copytext(message, 2, 4)) var/datum/language/L = language_keys[language_prefix] - if(!L) + if(!L || !can_speak(L)) language_prefix = lowertext(copytext(message, 2, 3)) L = language_keys[language_prefix] if(can_speak(L)) diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index dab4244c99c..63b1098240a 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -330,6 +330,12 @@ /obj/item/stack/material/glass = list(/decl/reagent/silicate), /obj/item/stack/material/glass/phoronglass = list(/decl/reagent/platinum, /decl/reagent/silicate, /decl/reagent/silicate, /decl/reagent/silicate), //5 platinum, 15 silicate, ) + var/list/beaker_types = list( // also can't be ground + /obj/item/reagent_containers/glass, + /obj/item/reagent_containers/food/drinks/drinkingglass, + /obj/item/reagent_containers/food/drinks/shaker, + /obj/item/reagent_containers/cooking_container + ) /obj/machinery/reagentgrinder/Initialize() . = ..() @@ -340,10 +346,7 @@ return /obj/machinery/reagentgrinder/attackby(var/obj/item/O as obj, var/mob/user as mob) - - if (istype(O,/obj/item/reagent_containers/glass) || \ - istype(O,/obj/item/reagent_containers/food/drinks/drinkingglass) || \ - istype(O,/obj/item/reagent_containers/food/drinks/shaker)) + if (is_type_in_list(O, beaker_types)) if (beaker) return 1 else diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm index 6c36549fc41..bfdf41fa37a 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm @@ -139,13 +139,11 @@ var/removing = (4 * removed) var/datum/reagents/ingested = M.get_ingested_reagents() for(var/_R in ingested.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if((remove_generic && istype(R, /decl/reagent/toxin)) || (_R in remove_toxins)) - ingested.remove_reagent(R.type, removing) + if((remove_generic && ispath(_R, /decl/reagent/toxin)) || (_R in remove_toxins)) + ingested.remove_reagent(_R, removing) return for(var/_R in M.reagents.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if((remove_generic && istype(R, /decl/reagent/toxin)) || (_R in remove_toxins)) + if((remove_generic && ispath(_R, /decl/reagent/toxin)) || (_R in remove_toxins)) M.reagents.remove_reagent(_R, removing) return @@ -605,10 +603,9 @@ var/datum/reagents/ingested = M.get_ingested_reagents() if(ingested) for(var/_R in ingested.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if(istype(R, /decl/reagent/alcohol)) + if(ispath(_R, /decl/reagent/alcohol)) var/amount = min(P, REAGENT_VOLUME(ingested, _R)) - ingested.remove_reagent(R.type, amount) + ingested.remove_reagent(_R, amount) P -= amount if (P <= 0) return @@ -617,8 +614,7 @@ //as a treatment option if someone was dumb enough to do this if(M.bloodstr) for(var/_R in M.bloodstr.reagent_volumes) - var/decl/reagent/R = decls_repository.get_decl(_R) - if(istype(R, /decl/reagent/alcohol)) + if(ispath(_R, /decl/reagent/alcohol)) var/amount = min(P, REAGENT_VOLUME(M.bloodstr, _R)) M.bloodstr.remove_reagent(_R, amount) P -= amount diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index 247131ae47c..270fc89ea06 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -79,12 +79,17 @@ qdel(src) /obj/item/reagent_containers/attackby(var/obj/item/W, var/mob/user) + if(istype(W, /obj/item/reagent_containers/food/snacks)) + var/obj/item/reagent_containers/food/snacks/dipped = W + dipped.attempt_apply_coating(src, user) + return if(!(W.flags & NOBLUDGEON) && (user.a_intent == I_HURT) && fragile && (W.force > fragile)) if(do_after(user, 10)) if(!QDELETED(src)) visible_message(SPAN_WARNING("[user] smashes [src] with \a [W]!")) user.do_attack_animation(src) shatter(W, user) + return ..() /obj/item/reagent_containers/attack(mob/M, mob/user, def_zone) diff --git a/code/modules/reagents/reagent_containers/food/snacks.dm b/code/modules/reagents/reagent_containers/food/snacks.dm index 64c40bdd51d..0d930cdbb5f 100644 --- a/code/modules/reagents/reagent_containers/food/snacks.dm +++ b/code/modules/reagents/reagent_containers/food/snacks.dm @@ -11,7 +11,7 @@ var/slices_num var/dried_type = null var/dry = 0 - var/decl/reagent/nutriment/coating/coating = null + var/coating = null // coating typepath, NOT decl var/icon/flat_icon = null //Used to cache a flat icon generated from dipping in batter. This is used again to make the cooked-batter-overlay var/do_coating_prefix = TRUE //If 0, we wont do "battered thing" or similar prefixes. Mainly for recipes that include batter but have a special name @@ -142,7 +142,8 @@ else to_chat(user, SPAN_NOTICE("You know the item as [initial(name)], but a little piece of propped-up paper indicates it's \a [name].")) if (coating) - to_chat(user, SPAN_NOTICE("It's coated in [coating.name]!")) + var/decl/reagent/coating_reagent = decls_repository.get_decl(coating) + to_chat(user, SPAN_NOTICE("It's coated in [coating_reagent.name]!")) if (bitecount==0) return else if (bitecount==1) @@ -256,28 +257,35 @@ return ..() //Code for dipping food in batter -/obj/item/reagent_containers/food/snacks/afterattack(obj/O as obj, mob/user as mob, proximity) - if(O.is_open_container() && !(istype(O, /obj/item/reagent_containers/food)) && proximity) - for (var/r in O.reagents.reagent_volumes) - - var/decl/reagent/R = r - if (istype(R, /decl/reagent/nutriment/coating)) - if (apply_coating(O.reagents, R, user)) - return TRUE - - return ..() +/** + * Perform checks, then apply any applicable coatings. + * + * @param dip /obj The object to attempt to dip src into. + * @param user /mob The mob attempting to dip src into dip. + * + * @return TRUE if coating applied, FALSE otherwise + */ +/obj/item/reagent_containers/food/snacks/proc/attempt_apply_coating(obj/dip, mob/user) + if(!dip.is_open_container() || istype(dip, /obj/item/reagent_containers/food) || !Adjacent(user)) + return + for (var/reagent_type in dip.reagents?.reagent_volumes) + if(!ispath(reagent_type, /decl/reagent/nutriment/coating)) + continue + return apply_coating(dip.reagents, reagent_type, user) //This proc handles drawing coatings out of a container when this food is dipped into it -/obj/item/reagent_containers/food/snacks/proc/apply_coating(var/datum/reagents/holder, var/decl/reagent/nutriment/coating/C, var/mob/user) +/obj/item/reagent_containers/food/snacks/proc/apply_coating(var/datum/reagents/holder, var/applied_coating, var/mob/user) if (coating) - to_chat(user, "The [src] is already coated in [coating.name]!") + var/decl/reagent/coating_reagent = decls_repository.get_decl(coating) + to_chat(user, "[src] is already coated in [coating_reagent.name]!") return FALSE + var/decl/reagent/nutriment/coating/applied_coating_reagent = decls_repository.get_decl(applied_coating) + //Calculate the reagents of the coating needed var/req = 0 for (var/r in reagents.reagent_volumes) - var/decl/reagent/R = r - if (istype(R, /decl/reagent/nutriment)) + if (ispath(r, /decl/reagent/nutriment)) req += reagents.reagent_volumes[r] * 0.2 else req += reagents.reagent_volumes[r] * 0.1 @@ -288,8 +296,8 @@ //the food has no reagents left, it's probably getting deleted soon return FALSE - if (holder.reagent_volumes[C.type] < req) - to_chat(user, SPAN_WARNING("There's not enough [C.name] to coat the [src]!")) + if (holder.reagent_volumes[applied_coating] < req) + to_chat(user, SPAN_WARNING("There's not enough [applied_coating_reagent.name] to coat [src]!")) return FALSE //First make sure there's space for our batter @@ -300,10 +308,10 @@ //Suck the coating out of the holder holder.trans_to_holder(reagents, req) - if (!REAGENT_VOLUME(reagents, C.type)) + if (!REAGENT_VOLUME(reagents, applied_coating)) return - coating = C + coating = applied_coating //Now we have to do the witchcraft with masking images //var/icon/I = new /icon(icon, icon_state) @@ -312,7 +320,7 @@ var/icon/I = flat_icon color = "#FFFFFF" //Some fruits use the color var. Reset this so it doesnt tint the batter I.Blend(new /icon('icons/obj/food_custom.dmi', rgb(255,255,255)),ICON_ADD) - I.Blend(new /icon('icons/obj/food_custom.dmi', coating.icon_raw),ICON_MULTIPLY) + I.Blend(new /icon('icons/obj/food_custom.dmi', applied_coating_reagent.icon_raw),ICON_MULTIPLY) var/image/J = image(I) J.alpha = 200 J.blend_mode = BLEND_OVERLAY @@ -320,13 +328,14 @@ add_overlay(J) if (user) - user.visible_message(SPAN_NOTICE("[user] dips [src] into \the [coating.name]"), SPAN_NOTICE("You dip [src] into \the [coating.name]")) + user.visible_message(SPAN_NOTICE("[user] dips [src] into \the [applied_coating_reagent.name]"), SPAN_NOTICE("You dip [src] into \the [applied_coating_reagent.name]")) return TRUE //Called by cooking machines. This is mainly intended to set properties on the food that differ between raw/cooked /obj/item/reagent_containers/food/snacks/proc/cook() if (coating) + var/decl/reagent/nutriment/coating/our_coating = decls_repository.get_decl(coating) var/list/temp = overlays.Copy() for (var/i in temp) if (istype(i, /image)) @@ -343,22 +352,20 @@ var/icon/I = flat_icon color = "#FFFFFF" //Some fruits use the color var I.Blend(new /icon('icons/obj/food_custom.dmi', rgb(255,255,255)),ICON_ADD) - I.Blend(new /icon('icons/obj/food_custom.dmi', coating.icon_cooked),ICON_MULTIPLY) + I.Blend(new /icon('icons/obj/food_custom.dmi', our_coating.icon_cooked),ICON_MULTIPLY) var/image/J = image(I) J.alpha = 200 J.tag = "coating" add_overlay(J) if (do_coating_prefix == 1) - name = "[coating.coated_adj] [name]" + name = "[our_coating.coated_adj] [name]" for (var/r in reagents.reagent_volumes) - var/decl/reagent/R = r - if (istype(R, /decl/reagent/nutriment/coating)) - var/decl/reagent/nutriment/coating/C = R + if (ispath(r, /decl/reagent/nutriment/coating)) + var/decl/reagent/nutriment/coating/C = decls_repository.get_decl(r) LAZYINITLIST(reagents.reagent_data) - LAZYINITLIST(reagents.reagent_data[r]) - reagents.reagent_data[r]["cooked"] = TRUE + LAZYSET(reagents.reagent_data[r], "cooked", TRUE) C.name = C.cooked_name // A proc for setting various flavors of the same type of food instead of creating new foods with the only difference being a flavor @@ -938,25 +945,19 @@ do_coating_prefix = 0 bitesize = 2 reagents_to_add = list(/decl/reagent/nutriment/protein = 6, /decl/reagent/nutriment/coating/batter = 1.7, /decl/reagent/nutriment/triglyceride/oil = 1.5) - -/obj/item/reagent_containers/food/snacks/sausage/battered/Initialize() - . = ..() - coating = decls_repository.get_decl(/decl/reagent/nutriment/coating/batter) + coating = /decl/reagent/nutriment/coating/batter /obj/item/reagent_containers/food/snacks/jalapeno_poppers name = "jalapeno popper" - desc = "A battered, deep-fried chilli pepper" + desc = "A battered, deep-fried chili pepper" icon_state = "popper" filling_color = "#00AA00" do_coating_prefix = 0 reagents_to_add = list(/decl/reagent/nutriment = 2, /decl/reagent/nutriment/coating/batter = 2, /decl/reagent/nutriment/triglyceride/oil = 2) - reagent_data = list(/decl/reagent/nutriment = list("chilli pepper" = 2)) + reagent_data = list(/decl/reagent/nutriment = list("chili pepper" = 2)) bitesize = 1 - -/obj/item/reagent_containers/food/snacks/jalapeno_poppers/Initialize() - . = ..() - coating = decls_repository.get_decl(/decl/reagent/nutriment/coating/batter) + coating = /decl/reagent/nutriment/coating/batter /obj/item/reagent_containers/food/snacks/donkpocket name = "Donk-pocket" @@ -2313,7 +2314,7 @@ filling_color = "#702708" center_of_mass = list("x"=15, "y"=9) reagents_to_add = list(/decl/reagent/nutriment = 3, /decl/reagent/nutriment/protein = 3, /decl/reagent/capsaicin = 3, /decl/reagent/drink/tomatojuice = 2, /decl/reagent/hyperzine = 5) - reagent_data = list(/decl/reagent/nutriment = list("chilli peppers" = 3)) + reagent_data = list(/decl/reagent/nutriment = list("chili peppers" = 3)) bitesize = 5 /obj/item/reagent_containers/food/snacks/stew/bear @@ -2380,7 +2381,7 @@ filling_color = "#EDDD00" center_of_mass = list("x"=18, "y"=14) reagents_to_add = list(/decl/reagent/nutriment = 8, /decl/reagent/nutriment/protein = 2, /decl/reagent/capsaicin = 2) - reagent_data = list(/decl/reagent/nutriment = list("fresh fries" = 4, "cheese" = 2, "chilli peppers" = 2)) + reagent_data = list(/decl/reagent/nutriment = list("fresh fries" = 4, "cheese" = 2, "chili peppers" = 2)) bitesize = 4 /obj/item/reagent_containers/food/snacks/friedmushroom @@ -3200,7 +3201,7 @@ /obj/item/reagent_containers/food/snacks/sliceable/pizza/crunch/Initialize() . = ..() - coating = decls_repository.get_decl(/decl/reagent/nutriment/coating/batter) + coating = /decl/reagent/nutriment/coating/batter /obj/item/reagent_containers/food/snacks/pizzacrunchslice name = "pizza crunch" @@ -3211,10 +3212,7 @@ center_of_mass = list("x"=18, "y"=13) reagents_to_add = list(/decl/reagent/nutriment = 5, /decl/reagent/nutriment/coating/batter = 2, /decl/reagent/nutriment/triglyceride/oil = 1) reagent_data = list(/decl/reagent/nutriment = list("pizza crust" = 5)) - -/obj/item/reagent_containers/food/snacks/sliceable/pizza/crunch/Initialize() - . = ..() - coating = decls_repository.get_decl(/decl/reagent/nutriment/coating/batter) + coating = /decl/reagent/nutriment/coating/batter /obj/item/pizzabox name = "pizza box" @@ -3463,7 +3461,7 @@ reagents_to_add = list(/decl/reagent/nutriment = 3) reagent_data = list(/decl/reagent/nutriment = list("uncooked dough" = 3)) filling_color = "#EDE0AF" - + /obj/item/reagent_containers/food/snacks/doughslice name = "dough slice" desc = "A building block of an impressive dish." @@ -3516,7 +3514,7 @@ if ("rodent") result = new /obj/item/reagent_containers/food/snacks/burger/mouse(src) to_chat(user, "You make a ratburger!") - + else if(istype(W,/obj/item/reagent_containers/food/snacks)) var/obj/item/reagent_containers/food/snacks/csandwich/roll/R = new(get_turf(src)) R.attackby(W,user) @@ -3647,7 +3645,7 @@ reagents_to_add = list(/decl/reagent/nutriment = 3) reagent_data = list(/decl/reagent/nutriment = list("uncooked potatos" = 3)) filling_color = "#EDF291" - + /obj/item/reagent_containers/food/snacks/liquidfood name = "LiquidFood ration" desc = "A prepackaged grey slurry of all the essential nutrients for a spacefarer on the go. Should this be crunchy? Now with artificial flavoring!" @@ -4056,7 +4054,7 @@ reagents_to_add = list(/decl/reagent/nutriment = 2) reagent_data = list(/decl/reagent/nutriment = list("nacho chips" = 1)) filling_color = "#EDF291" - + /obj/item/reagent_containers/food/snacks/chip/on_consume(mob/M as mob) if(reagents && reagents.total_volume) @@ -4224,7 +4222,7 @@ reagents_to_add = list(/decl/reagent/nutriment = 20) reagent_data = list(/decl/reagent/nutriment = list("salsa" = 20)) filling_color = "#FF4D36" - + /obj/item/reagent_containers/food/snacks/dip/guac name = "guac dip" desc = "A recreation of the ancient Sol 'Guacamole' dip using tofu, limes, and spices. This recreation obviously leaves out mole meat." @@ -4474,7 +4472,7 @@ reagents_to_add = list(/decl/reagent/nutriment = 8) reagent_data = list(/decl/reagent/nutriment = list("cheese toast" = 8)) filling_color = "#FFF97D" - + /obj/item/reagent_containers/food/snacks/bacon_and_eggs name = "bacon and eggs" desc = "A piece of bacon and two fried eggs." diff --git a/code/unit_tests/chemistry_tests.dm b/code/unit_tests/chemistry_tests.dm index 35fc755a910..51b89f9d2a5 100644 --- a/code/unit_tests/chemistry_tests.dm +++ b/code/unit_tests/chemistry_tests.dm @@ -15,7 +15,7 @@ datum/unit_test/specific_heat/start_test() for(var/reagent in decls_repository.get_decls_of_subtype(/decl/reagent/)) var/decl/reagent/R = reagent if(!SSchemistry.has_valid_specific_heat(R)) - log_unit_test("[ascii_red][R.type] lacks a proper specific heat value![ascii_reset]") + log_unit_test("[ascii_red][reagent] lacks a proper specific heat value![ascii_reset]") error_count++ if(error_count) diff --git a/config/example/secretchem.json b/config/example/secretchem.json index a43bd9975fd..eb686317304 100644 --- a/config/example/secretchem.json +++ b/config/example/secretchem.json @@ -3,12 +3,12 @@ "superrine": { "name": "super rine", "id": "superrine", - "result": "water", + "result": "/decl/reagent/water", "resultamount": 60, "required_reagents": { - "water": 1, - "sugar": 1 + "/decl/reagent/water": 1, + "/decl/reagent/sugar": 1 } } } -} \ No newline at end of file +} diff --git a/html/changelogs/MDP-bugfixes.yml b/html/changelogs/MDP-bugfixes.yml new file mode 100644 index 00000000000..4376b267f40 --- /dev/null +++ b/html/changelogs/MDP-bugfixes.yml @@ -0,0 +1,49 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: MoondancerPony + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Cooking containers are now acceptable containers for blenders, and also won't be ground up." + - refactor: "Converts a lot of reagent decl istypes to ispaths, which might cause a speedup." + - bugfix: "Ya'ssa will now properly handle messages starting with S that have no space between it and the key." + - bugfix: "Native Tajaran footwear selected from the loadout will now spawn properly." + - bugfix: "Fixes makeshift distilleries." + - bugfix: "You can no longer charge remotely by abusing a wheelchair and a cyborg charger." + - bugfix: "Fixes batter." + - tweak: "Batter is now applied by clicking a container with food in your hand." + - bugfix: "Secret chems now load properly."