fix: dont spawn eggs with negative age values #4319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for the corner-case where a monster that lays eggs is forced to reproduce via the debug menu. In such a case, the age of the spawned egg would be negative as the birth-timer points to a point in time in the future for the next valid reprouce check of the monster.
In this corner-case, we just use the current-turn timestamp for the newly spawned egg.
Purpose of change
Fix negative egg item age bug introduced when using debug menu to force egg-laying animal (e.g. chicken) top reproduce.
Describe the solution
Only use birth timer if it points to now or the past, otherwise use current timestamp.
Describe alternatives you've considered
Testing
spawn chicken
force chicken to lay egg - check its age
go far away and come back so submap gets reloaded
force previous chicken to lay egg - check its age
Additional context
Checklist