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

Errors examining or picking up items dropped by dead NPC #37339

Closed
wapcaplet opened this issue Jan 24, 2020 · 4 comments · Fixed by #38334
Closed

Errors examining or picking up items dropped by dead NPC #37339

wapcaplet opened this issue Jan 24, 2020 · 4 comments · Fixed by #38334
Labels
<Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact NPC / Factions NPCs, AI, Speech, Factions, Ownership
Milestone

Comments

@wapcaplet
Copy link
Contributor

wapcaplet commented Jan 24, 2020

Describe the bug

After I killed NPC Omar Bender inside my base in self-defense, he dropped a bunch of items, including a radio and crossbow that emit errors when I try to examine or grab them:

 DEBUG    : Requested non-existing faction 'solo_Omar Bender'
 FUNCTION : faction* faction_manager::get(const faction_id&, bool)
 FILE     : src/faction.cpp
 LINE     : 456

followed by:

 DEBUG    : item::get_owner_name() item two-way radio has no valid nor null faction id 
 FUNCTION : std::__cxx11::string item::get_owner_name() const
 FILE     : src/item.cpp
 LINE     : 1087

Steps To Reproduce

Steps to reproduce the behavior:

  1. Kill a hostile NPC
  2. See if they drop any items
  3. Try to examine or pick up their loot

Expected behavior

Expected all of dead NPC's items to have similar ownership/faction attributes. Or, if there is some reason his radio and crossbow are owned by another faction, at least there should be no errors trying to examine them.

Screenshots

Here are the two problematic items once I moved the corpse and clothing aside. Attempting to move them using advanced inventory manager or hauling simply does nothing (which seems fine, if these items aren't mine), but I only see errors if I try to examine or grab them:

image

Versions and configuration

  • OS: Linux
    • OS Version: LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch; Distributor ID: Ubuntu; Description: Ubuntu 18.04.3 LTS; Release: 18.04; Codename: bionic;
  • Game Version: 0.D-11480-gdcdef1eefc [64-bit]
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Vehicle Additions Pack [blazemod],
    Tanks and Other Vehicles [Tanks],
    Stats Through Kills [stats_through_kills],
    Stats Through Skills [StatsThroughSkills],
    Disable Religious Texts [no_religious_Texts]
    ]
@wapcaplet
Copy link
Contributor Author

wapcaplet commented Jan 31, 2020

I was able to reproduce this a couple more times in a build from master today (0.D-11818-g2c8919d95b) with these steps:

  • Create a new world
  • Create a new character
  • Debug in invincibility and a nice gun
  • Debug spawn NPCs until one is hostile
  • Kill NPC and see what they dropped

Once, the faulty item was a pot helmet; another time, a Mossberg 500 Security shotgun.

I have not tried killing friendly NPCs to see if it affects them too, but I might have to take the morale penalty and do it for science.

Attaching save game with a nearby corpse; the Mossberg 500 can't be examined or picked up, and shows up in red text:

image

Save game:
NPCville_CDDA_savegame.zip

  • OS: Linux
    • OS Version: LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch; Distributor ID: Ubuntu; Description: Ubuntu 18.04.3 LTS; Release: 18.04; Codename: bionic;
  • Game Version: 0.D-11818-g2c8919d95b [64-bit]
  • Graphics Version: Tiles
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food]
    ]

Now that I'm sure I can reproduce the issue, I will try cracking this and submit a PR if I can figure out a fix.

@wapcaplet
Copy link
Contributor Author

wapcaplet commented Jan 31, 2020

I located the code that deals with factions after an NPC's death but it'll take some time for me to grok it:

Cataclysm-DDA/src/npc.cpp

Lines 2406 to 2417 in 2c8919d

// if this NPC was the only member of a micro-faction, clean it up.
if( my_fac ) {
if( !is_fake() && !is_hallucination() ) {
if( my_fac->members.size() == 1 ) {
for( auto elem : inv_dump() ) {
elem->remove_owner();
elem->remove_old_owner();
}
}
my_fac->remove_member( getID() );
}
}

It looks like this bit is part of the "lone wolf" faction system added / revised back in September 2019:

9155080#diff-529d096f96854d0d52b251607dce9f6e

My guess is the faction was deleted after the NPC's death, but one of the dropped items remained attached to that faction ID somehow.

@kevingranade kevingranade added this to the 0.E milestone Feb 22, 2020
@Night-Pryanik Night-Pryanik added <Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact NPC / Factions NPCs, AI, Speech, Factions, Ownership labels Feb 25, 2020
@ghost
Copy link

ghost commented Feb 25, 2020

Cant reproduce, but can reproduce linked issue which is a different circumstance.

@ghost
Copy link

ghost commented Feb 25, 2020

Well, either way, the linked PR will fix all future instances of this type of bug, hopefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed Items / Item Actions / Item Qualities Items and how they work and interact NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants