eliminate implicit concatenation of strings

Explicitly combine adjacent string literals so that pre-ANSI compilers
still have a chance to compile the code.  I thought these had already
been dealt with, but I kept stumbling across them while reformatting,
so am trying to get them all out of the way now.
This commit is contained in:
PatR
2015-11-06 15:57:23 -08:00
parent 99925ff155
commit 449084fa6c
10 changed files with 216 additions and 198 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 eat.c $NHDT-Date: 1446808443 2015/11/06 11:14:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.151 $ */
/* NetHack 3.6 eat.c $NHDT-Date: 1446854226 2015/11/06 23:57:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.152 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2997,8 +2997,8 @@ struct obj *obj;
? (long) mons[obj->corpsenm].cnutrit
: (long) objects[obj->otyp].oc_nutrition;
if (uneaten_amt > full_amount) {
impossible("partly eaten food (%ld) more nutritious than untouched "
"food (%ld)",
impossible(
"partly eaten food (%ld) more nutritious than untouched food (%ld)",
uneaten_amt, full_amount);
uneaten_amt = full_amount;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1441753940 2015/09/08 23:12:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.183 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1446854228 2015/11/06 23:57:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.185 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -171,13 +171,13 @@ extern int n_dgns; /* from dungeon.c */
#endif
#ifdef SELECTSAVED
STATIC_DCL int FDECL(strcmp_wrap, (const void *, const void *));
STATIC_DCL int FDECL(CFDECLSPEC strcmp_wrap, (const void *, const void *));
#endif
STATIC_DCL char *FDECL(set_bonesfile_name, (char *, d_level *));
STATIC_DCL char *NDECL(set_bonestemp_name);
#ifdef COMPRESS
STATIC_DCL void FDECL(redirect,
(const char *, const char *, FILE *, BOOLEAN_P));
STATIC_DCL void FDECL(redirect, (const char *, const char *, FILE *,
BOOLEAN_P));
#endif
#if defined(COMPRESS) || defined(ZLIB_COMP)
STATIC_DCL void FDECL(docompress_file, (const char *, BOOLEAN_P));
@@ -208,25 +208,24 @@ STATIC_DCL int FDECL(open_levelfile_exclusively, (const char *, int, int));
* fname_encode()
*
* Args:
* legal zero-terminated list of acceptable file name
*characters
* quotechar lead-in character used to quote illegal characters as
*hex digits
* s string to encode
* callerbuf buffer to house result
* bufsz size of callerbuf
* legal zero-terminated list of acceptable file name characters
* quotechar lead-in character used to quote illegal characters as
* hex digits
* s string to encode
* callerbuf buffer to house result
* bufsz size of callerbuf
*
* Notes:
* The hex digits 0-9 and A-F are always part of the legal set due to
* their use in the encoding scheme, even if not explicitly included in
*'legal'.
* The hex digits 0-9 and A-F are always part of the legal set due to
* their use in the encoding scheme, even if not explicitly included in
* 'legal'.
*
* Sample:
* The following call:
* (void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
* '%', "This is a % test!", buf, 512);
* results in this encoding:
* "This%20is%20a%20%25%20test%21"
* The following call:
* (void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
* '%', "This is a % test!", buf, 512);
* results in this encoding:
* "This%20is%20a%20%25%20test%21"
*/
char *
fname_encode(legal, quotechar, s, callerbuf, bufsz)
@@ -270,11 +269,11 @@ int bufsz;
* fname_decode()
*
* Args:
* quotechar lead-in character used to quote illegal characters as
*hex digits
* s string to decode
* callerbuf buffer to house result
* bufsz size of callerbuf
* quotechar lead-in character used to quote illegal characters as
* hex digits
* s string to decode
* callerbuf buffer to house result
* bufsz size of callerbuf
*/
char *
fname_decode(quotechar, s, callerbuf, bufsz)
@@ -596,7 +595,8 @@ clearlocks()
}
#if defined(SELECTSAVED)
STATIC_OVL int
/* qsort comparison routine */
STATIC_OVL int CFDECLSPEC
strcmp_wrap(p, q)
const void *p;
const void *q;
@@ -649,6 +649,7 @@ void
really_close()
{
int fd = lftrack.fd;
lftrack.nethack_thinks_it_is_open = FALSE;
lftrack.fd = -1;
lftrack.oflag = 0;
@@ -670,6 +671,7 @@ int fd;
return close(fd);
}
#else
int
nhclose(fd)
int fd;
@@ -768,7 +770,7 @@ char errbuf[];
denies some or all access to world.
*/
(void) chmod(file, FCMASK | 007); /* allow other users full access */
#endif /* VMS && !SECURE */
#endif /* VMS && !SECURE */
return fd;
}
@@ -923,6 +925,7 @@ set_error_savefile()
#ifdef VMS
{
char *semi_colon = rindex(SAVEF, ';');
if (semi_colon)
*semi_colon = '\0';
}
@@ -954,11 +957,11 @@ create_savefile()
fd = creat(fq_save, FCMASK);
#endif
#if defined(VMS) && !defined(SECURE)
/*
Make sure the save file is owned by the current process. That's
the default for non-privileged users, but for priv'd users the
file will be owned by the directory's owner instead of the user.
*/
/*
Make sure the save file is owned by the current process. That's
the default for non-privileged users, but for priv'd users the
file will be owned by the directory's owner instead of the user.
*/
#undef getuid
(void) chown(fq_save, getuid(), getgid());
#define getuid() vms_getuid()
@@ -1056,17 +1059,18 @@ const char *filename;
#else
#define EXTSTR ""
#endif
if ( sscanf( filename, "%*[^/]/%d%63[^.]" EXTSTR, &uid, name ) == 2 ) {
#undef EXTSTR
/* "_" most likely means " ", which certainly looks nicer */
for (k=0; name[k]; k++)
if ( name[k]=='_' )
name[k]=' ';
return dupstr(name);
/* "_" most likely means " ", which certainly looks nicer */
for (k=0; name[k]; k++)
if ( name[k] == '_' )
name[k] = ' ';
return dupstr(name);
} else
#endif /* UNIX && QT_GRAPHICS */
{
return 0;
return 0;
}
/* --------- end of obsolete code ----*/
#endif /* 0 - WAS STORE_PLNAME_IN_FILE*/
@@ -1125,6 +1129,7 @@ get_saved_games()
closedir(dir);
if (n > 0) {
int i;
if (!(dir = opendir(fqname("save", SAVEPREFIX, 0))))
return 0;
result = (char **) alloc((n + 1) * sizeof(char *)); /* at most */
@@ -1133,12 +1138,14 @@ get_saved_games()
int uid;
char name[64]; /* more than PL_NSIZ */
struct dirent *entry = readdir(dir);
if (!entry)
break;
if (sscanf(entry->d_name, "%d%63s", &uid, name) == 2) {
if (uid == myuid) {
char filename[BUFSZ];
char *r;
Sprintf(filename, "save/%d%s", uid, name);
r = plname_from_file(filename);
if (r)
@@ -1158,7 +1165,7 @@ get_saved_games()
if (j > 0) {
if (j > 1)
qsort(result, j, sizeof(char *), strcmp_wrap);
qsort(result, j, sizeof (char *), strcmp_wrap);
result[j] = 0;
return result;
} else if (result) { /* could happen if save files are obsolete */
@@ -1174,6 +1181,7 @@ char **saved;
{
if (saved) {
int i = 0;
while (saved[i])
free((genericptr_t) saved[i++]);
free((genericptr_t) saved);
@@ -1404,6 +1412,7 @@ char *cfn;
#else
#ifdef SAVE_EXTENSION
char *bp = (char *) 0;
strcpy(cfn, filename);
if ((bp = strstri(cfn, SAVE_EXTENSION))) {
strsubst(bp, SAVE_EXTENSION, ".saz");
@@ -1707,8 +1716,8 @@ int retryct;
/* take a wild guess at the underlying cause */
HUP perror(lockname);
HUP raw_printf("Cannot lock %s.", filename);
HUP raw_printf("(Perhaps you are running NetHack from inside the "
"distribution package?).");
HUP raw_printf(
"(Perhaps you are running NetHack from inside the distribution package?).");
nesting--;
return FALSE;
default:
@@ -1884,9 +1893,9 @@ int src;
(void) strncpy(lastconfigfile, filename, BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0)
return (fp);
return fp;
if ((fp = fopenp(filename, "r")) != (FILE *) 0) {
return (fp);
return fp;
#if defined(UNIX) || defined(VMS)
} else {
/* access() above probably caught most problems for UNIX */
@@ -1900,15 +1909,15 @@ int src;
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) != (FILE *) 0)
return (fp);
return fp;
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
return (fp);
return fp;
#ifdef MSDOS
if ((fp = fopenp(fqname(backward_compat_configfile, CONFIGPREFIX, 0),
"r")) != (FILE *) 0)
return (fp);
return fp;
if ((fp = fopenp(backward_compat_configfile, "r")) != (FILE *) 0)
return (fp);
return fp;
#endif
#else
/* constructed full path names don't need fqname() */
@@ -1917,12 +1926,12 @@ int src;
BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0) {
return (fp);
return fp;
}
(void) strncpy(lastconfigfile, "sys$login:nethack.ini", BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0) {
return (fp);
return fp;
}
envp = nh_getenv("HOME");
@@ -1934,7 +1943,7 @@ int src;
(void) strncpy(lastconfigfile, tmp_config, BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(tmp_config, "r")) != (FILE *) 0)
return (fp);
return fp;
#else /* should be only UNIX left */
envp = nh_getenv("HOME");
if (!envp)
@@ -1945,7 +1954,7 @@ int src;
(void) strncpy(lastconfigfile, tmp_config, BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0)
return (fp);
return fp;
#if defined(__APPLE__)
/* try an alternative */
if (envp) {
@@ -1954,13 +1963,13 @@ int src;
(void) strncpy(lastconfigfile, tmp_config, BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0)
return (fp);
return fp;
Sprintf(tmp_config, "%s/%s", envp,
"Library/Preferences/NetHack Defaults.txt");
(void) strncpy(lastconfigfile, tmp_config, BUFSZ - 1);
lastconfigfile[BUFSZ - 1] = '\0';
if ((fp = fopenp(lastconfigfile, "r")) != (FILE *) 0)
return (fp);
return fp;
}
#endif
if (errno != ENOENT) {
@@ -2135,7 +2144,7 @@ int src;
} else if (match_varname(buf, "AUTOPICKUP_EXCEPTION", 5)) {
add_autopickup_exception(bufp);
} else if (match_varname(buf, "MSGTYPE", 7)) {
(void) msgtype_parse_add(bufp);
(void) msgtype_parse_add(bufp);
#ifdef NOCWD_ASSUMPTIONS
} else if (match_varname(buf, "HACKDIR", 4)) {
adjust_prefix(bufp, HACKPREFIX);
@@ -2398,11 +2407,13 @@ int src;
} else if (match_varname(buf, "DEPTH", 5)) {
extern int amii_numcolors;
int val = atoi(bufp);
amii_numcolors = 1L << min(DEPTH, val);
#ifdef SYSFLAGS
} else if (match_varname(buf, "DRIPENS", 7)) {
int i, val;
char *t;
for (i = 0, t = strtok(bufp, ",/"); t != (char *) 0;
i < 20 && (t = strtok((char *) 0, ",/")), ++i) {
sscanf(t, "%d", &val);
@@ -2411,6 +2422,7 @@ int src;
#endif
} else if (match_varname(buf, "SCREENMODE", 10)) {
extern long amii_scrnmode;
if (!stricmp(bufp, "req"))
amii_scrnmode = 0xffffffff; /* Requester */
else if (sscanf(bufp, "%x", &amii_scrnmode) != 1)
@@ -2418,6 +2430,7 @@ int src;
} else if (match_varname(buf, "MSGPENS", 7)) {
extern int amii_msgAPen, amii_msgBPen;
char *t = strtok(bufp, ",/");
if (t) {
sscanf(t, "%d", &amii_msgAPen);
if (t = strtok((char *) 0, ",/"))
@@ -2426,6 +2439,7 @@ int src;
} else if (match_varname(buf, "TEXTPENS", 8)) {
extern int amii_textAPen, amii_textBPen;
char *t = strtok(bufp, ",/");
if (t) {
sscanf(t, "%d", &amii_textAPen);
if (t = strtok((char *) 0, ",/"))
@@ -2434,6 +2448,7 @@ int src;
} else if (match_varname(buf, "MENUPENS", 8)) {
extern int amii_menuAPen, amii_menuBPen;
char *t = strtok(bufp, ",/");
if (t) {
sscanf(t, "%d", &amii_menuAPen);
if (t = strtok((char *) 0, ",/"))
@@ -2442,6 +2457,7 @@ int src;
} else if (match_varname(buf, "STATUSPENS", 10)) {
extern int amii_statAPen, amii_statBPen;
char *t = strtok(bufp, ",/");
if (t) {
sscanf(t, "%d", &amii_statAPen);
if (t = strtok((char *) 0, ",/"))
@@ -2450,6 +2466,7 @@ int src;
} else if (match_varname(buf, "OTHERPENS", 9)) {
extern int amii_otherAPen, amii_otherBPen;
char *t = strtok(bufp, ",/");
if (t) {
sscanf(t, "%d", &amii_otherAPen);
if (t = strtok((char *) 0, ",/"))
@@ -2497,18 +2514,22 @@ int src;
/* These should move to wc_ options */
} else if (match_varname(buf, "QT_TILEWIDTH", 12)) {
extern char *qt_tilewidth;
if (qt_tilewidth == NULL)
qt_tilewidth = dupstr(bufp);
} else if (match_varname(buf, "QT_TILEHEIGHT", 13)) {
extern char *qt_tileheight;
if (qt_tileheight == NULL)
qt_tileheight = dupstr(bufp);
} else if (match_varname(buf, "QT_FONTSIZE", 11)) {
extern char *qt_fontsize;
if (qt_fontsize == NULL)
qt_fontsize = dupstr(bufp);
} else if (match_varname(buf, "QT_COMPACT", 10)) {
extern int qt_compact_mode;
qt_compact_mode = atoi(bufp);
#endif
} else
@@ -2521,7 +2542,7 @@ boolean
can_read_file(filename)
const char *filename;
{
return (access(filename, 4) == 0);
return (boolean) (access(filename, 4) == 0);
}
#endif /* USER_SOUNDS */
@@ -2544,8 +2565,7 @@ int src;
#ifdef notyet
/*
XXX Don't call read() in parse_config_line, read as callback or reassemble
line
at this level.
line at this level.
OR: Forbid multiline stuff for alternate config sources.
*/
#endif
@@ -2591,7 +2611,7 @@ fopen_wizkit_file()
} else
#endif
if ((fp = fopenp(wizkit, "r")) != (FILE *) 0) {
return (fp);
return fp;
#if defined(UNIX) || defined(VMS)
} else {
/* access() above probably caught most problems for UNIX */
@@ -2603,7 +2623,7 @@ fopen_wizkit_file()
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
if ((fp = fopenp(fqname(wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0)
return (fp);
return fp;
#else
#ifdef VMS
envp = nh_getenv("HOME");
@@ -2612,7 +2632,7 @@ fopen_wizkit_file()
else
Sprintf(tmp_wizkit, "%s%s", "sys$login:", wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
return (fp);
return fp;
#else /* should be only UNIX left */
envp = nh_getenv("HOME");
if (envp)
@@ -2620,7 +2640,7 @@ fopen_wizkit_file()
else
Strcpy(tmp_wizkit, wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
return (fp);
return fp;
else if (errno != ENOENT) {
/* e.g., problems when setuid NetHack can't search home
* directory restricted to user */
@@ -2808,10 +2828,11 @@ int which_set;
values from the file, so only do that */
if (symp->range == SYM_CONTROL) {
struct symsetentry *tmpsp;
switch (symp->idx) {
case 0:
tmpsp =
(struct symsetentry *) alloc(sizeof(struct symsetentry));
(struct symsetentry *) alloc(sizeof (struct symsetentry));
tmpsp->next = (struct symsetentry *) 0;
if (!symset_list) {
symset_list = tmpsp;
@@ -2911,6 +2932,7 @@ int which_set;
case 5: /* restrictions: xxxx*/
if (chosen_symset_start) {
int n = 0;
while (known_restrictions[n]) {
if (!strcmpi(known_restrictions[n], bufp)) {
switch (n) {
@@ -3107,12 +3129,12 @@ recover_savefile()
processed[lev] = 0;
/* level 0 file contains:
* pid of creating process (ignored here)
* level number for current level of save file
* name of save file nethack would have created
* savefile info
* player name
* and game state
* pid of creating process (ignored here)
* level number for current level of save file
* name of save file nethack would have created
* savefile info
* player name
* and game state
*/
gfd = open_levelfile(0, errbuf);
if (gfd < 0) {
@@ -3120,15 +3142,16 @@ recover_savefile()
return FALSE;
}
if (read(gfd, (genericptr_t) &hpid, sizeof hpid) != sizeof hpid) {
raw_printf("\nCheckpoint data incompletely written or subsequently "
"clobbered. Recovery impossible.");
raw_printf("\n%s\n%s\n",
"Checkpoint data incompletely written or subsequently clobbered.",
"Recovery impossible.");
(void) nhclose(gfd);
return FALSE;
}
if (read(gfd, (genericptr_t) &savelev, sizeof(savelev))
!= sizeof(savelev)) {
raw_printf("\nCheckpointing was not in effect for %s -- recovery "
"impossible.\n",
raw_printf(
"\nCheckpointing was not in effect for %s -- recovery impossible.\n",
lock);
(void) nhclose(gfd);
return FALSE;
@@ -3147,12 +3170,12 @@ recover_savefile()
}
/* save file should contain:
* version info
* savefile info
* player name
* current level (including pets)
* (non-level-based) game state
* other levels
* version info
* savefile info
* player name
* current level (including pets)
* (non-level-based) game state
* other levels
*/
set_savefile_name(TRUE);
sfd = create_savefile();
@@ -3445,14 +3468,14 @@ char *nowin_buf;
/*
* Syntax (not case-sensitive):
* %section books
* %section books
*
* In the books section:
* %title booktitle(n)
* where booktitle=book title
* (n)= total number of passages present for this title
* %passage n
* where n=sequential passage number
* %title booktitle (n)
* where booktitle=book title without quotes
* (n)= total number of passages present for this title
* %passage k
* where k=sequential passage number
*
* %e ends the passage/book/section
* If in a passage, it marks the end of that passage.
@@ -3471,6 +3494,7 @@ char *nowin_buf;
case '%':
if (!strncmpi(&line[1], "section ", sizeof("section ") - 1)) {
char *st = &line[9]; /* 9 from "%section " */
scope = SECTIONSCOPE;
if (!strcmpi(st, tribsection))
matchedsection = TRUE;
@@ -3479,6 +3503,7 @@ char *nowin_buf;
} else if (!strncmpi(&line[1], "title ", sizeof("title ") - 1)) {
char *st = &line[7]; /* 7 from "%title " */
char *p1, *p2;
if ((p1 = index(st, '(')) != 0) {
*p1++ = '\0';
(void) mungspaces(st);
@@ -3508,6 +3533,7 @@ char *nowin_buf;
sizeof("passage ") - 1)) {
int passagenum = 0;
char *st = &line[9]; /* 9 from "%passage " */
while (*st == ' ' || *st == '\t')
st++;
if (*st && digit(*st) && (strlen(st) < 3))
@@ -3522,8 +3548,9 @@ char *nowin_buf;
}
}
} else if (!strncmpi(&line[1], "e ", sizeof("e ") - 1)) {
if (matchedtitle && (scope == PASSAGESCOPE)
&& ((!nowin_buf && tribwin != WIN_ERR) || (nowin_buf && foundpassage)))
if (matchedtitle && scope == PASSAGESCOPE
&& ((!nowin_buf && tribwin != WIN_ERR)
|| (nowin_buf && foundpassage)))
goto cleanup;
if (scope == TITLESCOPE)
matchedtitle = FALSE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitm.c $NHDT-Date: 1446604113 2015/11/04 02:28:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */
/* NetHack 3.6 mhitm.c $NHDT-Date: 1446854229 2015/11/06 23:57:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -568,8 +568,8 @@ struct attack *mattk;
}
if (mdef->minvis && !perceives(magr->data)) {
if (canseemon(magr)) {
pline("%s doesn't seem to notice that %s gaze was "
"reflected.",
pline(
"%s doesn't seem to notice that %s gaze was reflected.",
Monnam(magr), mhis(magr));
}
return MM_MISS;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitu.c $NHDT-Date: 1445556872 2015/10/22 23:34:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.129 $ */
/* NetHack 3.6 mhitu.c $NHDT-Date: 1446854230 2015/11/06 23:57:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.130 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -114,11 +114,9 @@ struct attack *mattk;
it's better than "sting" when not a stinging attack... */
return (!mwep || !mwep->opoisoned) ? "attack" : "weapon";
} else {
return (mattk->aatyp == AT_TUCH)
? "contact"
: (mattk->aatyp == AT_GAZE)
? "gaze"
: (mattk->aatyp == AT_BITE) ? "bite" : "sting";
return (mattk->aatyp == AT_TUCH) ? "contact"
: (mattk->aatyp == AT_GAZE) ? "gaze"
: (mattk->aatyp == AT_BITE) ? "bite" : "sting";
}
}
@@ -281,12 +279,12 @@ struct attack *alt_attk_buf;
/*
* mattacku: monster attacks you
* returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
* Note: if you're displaced or invisible the monster might attack the
* wrong position...
* Assumption: it's attacking you or an empty square; if there's another
* monster which it attacks by mistake, the caller had better
* take care of it...
* returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
* Note: if you're displaced or invisible the monster might attack the
* wrong position...
* Assumption: it's attacking you or an empty square; if there's another
* monster which it attacks by mistake, the caller had better
* take care of it...
*/
int
mattacku(mtmp)
@@ -323,9 +321,8 @@ register struct monst *mtmp;
foundyou = 1;
if (u.uinvulnerable)
return 0; /* stomachs can't hurt you! */
}
else if (u.usteed) {
} else if (u.usteed) {
if (mtmp == u.usteed)
/* Your steed won't attack you */
return 0;
@@ -410,9 +407,9 @@ register struct monst *mtmp;
} else {
/* surface hider */
if (!youseeit)
if (!youseeit) {
pline("It tries to move where you are hiding.");
else {
} else {
/* Ugly kludge for eggs. The message is phrased so as
* to be directed at the monster, not the player,
* which makes "laid by you" wrong. For the
@@ -425,6 +422,7 @@ register struct monst *mtmp;
|| (youmonst.data->mlet == S_EEL
&& is_pool(u.ux, u.uy))) {
int save_spe = 0; /* suppress warning */
if (obj) {
save_spe = obj->spe;
if (obj->otyp == EGG)
@@ -433,11 +431,11 @@ register struct monst *mtmp;
if (youmonst.data->mlet == S_EEL
|| u.umonnum == PM_TRAPPER)
pline(
"Wait, %s! There's a hidden %s named %s there!",
m_monnam(mtmp), youmonst.data->mname, plname);
"Wait, %s! There's a hidden %s named %s there!",
m_monnam(mtmp), youmonst.data->mname, plname);
else
pline("Wait, %s! There's a %s named %s hiding under "
"%s!",
pline(
"Wait, %s! There's a %s named %s hiding under %s!",
m_monnam(mtmp), youmonst.data->mname, plname,
doname(level.objects[u.ux][u.uy]));
if (obj)
@@ -486,6 +484,7 @@ register struct monst *mtmp;
plname);
if (multi < 0) { /* this should always be the case */
char buf[BUFSZ];
Sprintf(buf, "You appear to be %s again.",
Upolyd ? (const char *) an(youmonst.data->mname)
: (const char *) "yourself");
@@ -494,7 +493,7 @@ register struct monst *mtmp;
return 0;
}
/* Work out the armor class differential */
/* Work out the armor class differential */
tmp = AC_VALUE(u.uac) + 10; /* tmp ~= 0 - 20 */
tmp += mtmp->m_lev;
if (multi < 0)
@@ -512,14 +511,14 @@ register struct monst *mtmp;
newsym(mtmp->mx, mtmp->my);
}
/* Special demon handling code */
/* Special demon handling code */
if ((mtmp->cham == NON_PM) && is_demon(mdat) && !range2
&& mtmp->data != &mons[PM_BALROG] && mtmp->data != &mons[PM_SUCCUBUS]
&& mtmp->data != &mons[PM_INCUBUS])
if (!mtmp->mcan && !rn2(13))
(void) msummon(mtmp);
/* Special lycanthrope handling code */
/* Special lycanthrope handling code */
if ((mtmp->cham == NON_PM) && is_were(mdat) && !range2) {
if (is_human(mdat)) {
if (!rn2(5 - (night() * 2)) && !mtmp->mcan)
@@ -838,9 +837,9 @@ struct monst *mon;
/*
* hitmu: monster hits you
* returns 2 if monster dies (e.g. "yellow light"), 1 otherwise
* 3 if the monster lives but teleported/paralyzed, so it can't keep
* attacking you
* returns 2 if monster dies (e.g. "yellow light"), 1 otherwise
* 3 if the monster lives but teleported/paralyzed, so it can't keep
* attacking you
*/
STATIC_OVL int
hitmu(mtmp, mattk)
@@ -857,8 +856,8 @@ register struct attack *mattk;
if (!canspotmon(mtmp))
map_invisible(mtmp->mx, mtmp->my);
/* If the monster is undetected & hits you, you should know where
* the attack came from.
/* If the monster is undetected & hits you, you should know where
* the attack came from.
*/
if (mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) {
mtmp->mundetected = 0;
@@ -880,21 +879,20 @@ register struct attack *mattk;
}
}
/* First determine the base damage done */
/* First determine the base damage done */
dmg = d((int) mattk->damn, (int) mattk->damd);
if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight())
dmg += d((int) mattk->damn, (int) mattk->damd); /* extra damage */
/* Next a cancellation factor */
/* Use uncancelled when the cancellation factor takes into account
*certain
* armor's special magic protection. Otherwise just use !mtmp->mcan.
/* Next a cancellation factor.
* Use uncancelled when cancellation factor takes into account certain
* armor's special magic protection. Otherwise just use !mtmp->mcan.
*/
armpro = magic_negation(&youmonst);
uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro);
permdmg = 0;
/* Now, adjust damages via resistances or specific attacks */
/* Now, adjust damages via resistances or specific attacks */
switch (mattk->adtyp) {
case AD_PHYS:
if (mattk->aatyp == AT_HUGS && !sticks(youmonst.data)) {
@@ -1262,8 +1260,7 @@ register struct attack *mattk;
pline("%s %s.", Monnam(mtmp),
mtmp->minvent
? "brags about the goods some dungeon explorer provided"
: "makes some remarks about how difficult theft is "
"lately");
: "makes some remarks about how difficult theft is lately");
if (!tele_restrict(mtmp))
(void) rloc(mtmp, TRUE);
return 3;
@@ -1440,7 +1437,7 @@ register struct attack *mattk;
pline("You're covered in acid, but it seems harmless.");
dmg = 0;
} else {
pline("You're covered in acid! It burns!");
pline("You're covered in acid! It burns!");
exercise(A_STR, FALSE);
}
else
@@ -1551,8 +1548,8 @@ register struct attack *mattk;
if (u.uhp < 1)
done_in_by(mtmp, DIED);
/* Negative armor class reduces damage done instead of fully protecting
* against hits.
/* Negative armor class reduces damage done instead of fully protecting
* against hits.
*/
if (dmg && u.uac < 0) {
dmg -= rnd(-u.uac);
@@ -1572,11 +1569,11 @@ register struct attack *mattk;
int lowerlimit, *hpmax_p;
/*
* Apply some of the damage to permanent hit points:
* polymorphed 100% against poly'd hpmax
* hpmax > 25*lvl 100% against normal hpmax
* hpmax > 10*lvl 50..100%
* hpmax > 5*lvl 25..75%
* otherwise 0..50%
* polymorphed 100% against poly'd hpmax
* hpmax > 25*lvl 100% against normal hpmax
* hpmax > 10*lvl 50..100%
* hpmax > 5*lvl 25..75%
* otherwise 0..50%
* Never reduces hpmax below 1 hit point per level.
*/
permdmg = rn2(dmg / 2 + 1);
@@ -2026,8 +2023,8 @@ register struct attack *mattk;
break;
if (!m_canseeu(mtmp)) { /* probably you're invisible */
if (useeit)
pline("%s doesn't seem to notice that %s gaze was "
"reflected.",
pline(
"%s doesn't seem to notice that %s gaze was reflected.",
Monnam(mtmp), mhis(mtmp));
break;
}
@@ -2202,13 +2199,14 @@ register int n;
}
}
/* returns 0 if seduction impossible,
* 1 if fine,
* 2 if wrong gender for nymph
*/
int
could_seduce(magr, mdef, mattk)
struct monst *magr, *mdef;
struct attack *mattk;
/* returns 0 if seduction impossible,
* 1 if fine,
* 2 if wrong gender for nymph */
{
register struct permonst *pagr;
boolean agrinvis, defperc;
@@ -2327,10 +2325,9 @@ register struct monst *mon;
break; /* no point trying further rings */
}
if (rn2(20) < ACURR(A_CHA)) {
(void) safe_qbuf(
qbuf, "\"That ",
" looks pretty. Would you wear it for me?\"", ring,
xname, simpleonames, "ring");
(void) safe_qbuf(qbuf, "\"That ",
" looks pretty. Would you wear it for me?\"",
ring, xname, simpleonames, "ring");
makeknown(RIN_ADORNMENT);
if (yn(qbuf) == 'n')
continue;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1446808448 2015/11/06 11:14:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.235 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1446854231 2015/11/06 23:57:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.236 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4084,7 +4084,7 @@ boolean setinitial, setfromfile;
mttyp = query_msgtype();
if (mttyp == -1)
goto msgtypes_again;
if (!msgtype_add(mttyp, mtbuf)) {
if (!msgtype_add(mttyp, mtbuf)) {
pline("Error adding the message type.");
wait_synch();
goto msgtypes_again;
@@ -5017,8 +5017,7 @@ static const char *opt_intro[] = {
"-- for example, $ DEFINE NETHACKOPTIONS \"noautopickup,fruit:kumquat\"",
#endif
"or press \"O\" while playing and use the menu.", "",
"Boolean options (which can be negated by prefixing them with '!' or "
"\"no\"):",
"Boolean options (which can be negated by prefixing them with '!' or \"no\"):",
(char *) 0
};

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pray.c $NHDT-Date: 1446191091 2015/10/30 07:44:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.86 $ */
/* NetHack 3.6 pray.c $NHDT-Date: 1446854232 2015/11/06 23:57:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.87 $ */
/* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1017,8 +1017,8 @@ aligntyp g_align;
verbalize("Hark, %s!", youmonst.data->mlet == S_HUMAN
? "mortal"
: "creature");
verbalize("To enter the castle, thou must play the right "
"tune!");
verbalize(
"To enter the castle, thou must play the right tune!");
u.uevent.uheard_tune++;
break;
} else if (u.uevent.uheard_tune < 2) {
@@ -1236,8 +1236,8 @@ register struct obj *otmp;
Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
break;
case 2:
Your("sacrifice collapses into a cloud of dancing particles and "
"fades away!");
Your(
"sacrifice collapses into a cloud of dancing particles and fades away!");
break;
}
else if (Blind && u.ualign.type == A_LAWFUL)
@@ -1328,8 +1328,8 @@ dosacrifice()
/* Human sacrifice on a chaotic or unaligned altar */
/* is equivalent to demon summoning */
if (altaralign == A_CHAOTIC && u.ualign.type != A_CHAOTIC) {
pline("The blood floods the altar, which vanishes in %s "
"cloud!",
pline(
"The blood floods the altar, which vanishes in %s cloud!",
an(hcolor(NH_BLACK)));
levl[u.ux][u.uy].typ = ROOM;
levl[u.ux][u.uy].altarmask = 0;
@@ -1484,12 +1484,12 @@ dosacrifice()
} else { /* super big win */
adjalign(10);
u.uachieve.ascended = 1;
pline("An invisible choir sings, and you are bathed in "
"radiance...");
pline(
"An invisible choir sings, and you are bathed in radiance...");
godvoice(altaralign, "Congratulations, mortal!");
display_nhwindow(WIN_MESSAGE, FALSE);
verbalize("In return for thy service, I grant thee the gift "
"of Immortality!");
verbalize(
"In return for thy service, I grant thee the gift of Immortality!");
You("ascend to the status of Demigod%s...",
flags.female ? "dess" : "");
done(ASCENDED);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 read.c $NHDT-Date: 1446777536 2015/11/06 02:38:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.120 $ */
/* NetHack 3.6 read.c $NHDT-Date: 1446854233 2015/11/06 23:57:13 $ $NHDT-Branch: master $:$NHDT-Revision: 1.121 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -72,11 +72,9 @@ char *buf;
{
static const char *shirt_msgs[] = {
/* Scott Bigham */
"I explored the Dungeons of Doom and all I got was this lousy "
"T-shirt!",
"I explored the Dungeons of Doom and all I got was this lousy T-shirt!",
"Is that Mjollnir in your pocket or are you just happy to see me?",
"It's not the size of your sword, it's how #enhance'd you are with "
"it.",
"It's not the size of your sword, it's how #enhance'd you are with it.",
"Madame Elvira's House O' Succubi Lifetime Customer",
"Madame Elvira's House O' Succubi Employee of the Month",
"Ludios Vault Guards Do It In Small, Dark Rooms",
@@ -104,8 +102,7 @@ char *buf;
"I want to live forever or die in the attempt.", "Lichen Park",
"LOST IN THOUGHT - please send search party", "Meat is Mordor",
"Minetown Better Business Bureau", "Minetown Watch",
"Ms. Palm's House of Negotiable Affection -- A Very Reputable House "
"Of Disrepute",
"Ms. Palm's House of Negotiable Affection -- A Very Reputable House Of Disrepute",
"Protection Racketeer", "Real men love Crom",
"Somebody stole my Mojo!", "The Hellhound Gang", "The Werewolves",
"They Might Be Storm Giants",
@@ -292,8 +289,9 @@ doread()
maintained illiterate conduct so far, and this mail
scroll didn't come from bones, ask for confirmation */
if (!u.uconduct.literate) {
if (!scroll->spe && yn("Reading mail will violate \"illiterate\" "
"conduct. Read anyway?") != 'y')
if (!scroll->spe && yn(
"Reading mail will violate \"illiterate\" conduct. Read anyway?"
) != 'y')
return 0;
}
}
@@ -937,8 +935,8 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
case SCR_MAIL:
known = TRUE;
if (sobj->spe)
pline("This seems to be junk mail addressed to the finder of the "
"Eye of Larn.");
pline(
"This seems to be junk mail addressed to the finder of the Eye of Larn.");
/* note to the puzzled: the game Larn actually sends you junk
* mail if you win!
*/
@@ -1494,8 +1492,8 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (Hallucination) /* Ommmmmm! */
Your("mind releases itself from mundane concerns.");
else if (!strncmpi(plname, "Maud", 4))
pline("As your mind turns inward on itself, you forget "
"everything else.");
pline(
"As your mind turns inward on itself, you forget everything else.");
else if (rn2(2))
pline("Who was that Maud person anyway?");
else

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 shk.c $NHDT-Date: 1446713640 2015/11/05 08:54:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.115 $ */
/* NetHack 3.6 shk.c $NHDT-Date: 1446854234 2015/11/06 23:57:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.116 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2834,8 +2834,8 @@ xchar x, y;
if ((eshkp->robbed -= offer < 0L))
eshkp->robbed = 0L;
if (offer && !muteshk(shkp))
verbalize("Thank you for your contribution to restock this "
"recently plundered shop.");
verbalize(
"Thank you for your contribution to restock this recently plundered shop.");
subfrombill(obj, shkp);
return;
}
@@ -3012,16 +3012,13 @@ xchar x, y;
obj->no_charge = 1;
subfrombill(obj, shkp);
pay(-offer, shkp);
shk_names_obj(
shkp, obj,
(sell_how != SELL_NORMAL)
? (!ltmp && cltmp && only_partially_your_contents)
? "sold some items inside %s for %ld gold "
"piece%s.%s"
: "sold %s for %ld gold piece%s.%s"
: "relinquish %s and receive %ld gold piece%s in "
"compensation.%s",
offer, "");
shk_names_obj(shkp, obj,
(sell_how != SELL_NORMAL)
? ((!ltmp && cltmp && only_partially_your_contents)
? "sold some items inside %s for %ld gold piece%s.%s"
: "sold %s for %ld gold piece%s.%s")
: "relinquish %s and receive %ld gold piece%s in compensation.%s",
offer, "");
break;
default:
impossible("invalid sell response");

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 sp_lev.c $NHDT-Date: 1446713642 2015/11/05 08:54:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
/* NetHack 3.6 sp_lev.c $NHDT-Date: 1446854235 2015/11/06 23:57:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.69 $ */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
@@ -1652,8 +1652,8 @@ struct mkroom *croom;
break;
}
default:
impossible("create_monster: unimplemented mon appear type "
"[%d,\"%s\"]",
impossible(
"create_monster: unimplemented mon appear type [%d,\"%s\"]",
m->appear, m->appear_as.str);
break;
}
@@ -1841,8 +1841,8 @@ struct mkroom *croom;
remove_object(otmp);
if (mpickobj(invent_carrying_monster, otmp)) {
if (inuse > -1) {
impossible("container given to monster was merged or "
"deallocated.");
impossible(
"container given to monster was merged or deallocated.");
for (ci = inuse; ci < container_idx - 1; ci++)
container_obj[ci] = container_obj[ci + 1];
container_obj[container_idx] = NULL;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 spell.c $NHDT-Date: 1446632870 2015/11/04 10:27:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.68 $ */
/* NetHack 3.6 spell.c $NHDT-Date: 1446854236 2015/11/06 23:57:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.70 $ */
/* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */
@@ -182,8 +182,8 @@ struct obj *spellbook;
if (!rn2(3) && spellbook->otyp != SPE_BOOK_OF_THE_DEAD) {
spellbook->in_use = TRUE; /* in case called from learn */
pline("Being confused you have difficulties in controlling your "
"actions.");
pline(
"Being confused you have difficulties in controlling your actions.");
display_nhwindow(WIN_MESSAGE, FALSE);
You("accidentally tear the spellbook to pieces.");
if (!objects[spellbook->otyp].oc_name_known
@@ -387,9 +387,9 @@ learn(VOID_ARGS)
known, in case amnesia made you forget the book */
makeknown((int) booktype);
} else { /* (spellid(i) == NO_SPELL) */
/* for a normal book, spestudied will be zero, but for
a polymorphed one, spestudied will be non-zero and
one less reading is available than when re-learning */
/* for a normal book, spestudied will be zero, but for
a polymorphed one, spestudied will be non-zero and
one less reading is available than when re-learning */
if (book->spestudied >= MAX_SPELL_STUDY) {
/* pre-used due to being the product of polymorph */
pline("This spellbook is too faint to read even once.");
@@ -520,8 +520,8 @@ register struct obj *spellbook;
/* only wizards know if a spell is too difficult */
if (Role_if(PM_WIZARD) && read_ability < 20 && !confused) {
char qbuf[QBUFSZ];
Sprintf(qbuf, "This spellbook is %sdifficult to "
"comprehend. Continue?",
Sprintf(qbuf,
"This spellbook is %sdifficult to comprehend. Continue?",
(read_ability < 12 ? "very " : ""));
if (yn(qbuf) != 'y') {
spellbook->in_use = FALSE;