Git Product home page Git Product logo

Comments (16)

osuphobia avatar osuphobia commented on May 10, 2024 2

Finally found the exact points affecting how craft command deal with components on map.

When craft command (either from character or from basecamp) is to consume components on map, the function map::use_charges is called for components count_by_charges, and map::use_amount is called for components without charge.
If a furniture/terrain doesn't have the flag LIQUIDCONT, item in it that is count_by_charges will not be consumed.
Smoking rack and fermenting vat have the flag SEALED and don't have the flag LIQUIDCONT, so water or meat before removing of charges will not be consumed.
There is no such process in map::use_amount, so meat in somking rack is consumed in craft command now.

diff --git a/src/map.cpp b/src/map.cpp
index 2a70967c05..4803ed2411 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -5965,8 +5965,10 @@ std::list<item> map::use_amount( const std::vector<tripoint> &reachable_pts, con
         }
     }
     for( const tripoint &p : reachable_pts ) {
-        std::list<item> tmp = use_amount_square( p, type, quantity, filter );
-        ret.splice( ret.end(), tmp );
+        if( accessible_items( p ) ) {
+            std::list<item> tmp = use_amount_square( p, type, quantity, filter );
+            ret.splice( ret.end(), tmp );
+        }
     }
     return ret;
 }

This did fix the issue.

Thought that LIQUIDCONT is also the reason of items being counted in craft gui, but it did not work the way I expected. More test is needed.

from cataclysm-dda.

NetSysFire avatar NetSysFire commented on May 10, 2024

Both issues really do sound like a regression. Do you happen to know when approximately this bug was introduced? That could speed up the fix.

from cataclysm-dda.

IdleSol avatar IdleSol commented on May 10, 2024

I tried reproducing on a new save. And it didn't work. I started looking to see what the difference was. I found out that they are different errors.

In this case, the meat is wasted. But it's taken from a working smoking rack.

from cataclysm-dda.

IdleSol avatar IdleSol commented on May 10, 2024

Yeah, I tested it on corn kernels.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024

A sixth sense told me that this bug must be introduced when removing charges from food stuff.
Tested in https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-08-02-0307 and reproduced it, while things worked as intended in https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-07-31-0609.
Then I tried https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-08-02-0110, and the meat chunks out of the rack were consumed, so the reason of this issue should be #67356.

from cataclysm-dda.

NetSysFire avatar NetSysFire commented on May 10, 2024

CC @mqrause then, the author of the linked PR. Maybe they know what is happening here.

from cataclysm-dda.

mqrause avatar mqrause commented on May 10, 2024

A sixth sense told me that this bug must be introduced when removing charges from food stuff. Tested in https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-08-02-0307 and reproduced it, while things worked as intended in https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-07-31-0609. Then I tried https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2023-08-02-0110, and the meat chunks out of the rack were consumed, so the reason of this issue should be #67356.

I'm not sure I understand the conclusion. If experimental 2023-08-02-0307 merged that PR, but 2023-08-02-0110 already had the issue, the cause should be something different.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024

the meat chunks out of the rack were consumed

Sorry, maybe this sentence is misleading. I mean in 2023-08-02-0110 this issue is not existing, the chunks of meat in the smoking rack did not disappear, and the chunks outside were consumed correctly when crafting cooked meat.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024
20240422-0721-36.6119221.mp4

In 2023-08-02-0110 one chunk outside is consumed (total amount is 101 as the rack duplicated one chunk).

20240422-0731-57.7824247.mp4

In 2023-08-02-0307 the chunk in the rack is consumed (the duplicate bug is fixed so total amount is 100).

from cataclysm-dda.

mqrause avatar mqrause commented on May 10, 2024

That's curious. The PR in question just changes the charges count of the items put into the rack. That shouldn't have any effect on component selection for crafting. I suspect the real bug is hiding somewhere in the construction of the crafting inventory and that just surfaced it somehow.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024

Maybe you are right, I'll try to figure it out.
Just found something quite interesting.

If you migrate a save before 2023-08-02-0307 that already has a smoking rack, chunks in it will not be wrongly consumed.
But a new smoking rack built after migrating to 2023-08-02-0307 and newer version causes this issue again.
Wakarusa-trimmed.tar.gz

from cataclysm-dda.

IdleSol avatar IdleSol commented on May 10, 2024

You don't cook meat right. More specifically, you have the wrong kitchen. You need one like this:
test

Index 1. brazier + plank
Index 2. smoking rack (12ΠΊ charcoal + 80 chunk of meat) (Note. I assume charcoal is optional, but I tested with it.)
Index 3. brazier + plank (Note. Optional. I used for symmetry to eliminate some options.)
Index 4..6 One chunk of meat

You need the following versions of the game:

I don't know how they react to saves. In each version, I started with a clean character and options.

Steps to reproduce

  1. Build a fire in the braziers
  2. Create a save
  3. Start cooking the meat according to the recipe for cooked meat. One chunk at a time. (You need a pot or a frying pan.)
  4. Look at the meat lying on the ground
    Π°. Versions 2023-07-31-0609. Meat is spent sequentially: 4-5-6. After the meat from point 6 has been spent. The recipe becomes inactive.
    b. Versions 2023-07-31-1032. Meat is spent sequentially: 4-5. But at point 6, no meat is wasted. It is taken from the smoking rack

You can load from a save and try different character positions. At the top brazier, at the bottom brazier. Or anywhere else. The meat at point 6 is not wasted.

To summarize

Formally, the bug appeared after switching from charges to individual pieces. #60885
@osuphobia You guessed the "author" @mqrause But I highly doubt that the problem is in fixing it.

Rather in the algorithm of searching for components for crafting. He looks for them from right to left left to right, starting from the upper right left corner. And when he reaches the rack, he finds them.

A possible fix would be to mark the contents of the rack as ignored components.

The only question is what else might qualify. Water in a washing machine? In an autoclave? Charcoal in a smoking rack when creating steel? That is, does it only apply to the smoking rack or is it a more general problem.

from cataclysm-dda.

IdleSol avatar IdleSol commented on May 10, 2024

Tested the water in a home washing machine. It is not wasted in making clean water.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024

@IdleSol
Tested again, you are partly right.
Tools and fuels are irrelevant (for cooked meat shovel is enough), the game just attempts to consume components from the top left to bottom right, searching row by row. (You said right to left)
z1x2
Functions for crafting seems to treat items with/without charge differently, I'm still viewing them.

from cataclysm-dda.

IdleSol avatar IdleSol commented on May 10, 2024

Oh, I'm confusing right-left again.

from cataclysm-dda.

osuphobia avatar osuphobia commented on May 10, 2024

The only question is what else might qualify. Water in a washing machine? In an autoclave? Charcoal in a smoking rack when creating steel? That is, does it only apply to the smoking rack or is it a more general problem.

Tested wood keg and wood fermenting vat (added brewable data to water so it can be poured into the fermenting vat).
Water in the keg will be consumed when crafting clean water, while water in the vat will not. Water in the keg is counted when checking the recipe in the crafting gui.

So we got three conditions:

  1. Smoking rack. Components in it will not be counted in the crafting gui, but will be consumed in crafting command.
  2. Wood keg. Components in it will both be counted in the crafting gui and consumed in crafting command.
  3. Fermenting vat. Components in it will nether be counted in the crafting gui nor be consumed in crafting command.

For charcoal in a smoking rack, it will not be consumed, as it is loaded in the fake_char_smoker pseudo tool.
Washing machine and autoclave are Appliance/Power Grid things, did not check that part of functions.

from cataclysm-dda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.