X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fcontrol.c;h=1e9265e73074da48e2f884e93fa2ee94b00c1ed9;hb=60a77cb1894c678fff62840dc6b24931d839f820;hp=502f84a2698ea4e97ae51b211f164fa103a01689;hpb=2dccba703435158681552b8a8aefccab79eb13f3;p=plomrogue diff --git a/src/control.c b/src/control.c index 502f84a..1e9265e 100644 --- a/src/control.c +++ b/src/control.c @@ -1,8 +1,7 @@ /* control.c */ #include "control.h" -#include /* for uint8_t */ -#include /* for strcmp() */ +#include /* for uint8_t, uint16_t */ #include "windows.h" /* for cycle_active_win(), shift_active_win(), struct Win, * struct WinMeta */ @@ -11,15 +10,11 @@ */ #include "map.h" /* for map_scroll(), map_center() */ #include "main.h" /* for world global */ -#include "rexit.h" /* for exit_err() */ #include "wincontrol.h" /* for struct WinConf, scroll_pad(), toggle_window(), - * growshrink_active_window(),toggle_winconfig(), - * toggle_win_height_type(), toggle_win_width_type() + * growshrink_active_window(), toggle_winconfig(), + * toggle_win_size_type() */ -#include "map_object_actions.h" /* for struct MapObjAct, actor_wait(), - * actor_move(), actor_drop(), actor_pick(), - * actor_pick() - */ +#include "map_object_actions.h" /* for get_moa_id_by_name() */ #include "command_db.h" /* for is_command_id_shortdsc() */ #include "misc.h" /* for reload_interface_conf(), save_interface_conf(), * nav_inventory(), turn_over() @@ -36,11 +31,8 @@ static uint8_t try_cmd_1args(int cmd, char * match, void (* f) (char), char c); static uint8_t try_cmd_2args(int cmd, char * match, void (* f) (char, char), char c1, char c2); -/* try_player_cmd() helper, returns world.map_obj_acts action id for "name". */ -static uint8_t get_moa_id_by_name(char * name); - -/* If "action" is id of command named "match", set player->arg, ->command and - * call turn_over(). +/* If "action" is id of command named "match", set player's .arg and .command + * and call turn_over(). */ static uint8_t try_player_cmd(int action, char * match, char * command, uint8_t arg); @@ -93,23 +85,6 @@ static uint8_t try_cmd_2args(int cmd, char * match, -static uint8_t get_moa_id_by_name(char * name) -{ - struct MapObjAct * moa = world.map_obj_acts; - while (NULL != moa) - { - if (0 == strcmp(moa->name, name)) - { - break; - } - moa = moa->next; - } - exit_err(NULL == moa, "get_moa_id_name() did not find map object action."); - return moa->id; -} - - - static uint8_t try_player_cmd(int action, char * match, char * command, uint8_t arg) { @@ -209,9 +184,9 @@ extern uint8_t player_control_by_key(int key) extern uint8_t player_control_by_id(int action) { if ( try_player_cmd(action, "wait", "wait", 0) - || try_player_cmd(action, "drop", "drop", world.inventory_select) + || try_player_cmd(action, "drop", "drop", world.inventory_sel) || try_player_cmd(action, "pick", "pick_up", 0) - || try_player_cmd(action, "use", "use", world.inventory_select) + || try_player_cmd(action, "use", "use", world.inventory_sel) || try_player_cmd(action, "player_u", "move", 'N') || try_player_cmd(action, "player_d", "move", 'S') || try_player_cmd(action, "player_r", "move", 'E') @@ -226,8 +201,8 @@ extern uint8_t player_control_by_id(int action) extern uint8_t wingeom_control(int key) { - if ( try_cmd_0args(key, "to_height_t", toggle_win_height_type) - || try_cmd_0args(key, "to_width_t", toggle_win_width_type) + if ( try_cmd_1args(key, "to_height_t", toggle_win_size_type, 'y') + || try_cmd_1args(key, "to_width_t", toggle_win_size_type, 'x') || try_cmd_1args(key, "grow_h", growshrink_active_window, '*') || try_cmd_1args(key, "shri_h", growshrink_active_window, '_') || try_cmd_1args(key, "grow_v", growshrink_active_window, '+')