cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
696 stars 272 forks source link

Items are being added to type cache without building it first #1424

Closed Coolthulhu closed 2 years ago

Coolthulhu commented 2 years ago

Describe the bug

Brosef on discord reported this:

DEBUG    : Tried to add item to inventory using cache without building the items_type_cache.

 FUNCTION : add_item_by_items_type_cache
 FILE     : D:\a\Cataclysm-BN\Cataclysm-BN\src\inventory.cpp
 LINE     : 342
 VERSION  : BN 68b311f

He said it happened after dropping items into a vehicle.

Steps To Reproduce

Didn't try reproducing yet... When I get to it, I'll edit it here.

Expected behavior

Screenshots

Versions and configuration

Additional context

SaintCirno9 commented 2 years ago

I can reproduce it randomly when interacting with vehicle. Don't exactly know what happened though, weird. This might not cause any other problems, just a little annoying.

SaintCirno9 commented 2 years ago

Oh, I see. I forgot this. In inventory.cpp line 594:

if( cargo ) {
     const auto items = veh->get_items( cargo->part_index() );
     *this += std::list<item>( items.begin(), items.end() );
}

It uses '+=' instead of add_item(), should be replaced by add_item_by_items_type_cache()