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 foods getting negative rot when the date of cataclysm is not zero #33345

Merged

Conversation

Hirmuolio
Copy link
Contributor

@Hirmuolio Hirmuolio commented Aug 18, 2019

Summary

SUMMARY: Bugfixes "Fix food getting negative rot when start date is set to not zero"

Purpose of change

Fixes: #33338

Describe the solution

Items spawned during mapgen had their bday at calendar::turn_zero (day 0).
The cataclysm may occur at some later date (default day 30).
Rot calculation made some bad assumptions about how the last rot check is related to the occurence of the cataclysm.

Result was that the spawned items would get (potentially massive) negative rot when they were processed from calendar::turn_zero to calendar::start_of_cataclysm.

Items having bday at calendar::turn_zero is wrong practically always. Items that exist at the start of the game should have bday at calendar::start_of_cataclysm.

Now they have their bday at calendar::start_of_cataclysm.

The whole thing about calendar::start_of_cataclysm in rot calculations was probably originally meant to fix this issue. This is better solution so it has been removed.

Describe alternatives you've considered

Work around the wrong bday in other places:

  • At item placement code do not allow setting bday before calendar::start_of_cataclysm. There may be valid uses for bday before that and it would just hide wrong bdays being set somewhere.
  • Work around wrong bday in rot calculations. Some other item thing may also get broken by the wrong bday so this would only fix the currently known symptom.

Additional context

I don't know why time = std::min( { last_rot_check, last_temp_check } ); has curly bracets. It seems to work even without them ( last_rot_check, last_temp_check being different from each other is really rare so it will be really hard to notice if this breaks something ).

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics Time / Turns / Duration / Date Issues concerning any activities being too fast or too slow. Also issues about time and date ingame labels Aug 18, 2019
@Hirmuolio Hirmuolio changed the title Hirmuolio temp start date fix Hirmuolio temperature start date fix Aug 18, 2019
@Hirmuolio Hirmuolio changed the title Hirmuolio temperature start date fix Temperature start date fix Aug 18, 2019
@Hirmuolio
Copy link
Contributor Author

Hirmuolio commented Aug 19, 2019

Maybe a more complete fix would be to make sure that when an item is created its last_rot_check and last_temp_check (and maybe bday) are not before calendar::start_of_cataclysm.
If there are items that change due to time in other ways than temperature/rot they would probably get this bug too and would maybe et fixed byt doing this.

@Hirmuolio
Copy link
Contributor Author

Ok I did the more complete fix I mentioned above.

@Hirmuolio Hirmuolio changed the title Temperature start date fix Fix foods getting negative rot when the date of cataclysm is not zero Aug 19, 2019
time_duration spoil_variation = get_shelf_life() * 0.2f;
rot += factor * rng( -spoil_variation, spoil_variation );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to remove the multiplication by factor here?

Copy link
Contributor Author

@Hirmuolio Hirmuolio Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The factor is only applied to field dressed corpses. AFAIK none of those exist at the beginning of the cataclysm.
And if they do exist I think that shouldn't reduce the range of random variation the item can have.

src/item.cpp Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics Time / Turns / Duration / Date Issues concerning any activities being too fast or too slow. Also issues about time and date ingame
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Foods receive massive ammount of negative rot if starting day is not zero
4 participants