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

JSONize material wind resistance #50739

Merged

Conversation

anothersimulacrum
Copy link
Member

Summary

None

Purpose of change

There's no reason for it be hardcoded, and it's actually a pretty significant performance cost to look up those ids every turn.

Describe the solution

Built on top of #50735
Read the wind resistance of materials from JSON.

Describe alternatives you've considered

cataclysmbnteam/Cataclysm-BN#774 (comment)

Testing

image
image

Start a game with Dark Days of the Dead (has really high winds #50375), stand outside in only leather gear, cotton gear, and steel gear, and see different values for cold due to armour material.

@anothersimulacrum anothersimulacrum added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) labels Aug 13, 2021
Cache a variable, use the already fetched maptile to check the terrain
at the tile instead of looking up the submap again.
Perform two optimizations on Character::bodytemp
1. Store the items worn on each bodypart, and refer to that instead of
   iterating through all worn items and selecting the ones for the
   relevant body part multiple times.
2. Adjust some functions to run once, and return the data for all body
   parts. This optimization has a fair bit of overlap with CleverRaven#1, but I
   think both have value

There should be no behavioural changes.
Don't check every item for a flag for every item the character is
wearing, just check the current flag.
Character::in_climate_control drops off the profile of
Character::bodytemp with this change.
The vast majority of the time, we won't have any blisters - so only go
through the mildly expensive process of getting fire armor when we have
blisters.
There's no reason for this to be hardcoded, and dynamically constructing
the ids every turn (for Character::update_bodytemp) is actually a
significant performance sink.
Move it to JSON, experience performance improvements.
@kevingranade kevingranade merged commit f56f7c2 into CleverRaven:master Aug 13, 2021
@anothersimulacrum anothersimulacrum deleted the materials_windresist branch August 13, 2021 21:03
OrenAudeles pushed a commit to OrenAudeles/Cataclysm-DDA that referenced this pull request Sep 16, 2021
Merge pull request CleverRaven#50739 from anothersimulacrum/materials_windresist

JSONize material wind resistance
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: Performance Performance boosting code (CPU, memory, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants