Difference between revisions of "Source:NetHack 3.6.0/src/questpgr.c"

From NetHackWiki
Jump to navigation Jump to search
 
Line 47: Line 47:
 
  <span id="line40">40. static char nambuf[sizeof cvt_buf];</span>
 
  <span id="line40">40. static char nambuf[sizeof cvt_buf];</span>
 
  <span id="line41">41. </span>
 
  <span id="line41">41. </span>
 +
 +
== dump_qtlist ==
 +
   
 
  <span id="line42">42. /* dump the character msg list to check appearance;</span>
 
  <span id="line42">42. /* dump the character msg list to check appearance;</span>
 
  <span id="line43">43.   build with DEBUG enabled and use DEBUGFILES=questpgr.c</span>
 
  <span id="line43">43.   build with DEBUG enabled and use DEBUGFILES=questpgr.c</span>
Line 67: Line 70:
 
  <span id="line60">60. }</span>
 
  <span id="line60">60. }</span>
 
  <span id="line61">61. </span>
 
  <span id="line61">61. </span>
 +
 +
== Fread ==
 +
   
 
  <span id="line62">62. static void</span>
 
  <span id="line62">62. static void</span>
 
  <span id="line63">63. Fread(ptr, size, nitems, stream)</span>
 
  <span id="line63">63. Fread(ptr, size, nitems, stream)</span>
Line 81: Line 87:
 
  <span id="line74">74. }</span>
 
  <span id="line74">74. }</span>
 
  <span id="line75">75. </span>
 
  <span id="line75">75. </span>
 +
 +
== construct_qtlist ==
 +
   
 
  <span id="line76">76. STATIC_OVL struct qtmsg *</span>
 
  <span id="line76">76. STATIC_OVL struct qtmsg *</span>
 
  <span id="line77">77. construct_qtlist(hdr_offset)</span>
 
  <span id="line77">77. construct_qtlist(hdr_offset)</span>
Line 103: Line 112:
 
  <span id="line96">96. }</span>
 
  <span id="line96">96. }</span>
 
  <span id="line97">97. </span>
 
  <span id="line97">97. </span>
 +
 +
== load_qtlist ==
 +
   
 
  <span id="line98">98. void</span>
 
  <span id="line98">98. void</span>
 
  <span id="line99">99. load_qtlist()</span>
 
  <span id="line99">99. load_qtlist()</span>
Line 147: Line 159:
 
  <span id="line140">140. }</span>
 
  <span id="line140">140. }</span>
 
  <span id="line141">141. </span>
 
  <span id="line141">141. </span>
 +
 +
== unload_qtlist ==
 +
   
 
  <span id="line142">142. /* called at program exit */</span>
 
  <span id="line142">142. /* called at program exit */</span>
 
  <span id="line143">143. void</span>
 
  <span id="line143">143. void</span>
Line 160: Line 175:
 
  <span id="line153">153. }</span>
 
  <span id="line153">153. }</span>
 
  <span id="line154">154. </span>
 
  <span id="line154">154. </span>
 +
 +
== quest_info ==
 +
   
 
  <span id="line155">155. short</span>
 
  <span id="line155">155. short</span>
 
  <span id="line156">156. quest_info(typ)</span>
 
  <span id="line156">156. quest_info(typ)</span>
Line 179: Line 197:
 
  <span id="line172">172. }</span>
 
  <span id="line172">172. }</span>
 
  <span id="line173">173. </span>
 
  <span id="line173">173. </span>
 +
 +
== ldrname ==
 +
   
 
  <span id="line174">174. /* return your role leader's name */</span>
 
  <span id="line174">174. /* return your role leader's name */</span>
 
  <span id="line175">175. const char *</span>
 
  <span id="line175">175. const char *</span>
Line 190: Line 211:
 
  <span id="line183">183. }</span>
 
  <span id="line183">183. }</span>
 
  <span id="line184">184. </span>
 
  <span id="line184">184. </span>
 +
 +
