Skip to content

Wild bird eggs have a 0% chance to hatch #86438

@abadams

Description

@abadams

Describe the bug

I collected a large number of wild turkey eggs and other birds during the spring and left them on the ground to rot. Not a single bird hatched. After investigating, I found that 30 egg types can never hatch because the rot_spawn chance is silently zeroed by copy-from. This is caused by rot_spawn_data::deserialize() zeroing the inherited chance field when the child item overrides rot_spawn without re-specifying "chance".

egg_chicken defines:

"rot_spawn": { "monster": "mon_chicken_chick", "chance": 70 }

Child eggs like egg_crow override rot_spawn to change the monster but omit chance:

"rot_spawn": { "monster": "mon_crow_chick" }

During loading, copy-from initially inherits the parent's rot_spawn (including chance: 70). But then rot_spawn_data::deserialize() is called on the child's JSON. In item_degrade.cpp:1454:

optional( jo, false, "chance", rot_spawn_chance );

Because was_loaded is hardcoded to false and "chance" is absent from the child JSON, generic_factory.h:956 zero-initializes the field:

member = MemberType(); // rot_spawn_chance = 0.0

The hatch check at map.cpp:9007 then always fails.

In in rot_spawn_data::deserialize() it looks like was_loaded should be passed through from the caller instead of set to false, but maybe this was done for a reason. Alternatively, the individual bird eggs should all have non-zero chance-to-hatch.

Attach save file

N/A (my save file is gigantic, and this should be trivially reproducible without one)

Steps to reproduce

  1. Collect or debug-spawn wild bird eggs.
  2. Put them on the ground at room temperature.
  3. Wait for them to rot.

Expected behavior

Some of the eggs hatch into chicks of the appropriate species.

Screenshots

No response

Versions and configuration

I'm playing on commit 67c1223 (from about 3 weeks ago). It doesn't look like this has been addressed in the meantime.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    (S1 - Need confirmation)Report waiting on confirmation of reproducibility

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions