Skip to content

Commit

Permalink
Port function implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytheway committed Apr 18, 2020
1 parent 1becada commit 85e550c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
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
1 change: 0 additions & 1 deletion src/construction.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ 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
Expand Down
12 changes: 6 additions & 6 deletions src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ std::string window_panel::get_name() const
}

void overmap_ui::draw_overmap_chunk( const catacurses::window &w_minimap, const avatar &you,
const tripoint &global_omt, const int start_y_input, const int start_x_input, const int width,
const int height )
const tripoint &global_omt, const point &start_input,
const int width, const int height )
{
const int cursx = global_omt.x;
const int cursy = global_omt.y;
const tripoint targ = you.get_active_mission_target();
bool drew_mission = targ == overmap::invalid_tripoint;
const int start_y = start_y_input + ( height / 2 ) - 2;
const int start_x = start_x_input + ( width / 2 ) - 2;
const int start_y = start_input.y + ( height / 2 ) - 2;
const int start_x = start_input.x + ( width / 2 ) - 2;

for( int i = -( width / 2 ); i <= width - ( width / 2 ) - 1; i++ ) {
for( int j = -( height / 2 ); j <= height - ( height / 2 ) - 1; j++ ) {
Expand Down Expand Up @@ -410,7 +410,7 @@ void overmap_ui::draw_overmap_chunk( const catacurses::window &w_minimap, const
static void draw_minimap( const avatar &u, const catacurses::window &w_minimap )
{
const tripoint curs = u.global_omt_location();
overmap_ui::draw_overmap_chunk( w_minimap, u, curs, 0, 0, 5, 5 );
overmap_ui::draw_overmap_chunk( w_minimap, u, curs, point_zero, 5, 5 );
}

static void decorate_panel( const std::string &name, const catacurses::window &w )
Expand Down Expand Up @@ -1370,7 +1370,7 @@ static void draw_loc_labels( const avatar &u, const catacurses::window &w, bool
if( minimap ) {
const int offset = getmaxx( w ) - 6;
const tripoint curs = u.global_omt_location();
overmap_ui::draw_overmap_chunk( w, u, curs, -1, offset, 5, 5 );
overmap_ui::draw_overmap_chunk( w, u, curs, point( offset, -1 ), 5, 5 );
}
wrefresh( w );
}
Expand Down
3 changes: 0 additions & 3 deletions src/panels.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ enum face_type : int {

namespace overmap_ui
{
void draw_overmap_chunk( const catacurses::window &w_minimap, const avatar &you,
const tripoint &global_omt, int start_y, int start_x, int width,
int height );
void draw_overmap_chunk( const catacurses::window &w_minimap, const avatar &you,
const tripoint &global_omt, const point &start, int width,
int height );
Expand Down
6 changes: 3 additions & 3 deletions src/string_input_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,16 @@ const std::string &string_input_popup::query_string( const bool loop, const bool
return _text;
}

string_input_popup &string_input_popup::window( const catacurses::window &w, int startx, int starty,
string_input_popup &string_input_popup::window( const catacurses::window &w, const point &start,
int endx )
{
if( !custom_window && this->w ) {
// default window already created
return *this;
}
this->w = w;
_startx = startx;
_starty = starty;
_startx = start.x;
_starty = start.y;
_endx = endx;
custom_window = true;
return *this;
Expand Down
1 change: 0 additions & 1 deletion src/string_input_popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class string_input_popup // NOLINT(cata-xy)
* This method only has effect before the default window is initialized.
* After that calls to this method are just ignored.
*/
string_input_popup &window( const catacurses::window &w, int startx, int starty, int endx );
string_input_popup &window( const catacurses::window &w, const point &start, int endx );
/**
* Set / get the input context that is used to gather user input.
Expand Down

0 comments on commit 85e550c

Please sign in to comment.