OSDN Git Service

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