-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jsonify water boiling and other temperature effects on the item #78562
base: master
Are you sure you want to change the base?
Conversation
Visual Studio debugger takes AGES to show value of any struct members, but even longer for members that are down the list (since it seemingly retrieves them in order, and in order to see the `name` halfway through the struct you need to first see milling data, and weight and its pockets and...)
Two quesitons: to this particular change, shouldn't we specify for how long the temperature should last for boiling to happen? |
Good idea, but out of scope of this PR. It would no longer be a jsonification, but instead a new feature, and adding it seems not straightforward at a glance. Adding the neccessary duration to the json would be trivial tho (in other words, the proposed json system is easily extensible) FWIW the water boiling is not instant. It took me an hour of waiting for 0.5L of water in the pot to become water_clean. For some reason this does not work as well for meat. I suspect because I was setting a bit lower transition temperature for it, but as I mentioned in the OP i did not spend too much time debugging.
I have no strong opinion on this, since I have only learned of its existence today. If the whole system gets removed, I would be almost equally happy since the goal of un-hardcoding the water is still achieved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, there's not too much use of the system beyond specifically water->clean water transformation. The only others I could think of were:
This is kind of my immediate concern, in that it lacks a clear use case. The player's ability to manipulate temperature of an item is very limited, and in cases where they can (i.e. boiling water) it only currently exists because it's vital to survival.
To put on my snobbery hat, JSONizing this system introduces a suggestion that these things should happen through the temperature system. That if you wanted to turn raw meat into cooked meat or whatever it's valid to just drop it on the fire and done. It (like the original water boiling effect) is meant to bypass the crafting system, but without a clear need for doing so.
Anyway I have only minor nitpicks with the PR's implementation
|
||
static void load_temperature_effects( | ||
const JsonObject &jo, const std::string_view member, | ||
cata::value_ptr<islot_temperature_effects> &slotptr, const std::string &src ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang error here. Looks like you pass along src
but forgot to check if two definitions come from the same source?
@@ -1228,6 +1243,14 @@ struct itype { | |||
|
|||
using FlagsSetType = std::set<flag_id>; | |||
|
|||
protected: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you made a comment for this (quoted below), could you expand on what you meant? I've never had any trouble debugging in VS regardless of where a member is placed inside a struct. Do you mean scrolling through the raw data shown when you hover a variable, while the program is breakpointed?
(P.s.: driveby change - i've moved itype::name field to be the first field in the struct to make debugging in VS less agonizing. No behavior change, no save compat issues or anything of that sort)
I would suggest that an immediate use case would be expanding this to teas and coffees. |
Summary
Infrastructure "Jsonify water boiling and other temperature effects on the item"
Purpose of change
I have long known that I can turn
water
intoclean water
by crafting (&
) it - using some heat and a container suited for boiling.But just today I have found out that I don't actually need to spend time watching the kettle boil! I can just put it into the fire, go away, come back some time later to nice
clean water
waiting for me. This is great!However, to my bigger surprise this auto-boiling handling is hardcoded in C++ and only works for
water
->clean water
specifically.I thought that hardcode is bad, and JSON is good and set to move the logic into JSON (and perhaps apply it to more different use cases!).
Describe the solution
Add a new field to item json (and the deserialization thereof). I'll copy-paste the new docs:
Utilize this freshly added field for
water
totransform
it intowater_clean
at373 K
andremove_poison
.Change the hardcoded water transformation to instead iterate these
temperature_effect
s and execute any of those that get triggered.Remove the mentions of
"water"
,"water_clean"
fromitem.cpp
andunits::temperature boiling
from codebase.Describe alternatives you've considered
Testing
Made a firepit, set it on fire, put in a pot, filled it with water, waited for an hour, checked back, saw
clean water (hot)
Temporarily changed the water json to transform water into
cooking_oil
instead, repeated the above steps, sawvegetable cooking oil (hot)
Additional context
Honestly, there's not too much use of the system beyond specifically water->clean water transformation. The only others I could think of were:
1.5K1.5KK, i.e. 1500 kelvin, making it instantly cooked. I have not spent time debugging this further.material
rather thanitem
level?So this whole PR is just for clean-water un-hardcoding. For now.
(P.s.: driveby change - i've moved
itype::name
field to be the first field in the struct to make debugging in VS less agonizing. No behavior change, no save compat issues or anything of that sort)