Skip to content

Commit

Permalink
Minor fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Jun 16, 2019
1 parent 74fd712 commit d276aa8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ std::string four_quadrants::to_string() const
}

void map::add_light_from_items( const tripoint &p, item_stack::iterator begin,
map_stack::iterator end )
item_stack::iterator end )
{
for( auto itm_it = begin; itm_it != end; ++itm_it ) {
float ilum = 0.0; // brightness
Expand Down
5 changes: 4 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4132,7 +4132,10 @@ map_stack::iterator map::i_rem( const tripoint &p, map_stack::const_iterator it
void map::i_rem( const tripoint &p, item *it )
{
map_stack map_items = i_at( p );
map_items.erase( map_items.get_iterator_from_pointer( it ) );
map_stack::const_iterator iter = map_items.get_iterator_from_pointer( it );
if( iter != map_items.end() ) {
i_rem( p, iter );
}
}

void map::i_clear( const tripoint &p )
Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ class map
void apply_light_arc( const tripoint &p, int angle, float luminance, int wideangle = 30 );
void apply_light_ray( bool lit[MAPSIZE_X][MAPSIZE_Y],
const tripoint &s, const tripoint &e, float luminance );
void add_light_from_items( const tripoint &p, item_stack::iterator begin, map_stack::iterator end );
void add_light_from_items( const tripoint &p, item_stack::iterator begin, item_stack::iterator end );
std::unique_ptr<vehicle> add_vehicle_to_map( std::unique_ptr<vehicle> veh, bool merge_wrecks );

// Internal methods used to bash just the selected features
Expand Down
2 changes: 1 addition & 1 deletion src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3484,7 +3484,7 @@ void submap::load( JsonIn &jsin, const std::string &member_name, bool rubpow_upd
return VisitResponse::NEXT;
} );

colony<item>::iterator it = itm[p.x][p.y].insert( tmp );
const colony<item>::iterator it = itm[p.x][p.y].insert( tmp );
if( tmp.needs_processing() ) {
active_items.add( it, p );
}
Expand Down
19 changes: 7 additions & 12 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4443,20 +4443,15 @@ cata::optional<vehicle_stack::iterator> vehicle::add_item( int part, const item
return cata::optional<vehicle_stack::iterator>( new_pos );
}

bool vehicle::remove_item( int part, const item *it )
bool vehicle::remove_item( int part, item *it )
{
bool rc = false;
colony<item> &veh_items = parts[part].items;

for( auto iter = veh_items.begin(); iter != veh_items.end(); ++iter ) {
//delete the item if the pointer memory addresses are the same
if( it == &*iter ) {
remove_item( part, iter );
rc = true;
break;
}
const colony<item> &veh_items = parts[part].items;
const colony<item>::const_iterator iter = veh_items.get_iterator_from_pointer( it );
if( iter == veh_items.end() ) {
return false
}
return rc;
remove_item( part, iter );
return true;
}

vehicle_stack::iterator vehicle::remove_item( int part, vehicle_stack::const_iterator it )
Expand Down

0 comments on commit d276aa8

Please sign in to comment.