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

Zombies cant get clothes #53785

Closed
kydsh opened this issue Dec 26, 2021 · 1 comment · Fixed by #54632
Closed

Zombies cant get clothes #53785

kydsh opened this issue Dec 26, 2021 · 1 comment · Fixed by #54632
Labels
<Bug> This needs to be fixed [C++] Changes (can be) made in C++. Previously named `Code` Good First Issue This is a good first issue for a new contributor Items: Containers Things that hold other things Monsters Monsters both friendly and unfriendly.

Comments

@kydsh
Copy link

kydsh commented Dec 26, 2021

Describe the bug

when I move somewhere, I always get similar errors that are in the log

Steps to reproduce

  1. Move in some direction
  2. Get error

Expected behavior

I expect poor zombies to get their clothes

Screenshots

errrrr

Versions and configuration

win 10

34f079e

russian

mods: [ "dda", "blazeindustries", "aftershock", "crt_expansion", "no_hope", "StatsThroughSkills", "speedydex", "stats_through_kills", "stamina_regen_buff", "crazy_cataclysm", "Graphical_Overmap", "WHALEYHAIR1"
debug.log
FrostPunk.zip
]

Additional context

No response

@GoLoT
Copy link
Contributor

GoLoT commented Dec 27, 2021

The mdeath::normal() and mdeath::splatter() calls in

Cataclysm-DDA/src/monster.cpp

Lines 2527 to 2539 in f8734ab

switch( type->mdeath_effect.corpse_type ) {
case mdeath_type::NORMAL:
corpse = mdeath::normal( *this );
break;
case mdeath_type::BROKEN:
mdeath::broken( *this );
break;
case mdeath_type::SPLATTER:
corpse = mdeath::splatter( *this );
break;
default:
break;
}

are expected to return a nullptr if the corpse can't be created but make_mon_corpse() calls get_map().add_item_or_charges() which returns a reference to the null item, not nullptr, when the item can't be added to the chosen position.

This null item is still a valid item and the if (corpse) branches only check that the pointer is null so the items are being added to a null item without pockets, causing the error. The easier fix is to return nullptr when calling make_mon_corpse() if the item is null (corpse.is_null()) in the mdeath::splatter/normal calls, or checking that the corpse is not a null item before trying to add items to the corpse. The latter involves changing all the if(corpse)checks in drop_items_on_death() and monster::die().

I think this is a good first issue if anyone wants to fix it before I get to it.

An easy repro is to find/spawn a crater map special (the bugged ones that have ledges that lead to filled terrain) and spawning a zombie on top. The zombie will fall, die inside the wall and try to spawn a corpse. The wall will prevent placement of the corpse in that or any tiles around, causing the bug.

@BrettDong BrettDong added <Bug> This needs to be fixed [C++] Changes (can be) made in C++. Previously named `Code` Good First Issue This is a good first issue for a new contributor Items: Containers Things that hold other things Monsters Monsters both friendly and unfriendly. labels Dec 27, 2021
gruebite added a commit to gruebite/Cataclysm-DDA that referenced this issue Jan 21, 2022
Fixes an issue when a corpse can't be created, which should return a
nullptr, not a null item.

fixes CleverRaven#53785, fixes CleverRaven#54603
kevingranade pushed a commit that referenced this issue Jan 21, 2022
Fixes an issue when a corpse can't be created, which should return a
nullptr, not a null item.

fixes #53785, fixes #54603

Co-authored-by: Binrui Dong <brett.browning.dong@gmail.com>
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 [C++] Changes (can be) made in C++. Previously named `Code` Good First Issue This is a good first issue for a new contributor Items: Containers Things that hold other things Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants