Move quest texts to lua
This commit is contained in:
3047
dat/quest.lua
Normal file
3047
dat/quest.lua
Normal file
File diff suppressed because it is too large
Load Diff
3521
dat/quest.txt
3521
dat/quest.txt
File diff suppressed because it is too large
Load Diff
@@ -2094,8 +2094,8 @@ E short FDECL(quest_info, (int));
|
||||
E const char *NDECL(ldrname);
|
||||
E boolean FDECL(is_quest_artifact, (struct obj *));
|
||||
E struct obj *FDECL(find_quest_artifact, (unsigned));
|
||||
E void FDECL(com_pager, (int));
|
||||
E void FDECL(qt_pager, (int));
|
||||
E void FDECL(com_pager, (const char *));
|
||||
E void FDECL(qt_pager, (const char *));
|
||||
E struct permonst *NDECL(qt_montype);
|
||||
E void NDECL(deliver_splev_message);
|
||||
|
||||
|
||||
@@ -622,7 +622,6 @@ newgame()
|
||||
if (iflags.news)
|
||||
display_file(NEWS, FALSE);
|
||||
#endif
|
||||
load_qtlist(); /* load up the quest text info */
|
||||
/* quest_init(); -- Now part of role_init() */
|
||||
|
||||
mklev();
|
||||
@@ -639,7 +638,7 @@ newgame()
|
||||
|
||||
if (flags.legacy) {
|
||||
flush_screen(1);
|
||||
com_pager(1);
|
||||
com_pager("legacy");
|
||||
}
|
||||
|
||||
urealtime.realtime = 0L;
|
||||
|
||||
4
src/do.c
4
src/do.c
@@ -1663,9 +1663,9 @@ boolean at_stairs, falling, portal;
|
||||
|| g.quest_status.leader_is_dead)) {
|
||||
if (!u.uevent.qcalled) {
|
||||
u.uevent.qcalled = 1;
|
||||
com_pager(2); /* main "leader needs help" message */
|
||||
com_pager("quest_portal"); /* main "leader needs help" message */
|
||||
} else { /* reminder message */
|
||||
com_pager(Role_if(PM_ROGUE) ? 4 : 3);
|
||||
com_pager(Role_if(PM_ROGUE) ? "quest_portal_demand" : "quest_portal_again");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
src/quest.c
62
src/quest.c
@@ -27,13 +27,13 @@ static void
|
||||
on_start()
|
||||
{
|
||||
if (!Qstat(first_start)) {
|
||||
qt_pager(QT_FIRSTTIME);
|
||||
qt_pager("firsttime");
|
||||
Qstat(first_start) = TRUE;
|
||||
} else if ((u.uz0.dnum != u.uz.dnum) || (u.uz0.dlevel < u.uz.dlevel)) {
|
||||
if (Qstat(not_ready) <= 2)
|
||||
qt_pager(QT_NEXTTIME);
|
||||
qt_pager("nexttime");
|
||||
else
|
||||
qt_pager(QT_OTHERTIME);
|
||||
qt_pager("othertime");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ on_locate()
|
||||
return;
|
||||
} else if (!Qstat(first_locate)) {
|
||||
if (from_above)
|
||||
qt_pager(QT_FIRSTLOCATE);
|
||||
qt_pager("locate_first");
|
||||
/* if we've arrived from below this will be a lie, but there won't
|
||||
be any point in delivering the message upon a return visit from
|
||||
above later since the level has now been seen */
|
||||
Qstat(first_locate) = TRUE;
|
||||
} else {
|
||||
if (from_above)
|
||||
qt_pager(QT_NEXTLOCATE);
|
||||
qt_pager("locate_next");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ on_goal()
|
||||
if (Qstat(killed_nemesis)) {
|
||||
return;
|
||||
} else if (!Qstat(made_goal)) {
|
||||
qt_pager(QT_FIRSTGOAL);
|
||||
qt_pager("goal_first");
|
||||
Qstat(made_goal) = 1;
|
||||
} else {
|
||||
/*
|
||||
@@ -81,7 +81,7 @@ on_goal()
|
||||
| (1 << OBJ_BURIED));
|
||||
struct obj *qarti = find_quest_artifact(whichobjchains);
|
||||
|
||||
qt_pager(qarti ? QT_NEXTGOAL : QT_ALTGOAL);
|
||||
qt_pager(qarti ? "goal_next" : "goal_alt");
|
||||
if (Qstat(made_goal) < 7)
|
||||
Qstat(made_goal)++;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ nemdead()
|
||||
{
|
||||
if (!Qstat(killed_nemesis)) {
|
||||
Qstat(killed_nemesis) = TRUE;
|
||||
qt_pager(QT_KILLEDNEM);
|
||||
qt_pager("killed_nemesis");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ struct obj *obj;
|
||||
obj->dknown = 1;
|
||||
/* only give this message once */
|
||||
Qstat(touched_artifact) = TRUE;
|
||||
qt_pager(QT_GOTIT);
|
||||
qt_pager("gotit");
|
||||
exercise(A_WIS, TRUE);
|
||||
}
|
||||
}
|
||||
@@ -221,16 +221,16 @@ struct obj *obj; /* quest artifact; possibly null if carrying Amulet */
|
||||
struct obj *otmp;
|
||||
|
||||
if (u.uhave.amulet) { /* unlikely but not impossible */
|
||||
qt_pager(QT_HASAMULET);
|
||||
qt_pager("hasamulet");
|
||||
/* leader IDs the real amulet but ignores any fakes */
|
||||
if ((otmp = carrying(AMULET_OF_YENDOR)) != 0)
|
||||
fully_identify_obj(otmp);
|
||||
} else {
|
||||
qt_pager(!Qstat(got_thanks) ? QT_OFFEREDIT : QT_OFFEREDIT2);
|
||||
qt_pager(!Qstat(got_thanks) ? "offeredit" : "offeredit2");
|
||||
/* should have obtained bell during quest;
|
||||
if not, suggest returning for it now */
|
||||
if ((otmp = carrying(BELL_OF_OPENING)) == 0)
|
||||
com_pager(5);
|
||||
com_pager("quest_complete_no_bell");
|
||||
}
|
||||
Qstat(got_thanks) = TRUE;
|
||||
|
||||
@@ -260,7 +260,7 @@ chat_with_leader()
|
||||
|
||||
/* Rule 2: You've gone back before going for the amulet. */
|
||||
else
|
||||
qt_pager(QT_POSTHANKS);
|
||||
qt_pager("posthanks");
|
||||
|
||||
/* Rule 3: You've got the artifact and are back to return it. */
|
||||
} else if (u.uhave.questart) {
|
||||
@@ -274,16 +274,16 @@ chat_with_leader()
|
||||
|
||||
/* Rule 4: You haven't got the artifact yet. */
|
||||
} else if (Qstat(got_quest)) {
|
||||
qt_pager(rn1(10, QT_ENCOURAGE));
|
||||
qt_pager("encourage");
|
||||
|
||||
/* Rule 5: You aren't yet acceptable - or are you? */
|
||||
} else {
|
||||
if (!Qstat(met_leader)) {
|
||||
qt_pager(QT_FIRSTLEADER);
|
||||
qt_pager("leader_first");
|
||||
Qstat(met_leader) = TRUE;
|
||||
Qstat(not_ready) = 0;
|
||||
} else
|
||||
qt_pager(QT_NEXTLEADER);
|
||||
qt_pager("leader_next");
|
||||
|
||||
/* the quest leader might have passed through the portal into
|
||||
the regular dungeon; none of the remaining make sense there */
|
||||
@@ -291,16 +291,16 @@ chat_with_leader()
|
||||
return;
|
||||
|
||||
if (not_capable()) {
|
||||
qt_pager(QT_BADLEVEL);
|
||||
qt_pager("badlevel");
|
||||
exercise(A_WIS, TRUE);
|
||||
expulsion(FALSE);
|
||||
} else if (is_pure(TRUE) < 0) {
|
||||
com_pager(QT_BANISHED);
|
||||
com_pager("banished");
|
||||
expulsion(TRUE);
|
||||
} else if (is_pure(TRUE) == 0) {
|
||||
qt_pager(QT_BADALIGN);
|
||||
qt_pager("badalign");
|
||||
if (Qstat(not_ready) == MAX_QUEST_TRIES) {
|
||||
qt_pager(QT_LASTLEADER);
|
||||
qt_pager("leader_last");
|
||||
expulsion(TRUE);
|
||||
} else {
|
||||
Qstat(not_ready)++;
|
||||
@@ -308,7 +308,7 @@ chat_with_leader()
|
||||
expulsion(FALSE);
|
||||
}
|
||||
} else { /* You are worthy! */
|
||||
qt_pager(QT_ASSIGNQUEST);
|
||||
qt_pager("assignquest");
|
||||
exercise(A_WIS, TRUE);
|
||||
Qstat(got_quest) = TRUE;
|
||||
}
|
||||
@@ -330,7 +330,7 @@ struct monst *mtmp;
|
||||
return;
|
||||
|
||||
if (Qstat(pissed_off)) {
|
||||
qt_pager(QT_LASTLEADER);
|
||||
qt_pager("leader_last");
|
||||
expulsion(TRUE);
|
||||
} else
|
||||
chat_with_leader();
|
||||
@@ -340,7 +340,7 @@ static void
|
||||
chat_with_nemesis()
|
||||
{
|
||||
/* The nemesis will do most of the talking, but... */
|
||||
qt_pager(rn1(10, QT_DISCOURAGE));
|
||||
qt_pager("discourage");
|
||||
if (!Qstat(met_nemesis))
|
||||
Qstat(met_nemesis++);
|
||||
}
|
||||
@@ -350,21 +350,21 @@ nemesis_speaks()
|
||||
{
|
||||
if (!Qstat(in_battle)) {
|
||||
if (u.uhave.questart)
|
||||
qt_pager(QT_NEMWANTSIT);
|
||||
qt_pager("nemesis_wantsit");
|
||||
else if (Qstat(made_goal) == 1 || !Qstat(met_nemesis))
|
||||
qt_pager(QT_FIRSTNEMESIS);
|
||||
qt_pager("nemesis_first");
|
||||
else if (Qstat(made_goal) < 4)
|
||||
qt_pager(QT_NEXTNEMESIS);
|
||||
qt_pager("nemesis_next");
|
||||
else if (Qstat(made_goal) < 7)
|
||||
qt_pager(QT_OTHERNEMESIS);
|
||||
qt_pager("nemesis_other");
|
||||
else if (!rn2(5))
|
||||
qt_pager(rn1(10, QT_DISCOURAGE));
|
||||
qt_pager("discourage");
|
||||
if (Qstat(made_goal) < 7)
|
||||
Qstat(made_goal)++;
|
||||
Qstat(met_nemesis) = TRUE;
|
||||
} else /* he will spit out random maledictions */
|
||||
if (!rn2(5))
|
||||
qt_pager(rn1(10, QT_DISCOURAGE));
|
||||
qt_pager("discourage");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -372,9 +372,9 @@ chat_with_guardian()
|
||||
{
|
||||
/* These guys/gals really don't have much to say... */
|
||||
if (u.uhave.questart && Qstat(killed_nemesis))
|
||||
qt_pager(rn1(5, QT_GUARDTALK2));
|
||||
qt_pager("guardtalk_after");
|
||||
else
|
||||
qt_pager(rn1(5, QT_GUARDTALK));
|
||||
qt_pager("guardtalk_before");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
333
src/questpgr.c
333
src/questpgr.c
@@ -9,15 +9,12 @@
|
||||
|
||||
#include "qtext.h"
|
||||
|
||||
#define QTEXT_FILE "quest.dat"
|
||||
#define QTEXT_FILE "quest.lua"
|
||||
|
||||
#ifdef TTY_GRAPHICS
|
||||
#include "wintty.h"
|
||||
#endif
|
||||
|
||||
static void NDECL(dump_qtlist);
|
||||
static void FDECL(Fread, (genericptr_t, int, int, dlb *));
|
||||
static struct qtmsg *FDECL(construct_qtlist, (long));
|
||||
static const char *NDECL(intermed);
|
||||
static struct obj *FDECL(find_qarti, (struct obj *));
|
||||
static const char *NDECL(neminame);
|
||||
@@ -27,123 +24,10 @@ static void FDECL(qtext_pronoun, (CHAR_P, CHAR_P));
|
||||
static struct qtmsg *FDECL(msg_in, (struct qtmsg *, int));
|
||||
static void FDECL(convert_arg, (CHAR_P));
|
||||
static void FDECL(convert_line, (char *,char *));
|
||||
static void FDECL(deliver_by_pline, (struct qtmsg *));
|
||||
static void FDECL(deliver_by_window, (struct qtmsg *, int));
|
||||
static void FDECL(deliver_by_pline, (const char *));
|
||||
static void FDECL(deliver_by_window, (const char *, int));
|
||||
static boolean FDECL(skip_pager, (BOOLEAN_P));
|
||||
|
||||
/* 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 = g.qt_list.chrole; msg->msgnum > 0; msg++) {
|
||||
(void) dlb_fseek(g.msg_file, msg->offset, SEEK_SET);
|
||||
deliver_by_window(msg, NHW_MAP);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
static struct qtmsg *
|
||||
construct_qtlist(hdr_offset)
|
||||
long hdr_offset;
|
||||
{
|
||||
struct qtmsg *msg_list;
|
||||
int n_msgs;
|
||||
|
||||
(void) dlb_fseek(g.msg_file, hdr_offset, SEEK_SET);
|
||||
Fread(&n_msgs, sizeof(int), 1, g.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,
|
||||
g.msg_file);
|
||||
|
||||
msg_list[n_msgs].msgnum = -1;
|
||||
return msg_list;
|
||||
}
|
||||
|
||||
void
|
||||
load_qtlist()
|
||||
{
|
||||
int n_classes, i;
|
||||
char qt_classes[N_HDR][LEN_HDR];
|
||||
long qt_offsets[N_HDR];
|
||||
|
||||
g.msg_file = dlb_fopen(QTEXT_FILE, RDBMODE);
|
||||
if (!g.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, g.msg_file);
|
||||
Fread(&qt_classes[0][0], sizeof (char) * LEN_HDR, n_classes, g.msg_file);
|
||||
Fread(qt_offsets, sizeof (long), n_classes, g.msg_file);
|
||||
|
||||
/*
|
||||
* Now construct the message lists for quick reference later
|
||||
* on when we are actually paging the messages out.
|
||||
*/
|
||||
|
||||
g.qt_list.common = g.qt_list.chrole = (struct qtmsg *) 0;
|
||||
|
||||
for (i = 0; i < n_classes; i++) {
|
||||
if (!strncmp(COMMON_ID, qt_classes[i], LEN_HDR))
|
||||
g.qt_list.common = construct_qtlist(qt_offsets[i]);
|
||||
else if (!strncmp(g.urole.filecode, qt_classes[i], LEN_HDR))
|
||||
g.qt_list.chrole = construct_qtlist(qt_offsets[i]);
|
||||
#if 0 /* UNUSED but available */
|
||||
else if (!strncmp(g.urace.filecode, qt_classes[i], LEN_HDR))
|
||||
g.qt_list.chrace = construct_qtlist(qt_offsets[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!g.qt_list.common || !g.qt_list.chrole)
|
||||
impossible("load_qtlist: cannot load quest text.");
|
||||
dump_qtlist();
|
||||
return; /* no ***DON'T*** close the msg_file */
|
||||
}
|
||||
|
||||
/* called at program exit */
|
||||
void
|
||||
unload_qtlist()
|
||||
{
|
||||
if (g.msg_file)
|
||||
(void) dlb_fclose(g.msg_file), g.msg_file = 0;
|
||||
if (g.qt_list.common)
|
||||
free((genericptr_t) g.qt_list.common), g.qt_list.common = 0;
|
||||
if (g.qt_list.chrole)
|
||||
free((genericptr_t) g.qt_list.chrole), g.qt_list.chrole = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
short
|
||||
quest_info(typ)
|
||||
int typ;
|
||||
@@ -418,7 +302,7 @@ char *in_line, *out_line;
|
||||
char xbuf[BUFSZ];
|
||||
|
||||
cc = out_line;
|
||||
for (c = xcrypt(in_line, xbuf); *c; c++) {
|
||||
for (c = in_line; *c; c++) {
|
||||
*cc = 0;
|
||||
switch (*c) {
|
||||
case '\r':
|
||||
@@ -505,68 +389,42 @@ char *in_line, *out_line;
|
||||
}
|
||||
|
||||
static void
|
||||
deliver_by_pline(qt_msg)
|
||||
struct qtmsg *qt_msg;
|
||||
deliver_by_pline(str)
|
||||
const char *str;
|
||||
{
|
||||
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, g.msg_file);
|
||||
convert_line(in_line, out_line);
|
||||
pline("%s", out_line);
|
||||
}
|
||||
Strcpy(in_line, str);
|
||||
convert_line(in_line, out_line);
|
||||
pline("%s", out_line);
|
||||
}
|
||||
|
||||
static void
|
||||
deliver_by_window(qt_msg, how)
|
||||
struct qtmsg *qt_msg;
|
||||
deliver_by_window(msg, how)
|
||||
const char *msg;
|
||||
int how;
|
||||
{
|
||||
long size;
|
||||
const char *msgp = msg;
|
||||
const char *msgend = eos((char *)msg);
|
||||
char in_line[BUFSZ], out_line[BUFSZ];
|
||||
boolean qtdump = (how == NHW_MAP);
|
||||
winid datawin = create_nhwindow(qtdump ? NHW_TEXT : how);
|
||||
winid datawin = create_nhwindow(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, g.msg_file);
|
||||
while (msgp && msgp != msgend) {
|
||||
int i = 0;
|
||||
while (*msgp != '\0' && *msgp != '\n' && (i < BUFSZ-2)) {
|
||||
in_line[i] = *msgp;
|
||||
i++;
|
||||
msgp++;
|
||||
}
|
||||
if (*msgp == '\n')
|
||||
msgp++;
|
||||
in_line[i] = '\0';
|
||||
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, g.msg_file);
|
||||
convert_line(in_line, out_line);
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
|
||||
} 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);
|
||||
}
|
||||
|
||||
static boolean
|
||||
@@ -576,71 +434,110 @@ boolean common;
|
||||
/* WIZKIT: suppress plot feedback if starting with quest artifact */
|
||||
if (g.program_state.wizkit_wishing)
|
||||
return TRUE;
|
||||
if (!(common ? g.qt_list.common : g.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;
|
||||
}
|
||||
|
||||
void
|
||||
com_pager(msgnum)
|
||||
int msgnum;
|
||||
boolean
|
||||
com_pager_core(section, msgid)
|
||||
const char *section;
|
||||
const char *msgid;
|
||||
{
|
||||
struct qtmsg *qt_msg;
|
||||
const char *const howtoput[] = { "pline", "window", "menu", NULL };
|
||||
const int howtoput2i[] = { 1, 2, 3, 0 };
|
||||
int output;
|
||||
lua_State *L;
|
||||
char *synopsis;
|
||||
char *text;
|
||||
|
||||
if (skip_pager(TRUE))
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
if (!(qt_msg = msg_in(g.qt_list.common, msgnum))) {
|
||||
impossible("com_pager: message %d not found.", msgnum);
|
||||
return;
|
||||
L = nhl_init();
|
||||
|
||||
if (!nhl_loadlua(L, QTEXT_FILE)) {
|
||||
impossible("com_pager: %s not found.", QTEXT_FILE);
|
||||
lua_close(L);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
(void) dlb_fseek(g.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);
|
||||
lua_settop(L, 0);
|
||||
lua_getglobal(L, "questtext");
|
||||
if (!lua_istable(L, -1)) {
|
||||
impossible("com_pager: questtext in %s is not a lua table", QTEXT_FILE);
|
||||
lua_close(L);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lua_getfield(L, -1, section);
|
||||
if (!lua_istable(L, -1)) {
|
||||
impossible("com_pager: questtext[%s] in %s is not a lua table", section, QTEXT_FILE);
|
||||
lua_close(L);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lua_getfield(L, -1, msgid);
|
||||
if (!lua_istable(L, -1)) {
|
||||
impossible("com_pager: questtext[%s][%s] in %s is not a lua table", section, msgid, QTEXT_FILE);
|
||||
lua_close(L);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
synopsis = get_table_str_opt(L, "synopsis", NULL);
|
||||
text = get_table_str_opt(L, "text", NULL);
|
||||
output = howtoput2i[get_table_option(L, "output", "pline", howtoput)];
|
||||
|
||||
if (!synopsis && !text) {
|
||||
int nelems;
|
||||
lua_len(L, -1);
|
||||
nelems = LUA_INTCAST(lua_tointeger(L, -1));
|
||||
lua_pop(L, 1);
|
||||
if (nelems < 2) {
|
||||
impossible("com_pager: questtext[%s][%s] in %s in not an array of strings", section, msgid, QTEXT_FILE);
|
||||
lua_close(L);
|
||||
return FALSE;
|
||||
}
|
||||
nelems = rn2(nelems) + 1;
|
||||
lua_pushinteger(L, nelems);
|
||||
lua_gettable(L, -2);
|
||||
text = dupstr(luaL_checkstring(L, -1));
|
||||
}
|
||||
|
||||
if ((index(text, '\n') || (strlen(text) >= (BUFSZ - 1))) && output == 1)
|
||||
output = 2;
|
||||
|
||||
if (output == 1)
|
||||
deliver_by_pline(text);
|
||||
else if (output == 3)
|
||||
deliver_by_window(text, NHW_MENU);
|
||||
else
|
||||
deliver_by_window(qt_msg, NHW_TEXT);
|
||||
return;
|
||||
deliver_by_window(text, NHW_TEXT);
|
||||
|
||||
if (synopsis) {
|
||||
char in_line[BUFSZ], out_line[BUFSZ];
|
||||
Strcpy(in_line, synopsis);
|
||||
convert_line(in_line, out_line);
|
||||
putmsghistory(out_line, FALSE);
|
||||
}
|
||||
|
||||
free(synopsis);
|
||||
free(text);
|
||||
lua_close(L);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
qt_pager(msgnum)
|
||||
int msgnum;
|
||||
com_pager(msgid)
|
||||
const char *msgid;
|
||||
{
|
||||
struct qtmsg *qt_msg;
|
||||
com_pager_core("common", msgid);
|
||||
}
|
||||
|
||||
if (skip_pager(FALSE))
|
||||
return;
|
||||
|
||||
qt_msg = msg_in(g.qt_list.chrole, msgnum);
|
||||
if (!qt_msg) {
|
||||
/* some roles have an alternate message for return to the goal
|
||||
level when the quest artifact is absent (handled by caller)
|
||||
but some don't; for the latter, use the normal goal message;
|
||||
note: for first visit, artifact is assumed to always be
|
||||
present which might not be true for wizard mode but we don't
|
||||
worry about quest message references in that situation */
|
||||
if (msgnum == QT_ALTGOAL)
|
||||
qt_msg = msg_in(g.qt_list.chrole, QT_NEXTGOAL);
|
||||
}
|
||||
if (!qt_msg) {
|
||||
impossible("qt_pager: message %d not found.", msgnum);
|
||||
return;
|
||||
}
|
||||
|
||||
(void) dlb_fseek(g.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;
|
||||
void
|
||||
qt_pager(msgid)
|
||||
const char *msgid;
|
||||
{
|
||||
if (!com_pager_core(g.urole.filecode, msgid))
|
||||
com_pager_core("common", msgid);
|
||||
}
|
||||
|
||||
struct permonst *
|
||||
@@ -674,8 +571,6 @@ deliver_splev_message()
|
||||
/* 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);
|
||||
|
||||
|
||||
@@ -1104,7 +1104,6 @@ NHFILE *nhfp;
|
||||
*/
|
||||
inven_inuse(FALSE);
|
||||
|
||||
load_qtlist(); /* re-load the quest text info */
|
||||
/* Set up the vision internals, after levl[] data is loaded
|
||||
but before docrt(). */
|
||||
reglyph_darkroom();
|
||||
|
||||
@@ -1285,7 +1285,6 @@ freedynamicdata()
|
||||
#endif
|
||||
zero_nhfile(&tnhfp); /* also sets fd to -1 */
|
||||
tnhfp.mode = FREEING;
|
||||
unload_qtlist();
|
||||
free_menu_coloring();
|
||||
free_invbuf(); /* let_to_name (invent.c) */
|
||||
free_youbuf(); /* You_buf,&c (pline.c) */
|
||||
|
||||
@@ -762,13 +762,14 @@ register struct monst *mtmp;
|
||||
random_insult[rn2(SIZE(random_insult))]);
|
||||
} else if (is_lminion(mtmp)
|
||||
&& !(mtmp->isminion && EMIN(mtmp)->renegade)) {
|
||||
com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
|
||||
+ QT_ANGELIC);
|
||||
com_pager("angel_cuss"); /* TODO: the Hallucination msg */
|
||||
/*com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
|
||||
+ QT_ANGELIC);*/
|
||||
} else {
|
||||
if (!rn2(is_minion(mtmp->data) ? 100 : 5))
|
||||
pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
|
||||
else
|
||||
com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
|
||||
com_pager("demon_cuss");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ NHSROOT=..
|
||||
# SHELL=E:/GEMINI2/MUPFEL.TTP
|
||||
# UUDECODE=uudecode
|
||||
|
||||
VARDAT = bogusmon data engrave epitaph rumors quest.dat oracles options
|
||||
VARDAT = bogusmon data engrave epitaph rumors quest.lua oracles options
|
||||
|
||||
all: $(VARDAT) spec_levs quest_levs
|
||||
|
||||
@@ -100,9 +100,6 @@ data: data.base ../util/makedefs
|
||||
rumors: rumors.tru rumors.fal ../util/makedefs
|
||||
../util/makedefs -r
|
||||
|
||||
quest.dat: quest.txt ../util/makedefs
|
||||
../util/makedefs -q
|
||||
|
||||
oracles: oracles.txt ../util/makedefs
|
||||
../util/makedefs -h
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ DIRPERM = 0755
|
||||
# for Gnome
|
||||
# VARDATND = x11tiles pet_mark.xbm pilemark.xbm rip.xpm mapbg.xpm
|
||||
|
||||
VARDATD = bogusmon data engrave epitaph oracles options quest.dat rumors
|
||||
VARDATD = bogusmon data engrave epitaph oracles options quest.lua rumors
|
||||
VARDAT = $(VARDATD) $(VARDATND)
|
||||
|
||||
# Some versions of make use the SHELL environment variable as the shell
|
||||
@@ -133,8 +133,7 @@ oracles: $(GAME)
|
||||
options: $(GAME)
|
||||
( cd dat ; $(MAKE) options )
|
||||
|
||||
quest.dat: $(GAME)
|
||||
( cd dat ; $(MAKE) quest.dat )
|
||||
quest.lua: $(GAME)
|
||||
|
||||
spec_levs:
|
||||
( cd dat ; $(MAKE) spec_levs )
|
||||
@@ -247,9 +246,6 @@ fetch-Lua:
|
||||
update: $(GAME) recover $(VARDAT) spec_levs
|
||||
# (don't yank the old version out from under people who're playing it)
|
||||
-mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old
|
||||
# quest.dat is also kept open and has the same problems over NFS
|
||||
# (quest.dat may be inside nhdat if dlb is in use)
|
||||
-mv $(INSTDIR)/quest.dat $(INSTDIR)/quest.dat.old
|
||||
-mv $(INSTDIR)/nhdat $(INSTDIR)/nhdat.old
|
||||
# set up new versions of the game files
|
||||
( $(MAKE) dofiles )
|
||||
|
||||
Reference in New Issue
Block a user