| 1162 | } |
| 1163 | |
| 1164 | void |
| 1165 | level_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, "?")) { |
no test coverage detected