# \[8561\] Catastrophically failing at crafting Cooked Liver and Cracklins does not consume components

**URL:** https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048
**Category:** The Garage
**Created:** [March 3, 2019, 5:58pm UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048 "2019-03-03T17:58:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![digitCruncher](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@digitCruncher](https://discourse.cataclysmdda.org/u/digitCruncher)
#### Post date: [March 3, 2019, 5:58pm UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/1 "2019-03-03T17:58:37Z")

</div>

As the title says. Trying to cook cooked liver or cracklins at skill level 1 has a chance of failing and destroying some ingredients. Currently though, there is no risk of that happening.

I don’t know if this is more widespread (does it only effect failing creating components with only one initial ingredient? Does it only fail for food items?), but those two recipes have been confirmed to be the ones that I have tested, and don’t have time for more testing ATM.

---

<div class="post-metadata">

### Author: ![digitCruncher](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@digitCruncher](https://discourse.cataclysmdda.org/u/digitCruncher)
#### Post date: [March 5, 2019, 6:04am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/2 "2019-03-05T06:04:34Z")

</div>

tl;dr: Change Line 446 of crafting.cpp from

`if( cou > 0 && one_in( 2 ) ) {`  
to  
`if( cou > 0 || one_in( 2 ) ) {`

I did a bit more research just now, and it is definitely broken. After cooking 20 lards at skill level 0 and 1, I never consumed any fat. After crafting 5 upgraded solar panels at skill level 0, I consumed the following: 1 solar panel, 30 copper wires, 8 amplifier circuits, 8 solar cells, 2 power converters, and no solder.

According to the comments though (line 444/445 of crafting.cpp)

```
    // Each component currently has 50% chance of not being consumed
    // Skip first item so failed craft with one item recipe always loses component

```

I don’t know how to compile and test exactly what is wrong, but it is certainly not working as intended. My hunch? Line 446 reads:

if( cou \> 0 && one\_in( 2 ) ) {

But if the comments are correct, it should read:

if( cou \> 0 || one\_in( 2 ) ) {

Currently, I think that it is _never_ consuming the first thing in the inventory list, instead of _always_ consuming the first thing in the inventory list.

---

<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: [March 5, 2019, 6:19am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/3 "2019-03-05T06:19:37Z")

</div>

make a pull request on the github if you’re confident it fixes is

---

<div class="post-metadata">

### Author: ![digitCruncher](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@digitCruncher](https://discourse.cataclysmdda.org/u/digitCruncher)
#### Post date: [March 5, 2019, 6:23am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/4 "2019-03-05T06:23:00Z")

</div>

I am not confident it fixes it (can’t compile it from source code), and haven’t got a github account etc., so someone else with github / a version that they can compile can go ahead and do that. That is my best guess from eyeballing the code.

---

<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: [March 5, 2019, 6:24am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/5 "2019-03-05T06:24:59Z")

</div>

I don’t have any time to test today, but I’ll compile and upload you a build with that exact change and you can report back, if testing goes well, I’ll make a PR

Windows x64 is fine right?

---

<div class="post-metadata">

### Author: ![digitCruncher](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@digitCruncher](https://discourse.cataclysmdda.org/u/digitCruncher)
#### Post date: [March 5, 2019, 7:09am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/6 "2019-03-05T07:09:10Z")

</div>

Yip, Windows x64 is what I am using. Thanks!

---

<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: [March 5, 2019, 7:11am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/7 "2019-03-05T07:11:56Z")

</div>

alright, paste this exe into the newest build and tell me if it’s fixed  
I don’t see why it wouldn’t work in the build you’re using though.  
[https://mega.nz/#!OZERyKyJ!kGB14X9F1Qo9GlwQPQQebprkhCOMxFvzquYJduwdd10](https://mega.nz/#!OZERyKyJ!kGB14X9F1Qo9GlwQPQQebprkhCOMxFvzquYJduwdd10)

---

<div class="post-metadata">

### Author: ![digitCruncher](https://avatars.discourse-cdn.com/v4/letter/d/cab0a1/32.png) [@digitCruncher](https://discourse.cataclysmdda.org/u/digitCruncher)
#### Post date: [March 5, 2019, 8:34am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/8 "2019-03-05T08:34:07Z")

</div>

Unfortunately it doesn’t look like that is the correct version at all… it is much too small, even when I compared it to the curses version at [http://dev.narc.ro/cataclysm/jenkins-latest/Windows\_x64/Curses/](http://dev.narc.ro/cataclysm/jenkins-latest/Windows_x64/Curses/). Maybe someone else will have more success testing it, but I have stayed up much too late, so I won’t be able to test it.

Some day I might spend some time working out how to compile it on my machine, and work out github. But for now I just report the bugs and suggest fixes. I don’t have time for much else \>.\>

---

<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: [March 5, 2019, 9:17am UTC](https://discourse.cataclysmdda.org/t/8561-catastrophically-failing-at-crafting-cooked-liver-and-cracklins-does-not-consume-components/19048/9 "2019-03-05T09:17:51Z")

</div>

That’s alright, I’ll put a PR up, seems like it fixes the issue, or at least the failure seems to consume some fat some times, but none other times if I start with a high cooking skill, debug it to zero, fail to craft lard.

But you did say it wasn’t consuming any on failure before, so I guess it works?

Edit:

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/28501>

  
here
