Skip to content

Commit

Permalink
Use reference instead of pointer in Item_factory::add_item_to_group
Browse files Browse the repository at this point in the history
The pointer was dereferenced unconditionally, this shows that it is supposed to be non-null.
  • Loading branch information
BevapDin committed Mar 19, 2018
1 parent 28479d0 commit 6293189
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,12 +2371,12 @@ bool Item_factory::add_item_to_group(const Group_tag group_id, const Item_tag it
if (m_template_groups.find(group_id) == m_template_groups.end()) {
return false;
}
Item_spawn_data *group_to_access = m_template_groups[group_id].get();
if (group_to_access->has_item(item_id)) {
group_to_access->remove_item(item_id);
Item_spawn_data &group_to_access = *m_template_groups[group_id];
if( group_to_access.has_item( item_id ) ) {
group_to_access.remove_item( item_id );
}

Item_group *ig = dynamic_cast<Item_group *>(group_to_access);
Item_group *ig = dynamic_cast<Item_group *>( &group_to_access );
if (chance != 0 && ig != NULL) {
// Only re-add if chance != 0
ig->add_item_entry(item_id, chance);
Expand Down

0 comments on commit 6293189

Please sign in to comment.