MCPcopy Create free account
hub / github.com/NetHack/NetHack / dotelecmd

Function dotelecmd

src/teleport.c:918–1031  ·  view source on GitHub ↗

the #teleport command; 'm ^T' == choose among several teleport modes */

Source from the content-addressed store, hash-verified

916
917/* the #teleport command; 'm ^T' == choose among several teleport modes */
918int
919dotelecmd(void)
920{
921 long save_HTele, save_ETele;
922 int res, added, hidden;
923 boolean ignore_restrictions = FALSE;
924/* also defined in spell.c */
925#define NOOP_SPELL 0
926#define HIDE_SPELL 1
927#define ADD_SPELL 2
928#define UNHIDESPELL 3
929#define REMOVESPELL 4
930
931 /* normal mode; ignore 'm' prefix if it was given */
932 if (!wizard)
933 return dotele(FALSE) ? ECMD_TIME : ECMD_OK;
934
935 added = hidden = NOOP_SPELL;
936 save_HTele = HTeleportation, save_ETele = ETeleportation;
937 if (!iflags.menu_requested) {
938 ignore_restrictions = TRUE;
939 } else {
940 static const struct tporttypes {
941 char menulet;
942 const char *menudesc;
943 } tports[] = {
944 /*
945 * Potential combinations:
946 * 1) attempt ^T without intrinsic, not know spell;
947 * 2) via intrinsic, not know spell, obey restrictions;
948 * 3) via intrinsic, not know spell, ignore restrictions;
949 * 4) via intrinsic, know spell, obey restrictions;
950 * 5) via intrinsic, know spell, ignore restrictions;
951 * 6) via spell, not have intrinsic, obey restrictions;
952 * 7) via spell, not have intrinsic, ignore restrictions;
953 * 8) force, obey other restrictions;
954 * 9) force, ignore restrictions.
955 * We only support the 1st (t), 2nd (n), 6th (s), and 9th (w).
956 *
957 * This ignores the fact that there is an experience level
958 * (or poly-form) requirement which might make normal ^T fail.
959 */
960 { 'n', "normal ^T on demand; no spell, obey restrictions" },
961 { 's', "via spellcast; no intrinsic teleport" },
962 { 't', "try ^T without having it; no spell" },
963 { 'w', "debug mode; ignore restrictions" }, /* trad wizard mode */
964 };
965 menu_item *picks = (menu_item *) 0;
966 anything any;
967 winid win;
968 int i, tmode, clr = NO_COLOR;
969
970 win = create_nhwindow(NHW_MENU);
971 start_menu(win, MENU_BEHAVE_STANDARD);
972 any = cg.zeroany;
973 for (i = 0; i < SIZE(tports); ++i) {
974 any.a_int = (int) tports[i].menulet;
975 add_menu(win, &nul_glyphinfo, &any, (char) any.a_int, 0,

Callers

nothing calls this directly

Calls 4

doteleFunction · 0.85
add_menuFunction · 0.85
select_menuFunction · 0.85
tport_spellFunction · 0.85

Tested by

no test coverage detected