Skip to content

Commit

Permalink
Remove reference to g->m from map functions
Browse files Browse the repository at this point in the history
Those functions will use the implicitly given `this` object now.

Always using the main game map is redundant at best (as the function will typically be called on the main game map anyway, so `this == &g->m`).
But it may in fact be wrong: e.g. when the functions are called on a temporary map (e.g. during mapgen).
  • Loading branch information
BevapDin committed Sep 23, 2019
1 parent 94bdea5 commit 664ef4f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ void map::register_vehicle_zone( vehicle *veh, const int zlev )

bool map::deregister_vehicle_zone( zone_data &zone )
{
if( const cata::optional<vpart_reference> vp = g->m.veh_at( g->m.getlocal(
if( const cata::optional<vpart_reference> vp = veh_at( getlocal(
zone.get_start_point() ) ).part_with_feature( "CARGO", false ) ) {
auto bounds = vp->vehicle().loot_zones.equal_range( vp->mount() );
for( auto it = bounds.first; it != bounds.second; it++ ) {
Expand Down Expand Up @@ -2934,7 +2934,7 @@ void map::smash_items( const tripoint &p, const int power )
}

std::vector<item> contents;
auto items = g->m.i_at( p );
auto items = i_at( p );
for( auto i = items.begin(); i != items.end(); ) {
if( i->active ) {
// Get the explosion item actor
Expand Down Expand Up @@ -4378,7 +4378,7 @@ item &map::add_item( const tripoint &p, item new_item )
}

if( new_item.is_map() && !new_item.has_var( "reveal_map_center_omt" ) ) {
new_item.set_var( "reveal_map_center_omt", ms_to_omt_copy( g->m.getabs( p ) ) );
new_item.set_var( "reveal_map_center_omt", ms_to_omt_copy( getabs( p ) ) );
}

current_submap->is_uniform = false;
Expand All @@ -4401,7 +4401,7 @@ item map::water_from( const tripoint &p )
return item( "salt_water", 0, item::INFINITE_CHARGES );
}

const ter_id terrain_id = g->m.ter( p );
const ter_id terrain_id = ter( p );
if( terrain_id == t_sewage ) {
item ret( "water_sewage", 0, item::INFINITE_CHARGES );
ret.poison = rng( 1, 7 );
Expand Down Expand Up @@ -4633,7 +4633,7 @@ void map::process_items_in_submap( submap &current_submap, const tripoint &gridp
const tripoint map_location = tripoint( grid_offset + active_item_ref.location, gridp.z );
// root cellars are special
temperature_flag flag = temperature_flag::TEMP_NORMAL;
if( g->m.ter( map_location ) == t_rootcellar ) {
if( ter( map_location ) == t_rootcellar ) {
flag = temperature_flag::TEMP_ROOT_CELLAR;
}
map_stack items = i_at( map_location );
Expand Down Expand Up @@ -5591,7 +5591,7 @@ basecamp map::hoist_submap_camp( const tripoint &p )

void map::add_camp( const tripoint &p, const std::string &name )
{
tripoint omt_pos = ms_to_omt_copy( g->m.getabs( p ) );
tripoint omt_pos = ms_to_omt_copy( getabs( p ) );
basecamp temp_camp = basecamp( name, omt_pos );
overmap_buffer.add_camp( temp_camp );
g->u.camps.insert( omt_pos );
Expand Down Expand Up @@ -5737,7 +5737,7 @@ void map::draw( const catacurses::window &w, const tripoint &center )
g->reset_light_level();

update_visibility_cache( center.z );
const visibility_variables &cache = g->m.get_visibility_variables_cache();
const visibility_variables &cache = get_visibility_variables_cache();

const auto &visibility_cache = get_cache_ref( center.z ).visibility_cache;

Expand Down Expand Up @@ -8490,8 +8490,8 @@ std::list<tripoint> map::find_furnitures_in_radius( const tripoint &center, size
size_t radiusz )
{
std::list<tripoint> furn_locs;
for( const auto &furn_loc : g->m.points_in_radius( center, radius, radiusz ) ) {
if( g->m.furn( furn_loc ) == target ) {
for( const auto &furn_loc : points_in_radius( center, radius, radiusz ) ) {
if( furn( furn_loc ) == target ) {
furn_locs.push_back( furn_loc );
}
}
Expand Down

0 comments on commit 664ef4f

Please sign in to comment.