== intermed ==
 +
   
 
  <span id="line185">185. /* return your intermediate target string */</span>
 
  <span id="line185">185. /* return your intermediate target string */</span>
 
  <span id="line186">186. STATIC_OVL const char *</span>
 
  <span id="line186">186. STATIC_OVL const char *</span>
Line 197: Line 221:
 
  <span id="line190">190. }</span>
 
  <span id="line190">190. }</span>
 
  <span id="line191">191. </span>
 
  <span id="line191">191. </span>
 +
 +
== is_quest_artifact ==
 +
   
 
  <span id="line192">192. boolean</span>
 
  <span id="line192">192. boolean</span>
 
  <span id="line193">193. is_quest_artifact(otmp)</span>
 
  <span id="line193">193. is_quest_artifact(otmp)</span>
Line 204: Line 231:
 
  <span id="line197">197. }</span>
 
  <span id="line197">197. }</span>
 
  <span id="line198">198. </span>
 
  <span id="line198">198. </span>
 +
 +
== neminame ==
 +
   
 
  <span id="line199">199. /* return your role nemesis' name */</span>
 
  <span id="line199">199. /* return your role nemesis' name */</span>
 
  <span id="line200">200. STATIC_OVL const char *</span>
 
  <span id="line200">200. STATIC_OVL const char *</span>
Line 215: Line 245:
 
  <span id="line208">208. }</span>
 
  <span id="line208">208. }</span>
 
  <span id="line209">209. </span>
 
  <span id="line209">209. </span>
 +
 +
== guardname ==
 +
   
 
  <span id="line210">210. STATIC_OVL const char *</span>
 
  <span id="line210">210. STATIC_OVL const char *</span>
 
  <span id="line211">211. guardname() /* return your role leader's guard monster name */</span>
 
  <span id="line211">211. guardname() /* return your role leader's guard monster name */</span>
Line 223: Line 256:
 
  <span id="line216">216. }</span>
 
  <span id="line216">216. }</span>
 
  <span id="line217">217. </span>
 
  <span id="line217">217. </span>
 +
 +
== homebase ==
 +
   
 
  <span id="line218">218. STATIC_OVL const char *</span>
 
  <span id="line218">218. STATIC_OVL const char *</span>
 
  <span id="line219">219. homebase() /* return your role leader's location */</span>
 
  <span id="line219">219. homebase() /* return your role leader's location */</span>
Line 229: Line 265:
 
  <span id="line222">222. }</span>
 
  <span id="line222">222. }</span>
 
  <span id="line223">223. </span>
 
  <span id="line223">223. </span>
 +
 +
== qtext_pronoun ==
 +
   
 
  <span id="line224">224. /* replace deity, leader, nemesis, or artifact name with pronoun;</span>
 
  <span id="line224">224. /* replace deity, leader, nemesis, or artifact name with pronoun;</span>
 
  <span id="line225">225.   overwrites cvt_buf[] */</span>
 
  <span id="line225">225.   overwrites cvt_buf[] */</span>
Line 268: Line 307:
 
  <span id="line261">261. }</span>
 
  <span id="line261">261. }</span>
 
  <span id="line262">262. </span>
 
  <span id="line262">262. </span>
 +
 +
== msg_in ==
 +
   
 
  <span id="line263">263. STATIC_OVL struct qtmsg *</span>
 
  <span id="line263">263. STATIC_OVL struct qtmsg *</span>
 
  <span id="line264">264. msg_in(qtm_list, msgnum)</span>
 
  <span id="line264">264. msg_in(qtm_list, msgnum)</span>
Line 282: Line 324:
 
  <span id="line275">275. }</span>
 
  <span id="line275">275. }</span>
 
  <span id="line276">276. </span>
 
  <span id="line276">276. </span>
 +
 +
== convert_arg ==
 +
   
 
  <span id="line277">277. STATIC_OVL void</span>
 
  <span id="line277">277. STATIC_OVL void</span>
 
  <span id="line278">278. convert_arg(c)</span>
 
  <span id="line278">278. convert_arg(c)</span>
