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 uninitialized monster::horde_attraction #36880

Merged
merged 1 commit into from
Jan 10, 2020

Conversation

hexagonrecursion
Copy link
Contributor

@hexagonrecursion hexagonrecursion commented Jan 10, 2020

Summary

SUMMARY: Bugfixes "Fix uninitialized monster::horde_attraction"

Purpose of change

Fixes #36813 - code to initialize monster::horde_attraction was missing.

Describe the solution

Added code to the constructor to initialize the field. I used the same default value as the json loading code

horde_attraction = static_cast<monster_horde_attraction>( data.get_int( "horde_attraction", 0 ) );

Note: initial value of MHA_NULL will result in horde_attraction being randomized by monster::get_horde_attraction.

Cataclysm-DDA/src/monster.cpp

Lines 2839 to 2845 in 605409a

monster_horde_attraction monster::get_horde_attraction()
{
if( horde_attraction == MHA_NULL ) {
horde_attraction = static_cast<monster_horde_attraction>( rng( 1, 5 ) );
}
return horde_attraction;
}

Describe alternatives you've considered

Testing

Additional context

@hexagonrecursion hexagonrecursion changed the title Fix uninitialized monsterhorde_attraction Fix uninitialized monster::horde_attraction Jan 10, 2020
@hexagonrecursion
Copy link
Contributor Author

I accidentally submitted PR before filling the description. I then ninja-edited it, but PR Validator did not run again.

@anothersimulacrum
Copy link
Member

It did, it just didn't remove the failed run.

@kevingranade kevingranade merged commit 64d37f7 into CleverRaven:master Jan 10, 2020
@hexagonrecursion hexagonrecursion deleted the patch-5 branch January 11, 2020 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid enum load in monster::store
3 participants