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

Function level_tele

src/teleport.c:1164–1441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1162}
1163
1164void
1165level_tele(void)
1166{
1167 static const char get_there_from[] = "get there from %s.";
1168 int newlev;
1169 d_level newlevel;
1170 const char *escape_by_flying = 0; /* when surviving dest of -N */
1171 char buf[BUFSZ];
1172 boolean force_dest = FALSE;
1173
1174 if (iflags.debug_fuzzer) {
1175 do {
1176 newlevel.dnum = rn2(svn.n_dgns);
1177 } while (newlevel.dnum == astral_level.dnum
1178 || svd.dungeons[newlevel.dnum].flags.unconnected
1179 || !svd.dungeons[newlevel.dnum].num_dunlevs);
1180 newlevel.dlevel = 1 + rn2(dunlevs_in_dungeon(&newlevel));
1181 assign_level(&u.ucamefrom, &u.uz);
1182 schedule_goto(&newlevel, UTOTYPE_NONE, (char *) 0, (char *) 0);
1183 return;
1184 }
1185 if ((u.uhave.amulet || In_endgame(&u.uz) || In_sokoban(&u.uz))
1186 && !wizard) {
1187 You_feel("very disoriented for a moment.");
1188 return;
1189 }
1190 if ((Teleport_control && !Stunned) || wizard) {
1191 char qbuf[BUFSZ];
1192 int trycnt = 0;
1193
1194 Strcpy(qbuf, "To what level do you want to teleport?");
1195 do {
1196 if (iflags.menu_requested) {
1197 /* wizard mode 'm ^V' skips prompting on first pass
1198 (note: level Tport via menu won't have any second pass) */
1199 iflags.menu_requested = FALSE;
1200 if (wizard)
1201 goto levTport_menu;
1202 }
1203 if (++trycnt == 2) {
1204 if (wizard)
1205 Strcat(qbuf, " [type a number, name, or ? for a menu]");
1206 else
1207 Strcat(qbuf, " [type a number or name]");
1208 }
1209 *buf = '\0'; /* EDIT_GETLIN: if we're on second or later pass,
1210 the previous input was invalid so don't use it
1211 as getlin()'s preloaded default answer */
1212 getlin(qbuf, buf);
1213 if (!strcmp(buf, "*")) {
1214 goto random_levtport;
1215 } else if (Confusion && rnl(5)) {
1216 pline("Oops...");
1217 goto random_levtport;
1218 } else if (!strcmp(buf, "\033")) { /* cancelled */
1219 return;
1220 }
1221 if (wizard && !strcmp(buf, "?")) {

Callers 4

level_tele_trapFunction · 0.85
arti_invokeFunction · 0.85
wiz_level_teleFunction · 0.85
seffect_teleportationFunction · 0.85

Calls 15

rn2Function · 0.85
dunlevs_in_dungeonFunction · 0.85
assign_levelFunction · 0.85
schedule_gotoFunction · 0.85
You_feelFunction · 0.85
getlinFunction · 0.85
rnlFunction · 0.85
print_dungeonFunction · 0.85
mksobjFunction · 0.85
addinvFunction · 0.85
prinvFunction · 0.85
lev_by_nameFunction · 0.85

Tested by

no test coverage detected