Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Apr 3, 2020
1 parent d4a096a commit 6b6e351
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
17 changes: 17 additions & 0 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "game.h"
#include "handle_liquid.h"
#include "item.h"
#include "itype.h"
#include "map.h"

bool item_contents::empty() const
Expand Down Expand Up @@ -69,6 +70,22 @@ void item_contents::clear_items()
items.clear();
}

void item_contents::set_item_defaults()
{
/* For Items with a magazine or battery in its contents */
for( item &contained_item : items ) {
/* for guns and other items defined to have a magazine but don't use "ammo" */
if( contained_item.is_magazine() ) {
contained_item.ammo_set(
contained_item.ammo_default(), contained_item.ammo_capacity() / 2
);
} else { //Contents are batteries or food
contained_item.charges =
item::find_type( contained_item.typeId() )->charges_default();
}
}
}

void item_contents::migrate_item( item &obj, const std::set<itype_id> &migrations )
{
for( const std::string &c : migrations ) {
Expand Down
5 changes: 5 additions & 0 deletions src/item_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class item_contents
bool spill_contents( const tripoint &pos );
void clear_items();

/**
* Sets the items contained to their defaults.
*/
void set_item_defaults();

void handle_liquid_or_spill( Character &guy );
void casings_handle( const std::function<bool( item & )> &func );

Expand Down
13 changes: 1 addition & 12 deletions src/profession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,7 @@ std::list<item> profession::items( bool male, const std::vector<trait_id> &trait
//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 {
/* For Items with a magazine or battery in its contents */
for( auto &item_contents : item.contents ) {
/* for guns and other items defined to have a magazine but don't use "ammo" */
if( item_contents.is_magazine() ) {
item_contents.ammo_set(
item_contents.ammo_default(), item_contents.ammo_capacity() / 2
);
} else { //Contents are batteries or food
item_contents.charges =
item::find_type( item_contents.typeId() )->charges_default();
}
}
item.contents.set_item_defaults();
}
}

Expand Down

0 comments on commit 6b6e351

Please sign in to comment.