MCPcopy Index your code
hub / github.com/NetHack/NetHack / reset_commands

Function reset_commands

src/cmd.c:3343–3476  ·  view source on GitHub ↗

called at startup and after number_pad is twiddled */

Source from the content-addressed store, hash-verified

3341
3342/* called at startup and after number_pad is twiddled */
3343void
3344reset_commands(boolean initial)
3345{
3346 static const char sdir[] = "hykulnjb><",
3347 sdir_swap_yz[] = "hzkulnjb><",
3348 ndir[] = "47896321><",
3349 ndir_phone_layout[] = "41236987><";
3350 static const int ylist[] = {
3351 'y', 'Y', C('y'), M('y'), M('Y'), M(C('y'))
3352 };
3353 static struct ext_func_tab *back_dir_cmd[N_DIRS][N_MOVEMODES];
3354 static uchar back_dir_key[N_DIRS][N_MOVEMODES];
3355 static boolean backed_dir_cmd = FALSE;
3356 boolean flagtemp;
3357 int c, i, updated = 0;
3358 int dir, mode;
3359
3360 if (initial) {
3361 updated = 1;
3362 gc.Cmd.num_pad = FALSE;
3363 gc.Cmd.pcHack_compat = gc.Cmd.phone_layout = gc.Cmd.swap_yz = FALSE;
3364 for (i = 0; i < SIZE(spkeys_binds); i++)
3365 gc.Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key;
3366 commands_init();
3367 } else {
3368 if (backed_dir_cmd) {
3369 for (dir = 0; dir < N_DIRS; dir++) {
3370 for (mode = 0; mode < N_MOVEMODES; mode++) {
3371 cmdbind_add(back_dir_key[dir][mode], back_dir_cmd[dir][mode], FALSE);
3372 }
3373 }
3374 }
3375
3376 /* basic num_pad */
3377 flagtemp = iflags.num_pad;
3378 if (flagtemp != gc.Cmd.num_pad) {
3379 gc.Cmd.num_pad = flagtemp;
3380 ++updated;
3381 }
3382 /* swap_yz mode (only applicable for !num_pad); intended for
3383 QWERTZ keyboard used in Central Europe, particularly Germany */
3384 flagtemp = (iflags.num_pad_mode & 1) ? !gc.Cmd.num_pad : FALSE;
3385 if (flagtemp != gc.Cmd.swap_yz) {
3386 gc.Cmd.swap_yz = flagtemp;
3387 ++updated;
3388 /* FIXME? should Cmd.spkeys[] be scanned for y and/or z to swap?
3389 Cmd.swap_yz has been toggled;
3390 perform the swap (or reverse previous one) */
3391 for (i = 0; i < SIZE(ylist); i++) {
3392 c = ylist[i] & 0xff;
3393 cmdbind_swapkeys(c, c + 1);
3394 }
3395 }
3396 /* MSDOS compatibility mode (only applicable for num_pad) */
3397 flagtemp = (iflags.num_pad_mode & 1) ? gc.Cmd.num_pad : FALSE;
3398 if (flagtemp != gc.Cmd.pcHack_compat) {
3399 gc.Cmd.pcHack_compat = flagtemp;
3400 ++updated;

Callers 3

optfn_number_padFunction · 0.85
handler_number_padFunction · 0.85
initoptions_initFunction · 0.85

Calls 10

commands_initFunction · 0.85
cmdbind_addFunction · 0.85
cmdbind_swapkeysFunction · 0.85
ext_func_tab_from_funcFunction · 0.85
cmdbind_removeFunction · 0.85
highcFunction · 0.85
cmdbind_getFunction · 0.85
bind_key_fnFunction · 0.85
update_rest_on_spaceFunction · 0.85
cmd_from_funcFunction · 0.85

Tested by

no test coverage detected