Line 374: Line 419:
 
  <span id="line367">367. }</span>
 
  <span id="line367">367. }</span>
 
  <span id="line368">368. </span>
 
  <span id="line368">368. </span>
 +
 +
== convert_line ==
 +
   
 
  <span id="line369">369. STATIC_OVL void</span>
 
  <span id="line369">369. STATIC_OVL void</span>
 
  <span id="line370">370. convert_line(in_line, out_line)</span>
 
  <span id="line370">370. convert_line(in_line, out_line)</span>
Line 466: Line 514:
 
  <span id="line459">459. }</span>
 
  <span id="line459">459. }</span>
 
  <span id="line460">460. </span>
 
  <span id="line460">460. </span>
 +
 +
== deliver_by_pline ==
 +
   
 
  <span id="line461">461. STATIC_OVL void</span>
 
  <span id="line461">461. STATIC_OVL void</span>
 
  <span id="line462">462. deliver_by_pline(qt_msg)</span>
 
  <span id="line462">462. deliver_by_pline(qt_msg)</span>
Line 481: Line 532:
 
  <span id="line474">474. }</span>
 
  <span id="line474">474. }</span>
 
  <span id="line475">475. </span>
 
  <span id="line475">475. </span>
 +
 +
== deliver_by_window ==
 +
   
 
  <span id="line476">476. STATIC_OVL void</span>
 
  <span id="line476">476. STATIC_OVL void</span>
 
  <span id="line477">477. deliver_by_window(qt_msg, how)</span>
 
  <span id="line477">477. deliver_by_window(qt_msg, how)</span>
Line 531: Line 585:
 
  <span id="line524">524. }</span>
 
  <span id="line524">524. }</span>
 
  <span id="line525">525. </span>
 
  <span id="line525">525. </span>
 +
 +
== skip_pager ==
 +
   
 
  <span id="line526">526. boolean</span>
 
  <span id="line526">526. boolean</span>
 
  <span id="line527">527. skip_pager(common)</span>
 
  <span id="line527">527. skip_pager(common)</span>
Line 548: Line 605:
 
  <span id="line541">541. }</span>
 
  <span id="line541">541. }</span>
 
  <span id="line542">542. </span>
 
  <span id="line542">542. </span>
 +
 +
== com_pager ==
 +
   
 
  <span id="line543">543. void</span>
 
  <span id="line543">543. void</span>
 
  <span id="line544">544. com_pager(msgnum)</span>
 
  <span id="line544">544. com_pager(msgnum)</span>
Line 572: Line 632:
 
  <span id="line565">565. }</span>
 
  <span id="line565">565. }</span>
 
  <span id="line566">566. </span>
 
  <span id="line566">566. </span>
 +
 +
== qt_pager ==
 +
   
 
  <span id="line567">567. void</span>
 
  <span id="line567">567. void</span>
 
  <span id="line568">568. qt_pager(msgnum)</span>
 
  <span id="line568">568. qt_pager(msgnum)</span>
Line 594: Line 657:
 
  <span id="line587">587. }</span>
 
  <span id="line587">587. }</span>
 
  <span id="line588">588. </span>
 
  <span id="line588">588. </span>
 +
 +
== qt_montype ==
 +
   
 
  <span id="line589">589. struct permonst *</span>
 
  <span id="line589">589. struct permonst *</span>
 
  <span id="line590">590. qt_montype()</span>
 
  <span id="line590">590. qt_montype()</span>
Line 611: Line 677:
 
  <span id="line604">604. }</span>
 
  <span id="line604">604. }</span>
 
  <span id="line605">605. </span>
 
  <span id="line605">605. </span>
 +
 +
== deliver_splev_message ==
 +
   
 
  <span id="line606">606. /* special levels can include a custom arrival message; display it */</span>
 
  <span id="line606">606. /* special levels can include a custom arrival message; display it */</span>
 
  <span id="line607">607. void</span>
 
  <span id="line607">607. void</span>

Latest revision as of 22:10, 3 January 2016

Below is the full text to questpgr.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/questpgr.c#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

Top of file

 /* NetHack 3.6	questpgr.c	$NHDT-Date: 1448541043 2015/11/26 12:30:43 $  $NHDT-Branch: master $:$NHDT-Revision: 1.36 $ */
 /*      Copyright 1991, M. Stephenson                             */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
 #include "dlb.h"
 
 /*  quest-specific pager routines. */
 
 #include "qtext.h"
 
 #define QTEXT_FILE "quest.dat"
 
 #ifdef TTY_GRAPHICS
 #include "wintty.h"
 #endif
 
 /* from sp_lev.c, for deliver_splev_message() */
 extern char *lev_message;
 
 static void NDECL(dump_qtlist);
 static void FDECL(Fread, (genericptr_t, int, int, dlb *));
 STATIC_DCL struct qtmsg *FDECL(construct_qtlist, (long));
 STATIC_DCL const char *NDECL(intermed);
 STATIC_DCL const char *NDECL(neminame);
 STATIC_DCL const char *NDECL(guardname);
 STATIC_DCL const char *NDECL(homebase);
 STATIC_DCL void FDECL(qtext_pronoun, (CHAR_P, CHAR_P));
 STATIC_DCL struct qtmsg *FDECL(msg_in, (struct qtmsg *, int));
 STATIC_DCL void FDECL(convert_arg, (CHAR_P));
 STATIC_DCL void FDECL(convert_line, (char *,char *));
 STATIC_DCL void FDECL(deliver_by_pline, (struct qtmsg *));
 STATIC_DCL void FDECL(deliver_by_window, (struct qtmsg *, int));
 STATIC_DCL boolean FDECL(skip_pager, (BOOLEAN_P));
 
 static char cvt_buf[64];
 static struct qtlists qt_list;
 static dlb *msg_file;
 /* used by ldrname() and neminame(), then copied into cvt_buf */
 static char nambuf[sizeof cvt_buf];
 

dump_qtlist

 /* dump the character msg list to check appearance;
    build with DEBUG enabled and use DEBUGFILES=questpgr.c
    in sysconf file or environment */
 static void
 dump_qtlist()
 {
 #ifdef DEBUG
     struct qtmsg *msg;
 
     if (!explicitdebug(__FILE__))
         return;
 
     for (msg = qt_list.chrole; msg->msgnum > 0; msg++) {
         (void) dlb_fseek(msg_file, msg->offset, SEEK_SET);
         deliver_by_window(msg, NHW_MAP);
     }
 #endif /* DEBUG */
     return;
 }
 

Fread

 static void
 Fread(ptr, size, nitems, stream)
 genericptr_t ptr;
 int size, nitems;
 dlb *stream;
 {
     int cnt;
 
     if ((cnt = dlb_fread(ptr, size, nitems, stream)) != nitems) {
         panic("PREMATURE EOF ON QUEST TEXT FILE! Expected %d bytes, got %d",
               (size * nitems), (size * cnt));
     }
 }
 

construct_qtlist

 STATIC_OVL struct qtmsg *
 construct_qtlist(hdr_offset)
 long hdr_offset;
 {
     struct qtmsg *msg_list;
     int n_msgs;
 
     (void) dlb_fseek(msg_file, hdr_offset, SEEK_SET);
     Fread(&n_msgs, sizeof(int), 1, msg_file);
     msg_list = (struct qtmsg *) alloc((unsigned) (n_msgs + 1)
                                       * sizeof (struct qtmsg));
 
     /*
      * Load up the list.
      */
     Fread((genericptr_t) msg_list, n_msgs * sizeof (struct qtmsg), 1,
           msg_file);
 
     msg_list[n_msgs].msgnum = -1;
     return msg_list;
 }
 

load_qtlist

 void
 load_qtlist()
 {
     int n_classes, i;
     char qt_classes[N_HDR][LEN_HDR];
     long qt_offsets[N_HDR];
 
     msg_file = dlb_fopen(QTEXT_FILE, RDBMODE);
     if (!msg_file)
         panic("CANNOT OPEN QUEST TEXT FILE %s.", QTEXT_FILE);
 
     /*
      * Read in the number of classes, then the ID's & offsets for
      * each header.
      */
 
     Fread(&n_classes, sizeof (int), 1, msg_file);
     Fread(&qt_classes[0][0], sizeof (char) * LEN_HDR, n_classes, msg_file);
     Fread(qt_offsets, sizeof (long), n_classes, msg_file);
 
     /*
      * Now construct the message lists for quick reference later
      * on when we are actually paging the messages out.
      */
 
     qt_list.common = qt_list.chrole = (struct qtmsg *) 0;
 
     for (i = 0; i < n_classes; i++) {
         if (!strncmp(COMMON_ID, qt_classes[i], LEN_HDR))
             qt_list.common = construct_qtlist(qt_offsets[i]);
         else if (!strncmp(urole.filecode, qt_classes[i], LEN_HDR))
             qt_list.chrole = construct_qtlist(qt_offsets[i]);
 #if 0 /* UNUSED but available */
         else if (!strncmp(urace.filecode, qt_classes[i], LEN_HDR))
             qt_list.chrace = construct_qtlist(qt_offsets[i]);
 #endif
     }
 
     if (!qt_list.common || !qt_list.chrole)
         impossible("load_qtlist: cannot load quest text.");
     dump_qtlist();
     return; /* no ***DON'T*** close the msg_file */
 }
 

unload_qtlist

 /* called at program exit */
 void
 unload_qtlist()
 {
     if (msg_file)
         (void) dlb_fclose(msg_file), msg_file = 0;
     if (qt_list.common)
         free((genericptr_t) qt_list.common), qt_list.common = 0;
     if (qt_list.chrole)
         free((genericptr_t) qt_list.chrole), qt_list.chrole = 0;
     return;
 }
 

quest_info

 short
 quest_info(typ)
 int typ;
 {
     switch (typ) {
     case 0:
         return urole.questarti;
     case MS_LEADER:
         return urole.ldrnum;
     case MS_NEMESIS:
         return urole.neminum;
     case MS_GUARDIAN:
         return urole.guardnum;
     default:
         impossible("quest_info(%d)", typ);
     }
     return 0;
 }
 

ldrname

 /* return your role leader's name */
 const char *
 ldrname()
 {
     int i = urole.ldrnum;
 
     Sprintf(nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ",
             mons[i].mname);
     return nambuf;
 }
 

intermed

 /* return your intermediate target string */
 STATIC_OVL const char *
 intermed()
 {
     return urole.intermed;
 }
 

is_quest_artifact

 boolean
 is_quest_artifact(otmp)
 struct obj *otmp;
 {
     return (boolean) (otmp->oartifact == urole.questarti);
 }
 

neminame

 /* return your role nemesis' name */
 STATIC_OVL const char *
 neminame()
 {
     int i = urole.neminum;
 
     Sprintf(nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ",
             mons[i].mname);
     return nambuf;
 }
 

guardname

 STATIC_OVL const char *
 guardname() /* return your role leader's guard monster name */
 {
     int i = urole.guardnum;
 
     return mons[i].mname;
 }
 

homebase

 STATIC_OVL const char *
 homebase() /* return your role leader's location */
 {
     return urole.homebase;
 }
 

qtext_pronoun

 /* replace deity, leader, nemesis, or artifact name with pronoun;
    overwrites cvt_buf[] */
 STATIC_OVL void
 qtext_pronoun(who, which)
 char who,  /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => artifact */
     which; /* 'h'|'H'|'i'|'I'|'j'|'J' */
 {
     const char *pnoun;
     int g;
     char lwhich = lowc(which); /* H,I,J -> h,i,j */
 
     /*
      * Invalid subject (not d,l,n,o) yields neuter, singular result.
      *
      * For %o, treat all artifacts as neuter; some have plural names,
      * which genders[] doesn't handle; cvt_buf[] already contains name.
      */
     if (who == 'o'
         && (strstri(cvt_buf, "Eyes ")
             || strcmpi(cvt_buf, makesingular(cvt_buf)))) {
         pnoun = (lwhich == 'h') ? "they"
                 : (lwhich == 'i') ? "them"
                 : (lwhich == 'j') ? "their" : "?";
     } else {
         g = (who == 'd') ? quest_status.godgend
             : (who == 'l') ? quest_status.ldrgend
             : (who == 'n') ? quest_status.nemgend
             : 2; /* default to neuter */
         pnoun = (lwhich == 'h') ? genders[g].he
                 : (lwhich == 'i') ? genders[g].him
                 : (lwhich == 'j') ? genders[g].his : "?";
     }
     Strcpy(cvt_buf, pnoun);
     /* capitalize for H,I,J */
     if (lwhich != which)
         cvt_buf[0] = highc(cvt_buf[0]);
     return;
 }
 

msg_in

 STATIC_OVL struct qtmsg *
 msg_in(qtm_list, msgnum)
 struct qtmsg *qtm_list;
 int msgnum;
 {
     struct qtmsg *qt_msg;
 
     for (qt_msg = qtm_list; qt_msg->msgnum > 0; qt_msg++)
         if (qt_msg->msgnum == msgnum)
             return qt_msg;
 
     return (struct qtmsg *) 0;
 }
 

convert_arg

 STATIC_OVL void
 convert_arg(c)
 char c;
 {
     register const char *str;
 
     switch (c) {
     case 'p':
         str = plname;
         break;
     case 'c':
         str = (flags.female && urole.name.f) ? urole.name.f : urole.name.m;
         break;
     case 'r':
         str = rank_of(u.ulevel, Role_switch, flags.female);
         break;
     case 'R':
         str = rank_of(MIN_QUEST_LEVEL, Role_switch, flags.female);
         break;
     case 's':
         str = (flags.female) ? "sister" : "brother";
         break;
     case 'S':
         str = (flags.female) ? "daughter" : "son";
         break;
     case 'l':
         str = ldrname();
         break;
     case 'i':
         str = intermed();
         break;
     case 'O':
     case 'o':
         str = the(artiname(urole.questarti));
         if (c == 'O') {
             /* shorten "the Foo of Bar" to "the Foo"
                (buffer returned by the() is modifiable) */
             char *p = strstri(str, " of ");
 
             if (p)
                 *p = '\0';
         }
         break;
     case 'n':
         str = neminame();
         break;
     case 'g':
         str = guardname();
         break;
     case 'G':
         str = align_gtitle(u.ualignbase[A_ORIGINAL]);
         break;
     case 'H':
         str = homebase();
         break;
     case 'a':
         str = align_str(u.ualignbase[A_ORIGINAL]);
         break;
     case 'A':
         str = align_str(u.ualign.type);
         break;
     case 'd':
         str = align_gname(u.ualignbase[A_ORIGINAL]);
         break;
     case 'D':
         str = align_gname(A_LAWFUL);
         break;
     case 'C':
         str = "chaotic";
         break;
     case 'N':
         str = "neutral";
         break;
     case 'L':
         str = "lawful";
         break;
     case 'x':
         str = Blind ? "sense" : "see";
         break;
     case 'Z':
         str = dungeons[0].dname;
         break;
     case '%':
         str = "%";
         break;
     default:
         str = "";
         break;
     }
     Strcpy(cvt_buf, str);
 }
 

convert_line

 STATIC_OVL void
 convert_line(in_line, out_line)
 char *in_line, *out_line;
 {
     char *c, *cc;
     char xbuf[BUFSZ];
 
     cc = out_line;
     for (c = xcrypt(in_line, xbuf); *c; c++) {
         *cc = 0;
         switch (*c) {
         case '\r':
         case '\n':
             *(++cc) = 0;
             return;
 
         case '%':
             if (*(c + 1)) {
                 convert_arg(*(++c));
                 switch (*(++c)) {
                 /* insert "a"/"an" prefix */
                 case 'A':
                     Strcat(cc, An(cvt_buf));
                     cc += strlen(cc);
                     continue; /* for */
                 case 'a':
                     Strcat(cc, an(cvt_buf));
                     cc += strlen(cc);
                     continue; /* for */
 
                 /* capitalize */
                 case 'C':
                     cvt_buf[0] = highc(cvt_buf[0]);
                     break;
 
                 /* replace name with pronoun;
                    valid for %d, %l, %n, and %o */
                 case 'h': /* he/she */
                 case 'H': /* He/She */
                 case 'i': /* him/her */
                 case 'I':
                 case 'j': /* his/her */
                 case 'J':
                     if (index("dlno", lowc(*(c - 1))))
                         qtext_pronoun(*(c - 1), *c);
                     else
                         --c; /* default action */
                     break;
 
                 /* pluralize */
                 case 'P':
                     cvt_buf[0] = highc(cvt_buf[0]);
                 case 'p':
                     Strcpy(cvt_buf, makeplural(cvt_buf));
                     break;
 
                 /* append possessive suffix */
                 case 'S':
                     cvt_buf[0] = highc(cvt_buf[0]);
                 case 's':
                     Strcpy(cvt_buf, s_suffix(cvt_buf));
                     break;
 
                 /* strip any "the" prefix */
                 case 't':
                     if (!strncmpi(cvt_buf, "the ", 4)) {
                         Strcat(cc, &cvt_buf[4]);
                         cc += strlen(cc);
                         continue; /* for */
                     }
                     break;
 
                 default:
                     --c; /* undo switch increment */
                     break;
                 }
                 Strcat(cc, cvt_buf);
                 cc += strlen(cvt_buf);
                 break;
             } /* else fall through */
 
         default:
             *cc++ = *c;
             break;
         }
     }
     if (cc > &out_line[BUFSZ-1])
         panic("convert_line: overflow");
     *cc = 0;
     return;
 }
 

deliver_by_pline

 STATIC_OVL void
 deliver_by_pline(qt_msg)
 struct qtmsg *qt_msg;
 {
     long size;
     char in_line[BUFSZ], out_line[BUFSZ];
 
     *in_line = '\0';
     for (size = 0; size < qt_msg->size; size += (long) strlen(in_line)) {
         (void) dlb_fgets(in_line, sizeof in_line, msg_file);
         convert_line(in_line, out_line);
         pline("%s", out_line);
     }
 }
 

deliver_by_window

 STATIC_OVL void
 deliver_by_window(qt_msg, how)
 struct qtmsg *qt_msg;
 int how;
 {
     long size;
     char in_line[BUFSZ], out_line[BUFSZ];
     boolean qtdump = (how == NHW_MAP);
     winid datawin = create_nhwindow(qtdump ? NHW_TEXT : how);
 
 #ifdef DEBUG
     if (qtdump) {
         char buf[BUFSZ];
 
         /* when dumping quest messages at startup, all of them are passed to
          * deliver_by_window(), even if normally given to deliver_by_pline()
          */
         Sprintf(buf, "msgnum: %d, delivery: %c",
                 qt_msg->msgnum, qt_msg->delivery);
         putstr(datawin, 0, buf);
         putstr(datawin, 0, "");
     }
 #endif
     for (size = 0; size < qt_msg->size; size += (long) strlen(in_line)) {
         (void) dlb_fgets(in_line, sizeof in_line, msg_file);
         convert_line(in_line, out_line);
         putstr(datawin, 0, out_line);
     }
     display_nhwindow(datawin, TRUE);
     destroy_nhwindow(datawin);
 
     /* block messages delivered by window aren't kept in message history
        but have a one-line summary which is put there for ^P recall */
     *out_line = '\0';
     if (qt_msg->summary_size) {
         (void) dlb_fgets(in_line, sizeof in_line, msg_file);
         convert_line(in_line, out_line);
 #ifdef BETA
     } else if (qt_msg->delivery == 'c') { /* skip for 'qtdump' of 'p' */
         /* delivery 'c' and !summary_size, summary expected but not present;
            this doesn't prefix the number with role code vs 'general'
            but should be good enough for summary verification purposes */
         Sprintf(out_line, "[missing block message summary for #%05d]",
                 qt_msg->msgnum);
 #endif
     }
     if (*out_line)
         putmsghistory(out_line, FALSE);
 }
 

