CleverRaven / Cataclysm-DDA

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

Downloaded encryption codes (for mission) not shown on USB drive - save attached #64126

Closed matt32106 closed 1 year ago

matt32106 commented 1 year ago

Describe the bug

I am doing the download encryption codes mission. I opened the console, download the codes but they are not shown on the USB drive. See save attached.

Attach save file

Usher-trimmed.tar.gz

Steps to reproduce

E to open console Enter 3 times The console says Software downloaded Look at inventory, the 3 USB drives all look empty (it seems that in fact the codes are downloaded to the USB drive but they are just not showing in the inventory window).

Expected behavior

One of the USB drives should display the fact that it contains the codes

Screenshots

No response

Versions and configuration

Additional context

No response

aahue1889 commented 1 year ago

Going to try and Repro for Windows

anoobindisguise commented 1 year ago

It looks like the bug where USBs don't show their contents struck again. It happens once per experimental apparently. You probably have the software, the USB is just not telling you.

matt32106 commented 1 year ago

the USB is just not telling you. Yes! I tried teleport to base and I could complete the mission. I'll EDIT the dezscription of the bug, thanks.

aahue1889 commented 1 year ago

Do you know if there is a fix in the making for this? I am interested in looking for a fix.

aahue1889 commented 1 year ago

Repro Steps:

I can confirm this issue on windows OS as well

To quickly repro Spawn a Random NPC on Overmap

image

Go to Edit Player/NPC from debug menu and select newly spawned NPC and "Add Mission" to them

image

Add Download encryption codes

image


Speak to NPC and Accept mission - Debug Teleport to the expected location and find the Computer with Encryption Codes

I had to find them here - -2 Down in Lab

image

image


After the download you will no change the the USB you downloaded

image

--

However (as mentioned above) We can still complete the mission; its just that both the USB and Mission do not update upon you completing the download. image

aahue1889 commented 1 year ago

So if I were to go about fixing this:

I'd look for how "pocket_type": "SOFTWARE" can be surfaced in the Item description

  {
    "type": "TOOL",
    "id": "usb_drive",
    "symbol": ",",
    "color": "white",
    "name": { "str": "USB drive" },
    "description": "A USB thumb drive.  Useful for holding software.",
    "price": 10000,
    "price_postapoc": 10,
    "material": [ "plastic" ],
    "weight": "18 g",
    "volume": "5 ml",
    "pocket_data": [
      **{ "pocket_type": "SOFTWARE", "max_contains_volume": "1 L", "max_contains_weight": "1 kg" },**
      {
        "pocket_type": "EBOOK",
        "rigid": true,
        "max_contains_volume": "1 ml",
        "max_contains_weight": "1 g",
        "weight_multiplier": 0.0
      }
    ],
    "to_hit": -3,
    "flags": [ "MC_USED" ]
  },

Here is the 'pocket' logic of which I would have to mess with to get this to work

https://github.com/CleverRaven/Cataclysm-DDA/blob/58d681fb57312869f86a2800965c182c8c416d60/src/item_contents.cpp


If I don't see a response for this in the next 3 or so days, I'm going to tackle this officially.

andrei8l commented 1 year ago

I broke this in #63579

Quick fix:

diff --git a/src/item.cpp b/src/item.cpp
index 43aedd8496..e106d0c510 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -13758,7 +13758,9 @@ item const *item::this_or_single_content() const

 bool item::contents_only_one_type() const
 {
-    std::list<const item *> const items = all_items_top();
+    std::list<const item *> const items = is_software_storage()
+                                          ? all_items_top( item_pocket::pocket_type::SOFTWARE )
+                                          : all_items_top();
     return items.size() == 1 ||
            ( items.size() > 1 &&
     std::all_of( ++items.begin(), items.end(), [&items]( item const * e ) {

I would prefer to see item_contents::all_items_top( const std::function<bool( item_pocket & )> &filter ) exposed at the item-level though. This also needs a test unit in item_tname_test.cpp

aahue1889 commented 1 year ago

So what is the etiquette for something like this? @andrei8l

andrei8l commented 1 year ago

So what is the etiquette for something like this?

I've fixed this one but don't be afraid to just submit bug fixes. You won't step on anyone's toes.