OSDN Git Service

add translation
[jnethack/source.git] / src / cmd.c
1 /* NetHack 3.6  cmd.c   $NHDT-Date: 1446975462 2015/11/08 09:37:42 $  $NHDT-Branch: master $:$NHDT-Revision: 1.206 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10 #include "hack.h"
11 #include "func_tab.h"
12
13 #ifdef ALTMETA
14 STATIC_VAR boolean alt_esc = FALSE;
15 #endif
16
17 struct cmd Cmd = { 0 }; /* flag.h */
18
19 extern const char *hu_stat[];  /* hunger status from eat.c */
20 extern const char *enc_stat[]; /* encumbrance status from botl.c */
21
22 #ifdef UNIX
23 /*
24  * Some systems may have getchar() return EOF for various reasons, and
25  * we should not quit before seeing at least NR_OF_EOFS consecutive EOFs.
26  */
27 #if defined(SYSV) || defined(DGUX) || defined(HPUX)
28 #define NR_OF_EOFS 20
29 #endif
30 #endif
31
32 #define CMD_TRAVEL (char) 0x90
33 #define CMD_CLICKLOOK (char) 0x8F
34
35 #ifdef DEBUG
36 extern int NDECL(wiz_debug_cmd_bury);
37 extern int NDECL(wiz_debug_cmd_traveldisplay);
38 #endif
39
40 #ifdef DUMB /* stuff commented out in extern.h, but needed here */
41 extern int NDECL(doapply);            /**/
42 extern int NDECL(dorub);              /**/
43 extern int NDECL(dojump);             /**/
44 extern int NDECL(doextlist);          /**/
45 extern int NDECL(enter_explore_mode); /**/
46 extern int NDECL(dodrop);             /**/
47 extern int NDECL(doddrop);            /**/
48 extern int NDECL(dodown);             /**/
49 extern int NDECL(doup);               /**/
50 extern int NDECL(donull);             /**/
51 extern int NDECL(dowipe);             /**/
52 extern int NDECL(docallcnd);          /**/
53 extern int NDECL(dotakeoff);          /**/
54 extern int NDECL(doremring);          /**/
55 extern int NDECL(dowear);             /**/
56 extern int NDECL(doputon);            /**/
57 extern int NDECL(doddoremarm);        /**/
58 extern int NDECL(dokick);             /**/
59 extern int NDECL(dofire);             /**/
60 extern int NDECL(dothrow);            /**/
61 extern int NDECL(doeat);              /**/
62 extern int NDECL(done2);              /**/
63 extern int NDECL(vanquished);         /**/
64 extern int NDECL(doengrave);          /**/
65 extern int NDECL(dopickup);           /**/
66 extern int NDECL(ddoinv);             /**/
67 extern int NDECL(dotypeinv);          /**/
68 extern int NDECL(dolook);             /**/
69 extern int NDECL(doprgold);           /**/
70 extern int NDECL(doprwep);            /**/
71 extern int NDECL(doprarm);            /**/
72 extern int NDECL(doprring);           /**/
73 extern int NDECL(dopramulet);         /**/
74 extern int NDECL(doprtool);           /**/
75 extern int NDECL(dosuspend);          /**/
76 extern int NDECL(doforce);            /**/
77 extern int NDECL(doopen);             /**/
78 extern int NDECL(doclose);            /**/
79 extern int NDECL(dosh);               /**/
80 extern int NDECL(dodiscovered);       /**/
81 extern int NDECL(doclassdisco);       /**/
82 extern int NDECL(doset);              /**/
83 extern int NDECL(dotogglepickup);     /**/
84 extern int NDECL(dowhatis);           /**/
85 extern int NDECL(doquickwhatis);      /**/
86 extern int NDECL(dowhatdoes);         /**/
87 extern int NDECL(dohelp);             /**/
88 extern int NDECL(dohistory);          /**/
89 extern int NDECL(doloot);             /**/
90 extern int NDECL(dodrink);            /**/
91 extern int NDECL(dodip);              /**/
92 extern int NDECL(dosacrifice);        /**/
93 extern int NDECL(dopray);             /**/
94 extern int NDECL(dotip);              /**/
95 extern int NDECL(doturn);             /**/
96 extern int NDECL(doredraw);           /**/
97 extern int NDECL(doread);             /**/
98 extern int NDECL(dosave);             /**/
99 extern int NDECL(dosearch);           /**/
100 extern int NDECL(doidtrap);           /**/
101 extern int NDECL(dopay);              /**/
102 extern int NDECL(dosit);              /**/
103 extern int NDECL(dotalk);             /**/
104 extern int NDECL(docast);             /**/
105 extern int NDECL(dovspell);           /**/
106 extern int NDECL(dotele);             /**/
107 extern int NDECL(dountrap);           /**/
108 extern int NDECL(doversion);          /**/
109 extern int NDECL(doextversion);       /**/
110 extern int NDECL(doswapweapon);       /**/
111 extern int NDECL(dowield);            /**/
112 extern int NDECL(dowieldquiver);      /**/
113 extern int NDECL(dozap);              /**/
114 extern int NDECL(doorganize);         /**/
115 #endif                                /* DUMB */
116
117 static int NDECL(dosuspend_core); /**/
118
119 static int NDECL((*timed_occ_fn));
120
121 STATIC_PTR int NDECL(doprev_message);
122 STATIC_PTR int NDECL(timed_occupation);
123 STATIC_PTR int NDECL(doextcmd);
124 STATIC_PTR int NDECL(domonability);
125 STATIC_PTR int NDECL(dooverview_or_wiz_where);
126 STATIC_PTR int NDECL(dotravel);
127 STATIC_PTR int NDECL(doterrain);
128 STATIC_PTR int NDECL(wiz_wish);
129 STATIC_PTR int NDECL(wiz_identify);
130 STATIC_PTR int NDECL(wiz_map);
131 STATIC_PTR int NDECL(wiz_genesis);
132 STATIC_PTR int NDECL(wiz_where);
133 STATIC_PTR int NDECL(wiz_detect);
134 STATIC_PTR int NDECL(wiz_panic);
135 STATIC_PTR int NDECL(wiz_polyself);
136 STATIC_PTR int NDECL(wiz_level_tele);
137 STATIC_PTR int NDECL(wiz_level_change);
138 STATIC_PTR int NDECL(wiz_show_seenv);
139 STATIC_PTR int NDECL(wiz_show_vision);
140 STATIC_PTR int NDECL(wiz_smell);
141 STATIC_PTR int NDECL(wiz_mon_polycontrol);
142 STATIC_PTR int NDECL(wiz_show_wmodes);
143 STATIC_DCL void NDECL(wiz_map_levltyp);
144 STATIC_DCL void NDECL(wiz_levltyp_legend);
145 #if defined(__BORLANDC__) && !defined(_WIN32)
146 extern void FDECL(show_borlandc_stats, (winid));
147 #endif
148 #ifdef DEBUG_MIGRATING_MONS
149 STATIC_PTR int NDECL(wiz_migrate_mons);
150 #endif
151 STATIC_DCL int FDECL(size_monst, (struct monst *));
152 STATIC_DCL int FDECL(size_obj, (struct obj *));
153 STATIC_DCL void FDECL(count_obj, (struct obj *, long *, long *,
154                                   BOOLEAN_P, BOOLEAN_P));
155 STATIC_DCL void FDECL(obj_chain, (winid, const char *, struct obj *,
156                                   long *, long *));
157 STATIC_DCL void FDECL(mon_invent_chain, (winid, const char *, struct monst *,
158                                          long *, long *));
159 STATIC_DCL void FDECL(mon_chain, (winid, const char *, struct monst *,
160                                   long *, long *));
161 STATIC_DCL void FDECL(contained, (winid, const char *, long *, long *));
162 STATIC_PTR int NDECL(wiz_show_stats);
163 STATIC_DCL boolean FDECL(accept_menu_prefix, (int NDECL((*))));
164 #ifdef PORT_DEBUG
165 STATIC_DCL int NDECL(wiz_port_debug);
166 #endif
167 STATIC_PTR int NDECL(wiz_rumor_check);
168 STATIC_DCL char FDECL(cmd_from_func, (int NDECL((*))));
169 STATIC_PTR int NDECL(doattributes);
170 STATIC_PTR int NDECL(doconduct); /**/
171
172 STATIC_DCL void FDECL(enlght_line, (const char *, const char *, const char *,
173                                     const char *));
174 STATIC_DCL char *FDECL(enlght_combatinc, (const char *, int, int, char *));
175 STATIC_DCL void FDECL(enlght_halfdmg, (int, int));
176 STATIC_DCL boolean NDECL(walking_on_water);
177 STATIC_DCL boolean FDECL(cause_known, (int));
178 STATIC_DCL char *FDECL(attrval, (int, int, char *));
179 STATIC_DCL void FDECL(background_enlightenment, (int, int));
180 STATIC_DCL void FDECL(characteristics_enlightenment, (int, int));
181 STATIC_DCL void FDECL(one_characteristic, (int, int, int));
182 STATIC_DCL void FDECL(status_enlightenment, (int, int));
183 STATIC_DCL void FDECL(attributes_enlightenment, (int, int));
184
185 static const char *readchar_queue = "";
186 static coord clicklook_cc;
187
188 STATIC_DCL char *NDECL(parse);
189 STATIC_DCL boolean FDECL(help_dir, (CHAR_P, const char *));
190
191 STATIC_PTR int
192 doprev_message(VOID_ARGS)
193 {
194     return nh_doprev_message();
195 }
196
197 /* Count down by decrementing multi */
198 STATIC_PTR int
199 timed_occupation(VOID_ARGS)
200 {
201     (*timed_occ_fn)();
202     if (multi > 0)
203         multi--;
204     return multi > 0;
205 }
206
207 /* If you have moved since initially setting some occupations, they
208  * now shouldn't be able to restart.
209  *
210  * The basic rule is that if you are carrying it, you can continue
211  * since it is with you.  If you are acting on something at a distance,
212  * your orientation to it must have changed when you moved.
213  *
214  * The exception to this is taking off items, since they can be taken
215  * off in a number of ways in the intervening time, screwing up ordering.
216  *
217  *      Currently:      Take off all armor.
218  *                      Picking Locks / Forcing Chests.
219  *                      Setting traps.
220  */
221 void
222 reset_occupations()
223 {
224     reset_remarm();
225     reset_pick();
226     reset_trapset();
227 }
228
229 /* If a time is given, use it to timeout this function, otherwise the
230  * function times out by its own means.
231  */
232 void
233 set_occupation(fn, txt, xtime)
234 int NDECL((*fn));
235 const char *txt;
236 int xtime;
237 {
238     if (xtime) {
239         occupation = timed_occupation;
240         timed_occ_fn = fn;
241     } else
242         occupation = fn;
243     occtxt = txt;
244     occtime = 0;
245     return;
246 }
247
248 STATIC_DCL char NDECL(popch);
249
250 /* Provide a means to redo the last command.  The flag `in_doagain' is set
251  * to true while redoing the command.  This flag is tested in commands that
252  * require additional input (like `throw' which requires a thing and a
253  * direction), and the input prompt is not shown.  Also, while in_doagain is
254  * TRUE, no keystrokes can be saved into the saveq.
255  */
256 #define BSIZE 20
257 static char pushq[BSIZE], saveq[BSIZE];
258 static NEARDATA int phead, ptail, shead, stail;
259
260 STATIC_OVL char
261 popch()
262 {
263     /* If occupied, return '\0', letting tgetch know a character should
264      * be read from the keyboard.  If the character read is not the
265      * ABORT character (as checked in pcmain.c), that character will be
266      * pushed back on the pushq.
267      */
268     if (occupation)
269         return '\0';
270     if (in_doagain)
271         return (char) ((shead != stail) ? saveq[stail++] : '\0');
272     else
273         return (char) ((phead != ptail) ? pushq[ptail++] : '\0');
274 }
275
276 char
277 pgetchar() /* courtesy of aeb@cwi.nl */
278 {
279     register int ch;
280
281     if (!(ch = popch()))
282         ch = nhgetch();
283     return (char) ch;
284 }
285
286 /* A ch == 0 resets the pushq */
287 void
288 pushch(ch)
289 char ch;
290 {
291     if (!ch)
292         phead = ptail = 0;
293     if (phead < BSIZE)
294         pushq[phead++] = ch;
295     return;
296 }
297
298 /* A ch == 0 resets the saveq.  Only save keystrokes when not
299  * replaying a previous command.
300  */
301 void
302 savech(ch)
303 char ch;
304 {
305     if (!in_doagain) {
306         if (!ch)
307             phead = ptail = shead = stail = 0;
308         else if (shead < BSIZE)
309             saveq[shead++] = ch;
310     }
311     return;
312 }
313
314 /* here after # - now read a full-word command */
315 STATIC_PTR int
316 doextcmd(VOID_ARGS)
317 {
318     int idx, retval;
319     int NDECL((*func));
320
321     /* keep repeating until we don't run help or quit */
322     do {
323         idx = get_ext_cmd();
324         if (idx < 0)
325             return 0; /* quit */
326
327         func = extcmdlist[idx].ef_funct;
328         if (iflags.menu_requested && !accept_menu_prefix(func)) {
329 /*JP
330             pline("'m' prefix has no effect for this command.");
331 */
332             pline("'m'\90Ú\93ª\8e«\82Í\82±\82Ì\83R\83}\83\93\83h\82É\82Í\96³\8cø\81D");
333             iflags.menu_requested = FALSE;
334         }
335         retval = (*func)();
336     } while (func == doextlist);
337
338     return retval;
339 }
340
341 /* here after #? - now list all full-word commands */
342 int
343 doextlist(VOID_ARGS)
344 {
345     register const struct ext_func_tab *efp;
346     char buf[BUFSZ];
347     winid datawin;
348
349     datawin = create_nhwindow(NHW_TEXT);
350     putstr(datawin, 0, "");
351 /*JP
352     putstr(datawin, 0, "            Extended Commands List");
353 */
354     putstr(datawin, 0, "            \8ag\92£\83R\83}\83\93\83h\88ê\97\97");
355     putstr(datawin, 0, "");
356 /*JP
357     putstr(datawin, 0, "    Press '#', then type:");
358 */
359     putstr(datawin, 0, "    '#'\82ð\89\9f\82µ\82½\82 \82Æ\83^\83C\83v\82¹\82æ:");
360     putstr(datawin, 0, "");
361
362     for (efp = extcmdlist; efp->ef_txt; efp++) {
363         Sprintf(buf, "    %-15s - %s.", efp->ef_txt, efp->ef_desc);
364         putstr(datawin, 0, buf);
365     }
366     display_nhwindow(datawin, FALSE);
367     destroy_nhwindow(datawin);
368     return 0;
369 }
370
371 #ifdef TTY_GRAPHICS
372 #define MAX_EXT_CMD 50 /* Change if we ever have > 50 ext cmds */
373
374 /*
375  * This is currently used only by the tty port and is
376  * controlled via runtime option 'extmenu'.
377  * ``# ?'' is counted towards the limit of the number of commands,
378  * so we actually support MAX_EXT_CMD-1 "real" extended commands.
379  *
380  * Here after # - now show pick-list of possible commands.
381  */
382 int
383 extcmd_via_menu()
384 {
385     const struct ext_func_tab *efp;
386     menu_item *pick_list = (menu_item *) 0;
387     winid win;
388     anything any;
389     const struct ext_func_tab *choices[MAX_EXT_CMD + 1];
390     char buf[BUFSZ];
391     char cbuf[QBUFSZ], prompt[QBUFSZ], fmtstr[20];
392     int i, n, nchoices, acount;
393     int ret, biggest;
394     int accelerator, prevaccelerator;
395     int matchlevel = 0;
396
397     ret = 0;
398     cbuf[0] = '\0';
399     biggest = 0;
400     while (!ret) {
401         i = n = 0;
402         any = zeroany;
403         /* populate choices */
404         for (efp = extcmdlist; efp->ef_txt; efp++) {
405             if (!matchlevel || !strncmp(efp->ef_txt, cbuf, matchlevel)) {
406                 choices[i] = efp;
407                 if ((int) strlen(efp->ef_desc) > biggest) {
408                     biggest = strlen(efp->ef_desc);
409                     Sprintf(fmtstr, "%%-%ds", biggest + 15);
410                 }
411                 if (++i > MAX_EXT_CMD) {
412 #if defined(BETA)
413                     impossible(
414       "Exceeded %d extended commands in doextcmd() menu; 'extmenu' disabled.",
415                                MAX_EXT_CMD);
416 #endif /* BETA */
417                     iflags.extmenu = 0;
418                     return -1;
419                 }
420             }
421         }
422         choices[i] = (struct ext_func_tab *) 0;
423         nchoices = i;
424         /* if we're down to one, we have our selection so get out of here */
425         if (nchoices == 1) {
426             for (i = 0; extcmdlist[i].ef_txt != (char *) 0; i++)
427                 if (!strncmpi(extcmdlist[i].ef_txt, cbuf, matchlevel)) {
428                     ret = i;
429                     break;
430                 }
431             break;
432         }
433
434         /* otherwise... */
435         win = create_nhwindow(NHW_MENU);
436         start_menu(win);
437         accelerator = prevaccelerator = 0;
438         acount = 0;
439         for (i = 0; choices[i]; ++i) {
440             accelerator = choices[i]->ef_txt[matchlevel];
441             if (accelerator != prevaccelerator || nchoices < (ROWNO - 3)) {
442                 if (acount) {
443                     /* flush extended cmds for that letter already in buf */
444                     Sprintf(buf, fmtstr, prompt);
445                     any.a_char = prevaccelerator;
446                     add_menu(win, NO_GLYPH, &any, any.a_char, 0, ATR_NONE,
447                              buf, FALSE);
448                     acount = 0;
449                 }
450             }
451             prevaccelerator = accelerator;
452             if (!acount || nchoices < (ROWNO - 3)) {
453                 Sprintf(prompt, "%s [%s]", choices[i]->ef_txt,
454                         choices[i]->ef_desc);
455             } else if (acount == 1) {
456 /*JP
457                 Sprintf(prompt, "%s or %s", choices[i - 1]->ef_txt,
458 */
459                 Sprintf(prompt, "%s \82Ü\82½\82Í %s", choices[i-1]->ef_txt,
460                         choices[i]->ef_txt);
461             } else {
462 /*JP
463                 Strcat(prompt, " or ");
464 */
465                 Strcat(prompt," \82Ü\82½\82Í ");
466                 Strcat(prompt, choices[i]->ef_txt);
467             }
468             ++acount;
469         }
470         if (acount) {
471             /* flush buf */
472             Sprintf(buf, fmtstr, prompt);
473             any.a_char = prevaccelerator;
474             add_menu(win, NO_GLYPH, &any, any.a_char, 0, ATR_NONE, buf,
475                      FALSE);
476         }
477 /*JP
478         Sprintf(prompt, "Extended Command: %s", cbuf);
479 */
480         Sprintf(prompt, "\8ag\92£\83R\83}\83\93\83h: %s", cbuf);
481         end_menu(win, prompt);
482         n = select_menu(win, PICK_ONE, &pick_list);
483         destroy_nhwindow(win);
484         if (n == 1) {
485             if (matchlevel > (QBUFSZ - 2)) {
486                 free((genericptr_t) pick_list);
487 #if defined(BETA)
488                 impossible("Too many chars (%d) entered in extcmd_via_menu()",
489                            matchlevel);
490 #endif
491                 ret = -1;
492             } else {
493                 cbuf[matchlevel++] = pick_list[0].item.a_char;
494                 cbuf[matchlevel] = '\0';
495                 free((genericptr_t) pick_list);
496             }
497         } else {
498             if (matchlevel) {
499                 ret = 0;
500                 matchlevel = 0;
501             } else
502                 ret = -1;
503         }
504     }
505     return ret;
506 }
507 #endif /* TTY_GRAPHICS */
508
509 /* #monster command - use special monster ability while polymorphed */
510 STATIC_PTR int
511 domonability(VOID_ARGS)
512 {
513     if (can_breathe(youmonst.data))
514         return dobreathe();
515     else if (attacktype(youmonst.data, AT_SPIT))
516         return dospit();
517     else if (youmonst.data->mlet == S_NYMPH)
518         return doremove();
519     else if (attacktype(youmonst.data, AT_GAZE))
520         return dogaze();
521     else if (is_were(youmonst.data))
522         return dosummon();
523     else if (webmaker(youmonst.data))
524         return dospinweb();
525     else if (is_hider(youmonst.data))
526         return dohide();
527     else if (is_mind_flayer(youmonst.data))
528         return domindblast();
529     else if (u.umonnum == PM_GREMLIN) {
530         if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
531             if (split_mon(&youmonst, (struct monst *) 0))
532                 dryup(u.ux, u.uy, TRUE);
533         } else
534 /*JP
535             There("is no fountain here.");
536 */
537             pline("\82±\82±\82É\82Í\90ò\82Í\82È\82¢\81D");
538     } else if (is_unicorn(youmonst.data)) {
539         use_unicorn_horn((struct obj *) 0);
540         return 1;
541     } else if (youmonst.data->msound == MS_SHRIEK) {
542 /*JP
543         You("shriek.");
544 */
545         You("\8bà\90Ø\82è\90º\82ð\82 \82°\82½\81D");
546         if (u.uburied)
547 /*JP
548             pline("Unfortunately sound does not carry well through rock.");
549 */
550             pline("\8ec\94O\82È\82ª\82ç\89¹\82Í\8aâ\82ð\82¤\82Ü\82­\93`\82í\82ç\82È\82¢\81D");
551         else
552             aggravate();
553     } else if (youmonst.data->mlet == S_VAMPIRE)
554         return dopoly();
555     else if (Upolyd)
556 /*JP
557         pline("Any special ability you may have is purely reflexive.");
558 */
559         pline("\82 \82È\82½\82Ì\8e\9d\82Á\82Ä\82¢\82é\93Á\8eê\94\\97Í\82Í\82Ç\82ê\82à\8eó\93®\93I\82¾\81D");
560     else
561 /*JP
562         You("don't have a special ability in your normal form!");
563 */
564         You("\95\81\92i\82Ì\8ep\82Å\82Ì\93Á\8eê\94\\97Í\82ð\8e\9d\82Á\82Ä\82¢\82È\82¢\81I");
565     return 0;
566 }
567
568 int
569 enter_explore_mode(VOID_ARGS)
570 {
571     if (wizard) {
572 /*JP
573         You("are in debug mode.");
574 */
575         You("\82·\82Å\82É\83f\83o\83b\83O\83\82\81[\83h\82¾\81D");
576     } else if (discover) {
577 /*JP
578         You("are already in explore mode.");
579 */
580         You("\82·\82Å\82É\92T\8c\9f\83\82\81[\83h\82¾\81D");
581     } else {
582 #ifdef SYSCF
583 #if defined(UNIX)
584         if (!sysopt.explorers || !sysopt.explorers[0]
585             || !check_user_string(sysopt.explorers)) {
586 /*JP
587             You("cannot access explore mode.");
588 */
589             You("\92T\8c\9f\83\82\81[\83h\82É\83A\83N\83Z\83X\82Å\82«\82È\82¢\81D");
590             return 0;
591         }
592 #endif
593 #endif
594         pline(
595 /*JP
596         "Beware!  From explore mode there will be no return to normal game.");
597 */
598         "\8cx\8d\90\81I\94­\8c©\83\82\81[\83h\82É\93ü\82Á\82½\82ç\92Ê\8fí\83\82\81[\83h\82É\82Í\96ß\82ê\82È\82¢\81D");
599         if (paranoid_query(ParanoidQuit,
600 /*JP
601                            "Do you want to enter explore mode?")) {
602 */
603                            "\94­\8c©\83\82\81[\83h\82É\88Ú\82è\82Ü\82·\82©\81H")) {
604             clear_nhwindow(WIN_MESSAGE);
605 /*JP
606             You("are now in non-scoring explore mode.");
607 */
608             You("\83X\83R\83A\82ª\82Ì\82ç\82È\82¢\94­\8c©\83\82\81[\83h\82É\88Ú\8ds\82µ\82½\81D");
609             discover = TRUE;
610         } else {
611             clear_nhwindow(WIN_MESSAGE);
612 /*JP
613             pline("Resuming normal game.");
614 */
615             pline("\92Ê\8fí\83\82\81[\83h\82ð\91±\82¯\82é\81D");
616         }
617     }
618     return 0;
619 }
620
621 STATIC_PTR int
622 dooverview_or_wiz_where(VOID_ARGS)
623 {
624     if (wizard)
625         return wiz_where();
626     else
627         dooverview();
628     return 0;
629 }
630
631 /* ^W command - wish for something */
632 STATIC_PTR int
633 wiz_wish(VOID_ARGS) /* Unlimited wishes for debug mode by Paul Polderman */
634 {
635     if (wizard) {
636         boolean save_verbose = flags.verbose;
637
638         flags.verbose = FALSE;
639         makewish();
640         flags.verbose = save_verbose;
641         (void) encumber_msg();
642     } else
643 /*JP
644         pline("Unavailable command '%s'.",
645 */
646         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
647               visctrl((int) cmd_from_func(wiz_wish)));
648     return 0;
649 }
650
651 /* ^I command - reveal and optionally identify hero's inventory */
652 STATIC_PTR int
653 wiz_identify(VOID_ARGS)
654 {
655     if (wizard) {
656         iflags.override_ID = (int) cmd_from_func(wiz_identify);
657         if (display_inventory((char *) 0, TRUE) == -1)
658             identify_pack(0, FALSE);
659         iflags.override_ID = 0;
660     } else
661 /*JP
662         pline("Unavailable command '%s'.",
663 */
664         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
665               visctrl((int) cmd_from_func(wiz_identify)));
666     return 0;
667 }
668
669 /* ^F command - reveal the level map and any traps on it */
670 STATIC_PTR int
671 wiz_map(VOID_ARGS)
672 {
673     if (wizard) {
674         struct trap *t;
675         long save_Hconf = HConfusion, save_Hhallu = HHallucination;
676
677         HConfusion = HHallucination = 0L;
678         for (t = ftrap; t != 0; t = t->ntrap) {
679             t->tseen = 1;
680             map_trap(t, TRUE);
681         }
682         do_mapping();
683         HConfusion = save_Hconf;
684         HHallucination = save_Hhallu;
685     } else
686 /*JP
687         pline("Unavailable command '%s'.",
688 */
689         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
690               visctrl((int) cmd_from_func(wiz_map)));
691     return 0;
692 }
693
694 /* ^G command - generate monster(s); a count prefix will be honored */
695 STATIC_PTR int
696 wiz_genesis(VOID_ARGS)
697 {
698     if (wizard)
699         (void) create_particular();
700     else
701 /*JP
702         pline("Unavailable command '%s'.",
703 */
704         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
705               visctrl((int) cmd_from_func(wiz_genesis)));
706     return 0;
707 }
708
709 /* ^O command - display dungeon layout */
710 STATIC_PTR int
711 wiz_where(VOID_ARGS)
712 {
713     if (wizard)
714         (void) print_dungeon(FALSE, (schar *) 0, (xchar *) 0);
715     else
716 /*JP
717         pline("Unavailable command '%s'.",
718 */
719         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
720               visctrl((int) cmd_from_func(wiz_where)));
721     return 0;
722 }
723
724 /* ^E command - detect unseen (secret doors, traps, hidden monsters) */
725 STATIC_PTR int
726 wiz_detect(VOID_ARGS)
727 {
728     if (wizard)
729         (void) findit();
730     else
731 /*JP
732         pline("Unavailable command '%s'.",
733 */
734         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
735               visctrl((int) cmd_from_func(wiz_detect)));
736     return 0;
737 }
738
739 /* ^V command - level teleport */
740 STATIC_PTR int
741 wiz_level_tele(VOID_ARGS)
742 {
743     if (wizard)
744         level_tele();
745     else
746 /*JP
747         pline("Unavailable command '%s'.",
748 */
749         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
750               visctrl((int) cmd_from_func(wiz_level_tele)));
751     return 0;
752 }
753
754 /* #monpolycontrol command - choose new form for shapechangers, polymorphees */
755 STATIC_PTR int
756 wiz_mon_polycontrol(VOID_ARGS)
757 {
758     iflags.mon_polycontrol = !iflags.mon_polycontrol;
759 #if 0 /*JP*/
760     pline("Monster polymorph control is %s.",
761           iflags.mon_polycontrol ? "on" : "off");
762 #else
763     pline("\89ö\95¨\82Ì\95Ï\89»\90§\8cä: %s",
764           iflags.mon_polycontrol ? "\83I\83\93" : "\83I\83t");
765 #endif
766     return 0;
767 }
768
769 /* #levelchange command - adjust hero's experience level */
770 STATIC_PTR int
771 wiz_level_change(VOID_ARGS)
772 {
773     char buf[BUFSZ];
774     int newlevel;
775     int ret;
776
777 /*JP
778     getlin("To what experience level do you want to be set?", buf);
779 */
780     getlin("\8co\8c±\83\8c\83x\83\8b\82ð\82¢\82­\82Â\82É\90Ý\92è\82µ\82Ü\82·\82©\81H", buf);
781     (void) mungspaces(buf);
782     if (buf[0] == '\033' || buf[0] == '\0')
783         ret = 0;
784     else
785         ret = sscanf(buf, "%d", &newlevel);
786
787     if (ret != 1) {
788         pline1(Never_mind);
789         return 0;
790     }
791     if (newlevel == u.ulevel) {
792 /*JP
793         You("are already that experienced.");
794 */
795         You("\82·\82Å\82É\82»\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
796     } else if (newlevel < u.ulevel) {
797         if (u.ulevel == 1) {
798 /*JP
799             You("are already as inexperienced as you can get.");
800 */
801             You("\82·\82Å\82É\89Â\94\\82È\8cÀ\82è\82Ì\8dÅ\92á\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
802             return 0;
803         }
804         if (newlevel < 1)
805             newlevel = 1;
806         while (u.ulevel > newlevel)
807 /*JP
808             losexp("#levelchange");
809 */
810             losexp("#levelchange\83R\83}\83\93\83h\82Å");
811     } else {
812         if (u.ulevel >= MAXULEV) {
813 /*JP
814             You("are already as experienced as you can get.");
815 */
816             You("\82·\82Å\82É\89Â\94\\82È\8cÀ\82è\82Ì\8dÅ\91å\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
817             return 0;
818         }
819         if (newlevel > MAXULEV)
820             newlevel = MAXULEV;
821         while (u.ulevel < newlevel)
822             pluslvl(FALSE);
823     }
824     u.ulevelmax = u.ulevel;
825     return 0;
826 }
827
828 /* #panic command - test program's panic handling */
829 STATIC_PTR int
830 wiz_panic(VOID_ARGS)
831 {
832 /*JP
833     if (yn("Do you want to call panic() and end your game?") == 'y')
834 */
835     if (yn("panic()\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82µ\82Ä\83Q\81[\83\80\82ð\8fI\97¹\82³\82¹\82Ü\82·\82©\81H") == 'y')
836         panic("Crash test.");
837     return 0;
838 }
839
840 /* #polyself command - change hero's form */
841 STATIC_PTR int
842 wiz_polyself(VOID_ARGS)
843 {
844     polyself(1);
845     return 0;
846 }
847
848 /* #seenv command */
849 STATIC_PTR int
850 wiz_show_seenv(VOID_ARGS)
851 {
852     winid win;
853     int x, y, v, startx, stopx, curx;
854     char row[COLNO + 1];
855
856     win = create_nhwindow(NHW_TEXT);
857     /*
858      * Each seenv description takes up 2 characters, so center
859      * the seenv display around the hero.
860      */
861     startx = max(1, u.ux - (COLNO / 4));
862     stopx = min(startx + (COLNO / 2), COLNO);
863     /* can't have a line exactly 80 chars long */
864     if (stopx - startx == COLNO / 2)
865         startx++;
866
867     for (y = 0; y < ROWNO; y++) {
868         for (x = startx, curx = 0; x < stopx; x++, curx += 2) {
869             if (x == u.ux && y == u.uy) {
870                 row[curx] = row[curx + 1] = '@';
871             } else {
872                 v = levl[x][y].seenv & 0xff;
873                 if (v == 0)
874                     row[curx] = row[curx + 1] = ' ';
875                 else
876                     Sprintf(&row[curx], "%02x", v);
877             }
878         }
879         /* remove trailing spaces */
880         for (x = curx - 1; x >= 0; x--)
881             if (row[x] != ' ')
882                 break;
883         row[x + 1] = '\0';
884
885         putstr(win, 0, row);
886     }
887     display_nhwindow(win, TRUE);
888     destroy_nhwindow(win);
889     return 0;
890 }
891
892 /* #vision command */
893 STATIC_PTR int
894 wiz_show_vision(VOID_ARGS)
895 {
896     winid win;
897     int x, y, v;
898     char row[COLNO + 1];
899
900     win = create_nhwindow(NHW_TEXT);
901     Sprintf(row, "Flags: 0x%x could see, 0x%x in sight, 0x%x temp lit",
902             COULD_SEE, IN_SIGHT, TEMP_LIT);
903     putstr(win, 0, row);
904     putstr(win, 0, "");
905     for (y = 0; y < ROWNO; y++) {
906         for (x = 1; x < COLNO; x++) {
907             if (x == u.ux && y == u.uy)
908                 row[x] = '@';
909             else {
910                 v = viz_array[y][x]; /* data access should be hidden */
911                 if (v == 0)
912                     row[x] = ' ';
913                 else
914                     row[x] = '0' + viz_array[y][x];
915             }
916         }
917         /* remove trailing spaces */
918         for (x = COLNO - 1; x >= 1; x--)
919             if (row[x] != ' ')
920                 break;
921         row[x + 1] = '\0';
922
923         putstr(win, 0, &row[1]);
924     }
925     display_nhwindow(win, TRUE);
926     destroy_nhwindow(win);
927     return 0;
928 }
929
930 /* #wmode command */
931 STATIC_PTR int
932 wiz_show_wmodes(VOID_ARGS)
933 {
934     winid win;
935     int x, y;
936     char row[COLNO + 1];
937     struct rm *lev;
938     boolean istty = !strcmp(windowprocs.name, "tty");
939
940     win = create_nhwindow(NHW_TEXT);
941     if (istty)
942         putstr(win, 0, ""); /* tty only: blank top line */
943     for (y = 0; y < ROWNO; y++) {
944         for (x = 0; x < COLNO; x++) {
945             lev = &levl[x][y];
946             if (x == u.ux && y == u.uy)
947                 row[x] = '@';
948             else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
949                 row[x] = '0' + (lev->wall_info & WM_MASK);
950             else if (lev->typ == CORR)
951                 row[x] = '#';
952             else if (IS_ROOM(lev->typ) || IS_DOOR(lev->typ))
953                 row[x] = '.';
954             else
955                 row[x] = 'x';
956         }
957         row[COLNO] = '\0';
958         /* map column 0, levl[0][], is off the left edge of the screen */
959         putstr(win, 0, &row[1]);
960     }
961     display_nhwindow(win, TRUE);
962     destroy_nhwindow(win);
963     return 0;
964 }
965
966 /* wizard mode variant of #terrain; internal levl[][].typ values in base-36 */
967 STATIC_OVL void
968 wiz_map_levltyp(VOID_ARGS)
969 {
970     winid win;
971     int x, y, terrain;
972     char row[COLNO + 1];
973     boolean istty = !strcmp(windowprocs.name, "tty");
974
975     win = create_nhwindow(NHW_TEXT);
976     /* map row 0, levl[][0], is drawn on the second line of tty screen */
977     if (istty)
978         putstr(win, 0, ""); /* tty only: blank top line */
979     for (y = 0; y < ROWNO; y++) {
980         /* map column 0, levl[0][], is off the left edge of the screen;
981            it should always have terrain type "undiggable stone" */
982         for (x = 1; x < COLNO; x++) {
983             terrain = levl[x][y].typ;
984             /* assumes there aren't more than 10+26+26 terrain types */
985             row[x - 1] = (char) ((terrain == 0 && !may_dig(x, y))
986                                     ? '*'
987                                     : (terrain < 10)
988                                        ? '0' + terrain
989                                        : (terrain < 36)
990                                           ? 'a' + terrain - 10
991                                           : 'A' + terrain - 36);
992         }
993         if (levl[0][y].typ != 0 || may_dig(0, y))
994             row[x++] = '!';
995         row[x] = '\0';
996         putstr(win, 0, row);
997     }
998
999     {
1000         char dsc[BUFSZ];
1001         s_level *slev = Is_special(&u.uz);
1002
1003         Sprintf(dsc, "D:%d,L:%d", u.uz.dnum, u.uz.dlevel);
1004         /* [dungeon branch features currently omitted] */
1005         /* special level features */
1006         if (slev) {
1007             Sprintf(eos(dsc), " \"%s\"", slev->proto);
1008             /* special level flags (note: dungeon.def doesn't set `maze'
1009                or `hell' for any specific levels so those never show up) */
1010             if (slev->flags.maze_like)
1011                 Strcat(dsc, " mazelike");
1012             if (slev->flags.hellish)
1013                 Strcat(dsc, " hellish");
1014             if (slev->flags.town)
1015                 Strcat(dsc, " town");
1016             if (slev->flags.rogue_like)
1017                 Strcat(dsc, " roguelike");
1018             /* alignment currently omitted to save space */
1019         }
1020         /* level features */
1021         if (level.flags.nfountains)
1022             Sprintf(eos(dsc), " %c:%d", defsyms[S_fountain].sym,
1023                     (int) level.flags.nfountains);
1024         if (level.flags.nsinks)
1025             Sprintf(eos(dsc), " %c:%d", defsyms[S_sink].sym,
1026                     (int) level.flags.nsinks);
1027         if (level.flags.has_vault)
1028             Strcat(dsc, " vault");
1029         if (level.flags.has_shop)
1030             Strcat(dsc, " shop");
1031         if (level.flags.has_temple)
1032             Strcat(dsc, " temple");
1033         if (level.flags.has_court)
1034             Strcat(dsc, " throne");
1035         if (level.flags.has_zoo)
1036             Strcat(dsc, " zoo");
1037         if (level.flags.has_morgue)
1038             Strcat(dsc, " morgue");
1039         if (level.flags.has_barracks)
1040             Strcat(dsc, " barracks");
1041         if (level.flags.has_beehive)
1042             Strcat(dsc, " hive");
1043         if (level.flags.has_swamp)
1044             Strcat(dsc, " swamp");
1045         /* level flags */
1046         if (level.flags.noteleport)
1047             Strcat(dsc, " noTport");
1048         if (level.flags.hardfloor)
1049             Strcat(dsc, " noDig");
1050         if (level.flags.nommap)
1051             Strcat(dsc, " noMMap");
1052         if (!level.flags.hero_memory)
1053             Strcat(dsc, " noMem");
1054         if (level.flags.shortsighted)
1055             Strcat(dsc, " shortsight");
1056         if (level.flags.graveyard)
1057             Strcat(dsc, " graveyard");
1058         if (level.flags.is_maze_lev)
1059             Strcat(dsc, " maze");
1060         if (level.flags.is_cavernous_lev)
1061             Strcat(dsc, " cave");
1062         if (level.flags.arboreal)
1063             Strcat(dsc, " tree");
1064         if (Sokoban)
1065             Strcat(dsc, " sokoban-rules");
1066         /* non-flag info; probably should include dungeon branching
1067            checks (extra stairs and magic portals) here */
1068         if (Invocation_lev(&u.uz))
1069             Strcat(dsc, " invoke");
1070         if (On_W_tower_level(&u.uz))
1071             Strcat(dsc, " tower");
1072         /* append a branch identifier for completeness' sake */
1073         if (u.uz.dnum == 0)
1074             Strcat(dsc, " dungeon");
1075         else if (u.uz.dnum == mines_dnum)
1076             Strcat(dsc, " mines");
1077         else if (In_sokoban(&u.uz))
1078             Strcat(dsc, " sokoban");
1079         else if (u.uz.dnum == quest_dnum)
1080             Strcat(dsc, " quest");
1081         else if (Is_knox(&u.uz))
1082             Strcat(dsc, " ludios");
1083         else if (u.uz.dnum == 1)
1084             Strcat(dsc, " gehennom");
1085         else if (u.uz.dnum == tower_dnum)
1086             Strcat(dsc, " vlad");
1087         else if (In_endgame(&u.uz))
1088             Strcat(dsc, " endgame");
1089         else {
1090             /* somebody's added a dungeon branch we're not expecting */
1091             const char *brname = dungeons[u.uz.dnum].dname;
1092
1093             if (!brname || !*brname)
1094                 brname = "unknown";
1095             if (!strncmpi(brname, "the ", 4))
1096                 brname += 4;
1097             Sprintf(eos(dsc), " %s", brname);
1098         }
1099         /* limit the line length to map width */
1100         if (strlen(dsc) >= COLNO)
1101             dsc[COLNO - 1] = '\0'; /* truncate */
1102         putstr(win, 0, dsc);
1103     }
1104
1105     display_nhwindow(win, TRUE);
1106     destroy_nhwindow(win);
1107     return;
1108 }
1109
1110 /* temporary? hack, since level type codes aren't the same as screen
1111    symbols and only the latter have easily accessible descriptions */
1112 static const char *levltyp[] = {
1113     "stone", "vertical wall", "horizontal wall", "top-left corner wall",
1114     "top-right corner wall", "bottom-left corner wall",
1115     "bottom-right corner wall", "cross wall", "tee-up wall", "tee-down wall",
1116     "tee-left wall", "tee-right wall", "drawbridge wall", "tree",
1117     "secret door", "secret corridor", "pool", "moat", "water",
1118     "drawbridge up", "lava pool", "iron bars", "door", "corridor", "room",
1119     "stairs", "ladder", "fountain", "throne", "sink", "grave", "altar", "ice",
1120     "drawbridge down", "air", "cloud",
1121     /* not a real terrain type, but used for undiggable stone
1122        by wiz_map_levltyp() */
1123     "unreachable/undiggable",
1124     /* padding in case the number of entries above is odd */
1125     ""
1126 };
1127
1128 /* explanation of base-36 output from wiz_map_levltyp() */
1129 STATIC_OVL void
1130 wiz_levltyp_legend(VOID_ARGS)
1131 {
1132     winid win;
1133     int i, j, last, c;
1134     const char *dsc, *fmt;
1135     char buf[BUFSZ];
1136
1137     win = create_nhwindow(NHW_TEXT);
1138     putstr(win, 0, "#terrain encodings:");
1139     putstr(win, 0, "");
1140     fmt = " %c - %-28s"; /* TODO: include tab-separated variant for win32 */
1141     *buf = '\0';
1142     /* output in pairs, left hand column holds [0],[1],...,[N/2-1]
1143        and right hand column holds [N/2],[N/2+1],...,[N-1];
1144        N ('last') will always be even, and may or may not include
1145        the empty string entry to pad out the final pair, depending
1146        upon how many other entries are present in levltyp[] */
1147     last = SIZE(levltyp) & ~1;
1148     for (i = 0; i < last / 2; ++i)
1149         for (j = i; j < last; j += last / 2) {
1150             dsc = levltyp[j];
1151             c = !*dsc ? ' '
1152                    : !strncmp(dsc, "unreachable", 11) ? '*'
1153                       /* same int-to-char conversion as wiz_map_levltyp() */
1154                       : (j < 10) ? '0' + j
1155                          : (j < 36) ? 'a' + j - 10
1156                             : 'A' + j - 36;
1157             Sprintf(eos(buf), fmt, c, dsc);
1158             if (j > i) {
1159                 putstr(win, 0, buf);
1160                 *buf = '\0';
1161             }
1162         }
1163     display_nhwindow(win, TRUE);
1164     destroy_nhwindow(win);
1165     return;
1166 }
1167
1168 /* #wizsmell command - test usmellmon(). */
1169 STATIC_PTR int
1170 wiz_smell(VOID_ARGS)
1171 {
1172     int ans = 0;
1173     int mndx;  /* monster index */
1174     coord cc;  /* screen pos of unknown glyph */
1175     int glyph; /* glyph at selected position */
1176
1177     cc.x = u.ux;
1178     cc.y = u.uy;
1179     mndx = 0; /* gcc -Wall lint */
1180     if (!olfaction(youmonst.data)) {
1181         You("are incapable of detecting odors in your present form.");
1182         return 0;
1183     }
1184
1185     pline("You can move the cursor to a monster that you want to smell.");
1186     do {
1187         pline("Pick a monster to smell.");
1188         ans = getpos(&cc, TRUE, "a monster");
1189         if (ans < 0 || cc.x < 0) {
1190             return 0; /* done */
1191         }
1192         /* Convert the glyph at the selected position to a mndxbol. */
1193         glyph = glyph_at(cc.x, cc.y);
1194         if (glyph_is_monster(glyph))
1195             mndx = glyph_to_mon(glyph);
1196         else
1197             mndx = 0;
1198         /* Is it a monster? */
1199         if (mndx) {
1200             if (!usmellmon(&mons[mndx]))
1201                 pline("That monster seems to give off no smell.");
1202         } else
1203             pline("That is not a monster.");
1204     } while (TRUE);
1205     return 0;
1206 }
1207
1208 /* #wizrumorcheck command - verify each rumor access */
1209 STATIC_PTR int
1210 wiz_rumor_check(VOID_ARGS)
1211 {
1212     rumor_check();
1213     return 0;
1214 }
1215
1216 /* #terrain command -- show known map, inspired by crawl's '|' command */
1217 STATIC_PTR int
1218 doterrain(VOID_ARGS)
1219 {
1220     winid men;
1221     menu_item *sel;
1222     anything any;
1223     int n;
1224     int which;
1225
1226     /*
1227      * normal play: choose between known map without mons, obj, and traps
1228      *  (to see underlying terrain only), or
1229      *  known map without mons and objs (to see traps under mons and objs), or
1230      *  known map without mons (to see objects under monsters);
1231      * explore mode: normal choices plus full map (w/o mons, objs, traps);
1232      * wizard mode: normal and explore choices plus
1233      *  a dump of the internal levl[][].typ codes w/ level flags, or
1234      *  a legend for the levl[][].typ codes dump
1235      */
1236     men = create_nhwindow(NHW_MENU);
1237     any = zeroany;
1238     any.a_int = 1;
1239     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1240              "known map without monsters, objects, and traps",
1241              MENU_SELECTED);
1242     any.a_int = 2;
1243     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1244              "known map without monsters and objects",
1245              MENU_UNSELECTED);
1246     any.a_int = 3;
1247     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1248              "known map without monsters",
1249              MENU_UNSELECTED);
1250     if (discover || wizard) {
1251         any.a_int = 4;
1252         add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1253                  "full map without monsters, objects, and traps",
1254                  MENU_UNSELECTED);
1255         if (wizard) {
1256             any.a_int = 5;
1257             add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1258                      "internal levl[][].typ codes in base-36",
1259                      MENU_UNSELECTED);
1260             any.a_int = 6;
1261             add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1262                      "legend of base-36 levl[][].typ codes",
1263                      MENU_UNSELECTED);
1264         }
1265     }
1266     end_menu(men, "View which?");
1267
1268     n = select_menu(men, PICK_ONE, &sel);
1269     destroy_nhwindow(men);
1270     /*
1271      * n <  0: player used ESC to cancel;
1272      * n == 0: preselected entry was explicitly chosen and got toggled off;
1273      * n == 1: preselected entry was implicitly chosen via <space>|<enter>;
1274      * n == 2: another entry was explicitly chosen, so skip preselected one.
1275      */
1276     which = (n < 0) ? -1 : (n == 0) ? 1 : sel[0].item.a_int;
1277     if (n > 1 && which == 1)
1278         which = sel[1].item.a_int;
1279     if (n > 0)
1280         free((genericptr_t) sel);
1281
1282     switch (which) {
1283     case 1: reveal_terrain(0, 0);   break; /* known map */
1284     case 2: reveal_terrain(0, 1);   break; /* known map with traps */
1285     case 3: reveal_terrain(0, 1|2); break; /* known map w/ traps & objs */
1286     case 4: reveal_terrain(1, 0);   break; /* full map */
1287     case 5: wiz_map_levltyp();      break; /* map internals */
1288     case 6: wiz_levltyp_legend();   break; /* internal details */
1289     default: break;
1290     }
1291     return 0; /* no time elapses */
1292 }
1293
1294 /* -enlightenment and conduct- */
1295 static winid en_win = WIN_ERR;
1296 #if 0 /*JP*/
1297 static const char You_[] = "You ", are[] = "are ", were[] = "were ",
1298                   have[] = "have ", had[] = "had ", can[] = "can ",
1299                   could[] = "could ";
1300 #else
1301 static const char You_[] = "\82 \82È\82½\82Í", 
1302                   are[]  = "\82Å\82 \82é",       were[]  = "\82Å\82 \82Á\82½",
1303                   have[] = "\82ð\82à\82Á\82Ä\82¢\82é", had[]   = "\82ð\82à\82Á\82Ä\82¢\82½",
1304                   can[]  = "\82Å\82«\82é",       could[] = "\82Å\82«\82½",
1305                   iru[]  = "\82¢\82é",         ita[]   = "\82¢\82½";
1306 #endif
1307 #if 0 /*JP*//* not used */
1308 static const char have_been[] = "have been ", have_never[] = "have never ",
1309                   never[] = "never ";
1310 #endif
1311
1312 #if 0 /*JP*/
1313 #define enl_msg(prefix, present, past, suffix, ps) \
1314     enlght_line(prefix, final ? past : present, suffix, ps)
1315 #else
1316 #define enl_msg(prefix, present, past, suffix, ps) \
1317     enlght_line(prefix, ps, suffix, final ? past : present)
1318 #endif
1319 #define you_are(attr, ps) enl_msg(You_, are, were, attr, ps)
1320 #define you_have(attr, ps) enl_msg(You_, have, had, attr, ps)
1321 #define you_can(attr, ps) enl_msg(You_, can, could, attr, ps)
1322 /*JP
1323 #define you_have_been(goodthing) enl_msg(You_, have_been, were, goodthing, "")
1324 */
1325 #define you_have_been(goodthing) enl_msg(You_, are, were, goodthing, "")
1326 #if 0 /*JP*/
1327 #define you_have_never(badthing) \
1328     enl_msg(You_, have_never, never, badthing, "")
1329 #else
1330 #define you_have_never(badthing) \
1331     enl_msg(badthing, "\82Ä\82¢\82È\82¢", "\82È\82©\82Á\82½", "", "")
1332 #endif
1333 #if 0 /*JP*/
1334 #define you_have_X(something) \
1335     enl_msg(You_, have, (const char *) "", something, "")
1336 #else
1337 #define you_have_X(something) \
1338     enl_msg(something, "\82Ä\82¢\82é", "\82½", "", "")
1339 #endif
1340 #if 1 /*JP*/
1341 #define you_are_ing(goodthing, ps) enl_msg(You_, iru, ita, goodthing, ps)
1342 #endif
1343
1344 static void
1345 enlght_line(start, middle, end, ps)
1346 const char *start, *middle, *end, *ps;
1347 {
1348     char buf[BUFSZ];
1349
1350 /*JP
1351     Sprintf(buf, " %s%s%s%s.", start, middle, end, ps);
1352 */
1353     Sprintf(buf, "%s%s%s%s\81D", start, middle, end, ps);
1354     putstr(en_win, 0, buf);
1355 }
1356
1357 /* format increased chance to hit or damage or defense (Protection) */
1358 static char *
1359 enlght_combatinc(inctyp, incamt, final, outbuf)
1360 const char *inctyp;
1361 int incamt, final;
1362 char *outbuf;
1363 {
1364     const char *modif, *bonus;
1365     boolean invrt;
1366     int absamt;
1367
1368     absamt = abs(incamt);
1369     /* Protection amount is typically larger than damage or to-hit;
1370        reduce magnitude by a third in order to stretch modifier ranges
1371        (small:1..5, moderate:6..10, large:11..19, huge:20+) */
1372     if (!strcmp(inctyp, "defense"))
1373         absamt = (absamt * 2) / 3;
1374
1375     if (absamt <= 3)
1376 /*JP
1377         modif = "small";
1378 */
1379         modif = "\8bÍ\82©\82È";
1380     else if (absamt <= 6)
1381 /*JP
1382         modif = "moderate";
1383 */
1384         modif = "\92\86\92ö\93x\82Ì";
1385     else if (absamt <= 12)
1386 /*JP
1387         modif = "large";
1388 */
1389         modif = "\91å\82«\82È";
1390     else
1391 /*JP
1392         modif = "huge";
1393 */
1394         modif = "\8b­\91å\82È";
1395
1396 #if 0 /*JP*/
1397     modif = !incamt ? "no" : an(modif); /* ("no" case shouldn't happen) */
1398 #endif
1399 /*JP
1400     bonus = (incamt >= 0) ? "bonus" : "penalty";
1401 */
1402     bonus = (incamt > 0) ? "\83{\81[\83i\83X" : "\83y\83i\83\8b\83e\83B";
1403     /* "bonus <foo>" (to hit) vs "<bar> bonus" (damage, defense) */
1404     invrt = strcmp(inctyp, "to hit") ? TRUE : FALSE;
1405
1406 #if 0 /*JP*/
1407     Sprintf(outbuf, "%s %s %s", modif, invrt ? inctyp : bonus,
1408             invrt ? bonus : inctyp);
1409 #else
1410     Sprintf(outbuf, "%s\82É%s%s", inctyp, modif, bonus);
1411 #endif
1412     if (final || wizard)
1413         Sprintf(eos(outbuf), " (%s%d)", (incamt > 0) ? "+" : "", incamt);
1414
1415     return outbuf;
1416 }
1417
1418 /* report half physical or half spell damage */
1419 STATIC_OVL void
1420 enlght_halfdmg(category, final)
1421 int category;
1422 int final;
1423 {
1424     const char *category_name;
1425     char buf[BUFSZ];
1426
1427     switch (category) {
1428     case HALF_PHDAM:
1429         category_name = "physical";
1430         break;
1431     case HALF_SPDAM:
1432         category_name = "spell";
1433         break;
1434     default:
1435         category_name = "unknown";
1436         break;
1437     }
1438     Sprintf(buf, " %s %s damage", (final || wizard) ? "half" : "reduced",
1439             category_name);
1440     enl_msg(You_, "take", "took", buf, from_what(category));
1441 }
1442
1443 /* is hero actively using water walking capability on water (or lava)? */
1444 STATIC_OVL boolean
1445 walking_on_water()
1446 {
1447     if (u.uinwater || Levitation || Flying)
1448         return FALSE;
1449     return (boolean) (Wwalking
1450                       && (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)));
1451 }
1452
1453 /* check whether hero is wearing something that player definitely knows
1454    confers the target property; item must have been seen and its type
1455    discovered but it doesn't necessarily have to be fully identified */
1456 STATIC_OVL boolean
1457 cause_known(propindx)
1458 int propindx; /* index of a property which can be conveyed by worn item */
1459 {
1460     register struct obj *o;
1461     long mask = W_ARMOR | W_AMUL | W_RING | W_TOOL;
1462
1463     /* simpler than from_what()/what_gives(); we don't attempt to
1464        handle artifacts and we deliberately ignore wielded items */
1465     for (o = invent; o; o = o->nobj) {
1466         if (!(o->owornmask & mask))
1467             continue;
1468         if ((int) objects[o->otyp].oc_oprop == propindx
1469             && objects[o->otyp].oc_name_known && o->dknown)
1470             return TRUE;
1471     }
1472     return FALSE;
1473 }
1474
1475 /* format a characteristic value, accommodating Strength's strangeness */
1476 STATIC_OVL char *
1477 attrval(attrindx, attrvalue, resultbuf)
1478 int attrindx, attrvalue;
1479 char resultbuf[]; /* should be at least [7] to hold "18/100\0" */
1480 {
1481     if (attrindx != A_STR || attrvalue <= 18)
1482         Sprintf(resultbuf, "%d", attrvalue);
1483     else if (attrvalue > STR18(100)) /* 19 to 25 */
1484         Sprintf(resultbuf, "%d", attrvalue - 100);
1485     else /* simplify "18/ **" to be "18/100" */
1486         Sprintf(resultbuf, "18/%02d", attrvalue - 18);
1487     return resultbuf;
1488 }
1489
1490 void
1491 enlightenment(mode, final)
1492 int mode;  /* BASICENLIGHTENMENT | MAGICENLIGHTENMENT (| both) */
1493 int final; /* ENL_GAMEINPROGRESS:0, ENL_GAMEOVERALIVE, ENL_GAMEOVERDEAD */
1494 {
1495     char buf[BUFSZ], tmpbuf[BUFSZ];
1496
1497     Strcpy(tmpbuf, plname);
1498     *tmpbuf = highc(*tmpbuf); /* same adjustment as bottom line */
1499     /* as in background_enlightenment, when poly'd we need to use the saved
1500        gender in u.mfemale rather than the current you-as-monster gender */
1501 #if 0 /*JP*/
1502     Sprintf(buf, "%s the %s's attributes:", tmpbuf,
1503             ((Upolyd ? u.mfemale : flags.female) && urole.name.f)
1504                 ? urole.name.f
1505                 : urole.name.m);
1506 #else
1507     Sprintf(buf, "%s\82Ì%s\82Ì\91®\90«:",
1508             ((Upolyd ? u.mfemale : flags.female) && urole.name.f)
1509                 ? urole.name.f
1510                 : urole.name.m,
1511              tmpbuf);
1512 #endif
1513
1514     en_win = create_nhwindow(NHW_MENU);
1515     /* title */
1516     putstr(en_win, 0, buf); /* "Conan the Archeologist's attributes:" */
1517     /* background and characteristics; ^X or end-of-game disclosure */
1518     if (mode & BASICENLIGHTENMENT) {
1519         /* role, race, alignment, deities */
1520         background_enlightenment(mode, final);
1521         /* strength, dexterity, &c */
1522         characteristics_enlightenment(mode, final);
1523     }
1524     /* expanded status line information, including things which aren't
1525        included there due to space considerations--such as obvious
1526        alternative movement indicators (riding, levitation, &c), and
1527        various troubles (turning to stone, trapped, confusion, &c);
1528        shown for both basic and magic enlightenment */
1529     status_enlightenment(mode, final);
1530     /* remaining attributes; shown for potion,&c or wizard mode and
1531        explore mode ^X or end of game disclosure */
1532     if (mode & MAGICENLIGHTENMENT) {
1533         /* intrinsics and other traditional enlightenment feedback */
1534         attributes_enlightenment(mode, final);
1535     }
1536     display_nhwindow(en_win, TRUE);
1537     destroy_nhwindow(en_win);
1538     en_win = WIN_ERR;
1539 }
1540
1541 /*ARGSUSED*/
1542 /* display role, race, alignment and such to en_win */
1543 STATIC_OVL void
1544 background_enlightenment(unused_mode, final)
1545 int unused_mode UNUSED;
1546 int final;
1547 {
1548     const char *role_titl, *rank_titl;
1549     int innategend, difgend, difalgn;
1550     char buf[BUFSZ], tmpbuf[BUFSZ];
1551
1552     /* note that if poly'd, we need to use u.mfemale instead of flags.female
1553        to access hero's saved gender-as-human/elf/&c rather than current one */
1554     innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0;
1555     role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m;
1556     rank_titl = rank_of(u.ulevel, Role_switch, innategend);
1557
1558     putstr(en_win, 0, ""); /* separator after title */
1559 /*JP
1560     putstr(en_win, 0, "Background:");
1561 */
1562     putstr(en_win, 0, "\94w\8ci\8fî\95ñ:");
1563
1564     /* if polymorphed, report current shape before underlying role;
1565        will be repeated as first status: "you are transformed" and also
1566        among various attributes: "you are in beast form" (after being
1567        told about lycanthropy) or "you are polymorphed into <a foo>"
1568        (with countdown timer appended for wizard mode); we really want
1569        the player to know he's not a samurai at the moment... */
1570     if (Upolyd) {
1571         struct permonst *uasmon = youmonst.data;
1572
1573         tmpbuf[0] = '\0';
1574         /* here we always use current gender, not saved role gender */
1575         if (!is_male(uasmon) && !is_female(uasmon) && !is_neuter(uasmon))
1576 /*JP
1577             Sprintf(tmpbuf, "%s ", genders[flags.female ? 1 : 0].adj);
1578 */
1579             Sprintf(tmpbuf, "%s\82Ì", genders[flags.female ? 1 : 0].adj);
1580 #if 0 /*JP*/
1581         Sprintf(buf, "%sin %s%s form", !final ? "currently " : "", tmpbuf,
1582                 uasmon->mname);
1583 #else
1584         Sprintf(buf, "%s%s%s\82Ì\8ep", !final ? "\8d¡\82Ì\82Æ\82±\82ë" : "", tmpbuf,
1585                 uasmon->mname);
1586 #endif
1587         you_are(buf, "");
1588     }
1589
1590     /* report role; omit gender if it's redundant (eg, "female priestess") */
1591     tmpbuf[0] = '\0';
1592     if (!urole.name.f
1593         && ((urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE)
1594             || innategend != flags.initgend))
1595 /*JP
1596         Sprintf(tmpbuf, "%s ", genders[innategend].adj);
1597 */
1598         Sprintf(tmpbuf, "%s", genders[innategend].adj);
1599     buf[0] = '\0';
1600     if (Upolyd)
1601 #if 0 /*JP*/
1602         Strcpy(buf, "actually "); /* "You are actually a ..." */
1603 #else
1604         Strcpy(buf, "\8eÀ\8dÛ\82É\82Í"); /* "\82 \82È\82½\82Í\8eÀ\8dÛ\82É\82Í..." */
1605 #endif
1606     if (!strcmpi(rank_titl, role_titl)) {
1607         /* omit role when rank title matches it */
1608 #if 0 /*JP*/
1609         Sprintf(eos(buf), "%s, level %d %s%s", an(rank_titl), u.ulevel,
1610                 tmpbuf, urace.noun);
1611 #else
1612         Sprintf(eos(buf), "\83\8c\83x\83\8b%d\82Ì%s\82Ì%s%s", u.ulevel,
1613                 tmpbuf, urace.adj, role_titl);
1614 #endif
1615     } else {
1616 #if 0 /*JP*/
1617         Sprintf(eos(buf), "%s, a level %d %s%s %s", an(rank_titl), u.ulevel,
1618                 tmpbuf, urace.adj, role_titl);
1619 #else
1620         Sprintf(eos(buf), "\83\8c\83x\83\8b%d\82Ì%s\82Ì%s%s\82Ì%s", u.ulevel,
1621                 tmpbuf, urace.adj, role_titl, rank_titl);
1622 #endif
1623     }
1624     you_are(buf, "");
1625
1626     /* report alignment (bypass you_are() in order to omit ending period) */
1627 #if 0 /*JP*/
1628     Sprintf(buf, " %s%s%s, %son a mission for %s",
1629             You_, !final ? are : were,
1630             align_str(u.ualign.type),
1631             /* helm of opposite alignment (might hide conversion) */
1632             (u.ualign.type != u.ualignbase[A_CURRENT]) ? "temporarily "
1633                /* permanent conversion */
1634                : (u.ualign.type != u.ualignbase[A_ORIGINAL]) ? "now "
1635                   /* atheist (ignored in very early game) */
1636                   : (!u.uconduct.gnostic && moves > 1000L) ? "nominally "
1637                      /* lastly, normal case */
1638                      : "",
1639             u_gname());
1640 #else
1641     Sprintf(buf, "\82 \82È\82½\82Í%s\82Å, %s%s\82Ì\82½\82ß\82Ì\94C\96±\82ð\8ds\82Á\82Ä%s\81D",
1642             align_str(u.ualign.type),
1643             /* helm of opposite alignment (might hide conversion) */
1644             (u.ualign.type != u.ualignbase[A_CURRENT]) ? "\88ê\8e\9e\93I\82É"
1645                /* permanent conversion */
1646                : (u.ualign.type != u.ualignbase[A_ORIGINAL]) ? "\8c»\8dÝ"
1647                   /* atheist (ignored in very early game) */
1648                   : (!u.uconduct.gnostic && moves > 1000L) ? "\96¼\8b`\8fã"
1649                      /* lastly, normal case */
1650                      : "",
1651             u_gname(), !final ? iru : ita);
1652 #endif
1653     putstr(en_win, 0, buf);
1654     /* show the rest of this game's pantheon (finishes previous sentence)
1655        [appending "also Moloch" at the end would allow for straightforward
1656        trailing "and" on all three aligned entries but looks too verbose] */
1657 #if 0 /*JP*/
1658     Sprintf(buf, " who %s opposed by", !final ? "is" : "was");
1659 #else
1660     Strcpy(buf, "\82 \82È\82½\82Í");
1661 #endif
1662     if (u.ualign.type != A_LAWFUL)
1663 #if 0 /*JP*/
1664         Sprintf(eos(buf), " %s (%s) and", align_gname(A_LAWFUL),
1665                 align_str(A_LAWFUL));
1666 #else
1667         Sprintf(eos(buf), "%s(%s)\82¨\82æ\82Ñ", align_gname(A_LAWFUL),
1668                 align_str(A_LAWFUL));
1669 #endif
1670     if (u.ualign.type != A_NEUTRAL)
1671 #if 0 /*JP*/
1672         Sprintf(eos(buf), " %s (%s)%s", align_gname(A_NEUTRAL),
1673                 align_str(A_NEUTRAL),
1674                 (u.ualign.type != A_CHAOTIC) ? " and" : "");
1675 #else
1676         Sprintf(eos(buf), "%s(%s)%s", align_gname(A_NEUTRAL),
1677                 align_str(A_NEUTRAL),
1678                 (u.ualign.type != A_CHAOTIC) ? "\82¨\82æ\82Ñ" : "");
1679 #endif
1680 #if 0 /*JP*/
1681     if (u.ualign.type != A_CHAOTIC)
1682         Sprintf(eos(buf), " %s (%s)", align_gname(A_CHAOTIC),
1683                 align_str(A_CHAOTIC));
1684 #else
1685     if (u.ualign.type != A_CHAOTIC)
1686         Sprintf(eos(buf), "%s(%s)", align_gname(A_CHAOTIC),
1687                 align_str(A_CHAOTIC));
1688 #endif
1689 #if 0 /*JP*/
1690     Strcat(buf, "."); /* terminate sentence */
1691 #else
1692     Sprintf(eos(buf), "\82Æ\91Î\97§\82µ\82Ä%s\81D", !final ? iru : ita);
1693 #endif
1694     putstr(en_win, 0, buf);
1695
1696     /* show original alignment,gender,race,role if any have been changed;
1697        giving separate message for temporary alignment change bypasses need
1698        for tricky phrasing otherwise necessitated by possibility of having
1699        helm of opposite alignment mask a permanent alignment conversion */
1700     difgend = (innategend != flags.initgend);
1701     difalgn = (((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0)
1702                + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL])
1703                   ? 2 : 0));
1704     if (difalgn & 1) { /* have temporary alignment so report permanent one */
1705 /*JP
1706         Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT]));
1707 */
1708         Sprintf(buf, "\8eÀ\8dÛ\82É\82Í%s", align_str(u.ualignbase[A_CURRENT]));
1709         you_are(buf, "");
1710         difalgn &= ~1; /* suppress helm from "started out <foo>" message */
1711     }
1712     if (difgend || difalgn) { /* sex change or perm align change or both */
1713 #if 0 /*JP*/
1714         Sprintf(buf, " You started out %s%s%s.",
1715                 difgend ? genders[flags.initgend].adj : "",
1716                 (difgend && difalgn) ? " and " : "",
1717                 difalgn ? align_str(u.ualignbase[A_ORIGINAL]) : "");
1718 #else
1719         Sprintf(buf, "\82 \82È\82½\82Í%s%s%s\82Å\8aJ\8en\82µ\82½\81D",
1720                 difgend ? genders[flags.initgend].adj : "",
1721                 (difgend && difalgn) ? "\82©\82Â" : "",
1722                 difalgn ? align_str(u.ualignbase[A_ORIGINAL]) : "");
1723 #endif
1724         putstr(en_win, 0, buf);
1725     }
1726 }
1727
1728 /* characteristics: expanded version of bottom line strength, dexterity, &c */
1729 STATIC_OVL void
1730 characteristics_enlightenment(mode, final)
1731 int mode;
1732 int final;
1733 {
1734     putstr(en_win, 0, ""); /* separator after background */
1735     putstr(en_win, 0,
1736 /*JP
1737            final ? "Final Characteristics:" : "Current Characteristics:");
1738 */
1739            final ? "\8dÅ\8fI\91®\90«\81F" : "\8c»\8dÝ\82Ì\91®\90«\81F");
1740
1741     /* bottom line order */
1742     one_characteristic(mode, final, A_STR); /* strength */
1743     one_characteristic(mode, final, A_DEX); /* dexterity */
1744     one_characteristic(mode, final, A_CON); /* constitution */
1745     one_characteristic(mode, final, A_INT); /* intelligence */
1746     one_characteristic(mode, final, A_WIS); /* wisdom */
1747     one_characteristic(mode, final, A_CHA); /* charisma */
1748 }
1749
1750 /* display one attribute value for characteristics_enlightenment() */
1751 STATIC_OVL void
1752 one_characteristic(mode, final, attrindx)
1753 int mode, final, attrindx;
1754 {
1755     boolean hide_innate_value = FALSE, interesting_alimit;
1756     int acurrent, abase, apeak, alimit;
1757     const char *attrname, *paren_pfx;
1758     char subjbuf[BUFSZ], valubuf[BUFSZ], valstring[32];
1759
1760     /* being polymorphed or wearing certain cursed items prevents
1761        hero from reliably tracking changes to characteristics so
1762        we don't show base & peak values then; when the items aren't
1763        cursed, hero could take them off to check underlying values
1764        and we show those in such case so that player doesn't need
1765        to actually resort to doing that */
1766     if (Upolyd) {
1767         hide_innate_value = TRUE;
1768     } else if (Fixed_abil) {
1769         if (stuck_ring(uleft, RIN_SUSTAIN_ABILITY)
1770             || stuck_ring(uright, RIN_SUSTAIN_ABILITY))
1771             hide_innate_value = TRUE;
1772     }
1773     switch (attrindx) {
1774     case A_STR:
1775 /*JP
1776         attrname = "strength";
1777 */
1778         attrname = "\8b­\82³";
1779         if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER && uarmg->cursed)
1780             hide_innate_value = TRUE;
1781         break;
1782     case A_DEX:
1783 /*JP
1784         attrname = "dexterity";
1785 */
1786         attrname = "\91f\91\81\82³";
1787         break;
1788     case A_CON:
1789 /*JP
1790         attrname = "constitution";
1791 */
1792         attrname = "\91Ï\8bv\97Í";
1793         break;
1794     case A_INT:
1795 /*JP
1796         attrname = "intelligence";
1797 */
1798         attrname = "\92m\97Í";
1799         if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
1800             hide_innate_value = TRUE;
1801         break;
1802     case A_WIS:
1803 /*JP
1804         attrname = "wisdom";
1805 */
1806         attrname = "\8c«\82³";
1807         if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
1808             hide_innate_value = TRUE;
1809         break;
1810     case A_CHA:
1811 /*JP
1812         attrname = "charisma";
1813 */
1814         attrname = "\96£\97Í";
1815         break;
1816     default:
1817         return; /* impossible */
1818     };
1819     /* note: final disclosure includes MAGICENLIGHTENTMENT */
1820     if ((mode & MAGICENLIGHTENMENT) && !Upolyd)
1821         hide_innate_value = FALSE;
1822
1823     acurrent = ACURR(attrindx);
1824     (void) attrval(attrindx, acurrent, valubuf); /* Sprintf(valubuf,"%d",) */
1825 /*JP
1826     Sprintf(subjbuf, "Your %s ", attrname);
1827 */
1828     Sprintf(subjbuf, "\82 \82È\82½\82Ì%s\82Í", attrname);
1829
1830     if (!hide_innate_value) {
1831         /* show abase, amax, and/or attrmax if acurr doesn't match abase
1832            (a magic bonus or penalty is in effect) or abase doesn't match
1833            amax (some points have been lost to poison or exercise abuse
1834            and are restorable) or attrmax is different from normal human
1835            (while game is in progress; trying to reduce dependency on
1836            spoilers to keep track of such stuff) or attrmax was different
1837            from abase (at end of game; this attribute wasn't maxed out) */
1838         abase = ABASE(attrindx);
1839         apeak = AMAX(attrindx);
1840         alimit = ATTRMAX(attrindx);
1841         /* criterium for whether the limit is interesting varies */
1842         interesting_alimit =
1843             final ? TRUE /* was originally `(abase != alimit)' */
1844                   : (alimit != (attrindx != A_STR ? 18 : STR18(100)));
1845 /*JP
1846         paren_pfx = final ? " (" : " (current; ";
1847 */
1848         paren_pfx = final ? " (" : " (\8c»\8dÝ; ";
1849         if (acurrent != abase) {
1850 #if 0 /*JP*/
1851             Sprintf(eos(valubuf), "%sbase:%s", paren_pfx,
1852                     attrval(attrindx, abase, valstring));
1853 #else
1854             Sprintf(eos(valubuf), "%s\8aî\96{:%s", paren_pfx,
1855                     attrval(attrindx, abase, valstring));
1856 #endif
1857             paren_pfx = ", ";
1858         }
1859         if (abase != apeak) {
1860 #if 0 /*JP*/
1861             Sprintf(eos(valubuf), "%speak:%s", paren_pfx,
1862                     attrval(attrindx, apeak, valstring));
1863 #else
1864             Sprintf(eos(valubuf), "%s\8dÅ\91å:%s", paren_pfx,
1865                     attrval(attrindx, apeak, valstring));
1866 #endif
1867             paren_pfx = ", ";
1868         }
1869         if (interesting_alimit) {
1870 #if 0 /*JP*/
1871             Sprintf(eos(valubuf), "%s%slimit:%s", paren_pfx,
1872                     /* more verbose if exceeding 'limit' due to magic bonus */
1873                     (acurrent > alimit) ? "innate " : "",
1874                     attrval(attrindx, alimit, valstring));
1875 #else
1876             Sprintf(eos(valubuf), "%s%s\8fã\8cÀ:%s", paren_pfx,
1877                     /* more verbose if exceeding 'limit' due to magic bonus */
1878                     (acurrent > alimit) ? "\96{\97\88\82Ì" : "",
1879                     attrval(attrindx, alimit, valstring));
1880 #endif
1881             /* paren_pfx = ", "; */
1882         }
1883         if (acurrent != abase || abase != apeak || interesting_alimit)
1884             Strcat(valubuf, ")");
1885     }
1886 /*JP
1887     enl_msg(subjbuf, "is ", "was ", valubuf, "");
1888 */
1889     enl_msg(subjbuf, "\82¾", "\82¾\82Á\82½", valubuf, "");
1890 }
1891
1892 /* status: selected obvious capabilities, assorted troubles */
1893 STATIC_OVL void
1894 status_enlightenment(mode, final)
1895 int mode;
1896 int final;
1897 {
1898     boolean magic = (mode & MAGICENLIGHTENMENT) ? TRUE : FALSE;
1899     int cap;
1900     char buf[BUFSZ], youtoo[BUFSZ];
1901     boolean Riding = (u.usteed
1902                       /* if hero dies while dismounting, u.usteed will still
1903                          be set; we want to ignore steed in that situation */
1904                       && !(final == ENL_GAMEOVERDEAD
1905 /*JP
1906                            && !strcmp(killer.name, "riding accident")));
1907 */
1908                            && !strcmp(killer.name, "\8bR\8fæ\8e\96\8cÌ\82Å")));
1909     const char *steedname = (!Riding ? (char *) 0
1910                       : x_monnam(u.usteed,
1911                                  u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE,
1912                                  (char *) 0,
1913                                  (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
1914                                  FALSE));
1915
1916     /*\
1917      * Status (many are abbreviated on bottom line; others are or
1918      *     should be discernible to the hero hence to the player)
1919     \*/
1920     putstr(en_win, 0, ""); /* separator after title or characteristics */
1921 /*JP
1922     putstr(en_win, 0, final ? "Final Status:" : "Current Status:");
1923 */
1924     putstr(en_win, 0, final ? "\8dÅ\8fI\8fó\91Ô:" : "\8c»\8dÝ\82Ì\8fó\91Ô:");
1925
1926     Strcpy(youtoo, You_);
1927     /* not a traditional status but inherently obvious to player; more
1928        detail given below (attributes section) for magic enlightenment */
1929     if (Upolyd)
1930 /*JP
1931         you_are("transformed", "");
1932 */
1933         you_are_ing("\95Ï\89»\82µ\82Ä", "");
1934     /* not a trouble, but we want to display riding status before maybe
1935        reporting steed as trapped or hero stuck to cursed saddle */
1936     if (Riding) {
1937 #if 0 /*JP*/
1938         Sprintf(buf, "riding %s", steedname);
1939         you_are(buf, "");
1940 #else
1941         Sprintf(buf, "%s\82É\8fæ\82Á\82Ä", steedname);
1942         you_are_ing(buf, "");
1943 #endif
1944 /*JP
1945         Sprintf(eos(youtoo), "and %s ", steedname);
1946 */
1947         Sprintf(youtoo, "\82 \82È\82½\82Æ%s\82Í", steedname);
1948     }
1949     /* other movement situations that hero should always know */
1950     if (Levitation) {
1951         if (Lev_at_will && magic)
1952 /*JP
1953             you_are("levitating, at will", "");
1954 */
1955             you_are_ing("\8e©\95ª\82Ì\88Ó\8eu\82Å\95\82\97V\82µ\82Ä", "");
1956         else
1957 /*JP
1958             enl_msg(youtoo, are, were, "levitating", from_what(LEVITATION));
1959 */
1960             enl_msg(youtoo, "\82¢\82é", "\82¢\82½", "\95\82\97V\82µ\82Ä", from_what(LEVITATION));
1961     } else if (Flying) { /* can only fly when not levitating */
1962 /*JP
1963         enl_msg(youtoo, are, were, "flying", from_what(FLYING));
1964 */
1965         enl_msg(youtoo, "\82¢\82é", "\82¢\82½", "\94ò\82ñ\82Å", from_what(FLYING));
1966     }
1967     if (Underwater) {
1968 /*JP
1969         you_are("underwater", "");
1970 */
1971         enl_msg(You_, "\82¢\82é", "\82¢\82½", "\90\85\96Ê\89º\82É", "");
1972     } else if (u.uinwater) {
1973 /*JP
1974         you_are(Swimming ? "swimming" : "in water", from_what(SWIMMING));
1975 */
1976         enl_msg(You_, Swimming ? "\89j\82¢\82Å" : "\90\85\92\86\82É", "\82¢\82é", "\82¢\82½", from_what(SWIMMING));
1977     } else if (walking_on_water()) {
1978         /* show active Wwalking here, potential Wwalking elsewhere */
1979 #if 0 /*JP*/
1980         Sprintf(buf, "walking on %s",
1981                 is_pool(u.ux, u.uy) ? "water"
1982                 : is_lava(u.ux, u.uy) ? "lava"
1983                   : surface(u.ux, u.uy)); /* catchall; shouldn't happen */
1984         you_are(buf, from_what(WWALKING));
1985 #else
1986         Sprintf(buf, "%s\82Ì\8fã\82ð\95à\82¢\82Ä",
1987                 is_pool(u.ux, u.uy) ? "\90\85"
1988                 : is_lava(u.ux, u.uy) ? "\97n\8aâ"
1989                   : surface(u.ux, u.uy)); /* catchall; shouldn't happen */
1990         you_are_ing(buf, from_what(WWALKING));
1991 #endif
1992     }
1993     if (Upolyd && (u.uundetected || youmonst.m_ap_type != M_AP_NOTHING))
1994         youhiding(TRUE, final);
1995
1996     /* internal troubles, mostly in the order that prayer ranks them */
1997     if (Stoned)
1998 /*JP
1999         you_are("turning to stone", "");
2000 */
2001         enl_msg("\82 \82È\82½\82Í", "\82È\82è\82Â\82Â\82 \82é", "\82È\82Á\82½", "\90Î\82É", "");
2002     if (Slimed)
2003 /*JP
2004         you_are("turning into slime", "");
2005 */
2006         enl_msg("\82 \82È\82½\82Í", "\82È\82è\82Â\82Â\82 \82é", "\82È\82Á\82½", "\83X\83\89\83C\83\80\82É", "");
2007     if (Strangled) {
2008         if (u.uburied) {
2009 /*JP
2010             you_are("buried", "");
2011 */
2012             you_are_ing("\92\82\91§\82µ\82Ä", "");
2013         } else {
2014 /*JP
2015             Strcpy(buf, "being strangled");
2016 */
2017             Strcpy(buf, "\8eñ\82ð\8di\82ß\82ç\82ê\82Ä");
2018             if (wizard)
2019                 Sprintf(eos(buf), " (%ld)", (Strangled & TIMEOUT));
2020 /*JP
2021             you_are(buf, from_what(STRANGLED));
2022 */
2023             enl_msg("\82 \82È\82½\82Í", "\82¢\82é", "\82¢\82½", buf, from_what(STRANGLED));
2024         }
2025     }
2026     if (Sick) {
2027         /* prayer lumps these together; botl puts Ill before FoodPois */
2028         if (u.usick_type & SICK_NONVOMITABLE)
2029 /*JP
2030             you_are("terminally sick from illness", "");
2031 */
2032             enl_msg("\82 \82È\82½\82Í\95a\8bC\82Å\92v\96½\93I\82É\8bC\95ª\82ª\88«", "\82¢", "\82©\82Á\82½", "", "");
2033         if (u.usick_type & SICK_VOMITABLE)
2034 /*JP
2035             you_are("terminally sick from food poisoning", "");
2036 */
2037             enl_msg("\82 \82È\82½\82Í\90H\92\86\93Å\82Å\92v\96½\93I\82É\8bC\95ª\82ª\88«", "\82¢", "\82©\82Á\82½", "", "");
2038     }
2039     if (Vomiting)
2040 /*JP
2041         you_are("nauseated", "");
2042 */
2043         enl_msg(You_, "\93f\82«\8bC\82ª", "\82 \82é", "\82 \82Á\82½", "");
2044     if (Stunned)
2045 /*JP
2046         you_are("stunned", "");
2047 */
2048         you_are("\82­\82ç\82­\82ç\8fó\91Ô", "");
2049     if (Confusion)
2050 /*JP
2051         you_are("confused", "");
2052 */
2053         you_are("\8d¬\97\90\8fó\91Ô", "");
2054     if (Hallucination)
2055 /*JP
2056         you_are("hallucinating", "");
2057 */
2058         you_are("\8c\8ao\8fó\91Ô", "");
2059     if (Blind) {
2060         /* from_what() (currently wizard-mode only) checks !haseyes()
2061            before u.uroleplay.blind, so we should too */
2062 #if 0 /*JP*/
2063         Sprintf(buf, "%s blind",
2064                 !haseyes(youmonst.data) ? "innately"
2065                 : u.uroleplay.blind ? "permanently"
2066                   /* better phrasing desperately wanted... */
2067                   : Blindfolded_only ? "deliberately"
2068                     : "temporarily");
2069 #else
2070         Sprintf(buf, "%s\96Ó\96Ú",
2071                 !haseyes(youmonst.data) ? "\90\82Ü\82ê\82È\82ª\82ç\82É"
2072                 : u.uroleplay.blind ? "\8dP\8bv\93I\82É"
2073                   /* better phrasing desperately wanted... */
2074                   : Blindfolded_only ? "\8cÌ\88Ó\82É"
2075                     : "\88ê\8e\9e\93I\82É");
2076 #endif
2077         if (wizard && (Blinded & TIMEOUT) != 0L
2078             && !u.uroleplay.blind && haseyes(youmonst.data))
2079             Sprintf(eos(buf), " (%ld)", (Blinded & TIMEOUT));
2080         /* !haseyes: avoid "you are innately blind innately" */
2081         you_are(buf, !haseyes(youmonst.data) ? "" : from_what(BLINDED));
2082     }
2083     if (Deaf)
2084 /*JP
2085         you_are("deaf", from_what(DEAF));
2086 */
2087         you_are("\8e¨\82ª\95·\82±\82¦\82È\82¢\8fó\91Ô", from_what(DEAF));
2088
2089     /* external troubles, more or less */
2090     if (Punished) {
2091         if (uball) {
2092 /*JP
2093             Sprintf(buf, "chained to %s", ansimpleoname(uball));
2094 */
2095             Sprintf(buf, "%s\82É\82Â\82È\82ª\82ê\82Ä", ansimpleoname(uball));
2096         } else {
2097             impossible("Punished without uball?");
2098 /*JP
2099             Strcpy(buf, "punished");
2100 */
2101             Strcpy(buf, "\94±\82ð\8eó\82¯\82Ä");
2102         }
2103 /*JP
2104         you_are(buf, "");
2105 */
2106         you_are_ing(buf, "");
2107     }
2108     if (u.utrap) {
2109         char predicament[BUFSZ];
2110         struct trap *t;
2111         boolean anchored = (u.utraptype == TT_BURIEDBALL);
2112
2113         if (anchored) {
2114 /*JP
2115             Strcpy(predicament, "tethered to something buried");
2116 */
2117             Strcpy(predicament, "\89½\82©\96\84\82Ü\82Á\82Ä\82¢\82é\82à\82Ì\82É\82Â\82È\82ª\82ê\82Ä");
2118         } else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
2119 /*JP
2120             Sprintf(predicament, "stuck in %s", the(surface(u.ux, u.uy)));
2121 */
2122             Sprintf(predicament, "%s\82É\96\84\82Ü\82Á\82Ä", surface(u.ux, u.uy));
2123         } else {
2124 #if 0 /*JP*/
2125             Strcpy(predicament, "trapped");
2126             if ((t = t_at(u.ux, u.uy)) != 0)
2127                 Sprintf(eos(predicament), " in %s",
2128                         an(defsyms[trap_to_defsym(t->ttyp)].explanation));
2129 #else
2130             predicament[0] = '\0';
2131             if ((t = t_at(u.ux, u.uy)) != 0)
2132                 Sprintf(predicament, "%s\82É",
2133                         defsyms[trap_to_defsym(t->ttyp)].explanation);
2134             Strcat(predicament, "\82Ð\82Á\82©\82©\82Á\82Ä");
2135 #endif
2136         }
2137         if (u.usteed) { /* not `Riding' here */
2138 #if 0 /*JP*/
2139             Sprintf(buf, "%s%s ", anchored ? "you and " : "", steedname);
2140             *buf = highc(*buf);
2141             enl_msg(buf, (anchored ? "are " : "is "),
2142                     (anchored ? "were " : "was "), predicament, "");
2143 #else
2144             Sprintf(buf, "%s%s\82Í", anchored ? "\82 \82È\82½\82Æ" : "", steedname);
2145             enl_msg(buf, "\82¢\82é", "\82¢\82½" , predicament, "");
2146 #endif
2147         } else
2148             you_are(predicament, "");
2149     } /* (u.utrap) */
2150     if (u.uswallow) {
2151 /*JP
2152         Sprintf(buf, "swallowed by %s", a_monnam(u.ustuck));
2153 */
2154         Sprintf(buf, "%s\82É\88ù\82Ý\8d\9e\82Ü\82ê\82Ä", a_monnam(u.ustuck));
2155         if (wizard)
2156             Sprintf(eos(buf), " (%u)", u.uswldtim);
2157         you_are(buf, "");
2158     } else if (u.ustuck) {
2159 #if 0 /*JP*/
2160         Sprintf(buf, "%s %s",
2161                 (Upolyd && sticks(youmonst.data)) ? "holding" : "held by",
2162                 a_monnam(u.ustuck));
2163         you_are(buf, "");
2164 #else
2165         Sprintf(buf, "%s%s",
2166                 a_monnam(u.ustuck),
2167                 (Upolyd && sticks(youmonst.data)) ? "\82ð\95ß\82Ü\82¦\82Ä" : "\82É\95ß\82Ü\82Á\82Ä");
2168         you_are_ing(buf, "");
2169 #endif
2170     }
2171     if (Riding) {
2172         struct obj *saddle = which_armor(u.usteed, W_SADDLE);
2173
2174         if (saddle && saddle->cursed) {
2175             Sprintf(buf, "stuck to %s %s", s_suffix(steedname),
2176                     simpleonames(saddle));
2177             you_are(buf, "");
2178         }
2179     }
2180     if (Wounded_legs) {
2181         /* when mounted, Wounded_legs applies to steed rather than to
2182            hero; we only report steed's wounded legs in wizard mode */
2183         if (u.usteed) { /* not `Riding' here */
2184             if (wizard && steedname) {
2185 #if 0 /*JP*/
2186                 Strcpy(buf, steedname);
2187                 *buf = highc(*buf);
2188                 enl_msg(buf, " has", " had", " wounded legs", "");
2189 #else
2190                 enl_msg(buf, iru, ita, "\82Í\8e\88\82ð\89ö\89ä\82µ\82Ä", "");
2191 #endif
2192             }
2193         } else {
2194 #if 0 /*JP*/
2195             Sprintf(buf, "wounded %s", makeplural(body_part(LEG)));
2196             you_have(buf, "");
2197 #else
2198             Sprintf(buf, "%s\82ð\89ö\89ä\82µ\82Ä", makeplural(body_part(LEG)));
2199             you_are_ing(buf, "");
2200 #endif
2201         }
2202     }
2203     if (Glib) {
2204 #if 0 /*JP*/
2205         Sprintf(buf, "slippery %s", makeplural(body_part(FINGER)));
2206         you_have(buf, "");
2207 #else
2208         Sprintf(buf, "%s\82ª\82Ê\82é\82Ê\82é\82µ\82Ä", body_part(FINGER));
2209         enl_msg(buf, iru, ita, "", "");
2210 #endif
2211     }
2212     if (Fumbling) {
2213         if (magic || cause_known(FUMBLING))
2214 /*JP
2215             enl_msg(You_, "fumble", "fumbled", "", from_what(FUMBLING));
2216 */
2217             you_are_ing("\95s\8aí\97p\82É\82È\82Á\82Ä", from_what(FUMBLING));
2218     }
2219     if (Sleepy) {
2220         if (magic || cause_known(SLEEPY)) {
2221             Strcpy(buf, from_what(SLEEPY));
2222             if (wizard)
2223                 Sprintf(eos(buf), " (%ld)", (HSleepy & TIMEOUT));
2224 /*JP
2225             enl_msg("You ", "fall", "fell", " asleep uncontrollably", buf);
2226 */
2227             you_are_ing("\96°\82Á\82Ä", buf);
2228         }
2229     }
2230     /* hunger/nutrition */
2231     if (Hunger) {
2232         if (magic || cause_known(HUNGER))
2233 #if 0 /*JP*/
2234             enl_msg(You_, "hunger", "hungered", " rapidly",
2235                     from_what(HUNGER));
2236 #else
2237             enl_msg("\82 \82È\82½\82Í\82·\82®\82É\95 \82ª\8c¸\82é\8fó\91Ô", "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2238 #endif
2239     }
2240     Strcpy(buf, hu_stat[u.uhs]); /* hunger status; omitted if "normal" */
2241     mungspaces(buf);             /* strip trailing spaces */
2242     if (*buf) {
2243 #if 0 /*JP*/
2244         *buf = lowc(*buf); /* override capitalization */
2245         if (!strcmp(buf, "weak"))
2246             Strcat(buf, " from severe hunger");
2247         else if (!strncmp(buf, "faint", 5)) /* fainting, fainted */
2248             Strcat(buf, " due to starvation");
2249         you_are(buf, "");
2250 #else
2251         Strcat(buf, "\8fó\91Ô");
2252         you_are(buf, "");
2253 #endif
2254     }
2255     /* encumbrance */
2256     if ((cap = near_capacity()) > UNENCUMBERED) {
2257 #if 0 /*JP*/
2258         const char *adj = "?_?"; /* (should always get overridden) */
2259
2260         Strcpy(buf, enc_stat[cap]);
2261         *buf = lowc(*buf);
2262         switch (cap) {
2263         case SLT_ENCUMBER:
2264             adj = "slightly";
2265             break; /* burdened */
2266         case MOD_ENCUMBER:
2267             adj = "moderately";
2268             break; /* stressed */
2269         case HVY_ENCUMBER:
2270             adj = "very";
2271             break; /* strained */
2272         case EXT_ENCUMBER:
2273             adj = "extremely";
2274             break; /* overtaxed */
2275         case OVERLOADED:
2276             adj = "not possible";
2277             break;
2278         }
2279         Sprintf(eos(buf), "; movement %s %s%s", !final ? "is" : "was", adj,
2280                 (cap < OVERLOADED) ? " slowed" : "");
2281         you_are(buf, "");
2282 #else
2283         Sprintf(buf, "\89×\95¨\82É\82æ\82Á\82Ä%s\8fó\91Ô", enc_stat[cap]);
2284         you_are(buf, "");
2285 #endif
2286     } else {
2287         /* last resort entry, guarantees Status section is non-empty
2288            (no longer needed for that purpose since weapon status added;
2289            still useful though) */
2290 /*JP
2291         you_are("unencumbered", "");
2292 */
2293         you_are("\89×\95¨\82Í\8e×\96\82\82É\82È\82ç\82È\82¢\8fó\91Ô", "");
2294     }
2295     /* report being weaponless; distinguish whether gloves are worn */
2296     if (!uwep) {
2297 #if 0 /*JP*/
2298         you_are(uarmg ? "empty handed" /* gloves imply hands */
2299                       : humanoid(youmonst.data)
2300                          /* hands but no weapon and no gloves */
2301                          ? "bare handed"
2302                          /* alternate phrasing for paws or lack of hands */
2303                          : "not wielding anything",
2304                 "");
2305 #else
2306         enl_msg(You_, "\82¢", "\82©\82Á\82½", "\95\90\8aí\82ð\91\95\94õ\82µ\82Ä\82¢\82È", "");
2307 #endif
2308     /* two-weaponing implies a weapon (not other odd stuff) in each hand */
2309     } else if (u.twoweap) {
2310 /*JP
2311         you_are("wielding two weapons at once", "");
2312 */
2313         you_are("\93ñ\93\81\97¬", "");
2314     /* report most weapons by their skill class (so a katana will be
2315        described as a long sword, for instance; mattock and hook are
2316        exceptions), or wielded non-weapon item by its object class */
2317     } else {
2318         const char *what = weapon_descr(uwep);
2319
2320 #if 0 /*JP*/
2321         if (!strcmpi(what, "armor") || !strcmpi(what, "food")
2322             || !strcmpi(what, "venom"))
2323             Sprintf(buf, "wielding some %s", what);
2324         else
2325             Sprintf(buf, "wielding %s",
2326                     (uwep->quan == 1L) ? an(what) : makeplural(what));
2327         you_are(buf, "");
2328 #else
2329         Sprintf(buf, "%s\82ð\91\95\94õ\82µ\82Ä", what);
2330         enl_msg(You_, "\82¢\82é", "\82¢\82½", buf, "");
2331 #endif
2332     }
2333     /* report 'nudity' */
2334     if (!uarm && !uarmu && !uarmc && !uarmg && !uarmf && !uarmh) {
2335         if (u.uroleplay.nudist)
2336 #if 0 /*JP*/
2337             enl_msg(You_, "do", "did", " not wear any armor", "");
2338 #else
2339             enl_msg(You_, "\82¢", "\82©\82Á\82½", "\89½\82Ì\8aZ\82à\91\95\94õ\82µ\82È", "");
2340 #endif
2341         else
2342 #if 0 /*JP*/
2343             you_are("not wearing any armor", "");
2344 #else
2345             enl_msg(You_, "\82¢", "\82©\82Á\82½", "\89½\82Ì\8aZ\82à\91\95\94õ\82µ\82Ä\82¢\82È", "");
2346 #endif
2347     }
2348 }
2349
2350 /* attributes: intrinsics and the like, other non-obvious capabilities */
2351 void
2352 attributes_enlightenment(unused_mode, final)
2353 int unused_mode UNUSED;
2354 int final;
2355 {
2356     static NEARDATA const char if_surroundings_permitted[] =
2357         " if surroundings permitted";
2358     int ltmp, armpro;
2359     char buf[BUFSZ];
2360
2361     /*\
2362      *  Attributes
2363     \*/
2364     putstr(en_win, 0, "");
2365 /*JP
2366     putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:");
2367 */
2368     putstr(en_win, 0, final ? "\8dÅ\8fI\91®\90«:" : "\8c»\8dÝ\82Ì\91®\90«:");
2369
2370     if (u.uevent.uhand_of_elbereth) {
2371 #if 0 /*JP*/
2372         static const char *const hofe_titles[3] = { "the Hand of Elbereth",
2373                                                     "the Envoy of Balance",
2374                                                     "the Glory of Arioch" };
2375 #else
2376         static const char *const hofe_titles[3] = { "\83G\83\8b\83x\83\8c\83X\82Ì\8cä\8eè",
2377                                                     "\92²\98a\82Ì\8eg\8eÒ",
2378                                                     "\83A\83\8a\83I\83b\83`\82Ì\96¼\97_" };
2379 #endif
2380         you_are(hofe_titles[u.uevent.uhand_of_elbereth - 1], "");
2381     }
2382
2383     /* note: piousness 20 matches MIN_QUEST_ALIGN (quest.h) */
2384     if (u.ualign.record >= 20)
2385 /*JP
2386         you_are("piously aligned", "");
2387 */
2388       you_have("\8chåi\82È\90M\8bÂ\90S", "");
2389     else if (u.ualign.record > 13)
2390 /*JP
2391         you_are("devoutly aligned", "");
2392 */
2393       you_have("\90S\82©\82ç\82Ì\90M\8bÂ\90S", "");
2394     else if (u.ualign.record > 8)
2395 /*JP
2396         you_are("fervently aligned", "");
2397 */
2398       you_have("\94M\90S\82È\90M\8bÂ\90S", "");
2399     else if (u.ualign.record > 3)
2400 /*JP
2401         you_are("stridently aligned", "");
2402 */
2403       you_have("\82¨\82¨\82°\82³\82È\90M\8bÂ\90S", "");
2404     else if (u.ualign.record == 3)
2405 /*JP
2406         you_are("aligned", "");
2407 */
2408       you_have("\95\81\92Ê\82Ì\90M\8bÂ\90S", "");
2409     else if (u.ualign.record > 0)
2410 /*JP
2411         you_are("haltingly aligned", "");
2412 */
2413       you_have("çSçO\82µ\82È\82ª\82ç\82à\90M\8bÂ\90S", "");
2414     else if (u.ualign.record == 0)
2415 /*JP
2416         you_are("nominally aligned", "");
2417 */
2418       you_have("\8c`\82¾\82¯\82Ì\90M\8bÂ\90S", "");
2419     else if (u.ualign.record >= -3)
2420 /*JP
2421         you_have("strayed", "");
2422 */
2423       you_are_ing("\90M\8bÂ\82É\96À\82¢\82ð\82à\82Á\82Ä", "");
2424     else if (u.ualign.record >= -8)
2425 /*JP
2426         you_have("sinned", "");
2427 */
2428       you_are_ing("\8dß\82ð\95\89\82Á\82Ä", "");
2429     else
2430 /*JP
2431         you_have("transgressed", "");
2432 */
2433       you_are_ing("\90M\8bÂ\82©\82ç\88í\92E\82µ\82Ä", "");
2434     if (wizard) {
2435 #if 0 /*JP*/
2436         Sprintf(buf, " %d", u.ualign.record);
2437         enl_msg("Your alignment ", "is", "was", buf, "");
2438 #else
2439         Sprintf(buf, "\82 \82È\82½\82Ì\91®\90«\92l\82Í%d", u.ualign.record);
2440         enl_msg(buf, "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2441 #endif
2442     }
2443
2444     /*** Resistances to troubles ***/
2445     if (Invulnerable)
2446 /*JP
2447         you_are("invulnerable", from_what(INVULNERABLE));
2448 */
2449         you_are("\95s\8e\80\90g", from_what(INVULNERABLE));
2450     if (Antimagic)
2451 /*JP
2452         you_are("magic-protected", from_what(ANTIMAGIC));
2453 */
2454         you_have("\96\82\96@\96h\8cä\94\\97Í", from_what(ANTIMAGIC));
2455     if (Fire_resistance)
2456 /*JP
2457         you_are("fire resistant", from_what(FIRE_RES));
2458 */
2459         you_have("\89Î\82Ö\82Ì\91Ï\90«", from_what(FIRE_RES));
2460     if (Cold_resistance)
2461 /*JP
2462         you_are("cold resistant", from_what(COLD_RES));
2463 */
2464         you_have("\8a¦\82³\82Ö\82Ì\91Ï\90«", from_what(COLD_RES));
2465     if (Sleep_resistance)
2466 /*JP
2467         you_are("sleep resistant", from_what(SLEEP_RES));
2468 */
2469         you_have("\96°\82è\82Ö\82Ì\91Ï\90«", from_what(SLEEP_RES));
2470     if (Disint_resistance)
2471 /*JP
2472         you_are("disintegration-resistant", from_what(DISINT_RES));
2473 */
2474         you_have("\95²\8dÓ\82Ö\82Ì\91Ï\90«", from_what(DISINT_RES));
2475     if (Shock_resistance)
2476 /*JP
2477         you_are("shock resistant", from_what(SHOCK_RES));
2478 */
2479         you_have("\93d\8c\82\82Ö\82Ì\91Ï\90«", from_what(SHOCK_RES));
2480     if (Poison_resistance)
2481 /*JP
2482         you_are("poison resistant", from_what(POISON_RES));
2483 */
2484         you_have("\93Å\82Ö\82Ì\91Ï\90«", from_what(POISON_RES));
2485     if (Acid_resistance)
2486 /*JP
2487         you_are("acid resistant", from_what(ACID_RES));
2488 */
2489         you_have("\8e_\82Ö\82Ì\91Ï\90«", from_what(ACID_RES));
2490     if (Drain_resistance)
2491 /*JP
2492         you_are("level-drain resistant", from_what(DRAIN_RES));
2493 */
2494         you_have("\83\8c\83x\83\8b\83_\83E\83\93\82Ö\82Ì\91Ï\90«", from_what(DRAIN_RES));
2495     if (Sick_resistance)
2496 /*JP
2497         you_are("immune to sickness", from_what(SICK_RES));
2498 */
2499         you_have("\95a\8bC\82É\91Î\82·\82é\96Æ\89u", from_what(SICK_RES));
2500     if (Stone_resistance)
2501 /*JP
2502         you_are("petrification resistant", from_what(STONE_RES));
2503 */
2504         you_have("\90Î\89»\82Ö\82Ì\91Ï\90«", from_what(STONE_RES));
2505     if (Halluc_resistance)
2506 #if 0 /*JP*/
2507         enl_msg(You_, "resist", "resisted", " hallucinations",
2508                 from_what(HALLUC_RES));
2509 #else
2510         you_have("\8c\8ao\82Ö\82Ì\91Ï\90«", from_what(HALLUC_RES));
2511 #endif
2512     if (u.uedibility)
2513 /*JP
2514         you_can("recognize detrimental food", "");
2515 */
2516         you_can("\97L\8aQ\82È\90H\97¿\82ð\8e¯\95Ê", "");
2517
2518     /*** Vision and senses ***/
2519     if (!Blind && (Blinded || !haseyes(youmonst.data)))
2520         you_can("see", from_what(-BLINDED)); /* Eyes of the Overworld */
2521     if (See_invisible) {
2522         if (!Blind)
2523 /*JP
2524             enl_msg(You_, "see", "saw", " invisible", from_what(SEE_INVIS));
2525 */
2526             enl_msg("\82 \82È\82½\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", "\82é", "\82½", "", from_what(SEE_INVIS));
2527         else
2528 #if 0 /*JP*/
2529             enl_msg(You_, "will see", "would have seen",
2530                     " invisible when not blind", from_what(SEE_INVIS));
2531 #else
2532             enl_msg(You_, "\82é", "\82½",
2533                     "\96Ó\96Ú\82Å\82È\82¢\82Æ\82«\82É\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", from_what(SEE_INVIS));
2534 #endif
2535     }
2536     if (Blind_telepat)
2537 /*JP
2538         you_are("telepathic", from_what(TELEPAT));
2539 */
2540         you_have("\83e\83\8c\83p\83V\81[", from_what(TELEPAT));
2541     if (Warning)
2542 /*JP
2543         you_are("warned", from_what(WARNING));
2544 */
2545         you_have("\8cx\89ú\94\\97Í", from_what(WARNING));
2546     if (Warn_of_mon && context.warntype.obj) {
2547 #if 0 /*JP*/
2548         Sprintf(buf, "aware of the presence of %s",
2549                 (context.warntype.obj & M2_ORC) ? "orcs"
2550                 : (context.warntype.obj & M2_ELF) ? "elves"
2551                 : (context.warntype.obj & M2_DEMON) ? "demons" : something);
2552         you_are(buf, from_what(WARN_OF_MON));
2553 #else
2554         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2555                 (context.warntype.obj & M2_ORC) ? "\83I\81[\83N"
2556                 : (context.warntype.obj & M2_ELF) ? "\83G\83\8b\83t"
2557                 : (context.warntype.obj & M2_DEMON) ? "\88«\96\82" : something);
2558         you_have(buf, "");
2559 #endif
2560     }
2561     if (Warn_of_mon && context.warntype.polyd) {
2562 #if 0 /*JP*/
2563         Sprintf(buf, "aware of the presence of %s",
2564                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2565                  == (M2_HUMAN | M2_ELF))
2566                     ? "humans and elves"
2567                     : (context.warntype.polyd & M2_HUMAN)
2568                           ? "humans"
2569                           : (context.warntype.polyd & M2_ELF)
2570                                 ? "elves"
2571                                 : (context.warntype.polyd & M2_ORC)
2572                                       ? "orcs"
2573                                       : (context.warntype.polyd & M2_DEMON)
2574                                             ? "demons"
2575                                             : "certain monsters");
2576         you_are(buf, "");
2577 #else
2578         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2579                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2580                  == (M2_HUMAN | M2_ELF))
2581                     ? "\90l\8aÔ\82Æ\83G\83\8b\83t"
2582                     : (context.warntype.polyd & M2_HUMAN)
2583                           ? "\90l\8aÔ"
2584                           : (context.warntype.polyd & M2_ELF)
2585                                 ? "\83G\83\8b\83t"
2586                                 : (context.warntype.polyd & M2_ORC)
2587                                       ? "\83I\81[\83N"
2588                                       : (context.warntype.polyd & M2_DEMON)
2589                                             ? "\88«\96\82"
2590                                             : "\82 \82é\8eí\82Ì\89ö\95¨");
2591         you_have(buf, "");
2592 #endif
2593     }
2594     if (Warn_of_mon && context.warntype.speciesidx) {
2595 #if 0 /*JP*/
2596         Sprintf(buf, "aware of the presence of %s",
2597                 makeplural(mons[context.warntype.speciesidx].mname));
2598         you_are(buf, from_what(WARN_OF_MON));
2599 #else
2600         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2601                 mons[context.warntype.speciesidx].mname);
2602         you_have(buf, from_what(WARN_OF_MON));
2603 #endif
2604     }
2605     if (Undead_warning)
2606 /*JP
2607         you_are("warned of undead", from_what(WARN_UNDEAD));
2608 */
2609         you_have("\95s\8e\80\82Ì\90\95¨\82Ö\82Ì\8cx\89ú\94\\97Í", from_what(WARN_UNDEAD));
2610     if (Searching)
2611 /*JP
2612         you_have("automatic searching", from_what(SEARCHING));
2613 */
2614         you_have("\92T\8d¸\94\\97Í", from_what(SEARCHING));
2615     if (Clairvoyant)
2616 /*JP
2617         you_are("clairvoyant", from_what(CLAIRVOYANT));
2618 */
2619         you_have("\90ç\97¢\8aá\94\\97Í", from_what(CLAIRVOYANT));
2620     else if ((HClairvoyant || EClairvoyant) && BClairvoyant) {
2621         Strcpy(buf, from_what(-CLAIRVOYANT));
2622 #if 0 /*JP*/
2623         if (!strncmp(buf, " because of ", 12))
2624             /* overwrite substring; strncpy doesn't add terminator */
2625             (void) strncpy(buf, " if not for ", 12);
2626         enl_msg(You_, "could be", "could have been", " clairvoyant", buf);
2627 #else
2628         /*JP:\81u\81c\82É\82æ\82Á\82Ä\81v*/
2629         if (!strncmp(buf, "\82É\82æ\82Á\82Ä", 8))
2630             /*JP:\81u\81c\82ª\82È\82¯\82ê\82Î\81v\82É\8f\91\82«\8a·\82¦\82é*/
2631             strcpy(eos(buf) - 8, "\82ª\82È\82¯\82ê\82Î");
2632         you_have("\90ç\97¢\8aá\94\\97Í", buf);
2633 #endif
2634     }
2635     if (Infravision)
2636 /*JP
2637         you_have("infravision", from_what(INFRAVISION));
2638 */
2639         you_have("\90Ô\8aO\90ü\82ª\8c©\82¦\82é\8e\8b\8ao", from_what(INFRAVISION));
2640     if (Detect_monsters)
2641 /*JP
2642         you_are("sensing the presence of monsters", "");
2643 */
2644         you_have("\89ö\95¨\82ð\92T\82·\94\\97Í", "");
2645     if (u.umconf)
2646 /*JP
2647         you_are("going to confuse monsters", "");
2648 */
2649         you_have("\89ö\95¨\82ð\8d¬\97\90\82³\82¹\82é\94\\97Í", "");
2650
2651     /*** Appearance and behavior ***/
2652     if (Adornment) {
2653         int adorn = 0;
2654
2655         if (uleft && uleft->otyp == RIN_ADORNMENT)
2656             adorn += uleft->spe;
2657         if (uright && uright->otyp == RIN_ADORNMENT)
2658             adorn += uright->spe;
2659         /* the sum might be 0 (+0 ring or two which negate each other);
2660            that yields "you are charismatic" (which isn't pointless
2661            because it potentially impacts seduction attacks) */
2662 #if 0 /*JP*/
2663         Sprintf(buf, "%scharismatic",
2664                 (adorn > 0) ? "more " : (adorn < 0) ? "less " : "");
2665         you_are(buf, from_what(ADORNED));
2666 #else
2667         Sprintf(buf, "\96£\97Í%s\82Ä",
2668                 (adorn > 0) ? "\82ª\91\9d\89Á\82µ" : (adorn < 0) ? "\82ª\8c¸\8f­\82µ" : "\93I\82É\82È\82Á");
2669         enl_msg(You_, "\82Ä\82¢\82é", "\82½", buf, "");
2670 #endif
2671     }
2672     if (Invisible)
2673 /*JP
2674         you_are("invisible", from_what(INVIS));
2675 */
2676         you_are("\93§\96¾", from_what(INVIS));
2677     else if (Invis)
2678 /*JP
2679         you_are("invisible to others", from_what(INVIS));
2680 */
2681         you_are("\91¼\90l\82É\91Î\82µ\82Ä\93§\96¾", from_what(INVIS));
2682     /* ordinarily "visible" is redundant; this is a special case for
2683        the situation when invisibility would be an expected attribute */
2684     else if ((HInvis || EInvis) && BInvis)
2685 /*JP
2686         you_are("visible", from_what(-INVIS));
2687 */
2688         you_are("\95s\93§\96¾", from_what(-INVIS));
2689     if (Displaced)
2690 /*JP
2691         you_are("displaced", from_what(DISPLACED));
2692 */
2693         you_have("\8c\89e\94\\97Í", from_what(DISPLACED));
2694     if (Stealth)
2695 /*JP
2696         you_are("stealthy", from_what(STEALTH));
2697 */
2698         you_have("\90l\96Ú\82ð\93\90\82Þ\94\\97Í", from_what(STEALTH));
2699     if (Aggravate_monster)
2700 #if 0 /*JP*/
2701         enl_msg("You aggravate", "", "d", " monsters",
2702                 from_what(AGGRAVATE_MONSTER));
2703 #else
2704         you_are_ing("\94½\8a´\82ð\82©\82Á\82Ä", from_what(AGGRAVATE_MONSTER));
2705 #endif
2706     if (Conflict)
2707 /*JP
2708         enl_msg("You cause", "", "d", " conflict", from_what(CONFLICT));
2709 */
2710         you_are_ing("\93¬\91\88\82ð\88ø\82«\8bN\82±\82µ\82Ä", from_what(CONFLICT));
2711
2712     /*** Transportation ***/
2713     if (Jumping)
2714 /*JP
2715         you_can("jump", from_what(JUMPING));
2716 */
2717         you_can("\92µ\96ô\82·\82é\82±\82Æ\82ª", from_what(JUMPING));
2718     if (Teleportation)
2719 /*JP
2720         you_can("teleport", from_what(TELEPORT));
2721 */
2722         you_can("\8fu\8aÔ\88Ú\93®\82ª", from_what(TELEPORT));
2723     if (Teleport_control)
2724 /*JP
2725         you_have("teleport control", from_what(TELEPORT_CONTROL));
2726 */
2727         you_have("\8fu\8aÔ\88Ú\93®\82Ì\90§\8cä\94\\97Í", from_what(TELEPORT_CONTROL));
2728     /* actively levitating handled earlier as a status condition */
2729     if (BLevitation) { /* levitation is blocked */
2730         long save_BLev = BLevitation;
2731
2732         BLevitation = 0L;
2733         if (Levitation)
2734 #if 0 /*JP*/
2735             enl_msg(You_, "would levitate", "would have levitated",
2736                     if_surroundings_permitted, "");
2737 #else
2738             you_are("\95\82\97V\8fó\91Ô", "");
2739 #endif
2740         BLevitation = save_BLev;
2741     }
2742     /* actively flying handled earlier as a status condition */
2743     if (BFlying) { /* flight is blocked */
2744         long save_BFly = BFlying;
2745
2746         BFlying = 0L;
2747         if (Flying)
2748 #if 0 /*JP*/
2749             enl_msg(You_, "would fly", "would have flown",
2750                     Levitation
2751                        ? "if you weren't levitating"
2752                        : (save_BFly == FROMOUTSIDE)
2753                           ? if_surroundings_permitted
2754                           /* both surroundings and [latent] levitation */
2755                           : " if circumstances permitted",
2756                     "");
2757 #else
2758             you_can("\94ò\82Ô\82±\82Æ\82ª", "");
2759 #endif
2760         BFlying = save_BFly;
2761     }
2762     /* actively walking on water handled earlier as a status condition */
2763     if (Wwalking && !walking_on_water())
2764 /*JP
2765         you_can("walk on water", from_what(WWALKING));
2766 */
2767         you_can("\90\85\82Ì\8fã\82ð\95à\82­\82±\82Æ\82ª", from_what(WWALKING));
2768     /* actively swimming (in water but not under it) handled earlier */
2769     if (Swimming && (Underwater || !u.uinwater))
2770 /*JP
2771         you_can("swim", from_what(SWIMMING));
2772 */
2773         you_can("\89j\82®\82±\82Æ\82ª", from_what(SWIMMING));
2774     if (Breathless)
2775 /*JP
2776         you_can("survive without air", from_what(MAGICAL_BREATHING));
2777 */
2778         you_can("\8bó\8bC\82È\82µ\82Å\90\82«\89\84\82Ñ\82é\82±\82Æ\82ª", from_what(MAGICAL_BREATHING));
2779     else if (Amphibious)
2780 /*JP
2781         you_can("breathe water", from_what(MAGICAL_BREATHING));
2782 */
2783         you_can("\90\85\92\86\82Å\8cÄ\8bz\82ª", from_what(MAGICAL_BREATHING));
2784     if (Passes_walls)
2785 /*JP
2786         you_can("walk through walls", from_what(PASSES_WALLS));
2787 */
2788         you_can("\95Ç\82ð\92Ê\82è\94²\82¯\82é\82±\82Æ\82ª", from_what(PASSES_WALLS));
2789
2790     /*** Physical attributes ***/
2791     if (Regeneration)
2792 /*JP
2793         enl_msg("You regenerate", "", "d", "", from_what(REGENERATION));
2794 */
2795         you_have("\8dÄ\90\94\\97Í", from_what(REGENERATION));
2796     if (Slow_digestion)
2797 /*JP
2798         you_have("slower digestion", from_what(SLOW_DIGESTION));
2799 */
2800         enl_msg("\90H\95¨\82Ì\8fÁ\89»\82ª\92x", "\82¢", "\82©\82Á\82½", "", from_what(SLOW_DIGESTION));
2801     if (u.uhitinc)
2802 /*JP
2803         you_have(enlght_combatinc("to hit", u.uhitinc, final, buf), "");
2804 */
2805         you_have(enlght_combatinc("\96½\92\86\97¦", u.uhitinc, final, buf), "");
2806     if (u.udaminc)
2807 /*JP
2808         you_have(enlght_combatinc("damage", u.udaminc, final, buf), "");
2809 */
2810         you_have(enlght_combatinc("\83_\83\81\81[\83W", u.udaminc, final, buf), "");
2811     if (u.uspellprot || Protection) {
2812         int prot = 0;
2813
2814         if (uleft && uleft->otyp == RIN_PROTECTION)
2815             prot += uleft->spe;
2816         if (uright && uright->otyp == RIN_PROTECTION)
2817             prot += uright->spe;
2818         if (HProtection & INTRINSIC)
2819             prot += u.ublessed;
2820         prot += u.uspellprot;
2821         if (prot)
2822 /*JP
2823             you_have(enlght_combatinc("defense", prot, final, buf), "");
2824 */
2825             you_have(enlght_combatinc("\96h\8cä", prot, final, buf), "");
2826     }
2827     if ((armpro = magic_negation(&youmonst)) > 0) {
2828         /* magic cancellation factor, conferred by worn armor */
2829         static const char *const mc_types[] = {
2830 #if 0 /*JP*/
2831             "" /*ordinary*/, "warded", "guarded", "protected",
2832 #else
2833             "" /*ordinary*/, "\89q\82ç\82ê\82Ä", "\8cì\82ç\82ê\82Ä", "\8eç\82ç\82ê\82Ä",
2834 #endif
2835         };
2836         /* sanity check */
2837         if (armpro >= SIZE(mc_types))
2838             armpro = SIZE(mc_types) - 1;
2839 /*JP
2840         you_are(mc_types[armpro], "");
2841 */
2842         you_are_ing(mc_types[armpro], "");
2843     }
2844     if (Half_physical_damage)
2845         enlght_halfdmg(HALF_PHDAM, final);
2846     if (Half_spell_damage)
2847         enlght_halfdmg(HALF_SPDAM, final);
2848     /* polymorph and other shape change */
2849     if (Protection_from_shape_changers)
2850 #if 0 /*JP*/
2851         you_are("protected from shape changers",
2852                 from_what(PROT_FROM_SHAPE_CHANGERS));
2853 #else
2854         you_have("\95Ï\89»\89ö\95¨\82Ö\82Ì\91Ï\90«", from_what(PROT_FROM_SHAPE_CHANGERS));
2855 #endif
2856     if (Unchanging) {
2857         const char *what = 0;
2858
2859         if (!Upolyd) /* Upolyd handled below after current form */
2860 /*JP
2861             you_can("not change from your current form",
2862 */
2863             you_are("\8c»\8dÝ\82Ì\8ep\82©\82ç\95Ï\89»\82Å\82«\82È\82¢\8fó\91Ô",
2864                     from_what(UNCHANGING));
2865         /* blocked shape changes */
2866         if (Polymorph)
2867 /*JP
2868             what = !final ? "polymorph" : "have polymorphed";
2869 */
2870             what = "\95Ï\89»\82µ\82Ä";
2871         else if (u.ulycn >= LOW_PM)
2872 /*JP
2873             what = !final ? "change shape" : "have changed shape";
2874 */
2875             what = "\8ep\82ð\95Ï\82¦\82Ä";
2876         if (what) {
2877 #if 0 /*JP*/
2878             Sprintf(buf, "would %s periodically", what);
2879             /* omit from_what(UNCHANGING); too verbose */
2880             enl_msg(You_, buf, buf, " if not locked into your current form",
2881                     "");
2882 #else
2883             Sprintf(buf, "\82à\82µ\8c»\8dÝ\82Ì\8ep\82É\8cÅ\92è\82³\82ê\82Ä\82¢\82È\82¯\82ê\82Î\92è\8aú\93I\82É%s", what);
2884             you_are_ing(buf, "");
2885 #endif
2886         }
2887     } else if (Polymorph) {
2888 /*JP
2889         you_are("polymorphing periodically", from_what(POLYMORPH));
2890 */
2891         you_are("\92è\8aú\93I\82É\95Ï\89»\82µ\82Ä", from_what(POLYMORPH));
2892     }
2893     if (Polymorph_control)
2894 /*JP
2895         you_have("polymorph control", from_what(POLYMORPH_CONTROL));
2896 */
2897         you_have("\95Ï\89»\82Ì\90§\8cä\94\\97Í", from_what(POLYMORPH_CONTROL));
2898     if (Upolyd && u.umonnum != u.ulycn) {
2899         /* foreign shape (except were-form which is handled below) */
2900 /*JP
2901         Sprintf(buf, "polymorphed into %s", an(youmonst.data->mname));
2902 */
2903         Sprintf(buf, "%s\82É\95Ï\89»\82µ\82Ä", youmonst.data->mname);
2904         if (wizard)
2905             Sprintf(eos(buf), " (%d)", u.mtimedone);
2906 /*JP
2907         you_are(buf, "");
2908 */
2909         you_are_ing(buf, "");
2910     }
2911     if (lays_eggs(youmonst.data) && flags.female) /* Upolyd */
2912 /*JP
2913         you_can("lay eggs", "");
2914 */
2915         you_can("\97\91\82ð\8eY\82Þ\82±\82Æ\82ª", "");
2916     if (u.ulycn >= LOW_PM) {
2917 #if 0 /*JP*/
2918         /* "you are a werecreature [in beast form]" */
2919         Strcpy(buf, an(mons[u.ulycn].mname));
2920         if (u.umonnum == u.ulycn) {
2921             Strcat(buf, " in beast form");
2922             if (wizard)
2923                 Sprintf(eos(buf), " (%d)", u.mtimedone);
2924         }
2925 #else
2926         /*JP:\81u\82 \82È\82½\82Í[\8fb\82Ì\8ep\82Ì]\81\9b\81\9b\90l\8aÔ\82Å\82 \82é\81v*/
2927         buf[0] = '\0';
2928         if (u.umonnum == u.ulycn) {
2929             Strcpy(buf, "\8fb\82Ì\8ep\82Ì");
2930             if (wizard)
2931                 Sprintf(eos(buf), " (%d)", u.mtimedone);
2932         }
2933         Strcat(buf, mons[u.ulycn].mname);
2934 #endif
2935         you_are(buf, "");
2936     }
2937     if (Unchanging && Upolyd) /* !Upolyd handled above */
2938 /*JP
2939         you_can("not change from your current form", from_what(UNCHANGING));
2940 */
2941         enl_msg("\8d¡\82Ì\8ep\82©\82ç\95Ï\89»\82·\82é\82±\82Æ\82ª\82Å\82«\82È", "\82¢", "\82©\82Á\82½", "", from_what(UNCHANGING));
2942     if (Hate_silver)
2943         you_are("harmed by silver", "");
2944     /* movement and non-armor-based protection */
2945     if (Fast)
2946 /*JP
2947         you_are(Very_fast ? "very fast" : "fast", from_what(FAST));
2948 */
2949         you_have(Very_fast ? "\82Æ\82Ä\82à\91f\91\81\82­\8ds\93®\82·\82é\94\\97Í" : "\91f\91\81\82­\8ds\93®\82·\82é\94\\97Í", from_what(FAST));
2950     if (Reflecting)
2951 /*JP
2952         you_have("reflection", from_what(REFLECTING));
2953 */
2954         you_have("\94½\8eË\94\\97Í", from_what(REFLECTING));
2955     if (Free_action)
2956 /*JP
2957         you_have("free action", from_what(FREE_ACTION));
2958 */
2959         you_have("\8dS\91©\82³\82ê\82È\82¢\94\\97Í", from_what(FREE_ACTION));
2960     if (Fixed_abil)
2961 /*JP
2962         you_have("fixed abilities", from_what(FIXED_ABIL));
2963 */
2964         enl_msg("\94\\97Í\82ª\95Ï\89»\82µ\82È", "\82¢", "\82©\82Á\82½", "", from_what(FIXED_ABIL));
2965     if (Lifesaved)
2966 /*JP
2967         enl_msg("Your life ", "will be", "would have been", " saved", "");
2968 */
2969         enl_msg("\82 \82È\82½\82Ì\90\96½\82Í\95Û\91\82³\82ê\82Ä", iru, ita, "", "");
2970
2971     /*** Miscellany ***/
2972     if (Luck) {
2973         ltmp = abs((int) Luck);
2974 #if 0 /*JP*/
2975         Sprintf(buf, "%s%slucky",
2976                 ltmp >= 10 ? "extremely " : ltmp >= 5 ? "very " : "",
2977                 Luck < 0 ? "un" : "");
2978 #else
2979         Sprintf(buf, "%s%s",
2980                 ltmp >= 10 ? "\96Ò\97ó\82É" : ltmp >= 5 ? "\82Æ\82Ä\82à" : "",
2981                 Luck < 0 ? "\95s\8dK" : "\8dK\95\9f");
2982 #endif
2983         if (wizard)
2984             Sprintf(eos(buf), " (%d)", Luck);
2985         you_are(buf, "");
2986     } else if (wizard)
2987 /*JP
2988         enl_msg("Your luck ", "is", "was", " zero", "");
2989 */
2990         enl_msg("\82 \82È\82½\82Ì\89^\82Í\83[\83\8d", "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2991     if (u.moreluck > 0)
2992 /*JP
2993         you_have("extra luck", "");
2994 */
2995         you_have("\82³\82ç\82È\82é\8dK\89^", "");
2996     else if (u.moreluck < 0)
2997 /*JP
2998         you_have("reduced luck", "");
2999 */
3000         you_have("\82³\82ç\82È\82é\95s\89^", "");
3001     if (carrying(LUCKSTONE) || stone_luck(TRUE)) {
3002         ltmp = stone_luck(0);
3003         if (ltmp <= 0)
3004 /*JP
3005             enl_msg("Bad luck ", "does", "did", " not time out for you", "");
3006 */
3007             enl_msg("\95s\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3008         if (ltmp >= 0)
3009 /*JP
3010             enl_msg("Good luck ", "does", "did", " not time out for you", "");
3011 */
3012             enl_msg("\8dK\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3013     }
3014
3015     if (u.ugangr) {
3016 #if 0 /*JP*/
3017         Sprintf(buf, " %sangry with you",
3018                 u.ugangr > 6 ? "extremely " : u.ugangr > 3 ? "very " : "");
3019 #else
3020         Sprintf(buf, "%s\82Í%s\93{\82Á\82Ä%s", u_gname(),
3021                 u.ugangr > 6 ? "\96Ò\97ó\82É" : u.ugangr > 3 ? "\82Æ\82Ä\82à" : "", final ? ita : iru);
3022 #endif
3023         if (wizard)
3024             Sprintf(eos(buf), " (%d)", u.ugangr);
3025 #if 0 /*JP*/
3026         enl_msg(u_gname(), " is", " was", buf, "");
3027 #else
3028         enl_msg(buf, "", "", "", "");
3029 #endif
3030     } else {
3031         /*
3032          * We need to suppress this when the game is over, because death
3033          * can change the value calculated by can_pray(), potentially
3034          * resulting in a false claim that you could have prayed safely.
3035          */
3036         if (!final) {
3037 #if 0 /*JP*/
3038 #if 0
3039             /* "can [not] safely pray" vs "could [not] have safely prayed" */
3040             Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
3041                     final ? "have " : "", final ? "ed" : "");
3042 #else
3043             Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
3044 #endif
3045             if (wizard)
3046                 Sprintf(eos(buf), " (%d)", u.ublesscnt);
3047             you_can(buf, "");
3048 #else /*JP*/
3049             Sprintf(buf, "\82 \82È\82½\82Í\88À\91S\82É\8bF\82é\82±\82Æ\82ª");
3050             Strcat(buf, can_pray(FALSE) ? can : "\82Å\82«\82È\82¢");
3051             if (wizard)
3052               Sprintf(eos(buf), " (%d)", u.ublesscnt);
3053             enl_msg(buf, "", "", "", "");
3054 #endif
3055         }
3056     }
3057
3058     /* named fruit debugging (doesn't really belong here...) */
3059     if (wizard) {
3060         int fcount = 0;
3061         struct fruit *f;
3062         char buf2[BUFSZ];
3063
3064         for (f = ffruit; f; f = f->nextf) {
3065 /*JP
3066             Sprintf(buf, "Fruit %d ", ++fcount);
3067 */
3068             Sprintf(buf, "fruit %d \82Í", ++fcount);
3069             Sprintf(buf2, "%s (id %d)", f->fname, f->fid);
3070 /*JP
3071             enl_msg(buf, "is ", "was ", buf2, "");
3072 */
3073             enl_msg(buf, "\82¾", "\82¾\82Á\82½", buf2, "");
3074         }
3075 /*JP
3076         enl_msg("The current fruit ", "is ", "was ", pl_fruit, "");
3077 */
3078         enl_msg("\8c»\8dÝ\82Ì fruit \82Í", "\82¾", "\82¾\82Á\82½", pl_fruit, "");
3079         Sprintf(buf, "%d", flags.made_fruit);
3080 /*JP
3081         enl_msg("The made fruit flag ", "is ", "was ", buf, "");
3082 */
3083         enl_msg("made fruit flag \82Í", "\82¾", "\82¾\82Á\82½", buf, "");
3084     }
3085
3086     {
3087         const char *p;
3088
3089         buf[0] = '\0';
3090         if (final < 2) { /* still in progress, or quit/escaped/ascended */
3091 /*JP
3092             p = "survived after being killed ";
3093 */
3094             p = "\8e\80\82ñ\82¾\8cã\95\9c\8a\88\82µ\82Ä\82¢\82½";
3095             switch (u.umortality) {
3096             case 0:
3097 /*JP
3098                 p = !final ? (char *) 0 : "survived";
3099 */
3100                 p = !final ? (char *)0 : "\90\82«\89\84\82Ñ\82½";
3101                 break;
3102             case 1:
3103 /*JP
3104                 Strcpy(buf, "once");
3105 */
3106                 Strcpy(buf, "\88ê\93x");
3107                 break;
3108             case 2:
3109 /*JP
3110                 Strcpy(buf, "twice");
3111 */
3112                 Strcpy(buf, "\93ñ\93x");
3113                 break;
3114             case 3:
3115 /*JP
3116                 Strcpy(buf, "thrice");
3117 */
3118                 Strcpy(buf, "\8eO\93x");
3119                 break;
3120             default:
3121 /*JP
3122                 Sprintf(buf, "%d times", u.umortality);
3123 */
3124                 Sprintf(buf, "%d\89ñ", u.umortality);
3125                 break;
3126             }
3127         } else { /* game ended in character's death */
3128 /*JP
3129             p = "are dead";
3130 */
3131             p = "\8e\80\82ñ\82Å\82¢\82é";
3132             switch (u.umortality) {
3133             case 0:
3134                 impossible("dead without dying?");
3135             case 1:
3136                 break; /* just "are dead" */
3137             default:
3138 #if 0 /*JP*/
3139                 Sprintf(buf, " (%d%s time!)", u.umortality,
3140                         ordin(u.umortality));
3141 #else
3142                  Sprintf(buf, "(%d\89ñ\81I)", u.umortality);
3143 #endif
3144                 break;
3145             }
3146         }
3147         if (p)
3148 /*JP
3149             enl_msg(You_, "have been killed ", p, buf, "");
3150 */
3151             enl_msg(You_, "\8e\80\82ñ\82Å\82¢\82é", p, buf, "");
3152     }
3153 }
3154
3155 #if 0  /* no longer used */
3156 STATIC_DCL boolean NDECL(minimal_enlightenment);
3157
3158 /*
3159  * Courtesy function for non-debug, non-explorer mode players
3160  * to help refresh them about who/what they are.
3161  * Returns FALSE if menu cancelled (dismissed with ESC), TRUE otherwise.
3162  */
3163 STATIC_OVL boolean
3164 minimal_enlightenment()
3165 {
3166     winid tmpwin;
3167     menu_item *selected;
3168     anything any;
3169     int genidx, n;
3170     char buf[BUFSZ], buf2[BUFSZ];
3171     static const char untabbed_fmtstr[] = "%-15s: %-12s";
3172     static const char untabbed_deity_fmtstr[] = "%-17s%s";
3173     static const char tabbed_fmtstr[] = "%s:\t%-12s";
3174     static const char tabbed_deity_fmtstr[] = "%s\t%s";
3175     static const char *fmtstr;
3176     static const char *deity_fmtstr;
3177
3178     fmtstr = iflags.menu_tab_sep ? tabbed_fmtstr : untabbed_fmtstr;
3179     deity_fmtstr = iflags.menu_tab_sep ? tabbed_deity_fmtstr
3180                                        : untabbed_deity_fmtstr;
3181     any = zeroany;
3182     buf[0] = buf2[0] = '\0';
3183     tmpwin = create_nhwindow(NHW_MENU);
3184     start_menu(tmpwin);
3185     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3186 /*JP
3187              "Starting", FALSE);
3188 */
3189              "\8aJ\8en", FALSE);
3190
3191     /* Starting name, race, role, gender */
3192 /*JP
3193     Sprintf(buf, fmtstr, "name", plname);
3194 */
3195     Sprintf(buf, fmtstr, "\96¼\91O", plname);
3196     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3197 /*JP
3198     Sprintf(buf, fmtstr, "race", urace.noun);
3199 */
3200     Sprintf(buf, fmtstr, "\8eí\91°", urace.noun);
3201     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3202 /*JP
3203     Sprintf(buf, fmtstr, "role",
3204 */
3205     Sprintf(buf, fmtstr, "\90E\8bÆ",
3206             (flags.initgend && urole.name.f) ? urole.name.f : urole.name.m);
3207     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3208 /*JP
3209     Sprintf(buf, fmtstr, "gender", genders[flags.initgend].adj);
3210 */
3211     Sprintf(buf, fmtstr, "\90«\95Ê", genders[flags.initgend].adj);
3212     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3213
3214     /* Starting alignment */
3215 /*JP
3216     Sprintf(buf, fmtstr, "alignment", align_str(u.ualignbase[A_ORIGINAL]));
3217 */
3218     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualignbase[A_ORIGINAL]));
3219     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3220
3221     /* Current name, race, role, gender */
3222     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3223     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3224 /*JP
3225              "Current", FALSE);
3226 */
3227              "\8c»\8dÝ", FALSE);
3228 /*JP
3229     Sprintf(buf, fmtstr, "race", Upolyd ? youmonst.data->mname : urace.noun);
3230 */
3231     Sprintf(buf, fmtstr, "\8eí\91°", Upolyd ? youmonst.data->mname : urace.noun);
3232     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3233     if (Upolyd) {
3234 /*JP
3235         Sprintf(buf, fmtstr, "role (base)",
3236 */
3237         Sprintf(buf, fmtstr, "\90E\8bÆ(\8aî\96{)",
3238                 (u.mfemale && urole.name.f) ? urole.name.f
3239                                             : urole.name.m);
3240         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3241     } else {
3242 /*JP
3243         Sprintf(buf, fmtstr, "role",
3244 */
3245         Sprintf(buf, fmtstr, "\90E\8bÆ",
3246                 (flags.female && urole.name.f) ? urole.name.f
3247                                                : urole.name.m);
3248         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3249     }
3250     /* don't want poly_gender() here; it forces `2' for non-humanoids */
3251     genidx = is_neuter(youmonst.data) ? 2 : flags.female;
3252 /*JP
3253     Sprintf(buf, fmtstr, "gender", genders[genidx].adj);
3254 */
3255     Sprintf(buf, fmtstr, "\90«\95Ê", genders[genidx].adj);
3256     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3257     if (Upolyd && (int) u.mfemale != genidx) {
3258 /*JP
3259         Sprintf(buf, fmtstr, "gender (base)", genders[u.mfemale].adj);
3260 */
3261         Sprintf(buf, fmtstr, "\90«\95Ê(\8aî\96{)", genders[u.mfemale].adj);
3262         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3263     }
3264
3265     /* Current alignment */
3266 /*JP
3267     Sprintf(buf, fmtstr, "alignment", align_str(u.ualign.type));
3268 */
3269     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualign.type));
3270     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3271
3272     /* Deity list */
3273     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3274     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3275 /*JP
3276              "Deities", FALSE);
3277 */
3278              "\90_", FALSE);
3279 #if 0 /*JP*/
3280     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3281             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3282              && u.ualign.type == A_CHAOTIC)               ? " (s,c)"
3283                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (s)"
3284                 : (u.ualign.type   == A_CHAOTIC)          ? " (c)" : "");
3285 #else
3286     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3287             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3288              && u.ualign.type == A_CHAOTIC)               ? " (\8f\89\81C\8c»)"
3289                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (\8f\89)"
3290                 : (u.ualign.type   == A_CHAOTIC)          ? " (\8c»)" : "");
3291 #endif
3292 /*JP
3293     Sprintf(buf, fmtstr, "Chaotic", buf2);
3294 */
3295     Sprintf(buf, fmtstr, "\8d¬\93×", buf2);
3296     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3297
3298 #if 0 /*JP*/
3299     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3300             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3301              && u.ualign.type == A_NEUTRAL)               ? " (s,c)"
3302                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (s)"
3303                 : (u.ualign.type   == A_NEUTRAL)          ? " (c)" : "");
3304 #else
3305     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3306             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3307              && u.ualign.type == A_NEUTRAL)               ? " (\8f\89\81C\8c»)"
3308                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (\8f\89)"
3309                 : (u.ualign.type   == A_NEUTRAL)          ? " (\8c»)" : "");
3310 #endif
3311 /*JP
3312     Sprintf(buf, fmtstr, "Neutral", buf2);
3313 */
3314     Sprintf(buf, fmtstr, "\92\86\97§", buf2);
3315     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3316
3317 #if 0 /*JP*/
3318     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3319             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3320              && u.ualign.type == A_LAWFUL)                ? " (s,c)"
3321                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (s)"
3322                 : (u.ualign.type   == A_LAWFUL)           ? " (c)" : "");
3323 #else
3324     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3325             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3326              && u.ualign.type == A_LAWFUL)                ? " (\8f\89\81C\8c»)"
3327                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (\8f\89)"
3328                 : (u.ualign.type   == A_LAWFUL)           ? " (\8c»)" : "");
3329 #endif
3330 /*JP
3331     Sprintf(buf, fmtstr, "Lawful", buf2);
3332 */
3333     Sprintf(buf, fmtstr, "\92\81\8f\98", buf2);
3334     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3335
3336 /*JP
3337     end_menu(tmpwin, "Base Attributes");
3338 */
3339     end_menu(tmpwin, "\8aî\96{\91®\90«");
3340     n = select_menu(tmpwin, PICK_NONE, &selected);
3341     destroy_nhwindow(tmpwin);
3342     return (boolean) (n != -1);
3343 }
3344 #endif /*0*/
3345
3346 /* ^X command */
3347 STATIC_PTR int
3348 doattributes(VOID_ARGS)
3349 {
3350     int mode = BASICENLIGHTENMENT;
3351
3352     /* show more--as if final disclosure--for wizard and explore modes */
3353     if (wizard || discover)
3354         mode |= MAGICENLIGHTENMENT;
3355
3356     enlightenment(mode, ENL_GAMEINPROGRESS);
3357     return 0;
3358 }
3359
3360 void
3361 youhiding(via_enlghtmt, msgflag)
3362 boolean via_enlghtmt; /* englightment line vs topl message */
3363 int msgflag;          /* for variant message phrasing */
3364 {
3365     char *bp, buf[BUFSZ];
3366
3367 /*JP
3368     Strcpy(buf, "hiding");
3369 */
3370     Strcpy(buf, "\89B\82ê");
3371     if (youmonst.m_ap_type != M_AP_NOTHING) {
3372         /* mimic; hero is only able to mimic a strange object or gold
3373            or hallucinatory alternative to gold, so we skip the details
3374            for the hypothetical furniture and monster cases */
3375 #if 0 /*JP*//*\8cã\82ë\82É\89ñ\82·*/
3376         bp = eos(strcpy(buf, "mimicking"));
3377 #endif
3378         if (youmonst.m_ap_type == M_AP_OBJECT) {
3379 /*JP
3380             Sprintf(bp, " %s", an(simple_typename(youmonst.mappearance)));
3381 */
3382             Strcpy(buf, simple_typename(youmonst.mappearance));
3383         } else if (youmonst.m_ap_type == M_AP_FURNITURE) {
3384 /*JP
3385             Strcpy(bp, " something");
3386 */
3387             Strcpy(buf, "\89½\82©");
3388         } else if (youmonst.m_ap_type == M_AP_MONSTER) {
3389 /*JP
3390             Strcpy(bp, " someone");
3391 */
3392             Strcpy(buf, "\89½\8eÒ\82©");
3393         } else {
3394             ; /* something unexpected; leave 'buf' as-is */
3395         }
3396 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3397         Strcat(buf, "\82Ì\82Ó\82è\82ð\82µ");
3398 #endif
3399     } else if (u.uundetected) {
3400         bp = eos(buf); /* points past "hiding" */
3401         if (youmonst.data->mlet == S_EEL) {
3402             if (is_pool(u.ux, u.uy))
3403 /*JP
3404                 Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy));
3405 */
3406                 Sprintf(bp, "%s\82Ì\92\86\82É", waterbody_name(u.ux, u.uy));
3407         } else if (hides_under(youmonst.data)) {
3408             struct obj *o = level.objects[u.ux][u.uy];
3409
3410             if (o)
3411 /*JP
3412                 Sprintf(bp, " underneath %s", ansimpleoname(o));
3413 */
3414                 Sprintf(bp, "%s\82Ì\89º\82É", ansimpleoname(o));
3415         } else if (is_clinger(youmonst.data) || Flying) {
3416             /* Flying: 'lurker above' hides on ceiling but doesn't cling */
3417 /*JP
3418             Sprintf(bp, " on the %s", ceiling(u.ux, u.uy));
3419 */
3420             Sprintf(bp, "%s\82É", ceiling(u.ux, u.uy));
3421         } else {
3422             /* on floor; is_hider() but otherwise not special: 'trapper' */
3423             if (u.utrap && u.utraptype == TT_PIT) {
3424                 struct trap *t = t_at(u.ux, u.uy);
3425
3426 #if 0 /*JP*/
3427                 Sprintf(bp, " in a %spit",
3428                         (t && t->ttyp == SPIKED_PIT) ? "spiked " : "");
3429 #else
3430                 Sprintf(bp, "%s\97\8e\82µ\8c\8a\82Ì\92\86\82É",
3431                         (t && t->ttyp == SPIKED_PIT) ? "\83g\83Q\82¾\82ç\82¯\82Ì" : "");
3432 #endif
3433             } else
3434 /*JP
3435                 Sprintf(bp, " on the %s", surface(u.ux, u.uy));
3436 */
3437                 Sprintf(bp, "%s\82É", surface(u.ux, u.uy));
3438         }
3439 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3440         Strcat(buf, "\89B\82ê");
3441 #endif
3442     } else {
3443         ; /* shouldn't happen; will result in generic "you are hiding" */
3444     }
3445
3446     if (via_enlghtmt) {
3447         int final = msgflag; /* 'final' is used by you_are() macro */
3448
3449 /*JP
3450         you_are(buf, "");
3451 */
3452         enl_msg(buf, "\82Ä\82¢\82é", "\82Ä\82¢\82½", "", "");
3453     } else {
3454         /* for dohide(), when player uses '#monster' command */
3455 #if 0 /*JP*/
3456         You("are %s %s.", msgflag ? "already" : "now", buf);
3457 #else
3458         if (msgflag) {
3459             You("\82·\82Å\82É%s\82Ä\82¢\82é\81D", buf);
3460         } else {
3461             You("%s\82½\81D", buf);
3462         }
3463 #endif
3464     }
3465 }
3466
3467 /* KMH, #conduct
3468  * (shares enlightenment's tense handling)
3469  */
3470 STATIC_PTR int
3471 doconduct(VOID_ARGS)
3472 {
3473     show_conduct(0);
3474     return 0;
3475 }
3476
3477 void
3478 show_conduct(final)
3479 int final;
3480 {
3481     char buf[BUFSZ];
3482     int ngenocided;
3483
3484     /* Create the conduct window */
3485     en_win = create_nhwindow(NHW_MENU);
3486 /*JP
3487     putstr(en_win, 0, "Voluntary challenges:");
3488 */
3489     putstr(en_win, 0, "\8e©\94­\93I\92§\90í:");
3490
3491     if (u.uroleplay.blind)
3492 /*JP
3493         you_have_been("blind from birth");
3494 */
3495         you_have_been("\90\82Ü\82ê\82È\82ª\82ç\82É\96Ó\96Ú");
3496     if (u.uroleplay.nudist)
3497 /*JP
3498         you_have_been("faithfully nudist");
3499 */
3500         you_have_been("\92\89\8eÀ\82È\97\87\91°");
3501
3502     if (!u.uconduct.food)
3503 /*JP
3504         enl_msg(You_, "have gone", "went", " without food", "");
3505 */
3506         enl_msg("\82 \82È\82½\82Í\90H\8e\96\82ð\82µ", "\82Ä\82¢\82È\82¢", "\82È\82©\82Á\82½", "", "");
3507     /* But beverages are okay */
3508     else if (!u.uconduct.unvegan)
3509 /*JP
3510         you_have_X("followed a strict vegan diet");
3511 */
3512         you_have_been("\8cµ\8ai\82È\8dØ\90H\8eå\8b`\8eÒ");
3513     else if (!u.uconduct.unvegetarian)
3514 /*JP
3515         you_have_been("vegetarian");
3516 */
3517         you_have_been("\8dØ\90H\8eå\8b`\8eÒ");
3518
3519     if (!u.uconduct.gnostic)
3520 /*JP
3521         you_have_been("an atheist");
3522 */
3523         you_have_been("\96³\90_\98_\8eÒ");
3524
3525     if (!u.uconduct.weaphit) {
3526 /*JP
3527         you_have_never("hit with a wielded weapon");
3528 */
3529         you_have_never("\82 \82È\82½\82Í\91\95\94õ\82µ\82Ä\82¢\82é\95\90\8aí\82Å\8dU\8c\82\82µ");
3530     } else if (wizard) {
3531 #if 0 /*JP*/
3532         Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit,
3533                 plur(u.uconduct.weaphit));
3534         you_have_X(buf);
3535 #else
3536         Sprintf(buf, "\82 \82È\82½\82Í%ld\89ñ\91\95\94õ\82µ\82½\95\90\8aí\82ð\8eg\97p\82µ", u.uconduct.weaphit);
3537         you_have_X(buf);
3538 #endif
3539     }
3540     if (!u.uconduct.killer)
3541 /*JP
3542         you_have_been("a pacifist");
3543 */
3544         you_have_been("\95½\98a\8eå\8b`\8eÒ");
3545
3546     if (!u.uconduct.literate) {
3547 /*JP
3548         you_have_been("illiterate");
3549 */
3550         you_have_never("\82 \82È\82½\82Í\93Ç\82Ý\8f\91\82«\82µ");
3551     } else if (wizard) {
3552 #if 0 /*JP*/
3553         Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate,
3554                 plur(u.uconduct.literate));
3555         you_have_X(buf);
3556 #else
3557         Sprintf(buf, "%ld\89ñ\93Ç\82ñ\82¾\82è\8f\91\82¢\82½\82è\82µ", u.uconduct.literate);
3558         you_have_X(buf);
3559 #endif
3560     }
3561
3562     ngenocided = num_genocides();
3563     if (ngenocided == 0) {
3564 /*JP
3565         you_have_never("genocided any monsters");
3566 */
3567         you_have_never("\82 \82È\82½\82Í\89ö\95¨\82ð\8bs\8eE\82µ");
3568     } else {
3569 #if 0 /*JP*/
3570         Sprintf(buf, "genocided %d type%s of monster%s", ngenocided,
3571                 plur(ngenocided), plur(ngenocided));
3572         you_have_X(buf);
3573 #else
3574         Sprintf(buf, "%d\8eí\82Ì\89ö\95¨\82ð\8bs\8eE\82µ", ngenocided);
3575         you_have_X(buf);
3576 #endif
3577     }
3578
3579     if (!u.uconduct.polypiles) {
3580 /*JP
3581         you_have_never("polymorphed an object");
3582 */
3583         you_have_never("\82 \82È\82½\82Í\95¨\91Ì\82ð\95Ï\89»\82³\82¹");
3584     } else if (wizard) {
3585 #if 0 /*JP*/
3586         Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles,
3587                 plur(u.uconduct.polypiles));
3588         you_have_X(buf);
3589 #else
3590         Sprintf(buf, "%ld\8cÂ\82Ì\93¹\8bï\82ð\95Ï\89»\82³\82¹", u.uconduct.polypiles);
3591         you_have_X(buf);
3592 #endif
3593     }
3594
3595     if (!u.uconduct.polyselfs) {
3596 /*JP
3597         you_have_never("changed form");
3598 */
3599         you_have_never("\82 \82È\82½\82Í\95Ï\89»\82µ");
3600     } else if (wizard) {
3601 #if 0 /*JP*/
3602         Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs,
3603                 plur(u.uconduct.polyselfs));
3604         you_have_X(buf);
3605 #else
3606         Sprintf(buf, "%ld\89ñ\8ep\82ð\95Ï\82¦", u.uconduct.polyselfs);
3607         you_have_X(buf);
3608 #endif
3609     }
3610
3611     if (!u.uconduct.wishes) {
3612 /*JP
3613         you_have_X("used no wishes");
3614 */
3615         you_have_never("\82 \82È\82½\82Í\8aè\82¢\8e\96\82ð\82µ");
3616     } else {
3617 #if 0 /*JP*/
3618         Sprintf(buf, "used %ld wish%s", u.uconduct.wishes,
3619                 (u.uconduct.wishes > 1L) ? "es" : "");
3620         you_have_X(buf);
3621 #else
3622         Sprintf(buf, "%ld\89ñ\8aè\82¢\8e\96\82ð\82µ", u.uconduct.wishes);
3623         you_have_X(buf);
3624 #endif
3625
3626         if (!u.uconduct.wisharti)
3627 #if 0 /*JP*/
3628             enl_msg(You_, "have not wished", "did not wish",
3629                     " for any artifacts", "");
3630 #else
3631             enl_msg("\82 \82È\82½\82Í\90¹\8aí\82ð\8aè", "\82Á\82Ä\82¢\82È\82¢", "\82í\82È\82©\82Á\82½", "", "");
3632 #endif
3633     }
3634
3635     /* Pop up the window and wait for a key */
3636     display_nhwindow(en_win, TRUE);
3637     destroy_nhwindow(en_win);
3638     en_win = WIN_ERR;
3639 }
3640
3641 #ifndef M
3642 #ifndef NHSTDC
3643 #define M(c) (0x80 | (c))
3644 #else
3645 #define M(c) ((c) -128)
3646 #endif /* NHSTDC */
3647 #endif
3648 #ifndef C
3649 #define C(c) (0x1f & (c))
3650 #endif
3651
3652 static const struct func_tab cmdlist[] = {
3653     { C('d'), FALSE, dokick }, /* "D" is for door!...?  Msg is in dokick.c */
3654     { C('e'), TRUE, wiz_detect },
3655     { C('f'), TRUE, wiz_map },
3656     { C('g'), TRUE, wiz_genesis },
3657     { C('i'), TRUE, wiz_identify },
3658     { C('l'), TRUE, doredraw },    /* if number_pad is set */
3659     { C('n'), TRUE, donamelevel }, /* if number_pad is set */
3660     { C('o'), TRUE, dooverview_or_wiz_where }, /* depends on wizard status */
3661     { C('p'), TRUE, doprev_message },
3662     { C('r'), TRUE, doredraw },
3663     { C('t'), TRUE, dotele },
3664     { C('v'), TRUE, wiz_level_tele },
3665     { C('w'), TRUE, wiz_wish },
3666     { C('x'), TRUE, doattributes },
3667     { C('z'), TRUE, dosuspend_core },
3668     { 'a', FALSE, doapply },
3669     { 'A', FALSE, doddoremarm },
3670     { M('a'), TRUE, doorganize },
3671     { M('A'), TRUE, donamelevel }, /* #annotate */
3672     /*  'b', 'B' : go sw */
3673     { 'c', FALSE, doclose },
3674     { 'C', TRUE, docallcmd },
3675     { M('c'), TRUE, dotalk },
3676     { M('C'), TRUE, doconduct }, /* #conduct */
3677     { 'd', FALSE, dodrop },
3678     { 'D', FALSE, doddrop },
3679     { M('d'), FALSE, dodip },
3680     { 'e', FALSE, doeat },
3681     { 'E', FALSE, doengrave },
3682     { M('e'), TRUE, enhance_weapon_skill },
3683     { 'f', FALSE, dofire },
3684     /*  'F' : fight (one time) */
3685     { M('f'), FALSE, doforce },
3686     /*  'g', 'G' : multiple go */
3687     /*  'h', 'H' : go west */
3688     { 'h', TRUE, dohelp }, /* if number_pad is set */
3689     { 'i', TRUE, ddoinv },
3690     { 'I', TRUE, dotypeinv }, /* Robert Viduya */
3691     { M('i'), TRUE, doinvoke },
3692     /*  'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */
3693     { 'j', FALSE, dojump }, /* if number_pad is on */
3694     { M('j'), FALSE, dojump },
3695     { 'k', FALSE, dokick }, /* if number_pad is on */
3696     { 'l', FALSE, doloot }, /* if number_pad is on */
3697     { M('l'), FALSE, doloot },
3698     /*  'n' prefixes a count if number_pad is on */
3699     { M('m'), TRUE, domonability },
3700     { 'N', TRUE, docallcmd }, /* if number_pad is on */
3701     { M('n'), TRUE, docallcmd },
3702     { M('N'), TRUE, docallcmd },
3703     { 'o', FALSE, doopen },
3704     { 'O', TRUE, doset },
3705     { M('o'), FALSE, dosacrifice },
3706     { M('O'), TRUE, dooverview }, /* #overview */
3707     { 'p', FALSE, dopay },
3708     { 'P', FALSE, doputon },
3709     { M('p'), TRUE, dopray },
3710     { 'q', FALSE, dodrink },
3711     { 'Q', FALSE, dowieldquiver },
3712     { M('q'), TRUE, done2 },
3713     { 'r', FALSE, doread },
3714     { 'R', FALSE, doremring },
3715     { M('r'), FALSE, dorub },
3716     { M('R'), FALSE, doride }, /* #ride */
3717 /*JP
3718     { 's', TRUE, dosearch, "searching" },
3719 */
3720     { 's', TRUE, dosearch, "\91{\82·" },
3721     { 'S', TRUE, dosave },
3722     { M('s'), FALSE, dosit },
3723     { 't', FALSE, dothrow },
3724     { 'T', FALSE, dotakeoff },
3725     { M('t'), TRUE, doturn },
3726     { M('T'), FALSE, dotip }, /* #tip */
3727     /*  'u', 'U' : go ne */
3728     { 'u', FALSE, dountrap }, /* if number_pad is on */
3729     { M('u'), FALSE, dountrap },
3730     { 'v', TRUE, doversion },
3731     { 'V', TRUE, dohistory },
3732     { M('v'), TRUE, doextversion },
3733     { 'w', FALSE, dowield },
3734     { 'W', FALSE, dowear },
3735     { M('w'), FALSE, dowipe },
3736     { 'x', FALSE, doswapweapon },
3737     { 'X', FALSE, dotwoweapon },
3738     /*  'y', 'Y' : go nw */
3739     { 'z', FALSE, dozap },
3740     { 'Z', TRUE, docast },
3741     { '<', FALSE, doup },
3742     { '>', FALSE, dodown },
3743     { '/', TRUE, dowhatis },
3744     { '&', TRUE, dowhatdoes },
3745     { '?', TRUE, dohelp },
3746     { M('?'), TRUE, doextlist },
3747 #ifdef SHELL
3748     { '!', TRUE, dosh },
3749 #endif
3750 /*JP
3751     { '.', TRUE, donull, "waiting" },
3752 */
3753     { '.', TRUE, donull, "\8bx\8ce\82·\82é" },
3754 /*JP
3755     { ' ', TRUE, donull, "waiting" },
3756 */
3757     { ' ', TRUE, donull, "\8bx\8ce\82·\82é" },
3758     { ',', FALSE, dopickup },
3759     { ':', TRUE, dolook },
3760     { ';', TRUE, doquickwhatis },
3761     { '^', TRUE, doidtrap },
3762     { '\\', TRUE, dodiscovered }, /* Robert Viduya */
3763     { '`', TRUE, doclassdisco },
3764     { '@', TRUE, dotogglepickup },
3765     { M('2'), FALSE, dotwoweapon },
3766     { WEAPON_SYM, TRUE, doprwep },
3767     { ARMOR_SYM, TRUE, doprarm },
3768     { RING_SYM, TRUE, doprring },
3769     { AMULET_SYM, TRUE, dopramulet },
3770     { TOOL_SYM, TRUE, doprtool },
3771     { '*', TRUE, doprinuse }, /* inventory of all equipment in use */
3772     { GOLD_SYM, TRUE, doprgold },
3773     { SPBOOK_SYM, TRUE, dovspell }, /* Mike Stephenson */
3774     { '#', TRUE, doextcmd },
3775     { '_', TRUE, dotravel },
3776     { 0, 0, 0, 0 }
3777 };
3778
3779 struct ext_func_tab extcmdlist[] = {
3780 /*JP
3781     { "adjust", "adjust inventory letters", doorganize, TRUE },
3782 */
3783     { "adjust", "\8e\9d\82¿\95¨\88ê\97\97\82Ì\92²\90®", doorganize, TRUE },
3784 /*JP
3785     { "annotate", "name current level", donamelevel, TRUE },
3786 */
3787     { "annotate", "\8c»\8dÝ\82Ì\8aK\82É\96¼\91O\82ð\82Â\82¯\82é", donamelevel, TRUE },
3788 #if 0 /*JP*/
3789     { "chat", "talk to someone", dotalk, TRUE }, /* converse? */
3790 #else
3791     { "chat", "\92N\82©\82Æ\98b\82·", dotalk, TRUE }, /* converse? */
3792 #endif
3793 #if 0 /*JP*/
3794     { "conduct", "list voluntary challenges you have maintained", doconduct,
3795       TRUE },
3796 #else
3797     { "conduct", "\82Ç\82¤\82¢\82¤\8ds\93®\82ð\82Æ\82Á\82½\82©\8c©\82é", doconduct, TRUE },
3798 #endif
3799 /*JP
3800     { "dip", "dip an object into something", dodip, FALSE },
3801 */
3802     { "dip", "\89½\82©\82É\95¨\82ð\90Z\82·", dodip, FALSE },
3803 #if 0 /*JP*/
3804     { "enhance", "advance or check weapon and spell skills",
3805       enhance_weapon_skill, TRUE },
3806 #else
3807     { "enhance", "\95\90\8aí\8fn\97û\93x\82ð\8d\82\82ß\82é", enhance_weapon_skill, TRUE },
3808 #endif
3809 /*JP
3810     { "exploremode", "enter explore mode", enter_explore_mode, TRUE },
3811 */
3812     { "exploremode", "\92T\8c\9f\83\82\81[\83h\82É\93ü\82é", enter_explore_mode, TRUE },
3813 /*JP
3814     { "force", "force a lock", doforce, FALSE },
3815 */
3816     { "force", "\8c®\82ð\82±\82\82 \82¯\82é", doforce, FALSE },
3817 /*JP
3818     { "invoke", "invoke an object's powers", doinvoke, TRUE },
3819 */
3820     { "invoke", "\95¨\82Ì\93Á\95Ê\82È\97Í\82ð\8eg\82¤", doinvoke, TRUE },
3821 /*JP
3822     { "jump", "jump to a location", dojump, FALSE },
3823 */
3824     { "jump", "\91¼\82Ì\88Ê\92u\82É\94ò\82Ñ\82¤\82Â\82é", dojump, FALSE },
3825 /*JP
3826     { "loot", "loot a box on the floor", doloot, FALSE },
3827 */
3828     { "loot", "\8f°\82Ì\8fã\82Ì\94 \82ð\8aJ\82¯\82é", doloot, TRUE },
3829 /*JP
3830     { "monster", "use a monster's special ability", domonability, TRUE },
3831 */
3832     { "monster", "\89ö\95¨\82Ì\93Á\95Ê\94\\97Í\82ð\8eg\82¤", domonability, TRUE },
3833 /*JP
3834     { "name", "name a monster or an object", docallcmd, TRUE },
3835 */
3836     { "name", "\83A\83C\83e\83\80\82â\95¨\82É\96¼\91O\82ð\82Â\82¯\82é", docallcmd, TRUE },
3837 /*JP
3838     { "offer", "offer a sacrifice to the gods", dosacrifice, FALSE },
3839 */
3840     { "offer", "\90_\82É\8b\9f\95¨\82ð\95ù\82°\82é", dosacrifice, FALSE },
3841 /*JP
3842     { "overview", "show an overview of the dungeon", dooverview, TRUE },
3843 */
3844     { "overview", "\96À\8b{\82Ì\8aT\97v\82ð\95\\8e¦\82·\82é", dooverview, TRUE },
3845 /*JP
3846     { "pray", "pray to the gods for help", dopray, TRUE },
3847 */
3848     { "pray", "\90_\82É\8bF\82é", dopray, TRUE },
3849 /*JP
3850     { "quit", "exit without saving current game", done2, TRUE },
3851 */
3852     { "quit", "\83Z\81[\83u\82µ\82È\82¢\82Å\8fI\97¹", done2, TRUE },
3853 /*JP
3854     { "ride", "ride (or stop riding) a monster", doride, FALSE },
3855 */
3856     { "ride", "\89ö\95¨\82É\8fæ\82é(\82Ü\82½\82Í\8d~\82è\82é)", doride, FALSE },
3857 /*JP
3858     { "rub", "rub a lamp or a stone", dorub, FALSE },
3859 */
3860     { "rub", "\83\89\83\93\83v\82ð\82±\82·\82é", dorub, FALSE },
3861 /*JP
3862     { "sit", "sit down", dosit, FALSE },
3863 */
3864     { "sit", "\8dÀ\82é", dosit, FALSE },
3865 /*JP
3866     { "terrain", "show map without obstructions", doterrain, TRUE },
3867 */
3868     { "terrain", "\8e×\96\82\82³\82ê\82¸\82É\92n\90}\82ð\8c©\82é", doterrain, TRUE },
3869 /*JP
3870     { "tip", "empty a container", dotip, FALSE },
3871 */
3872     { "tip", "\93ü\82ê\95¨\82ð\8bó\82É\82·\82é", dotip, FALSE },
3873 /*JP
3874     { "turn", "turn undead", doturn, TRUE },
3875 */
3876     { "turn", "\83A\83\93\83f\83b\83g\82ð\93y\82É\95Ô\82·", doturn, TRUE },
3877 /*JP
3878     { "twoweapon", "toggle two-weapon combat", dotwoweapon, FALSE },
3879 */
3880     { "twoweapon", "\97¼\8eè\8e\9d\82¿\82Ì\90Ø\82è\91Ö\82¦", dotwoweapon, FALSE },
3881 /*JP
3882     { "untrap", "untrap something", dountrap, FALSE },
3883 */
3884     { "untrap", "ã©\82ð\82Í\82¸\82·", dountrap, FALSE },
3885 #if 0 /*JP*/
3886     { "version", "list compile time options for this version of NetHack",
3887       doextversion, TRUE },
3888 #else
3889     { "version", "\83R\83\93\83p\83C\83\8b\8e\9e\82Ì\83I\83v\83V\83\87\83\93\82ð\95\\8e¦\82·\82é", doextversion, TRUE },
3890 #endif
3891 /*JP
3892     { "wipe", "wipe off your face", dowipe, FALSE },
3893 */
3894     { "wipe", "\8aç\82ð\90@\82¤", dowipe, FALSE },
3895 /*JP
3896     { "?", "get this list of extended commands", doextlist, TRUE },
3897 */
3898     { "?", "\82±\82Ì\8ag\92£\83R\83}\83\93\83h\88ê\97\97\82ð\95\\8e¦\82·\82é", doextlist, TRUE },
3899     /*
3900      * There must be a blank entry here for every entry in the table
3901      * below.
3902      */
3903     { (char *) 0, (char *) 0, donull, TRUE }, /* levelchange */
3904     { (char *) 0, (char *) 0, donull, TRUE }, /* lightsources */
3905 #ifdef DEBUG_MIGRATING_MONS
3906     { (char *) 0, (char *) 0, donull, TRUE }, /* migratemons */
3907 #endif
3908     { (char *) 0, (char *) 0, donull, TRUE }, /* monpolycontrol */
3909     { (char *) 0, (char *) 0, donull, TRUE }, /* panic */
3910     { (char *) 0, (char *) 0, donull, TRUE }, /* polyself */
3911 #ifdef PORT_DEBUG
3912     { (char *) 0, (char *) 0, donull, TRUE }, /* portdebug */
3913 #endif
3914     { (char *) 0, (char *) 0, donull, TRUE }, /* seenv */
3915     { (char *) 0, (char *) 0, donull, TRUE }, /* stats */
3916     { (char *) 0, (char *) 0, donull, TRUE }, /* timeout */
3917     { (char *) 0, (char *) 0, donull, TRUE }, /* vanquished */
3918     { (char *) 0, (char *) 0, donull, TRUE }, /* vision */
3919     { (char *) 0, (char *) 0, donull, TRUE }, /* wizsmell */
3920 #ifdef DEBUG
3921     { (char *) 0, (char *) 0, donull, TRUE }, /* wizdebug_traveldisplay */
3922     { (char *) 0, (char *) 0, donull, TRUE }, /* wizdebug_bury */
3923 #endif
3924     { (char *) 0, (char *) 0, donull, TRUE }, /* wizrumorcheck */
3925     { (char *) 0, (char *) 0, donull, TRUE }, /* wmode */
3926     { (char *) 0, (char *) 0, donull, TRUE }  /* sentinel */
3927 };
3928
3929 /* there must be a placeholder in the table above for every entry here */
3930 static const struct ext_func_tab debug_extcmdlist[] = {
3931 /*JP
3932     { "levelchange", "change experience level", wiz_level_change, TRUE },
3933 */
3934     { "levelchange", "\8co\8c±\83\8c\83x\83\8b\82ð\95Ï\82¦\82é", wiz_level_change, TRUE},
3935 /*JP
3936     { "lightsources", "show mobile light sources", wiz_light_sources, TRUE },
3937 */
3938     { "light sources", "\88Ú\93®\8cõ\8c¹\82ð\8c©\82é", wiz_light_sources, TRUE},
3939 #ifdef DEBUG_MIGRATING_MONS
3940 /*JP
3941     { "migratemons", "migrate n random monsters", wiz_migrate_mons, TRUE },
3942 */
3943     { "migratemons", "\83\89\83\93\83_\83\80\82È\89ö\95¨\82ð\89½\91Ì\82©\88Ú\8fZ\82³\82¹\82é", wiz_migrate_mons, TRUE },
3944 #endif
3945 /*JP
3946     { "monpolycontrol", "control monster polymorphs", wiz_mon_polycontrol,
3947 */
3948     { "monpoly_control", "\89ö\95¨\82Ö\82Ì\95Ï\89»\82ð\90§\8cä\82·\82é", wiz_mon_polycontrol,
3949       TRUE },
3950 /*JP
3951     { "panic", "test panic routine (fatal to game)", wiz_panic, TRUE },
3952 */
3953     { "panic", "\83p\83j\83b\83N\83\8b\81[\83`\83\93\82ð\83e\83X\83g\82·\82é(\92v\96½\93I)", wiz_panic, TRUE},
3954 /*JP
3955     { "polyself", "polymorph self", wiz_polyself, TRUE },
3956 */
3957     { "polyself", "\95Ï\89»\82·\82é", wiz_polyself, TRUE},
3958 #ifdef PORT_DEBUG
3959 /*JP
3960     { "portdebug", "wizard port debug command", wiz_port_debug, TRUE },
3961 */
3962     { "portdebug", "\83E\83B\83U\81[\83h\83|\81[\83g\83f\83o\83b\83O\83R\83}\83\93\83h", wiz_port_debug, TRUE },
3963 #endif
3964 /*JP
3965     { "seenv", "show seen vectors", wiz_show_seenv, TRUE },
3966 */
3967     { "seenv", "\8e\8b\90ü\83x\83N\83g\83\8b\82ð\8c©\82é", wiz_show_seenv, TRUE},
3968 /*JP
3969     { "stats", "show memory statistics", wiz_show_stats, TRUE },
3970 */
3971     { "stats", "\83\81\83\82\83\8a\8fó\91Ô\82ð\8c©\82é", wiz_show_stats, TRUE},
3972 /*JP
3973     { "timeout", "look at timeout queue", wiz_timeout_queue, TRUE },
3974 */
3975     { "timeout", "\8e\9e\8aÔ\90Ø\82ê\83L\83\85\81[\82ð\8c©\82é", wiz_timeout_queue, TRUE},
3976 /*JP
3977     { "vanquished", "list vanquished monsters", dovanquished, TRUE },
3978 */
3979     { "vanquished", "\93|\82µ\82½\89ö\95¨\82Ì\88ê\97\97\82ð\8c©\82é", dovanquished, TRUE },
3980 /*JP
3981     { "vision", "show vision array", wiz_show_vision, TRUE },
3982 */
3983     { "vision", "\8e\8b\8aE\94z\97ñ\82ð\8c©\82é", wiz_show_vision, TRUE},
3984 /*JP
3985     { "wizsmell", "smell monster", wiz_smell, TRUE },
3986 */
3987     { "wizsmell", "\89ö\95¨\82Ì\93õ\82¢\82ð\9ak\82®", wiz_smell, TRUE },
3988 #ifdef DEBUG
3989 /*JP
3990     { "wizdebug_traveldisplay", "wizard debug: toggle travel display",
3991 */
3992     { "wizdebug_traveldisplay", "\83E\83B\83U\81[\83h\83f\83o\83b\83O: \88Ú\93®\95\\8e¦\82ð\90Ø\82è\91Ö\82¦\82é",
3993       wiz_debug_cmd_traveldisplay, TRUE },
3994 /*JP
3995     { "wizdebug_bury", "wizard debug: bury objs under and around you",
3996 */
3997     { "wizdebug_bury", "\83E\83B\83U\81[\83h\82Å\83o\83b\83O: \95¨\82ð\82 \82È\82½\82Ì\8eü\82è\82É\96\84\82ß\82é",
3998       wiz_debug_cmd_bury, TRUE },
3999 #endif
4000 /*JP
4001     { "wizrumorcheck", "verify rumor boundaries", wiz_rumor_check, TRUE },
4002 */
4003     { "wizrumorcheck", "\89\\82Ì\8b«\8aE\82ð\8c\9f\8fØ\82·\82é", wiz_rumor_check, TRUE },
4004 /*JP
4005     { "wmode", "show wall modes", wiz_show_wmodes, TRUE },
4006 */
4007     { "wmode", "\95Ç\83\82\81[\83h\82ð\8c©\82é", wiz_show_wmodes, TRUE},
4008     { (char *) 0, (char *) 0, donull, TRUE }
4009 };
4010
4011 /*
4012  * Insert debug commands into the extended command list.  This function
4013  * assumes that the last entry will be the help entry.
4014  *
4015  * You must add entries in ext_func_tab every time you add one to the
4016  * debug_extcmdlist().
4017  */
4018 void
4019 add_debug_extended_commands()
4020 {
4021     int i, j, k, n;
4022
4023     /* count the # of help entries */
4024     for (n = 0; extcmdlist[n].ef_txt[0] != '?'; n++)
4025         ;
4026
4027     for (i = 0; debug_extcmdlist[i].ef_txt; i++) {
4028         /* need enough room for "?" entry plus terminator */
4029         if (n + 2 >= SIZE(extcmdlist))
4030             panic("Too many debugging commands!");
4031         for (j = 0; j < n; j++)
4032             if (strcmp(debug_extcmdlist[i].ef_txt, extcmdlist[j].ef_txt) < 0)
4033                 break;
4034
4035         /* insert i'th debug entry into extcmdlist[j], pushing down  */
4036         for (k = n; k >= j; --k)
4037             extcmdlist[k + 1] = extcmdlist[k];
4038         extcmdlist[j] = debug_extcmdlist[i];
4039         n++; /* now an extra entry */
4040     }
4041 }
4042
4043 STATIC_OVL char
4044 cmd_from_func(fn)
4045 int NDECL((*fn));
4046 {
4047     int i;
4048     for (i = 0; i < SIZE(cmdlist); ++i)
4049         if (cmdlist[i].f_funct == fn)
4050             return cmdlist[i].f_char;
4051     return 0;
4052 }
4053
4054 static const char template[] = "%-18s %4ld  %6ld";
4055 static const char count_str[] = "                   count  bytes";
4056 static const char separator[] = "------------------ -----  ------";
4057
4058 STATIC_OVL int
4059 size_obj(otmp)
4060 struct obj *otmp;
4061 {
4062     int sz = (int) sizeof(struct obj);
4063
4064     if (otmp->oextra) {
4065         sz += (int) sizeof(struct oextra);
4066         if (ONAME(otmp))
4067             sz += (int) strlen(ONAME(otmp)) + 1;
4068         if (OMONST(otmp))
4069             sz += (int) sizeof(struct monst);
4070         if (OMID(otmp))
4071             sz += (int) sizeof(unsigned);
4072         if (OLONG(otmp))
4073             sz += (int) sizeof(long);
4074         if (OMAILCMD(otmp))
4075             sz += (int) strlen(OMAILCMD(otmp)) + 1;
4076     }
4077     return sz;
4078 }
4079
4080 STATIC_OVL void
4081 count_obj(chain, total_count, total_size, top, recurse)
4082 struct obj *chain;
4083 long *total_count;
4084 long *total_size;
4085 boolean top;
4086 boolean recurse;
4087 {
4088     long count, size;
4089     struct obj *obj;
4090
4091     for (count = size = 0, obj = chain; obj; obj = obj->nobj) {
4092         if (top) {
4093             count++;
4094             size += size_obj(obj);
4095         }
4096         if (recurse && obj->cobj)
4097             count_obj(obj->cobj, total_count, total_size, TRUE, TRUE);
4098     }
4099     *total_count += count;
4100     *total_size += size;
4101 }
4102
4103 STATIC_OVL void
4104 obj_chain(win, src, chain, total_count, total_size)
4105 winid win;
4106 const char *src;
4107 struct obj *chain;
4108 long *total_count;
4109 long *total_size;
4110 {
4111     char buf[BUFSZ];
4112     long count = 0, size = 0;
4113
4114     count_obj(chain, &count, &size, TRUE, FALSE);
4115     *total_count += count;
4116     *total_size += size;
4117     Sprintf(buf, template, src, count, size);
4118     putstr(win, 0, buf);
4119 }
4120
4121 STATIC_OVL void
4122 mon_invent_chain(win, src, chain, total_count, total_size)
4123 winid win;
4124 const char *src;
4125 struct monst *chain;
4126 long *total_count;
4127 long *total_size;
4128 {
4129     char buf[BUFSZ];
4130     long count = 0, size = 0;
4131     struct monst *mon;
4132
4133     for (mon = chain; mon; mon = mon->nmon)
4134         count_obj(mon->minvent, &count, &size, TRUE, FALSE);
4135     *total_count += count;
4136     *total_size += size;
4137     Sprintf(buf, template, src, count, size);
4138     putstr(win, 0, buf);
4139 }
4140
4141 STATIC_OVL void
4142 contained(win, src, total_count, total_size)
4143 winid win;
4144 const char *src;
4145 long *total_count;
4146 long *total_size;
4147 {
4148     char buf[BUFSZ];
4149     long count = 0, size = 0;
4150     struct monst *mon;
4151
4152     count_obj(invent, &count, &size, FALSE, TRUE);
4153     count_obj(fobj, &count, &size, FALSE, TRUE);
4154     count_obj(level.buriedobjlist, &count, &size, FALSE, TRUE);
4155     count_obj(migrating_objs, &count, &size, FALSE, TRUE);
4156     /* DEADMONSTER check not required in this loop since they have no
4157      * inventory */
4158     for (mon = fmon; mon; mon = mon->nmon)
4159         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4160     for (mon = migrating_mons; mon; mon = mon->nmon)
4161         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4162
4163     *total_count += count;
4164     *total_size += size;
4165
4166     Sprintf(buf, template, src, count, size);
4167     putstr(win, 0, buf);
4168 }
4169
4170 STATIC_OVL int
4171 size_monst(mtmp)
4172 struct monst *mtmp;
4173 {
4174     int sz = (int) sizeof(struct monst);
4175
4176     if (mtmp->mextra) {
4177         sz += (int) sizeof(struct mextra);
4178         if (MNAME(mtmp))
4179             sz += (int) strlen(MNAME(mtmp)) + 1;
4180         if (EGD(mtmp))
4181             sz += (int) sizeof(struct egd);
4182         if (EPRI(mtmp))
4183             sz += (int) sizeof(struct epri);
4184         if (ESHK(mtmp))
4185             sz += (int) sizeof(struct eshk);
4186         if (EMIN(mtmp))
4187             sz += (int) sizeof(struct emin);
4188         if (EDOG(mtmp))
4189             sz += (int) sizeof(struct edog);
4190         /* mextra->mcorpsenm doesn't point to more memory */
4191     }
4192     return sz;
4193 }
4194
4195 STATIC_OVL void
4196 mon_chain(win, src, chain, total_count, total_size)
4197 winid win;
4198 const char *src;
4199 struct monst *chain;
4200 long *total_count;
4201 long *total_size;
4202 {
4203     char buf[BUFSZ];
4204     long count, size;
4205     struct monst *mon;
4206
4207     for (count = size = 0, mon = chain; mon; mon = mon->nmon) {
4208         count++;
4209         size += size_monst(mon);
4210     }
4211     *total_count += count;
4212     *total_size += size;
4213     Sprintf(buf, template, src, count, size);
4214     putstr(win, 0, buf);
4215 }
4216
4217 /*
4218  * Display memory usage of all monsters and objects on the level.
4219  */
4220 static int
4221 wiz_show_stats()
4222 {
4223     char buf[BUFSZ];
4224     winid win;
4225     long total_obj_size = 0, total_obj_count = 0;
4226     long total_mon_size = 0, total_mon_count = 0;
4227
4228     win = create_nhwindow(NHW_TEXT);
4229     putstr(win, 0, "Current memory statistics:");
4230     putstr(win, 0, "");
4231     Sprintf(buf, "Objects, size %d", (int) sizeof(struct obj));
4232     putstr(win, 0, buf);
4233     putstr(win, 0, "");
4234     putstr(win, 0, count_str);
4235
4236     obj_chain(win, "invent", invent, &total_obj_count, &total_obj_size);
4237     obj_chain(win, "fobj", fobj, &total_obj_count, &total_obj_size);
4238     obj_chain(win, "buried", level.buriedobjlist, &total_obj_count,
4239               &total_obj_size);
4240     obj_chain(win, "migrating obj", migrating_objs, &total_obj_count,
4241               &total_obj_size);
4242     mon_invent_chain(win, "minvent", fmon, &total_obj_count, &total_obj_size);
4243     mon_invent_chain(win, "migrating minvent", migrating_mons,
4244                      &total_obj_count, &total_obj_size);
4245
4246     contained(win, "contained", &total_obj_count, &total_obj_size);
4247
4248     putstr(win, 0, separator);
4249     Sprintf(buf, template, "Total", total_obj_count, total_obj_size);
4250     putstr(win, 0, buf);
4251
4252     putstr(win, 0, "");
4253     putstr(win, 0, "");
4254     Sprintf(buf, "Monsters, size %d", (int) sizeof(struct monst));
4255     putstr(win, 0, buf);
4256     putstr(win, 0, "");
4257
4258     mon_chain(win, "fmon", fmon, &total_mon_count, &total_mon_size);
4259     mon_chain(win, "migrating", migrating_mons, &total_mon_count,
4260               &total_mon_size);
4261
4262     putstr(win, 0, separator);
4263     Sprintf(buf, template, "Total", total_mon_count, total_mon_size);
4264     putstr(win, 0, buf);
4265
4266 #if defined(__BORLANDC__) && !defined(_WIN32)
4267     show_borlandc_stats(win);
4268 #endif
4269
4270     display_nhwindow(win, FALSE);
4271     destroy_nhwindow(win);
4272     return 0;
4273 }
4274
4275 void
4276 sanity_check()
4277 {
4278     obj_sanity_check();
4279     timer_sanity_check();
4280     mon_sanity_check();
4281     light_sources_sanity_check();
4282 }
4283
4284 #ifdef DEBUG_MIGRATING_MONS
4285 static int
4286 wiz_migrate_mons()
4287 {
4288     int mcount = 0;
4289     char inbuf[BUFSZ];
4290     struct permonst *ptr;
4291     struct monst *mtmp;
4292     d_level tolevel;
4293
4294     getlin("How many random monsters to migrate? [0]", inbuf);
4295     if (*inbuf == '\033')
4296         return 0;
4297     mcount = atoi(inbuf);
4298     if (mcount < 0 || mcount > (COLNO * ROWNO) || Is_botlevel(&u.uz))
4299         return 0;
4300     while (mcount > 0) {
4301         if (Is_stronghold(&u.uz))
4302             assign_level(&tolevel, &valley_level);
4303         else
4304             get_level(&tolevel, depth(&u.uz) + 1);
4305         ptr = rndmonst();
4306         mtmp = makemon(ptr, 0, 0, NO_MM_FLAGS);
4307         if (mtmp)
4308             migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
4309                              (coord *) 0);
4310         mcount--;
4311     }
4312     return 0;
4313 }
4314 #endif
4315
4316 #define unctrl(c) ((c) <= C('z') ? (0x60 | (c)) : (c))
4317 #define unmeta(c) (0x7f & (c))
4318
4319 /* called at startup and after number_pad is twiddled */
4320 void
4321 reset_commands(initial)
4322 boolean initial;
4323 {
4324     static const char sdir[] = "hykulnjb><",
4325                       sdir_swap_yz[] = "hzkulnjb><",
4326                       ndir[] = "47896321><",
4327                       ndir_phone_layout[] = "41236987><";
4328     static const int ylist[] = {
4329         'y', 'Y', C('y'), M('y'), M('Y'), M(C('y'))
4330     };
4331     const struct func_tab *cmdtmp;
4332     boolean flagtemp;
4333     int c, i, updated = 0;
4334
4335     if (initial) {
4336         updated = 1;
4337         for (i = 0; i < SIZE(cmdlist); i++) {
4338             c = cmdlist[i].f_char & 0xff;
4339             Cmd.commands[c] = &cmdlist[i];
4340         }
4341         Cmd.num_pad = FALSE;
4342         Cmd.pcHack_compat = Cmd.phone_layout = Cmd.swap_yz = FALSE;
4343     } else {
4344         /* basic num_pad */
4345         flagtemp = iflags.num_pad;
4346         if (flagtemp != Cmd.num_pad) {
4347             Cmd.num_pad = flagtemp;
4348             ++updated;
4349         }
4350         /* swap_yz mode (only applicable for !num_pad) */
4351         flagtemp = (iflags.num_pad_mode & 1) ? !Cmd.num_pad : FALSE;
4352         if (flagtemp != Cmd.swap_yz) {
4353             Cmd.swap_yz = flagtemp;
4354             ++updated;
4355             /* Cmd.swap_yz has been toggled;
4356                perform the swap (or reverse previous one) */
4357             for (i = 0; i < SIZE(ylist); i++) {
4358                 c = ylist[i] & 0xff;
4359                 cmdtmp = Cmd.commands[c];              /* tmp = [y] */
4360                 Cmd.commands[c] = Cmd.commands[c + 1]; /* [y] = [z] */
4361                 Cmd.commands[c + 1] = cmdtmp;          /* [z] = tmp */
4362             }
4363         }
4364         /* MSDOS compatibility mode (only applicable for num_pad) */
4365         flagtemp = (iflags.num_pad_mode & 1) ? Cmd.num_pad : FALSE;
4366         if (flagtemp != Cmd.pcHack_compat) {
4367             Cmd.pcHack_compat = flagtemp;
4368             ++updated;
4369             /* pcHack_compat has been toggled */
4370             c = M('5') & 0xff;
4371             cmdtmp = Cmd.commands['5'];
4372             Cmd.commands['5'] = Cmd.commands[c];
4373             Cmd.commands[c] = cmdtmp;
4374             c = M('0') & 0xff;
4375             Cmd.commands[c] = Cmd.pcHack_compat ? Cmd.commands['I'] : 0;
4376         }
4377         /* phone keypad layout (only applicable for num_pad) */
4378         flagtemp = (iflags.num_pad_mode & 2) ? Cmd.num_pad : FALSE;
4379         if (flagtemp != Cmd.phone_layout) {
4380             Cmd.phone_layout = flagtemp;
4381             ++updated;
4382             /* phone_layout has been toggled */
4383             for (i = 0; i < 3; i++) {
4384                 c = '1' + i;                           /* 1,2,3 <-> 7,8,9 */
4385                 cmdtmp = Cmd.commands[c];              /* tmp = [1] */
4386                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [1] = [7] */
4387                 Cmd.commands[c + 6] = cmdtmp;          /* [7] = tmp */
4388                 c = (M('1') & 0xff) + i;  /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */
4389                 cmdtmp = Cmd.commands[c]; /* tmp = [M-1] */
4390                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [M-1] = [M-7] */
4391                 Cmd.commands[c + 6] = cmdtmp;          /* [M-7] = tmp */
4392             }
4393         }
4394     } /*?initial*/
4395
4396     if (updated)
4397         Cmd.serialno++;
4398     Cmd.dirchars = !Cmd.num_pad
4399                        ? (!Cmd.swap_yz ? sdir : sdir_swap_yz)
4400                        : (!Cmd.phone_layout ? ndir : ndir_phone_layout);
4401     Cmd.alphadirchars = !Cmd.num_pad ? Cmd.dirchars : sdir;
4402
4403     Cmd.move_W = Cmd.dirchars[0];
4404     Cmd.move_NW = Cmd.dirchars[1];
4405     Cmd.move_N = Cmd.dirchars[2];
4406     Cmd.move_NE = Cmd.dirchars[3];
4407     Cmd.move_E = Cmd.dirchars[4];
4408     Cmd.move_SE = Cmd.dirchars[5];
4409     Cmd.move_S = Cmd.dirchars[6];
4410     Cmd.move_SW = Cmd.dirchars[7];
4411 }
4412
4413 STATIC_OVL boolean
4414 accept_menu_prefix(cmd_func)
4415 int NDECL((*cmd_func));
4416 {
4417     if (cmd_func == dopickup || cmd_func == dotip
4418         || cmd_func == doextcmd || cmd_func == doextlist)
4419         return TRUE;
4420     return FALSE;
4421 }
4422
4423 void
4424 rhack(cmd)
4425 register char *cmd;
4426 {
4427     boolean do_walk, do_rush, prefix_seen, bad_command,
4428         firsttime = (cmd == 0);
4429
4430     iflags.menu_requested = FALSE;
4431 #ifdef SAFERHANGUP
4432     if (program_state.done_hup)
4433         end_of_input();
4434 #endif
4435     if (firsttime) {
4436         context.nopick = 0;
4437         cmd = parse();
4438     }
4439     if (*cmd == '\033') {
4440         context.move = FALSE;
4441         return;
4442     }
4443     if (*cmd == DOAGAIN && !in_doagain && saveq[0]) {
4444         in_doagain = TRUE;
4445         stail = 0;
4446         rhack((char *) 0); /* read and execute command */
4447         in_doagain = FALSE;
4448         return;
4449     }
4450     /* Special case of *cmd == ' ' handled better below */
4451     if (!*cmd || *cmd == (char) 0377) {
4452         nhbell();
4453         context.move = FALSE;
4454         return; /* probably we just had an interrupt */
4455     }
4456
4457     /* handle most movement commands */
4458     do_walk = do_rush = prefix_seen = FALSE;
4459     context.travel = context.travel1 = 0;
4460     switch (*cmd) {
4461     case 'g':
4462         if (movecmd(cmd[1])) {
4463             context.run = 2;
4464             do_rush = TRUE;
4465         } else
4466             prefix_seen = TRUE;
4467         break;
4468     case '5':
4469         if (!Cmd.num_pad)
4470             break; /* else FALLTHRU */
4471     case 'G':
4472         if (movecmd(lowc(cmd[1]))) {
4473             context.run = 3;
4474             do_rush = TRUE;
4475         } else
4476             prefix_seen = TRUE;
4477         break;
4478     case '-':
4479         if (!Cmd.num_pad)
4480             break; /* else FALLTHRU */
4481     /* Effects of movement commands and invisible monsters:
4482      * m: always move onto space (even if 'I' remembered)
4483      * F: always attack space (even if 'I' not remembered)
4484      * normal movement: attack if 'I', move otherwise.
4485      */
4486     case 'F':
4487         if (movecmd(cmd[1])) {
4488             context.forcefight = 1;
4489             do_walk = TRUE;
4490         } else
4491             prefix_seen = TRUE;
4492         break;
4493     case 'm':
4494         if (movecmd(cmd[1]) || u.dz) {
4495             context.run = 0;
4496             context.nopick = 1;
4497             if (!u.dz)
4498                 do_walk = TRUE;
4499             else
4500                 cmd[0] = cmd[1]; /* "m<" or "m>" */
4501         } else
4502             prefix_seen = TRUE;
4503         break;
4504     case 'M':
4505         if (movecmd(lowc(cmd[1]))) {
4506             context.run = 1;
4507             context.nopick = 1;
4508             do_rush = TRUE;
4509         } else
4510             prefix_seen = TRUE;
4511         break;
4512     case '0':
4513         if (!Cmd.num_pad)
4514             break;
4515         (void) ddoinv(); /* a convenience borrowed from the PC */
4516         context.move = FALSE;
4517         multi = 0;
4518         return;
4519     case CMD_CLICKLOOK:
4520         if (iflags.clicklook) {
4521             context.move = FALSE;
4522             do_look(2, &clicklook_cc);
4523         }
4524         return;
4525     case CMD_TRAVEL:
4526         if (flags.travelcmd) {
4527             context.travel = 1;
4528             context.travel1 = 1;
4529             context.run = 8;
4530             context.nopick = 1;
4531             do_rush = TRUE;
4532             break;
4533         }
4534         /*FALLTHRU*/
4535     default:
4536         if (movecmd(*cmd)) { /* ordinary movement */
4537             context.run = 0; /* only matters here if it was 8 */
4538             do_walk = TRUE;
4539         } else if (movecmd(Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) {
4540             context.run = 1;
4541             do_rush = TRUE;
4542         } else if (movecmd(unctrl(*cmd))) {
4543             context.run = 3;
4544             do_rush = TRUE;
4545         }
4546         break;
4547     }
4548
4549     /* some special prefix handling */
4550     /* overload 'm' prefix to mean "request a menu" */
4551     if (prefix_seen && cmd[0] == 'm') {
4552         /* (for func_tab cast, see below) */
4553         const struct func_tab *ft = Cmd.commands[cmd[1] & 0xff];
4554         int NDECL((*func)) = ft ? ((struct func_tab *) ft)->f_funct : 0;
4555
4556         if (func && accept_menu_prefix(func)) {
4557             iflags.menu_requested = TRUE;
4558             ++cmd;
4559         }
4560     }
4561
4562     if ((do_walk || do_rush) && !context.travel && !dxdy_moveok()) {
4563         /* trying to move diagonally as a grid bug;
4564            this used to be treated by movecmd() as not being
4565            a movement attempt, but that didn't provide for any
4566            feedback and led to strangeness if the key pressed
4567            ('u' in particular) was overloaded for num_pad use */
4568         You_cant("get there from here...");
4569         context.run = 0;
4570         context.nopick = context.forcefight = FALSE;
4571         context.move = context.mv = FALSE;
4572         multi = 0;
4573         return;
4574     }
4575
4576     if (do_walk) {
4577         if (multi)
4578             context.mv = TRUE;
4579         domove();
4580         context.forcefight = 0;
4581         return;
4582     } else if (do_rush) {
4583         if (firsttime) {
4584             if (!multi)
4585                 multi = max(COLNO, ROWNO);
4586             u.last_str_turn = 0;
4587         }
4588         context.mv = TRUE;
4589         domove();
4590         return;
4591     } else if (prefix_seen && cmd[1] == '\033') { /* <prefix><escape> */
4592         /* don't report "unknown command" for change of heart... */
4593         bad_command = FALSE;
4594     } else if (*cmd == ' ' && !flags.rest_on_space) {
4595         bad_command = TRUE; /* skip cmdlist[] loop */
4596
4597         /* handle all other commands */
4598     } else {
4599         register const struct func_tab *tlist;
4600         int res, NDECL((*func));
4601
4602 #if 0
4603         /* obsolete - scan through the cmdlist array looking for *cmd */
4604         for (tlist = cmdlist; tlist->f_char; tlist++) {
4605             if ((*cmd & 0xff) != (tlist->f_char & 0xff))
4606                 continue;
4607 #else
4608         /* current - use *cmd to directly index cmdlist array */
4609         if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
4610 #endif
4611             if (u.uburied && !tlist->can_if_buried) {
4612 /*JP
4613                 You_cant("do that while you are buried!");
4614 */
4615                 You("\96\84\82Ü\82Á\82Ä\82¢\82é\8e\9e\82É\82»\82ñ\82È\82±\82Æ\82Í\82Å\82«\82È\82¢\81I");
4616                 res = 0;
4617             } else {
4618                 /* we discard 'const' because some compilers seem to have
4619                    trouble with the pointer passed to set_occupation() */
4620                 func = ((struct func_tab *) tlist)->f_funct;
4621                 if (tlist->f_text && !occupation && multi)
4622                     set_occupation(func, tlist->f_text, multi);
4623                 res = (*func)(); /* perform the command */
4624             }
4625             if (!res) {
4626                 context.move = FALSE;
4627                 multi = 0;
4628             }
4629             return;
4630         }
4631         /* if we reach here, cmd wasn't found in cmdlist[] */
4632         bad_command = TRUE;
4633     }
4634
4635     if (bad_command) {
4636         char expcmd[10];
4637         register char c, *cp = expcmd;
4638
4639         while ((c = *cmd++) != '\0'
4640                && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) {
4641             if (c >= 040 && c < 0177) {
4642                 *cp++ = c;
4643             } else if (c & 0200) {
4644                 *cp++ = 'M';
4645                 *cp++ = '-';
4646                 *cp++ = c & ~0200;
4647             } else {
4648                 *cp++ = '^';
4649                 *cp++ = c ^ 0100;
4650             }
4651         }
4652         *cp = '\0';
4653         if (!prefix_seen || !iflags.cmdassist
4654 /*JP
4655             || !help_dir(0, "Invalid direction key!"))
4656 */
4657             || !help_dir(0, "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I"))
4658 /*JP
4659             Norep("Unknown command '%s'.", expcmd);
4660 */
4661             Norep("'%s'\83R\83}\83\93\83h\81H", expcmd);
4662     }
4663     /* didn't move */
4664     context.move = FALSE;
4665     multi = 0;
4666     return;
4667 }
4668
4669 /* convert an x,y pair into a direction code */
4670 int
4671 xytod(x, y)
4672 schar x, y;
4673 {
4674     register int dd;
4675
4676     for (dd = 0; dd < 8; dd++)
4677         if (x == xdir[dd] && y == ydir[dd])
4678             return dd;
4679     return -1;
4680 }
4681
4682 /* convert a direction code into an x,y pair */
4683 void
4684 dtoxy(cc, dd)
4685 coord *cc;
4686 register int dd;
4687 {
4688     cc->x = xdir[dd];
4689     cc->y = ydir[dd];
4690     return;
4691 }
4692
4693 /* also sets u.dz, but returns false for <> */
4694 int
4695 movecmd(sym)
4696 char sym;
4697 {
4698     register const char *dp = index(Cmd.dirchars, sym);
4699
4700     u.dz = 0;
4701     if (!dp || !*dp)
4702         return 0;
4703     u.dx = xdir[dp - Cmd.dirchars];
4704     u.dy = ydir[dp - Cmd.dirchars];
4705     u.dz = zdir[dp - Cmd.dirchars];
4706 #if 0 /* now handled elsewhere */
4707     if (u.dx && u.dy && NODIAG(u.umonnum)) {
4708         u.dx = u.dy = 0;
4709         return 0;
4710     }
4711 #endif
4712     return !u.dz;
4713 }
4714
4715 /* grid bug handling which used to be in movecmd() */
4716 int
4717 dxdy_moveok()
4718 {
4719     if (u.dx && u.dy && NODIAG(u.umonnum))
4720         u.dx = u.dy = 0;
4721     return u.dx || u.dy;
4722 }
4723
4724 /* decide whether a character (user input keystroke) requests screen repaint */
4725 boolean
4726 redraw_cmd(c)
4727 char c;
4728 {
4729     return (boolean) (c == C('r') || (Cmd.num_pad && c == C('l')));
4730 }
4731
4732 /*
4733  * uses getdir() but unlike getdir() it specifically
4734  * produces coordinates using the direction from getdir()
4735  * and verifies that those coordinates are ok.
4736  *
4737  * If the call to getdir() returns 0, Never_mind is displayed.
4738  * If the resulting coordinates are not okay, emsg is displayed.
4739  *
4740  * Returns non-zero if coordinates in cc are valid.
4741  */
4742 int
4743 get_adjacent_loc(prompt, emsg, x, y, cc)
4744 const char *prompt, *emsg;
4745 xchar x, y;
4746 coord *cc;
4747 {
4748     xchar new_x, new_y;
4749     if (!getdir(prompt)) {
4750         pline1(Never_mind);
4751         return 0;
4752     }
4753     new_x = x + u.dx;
4754     new_y = y + u.dy;
4755     if (cc && isok(new_x, new_y)) {
4756         cc->x = new_x;
4757         cc->y = new_y;
4758     } else {
4759         if (emsg)
4760             pline1(emsg);
4761         return 0;
4762     }
4763     return 1;
4764 }
4765
4766 int
4767 getdir(s)
4768 const char *s;
4769 {
4770     char dirsym;
4771     int is_mov;
4772
4773 retry:
4774     if (in_doagain || *readchar_queue)
4775         dirsym = readchar();
4776     else
4777 /*JP
4778         dirsym = yn_function((s && *s != '^') ? s : "In what direction?",
4779 */
4780         dirsym = yn_function((s && *s != '^') ? s : "\82Ç\82Ì\95û\8cü\81H",
4781                              (char *) 0, '\0');
4782     /* remove the prompt string so caller won't have to */
4783     clear_nhwindow(WIN_MESSAGE);
4784
4785     if (redraw_cmd(dirsym)) { /* ^R */
4786         docrt();              /* redraw */
4787         goto retry;
4788     }
4789     savech(dirsym);
4790
4791     if (dirsym == '.' || dirsym == 's') {
4792         u.dx = u.dy = u.dz = 0;
4793     } else if (!(is_mov = movecmd(dirsym)) && !u.dz) {
4794         boolean did_help = FALSE, help_requested;
4795
4796         if (!index(quitchars, dirsym)) {
4797             help_requested = (dirsym == '?');
4798             if (help_requested || iflags.cmdassist) {
4799                 did_help =
4800                     help_dir((s && *s == '^') ? dirsym : 0,
4801                              help_requested ? (const char *) 0
4802 /*JP
4803                                             : "Invalid direction key!");
4804 */
4805                                             : "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I");
4806                 if (help_requested)
4807                     goto retry;
4808             }
4809             if (!did_help)
4810 /*JP
4811                 pline("What a strange direction!");
4812 */
4813                 pline("\82¸\82¢\82Ô\82ñ\82Æ\8aï\96­\82È\95û\8cü\82¾\81I");
4814         }
4815         return 0;
4816     } else if (is_mov && !dxdy_moveok()) {
4817 /*JP
4818         You_cant("orient yourself that direction.");
4819 */
4820         You_cant("\8cü\82«\82É\8e©\95ª\8e©\90g\82ð\8ew\92è\82Å\82«\82È\82¢\81D");
4821         return 0;
4822     }
4823     if (!u.dz && (Stunned || (Confusion && !rn2(5))))
4824         confdir();
4825     return 1;
4826 }
4827
4828 STATIC_OVL boolean
4829 help_dir(sym, msg)
4830 char sym;
4831 const char *msg;
4832 {
4833     char ctrl;
4834     winid win;
4835     static const char wiz_only_list[] = "EFGIOVW";
4836     char buf[BUFSZ], buf2[BUFSZ], *explain;
4837
4838     win = create_nhwindow(NHW_TEXT);
4839     if (!win)
4840         return FALSE;
4841     if (msg) {
4842         Sprintf(buf, "cmdassist: %s", msg);
4843         putstr(win, 0, buf);
4844         putstr(win, 0, "");
4845     }
4846     if (letter(sym)) {
4847         sym = highc(sym);
4848         ctrl = (sym - 'A') + 1;
4849         if ((explain = dowhatdoes_core(ctrl, buf2))
4850             && (!index(wiz_only_list, sym) || wizard)) {
4851             Sprintf(buf, "Are you trying to use ^%c%s?", sym,
4852                     index(wiz_only_list, sym)
4853                         ? ""
4854                         : " as specified in the Guidebook");
4855             putstr(win, 0, buf);
4856             putstr(win, 0, "");
4857             putstr(win, 0, explain);
4858             putstr(win, 0, "");
4859             putstr(win, 0, "To use that command, you press");
4860             Sprintf(buf, "the <Ctrl> key, and the <%c> key at the same time.",
4861                     sym);
4862             putstr(win, 0, buf);
4863             putstr(win, 0, "");
4864         }
4865     }
4866     if (NODIAG(u.umonnum)) {
4867         putstr(win, 0, "Valid direction keys in your current form are:");
4868         Sprintf(buf, "             %c   ", Cmd.move_N);
4869         putstr(win, 0, buf);
4870         putstr(win, 0, "             |   ");
4871         Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
4872         putstr(win, 0, buf);
4873         putstr(win, 0, "             |   ");
4874         Sprintf(buf, "             %c   ", Cmd.move_S);
4875         putstr(win, 0, buf);
4876     } else {
4877         putstr(win, 0, "Valid direction keys are:");
4878         Sprintf(buf, "          %c  %c  %c", Cmd.move_NW, Cmd.move_N,
4879                 Cmd.move_NE);
4880         putstr(win, 0, buf);
4881         putstr(win, 0, "           \\ | / ");
4882         Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
4883         putstr(win, 0, buf);
4884         putstr(win, 0, "           / | \\ ");
4885         Sprintf(buf, "          %c  %c  %c", Cmd.move_SW, Cmd.move_S,
4886                 Cmd.move_SE);
4887         putstr(win, 0, buf);
4888     };
4889     putstr(win, 0, "");
4890     putstr(win, 0, "          <  up");
4891     putstr(win, 0, "          >  down");
4892     putstr(win, 0, "          .  direct at yourself");
4893     if (msg) {
4894         /* non-null msg means that this wasn't an explicit user request */
4895         putstr(win, 0, "");
4896         putstr(win, 0,
4897 /*JP
4898                "(Suppress this message with !cmdassist in config file.)");
4899 */
4900                "(\82±\82Ì\83\81\83b\83Z\81[\83W\82ð\95\\8e¦\82µ\82½\82­\82È\82¢\8fê\8d\87\82Í\90Ý\92è\83t\83@\83C\83\8b\82É !cmdassist \82ð\90Ý\92è\82µ\82Ä\82­\82¾\82³\82¢\81D)");
4901     }
4902     display_nhwindow(win, FALSE);
4903     destroy_nhwindow(win);
4904     return TRUE;
4905 }
4906
4907 void
4908 confdir()
4909 {
4910     register int x = NODIAG(u.umonnum) ? 2 * rn2(4) : rn2(8);
4911
4912     u.dx = xdir[x];
4913     u.dy = ydir[x];
4914     return;
4915 }
4916
4917 const char *
4918 directionname(dir)
4919 int dir;
4920 {
4921     static NEARDATA const char *const dirnames[] = {
4922         "west",      "northwest", "north",     "northeast", "east",
4923         "southeast", "south",     "southwest", "down",      "up",
4924     };
4925
4926     if (dir < 0 || dir >= SIZE(dirnames))
4927         return "invalid";
4928     return dirnames[dir];
4929 }
4930
4931 int
4932 isok(x, y)
4933 register int x, y;
4934 {
4935     /* x corresponds to curx, so x==1 is the first column. Ach. %% */
4936     return x >= 1 && x <= COLNO - 1 && y >= 0 && y <= ROWNO - 1;
4937 }
4938
4939 static NEARDATA int last_multi;
4940
4941 /*
4942  * convert a MAP window position into a movecmd
4943  */
4944 const char *
4945 click_to_cmd(x, y, mod)
4946 int x, y, mod;
4947 {
4948     int dir;
4949     static char cmd[4];
4950     cmd[1] = 0;
4951
4952     if (iflags.clicklook && mod == CLICK_2) {
4953         clicklook_cc.x = x;
4954         clicklook_cc.y = y;
4955         cmd[0] = CMD_CLICKLOOK;
4956         return cmd;
4957     }
4958
4959     x -= u.ux;
4960     y -= u.uy;
4961
4962     if (flags.travelcmd) {
4963         if (abs(x) <= 1 && abs(y) <= 1) {
4964             x = sgn(x), y = sgn(y);
4965         } else {
4966             u.tx = u.ux + x;
4967             u.ty = u.uy + y;
4968             cmd[0] = CMD_TRAVEL;
4969             return cmd;
4970         }
4971
4972         if (x == 0 && y == 0) {
4973             /* here */
4974             if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)
4975                 || IS_SINK(levl[u.ux][u.uy].typ)) {
4976                 cmd[0] = mod == CLICK_1 ? 'q' : M('d');
4977                 return cmd;
4978             } else if (IS_THRONE(levl[u.ux][u.uy].typ)) {
4979                 cmd[0] = M('s');
4980                 return cmd;
4981             } else if ((u.ux == xupstair && u.uy == yupstair)
4982                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
4983                            && sstairs.up)
4984                        || (u.ux == xupladder && u.uy == yupladder)) {
4985                 return "<";
4986             } else if ((u.ux == xdnstair && u.uy == ydnstair)
4987                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
4988                            && !sstairs.up)
4989                        || (u.ux == xdnladder && u.uy == ydnladder)) {
4990                 return ">";
4991             } else if (OBJ_AT(u.ux, u.uy)) {
4992                 cmd[0] =
4993                     Is_container(level.objects[u.ux][u.uy]) ? M('l') : ',';
4994                 return cmd;
4995             } else {
4996                 return "."; /* just rest */
4997             }
4998         }
4999
5000         /* directional commands */
5001
5002         dir = xytod(x, y);
5003
5004         if (!m_at(u.ux + x, u.uy + y)
5005             && !test_move(u.ux, u.uy, x, y, TEST_MOVE)) {
5006             cmd[1] = Cmd.dirchars[dir];
5007             cmd[2] = '\0';
5008             if (IS_DOOR(levl[u.ux + x][u.uy + y].typ)) {
5009                 /* slight assistance to the player: choose kick/open for them
5010                  */
5011                 if (levl[u.ux + x][u.uy + y].doormask & D_LOCKED) {
5012                     cmd[0] = C('d');
5013                     return cmd;
5014                 }
5015                 if (levl[u.ux + x][u.uy + y].doormask & D_CLOSED) {
5016                     cmd[0] = 'o';
5017                     return cmd;
5018                 }
5019             }
5020             if (levl[u.ux + x][u.uy + y].typ <= SCORR) {
5021                 cmd[0] = 's';
5022                 cmd[1] = 0;
5023                 return cmd;
5024             }
5025         }
5026     } else {
5027         /* convert without using floating point, allowing sloppy clicking */
5028         if (x > 2 * abs(y))
5029             x = 1, y = 0;
5030         else if (y > 2 * abs(x))
5031             x = 0, y = 1;
5032         else if (x < -2 * abs(y))
5033             x = -1, y = 0;
5034         else if (y < -2 * abs(x))
5035             x = 0, y = -1;
5036         else
5037             x = sgn(x), y = sgn(y);
5038
5039         if (x == 0 && y == 0) /* map click on player to "rest" command */
5040             return ".";
5041
5042         dir = xytod(x, y);
5043     }
5044
5045     /* move, attack, etc. */
5046     cmd[1] = 0;
5047     if (mod == CLICK_1) {
5048         cmd[0] = Cmd.dirchars[dir];
5049     } else {
5050         cmd[0] = (Cmd.num_pad
5051                      ? M(Cmd.dirchars[dir])
5052                      : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
5053     }
5054
5055     return cmd;
5056 }
5057
5058 STATIC_OVL char *
5059 parse()
5060 {
5061 #ifdef LINT /* static char in_line[COLNO]; */
5062     char in_line[COLNO];
5063 #else
5064     static char in_line[COLNO];
5065 #endif
5066     register int foo;
5067     boolean prezero = FALSE;
5068
5069     multi = 0;
5070     context.move = 1;
5071     flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */
5072
5073 #ifdef ALTMETA
5074     alt_esc = iflags.altmeta; /* readchar() hack */
5075 #endif
5076     if (!Cmd.num_pad || (foo = readchar()) == 'n')
5077         for (;;) {
5078             foo = readchar();
5079             if (foo >= '0' && foo <= '9') {
5080                 multi = 10 * multi + foo - '0';
5081                 if (multi < 0 || multi >= LARGEST_INT)
5082                     multi = LARGEST_INT;
5083                 if (multi > 9) {
5084                     clear_nhwindow(WIN_MESSAGE);
5085 /*JP
5086                     Sprintf(in_line, "Count: %d", multi);
5087 */
5088                     Sprintf(in_line, "\90\94: %d", multi);
5089                     pline1(in_line);
5090                     mark_synch();
5091                 }
5092                 last_multi = multi;
5093                 if (!multi && foo == '0')
5094                     prezero = TRUE;
5095             } else
5096                 break; /* not a digit */
5097         }
5098 #ifdef ALTMETA
5099     alt_esc = FALSE; /* readchar() reset */
5100 #endif
5101
5102     if (foo == '\033') { /* esc cancels count (TH) */
5103         clear_nhwindow(WIN_MESSAGE);
5104         multi = last_multi = 0;
5105     } else if (foo == DOAGAIN || in_doagain) {
5106         multi = last_multi;
5107     } else {
5108         last_multi = multi;
5109         savech(0); /* reset input queue */
5110         savech((char) foo);
5111     }
5112
5113     if (multi) {
5114         multi--;
5115         save_cm = in_line;
5116     } else {
5117         save_cm = (char *) 0;
5118     }
5119     /* in 3.4.3 this was in rhack(), where it was too late to handle M-5 */
5120     if (Cmd.pcHack_compat) {
5121         /* This handles very old inconsistent DOS/Windows behaviour
5122            in a different way: earlier, the keyboard handler mapped
5123            these, which caused counts to be strange when entered
5124            from the number pad. Now do not map them until here. */
5125         switch (foo) {
5126         case '5':
5127             foo = 'g';
5128             break;
5129         case M('5'):
5130             foo = 'G';
5131             break;
5132         case M('0'):
5133             foo = 'I';
5134             break;
5135         default:
5136             break; /* as is */
5137         }
5138     }
5139
5140     in_line[0] = foo;
5141     in_line[1] = '\0';
5142     if (foo == 'g' || foo == 'G' || foo == 'm' || foo == 'M' || foo == 'F'
5143         || (Cmd.num_pad && (foo == '5' || foo == '-'))) {
5144         foo = readchar();
5145         savech((char) foo);
5146         in_line[1] = foo;
5147         in_line[2] = 0;
5148     }
5149     clear_nhwindow(WIN_MESSAGE);
5150     if (prezero)
5151         in_line[0] = '\033';
5152     return in_line;
5153 }
5154
5155 #ifdef HANGUPHANDLING
5156 /* some very old systems, or descendents of such systems, expect signal
5157    handlers to have return type `int', but they don't actually inspect
5158    the return value so we should be safe using `void' unconditionally */
5159 /*ARGUSED*/
5160 void
5161 hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
5162 int sig_unused UNUSED;
5163 {
5164     if (program_state.exiting)
5165         program_state.in_moveloop = 0;
5166     nhwindows_hangup();
5167 #ifdef SAFERHANGUP
5168     /* When using SAFERHANGUP, the done_hup flag it tested in rhack
5169        and a couple of other places; actual hangup handling occurs then.
5170        This is 'safer' because it disallows certain cheats and also
5171        protects against losing objects in the process of being thrown,
5172        but also potentially riskier because the disconnected program
5173        must continue running longer before attempting a hangup save. */
5174     program_state.done_hup++;
5175     /* defer hangup iff game appears to be in progress */
5176     if (program_state.in_moveloop && program_state.something_worth_saving)
5177         return;
5178 #endif /* SAFERHANGUP */
5179     end_of_input();
5180 }
5181
5182 void
5183 end_of_input()
5184 {
5185 #ifdef NOSAVEONHANGUP
5186 #ifdef INSURANCE
5187     if (flags.ins_chkpt && program_state.something_worth_saving)
5188         program_statue.preserve_locks = 1; /* keep files for recovery */
5189 #endif
5190     program_state.something_worth_saving = 0; /* don't save */
5191 #endif
5192
5193 #ifndef SAFERHANGUP
5194     if (!program_state.done_hup++)
5195 #endif
5196         if (program_state.something_worth_saving)
5197             (void) dosave0();
5198     if (iflags.window_inited)
5199         exit_nhwindows((char *) 0);
5200     clearlocks();
5201     terminate(EXIT_SUCCESS);
5202     /*NOTREACHED*/ /* not necessarily true for vms... */
5203     return;
5204 }
5205 #endif /* HANGUPHANDLING */
5206
5207 char
5208 readchar()
5209 {
5210     register int sym;
5211     int x = u.ux, y = u.uy, mod = 0;
5212
5213     if (*readchar_queue)
5214         sym = *readchar_queue++;
5215     else
5216         sym = in_doagain ? pgetchar() : nh_poskey(&x, &y, &mod);
5217
5218 #ifdef NR_OF_EOFS
5219     if (sym == EOF) {
5220         register int cnt = NR_OF_EOFS;
5221         /*
5222          * Some SYSV systems seem to return EOFs for various reasons
5223          * (?like when one hits break or for interrupted systemcalls?),
5224          * and we must see several before we quit.
5225          */
5226         do {
5227             clearerr(stdin); /* omit if clearerr is undefined */
5228             sym = pgetchar();
5229         } while (--cnt && sym == EOF);
5230     }
5231 #endif /* NR_OF_EOFS */
5232
5233     if (sym == EOF) {
5234 #ifdef HANGUPHANDLING
5235         hangup(0); /* call end_of_input() or set program_state.done_hup */
5236 #endif
5237         sym = '\033';
5238 #ifdef ALTMETA
5239     } else if (sym == '\033' && alt_esc) {
5240         /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' */
5241         sym = *readchar_queue ? *readchar_queue++ : pgetchar();
5242         if (sym == EOF || sym == 0)
5243             sym = '\033';
5244         else if (sym != '\033')
5245             sym |= 0200; /* force 8th bit on */
5246 #endif                   /*ALTMETA*/
5247     } else if (sym == 0) {
5248         /* click event */
5249         readchar_queue = click_to_cmd(x, y, mod);
5250         sym = *readchar_queue++;
5251     }
5252     return (char) sym;
5253 }
5254
5255 STATIC_PTR int
5256 dotravel(VOID_ARGS)
5257 {
5258     /* Keyboard travel command */
5259     static char cmd[2];
5260     coord cc;
5261
5262     if (!flags.travelcmd)
5263         return 0;
5264     cmd[1] = 0;
5265     cc.x = iflags.travelcc.x;
5266     cc.y = iflags.travelcc.y;
5267     if (cc.x == -1 && cc.y == -1) {
5268         /* No cached destination, start attempt from current position */
5269         cc.x = u.ux;
5270         cc.y = u.uy;
5271     }
5272 /*JP
5273     pline("Where do you want to travel to?");
5274 */
5275     pline("\82Ç\82±\82É\88Ú\93®\82·\82é\81H");
5276 /*JP
5277     if (getpos(&cc, TRUE, "the desired destination") < 0) {
5278 */
5279     if (getpos(&cc, TRUE, "\88Ú\93®\90æ") < 0) {
5280         /* user pressed ESC */
5281         return 0;
5282     }
5283     iflags.travelcc.x = u.tx = cc.x;
5284     iflags.travelcc.y = u.ty = cc.y;
5285     cmd[0] = CMD_TRAVEL;
5286     readchar_queue = cmd;
5287     return 0;
5288 }
5289
5290 #ifdef PORT_DEBUG
5291 extern void NDECL(win32con_debug_keystrokes);
5292 extern void NDECL(win32con_handler_info);
5293
5294 int
5295 wiz_port_debug()
5296 {
5297     int n, k;
5298     winid win;
5299     anything any;
5300     int item = 'a';
5301     int num_menu_selections;
5302     struct menu_selection_struct {
5303         char *menutext;
5304         void NDECL((*fn));
5305     } menu_selections[] = {
5306 #ifdef WIN32
5307         { "test win32 keystrokes (tty only)", win32con_debug_keystrokes },
5308         { "show keystroke handler information (tty only)",
5309           win32con_handler_info },
5310 #endif
5311         { (char *) 0, (void NDECL((*) )) 0 } /* array terminator */
5312     };
5313
5314     num_menu_selections = SIZE(menu_selections) - 1;
5315     if (num_menu_selections > 0) {
5316         menu_item *pick_list;
5317         win = create_nhwindow(NHW_MENU);
5318         start_menu(win);
5319         for (k = 0; k < num_menu_selections; ++k) {
5320             any.a_int = k + 1;
5321             add_menu(win, NO_GLYPH, &any, item++, 0, ATR_NONE,
5322                      menu_selections[k].menutext, MENU_UNSELECTED);
5323         }
5324         end_menu(win, "Which port debugging feature?");
5325         n = select_menu(win, PICK_ONE, &pick_list);
5326         destroy_nhwindow(win);
5327         if (n > 0) {
5328             n = pick_list[0].item.a_int - 1;
5329             free((genericptr_t) pick_list);
5330             /* execute the function */
5331             (*menu_selections[n].fn)();
5332         }
5333     } else
5334         pline("No port-specific debug capability defined.");
5335     return 0;
5336 }
5337 #endif /*PORT_DEBUG*/
5338
5339 /*
5340  *   Parameter validator for generic yes/no function to prevent
5341  *   the core from sending too long a prompt string to the
5342  *   window port causing a buffer overflow there.
5343  */
5344 char
5345 yn_function(query, resp, def)
5346 const char *query, *resp;
5347 char def;
5348 {
5349     char qbuf[QBUFSZ];
5350
5351     iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
5352
5353     /* maximum acceptable length is QBUFSZ-1 */
5354     if (strlen(query) < QBUFSZ)
5355         return (*windowprocs.win_yn_function)(query, resp, def);
5356
5357     /* caller shouldn't have passed anything this long */
5358     paniclog("Query truncated: ", query);
5359     (void) strncpy(qbuf, query, QBUFSZ - 1 - 3);
5360     Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
5361     return (*windowprocs.win_yn_function)(qbuf, resp, def);
5362 }
5363
5364 /* for paranoid_confirm:quit,die,attack prompting */
5365 boolean
5366 paranoid_query(be_paranoid, prompt)
5367 boolean be_paranoid;
5368 const char *prompt;
5369 {
5370     boolean confirmed_ok;
5371
5372     /* when paranoid, player must respond with "yes" rather than just 'y'
5373        to give the go-ahead for this query; default is "no" unless the
5374        ParanoidConfirm flag is set in which case there's no default */
5375     if (be_paranoid) {
5376         char qbuf[QBUFSZ], ans[BUFSZ];
5377         const char *promptprefix = "", *responsetype = ParanoidConfirm
5378                                                            ? "(yes|no)"
5379                                                            : "(yes) [no]";
5380         int trylimit = 6; /* 1 normal, 5 more with "Yes or No:" prefix */
5381
5382         /* in addition to being paranoid about this particular
5383            query, we might be even more paranoid about all paranoia
5384            responses (ie, ParanoidConfirm is set) in which case we
5385            require "no" to reject in addition to "yes" to confirm
5386            (except we won't loop if response is ESC; it means no) */
5387         do {
5388             Sprintf(qbuf, "%s%s %s", promptprefix, prompt, responsetype);
5389             getlin(qbuf, ans);
5390             (void) mungspaces(ans);
5391             confirmed_ok = !strcmpi(ans, "yes");
5392             if (confirmed_ok || *ans == '\033')
5393                 break;
5394             promptprefix = "\"Yes\" or \"No\": ";
5395         } while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
5396     } else
5397         confirmed_ok = (yn(prompt) == 'y');
5398
5399     return confirmed_ok;
5400 }
5401
5402 int
5403 dosuspend_core()
5404 {
5405 #ifdef SUSPEND
5406     /* Does current window system support suspend? */
5407     if ((*windowprocs.win_can_suspend)()) {
5408         /* NB: SYSCF SHELLERS handled in port code. */
5409         dosuspend();
5410     } else
5411 #endif
5412         Norep("Suspend command not available.");
5413     return 0;
5414 }
5415
5416 /*cmd.c*/