Dead code removal, redundant text macros, drying rack now applies TRAIT_FOOD_CHEF_MADE. (#80677)

I've been coding a PR these couple days, and I've noticed a few
oversights, all related to food, while working on it.

This PR removes an unused, 12 years old datum, and some redundant text
macros in a text string, for processable items, that already uses the
bold spans. It also makes it so food made with a drying rack gets the
chef made trait, similarly to other methods (though not as foolproof).
This commit is contained in:
Ghom
2024-01-04 00:10:36 +00:00
committed by GitHub
parent 352627e04a
commit f3108f99be
6 changed files with 38 additions and 140 deletions
+1 -1
View File
@@ -130,7 +130,7 @@
#define COMSIG_ITEM_ON_JUICE "on_juice"
///from /obj/machinery/hydroponics/attackby(obj/item/O, mob/user, params) when an object is used as compost: (mob/user)
#define COMSIG_ITEM_ON_COMPOSTED "on_composted"
///Called when an item is dried by a drying rack:
///Called when an item is dried by a drying rack
#define COMSIG_ITEM_DRIED "item_dried"
///from base of obj/item/dropped(): (mob/user)
#define COMSIG_ITEM_DROPPED "item_drop"
+10 -5
View File
@@ -20,20 +20,20 @@
UnregisterSignal(target, COMSIG_FOOD_CONSUMED)
REMOVE_TRAIT(target, TRAIT_DRYABLE, ELEMENT_TRAIT(type))
/datum/element/dryable/proc/finish_drying(atom/source)
/datum/element/dryable/proc/finish_drying(atom/source, datum/weakref/drying_user)
SIGNAL_HANDLER
var/atom/dried_atom = source
if(dry_result == dried_atom.type)//if the dried type is the same as our currrent state, don't bother creating a whole new item, just re-color it.
var/atom/movable/resulting_atom = dried_atom
resulting_atom.add_atom_colour(COLOR_DRIED_TAN, FIXED_COLOUR_PRIORITY)
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
apply_dried_status(resulting_atom, drying_user)
resulting_atom.forceMove(source.drop_location())
return
else if(isstack(source)) //Check if its a sheet
var/obj/item/stack/itemstack = dried_atom
for(var/i in 1 to itemstack.amount)
var/atom/movable/resulting_atom = new dry_result(source.drop_location())
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
apply_dried_status(resulting_atom, drying_user)
qdel(source)
return
else if(istype(source, /obj/item/food) && ispath(dry_result, /obj/item/food))
@@ -41,11 +41,16 @@
var/obj/item/food/resulting_food = new dry_result(source.drop_location())
resulting_food.reagents.clear_reagents()
source_food.reagents.trans_to(resulting_food, source_food.reagents.total_volume)
ADD_TRAIT(resulting_food, TRAIT_DRIED, ELEMENT_TRAIT(type))
apply_dried_status(resulting_food, drying_user)
qdel(source)
return
else
var/atom/movable/resulting_atom = new dry_result(source.drop_location())
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
apply_dried_status(resulting_atom, drying_user)
qdel(source)
/datum/element/dryable/proc/apply_dried_status(atom/target, datum/weakref/drying_user)
ADD_TRAIT(target, TRAIT_DRIED, ELEMENT_TRAIT(type))
var/datum/mind/user_mind = drying_user?.resolve()
if(drying_user && istype(target, /obj/item/food))
ADD_TRAIT(target, TRAIT_FOOD_CHEF_MADE, REF(user_mind))
+2 -2
View File
@@ -71,9 +71,9 @@
else
if(result_gender == PLURAL)
examine_list += span_notice("It can be turned into some [result_name] with [span_bold(tool_desc)]</b>!")
examine_list += span_notice("It can be turned into some [result_name] with [span_bold(tool_desc)]!")
else
examine_list += span_notice("It can be turned into \a [result_name] with <b>[span_bold(tool_desc)]</b>!")
examine_list += span_notice("It can be turned into \a [result_name] with [span_bold(tool_desc)]!")
/**
* Adds context sensitivy directly to the processable file for screentips
-119
View File
@@ -1,119 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * *
* /datum/recipe by rastaf0 13 apr 2011 *
* * * * * * * * * * * * * * * * * * * * * * * * * *
* This is powerful and flexible recipe system.
* It exists not only for food.
* supports both reagents and objects as prerequisites.
* In order to use this system you have to define a deriative from /datum/recipe
* * reagents are reagents. Acid, milc, booze, etc.
* * items are objects. Fruits, tools, circuit boards.
* * result is type to create as new object
* * time is optional parameter, you shall use in in your machine,
* default /datum/recipe/ procs does not rely on this parameter.
*
* Functions you need:
* /datum/recipe/proc/make(obj/container as obj)
* Creates result inside container,
* deletes prerequisite reagents,
* transfers reagents from prerequisite objects,
* deletes all prerequisite objects (even not needed for recipe at the moment).
*
* /proc/select_recipe(list/datum/recipe/avaiable_recipes), obj/obj as obj, exact = 1)
* Wonderful function that select suitable recipe for you.
* obj is a machine (or magik hat) with prerequisites,
* exact = 0 forces algorithm to ignore superfluous stuff.
*
*
* Functions you do not need to call directly but could:
* /datum/recipe/proc/check_reagents(datum/reagents/avail_reagents)
* //1=precisely, 0=insufficiently, -1=superfluous
*
* /datum/recipe/proc/check_items(obj/container as obj)
* //1=precisely, 0=insufficiently, -1=superfluous
*
* */
/datum/recipe
var/list/reagents_list // example: = list(/datum/reagent/consumable/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/result //example: = /obj/item/food/donut/plain
var/time = 100 // 1/10 part of second
/datum/recipe/proc/check_reagents(datum/reagents/avail_reagents) //1=precisely, 0=insufficiently, -1=superfluous
. = 1
for (var/r_r in reagents_list)
var/aval_r_amnt = avail_reagents.get_reagent_amount(r_r)
if (!(abs(aval_r_amnt - reagents_list[r_r])<0.5)) //if NOT equals
if (aval_r_amnt>reagents_list[r_r])
. = -1
else
return 0
if ((reagents_list?(reagents_list.len):(0)) < avail_reagents.reagent_list.len)
return -1
return .
/datum/recipe/proc/check_items(obj/container) //1=precisely, 0=insufficiently, -1=superfluous
if (!items)
if (locate(/obj/) in container)
return -1
else
return 1
. = 1
var/list/checklist = items.Copy()
for (var/obj/O in container)
var/found = 0
for (var/type in checklist)
if (istype(O,type))
checklist-=type
found = 1
break
if (!found)
. = -1
if (checklist.len)
return 0
return .
//general version
/datum/recipe/proc/make(obj/container)
var/obj/result_obj = new result(container)
for (var/obj/O in (container.contents-result_obj))
O.reagents.trans_to(result_obj, O.reagents.total_volume)
qdel(O)
container.reagents.clear_reagents()
return result_obj
// food-related
/datum/recipe/proc/make_food(obj/container)
var/obj/result_obj = new result(container)
for (var/obj/O in (container.contents-result_obj))
if (O.reagents)
O.reagents.del_reagent(/datum/reagent/consumable/nutriment)
O.reagents.trans_to(result_obj, O.reagents.total_volume)
qdel(O)
container.reagents.clear_reagents()
return result_obj
/proc/select_recipe(list/datum/recipe/avaiable_recipes, obj/obj, exact = 1 as num)
if (!exact)
exact = -1
var/list/datum/recipe/possible_recipes = new
for (var/datum/recipe/recipe in avaiable_recipes)
if (recipe.check_reagents(obj.reagents) == exact && recipe.check_items(obj) == exact)
possible_recipes+=recipe
if (possible_recipes.len == 0)
return null
else if (possible_recipes.len == 1)
return possible_recipes[1]
else //okay, let's select the most complicated recipe
var/r_count = 0
var/i_count = 0
. = possible_recipes[1]
for (var/datum/recipe/recipe in possible_recipes)
var/N_i = (recipe.items)?(recipe.items.len):0
var/N_r = (recipe.reagents_list)?(recipe.reagents_list.len):0
if (N_i > i_count || (N_i == i_count && N_r > r_count ))
r_count = N_r
i_count = N_i
. = recipe
return .
@@ -265,7 +265,7 @@
!(weapon.flags_1 & HOLOGRAM_1) && \
accept_check(weapon) \
)
load(weapon)
load(weapon, user)
user.visible_message(span_notice("[user] adds \the [weapon] to \the [src]."), span_notice("You add \the [weapon] to \the [src]."))
SStgui.update_uis(src)
if(visible_contents)
@@ -282,7 +282,7 @@
!(object.flags_1 & HOLOGRAM_1) && \
accept_check(object) \
)
load(object)
load(object, user)
loaded++
SStgui.update_uis(src)
@@ -328,7 +328,7 @@
* Arguments
* * [weapon][obj/item] - the item to load. If the item is being held by a mo it will transfer it from hand else directly force move
*/
/obj/machinery/smartfridge/proc/load(obj/item/weapon)
/obj/machinery/smartfridge/proc/load(obj/item/weapon, mob/user)
if(ismob(weapon.loc))
var/mob/owner = weapon.loc
if(!owner.transferItemToLoc(weapon, src))
@@ -437,6 +437,8 @@
can_atmos_pass = ATMOS_PASS_YES
/// Is the rack currently drying stuff
var/drying = FALSE
/// The reference to the last user's mind. Needed for the chef made trait to be properly applied correctly to dried food.
var/datum/weakref/current_user
/obj/machinery/smartfridge/drying_rack/Initialize(mapload)
. = ..()
@@ -447,6 +449,10 @@
//so we don't drop any of the parent smart fridge parts upon deconstruction
clear_components()
/obj/machinery/smartfridge/drying_rack/Destroy()
current_user = null
return ..()
/// We cleared out the components in initialize so we can optimize this
/obj/machinery/smartfridge/drying_rack/visible_items()
return contents.len
@@ -505,7 +511,7 @@
switch(action)
if("Dry")
toggle_drying(FALSE)
toggle_drying(FALSE, usr)
return TRUE
/obj/machinery/smartfridge/drying_rack/powered()
@@ -516,9 +522,13 @@
if(!powered())
toggle_drying(TRUE)
/obj/machinery/smartfridge/drying_rack/load(obj/item/dried_object) //For updating the filled overlay
/obj/machinery/smartfridge/drying_rack/load(obj/item/dried_object, mob/user) //For updating the filled overlay
. = ..()
if(!.)
return
update_appearance()
if(drying && user?.mind)
current_user = WEAKREF(user.mind)
/obj/machinery/smartfridge/drying_rack/update_overlays()
. = ..()
@@ -546,17 +556,20 @@
* Arguments
* * forceoff - if TRUE will force the dryer off always
*/
/obj/machinery/smartfridge/drying_rack/proc/toggle_drying(forceoff)
/obj/machinery/smartfridge/drying_rack/proc/toggle_drying(forceoff, mob/user)
if(drying || forceoff)
drying = FALSE
current_user = FALSE
update_use_power(IDLE_POWER_USE)
else
drying = TRUE
if(user?.mind)
current_user = WEAKREF(user.mind)
update_use_power(ACTIVE_POWER_USE)
update_appearance()
/obj/machinery/smartfridge/drying_rack/proc/rack_dry(obj/item/target)
SEND_SIGNAL(target, COMSIG_ITEM_DRIED)
SEND_SIGNAL(target, COMSIG_ITEM_DRIED, current_user)
/obj/machinery/smartfridge/drying_rack/emp_act(severity)
. = ..()
@@ -647,17 +660,17 @@
/obj/machinery/smartfridge/organ/accept_check(obj/item/O)
return (isorgan(O) || isbodypart(O))
/obj/machinery/smartfridge/organ/load(obj/item/O)
/obj/machinery/smartfridge/organ/load(obj/item/item, mob/user)
. = ..()
if(!.) //if the item loads, clear can_decompose
return
if(isorgan(O))
var/obj/item/organ/organ = O
if(isorgan(item))
var/obj/item/organ/organ = item
organ.organ_flags |= ORGAN_FROZEN
if(isbodypart(O))
var/obj/item/bodypart/bodypart = O
if(isbodypart(item))
var/obj/item/bodypart/bodypart = item
for(var/obj/item/organ/stored in bodypart.contents)
stored.organ_flags |= ORGAN_FROZEN
-1
View File
@@ -779,7 +779,6 @@
#include "code\datums\position_point_vector.dm"
#include "code\datums\profiling.dm"
#include "code\datums\progressbar.dm"
#include "code\datums\recipe.dm"
#include "code\datums\request_message.dm"
#include "code\datums\ruins.dm"
#include "code\datums\saymode.dm"