MCPcopy Create free account
hub / github.com/crawl/crawl / process_command

Function process_command

crawl-ref/source/main.cc:2094–2508  ·  view source on GitHub ↗

Note that in some actions, you don't want to clear afterwards. e.g. list_jewellery, etc. calling this directly will not record the command for later replay; if you want to ensure that it's recorded, see macro.cc:process_command_on_record.

Source from the content-addressed store, hash-verified

2092// calling this directly will not record the command for later replay; if you
2093// want to ensure that it's recorded, see macro.cc:process_command_on_record.
2094void process_command(command_type cmd, command_type prev_cmd)
2095{
2096 you.apply_berserk_penalty = true;
2097
2098 if (cmd == CMD_GAME_MENU)
2099 {
2100 GameMenu m;
2101 m.show();
2102 if (m.cmd == CMD_NO_CMD)
2103 return;
2104 cmd = m.cmd;
2105 }
2106
2107 switch (cmd)
2108 {
2109#ifdef USE_TILE
2110 // Tiles-specific commands.
2111 case CMD_EDIT_PLAYER_TILE: tiles.draw_doll_edit(); break;
2112#endif
2113
2114 // Movement and running commands.
2115 case CMD_ATTACK_DOWN_LEFT: _swing_at_target({-1, 1}); break;
2116 case CMD_ATTACK_DOWN: _swing_at_target({ 0, 1}); break;
2117 case CMD_ATTACK_UP_RIGHT: _swing_at_target({ 1, -1}); break;
2118 case CMD_ATTACK_UP: _swing_at_target({ 0, -1}); break;
2119 case CMD_ATTACK_UP_LEFT: _swing_at_target({-1, -1}); break;
2120 case CMD_ATTACK_LEFT: _swing_at_target({-1, 0}); break;
2121 case CMD_ATTACK_DOWN_RIGHT: _swing_at_target({ 1, 1}); break;
2122 case CMD_ATTACK_RIGHT: _swing_at_target({ 1, 0}); break;
2123
2124 case CMD_MOVE_DOWN_LEFT: move_player_action({-1, 1}); break;
2125 case CMD_MOVE_DOWN: move_player_action({ 0, 1}); break;
2126 case CMD_MOVE_UP_RIGHT: move_player_action({ 1, -1}); break;
2127 case CMD_MOVE_UP: move_player_action({ 0, -1}); break;
2128 case CMD_MOVE_UP_LEFT: move_player_action({-1, -1}); break;
2129 case CMD_MOVE_LEFT: move_player_action({-1, 0}); break;
2130 case CMD_MOVE_DOWN_RIGHT: move_player_action({ 1, 1}); break;
2131 case CMD_MOVE_RIGHT: move_player_action({ 1, 0}); break;
2132
2133 case CMD_SAFE_MOVE_DOWN_LEFT: _safe_move_player({-1, 1}); break;
2134 case CMD_SAFE_MOVE_DOWN: _safe_move_player({ 0, 1}); break;
2135 case CMD_SAFE_MOVE_UP_RIGHT: _safe_move_player({ 1, -1}); break;
2136 case CMD_SAFE_MOVE_UP: _safe_move_player({ 0, -1}); break;
2137 case CMD_SAFE_MOVE_UP_LEFT: _safe_move_player({-1, -1}); break;
2138 case CMD_SAFE_MOVE_LEFT: _safe_move_player({-1, 0}); break;
2139 case CMD_SAFE_MOVE_DOWN_RIGHT: _safe_move_player({ 1, 1}); break;
2140 case CMD_SAFE_MOVE_RIGHT: _safe_move_player({ 1, 0}); break;
2141
2142 case CMD_CLOSE_DOOR_DOWN_LEFT: close_door_action({-1, 1}); break;
2143 case CMD_CLOSE_DOOR_DOWN: close_door_action({ 0, 1}); break;
2144 case CMD_CLOSE_DOOR_UP_RIGHT: close_door_action({ 1, -1}); break;
2145 case CMD_CLOSE_DOOR_UP: close_door_action({ 0, -1}); break;
2146 case CMD_CLOSE_DOOR_UP_LEFT: close_door_action({-1, -1}); break;
2147 case CMD_CLOSE_DOOR_LEFT: close_door_action({-1, 0}); break;
2148 case CMD_CLOSE_DOOR_DOWN_RIGHT: close_door_action({ 1, 1}); break;
2149 case CMD_CLOSE_DOOR_RIGHT: close_door_action({ 1, 0}); break;
2150 case CMD_CLOSE_DOOR: close_door_action({ 0, 0}); break;
2151

Callers 15

_inputFunction · 0.70
GameMenuMethod · 0.70
handle_mouseMethod · 0.70
process_commandMethod · 0.70
process_commandMethod · 0.70
tile_click_cellFunction · 0.70
process_keyMethod · 0.70
_handle_cell_clickFunction · 0.70
handle_mouseMethod · 0.70
process_commandMethod · 0.70

Calls 15

_swing_at_targetFunction · 0.85
move_player_actionFunction · 0.85
_safe_move_playerFunction · 0.85
close_door_actionFunction · 0.85
_handle_autofightFunction · 0.85
_do_restFunction · 0.85
_take_stairsFunction · 0.85
open_door_actionFunction · 0.85
_do_cmd_repeatFunction · 0.85
_do_prev_cmd_againFunction · 0.85
macro_quick_addFunction · 0.85
macro_menuFunction · 0.85

Tested by

no test coverage detected