From a8e27402af2a8b7e4339cea0cc4cc5258c5f278f Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Wed, 27 Nov 2024 10:28:32 +0100 Subject: [PATCH 1/2] Fixed possible to read books stored discharged smarthpone. Fixes #77919. The cause of the bug was that in the read menu it was not checked if the book was stored in smartphone with enough charge to read. This was fixed by checking if the book is stored in a smartphone with enough charge to read. --- src/game_inventory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 7d2b8ada9fa92..9f232d4a55afb 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1459,7 +1459,11 @@ class read_inventory_preset: public pickup_inventory_preset } bool is_shown( const item_location &loc ) const override { - return loc->is_book() || loc->type->can_use( "learn_spell" ); + const item_location p_loc = loc.parent_item(); + + return ( loc->is_book() || loc->type->can_use( "learn_spell" ) ) && + ( p_loc.where() == item_location::type::invalid || !p_loc->is_ebook_storage() || + p_loc->energy_remaining().value() >= 1000000 ); } std::string get_denial( const item_location &loc ) const override { From 7496650a9878883709f73d3cfa87eda66c4b8ed4 Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Wed, 27 Nov 2024 20:23:46 +0100 Subject: [PATCH 2/2] Simplified energy comparison in condition. --- src/game_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index 9f232d4a55afb..d0cda04844fb5 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -1463,7 +1463,7 @@ class read_inventory_preset: public pickup_inventory_preset return ( loc->is_book() || loc->type->can_use( "learn_spell" ) ) && ( p_loc.where() == item_location::type::invalid || !p_loc->is_ebook_storage() || - p_loc->energy_remaining().value() >= 1000000 ); + p_loc->energy_remaining() >= 1_kJ ); } std::string get_denial( const item_location &loc ) const override {