Skip to content

Commit

Permalink
Rename ACTION_MOVE_<NSWE> actions to better reflect their meaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox committed Jan 9, 2020
1 parent 013cdf9 commit e21eed2
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
64 changes: 32 additions & 32 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ std::string action_ident( action_id act )
return "pause";
case ACTION_TIMEOUT:
return "TIMEOUT";
case ACTION_MOVE_N:
case ACTION_MOVE_FORTH:
return "UP";
case ACTION_MOVE_NE:
case ACTION_MOVE_FORTH_RIGHT:
return "RIGHTUP";
case ACTION_MOVE_E:
case ACTION_MOVE_RIGHT:
return "RIGHT";
case ACTION_MOVE_SE:
case ACTION_MOVE_BACK_RIGHT:
return "RIGHTDOWN";
case ACTION_MOVE_S:
case ACTION_MOVE_BACK:
return "DOWN";
case ACTION_MOVE_SW:
case ACTION_MOVE_BACK_LEFT:
return "LEFTDOWN";
case ACTION_MOVE_W:
case ACTION_MOVE_LEFT:
return "LEFT";
case ACTION_MOVE_NW:
case ACTION_MOVE_FORTH_LEFT:
return "LEFTUP";
case ACTION_MOVE_DOWN:
return "LEVEL_DOWN";
Expand Down Expand Up @@ -454,21 +454,21 @@ action_id look_up_action( const std::string &ident )
{
// Temporarily for the interface with the input manager!
if( ident == "move_nw" ) {
return ACTION_MOVE_NW;
return ACTION_MOVE_FORTH_LEFT;
} else if( ident == "move_sw" ) {
return ACTION_MOVE_SW;
return ACTION_MOVE_BACK_LEFT;
} else if( ident == "move_ne" ) {
return ACTION_MOVE_NE;
return ACTION_MOVE_FORTH_RIGHT;
} else if( ident == "move_se" ) {
return ACTION_MOVE_SE;
return ACTION_MOVE_BACK_RIGHT;
} else if( ident == "move_n" ) {
return ACTION_MOVE_N;
return ACTION_MOVE_FORTH;
} else if( ident == "move_s" ) {
return ACTION_MOVE_S;
return ACTION_MOVE_BACK;
} else if( ident == "move_w" ) {
return ACTION_MOVE_W;
return ACTION_MOVE_LEFT;
} else if( ident == "move_e" ) {
return ACTION_MOVE_E;
return ACTION_MOVE_RIGHT;
} else if( ident == "move_down" ) {
return ACTION_MOVE_DOWN;
} else if( ident == "move_up" ) {
Expand Down Expand Up @@ -512,43 +512,43 @@ action_id get_movement_action_from_delta( const tripoint &d, const iso_rotate ro

const bool iso_mode = rot == iso_rotate::yes && use_tiles && tile_iso;
if( d.xy() == point_north ) {
return iso_mode ? ACTION_MOVE_NW : ACTION_MOVE_N;
return iso_mode ? ACTION_MOVE_FORTH_LEFT : ACTION_MOVE_FORTH;
} else if( d.xy() == point_north_east ) {
return iso_mode ? ACTION_MOVE_N : ACTION_MOVE_NE;
return iso_mode ? ACTION_MOVE_FORTH : ACTION_MOVE_FORTH_RIGHT;
} else if( d.xy() == point_east ) {
return iso_mode ? ACTION_MOVE_NE : ACTION_MOVE_E;
return iso_mode ? ACTION_MOVE_FORTH_RIGHT : ACTION_MOVE_RIGHT;
} else if( d.xy() == point_south_east ) {
return iso_mode ? ACTION_MOVE_E : ACTION_MOVE_SE;
return iso_mode ? ACTION_MOVE_RIGHT : ACTION_MOVE_BACK_RIGHT;
} else if( d.xy() == point_south ) {
return iso_mode ? ACTION_MOVE_SE : ACTION_MOVE_S;
return iso_mode ? ACTION_MOVE_BACK_RIGHT : ACTION_MOVE_BACK;
} else if( d.xy() == point_south_west ) {
return iso_mode ? ACTION_MOVE_S : ACTION_MOVE_SW;
return iso_mode ? ACTION_MOVE_BACK : ACTION_MOVE_BACK_LEFT;
} else if( d.xy() == point_west ) {
return iso_mode ? ACTION_MOVE_SW : ACTION_MOVE_W;
return iso_mode ? ACTION_MOVE_BACK_LEFT : ACTION_MOVE_LEFT;
} else {
return iso_mode ? ACTION_MOVE_W : ACTION_MOVE_NW;
return iso_mode ? ACTION_MOVE_LEFT : ACTION_MOVE_FORTH_LEFT;
}
}

point get_delta_from_movement_action( const action_id act, const iso_rotate rot )
{
const bool iso_mode = rot == iso_rotate::yes && use_tiles && tile_iso;
switch( act ) {
case ACTION_MOVE_N:
case ACTION_MOVE_FORTH:
return iso_mode ? point_north_east : point_north;
case ACTION_MOVE_NE:
case ACTION_MOVE_FORTH_RIGHT:
return iso_mode ? point_east : point_north_east;
case ACTION_MOVE_E:
case ACTION_MOVE_RIGHT:
return iso_mode ? point_south_east : point_east;
case ACTION_MOVE_SE:
case ACTION_MOVE_BACK_RIGHT:
return iso_mode ? point_south : point_south_east;
case ACTION_MOVE_S:
case ACTION_MOVE_BACK:
return iso_mode ? point_south_west : point_south;
case ACTION_MOVE_SW:
case ACTION_MOVE_BACK_LEFT:
return iso_mode ? point_west : point_south_west;
case ACTION_MOVE_W:
case ACTION_MOVE_LEFT:
return iso_mode ? point_north_west : point_west;
case ACTION_MOVE_NW:
case ACTION_MOVE_FORTH_LEFT:
return iso_mode ? point_north : point_north_west;
default:
return point_zero;
Expand Down
36 changes: 18 additions & 18 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ enum action_id : int {
ACTION_PAUSE,
/** Input timeout */
ACTION_TIMEOUT,
/** Move character north */
ACTION_MOVE_N,
/** Move character north-east */
ACTION_MOVE_NE,
/** Move character east */
ACTION_MOVE_E,
/** Move character south-east */
ACTION_MOVE_SE,
/** Move character south */
ACTION_MOVE_S,
/** Move character south-west */
ACTION_MOVE_SW,
/** Move character west */
ACTION_MOVE_W,
/** Move character north-west */
ACTION_MOVE_NW,
/** Move towards top of screen / accelerate */
ACTION_MOVE_FORTH,
/** Move towards top-right of screen / accelerate and steer right */
ACTION_MOVE_FORTH_RIGHT,
/** Move / steer right */
ACTION_MOVE_RIGHT,
/** Move towards bottom-right of screen / decelerate and steer right */
ACTION_MOVE_BACK_RIGHT,
/** Move towards bottom of screen / decelerate */
ACTION_MOVE_BACK,
/** Move towards bottom-left of screen / decelerate and steer left */
ACTION_MOVE_BACK_LEFT,
/** Move / steer left */
ACTION_MOVE_LEFT,
/** Move towards top-left of screen / accelerate and steer left */
ACTION_MOVE_FORTH_LEFT,
/** Descend a staircase */
ACTION_MOVE_DOWN,
/** Ascend a staircase */
Expand Down Expand Up @@ -512,8 +512,8 @@ enum class iso_rotate {
* @note: This function does not sanitize its inputs, which can result in some strange behavior:
* 1. If d.z is valid and non-zero, then d.x and d.y are ignored.
* 2. If d.z is invalid, it is treated as if it were zero.
* 3. If d.z is 0 or invalid, then any invalid d.x or d.y results in @ref ACTION_MOVE_NW
* 4. If d.z is 0 or invalid, then a d.x == d.y == 0 results in @ref ACTION_MOVE_NW
* 3. If d.z is 0 or invalid, then any invalid d.x or d.y results in @ref ACTION_MOVE_FORTH_LEFT
* 4. If d.z is 0 or invalid, then a d.x == d.y == 0 results in @ref ACTION_MOVE_FORTH_LEFT
*
* @param[in] d coordinate delta, each coordinate should be -1, 0, or 1
* @returns ID of corresponding move action (usually... see note above)
Expand Down
16 changes: 8 additions & 8 deletions src/gamemode_defense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ void defense_game::pre_action( action_id &act )
action_error_message = _( "You cannot save in defense mode!" );
}
break;
case ACTION_MOVE_N:
case ACTION_MOVE_NE:
case ACTION_MOVE_E:
case ACTION_MOVE_SE:
case ACTION_MOVE_S:
case ACTION_MOVE_SW:
case ACTION_MOVE_W:
case ACTION_MOVE_NW: {
case ACTION_MOVE_FORTH:
case ACTION_MOVE_FORTH_RIGHT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_BACK_RIGHT:
case ACTION_MOVE_BACK:
case ACTION_MOVE_BACK_LEFT:
case ACTION_MOVE_LEFT:
case ACTION_MOVE_FORTH_LEFT: {
const point delta = get_delta_from_movement_action( act, iso_rotate::yes );
if( ( delta.y < 0 && g->u.posy() == HALF_MAPSIZE_Y && g->get_levy() <= 93 )
|| ( delta.y > 0 && g->u.posy() == HALF_MAPSIZE_Y + SEEY - 1 && g->get_levy() >= 98 )
Expand Down
16 changes: 8 additions & 8 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,14 +1683,14 @@ bool game::handle_action()
open_movement_mode_menu();
break;

case ACTION_MOVE_N:
case ACTION_MOVE_NE:
case ACTION_MOVE_E:
case ACTION_MOVE_SE:
case ACTION_MOVE_S:
case ACTION_MOVE_SW:
case ACTION_MOVE_W:
case ACTION_MOVE_NW:
case ACTION_MOVE_FORTH:
case ACTION_MOVE_FORTH_RIGHT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_BACK_RIGHT:
case ACTION_MOVE_BACK:
case ACTION_MOVE_BACK_LEFT:
case ACTION_MOVE_LEFT:
case ACTION_MOVE_FORTH_LEFT:
if( !u.get_value( "remote_controlling" ).empty() &&
( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) {
rcdrive( get_delta_from_movement_action( act, iso_rotate::yes ) );
Expand Down
6 changes: 3 additions & 3 deletions src/help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void help::deserialize( JsonIn &jsin )
std::string help::get_dir_grid()
{
static const std::array<action_id, 9> movearray = {{
ACTION_MOVE_NW, ACTION_MOVE_N, ACTION_MOVE_NE,
ACTION_MOVE_W, ACTION_PAUSE, ACTION_MOVE_E,
ACTION_MOVE_SW, ACTION_MOVE_S, ACTION_MOVE_SE
ACTION_MOVE_FORTH_LEFT, ACTION_MOVE_FORTH, ACTION_MOVE_FORTH_RIGHT,
ACTION_MOVE_LEFT, ACTION_PAUSE, ACTION_MOVE_RIGHT,
ACTION_MOVE_BACK_LEFT, ACTION_MOVE_BACK, ACTION_MOVE_BACK_RIGHT
}
};

Expand Down

0 comments on commit e21eed2

Please sign in to comment.