The current system for food temperatures is flawed


Working prototype

Soring the energy in joules into an integer seems to be not precise enough but that should be fixable.

How careful do I need to be with item tags? For example can I just remove “WARM” tag from the item or should I first check if the item has that tag? Same for adding them, can I just add “WARM” tag or should I first check if the item already has that?


First off, know this, my C++ is probably ranked D- by know, been a very long time for me.

Second, I am only picking your brain to hopefully help in some obscure, unknown to me way.

I would think to check for the tag first to avoid running unnecessary code. This should help keep processor overhead down. And have you benchmarked the code to see how much time it adds? Will it lag the game on insane items being calculated for each turn?

If none of this is helpful, feel free to ignore me. LOL


There is starting to be enough math in to start testing performance.

If anyone has saves with massive numbers of food stacks in one place you can upload them somewhere and link them here.

Preferably small folder size and no extra mods.


Could always debug them in


Yeah, but if you want to test real-world use cases it’s not ideal.


Store the energy in millijoules or microjoules - an int can store 2147483648, and that’s up to 2 kJ with 6 significant figures. How large a number at how much precision do you need?


I want to be like you when I grow up…including the stache.


In all seriousness I admire how much you know. Lol


Item calculations are done per stack. Spawning 1000 items would only create one item stack. Debugging in 10k items one by one would be pretty tiresome.

I’m storing the energy in centijoules (0.01 J).
The biggest item in game with temperature is probably 200 l water tank.
Energy in 200 l of liquid water = 200000 g * ( 273.15 K * 2.108 J/gK + 334 J/g ) = 181960040 J = 18196004000 cJ
That thing can’t even be in liquid form at 0 °C without overflowing the integer.
You rarely think on how massive ammounts of energy melting water takes. The ice -> water change alone is 6680000000 cJ for 200 l of water.

Saving half joules in there should work. That would allow 200 l water tank to heat to around 1000 °C before issues start and with longer calculation intervals that should be accurate enough. Not sure how hot temperatures the system would need to handle.

At first it seemed that I would need much better precision but I had just messed with units.


Well here are the changes
I hope it has all the changed files.


I saw your PR on the github and could not find you on the discord, so I brought you a moni hug from there to here. This is an amazing first contribution, I hope all possible kinks and such are worked out and the PR goes smoothly!


I still need those saves with massive number of food stacks. (spawning items with debug menu will spawn X number of items in one stack. This will be calculated as single item.)

Performance with large number of items is still completely untested.


It is time to start adding the thermal properties to foods. And I could do with some help on how to do it.

The original plan was this:
Add “specific_heat_liquid”, “specific_heat_solid” abd “latent_heat” to all foods.
But we don’t really need unique values for all foods.

New plan:
Have a json file that defines different thermal properties for groupos of items.

Something like this:

    "id": "water",
    "specific_heat_liquid": 4.186,
    "specific_heat_solid": 2.108,
    "latent_heat": 334,
    "id": "raw_meat",
    "specific_heat_liquid": 3.5,
    "specific_heat_solid": 2.2,
    "latent_heat": 230,
    "id": "sausage",
    "specific_heat_liquid": 3.1,
    "specific_heat_solid": 2.3,
    "latent_heat": 170,
    "id": "fruit",
    "specific_heat_liquid": 3.8,
    "specific_heat_solid": 2,
    "latent_heat": 270,

(freezing temperatures could also be added here later. Most foods just freeze at 0 C even if they should freeze a bit later)

Then each raw meat item would just have “thermal group”: “meat” in them.

But I don’t know how to do this.

  • How to make the game load this json?
  • How to get the thermal properties based on the id?


I think a good way to do this would be able to use the material (flesh, veggy, wheat, ect), the item’s quench value to determine liquid content and weight?

Per-item values for everything otherwise sounds like hell.


The material could maybe be used. But there would be some problems.

How to handle foods that have multiple materials?
Some foods have no materials (only few odd ones like wax and royal jelly).
Some odd ones like “tomato” being separate material from “vegetable”. I guess they were meant for the allergy/food intolerance system.
No “dry” material. Dried mushrooms and fresh mushrooms are both “mushroom”.
No “cooked” material. Vegetable dishes would be like fresh vegetables. And then vegetable dishes would behave differently from meat dishes.


Wow I love you, nice work


After thinking for a while the already existing “material” could work well enough.

For foods with multiple materials just use the first material and ignore the rest. Add few new materials to fill some holes.