Skip to content

Commit

Permalink
Use shorter scale specifications (#42317)
Browse files Browse the repository at this point in the history
When working on #41693 I totally forgot that I'd added shorter names for
the various coord::scale values to use in project_to etc. without being
so verbose.

This makes the API more consistent because the names of the scales match
the abbreviations in the type names.

Convert to the shorter names.

Strictly a find-and-replace commit, so hopefully should be safe.
  • Loading branch information
jbytheway authored Jul 21, 2020
1 parent 4795a1e commit ab7a370
Show file tree
Hide file tree
Showing 27 changed files with 136 additions and 136 deletions.
2 changes: 1 addition & 1 deletion src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,7 @@ void activity_handlers::travel_do_turn( player_activity *act, player *p )
map &here = get_map();
// TODO: fix point types
tripoint sm_tri = here.getlocal(
project_to<coords::scale::map_square>( p->omt_path.back() ).raw() );
project_to<coords::ms>( p->omt_path.back() ).raw() );
tripoint centre_sub = sm_tri + point( SEEX, SEEY );
if( !here.passable( centre_sub ) ) {
tripoint_range<tripoint> candidates = here.points_in_radius( centre_sub, 2 );
Expand Down
4 changes: 2 additions & 2 deletions src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void basecamp::form_crafting_inventory()
{
if( by_radio ) {
tinymap target_map;
target_map.load( project_to<coords::scale::submap>( omt_pos ), false );
target_map.load( project_to<coords::sm>( omt_pos ), false );
form_crafting_inventory( target_map );
} else {
form_crafting_inventory( get_map() );
Expand Down Expand Up @@ -751,7 +751,7 @@ void basecamp_action_components::consume_components()
if( base_.by_radio ) {
map_ = std::make_unique<tinymap>();
// TODO: fix point types
map_->load( project_to<coords::scale::submap>( base_.camp_omt_pos() ).raw(), false );
map_->load( project_to<coords::sm>( base_.camp_omt_pos() ).raw(), false );
target_map = map_.get();
}
const tripoint &origin = target_map->getlocal( base_.get_dumping_spot() );
Expand Down
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10842,7 +10842,7 @@ void Character::place_corpse()
void Character::place_corpse( const tripoint_abs_omt &om_target )
{
tinymap bay;
bay.load( project_to<coords::scale::submap>( om_target ), false );
bay.load( project_to<coords::sm>( om_target ), false );
point fin( rng( 1, SEEX * 2 - 2 ), rng( 1, SEEX * 2 - 2 ) );
// This makes no sense at all. It may find a random tile without furniture, but
// if the first try to find one fails, it will go through all tiles of the map
Expand Down
2 changes: 1 addition & 1 deletion src/coordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ struct real_coords {
}

point_abs_omt abs_omt() const {
return project_to<coords::scale::overmap_terrain>( point_abs_sm( abs_sub ) );
return project_to<coords::omt>( point_abs_sm( abs_sub ) );
}

// helper functions to return abs_pos of submap/overmap tile/overmap's start
Expand Down
8 changes: 4 additions & 4 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void teleport_overmap()
g->place_player_overmap( where );

const tripoint_abs_om new_pos =
project_to<coords::scale::overmap>( player_character.global_omt_location() );
project_to<coords::om>( player_character.global_omt_location() );
add_msg( _( "You teleport to overmap %s." ), new_pos.to_string() );
}

Expand All @@ -463,8 +463,8 @@ void spawn_nested_mapgen()

map &here = get_map();
const tripoint_abs_ms abs_ms( here.getabs( *where ) );
const tripoint_abs_omt abs_omt = project_to<coords::scale::overmap_terrain>( abs_ms );
const tripoint_abs_sm abs_sub = project_to<coords::scale::submap>( abs_ms );
const tripoint_abs_omt abs_omt = project_to<coords::omt>( abs_ms );
const tripoint_abs_sm abs_sub = project_to<coords::sm>( abs_ms );

map target_map;
target_map.load( abs_sub, true );
Expand Down Expand Up @@ -1788,7 +1788,7 @@ void debug()
if( mx_choice >= 0 && mx_choice < static_cast<int>( mx_str.size() ) ) {
const tripoint_abs_omt where_omt( ui::omap::choose_point() );
if( where_omt != overmap::invalid_tripoint ) {
tripoint_abs_sm where_sm = project_to<coords::scale::submap>( where_omt );
tripoint_abs_sm where_sm = project_to<coords::sm>( where_omt );
tinymap mx_map;
// TODO: fix point types
mx_map.load( where_sm.raw(), false );
Expand Down
10 changes: 5 additions & 5 deletions src/editmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu )
// TODO: add a do-not-save-generated-submaps parameter
// TODO: keep track of generated submaps to delete them properly and to avoid memory leaks
// TODO: fix point types
tmpmap.generate( tripoint( project_to<coords::scale::submap>( omt_pos.xy() ).raw(), target.z ),
tmpmap.generate( tripoint( project_to<coords::sm>( omt_pos.xy() ).raw(), target.z ),
calendar::turn );

gmenu.border_color = c_light_gray;
Expand Down Expand Up @@ -1832,7 +1832,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu )
cleartmpmap( tmpmap );
// TODO: fix point types
tmpmap.generate(
tripoint( project_to<coords::scale::submap>( omt_pos.xy() ).raw(), target.z ),
tripoint( project_to<coords::sm>( omt_pos.xy() ).raw(), target.z ),
calendar::turn );
}

Expand All @@ -1859,7 +1859,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu )
cleartmpmap( tmpmap );
// TODO: fix point types
tmpmap.generate(
tripoint( project_to<coords::scale::submap>( omt_pos.xy() ).raw(), target.z ),
tripoint( project_to<coords::sm>( omt_pos.xy() ).raw(), target.z ),
calendar::turn );
} else if( gpmenu.ret == 1 ) {
tmpmap.rotate( 1 );
Expand Down Expand Up @@ -1936,7 +1936,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu )
vehicle *editmap::mapgen_veh_query( const tripoint_abs_omt &omt_tgt )
{
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );

std::vector<vehicle *> possible_vehicles;
for( int x = 0; x < 2; x++ ) {
Expand Down Expand Up @@ -1971,7 +1971,7 @@ bool editmap::mapgen_veh_destroy( const tripoint_abs_omt &omt_tgt, vehicle *car_
{
map &here = get_map();
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );
for( int x = 0; x < 2; x++ ) {
for( int y = 0; y < 2; y++ ) {
submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } );
Expand Down
16 changes: 8 additions & 8 deletions src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ void basecamp::start_relay_hide_site()
}
//Check items in improvised shelters at hide site
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( forest ), false );
target_bay.load( project_to<coords::sm>( forest ), false );
std::vector<item *> hide_inv;
for( item &i : target_bay.i_at( point( 11, 10 ) ) ) {
hide_inv.push_back( &i );
Expand Down Expand Up @@ -2305,10 +2305,10 @@ static std::pair<size_t, std::string> farm_action( const tripoint_abs_omt &omt_t
//farm_json is what the area should look like according to jsons
tinymap farm_json;
// TODO: fix point types
farm_json.generate( project_to<coords::scale::submap>( omt_tgt ).raw(), calendar::turn );
farm_json.generate( project_to<coords::sm>( omt_tgt ).raw(), calendar::turn );
//farm_map is what the area actually looks like
tinymap farm_map;
farm_map.load( project_to<coords::scale::submap>( omt_tgt ), false );
farm_map.load( project_to<coords::sm>( omt_tgt ), false );
tripoint mapmin = tripoint( 0, 0, omt_tgt.z() );
tripoint mapmax = tripoint( 2 * SEEX - 1, 2 * SEEY - 1, omt_tgt.z() );
bool done_planting = false;
Expand Down Expand Up @@ -3193,7 +3193,7 @@ int om_harvest_ter( npc &comp, const tripoint_abs_omt &omt_tgt, const ter_id &t,
{
const ter_t &ter_tgt = t.obj();
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );
int harvested = 0;
int total = 0;
tripoint mapmin = tripoint( 0, 0, omt_tgt.z() );
Expand Down Expand Up @@ -3237,7 +3237,7 @@ int om_cutdown_trees( const tripoint_abs_omt &omt_tgt, int chance, bool estimate
bool force_cut_trunk )
{
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );
int harvested = 0;
int total = 0;
tripoint mapmin = tripoint( 0, 0, omt_tgt.z() );
Expand Down Expand Up @@ -3283,7 +3283,7 @@ mass_volume om_harvest_itm( const npc_ptr &comp, const tripoint_abs_omt &omt_tgt
bool take )
{
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );
units::mass harvested_m = 0_gram;
units::volume harvested_v = 0_ml;
units::mass total_m = 0_gram;
Expand Down Expand Up @@ -3457,7 +3457,7 @@ bool om_set_hide_site( npc &comp, const tripoint_abs_omt &omt_tgt,
const std::vector<item *> &itms_rem )
{
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_tgt ), false );
target_bay.load( project_to<coords::sm>( omt_tgt ), false );
target_bay.ter_set( point( 11, 10 ), t_improvised_shelter );
for( auto i : itms_rem ) {
comp.companion_mission_inv.add_item( *i );
Expand Down Expand Up @@ -4023,7 +4023,7 @@ void basecamp::place_results( const item &result )
{
if( by_radio ) {
tinymap target_bay;
target_bay.load( project_to<coords::scale::submap>( omt_pos ), false );
target_bay.load( project_to<coords::sm>( omt_pos ), false );
const tripoint &new_spot = target_bay.getlocal( get_dumping_spot() );
target_bay.add_item_or_charges( new_spot, result, true );
apply_camp_ownership( new_spot, 10 );
Expand Down
8 changes: 4 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ bool game::start_game()
}

// TODO: fix point types
tripoint lev = project_to<coords::scale::submap>( omtstart ).raw();
tripoint lev = project_to<coords::sm>( omtstart ).raw();
// The player is centered in the map, but lev[xyz] refers to the top left point of the map
lev.x -= HALF_MAPSIZE;
lev.y -= HALF_MAPSIZE;
Expand Down Expand Up @@ -860,7 +860,7 @@ vehicle *game::place_vehicle_nearby(
for( const tripoint_abs_omt &goal : overmap_buffer.find_all( omt_origin, find_params ) ) {
// try place vehicle there.
tinymap target_map;
target_map.load( project_to<coords::scale::submap>( goal ), false );
target_map.load( project_to<coords::sm>( goal ), false );
const tripoint tinymap_center( SEEX, SEEY, goal.z() );
static const std::vector<int> angles = {0, 90, 180, 270};
vehicle *veh = target_map.add_vehicle( id, tinymap_center, random_entry( angles ), rng( 50, 80 ),
Expand Down Expand Up @@ -4659,7 +4659,7 @@ void game::overmap_npc_move()
}
// TODO: fix point types
elem->travel_overmap(
project_to<coords::scale::submap>( elem->omt_path.back() ).raw() );
project_to<coords::sm>( elem->omt_path.back() ).raw() );
}
reload_npcs();
}
Expand Down Expand Up @@ -9992,7 +9992,7 @@ void game::place_player_overmap( const tripoint_abs_omt &om_dest )
// player will be centered in the middle of the map.
// TODO: fix point types
const tripoint map_sm_pos(
project_to<coords::scale::submap>( om_dest ).raw() + point( -HALF_MAPSIZE, -HALF_MAPSIZE ) );
project_to<coords::sm>( om_dest ).raw() + point( -HALF_MAPSIZE, -HALF_MAPSIZE ) );
const tripoint player_pos( u.pos().xy(), map_sm_pos.z );
load_map( map_sm_pos );
load_npcs();
Expand Down
2 changes: 1 addition & 1 deletion src/gamemode_defense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void defense_game::init_map()

// For this mode assume we always want overmap zero.
tripoint_abs_omt abs_defloc_pos = project_combine( point_abs_om(), defloc_pos );
g->load_map( project_to<coords::scale::submap>( abs_defloc_pos ) );
g->load_map( project_to<coords::sm>( abs_defloc_pos ) );
Character &player_character = get_player_character();
player_character.setx( SEEX );
player_character.sety( SEEY );
Expand Down
2 changes: 1 addition & 1 deletion src/gamemode_tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool tutorial_game::init()
player_character.inv.add_item( lighter, true, false );
player_character.set_skill_level( skill_gun, 5 );
player_character.set_skill_level( skill_melee, 5 );
g->load_map( project_to<coords::scale::submap>( lp_abs ) );
g->load_map( project_to<coords::sm>( lp_abs ) );
player_character.setx( 2 );
player_character.sety( 4 );

Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4823,7 +4823,7 @@ std::string item::display_name( unsigned int quantity ) const
tripoint map_pos_omt =
get_var( "reveal_map_center_omt", player_character.global_omt_location().raw() );
tripoint_abs_sm map_pos =
project_to<coords::scale::submap>( tripoint_abs_omt( map_pos_omt ) );
project_to<coords::sm>( tripoint_abs_omt( map_pos_omt ) );
const city *c = overmap_buffer.closest_city( map_pos ).city;
if( c != nullptr ) {
name = string_format( "%s %s", c->name, name );
Expand Down
4 changes: 2 additions & 2 deletions src/magic_teleporter_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static cata::optional<tripoint> find_valid_teleporters_omt( const tripoint_abs_o
// this is the top left hand square of the global absolute coordinate
// of the overmap terrain we want to try to teleport to.
// an OMT is SEEX * SEEY in size
const tripoint_abs_sm sm_pt = project_to<coords::scale::submap>( omt_pt );
const tripoint_abs_sm sm_pt = project_to<coords::sm>( omt_pt );
tinymap checker;
// TODO: fix point types
checker.load( sm_pt.raw(), true );
Expand All @@ -76,7 +76,7 @@ static cata::optional<tripoint> find_valid_teleporters_omt( const tripoint_abs_o
bool teleporter_list::place_avatar_overmap( Character &you, const tripoint_abs_omt &omt_pt ) const
{
tinymap omt_dest( 2, true );
tripoint_abs_sm sm_dest = project_to<coords::scale::submap>( omt_pt );
tripoint_abs_sm sm_dest = project_to<coords::sm>( omt_pt );
// TODO: fix point types
omt_dest.load( sm_dest.raw(), true );
cata::optional<tripoint> global_dest = find_valid_teleporters_omt( omt_pt );
Expand Down
12 changes: 6 additions & 6 deletions src/map_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub )

tinymap m;
if( bridge_at_north && bridgehead_at_center && road_at_south ) {
m.load( project_to<coords::scale::submap>( abs_omt + point_south ), false );
m.load( project_to<coords::sm>( abs_omt + point_south ), false );

//Sandbag block at the left edge
line_furn( &m, f_sandbag_half, point( 3, 4 ), point( 3, 7 ) );
Expand Down Expand Up @@ -1233,7 +1233,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub )
}

if( bridge_at_south && bridgehead_at_center && road_at_north ) {
m.load( project_to<coords::scale::submap>( abs_omt + point_north ), false );
m.load( project_to<coords::sm>( abs_omt + point_north ), false );
//Two horizontal lines of sandbags
line_furn( &m, f_sandbag_half, point( 5, 15 ), point( 10, 15 ) );
line_furn( &m, f_sandbag_half, point( 13, 15 ), point( 18, 15 ) );
Expand Down Expand Up @@ -1335,7 +1335,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub )
}

if( bridge_at_west && bridgehead_at_center && road_at_east ) {
m.load( project_to<coords::scale::submap>( abs_omt + point_east ), false );
m.load( project_to<coords::sm>( abs_omt + point_east ), false );
//Draw walls of first tent
square_furn( &m, f_canvas_wall, point( 0, 3 ), point( 4, 13 ) );

Expand Down Expand Up @@ -1482,7 +1482,7 @@ static bool mx_minefield( map &, const tripoint &abs_sub )
}

if( bridge_at_east && bridgehead_at_center && road_at_west ) {
m.load( project_to<coords::scale::submap>( abs_omt + point_west ), false );
m.load( project_to<coords::sm>( abs_omt + point_west ), false );
//Spawn military cargo truck blocking the entry
m.add_vehicle( vproto_id( "military_cargo_truck" ), point( 15, 11 ), 270, 70, 1 );

Expand Down Expand Up @@ -3001,7 +3001,7 @@ static bool mx_city_trap( map &/*m*/, const tripoint &abs_sub )
// TODO: fix point types
const city_reference c = overmap_buffer.closest_city( tripoint_abs_sm( abs_sub ) );
const tripoint_abs_omt city_center_omt =
project_to<coords::scale::overmap_terrain>( c.abs_sm_pos );
project_to<coords::omt>( c.abs_sm_pos );

//Then fill vector with all roads inside the city radius
std::vector<tripoint_abs_omt> valid_omt;
Expand All @@ -3014,7 +3014,7 @@ static bool mx_city_trap( map &/*m*/, const tripoint &abs_sub )
const tripoint_abs_omt road_omt = random_entry( valid_omt, city_center_omt );

tinymap compmap;
compmap.load( project_to<coords::scale::submap>( road_omt ), false );
compmap.load( project_to<coords::sm>( road_omt ), false );

const tripoint trap_center = { SEEX + rng( -5, 5 ), SEEY + rng( -5, 5 ), abs_sub.z };
bool empty_3x3_square = false;
Expand Down
2 changes: 1 addition & 1 deletion src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6930,7 +6930,7 @@ bool update_mapgen_function_json::update_map( const tripoint_abs_omt &omt_pos, c
}
tinymap update_tmap;
// TODO: fix point types
const tripoint sm_pos = project_to<coords::scale::submap>( omt_pos ).raw();
const tripoint sm_pos = project_to<coords::sm>( omt_pos ).raw();
update_tmap.load( sm_pos, true );

mapgendata md( omt_pos, update_tmap, 0.0f, calendar::start_of_cataclysm, miss );
Expand Down
Loading

0 comments on commit ab7a370

Please sign in to comment.