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
- Collect or debug-spawn wild bird eggs.
- Put them on the ground at room temperature.
- 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
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 inheritedchancefield when the child item overridesrot_spawnwithout re-specifying"chance".egg_chickendefines:Child eggs like
egg_crowoverriderot_spawnto change the monster but omitchance:During loading,
copy-frominitially inherits the parent'srot_spawn(includingchance: 70). But thenrot_spawn_data::deserialize()is called on the child's JSON. Initem_degrade.cpp:1454:Because
was_loadedis hardcoded tofalseand"chance"is absent from the child JSON,generic_factory.h:956zero-initializes the field:member = MemberType(); // rot_spawn_chance = 0.0The hatch check at
map.cpp:9007then 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
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