Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Inventory Management not allowing some things to be dropped #79414

Open
Hypheonix opened this issue Jan 29, 2025 · 7 comments · May be fixed by #79422
Open

Advanced Inventory Management not allowing some things to be dropped #79414

Hypheonix opened this issue Jan 29, 2025 · 7 comments · May be fixed by #79422
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility

Comments

@Hypheonix
Copy link

Describe the bug

On experimental build 2025-01-29-1944, I am having an issue with the advanced inventory screen and placing items on the ground - somethings will drop and others will not. When using the drop interface I can drop all items onto the same spot that otherwise would not work in the advanced inventory screen.

Attach save file

Greensburg-trimmed.tar.gz

Steps to reproduce

Utilizing my save should suffice, I'm pretty much playing on vanilla CDDA besides tiles and music.

Expected behavior

I would expect that I can place things on the ground

Screenshots

Image

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.22631.4751 (23H2)
  • Game Version: cdda-experimental-2025-01-29-1944 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

Additional context

This just started happening when I updated to 1944.

@Hypheonix Hypheonix added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Jan 29, 2025
@nemesis688
Copy link

Also experiencing this on the same build. Started a fresh save and new world to double check and it is present there as well. Can move items into open containers such as bags and jars but can not move items into furniture/vehicles (in addition to the open ground) such as car trunks, fridges, cupboards..

@Hypheonix
Copy link
Author

Hypheonix commented Jan 29, 2025

When looking at the previous commit it could possibly be this:
#79409

@JeffCarr
Copy link

JeffCarr commented Jan 29, 2025

I have this exact same issue on the latest experimental. Happens with the advanced inventory when dropping on the floor, furniture, or vehicles.

@moxian
Copy link
Contributor

moxian commented Jan 30, 2025

I can confirm that the problem started appearing in cdda-experimental-2025-01-29-1944 (so #79409) , and did not exist in the previous release cdda-experimental-2025-01-29-1641

cc @marilynias for visibility

@CoroNaut
Copy link

I updated to the latest update with #79409. I found a difference between a few items that can be moved and those that can't... but can't figure out any more than that. Some items like pocket knife and plastic bottle (sealed)... can still be moved...

The difference being... the items I can move don't open the actions menu along side the item info when I press 'e' to examine the item. The items that claim the destination area is full when trying to move them do open the actions menu along side the item info when pressing 'e' to examine. (pictures in the details section)

Do the items that can be moved somehow report weight strangely... or the items that can't move reporting their weight strangely when considering the it.charges_per_weight( free_mass ) function...? Or perhaps the panes[dest].free_weight_capacity(); function reports the non-container location as having 0 max weight..?

definitely some jank here lol.

The items on the right pane are able to be moved without issue. The items on the left say "destination area full..."

Image

The items that can't be moved will open the item info window including the actions you can take on that item when 'e' examined.

Image
Image

The items that can be moved will open just the item info window upon being 'e' examined.

Image

TESTINGTWO-trimmed.tar.gz

  • OS: Windows
    • OS Version: 10.0.19045.5371 (22H2)
  • Game Version: cdda-experimental-2025-01-29-2148 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

@ProfoundDarkness
Copy link
Contributor

This is kinda strange... I made a tiny tweak to the code so I could inspect the results of charges_per_volume and charges_per_weight. Also set a breakpoint so I could step through and see whats up.

so couldn't figure out how to make the permalinked code look nice, including link followed by code.
https://github.com/CleverRaven/Cataclysm-DDA/blob/944ab309aec36cbb5f7828001a7afcf3a350a5aa/src/advanced_inv.cpp#L2244C1-L2245C77
const int room_for = std::min( it.charges_per_volume( free_volume ), it.charges_per_weight( free_mass ) );
https://github.com/CleverRaven/Cataclysm-DDA/blob/944ab309aec36cbb5f7828001a7afcf3a350a5aa/src/item.cpp#L1395C1-L1402C30
units::mass my_weight = weight(); if( my_weight == 0_gram ) { if( !suppress_warning ) { debugmsg( "Item '%s' with zero weight", tname() ); } return INFINITE_CHARGES; } return m / my_weight;

trying to move an item that won't move to an empty square, in function charges_per_weight the value for m = 9223372036854775807 and my_weight = 560000.
at the return it's m / my_weight...
back in advanced_inv, the value of m / my_weight ends up being a REALLY negative number (-892371491)...
Which ends up being the negative value out of the std::min...

Odd.
So by the time we end up back in advanced_inv ... (9223372036854775807 / 560000 = 16470307208669.2425125, stuffed into an int = 16470307208669) becomes -892371491

Ah... I think I see... the values being delt with don't always fit nice into an int. We'd need an extra check in advanced_inv::query_charges for if the value from charges_per_weight being negative of change the type of return to something bigger than int (mass is an int64) or an extra bid of code in item::charges_per_weight to return max int in the right condition... Or I'm off about the stuff after 'Odd' ... can't really concentrate rn

@marilynias
Copy link
Contributor

marilynias commented Jan 30, 2025

indeed, item::charges_per_weight() (which my PR relied on) tried to return a value greater than INT_MAX overflowing to negative. The ground has a practically infinite weight capacity, so the items it could hold were greater then INT_MAX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants