From 552cbe51daa7d9103880d8a3ee258abe27377602 Mon Sep 17 00:00:00 2001 From: scarf Date: Fri, 29 Dec 2023 11:27:58 +0900 Subject: [PATCH] fix: prevent debugmsg while refilling liquid container with another one (#4010) check emptiness before removing container contents --- src/item.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index 3e9c38ec105e..25051aeb76ce 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -8248,8 +8248,11 @@ bool item::reload( player &u, item &loc, int qty ) } } + // we have transfered ammo from the container to the item + // therefore, we erase the 0-charge item inside container + // TODO: why don't we just remove 0-charge items? if( ammo->charges == 0 && !ammo->has_flag( flag_SPEEDLOADER ) ) { - if( container != nullptr ) { + if( container != nullptr && !container->contents.empty() ) { container->remove_item( container->contents.front() ); u.inv_restack( ); // emptied containers do not stack with non-empty ones } else {