CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.68k stars 4.19k forks source link

can't refill my 2.5L canteen #60282

Open pantherpusher opened 2 years ago

pantherpusher commented 2 years ago

Describe the bug

when I try to refill my 2.5L canteen from a 200L barrel of clean water, it throws up the following error and doesn't put water into the canteen

DEBUG : tried to put an item (water_clean, amount 1) in a container (2lcanteen) that cannot contain it

FUNCTION : fill_with FILE : D:\a\Cataclysm-DDA\Cataclysm-DDA\src\item.cpp LINE : 12067 VERSION : 60f648c

Steps to reproduce

  1. have a 200L barrel of clean water and an empty 2.5L canteen
  2. Set the canteen's pocket to not automatically be used to carry stuff
  3. Try to reload the canteen with the water from the barrel
  4. Get the error

Expected behavior

For the canteen to have water in it

Screenshots

No response

Versions and configuration

Additional context

No response

Night-Pryanik commented 2 years ago

Set the canteen's pocket to not automatically be used to carry stuff

Please describe in details this point.

pantherpusher commented 2 years ago

Enter the item menu for the canteen and select pocket settings. image Toggle autopickup so that items will not be inserted into the pocket unless manually inserted image

hexagonrecursion commented 2 years ago

/confirmed

 DEBUG    : tried to put an item (water, amount 1) in a container (2lcanteen) that cannot contain it

 FUNCTION : int item::fill_with(const item&, int, bool, bool, bool)
 FILE     : src/item.cpp
 LINE     : 12066
 VERSION  : cee383c
hexagonrecursion commented 2 years ago

Toggling autopickup as described above is essential to reproducing this bug: if I skip this step, the bug does not trigger.

ZhilkinSerg commented 1 week ago

Setting ignore_settings to true should probably fix the issue and be kinda safe - I don't think autopickup is possible for liquids anyway:

diff --git a/src/item.cpp b/src/item.cpp
index 7ffa2bce87..69a5086ecc 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -11943,7 +11943,7 @@ bool item::reload( Character &u, item_location ammo, int qty )

     } else if( is_watertight_container() && ammo->made_of_from_type( phase_id::LIQUID ) ) {
         item contents( *ammo );
-        fill_with( contents, qty );
+        fill_with( contents, qty, false, false, true );
         if( ammo.has_parent() ) {
             ammo.parent_item()->contained_where( *ammo.get_item() )->on_contents_changed();
         }