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 more functions to use point #39956

Merged
merged 4 commits into from
Apr 27, 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
27 changes: 11 additions & 16 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ input_context game::get_player_input( std::string &action )
return ctxt;
}

static void rcdrive( int dx, int dy )
inline static void rcdrive( const point &d )
{
player &u = g->u;
map &m = g->m;
Expand Down Expand Up @@ -412,7 +412,7 @@ static void rcdrive( int dx, int dy )
}
item *rc_car = rc_pair->second;

tripoint dest( cx + dx, cy + dy, cz );
tripoint dest( cx + d.x, cy + d.y, cz );
if( m.impassable( dest ) || !m.can_put_items_ter_furn( dest ) ||
m.has_furn( dest ) ) {
sounds::sound( dest, 7, sounds::sound_t::combat,
Expand All @@ -431,12 +431,7 @@ static void rcdrive( int dx, int dy )
}
}

inline static void rcdrive( point d )
{
return rcdrive( d.x, d.y );
}

static void pldrive( int x, int y, int z = 0 )
static void pldrive( const tripoint &p )
{
if( !g->check_safe_mode_allowed() ) {
return;
Expand Down Expand Up @@ -479,33 +474,33 @@ static void pldrive( int x, int y, int z = 0 )
return;
}
}
if( z != 0 && !u.has_trait( trait_PROF_HELI_PILOT ) ) {
if( p.z != 0 && !u.has_trait( trait_PROF_HELI_PILOT ) ) {
u.add_msg_if_player( m_info, _( "You have no idea how to make the vehicle fly." ) );
return;
}
if( z != 0 && !g->m.has_zlevels() ) {
if( p.z != 0 && !g->m.has_zlevels() ) {
u.add_msg_if_player( m_info, _( "This vehicle doesn't look very airworthy." ) );
return;
}
if( z == -1 ) {
if( p.z == -1 ) {
if( veh->check_heli_descend( u ) ) {
u.add_msg_if_player( m_info, _( "You steer the vehicle into a descent." ) );
} else {
return;
}
} else if( z == 1 ) {
} else if( p.z == 1 ) {
if( veh->check_heli_ascend( u ) ) {
u.add_msg_if_player( m_info, _( "You steer the vehicle into an ascent." ) );
} else {
return;
}
}
veh->pldrive( point( x, y ), z );
veh->pldrive( p.xy(), p.z );
}

inline static void pldrive( point d )
{
return pldrive( d.x, d.y );
return pldrive( tripoint( d, 0 ) );
}

static void open()
Expand Down Expand Up @@ -1817,7 +1812,7 @@ bool game::handle_action()
if( !u.in_vehicle ) {
vertical_move( -1, false );
} else if( veh_ctrl && vp->vehicle().is_rotorcraft() ) {
pldrive( 0, 0, -1 );
pldrive( tripoint_below );
}
break;

Expand All @@ -1832,7 +1827,7 @@ bool game::handle_action()
if( !u.in_vehicle ) {
vertical_move( 1, false );
} else if( veh_ctrl && vp->vehicle().is_rotorcraft() ) {
pldrive( 0, 0, 1 );
pldrive( tripoint_above );
}
break;

Expand Down
12 changes: 6 additions & 6 deletions src/iuse_software_sokoban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,26 @@ void sokoban_game::parse_level( std::istream &fin )
}
}

int sokoban_game::get_wall_connection( const int iY, const int iX )
int sokoban_game::get_wall_connection( const point &i )
{
bool bTop = false;
bool bRight = false;
bool bBottom = false;
bool bLeft = false;

if( mLevel[iY - 1][iX] == "#" ) {
if( mLevel[i.y - 1][i.x] == "#" ) {
bTop = true;
}

if( mLevel[iY][iX + 1] == "#" ) {
if( mLevel[i.y][i.x + 1] == "#" ) {
bRight = true;
}

if( mLevel[iY + 1][iX] == "#" ) {
if( mLevel[i.y + 1][i.x] == "#" ) {
bBottom = true;
}

if( mLevel[iY][iX - 1] == "#" ) {
if( mLevel[i.y][i.x - 1] == "#" ) {
bLeft = true;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ void sokoban_game::draw_level( const catacurses::window &w_sokoban )

if( sTile == "#" ) {
mvwputch( w_sokoban, point( iOffsetX + iterX->first, iOffsetY + elem.first ),
c_white, get_wall_connection( elem.first, iterX->first ) );
c_white, get_wall_connection( point( iterX->first, elem.first ) ) );

} else {
nc_color cCol = c_white;
Expand Down
4 changes: 3 additions & 1 deletion src/iuse_software_sokoban.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <vector>
#include <utility>

struct point;

namespace catacurses
{
class window;
Expand Down Expand Up @@ -50,7 +52,7 @@ class sokoban_game

void parse_level( std::istream &fin );
bool check_win();
int get_wall_connection( int iY, int iX );
int get_wall_connection( const point & );
void draw_level( const catacurses::window &w_sokoban );
void clear_level( const catacurses::window &w_sokoban );
void print_score( const catacurses::window &w_sokoban, int iScore, int iMoves );
Expand Down
2 changes: 1 addition & 1 deletion src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ If you need to insert a new field behavior per unit time add a case statement in
bool map::process_fields_in_submap( submap *const current_submap,
const tripoint &submap )
{
scent_block sblk( submap.x, submap.y, submap.z, g->scent );
scent_block sblk( submap, g->scent );

// This should be true only when the field changes transparency
// More correctly: not just when the field is opaque, but when it changes state
Expand Down
Loading