Skip to content

Commit

Permalink
Merge pull request #39898 from Demoragon/fix-charges
Browse files Browse the repository at this point in the history
Fix items having inappropriate charges in chargen
  • Loading branch information
ifreund authored Apr 27, 2020
2 parents 24673ca + fa88e32 commit d1c39eb
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/profession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,43 +434,6 @@ std::list<item> profession::items( bool male, const std::vector<trait_id> &trait
}
}

/* Purpose: Post processing on profession selection and generation on start.
Professions are newly generated each time on selection, even
if the profession has already been selected previously. The profession
is even generated again after selection, and the game is started.
The purpose of this loop is to provide default numbers for item charges
and ammo. This extends to food as well, however due to the nature of
the way these professions are generated, food items one see's on the profession
screen will be different in-game, but still these charge numbers will be
dictated by the default of said items.
Graphical Issue: Currently, worn items can fluctuate between 0 and their default value
upon entering the game this issue will resolve itself and the correct
default value will be given to the player. This issue occurs
on holding the enter key to make rapid selection of a profession.
TODO: Currently the way magazines are implemented they do not contain a default value.
Professions contain a max charge value found in the JSON file however, this
does not help in choosing a default. Below is a compromise that takes the
half of the magazines capacity as a default. This was chosen because most
defaults are half of the items max value.
-- Ideally, the default value of a magazine would be defined in the profession JSON file. --
*/
for( auto &item : result ) {
/* Set top level items that have a charge to their default states */
/* includes refillable liters */

item.charges = item::find_type( item.typeId() )->charges_default();

/* Top level item has a magazine */
if( item.is_magazine() ) {
//Check the TODO for more information as to why we are dividing by two here.
item.ammo_set( item.ammo_default(), item.ammo_capacity() / 2 );
} else {
item.contents.set_item_defaults();
}
}

result.sort( []( const item & first, const item & second ) {
return first.get_layer() < second.get_layer();
} );
Expand Down

0 comments on commit d1c39eb

Please sign in to comment.