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

Function help_dir

src/cmd.c:4170–4296  ·  view source on GitHub ↗

explain choices if player has asked for getdir() help or has given an invalid direction after a prefix key ('F', 'g', 'm', &c), which might be bogus but could be up, down, or self when not applicable */

Source from the content-addressed store, hash-verified

4168 an invalid direction after a prefix key ('F', 'g', 'm', &c), which
4169 might be bogus but could be up, down, or self when not applicable */
4170staticfn boolean
4171help_dir(
4172 char sym,
4173 uchar spkey, /* actual key; either prefix or ESC */
4174 const char *msg)
4175{
4176 static const char wiz_only_list[] = "EFGIVW";
4177 char ctrl;
4178 winid win;
4179 char buf[BUFSZ], buf2[BUFSZ], *explain;
4180 const char *dothat /*, *how */;
4181 boolean prefixhandling /*, viawindow */;
4182
4183 /* NHKF_ESC indicates that player asked for help at getdir prompt */
4184 /* viawindow = (spkey == gc.Cmd.spkeys[NHKF_ESC] || iflags.cmdassist); */
4185 prefixhandling = (spkey != gc.Cmd.spkeys[NHKF_ESC]);
4186 /*
4187 * Handling for prefix keys that don't want special directions.
4188 * Delivered via pline if 'cmdassist' is off, or instead of the
4189 * general message if it's on.
4190 */
4191 dothat = "do that";
4192 /* how = " at"; */ /* for "<action> at yourself"; not used for up/down */
4193
4194 buf[0] = '\0';
4195#if 0 /* Since prefix keys got 'promoted' to commands, feedback for
4196 * invalid prefix is done in rhack() these days.
4197 */
4198 /* for movement prefix followed by '.' or (numpad && 's') to mean 'self';
4199 note: '-' for hands (inventory form of 'self') is not handled here */
4200 if (prefixhandling
4201 && (sym == gc.Cmd.spkeys[NHKF_GETDIR_SELF]
4202 || (gc.Cmd.num_pad && sym == gc.Cmd.spkeys[NHKF_GETDIR_SELF2]))) {
4203 Sprintf(buf, "You can't %s%s yourself.", dothat, how);
4204 /* for movement prefix followed by up or down */
4205 } else if (prefixhandling && (sym == '<' || sym == '>')) {
4206 Sprintf(buf, "You can't %s %s.", dothat,
4207 /* was "upwards" and "downwards", but they're considered
4208 to be variants of canonical "upward" and "downward" */
4209 (sym == '<') ? "upward" : "downward");
4210 }
4211
4212 /* if '!cmdassist', display via pline() and we're done (note: asking
4213 for help at getdir() prompt forces cmdassist for this operation) */
4214 if (!viawindow) {
4215 if (prefixhandling) {
4216 if (!*buf)
4217 Sprintf(buf, "Invalid direction for '%s' prefix.",
4218 visctrl(spkey));
4219 pline("%s", buf);
4220 return TRUE;
4221 }
4222 /* when 'cmdassist' is off and caller doesn't insist, do nothing */
4223 return FALSE;
4224 }
4225#else
4226 nhUse(prefixhandling);
4227#endif

Callers 1

getdirFunction · 0.85

Calls 6

visctrlFunction · 0.85
letterFunction · 0.85
highcFunction · 0.85
dowhatdoes_coreFunction · 0.85
show_direction_keysFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected