OSDN Git Service

update year to 2020
[jnethack/source.git] / src / role.c
index a0238a9..92ddba2 100644 (file)
@@ -1,11 +1,11 @@
-/* NetHack 3.6 role.c  $NHDT-Date: 1463561393 2016/05/18 08:49:53 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.38 $ */
+/* NetHack 3.6 role.c  $NHDT-Date: 1547086250 2019/01/10 02:10:50 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.56 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* JNetHack Copyright */
 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
-/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020            */
 /* JNetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
@@ -30,7 +30,7 @@
  * God names use a leading underscore to flag goddesses.
  */
 const struct Role roles[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Archeologist", 0 },
       { { "Digger", 0 },
         { "Field Worker", 0 },
@@ -56,7 +56,7 @@ const struct Role roles[] = {
       "\83P\83c\83A\83\8b\83J\83g\83\8b", "\83J\83}\83L\83V\83g\83\8a", "\83t\83w\83g\83g\83\8b", /* Central American */
 #endif
       "Arc",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the College of Archeology",
       "the Tomb of the Toltec Kings",
 #else
@@ -91,7 +91,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_MAGIC_MAPPING,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Barbarian", 0 },
       { { "Plunderer", "Plunderess" },
         { "Pillager", 0 },
@@ -117,7 +117,7 @@ const struct Role roles[] = {
       "\83~\83g\83\89", "\83N\83\8d\83\80", "\83Z\83g", /* Hyborian */
 #endif
       "Bar",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Camp of the Duali Tribe",
       "the Duali Oasis",
 #else
@@ -152,7 +152,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_HASTE_SELF,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Caveman", "Cavewoman" },
       { { "Troglodyte", 0 },
         { "Aborigine", 0 },
@@ -178,7 +178,7 @@ const struct Role roles[] = {
       "\83A\83k", "_\83C\83V\83\85\83^\83\8b", "\83A\83\93\83V\83\83\83\8b", /* Babylonian */
 #endif
       "Cav",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Caves of the Ancestors",
       "the Dragon's Lair",
 #else
@@ -213,7 +213,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_DIG,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Healer", 0 },
       { { "Rhizotomist", 0 },
         { "Empiric", 0 },
@@ -239,7 +239,7 @@ const struct Role roles[] = {
       "_\83A\83e\83i", "\83w\83\8b\83\81\83X", "\83|\83Z\83C\83h\83\93", /* Greek */
 #endif
       "Hea",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Temple of Epidaurus",
       "the Temple of Coeus",
 #else
@@ -273,7 +273,7 @@ const struct Role roles[] = {
       A_WIS,
       SPE_CURE_SICKNESS,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Knight", 0 },
       { { "Gallant", 0 },
         { "Esquire", 0 },
@@ -299,7 +299,7 @@ const struct Role roles[] = {
       "\83\8b\81[\83t", "_\83u\83\8a\83W\83b\83g", "\83}\83i\83\93\83i\83\93\81E\83}\83N\83\8a\81[\83\8b", /* Celtic */
 #endif
       "Kni",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "Camelot Castle",
       "the Isle of Glass",
 #else
@@ -333,7 +333,7 @@ const struct Role roles[] = {
       A_WIS,
       SPE_TURN_UNDEAD,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Monk", 0 },
       { { "Candidate", 0 },
         { "Novice", 0 },
@@ -359,7 +359,7 @@ const struct Role roles[] = {
       "\8eR\97\8b\90¸", "\90Ô\8f¼\8eq", "\89©\92é", /* Chinese */
 #endif
       "Mon",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Monastery of Chan-Sune",
       "the Monastery of the Earth-Lord",
 #else
@@ -394,7 +394,7 @@ const struct Role roles[] = {
       A_WIS,
       SPE_RESTORE_ABILITY,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Priest", "Priestess" },
       { { "Aspirant", 0 },
         { "Acolyte", 0 },
@@ -420,7 +420,7 @@ const struct Role roles[] = {
       0, 0, 0, /* deities from a randomly chosen other role will be used */
 #endif
       "Pri",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Great Temple",
       "the Temple of Nalzok",
 #else
@@ -457,7 +457,7 @@ const struct Role roles[] = {
       -4 },
     /* Note:  Rogue precedes Ranger so that use of `-R' on the command line
        retains its traditional meaning. */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Rogue", 0 },
       { { "Footpad", 0 },
         { "Cutpurse", 0 },
@@ -483,7 +483,7 @@ const struct Role roles[] = {
       "\83C\83Z\83b\83N", "\83\82\83O", "\83R\83X", /* Nehwon */
 #endif
       "Rog",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Thieves' Guild Hall",
       "the Assassins' Guild Hall",
 #else
@@ -517,7 +517,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_DETECT_TREASURE,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Ranger", 0 },
       {
 #if 0 /* OBSOLETE */
@@ -557,7 +557,7 @@ const struct Role roles[] = {
       "\83}\81[\83L\83\85\83\8a\81[", "_\83r\81[\83i\83X", "\83}\81[\83Y", /* Roman/planets */
 #endif
       "Ran",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "Orion's camp",
       "the cave of the wumpus",
 #else
@@ -592,7 +592,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_INVISIBILITY,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Samurai", 0 },
       { { "Hatamoto", 0 },       /* Banner Knight */
         { "Ronin", 0 },          /* no allegiance */
@@ -618,7 +618,7 @@ const struct Role roles[] = {
       "_\93V\8fÆ\91å\90_", "\97\8b\90_", "\90{\8d²\94V\92j", /* Japanese */
 #endif
       "Sam",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Castle of the Taro Clan",
       "the Shogun's Castle",
 #else
@@ -652,7 +652,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_CLAIRVOYANCE,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Tourist", 0 },
       { { "Rambler", 0 },
         { "Sightseer", 0 },
@@ -678,7 +678,7 @@ const struct Role roles[] = {
       "\96Ó\96Ú\82Ì\83C\83I", "_\81\83\8f\97\90_\81\84", "\83I\83t\83\89\81[", /* Discworld */
 #endif
       "Tou",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "Ankh-Morpork",
       "the Thieves' Guild Hall",
 #else
@@ -712,7 +712,7 @@ const struct Role roles[] = {
       A_INT,
       SPE_CHARM_MONSTER,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Valkyrie", 0 },
       { { "Stripling", 0 },
         { "Skirmisher", 0 },
@@ -738,7 +738,7 @@ const struct Role roles[] = {
       "\83`\83\85\81[\83\8b", "\83I\81[\83f\83B\83\93", "\83\8d\83L", /* Norse */
 #endif
       "Val",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Shrine of Destiny",
       "the cave of Surtur",
 #else
@@ -772,7 +772,7 @@ const struct Role roles[] = {
       A_WIS,
       SPE_CONE_OF_COLD,
       -4 },
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { { "Wizard", 0 },
       { { "Evoker", 0 },
         { "Conjurer", 0 },
@@ -798,7 +798,7 @@ const struct Role roles[] = {
       "\83v\83^\83n", "\83g\81[\83g", "\83A\83\93\83t\83\8b", /* Egyptian */
 #endif
       "Wiz",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
       "the Lonely Tower",
       "the Tower of Darkness",
 #else
@@ -868,7 +868,7 @@ struct Role urole = {
 /* Table of all races */
 const struct Race races[] = {
     {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         "human",
         "human",
         "humanity",
@@ -878,7 +878,7 @@ const struct Race races[] = {
         "\90l\8aÔ",
 #endif
         "Hum",
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         { "man", "woman" },
 #else
         { "\92j", "\8f\97" },
@@ -900,7 +900,7 @@ const struct Race races[] = {
         { 1, 0, 2, 0, 2, 0 }  /* Energy */
     },
     {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         "elf",
         "elven",
         "elvenkind",
@@ -927,7 +927,7 @@ const struct Race races[] = {
         { 2, 0, 3, 0, 3, 0 }  /* Energy */
     },
     {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         "dwarf",
         "dwarven",
         "dwarvenkind",
@@ -954,7 +954,7 @@ const struct Race races[] = {
         { 0, 0, 0, 0, 0, 0 }  /* Energy */
     },
     {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         "gnome",
         "gnomish",
         "gnomehood",
@@ -981,7 +981,7 @@ const struct Race races[] = {
         { 2, 0, 2, 0, 2, 0 }  /* Energy */
     },
     {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         "orc",
         "orcish",
         "orcdom",
@@ -1042,7 +1042,7 @@ struct Race urace = {
   \8aY\93\96\95\94\82à\97v\8fC\90³\81B
 */
 const struct Gender genders[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { "male", "he", "him", "his", "Mal", ROLE_MALE },
     { "female", "she", "her", "her", "Fem", ROLE_FEMALE },
     { "neuter", "it", "it", "its", "Ntr", ROLE_NEUTER }
@@ -1055,7 +1055,7 @@ const struct Gender genders[] = {
 
 /* Table of all alignments */
 const struct Align aligns[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     { "law", "lawful", "Law", ROLE_LAWFUL, A_LAWFUL },
     { "balance", "neutral", "Neu", ROLE_NEUTRAL, A_NEUTRAL },
     { "chaos", "chaotic", "Cha", ROLE_CHAOTIC, A_CHAOTIC },
@@ -1093,9 +1093,16 @@ int rolenum;
 }
 
 int
-randrole()
+randrole(for_display)
+boolean for_display;
 {
-    return rn2(SIZE(roles) - 1);
+    int res = SIZE(roles) - 1;
+
+    if (for_display)
+        res = rn2_on_display_rng(res);
+    else
+        res = rn2(res);
+    return res;
 }
 
 STATIC_OVL int
@@ -1111,7 +1118,7 @@ randrole_filtered()
             && ok_gend(i, ROLE_NONE, ROLE_RANDOM, ROLE_NONE)
             && ok_align(i, ROLE_NONE, ROLE_NONE, ROLE_RANDOM))
             set[n++] = i;
-    return n ? set[rn2(n)] : randrole();
+    return n ? set[rn2(n)] : randrole(FALSE);
 }
 
 int
@@ -1791,7 +1798,9 @@ int buflen, rolenum, racenum, gendnum, alignnum;
     static char err_ret[] = " character's";
 */
     static char err_ret[] = "\83L\83\83\83\89\83N\83^\81[\82Ì";
+#if 0 /*JP*/
     boolean donefirst = FALSE;
+#endif
 
     if (!suppliedbuf || buflen < 1)
         return err_ret;
@@ -1816,14 +1825,18 @@ int buflen, rolenum, racenum, gendnum, alignnum;
                 Strcat(buf, " ");
 #endif
             Strcat(buf, aligns[alignnum].adj);
+#if 0 /*JP*/
             donefirst = TRUE;
+#endif
         } else {
 #if 0 /*JP*/
             if (donefirst)
                 Strcat(buf, " ");
 #endif
             Strcat(buf, aligns[alignnum].adj);
+#if 0 /*JP*/
             donefirst = TRUE;
+#endif
         }
     } else {
         /* in case we got here by failing the ok_align() test */
@@ -1857,7 +1870,9 @@ int buflen, rolenum, racenum, gendnum, alignnum;
                     Strcat(buf, " ");
 #endif
                 Strcat(buf, genders[gendnum].adj);
+#if 0 /*JP*/
                 donefirst = TRUE;
+#endif
             }
         } else {
 #if 0 /*JP*/
@@ -1865,7 +1880,9 @@ int buflen, rolenum, racenum, gendnum, alignnum;
                 Strcat(buf, " ");
 #endif
             Strcat(buf, genders[gendnum].adj);
+#if 0 /*JP*/
             donefirst = TRUE;
+#endif
         }
     } else {
         /* if gender not specified, but role is specified
@@ -1888,14 +1905,18 @@ int buflen, rolenum, racenum, gendnum, alignnum;
 #endif
             Strcat(buf, (rolenum == ROLE_NONE) ? races[racenum].noun
                                                : races[racenum].adj);
+#if 0 /*JP*/
             donefirst = TRUE;
+#endif
         } else if (!validrole(rolenum)) {
 #if 0 /*JP*/
             if (donefirst)
                 Strcat(buf, " ");
 #endif
             Strcat(buf, races[racenum].noun);
+#if 0 /*JP*/
             donefirst = TRUE;
+#endif
         } else {
             pa[BP_RACE] = 1;
             post_attribs++;
@@ -1924,7 +1945,9 @@ int buflen, rolenum, racenum, gendnum, alignnum;
             } else
                 Strcat(buf, roles[rolenum].name.m);
         }
+#if 0 /*JP*/
         donefirst = TRUE;
+#endif
     } else if (rolenum == ROLE_NONE) {
         pa[BP_ROLE] = 1;
         post_attribs++;
@@ -1940,7 +1963,9 @@ int buflen, rolenum, racenum, gendnum, alignnum;
         Strcat(buf, "character");
 */
         Strcat(buf, "\83L\83\83\83\89\83N\83^\81[");
+#if 0 /*JP*/
         donefirst = TRUE;
+#endif
     }
     /* <your lawful female gnomish cavewoman> || <your lawful female gnome>
      *    || <your lawful female character>
@@ -1975,9 +2000,8 @@ int buflen, rolenum, racenum, gendnum, alignnum;
     Strcpy(tmpbuf, "Shall I pick ");
     if (racenum != ROLE_NONE || validrole(rolenum))
         Strcat(tmpbuf, "your ");
-    else {
+    else
         Strcat(tmpbuf, "a ");
-    }
 #else
     Strcpy(tmpbuf, "");
 #endif
@@ -1985,6 +2009,12 @@ int buflen, rolenum, racenum, gendnum, alignnum;
 
     (void) root_plselection_prompt(eos(tmpbuf), buflen - strlen(tmpbuf),
                                    rolenum, racenum, gendnum, alignnum);
+#if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\95s\97v*/
+    /* "Shall I pick a character's role, race, gender, and alignment for you?"
+       plus " [ynaq] (y)" is a little too long for a conventional 80 columns;
+       also, "pick a character's <anything>" sounds a bit stilted */
+    strsubst(tmpbuf, "pick a character", "pick character");
+#endif
 #if 0 /*JP*/
     Sprintf(buf, "%s", s_suffix(tmpbuf));
 #else
@@ -2023,31 +2053,31 @@ int buflen, rolenum, racenum, gendnum, alignnum;
     if (num_post_attribs) {
         if (pa[BP_RACE]) {
             (void) promptsep(eos(buf), num_post_attribs);
-/*
+/*JP
             Strcat(buf, "race");
 */
-           Strcat(buf, "\8eí\91°");
+            Strcat(buf, "\8eí\91°");
         }
         if (pa[BP_ROLE]) {
             (void) promptsep(eos(buf), num_post_attribs);
-/*
+/*JP
             Strcat(buf, "role");
 */
-           Strcat(buf, "\90E\8bÆ");
+            Strcat(buf, "\90E\8bÆ");
         }
         if (pa[BP_GEND]) {
             (void) promptsep(eos(buf), num_post_attribs);
 /*JP
             Strcat(buf, "gender");
 */
-           Strcat(buf, "\90«\95Ê");
+            Strcat(buf, "\90«\95Ê");
         }
         if (pa[BP_ALIGN]) {
             (void) promptsep(eos(buf), num_post_attribs);
 /*JP
             Strcat(buf, "alignment");
 */
-           Strcat(buf, "\91®\90«");
+            Strcat(buf, "\91®\90«");
         }
     }
 /*JP
@@ -2071,14 +2101,15 @@ plnamesuffix()
 
     /* some generic user names will be ignored in favor of prompting */
     if (sysopt.genericusers) {
-       if (*sysopt.genericusers == '*') *plname = '\0';
-       else {
-           i = (int)strlen(plname);
-           if ((sptr = strstri(sysopt.genericusers, plname)) != 0
-               && (sptr == sysopt.genericusers || sptr[-1] == ' ')
-               && (sptr[i] == ' ' || sptr[i] == '\0'))
-               *plname = '\0'; /* call askname() */
-       }
+        if (*sysopt.genericusers == '*') {
+            *plname = '\0';
+        } else {
+            i = (int) strlen(plname);
+            if ((sptr = strstri(sysopt.genericusers, plname)) != 0
+                && (sptr == sysopt.genericusers || sptr[-1] == ' ')
+                && (sptr[i] == ' ' || sptr[i] == '\0'))
+                *plname = '\0'; /* call askname() */
+        }
     }
 
     do {
@@ -2218,13 +2249,17 @@ winid where;
     Sprintf(buf, "%12s ", "alignment:");
 */
     Sprintf(buf, "%12s ", "\91®\90«:");
+#if 0 /*JP:\93ú\96{\8cê\82Å\82Í\96¼\8e\8c\82ª\8e©\91R*/
     Strcat(buf, (which == RS_ALGNMNT) ? choosing : (a == ROLE_NONE)
                                                        ? not_yet
                                                        : (a == ROLE_RANDOM)
                                                              ? rand_choice
-#if 0 /*JP:\93ú\96{\8cê\82Å\82Í\96¼\8e\8c\82ª\8e©\91R*/
                                                              : aligns[a].adj);
 #else
+    Strcat(buf, (which == RS_ALGNMNT) ? choosing : (a == ROLE_NONE)
+                                                       ? not_yet
+                                                       : (a == ROLE_RANDOM)
+                                                             ? rand_choice
                                                              : aligns[a].noun);
 #endif
     putstr(where, 0, buf);
@@ -2556,7 +2591,7 @@ role_init()
     if (flags.pantheon == -1) {             /* new game */
         flags.pantheon = flags.initrole;    /* use own gods */
         while (!roles[flags.pantheon].lgod) /* unless they're missing */
-            flags.pantheon = randrole();
+            flags.pantheon = randrole(FALSE);
     }
     if (!urole.lgod) {
         urole.lgod = roles[flags.pantheon].lgod;
@@ -2569,6 +2604,14 @@ role_init()
 */
     quest_status.godgend = !strcmpi(align_gtitle(alignmnt), "\8f\97\90_");
 
+#if 0
+/*
+ * Disable this fixup so that mons[] can be const.  The only
+ * place where it actually matters for the hero is in set_uasmon()
+ * and that can use mons[race] rather than mons[role] for this
+ * particular property.  Despite the comment, it is checked--where
+ * needed--via instrinsic 'Infravision' which set_uasmon() manages.
+ */
     /* Fix up infravision */
     if (mons[urace.malenum].mflags3 & M3_INFRAVISION) {
         /* although an infravision intrinsic is possible, infravision
@@ -2584,6 +2627,7 @@ role_init()
         if (urole.femalenum != NON_PM)
             mons[urole.femalenum].mflags3 |= M3_INFRAVISION;
     }
+#endif /*0*/
 
     /* Artifacts are fixed in hack_artifacts() */