Skip to content

Allow roundtripping damage in folded vehicle items#60710

Merged
dseguin merged 3 commits intoCleverRaven:masterfrom
irwiss:folded-pass-damage
Sep 7, 2022
Merged

Allow roundtripping damage in folded vehicle items#60710
dseguin merged 3 commits intoCleverRaven:masterfrom
irwiss:folded-pass-damage

Conversation

@irwiss
Copy link
Contributor

@irwiss irwiss commented Sep 3, 2022

Summary

None

Purpose of change

Fixes #60700

Describe the solution

On folding calculate average part damage and serialize into item_var and item itself.

On unfolding get the difference between current item and old item_var damage;
Start applying it to random parts in chunks

be40dc0 also fixes a couple more MSVC warnings I missed in #60568

Note that I had need for a random-looking sequence with fixed seed - I don't need it to actually be random, just so parts "look" randomly damaged in a way that tests can snapshot (and so don't rely on global rng state) and there seems to be none existing - so I added one into rng.h/cpp

Describe alternatives you've considered

Using one of the simple hashes available for the rng sequence, but it'd do the same job but with extra steps and possible bugs.

Testing

Spawn and kill zombie granny, unfold wheelchair, parts should be damaged.

Unit test is added, could also run the unit test scenario manually

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Vehicles Vehicles, parts, mechanics & interactions labels Sep 3, 2022
@irwiss irwiss changed the title Allow roundtripping damage in folded veh items Allow roundtripping damage in folded vehicle items Sep 3, 2022
@github-actions github-actions bot added <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Sep 3, 2022
@irwiss irwiss force-pushed the folded-pass-damage branch 2 times, most recently from 1789d63 to 7c32e43 Compare September 3, 2022 21:18
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 3, 2022
@irwiss irwiss force-pushed the folded-pass-damage branch from 7c32e43 to be40dc0 Compare September 4, 2022 14:52
@irwiss irwiss marked this pull request as ready for review September 4, 2022 19:49
Copy link
Member

@dseguin dseguin left a comment

Choose a reason for hiding this comment

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

LGTM

@irwiss irwiss force-pushed the folded-pass-damage branch from be40dc0 to 9a4eac8 Compare September 5, 2022 22:58
@dseguin dseguin merged commit c27332b into CleverRaven:master Sep 7, 2022
@irwiss irwiss deleted the folded-pass-damage branch September 7, 2022 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions Vehicles Vehicles, parts, mechanics & interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Damaging folded vehicles (the item) doesn't damage the vehicle

3 participants