skip_pager

 boolean
 skip_pager(common)
 boolean common;
 {
     /* WIZKIT: suppress plot feedback if starting with quest artifact */
     if (program_state.wizkit_wishing)
         return TRUE;
     if (!(common ? qt_list.common : qt_list.chrole)) {
         panic("%s: no %s quest text data available",
               common ? "com_pager" : "qt_pager",
               common ? "common" : "role-specific");
         /*NOTREACHED*/
         return TRUE;
     }
     return FALSE;
 }
 

com_pager

 void
 com_pager(msgnum)
 int msgnum;
 {
     struct qtmsg *qt_msg;
 
     if (skip_pager(TRUE))
         return;
 
     if (!(qt_msg = msg_in(qt_list.common, msgnum))) {
         impossible("com_pager: message %d not found.", msgnum);
         return;
     }
 
     (void) dlb_fseek(msg_file, qt_msg->offset, SEEK_SET);
     if (qt_msg->delivery == 'p')
         deliver_by_pline(qt_msg);
     else if (msgnum == 1)
         deliver_by_window(qt_msg, NHW_MENU);
     else
         deliver_by_window(qt_msg, NHW_TEXT);
     return;
 }
 

qt_pager

 void
 qt_pager(msgnum)
 int msgnum;
 {
     struct qtmsg *qt_msg;
 
     if (skip_pager(FALSE))
         return;
 
     if (!(qt_msg = msg_in(qt_list.chrole, msgnum))) {
         impossible("qt_pager: message %d not found.", msgnum);
         return;
     }
 
     (void) dlb_fseek(msg_file, qt_msg->offset, SEEK_SET);
     if (qt_msg->delivery == 'p' && strcmp(windowprocs.name, "X11"))
         deliver_by_pline(qt_msg);
     else
         deliver_by_window(qt_msg, NHW_TEXT);
     return;
 }
 

qt_montype

 struct permonst *
 qt_montype()
 {
     int qpm;
 
     if (rn2(5)) {
         qpm = urole.enemy1num;
         if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD))
             return &mons[qpm];
         return mkclass(urole.enemy1sym, 0);
     }
     qpm = urole.enemy2num;
     if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD))
         return &mons[qpm];
     return mkclass(urole.enemy2sym, 0);
 }
 

deliver_splev_message

 /* special levels can include a custom arrival message; display it */
 void
 deliver_splev_message()
 {
     char *str, *nl, in_line[BUFSZ], out_line[BUFSZ];
 
     /* there's no provision for delivering via window instead of pline */
     if (lev_message) {
         /* lev_message can span multiple lines using embedded newline chars;
            any segments too long to fit within in_line[] will be truncated */
         for (str = lev_message; *str; str = nl + 1) {
             /* copying will stop at newline if one is present */
             copynchars(in_line, str, (int) (sizeof in_line) - 1);
 
             /* convert_line() expects encrypted input */
             (void) xcrypt(in_line, in_line);
             convert_line(in_line, out_line);
             pline("%s", out_line);
 
             if ((nl = index(str, '\n')) == 0)
                 break; /* done if no newline */
         }
 
         free((genericptr_t) lev_message);
         lev_message = 0;
     }
 }
 
 /*questpgr.c*/