# The current system for food temperatures is flawed

**URL:** https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119
**Category:** The Drawing Board
**Created:** [October 23, 2018, 8:20am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119 "2018-10-23T08:20:08Z")
**Posts on this page:** 17
**Page:** 2

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [December 30, 2018, 8:11am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/21 "2018-12-30T08:11:29Z")

</div>

Working prototype

 ![](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/2X/8/87eed1269a5afb5772eade3aef4a2a5ef8f37a0a.png)

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?

---

<div class="post-metadata">

### Author: ![Daeros13](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/daeros13/32/3996_2.png) [@Daeros13](https://discourse.cataclysmdda.org/u/Daeros13)
#### Post date: [December 30, 2018, 8:37am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/22 "2018-12-30T08:37:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [December 30, 2018, 9:58pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/23 "2018-12-30T21:58:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Stone](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/stone/32/2507_2.png) [@Stone](https://discourse.cataclysmdda.org/u/Stone)
#### Post date: [December 30, 2018, 10:08pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/24 "2018-12-30T22:08:37Z")

</div>

Could always debug them in

---

<div class="post-metadata">

### Author: ![Mantar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mantar/32/42_2.png) [@Mantar](https://discourse.cataclysmdda.org/u/Mantar)
#### Post date: [December 31, 2018, 12:29am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/25 "2018-12-31T00:29:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)
#### Post date: [December 31, 2018, 3:26am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/26 "2018-12-31T03:26:14Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ecchi\_squid](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ecchi_squid/32/6386_2.png) [@ecchi\_squid](https://discourse.cataclysmdda.org/u/ecchi_squid)
#### Post date: [December 31, 2018, 5:30am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/27 "2018-12-31T05:30:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ecchi\_squid](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ecchi_squid/32/6386_2.png) [@ecchi\_squid](https://discourse.cataclysmdda.org/u/ecchi_squid)
#### Post date: [December 31, 2018, 5:37am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/28 "2018-12-31T05:37:20Z")

</div>

In all seriousness I admire how much you know. Lol

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [December 31, 2018, 8:20am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/29 "2018-12-31T08:20:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [December 31, 2018, 4:13pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/30 "2018-12-31T16:13:02Z")

</div>

Well here are the changes [https://github.com/CleverRaven/Cataclysm-DDA/pull/27387](https://github.com/CleverRaven/Cataclysm-DDA/pull/27387)  
I hope it has all the changed files.

---

<div class="post-metadata">

### Author: ![Poragon](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/poragon/32/4161_2.png) [@Poragon](https://discourse.cataclysmdda.org/u/Poragon)
#### Post date: [December 31, 2018, 6:28pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/31 "2018-12-31T18:28:32Z")

</div>

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!

![](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/2X/d/d650feb3136539ec1e32fcca1b4490bf0f4f765d.png)

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [January 1, 2019, 9:09pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/32 "2019-01-01T21:09:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [January 18, 2019, 10:30am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/33 "2019-01-18T10:30:58Z")

</div>

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:

```
[
  {
    "type": "THERMAL_PROPERTIES",
    "id": "water",
    "specific_heat_liquid": 4.186,
    "specific_heat_solid": 2.108,
    "latent_heat": 334,
  },
  {
    "type": "THERMAL_PROPERTIES",
    "id": "raw_meat",
    "specific_heat_liquid": 3.5,
    "specific_heat_solid": 2.2,
    "latent_heat": 230,
  },
  {
    "type": "THERMAL_PROPERTIES",
    "id": "sausage",
    "specific_heat_liquid": 3.1,
    "specific_heat_solid": 2.3,
    "latent_heat": 170,
  },
  {
    "type": "THERMAL_PROPERTIES",
    "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?

---

<div class="post-metadata">

### Author: ![dissociativity](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/dissociativity/32/4967_2.png) [@dissociativity](https://discourse.cataclysmdda.org/u/dissociativity)
#### Post date: [January 18, 2019, 10:32am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/34 "2019-01-18T10:32:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [January 18, 2019, 10:59am UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/35 "2019-01-18T10:59:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Noob\_Noob](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Noob\_Noob](https://discourse.cataclysmdda.org/u/Noob_Noob)
#### Post date: [January 18, 2019, 12:22pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/36 "2019-01-18T12:22:31Z")

</div>

Wow I love you, nice work

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [January 18, 2019, 2:26pm UTC](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119/37 "2019-01-18T14:26:29Z")

</div>

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.

[Previous page](https://discourse.cataclysmdda.org/t/the-current-system-for-food-temperatures-is-flawed/17119.md?page=1)
