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

fix: dont spawn eggs with negative age values #4319

Merged

Conversation

ekaratzas
Copy link
Contributor

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

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.
@github-actions github-actions bot added the src changes related to source code. label Mar 9, 2024
@scarf005 scarf005 merged commit f2e4353 into cataclysmbnteam:main Mar 9, 2024
13 checks passed
@ekaratzas ekaratzas deleted the fix-negative-age-debug-spawn branch March 10, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants