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

Temperature calculation cleaning #30385

Merged

Conversation

Hirmuolio
Copy link
Contributor

@Hirmuolio Hirmuolio commented May 10, 2019

Summary

SUMMARY: Infrastructure "Clean temperature code a bit"

Purpose of change

The temperature code would set and get the enviroment temperature in many places before the item processing is called. Then the temperature is passed along through numerous functions until it reaches the process_temperature_rot and is finally used.

This would also cause the g->get_temperature( pos ) to be called on all temperature tracked items every turn. The temperature is needed only once every 10 minutes (100 turns) so 99% of times this was unnecessary.

Describe the solution

  • Get the temperature inside process_temperature_rot. It is the only place where the temperature is actually used.
  • The second item::process only existed to pass the temperature along. It has been removed now.
  • Removed an unnecessary item activation in map.cpp.
  • The temperature in game.h was a signed char (this is the temperature before heat sources like fires). So the temperature range was quite limited. Changed that to an integer so that the test could set the temperature to 55 C without overflowing.
  • Added function for clearing temperature cache in map.cpp. used only in the temperature unit test.
  • Added unit test for items in temperature controlled place. The test tests heated container.
  • Use g->new_game to see if mapgen is completed to avoid the segrault with vending machines/toilets.

Describe alternatives you've considered

Additional context

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels May 10, 2019
@Hirmuolio Hirmuolio marked this pull request as ready for review May 12, 2019 06:56
@ZhilkinSerg ZhilkinSerg self-assigned this May 16, 2019
@kevingranade kevingranade merged commit d7c155f into CleverRaven:master May 17, 2019
@ZhilkinSerg ZhilkinSerg removed their assignment May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Mechanics: Temperature Freezing, cooling, thawing, heating, etc. mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants