Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert moreAPIs to use points 20200418 #39697

Merged
merged 7 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ advanced_inventory::advanced_inventory()
// panes don't need initialization, they are recalculated immediately
, squares( {
{
// hx hy
{ AIM_INVENTORY, 25, 2, tripoint_zero, _( "Inventory" ), _( "IN" ), "I", "ITEMS_INVENTORY", AIM_INVENTORY},
{ AIM_SOUTHWEST, 30, 3, tripoint_south_west, _( "South West" ), _( "SW" ), "1", "ITEMS_SW", AIM_WEST},
{ AIM_SOUTH, 33, 3, tripoint_south, _( "South" ), _( "S" ), "2", "ITEMS_S", AIM_SOUTHWEST},
{ AIM_SOUTHEAST, 36, 3, tripoint_south_east, _( "South East" ), _( "SE" ), "3", "ITEMS_SE", AIM_SOUTH},
{ AIM_WEST, 30, 2, tripoint_west, _( "West" ), _( "W" ), "4", "ITEMS_W", AIM_NORTHWEST},
{ AIM_CENTER, 33, 2, tripoint_zero, _( "Directly below you" ), _( "DN" ), "5", "ITEMS_CE", AIM_CENTER},
{ AIM_EAST, 36, 2, tripoint_east, _( "East" ), _( "E" ), "6", "ITEMS_E", AIM_SOUTHEAST},
{ AIM_NORTHWEST, 30, 1, tripoint_north_west, _( "North West" ), _( "NW" ), "7", "ITEMS_NW", AIM_NORTH},
{ AIM_NORTH, 33, 1, tripoint_north, _( "North" ), _( "N" ), "8", "ITEMS_N", AIM_NORTHEAST},
{ AIM_NORTHEAST, 36, 1, tripoint_north_east, _( "North East" ), _( "NE" ), "9", "ITEMS_NE", AIM_EAST},
{ AIM_DRAGGED, 25, 1, tripoint_zero, _( "Grabbed Vehicle" ), _( "GR" ), "D", "ITEMS_DRAGGED_CONTAINER", AIM_DRAGGED},
{ AIM_ALL, 22, 3, tripoint_zero, _( "Surrounding area" ), _( "AL" ), "A", "ITEMS_AROUND", AIM_ALL},
{ AIM_CONTAINER, 22, 1, tripoint_zero, _( "Container" ), _( "CN" ), "C", "ITEMS_CONTAINER", AIM_CONTAINER},
{ AIM_WORN, 25, 3, tripoint_zero, _( "Worn Items" ), _( "WR" ), "W", "ITEMS_WORN", AIM_WORN}
// pos in window
{ AIM_INVENTORY, point( 25, 2 ), tripoint_zero, _( "Inventory" ), _( "IN" ), "I", "ITEMS_INVENTORY", AIM_INVENTORY},
{ AIM_SOUTHWEST, point( 30, 3 ), tripoint_south_west, _( "South West" ), _( "SW" ), "1", "ITEMS_SW", AIM_WEST},
{ AIM_SOUTH, point( 33, 3 ), tripoint_south, _( "South" ), _( "S" ), "2", "ITEMS_S", AIM_SOUTHWEST},
{ AIM_SOUTHEAST, point( 36, 3 ), tripoint_south_east, _( "South East" ), _( "SE" ), "3", "ITEMS_SE", AIM_SOUTH},
{ AIM_WEST, point( 30, 2 ), tripoint_west, _( "West" ), _( "W" ), "4", "ITEMS_W", AIM_NORTHWEST},
{ AIM_CENTER, point( 33, 2 ), tripoint_zero, _( "Directly below you" ), _( "DN" ), "5", "ITEMS_CE", AIM_CENTER},
{ AIM_EAST, point( 36, 2 ), tripoint_east, _( "East" ), _( "E" ), "6", "ITEMS_E", AIM_SOUTHEAST},
{ AIM_NORTHWEST, point( 30, 1 ), tripoint_north_west, _( "North West" ), _( "NW" ), "7", "ITEMS_NW", AIM_NORTH},
{ AIM_NORTH, point( 33, 1 ), tripoint_north, _( "North" ), _( "N" ), "8", "ITEMS_N", AIM_NORTHEAST},
{ AIM_NORTHEAST, point( 36, 1 ), tripoint_north_east, _( "North East" ), _( "NE" ), "9", "ITEMS_NE", AIM_EAST},
{ AIM_DRAGGED, point( 25, 1 ), tripoint_zero, _( "Grabbed Vehicle" ), _( "GR" ), "D", "ITEMS_DRAGGED_CONTAINER", AIM_DRAGGED},
{ AIM_ALL, point( 22, 3 ), tripoint_zero, _( "Surrounding area" ), _( "AL" ), "A", "ITEMS_AROUND", AIM_ALL},
{ AIM_CONTAINER, point( 22, 1 ), tripoint_zero, _( "Container" ), _( "CN" ), "C", "ITEMS_CONTAINER", AIM_CONTAINER},
{ AIM_WORN, point( 25, 3 ), tripoint_zero, _( "Worn Items" ), _( "WR" ), "W", "ITEMS_WORN", AIM_WORN}
}
} )
{
Expand Down Expand Up @@ -1501,7 +1501,7 @@ void advanced_inventory::display()
string_input_popup spopup;
std::string filter = spane.filter;
filter_edit = true;
spopup.window( spane.window, 4, w_height - 1, w_width / 2 - 4 )
spopup.window( spane.window, point( 4, w_height - 1 ), w_width / 2 - 4 )
.max_length( 256 )
.text( filter );

Expand Down
4 changes: 2 additions & 2 deletions src/advanced_inv_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ int advanced_inv_area::get_item_count() const
}
}

advanced_inv_area::advanced_inv_area( aim_location id, int hscreenx, int hscreeny, tripoint off,
advanced_inv_area::advanced_inv_area( aim_location id, const point &h, tripoint off,
const std::string &name, const std::string &shortname,
std::string minimapname, std::string actionname,
aim_location relative_location ) :
id( id ), hscreen( hscreenx, hscreeny ),
id( id ), hscreen( h ),
off( off ), name( name ), shortname( shortname ),
canputitemsloc( false ), veh( nullptr ), vstor( -1 ), volume( 0_ml ),
weight( 0_gram ), max_size( 0 ), minimapname( minimapname ), actionname( actionname ),
Expand Down
7 changes: 4 additions & 3 deletions src/advanced_inv_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ class advanced_inv_area
const aim_location relative_location;

advanced_inv_area( aim_location id ) : id( id ), relative_location( id ) {}
advanced_inv_area( aim_location id, int hscreenx, int hscreeny, tripoint off,
const std::string &name, const std::string &shortname, std::string minimapname,
std::string actionname, aim_location relative_location );
advanced_inv_area(
aim_location id, const point &hscreen, tripoint off, const std::string &name,
const std::string &shortname, std::string minimapname, std::string actionname,
aim_location relative_location );

void init();

Expand Down
12 changes: 6 additions & 6 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const std::string flag_SWIMMABLE( "SWIMMABLE" );

#define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": "

bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz )
bool avatar_action::move( avatar &you, map &m, const tripoint &d )
{
if( ( !g->check_safe_mode_allowed() ) || you.has_active_mutation( trait_SHELL2 ) ) {
if( you.has_active_mutation( trait_SHELL2 ) ) {
Expand All @@ -100,14 +100,14 @@ bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz )
}
const bool is_riding = you.is_mounted();
tripoint dest_loc;
if( dz == 0 && you.has_effect( effect_stunned ) ) {
if( d.z == 0 && you.has_effect( effect_stunned ) ) {
dest_loc.x = rng( you.posx() - 1, you.posx() + 1 );
dest_loc.y = rng( you.posy() - 1, you.posy() + 1 );
dest_loc.z = you.posz();
} else {
dest_loc.x = you.posx() + dx;
dest_loc.y = you.posy() + dy;
dest_loc.z = you.posz() + dz;
dest_loc.x = you.posx() + d.x;
dest_loc.y = you.posy() + d.y;
dest_loc.z = you.posz() + d.z;
}

if( dest_loc == you.pos() ) {
Expand Down Expand Up @@ -215,7 +215,7 @@ bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz )
}
}

if( dz == 0 && ramp_move( you, m, dest_loc ) ) {
if( d.z == 0 && ramp_move( you, m, dest_loc ) ) {
// TODO: Make it work nice with automove (if it doesn't do so already?)
return false;
}
Expand Down
6 changes: 1 addition & 5 deletions src/avatar_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ bool eat_here( avatar &you );

// Standard movement; handles attacks, traps, &c. Returns false if auto move
// should be canceled
bool move( avatar &you, map &m, int dx, int dy, int dz = 0 );
inline bool move( avatar &you, map &m, const tripoint &d )
{
return move( you, m, d.x, d.y, d.z );
}
bool move( avatar &you, map &m, const tripoint &d );
inline bool move( avatar &you, map &m, const point &d )
{
return move( you, m, tripoint( d, 0 ) );
Expand Down
4 changes: 2 additions & 2 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,11 +1591,11 @@ void check_constructions()
}
}

int construction::print_time( const catacurses::window &w, int ypos, int xpos, int width,
int construction::print_time( const catacurses::window &w, const point &p, int width,
nc_color col ) const
{
std::string text = get_time_string();
return fold_and_print( w, point( xpos, ypos ), width, col, text );
return fold_and_print( w, p, width, col, text );
}

float construction::time_scale() const
Expand Down
2 changes: 1 addition & 1 deletion src/construction.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct construction {

// NPC assistance adjusted
int adjusted_time() const;
int print_time( const catacurses::window &w, int ypos, int xpos, int width, nc_color col ) const;
int print_time( const catacurses::window &w, const point &, int width, nc_color col ) const;
std::vector<std::string> get_folded_time_string( int width ) const;
// Result of construction scaling option
float time_scale() const;
Expand Down
32 changes: 16 additions & 16 deletions src/coordinate_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ static int divide( int v, int m, int &r )
return result;
}

point omt_to_om_copy( int x, int y )
point omt_to_om_copy( const point &p )
{
return point( divide( x, OMAPX ), divide( y, OMAPY ) );
return point( divide( p.x, OMAPX ), divide( p.y, OMAPY ) );
}

tripoint omt_to_om_copy( const tripoint &p )
Expand All @@ -43,9 +43,9 @@ point om_to_omt_copy( const point &p )
return point( p.x * OMAPX, p.y * OMAPY );
}

point sm_to_omt_copy( int x, int y )
point sm_to_omt_copy( const point &p )
{
return point( divide( x, 2 ), divide( y, 2 ) );
return point( divide( p.x, 2 ), divide( p.y, 2 ) );
}

tripoint sm_to_omt_copy( const tripoint &p )
Expand All @@ -64,9 +64,9 @@ point sm_to_omt_remain( int &x, int &y )
return point( divide( x, 2, x ), divide( y, 2, y ) );
}

point sm_to_om_copy( int x, int y )
point sm_to_om_copy( const point &p )
{
return point( divide( x, 2 * OMAPX ), divide( y, 2 * OMAPY ) );
return point( divide( p.x, 2 * OMAPX ), divide( p.y, 2 * OMAPY ) );
}

tripoint sm_to_om_copy( const tripoint &p )
Expand All @@ -90,9 +90,9 @@ point omt_to_ms_copy( const point &p )
return point( p.x * 2 * SEEX, p.y * 2 * SEEY );
}

point omt_to_sm_copy( int x, int y )
point omt_to_sm_copy( const point &p )
{
return point( x * 2, y * 2 );
return point( p.x * 2, p.y * 2 );
}

tripoint omt_to_sm_copy( const tripoint &p )
Expand All @@ -106,9 +106,9 @@ void omt_to_sm( int &x, int &y )
y *= 2;
}

point om_to_sm_copy( int x, int y )
point om_to_sm_copy( const point &p )
{
return point( x * 2 * OMAPX, y * 2 * OMAPX );
return point( p.x * 2 * OMAPX, p.y * 2 * OMAPX );
}

tripoint om_to_sm_copy( const tripoint &p )
Expand All @@ -122,9 +122,9 @@ void om_to_sm( int &x, int &y )
y *= 2 * OMAPY;
}

point ms_to_sm_copy( int x, int y )
point ms_to_sm_copy( const point &p )
{
return point( divide( x, SEEX ), divide( y, SEEY ) );
return point( divide( p.x, SEEX ), divide( p.y, SEEY ) );
}

tripoint ms_to_sm_copy( const tripoint &p )
Expand All @@ -143,9 +143,9 @@ point ms_to_sm_remain( int &x, int &y )
return point( divide( x, SEEX, x ), divide( y, SEEY, y ) );
}

point sm_to_ms_copy( int x, int y )
point sm_to_ms_copy( const point &p )
{
return point( x * SEEX, y * SEEY );
return point( p.x * SEEX, p.y * SEEY );
}

tripoint sm_to_ms_copy( const tripoint &p )
Expand All @@ -159,9 +159,9 @@ void sm_to_ms( int &x, int &y )
y *= SEEY;
}

point ms_to_omt_copy( int x, int y )
point ms_to_omt_copy( const point &p )
{
return point( divide( x, SEEX * 2 ), divide( y, SEEY * 2 ) );
return point( divide( p.x, SEEX * 2 ), divide( p.y, SEEY * 2 ) );
}

tripoint ms_to_omt_copy( const tripoint &p )
Expand Down
50 changes: 8 additions & 42 deletions src/coordinate_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@
*/

// overmap terrain to overmap
point omt_to_om_copy( int x, int y );
inline point omt_to_om_copy( const point &p )
{
return omt_to_om_copy( p.x, p.y );
}
point omt_to_om_copy( const point &p );
tripoint omt_to_om_copy( const tripoint &p );
void omt_to_om( int &x, int &y );
inline void omt_to_om( point &p )
Expand All @@ -77,11 +73,7 @@ inline point omt_to_om_remain( point &p )
// overmap to overmap terrain
point om_to_omt_copy( const point &p );
// submap to overmap terrain
point sm_to_omt_copy( int x, int y );
inline point sm_to_omt_copy( const point &p )
{
return sm_to_omt_copy( p.x, p.y );
}
point sm_to_omt_copy( const point &p );
tripoint sm_to_omt_copy( const tripoint &p );
void sm_to_omt( int &x, int &y );
inline void sm_to_omt( point &p )
Expand All @@ -98,11 +90,7 @@ inline point sm_to_omt_remain( point &p )
return sm_to_omt_remain( p.x, p.y );
}
// submap to overmap, basically: x / (OMAPX * 2)
point sm_to_om_copy( int x, int y );
inline point sm_to_om_copy( const point &p )
{
return sm_to_om_copy( p.x, p.y );
}
point sm_to_om_copy( const point &p );
tripoint sm_to_om_copy( const tripoint &p );
void sm_to_om( int &x, int &y );
inline void sm_to_om( point &p )
Expand All @@ -119,17 +107,11 @@ inline point sm_to_om_remain( point &p )
return sm_to_om_remain( p.x, p.y );
}
// overmap terrain to submap, basically: x *= 2
point omt_to_sm_copy( int x, int y );

inline int omt_to_sm_copy( int a )
{
return 2 * a;
}

inline point omt_to_sm_copy( const point &p )
{
return omt_to_sm_copy( p.x, p.y );
}
point omt_to_sm_copy( const point &p );
tripoint omt_to_sm_copy( const tripoint &p );
void omt_to_sm( int &x, int &y );
inline void omt_to_sm( point &p )
Expand All @@ -143,11 +125,7 @@ inline void omt_to_sm( tripoint &p )
// overmap terrain to map square
point omt_to_ms_copy( const point &p );
// overmap to submap, basically: x *= 2 * OMAPX
point om_to_sm_copy( int x, int y );
inline point om_to_sm_copy( const point &p )
{
return om_to_sm_copy( p.x, p.y );
}
point om_to_sm_copy( const point &p );
tripoint om_to_sm_copy( const tripoint &p );
void om_to_sm( int &x, int &y );
inline void om_to_sm( point &p )
Expand All @@ -159,11 +137,7 @@ inline void om_to_sm( tripoint &p )
om_to_sm( p.x, p.y );
}
// map squares to submap, basically: x /= SEEX
point ms_to_sm_copy( int x, int y );
inline point ms_to_sm_copy( const point &p )
{
return ms_to_sm_copy( p.x, p.y );
}
point ms_to_sm_copy( const point &p );
tripoint ms_to_sm_copy( const tripoint &p );
void ms_to_sm( int &x, int &y );
inline void ms_to_sm( point &p )
Expand All @@ -186,11 +160,7 @@ inline tripoint ms_to_sm_remain( tripoint &p )
// submap back to map squares, basically: x *= SEEX
// Note: this gives you the map square coordinates of the top-left corner
// of the given submap.
point sm_to_ms_copy( int x, int y );
inline point sm_to_ms_copy( const point &p )
{
return sm_to_ms_copy( p.x, p.y );
}
point sm_to_ms_copy( const point &p );
tripoint sm_to_ms_copy( const tripoint &p );
void sm_to_ms( int &x, int &y );
inline void sm_to_ms( point &p )
Expand All @@ -202,11 +172,7 @@ inline void sm_to_ms( tripoint &p )
sm_to_ms( p.x, p.y );
}
// map squares to overmap terrain, basically: x /= SEEX * 2
point ms_to_omt_copy( int x, int y );
inline point ms_to_omt_copy( const point &p )
{
return ms_to_omt_copy( p.x, p.y );
}
point ms_to_omt_copy( const point &p );
tripoint ms_to_omt_copy( const tripoint &p );
void ms_to_omt( int &x, int &y );
inline void ms_to_omt( point &p )
Expand Down
6 changes: 3 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ bool game::cleanup_at_end()

int iStartX = FULL_SCREEN_WIDTH / 2 - ( ( iMaxWidth - 4 ) / 2 );
std::string sLastWords = string_input_popup()
.window( w_rip, iStartX, iNameLine, iStartX + iMaxWidth - 4 - 1 )
.window( w_rip, point( iStartX, iNameLine ), iStartX + iMaxWidth - 4 - 1 )
.max_length( iMaxWidth - 4 - 1 )
.query_string();
death_screen();
Expand Down Expand Up @@ -10737,7 +10737,7 @@ point game::update_map( int &x, int &y )

// Shift NPCs
for( auto it = active_npc.begin(); it != active_npc.end(); ) {
( *it )->shift( shift.x, shift.y );
( *it )->shift( shift );
if( ( *it )->posx() < 0 - SEEX * 2 || ( *it )->posy() < 0 - SEEX * 2 ||
( *it )->posx() > SEEX * ( MAPSIZE + 2 ) || ( *it )->posy() > SEEY * ( MAPSIZE + 2 ) ) {
//Remove the npc from the active list. It remains in the overmap list.
Expand Down Expand Up @@ -11136,7 +11136,7 @@ void game::perhaps_add_random_npc()
tmp->set_fac( new_solo_fac ? new_solo_fac->id : faction_id( "no_faction" ) );
// adds the npc to the correct overmap.
tripoint submap_spawn = omt_to_sm_copy( spawn_point );
tmp->spawn_at_sm( submap_spawn.x, submap_spawn.y, 0 );
tmp->spawn_at_sm( tripoint( submap_spawn.xy(), 0 ) );
overmap_buffer.insert_npc( tmp );
tmp->form_opinion( u );
tmp->mission = NPC_MISSION_NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ action_id input_context::display_menu( const bool permit_execute_action )
display_height = height - LEGEND_HEIGHT - BORDER_SPACE; // -2 for the border
// width of the legend
legwidth = width - 4 - BORDER_SPACE;
spopup.window( w_help, 4, 8, legwidth )
spopup.window( w_help, point( 4, 8 ), legwidth )
.max_length( legwidth )
.context( ctxt );
ui.position_from_window( w_help );
Expand Down
2 changes: 1 addition & 1 deletion src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ void inventory_selector::refresh_window() const
void inventory_selector::set_filter()
{
string_input_popup spopup;
spopup.window( w_inv, 4, getmaxy( w_inv ) - 1, ( getmaxx( w_inv ) / 2 ) - 4 )
spopup.window( w_inv, point( 4, getmaxy( w_inv ) - 1 ), ( getmaxx( w_inv ) / 2 ) - 4 )
.max_length( 256 )
.text( filter );

Expand Down
Loading