From c43591982ab83962d1706a6e4c6302af9807d1bb Mon Sep 17 00:00:00 2001 From: oranges Date: Sat, 25 Nov 2017 00:45:44 +1300 Subject: [PATCH 1/2] Refactor on_reagent_change to pass through the change type --- code/__DEFINES/reagents.dm | 7 ++++++- code/datums/datumvars.dm | 2 +- code/game/mecha/equipment/tools/medical_tools.dm | 2 +- code/game/mecha/equipment/tools/work_tools.dm | 3 --- code/game/objects/items/devices/scanners.dm | 2 +- code/modules/food_and_drinks/drinks/drinks.dm | 8 ++++---- .../food_and_drinks/drinks/drinks/drinkingglass.dm | 10 ++++++++-- code/modules/food_and_drinks/food/condiment.dm | 10 +++++----- code/modules/food_and_drinks/food/customizables.dm | 2 +- code/modules/hydroponics/biogenerator.dm | 2 +- code/modules/integrated_electronics/passive/power.dm | 2 +- .../integrated_electronics/subtypes/reagents.dm | 12 ++++++------ code/modules/mob/living/simple_animal/bot/secbot.dm | 2 +- code/modules/reagents/chemistry/holder.dm | 9 ++++----- .../reagents/reagent_containers/blood_pack.dm | 2 +- code/modules/reagents/reagent_containers/bottle.dm | 2 +- code/modules/reagents/reagent_containers/glass.dm | 2 +- code/modules/reagents/reagent_containers/syringes.dm | 2 +- 18 files changed, 44 insertions(+), 37 deletions(-) diff --git a/code/__DEFINES/reagents.dm b/code/__DEFINES/reagents.dm index 9e17719e76..c85365db90 100644 --- a/code/__DEFINES/reagents.dm +++ b/code/__DEFINES/reagents.dm @@ -11,4 +11,9 @@ #define INGEST 2 //ingestion #define VAPOR 3 //foam, spray, blob attack #define PATCH 4 //patches -#define INJECT 5 //injection \ No newline at end of file +#define INJECT 5 //injection + +//defines passed through to the on_reagent_change proc +#define DEL_REAGENT 1 //reagent deleted (fully cleared) +#define ADD_REAGENT 2 // reagent added +#define REM_REAGENT 3 // reagent removed (may still exist) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 894f34345d..c609e63f0f 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -31,7 +31,7 @@ .["Show VV To Player"] = "?_src_=vars;[HrefToken(TRUE)];expose=[REF(src)]" -/datum/proc/on_reagent_change() +/datum/proc/on_reagent_change(changetype) return diff --git a/code/game/mecha/equipment/tools/medical_tools.dm b/code/game/mecha/equipment/tools/medical_tools.dm index cc0f935628..ebac3fb6d2 100644 --- a/code/game/mecha/equipment/tools/medical_tools.dm +++ b/code/game/mecha/equipment/tools/medical_tools.dm @@ -504,7 +504,7 @@ return 1 return -/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/on_reagent_change() +/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/on_reagent_change(changetype) ..() update_equip_info() return diff --git a/code/game/mecha/equipment/tools/work_tools.dm b/code/game/mecha/equipment/tools/work_tools.dm index 7ec90ab7ce..6d9fc9e13e 100644 --- a/code/game/mecha/equipment/tools/work_tools.dm +++ b/code/game/mecha/equipment/tools/work_tools.dm @@ -179,9 +179,6 @@ /obj/item/mecha_parts/mecha_equipment/extinguisher/get_equip_info() return "[..()] \[[src.reagents.total_volume]\]" -/obj/item/mecha_parts/mecha_equipment/extinguisher/on_reagent_change() - return - /obj/item/mecha_parts/mecha_equipment/extinguisher/can_attach(obj/mecha/working/M as obj) if(..()) if(istype(M)) diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index cbe1161422..bc99a28eea 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -417,7 +417,7 @@ MASS SPECTROMETER ..() create_reagents(5) -/obj/item/device/mass_spectrometer/on_reagent_change() +/obj/item/device/mass_spectrometer/on_reagent_change(changetype) if(reagents.total_volume) icon_state = initial(icon_state) + "_s" else diff --git a/code/modules/food_and_drinks/drinks/drinks.dm b/code/modules/food_and_drinks/drinks/drinks.dm index 72e3621131..5d3cd09f51 100644 --- a/code/modules/food_and_drinks/drinks/drinks.dm +++ b/code/modules/food_and_drinks/drinks/drinks.dm @@ -15,7 +15,7 @@ resistance_flags = NONE var/isGlass = TRUE //Whether the 'bottle' is made of glass or not so that milk cartons dont shatter when someone gets hit by it -/obj/item/reagent_containers/food/drinks/on_reagent_change() +/obj/item/reagent_containers/food/drinks/on_reagent_change(changetype) if (gulp_size < 5) gulp_size = 5 else @@ -209,7 +209,7 @@ item_state = "coffee" spillable = TRUE -/obj/item/reagent_containers/food/drinks/mug/on_reagent_change() +/obj/item/reagent_containers/food/drinks/mug/on_reagent_change(changetype) if(reagents.total_volume) icon_state = "tea" else @@ -261,7 +261,7 @@ spillable = TRUE isGlass = FALSE -/obj/item/reagent_containers/food/drinks/sillycup/on_reagent_change() +/obj/item/reagent_containers/food/drinks/sillycup/on_reagent_change(changetype) if(reagents.total_volume) icon_state = "water_cup" else @@ -289,7 +289,7 @@ transfer_fingerprints_to(B) qdel(src) -/obj/item/reagent_containers/food/drinks/sillycup/smallcarton/on_reagent_change() +/obj/item/reagent_containers/food/drinks/sillycup/smallcarton/on_reagent_change(changetype) if (reagents.reagent_list.len) switch(reagents.get_master_reagent_id()) if("orangejuice") diff --git a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm index 9f2f6650bc..875185afb1 100644 --- a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm @@ -12,7 +12,7 @@ resistance_flags = ACID_PROOF unique_rename = 1 -/obj/item/reagent_containers/food/drinks/drinkingglass/on_reagent_change() +/obj/item/reagent_containers/food/drinks/drinkingglass/on_reagent_change(changetype) cut_overlays() if(reagents.reagent_list.len) var/datum/reagent/R = reagents.get_master_reagent() @@ -46,7 +46,7 @@ volume = 15 materials = list(MAT_GLASS=100) -/obj/item/reagent_containers/food/drinks/drinkingglass/shotglass/on_reagent_change() +/obj/item/reagent_containers/food/drinks/drinkingglass/shotglass/on_reagent_change(changetype) cut_overlays() if (gulp_size < 15) @@ -74,9 +74,15 @@ desc = "A shot glass - the universal symbol for bad decisions." return +<<<<<<< HEAD /obj/item/reagent_containers/food/drinks/drinkingglass/filled/New() ..() on_reagent_change() +======= +/obj/item/reagent_containers/food/drinks/drinkingglass/filled/Initialize() + . = ..() + on_reagent_change(ADD_REAGENT) +>>>>>>> 73b25d7... Refactor on_reagent_change to pass through the change type (#32805) /obj/item/reagent_containers/food/drinks/drinkingglass/filled/soda name = "Soda Water" diff --git a/code/modules/food_and_drinks/food/condiment.dm b/code/modules/food_and_drinks/food/condiment.dm index c115ef51af..3e6e2e8450 100644 --- a/code/modules/food_and_drinks/food/condiment.dm +++ b/code/modules/food_and_drinks/food/condiment.dm @@ -13,7 +13,7 @@ container_type = OPENCONTAINER_1 possible_transfer_amounts = list(1, 5, 10, 15, 20, 25, 30, 50) volume = 50 - //Possible_states has the reagent id as key and a list of, in order, the icon_state, the name and the desc as values. Used in the on_reagent_change() to change names, descs and sprites. + //Possible_states has the reagent id as key and a list of, in order, the icon_state, the name and the desc as values. Used in the on_reagent_change(changetype) to change names, descs and sprites. var/list/possible_states = list( "ketchup" = list("ketchup", "ketchup bottle", "You feel more American already."), "capsaicin" = list("hotsauce", "hotsauce bottle", "You can almost TASTE the stomach ulcers now!"), @@ -80,7 +80,7 @@ var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this) to_chat(user, "You transfer [trans] units of the condiment to [target].") -/obj/item/reagent_containers/food/condiment/on_reagent_change() +/obj/item/reagent_containers/food/condiment/on_reagent_change(changetype) if(!possible_states.len) return if(reagents.reagent_list.len > 0) @@ -126,7 +126,7 @@ list_reagents = list("sodiumchloride" = 20) possible_states = list() -/obj/item/reagent_containers/food/condiment/saltshaker/on_reagent_change() +/obj/item/reagent_containers/food/condiment/saltshaker/on_reagent_change(changetype) if(reagents.reagent_list.len == 0) icon_state = "emptyshaker" else @@ -164,7 +164,7 @@ list_reagents = list("blackpepper" = 20) possible_states = list() -/obj/item/reagent_containers/food/condiment/peppermill/on_reagent_change() +/obj/item/reagent_containers/food/condiment/peppermill/on_reagent_change(changetype) if(reagents.reagent_list.len == 0) icon_state = "emptyshaker" else @@ -255,7 +255,7 @@ src.reagents.trans_to(target, amount_per_transfer_from_this) qdel(src) -/obj/item/reagent_containers/food/condiment/pack/on_reagent_change() +/obj/item/reagent_containers/food/condiment/pack/on_reagent_change(changetype) if(reagents.reagent_list.len > 0) var/main_reagent = reagents.get_master_reagent_id() if(main_reagent in possible_states) diff --git a/code/modules/food_and_drinks/food/customizables.dm b/code/modules/food_and_drinks/food/customizables.dm index 176e3fe8eb..3351a67d39 100644 --- a/code/modules/food_and_drinks/food/customizables.dm +++ b/code/modules/food_and_drinks/food/customizables.dm @@ -313,7 +313,7 @@ . = ..() return -/obj/item/reagent_containers/glass/bowl/on_reagent_change() +/obj/item/reagent_containers/glass/bowl/on_reagent_change(changetype) ..() update_icon() diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index d46875eb00..ff3c8b4309 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -53,7 +53,7 @@ productivity = P max_items = max_storage -/obj/machinery/biogenerator/on_reagent_change() //When the reagents change, change the icon as well. +/obj/machinery/biogenerator/on_reagent_change(changetype) //When the reagents change, change the icon as well. update_icon() /obj/machinery/biogenerator/update_icon() diff --git a/code/modules/integrated_electronics/passive/power.dm b/code/modules/integrated_electronics/passive/power.dm index 8b6cb562f0..7c7439d45b 100644 --- a/code/modules/integrated_electronics/passive/power.dm +++ b/code/modules/integrated_electronics/passive/power.dm @@ -113,7 +113,7 @@ push_data() ..() -/obj/item/integrated_circuit/passive/power/chemical_cell/on_reagent_change() +/obj/item/integrated_circuit/passive/power/chemical_cell/on_reagent_change(changetype) set_pin_data(IC_OUTPUT, 1, reagents.total_volume) push_data() diff --git a/code/modules/integrated_electronics/subtypes/reagents.dm b/code/modules/integrated_electronics/subtypes/reagents.dm index bdea98bae3..1793869237 100644 --- a/code/modules/integrated_electronics/subtypes/reagents.dm +++ b/code/modules/integrated_electronics/subtypes/reagents.dm @@ -28,9 +28,10 @@ var/smoke_radius = 5 var/notified = FALSE -/obj/item/integrated_circuit/reagent/smoke/on_reagent_change() - //reset warning - notified = FALSE +/obj/item/integrated_circuit/reagent/smoke/on_reagent_change(changetype) + //reset warning only if we have reagents now + if(changetype == ADD_REAGENT) + notified = FALSE set_pin_data(IC_OUTPUT, 1, reagents.total_volume) push_data() @@ -48,7 +49,6 @@ if(S) S.set_up(reagents, smoke_radius, location, notified) if(!notified) - //we have now notified notified = TRUE S.start() @@ -83,7 +83,7 @@ ..() -/obj/item/integrated_circuit/reagent/injector/on_reagent_change() +/obj/item/integrated_circuit/reagent/injector/on_reagent_change(changetype) set_pin_data(IC_OUTPUT, 1, reagents.total_volume) push_data() @@ -263,7 +263,7 @@ push_data() ..() -/obj/item/integrated_circuit/reagent/storage/on_reagent_change() +/obj/item/integrated_circuit/reagent/storage/on_reagent_change(changetype) set_pin_data(IC_OUTPUT, 1, reagents.total_volume) push_data() diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index 4300746901..03a5bec73b 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -54,7 +54,7 @@ new /obj/item/stock_parts/cell/potato(Tsec) var/obj/item/reagent_containers/food/drinks/drinkingglass/shotglass/S = new(Tsec) S.reagents.add_reagent("whiskey", 15) - S.on_reagent_change() + S.on_reagent_change(ADD_REAGENT) ..() /mob/living/simple_animal/bot/secbot/pingsky diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 5997d1d1c3..9c4bff72cb 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -1,5 +1,4 @@ - /////////////////////////////////////////////////////////////////////////////////// /datum/reagents @@ -428,7 +427,7 @@ reagent_list -= R update_total() if(my_atom) - my_atom.on_reagent_change() + my_atom.on_reagent_change(DEL_REAGENT) check_ignoreslow(my_atom) check_gofast(my_atom) check_goreallyfast(my_atom) @@ -526,7 +525,7 @@ R.volume += amount update_total() if(my_atom) - my_atom.on_reagent_change() + my_atom.on_reagent_change(ADD_REAGENT) R.on_merge(data, amount) if(!no_react) handle_reactions() @@ -545,7 +544,7 @@ update_total() if(my_atom) - my_atom.on_reagent_change() + my_atom.on_reagent_change(ADD_REAGENT) if(!no_react) handle_reactions() if(isliving(my_atom)) @@ -587,7 +586,7 @@ if(!safety)//So it does not handle reactions when it need not to handle_reactions() if(my_atom) - my_atom.on_reagent_change() + my_atom.on_reagent_change(REM_REAGENT) return TRUE return FALSE diff --git a/code/modules/reagents/reagent_containers/blood_pack.dm b/code/modules/reagents/reagent_containers/blood_pack.dm index d4b8e165ee..a4d766539f 100644 --- a/code/modules/reagents/reagent_containers/blood_pack.dm +++ b/code/modules/reagents/reagent_containers/blood_pack.dm @@ -13,7 +13,7 @@ reagents.add_reagent("blood", 200, list("donor"=null,"viruses"=null,"blood_DNA"=null,"blood_type"=blood_type,"resistances"=null,"trace_chem"=null)) update_icon() -/obj/item/reagent_containers/blood/on_reagent_change() +/obj/item/reagent_containers/blood/on_reagent_change(changetype) if(reagents) var/datum/reagent/blood/B = reagents.has_reagent("blood") if(B && B.data && B.data["blood_type"]) diff --git a/code/modules/reagents/reagent_containers/bottle.dm b/code/modules/reagents/reagent_containers/bottle.dm index d6fad81f64..6fad290676 100644 --- a/code/modules/reagents/reagent_containers/bottle.dm +++ b/code/modules/reagents/reagent_containers/bottle.dm @@ -15,7 +15,7 @@ icon_state = "bottle" update_icon() -/obj/item/reagent_containers/glass/bottle/on_reagent_change() +/obj/item/reagent_containers/glass/bottle/on_reagent_change(changetype) update_icon() /obj/item/reagent_containers/glass/bottle/update_icon() diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index 4e2e88c06d..20c4ba6933 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -126,7 +126,7 @@ . = ..() update_icon() -/obj/item/reagent_containers/glass/beaker/on_reagent_change() +/obj/item/reagent_containers/glass/beaker/on_reagent_change(changetype) update_icon() /obj/item/reagent_containers/glass/beaker/update_icon() diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index 1bd1eba3c4..9695caab02 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -21,7 +21,7 @@ mode = SYRINGE_INJECT update_icon() -/obj/item/reagent_containers/syringe/on_reagent_change() +/obj/item/reagent_containers/syringe/on_reagent_change(changetype) update_icon() /obj/item/reagent_containers/syringe/pickup(mob/user) From 44fb7ccdb791aa1bc55661e2dcb71bfbdf5a7e67 Mon Sep 17 00:00:00 2001 From: deathride58 Date: Fri, 24 Nov 2017 18:00:44 -0500 Subject: [PATCH 2/2] Update drinkingglass.dm --- code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm index 875185afb1..263d592303 100644 --- a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm @@ -74,15 +74,9 @@ desc = "A shot glass - the universal symbol for bad decisions." return -<<<<<<< HEAD -/obj/item/reagent_containers/food/drinks/drinkingglass/filled/New() - ..() - on_reagent_change() -======= /obj/item/reagent_containers/food/drinks/drinkingglass/filled/Initialize() . = ..() on_reagent_change(ADD_REAGENT) ->>>>>>> 73b25d7... Refactor on_reagent_change to pass through the change type (#32805) /obj/item/reagent_containers/food/drinks/drinkingglass/filled/soda name = "Soda Water"