Reformat all C files.

I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
This commit is contained in:
Sean Hunt
2015-05-09 13:43:16 -04:00
parent 167800afdf
commit 97d6fade74
270 changed files with 182649 additions and 173878 deletions
+491 -438
View File
File diff suppressed because it is too large Load Diff
+58 -54
View File
@@ -1,14 +1,14 @@
/* NetHack 3.6 alloc.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 alloc.c $NHDT-Date: 1431192765 2015/05/09 17:32:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */
/* NetHack 3.6 alloc.c $Date: 2012/01/29 03:00:17 $ $Revision: 1.8 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* to get the malloc() prototype from system.h */
#define ALLOC_C /* comment line for pre-compiled headers */
#define ALLOC_C /* comment line for pre-compiled headers */
/* since this file is also used in auxiliary programs, don't include all the
* function declarations for all of nethack
*/
#define EXTERN_H /* comment line for pre-compiled headers */
#define EXTERN_H /* comment line for pre-compiled headers */
#include "config.h"
char *FDECL(fmt_ptr, (const genericptr));
@@ -16,49 +16,50 @@ char *FDECL(fmt_ptr, (const genericptr));
#ifdef MONITOR_HEAP
#undef alloc
#undef free
extern void FDECL(free,(genericptr_t));
extern void FDECL(free, (genericptr_t));
static void NDECL(heapmon_init);
static FILE *heaplog = 0;
static boolean tried_heaplog = FALSE;
#endif
long *FDECL(alloc,(unsigned int));
extern void VDECL(panic, (const char *,...)) PRINTF_F(1,2);
long *FDECL(alloc, (unsigned int));
extern void
VDECL(panic, (const char *, ...))
PRINTF_F(1, 2);
long *
alloc(lth)
register unsigned int lth;
long *alloc(lth) register unsigned int lth;
{
#ifdef LINT
/*
* a ridiculous definition, suppressing
* "possible pointer alignment problem" for (long *) malloc()
* from lint
*/
long dummy = ftell(stderr);
/*
* a ridiculous definition, suppressing
* "possible pointer alignment problem" for (long *) malloc()
* from lint
*/
long dummy = ftell(stderr);
if(lth) dummy = 0; /* make sure arg is used */
return(&dummy);
if (lth)
dummy = 0; /* make sure arg is used */
return (&dummy);
#else
register genericptr_t ptr;
register genericptr_t ptr;
ptr = malloc(lth);
ptr = malloc(lth);
#ifndef MONITOR_HEAP
if (!ptr) panic("Memory allocation failure; cannot get %u bytes", lth);
if (!ptr)
panic("Memory allocation failure; cannot get %u bytes", lth);
#endif
return((long *) ptr);
return ((long *) ptr);
#endif
}
# ifdef HAS_PTR_FMT
# define PTR_FMT "%p"
# define PTR_TYP genericptr_t
# else
# define PTR_FMT "%06lx"
# define PTR_TYP unsigned long
# endif
#ifdef HAS_PTR_FMT
#define PTR_FMT "%p"
#define PTR_TYP genericptr_t
#else
#define PTR_FMT "%06lx"
#define PTR_TYP unsigned long
#endif
/* A small pool of static formatting buffers.
* PTRBUFSIZ: We assume that pointers will be formatted as integers in
@@ -79,13 +80,14 @@ char *
fmt_ptr(ptr)
const genericptr ptr;
{
char *buf;
char *buf;
buf = ptrbuf[ptrbufidx];
if (++ptrbufidx >= PTRBUFCNT) ptrbufidx = 0;
buf = ptrbuf[ptrbufidx];
if (++ptrbufidx >= PTRBUFCNT)
ptrbufidx = 0;
Sprintf(buf, PTR_FMT, (PTR_TYP)ptr);
return buf;
Sprintf(buf, PTR_FMT, (PTR_TYP) ptr);
return buf;
}
#ifdef MONITOR_HEAP
@@ -95,11 +97,11 @@ const genericptr ptr;
static void
heapmon_init()
{
char *logname = getenv("NH_HEAPLOG");
char *logname = getenv("NH_HEAPLOG");
if (logname && *logname)
heaplog = fopen(logname, "w");
tried_heaplog = TRUE;
if (logname && *logname)
heaplog = fopen(logname, "w");
tried_heaplog = TRUE;
}
long *
@@ -108,17 +110,18 @@ unsigned int lth;
const char *file;
int line;
{
long *ptr = alloc(lth);
long *ptr = alloc(lth);
if (!tried_heaplog) heapmon_init();
if (heaplog)
(void) fprintf(heaplog, "+%5u %s %4d %s\n", lth,
fmt_ptr((genericptr_t)ptr), line, file);
/* potential panic in alloc() was deferred til here */
if (!ptr) panic("Cannot get %u bytes, line %d of %s",
lth, line, file);
if (!tried_heaplog)
heapmon_init();
if (heaplog)
(void) fprintf(heaplog, "+%5u %s %4d %s\n", lth,
fmt_ptr((genericptr_t) ptr), line, file);
/* potential panic in alloc() was deferred til here */
if (!ptr)
panic("Cannot get %u bytes, line %d of %s", lth, line, file);
return ptr;
return ptr;
}
void
@@ -127,12 +130,13 @@ genericptr_t ptr;
const char *file;
int line;
{
if (!tried_heaplog) heapmon_init();
if (heaplog)
(void) fprintf(heaplog, "- %s %4d %s\n",
fmt_ptr((genericptr_t)ptr), line, file);
if (!tried_heaplog)
heapmon_init();
if (heaplog)
(void) fprintf(heaplog, "- %s %4d %s\n",
fmt_ptr((genericptr_t) ptr), line, file);
free(ptr);
free(ptr);
}
/* strdup() which uses our alloc() rather than libc's malloc(),
@@ -143,7 +147,7 @@ const char *string;
const char *file;
int line;
{
return strcpy((char *)nhalloc(strlen(string) + 1, file, line), string);
return strcpy((char *) nhalloc(strlen(string) + 1, file, line), string);
}
#undef dupstr
@@ -156,7 +160,7 @@ char *
dupstr(string)
const char *string;
{
return strcpy((char *)alloc(strlen(string) + 1), string);
return strcpy((char *) alloc(strlen(string) + 1), string);
}
/*alloc.c*/
+2781 -2650
View File
File diff suppressed because it is too large Load Diff
+1303 -1196
View File
File diff suppressed because it is too large Load Diff
+815 -680
View File
File diff suppressed because it is too large Load Diff
+573 -566
View File
File diff suppressed because it is too large Load Diff
+496 -472
View File
File diff suppressed because it is too large Load Diff
+1208 -1083
View File
File diff suppressed because it is too large Load Diff
+2942 -2667
View File
File diff suppressed because it is too large Load Diff
+698 -657
View File
File diff suppressed because it is too large Load Diff
+130 -128
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.c $NHDT-Date: 1430897862 2015/05/06 07:37:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.56 $ */
/* NetHack 3.6 decl.c $NHDT-Date: 1431192766 2015/05/09 17:32:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
/* NetHack 3.6 decl.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.37 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -9,13 +9,13 @@ int NDECL((*afternmv));
int NDECL((*occupation));
/* from xxxmain.c */
const char *hname = 0; /* name of the game (argv[0] of main) */
int hackpid = 0; /* current process id */
const char *hname = 0; /* name of the game (argv[0] of main) */
int hackpid = 0; /* current process id */
#if defined(UNIX) || defined(VMS)
int locknum = 0; /* max num of simultaneous users */
int locknum = 0; /* max num of simultaneous users */
#endif
#ifdef DEF_PAGER
char *catmore = 0; /* default pager */
char *catmore = 0; /* default pager */
#endif
NEARDATA int bases[MAXOCLASSES] = DUMMY;
@@ -27,10 +27,9 @@ NEARDATA int nsubroom = 0;
NEARDATA int occtime = 0;
/* maze limits must be even; masking off lowest bit guarantees that */
int x_maze_max = (COLNO-1) & ~1,
y_maze_max = (ROWNO-1) & ~1;
int x_maze_max = (COLNO - 1) & ~1, y_maze_max = (ROWNO - 1) & ~1;
int otg_temp; /* used by object_to_glyph() [otg] */
int otg_temp; /* used by object_to_glyph() [otg] */
NEARDATA int in_doagain = 0;
@@ -38,24 +37,24 @@ NEARDATA int in_doagain = 0;
* The following structure will be initialized at startup time with
* the level numbers of some "important" things in the game.
*/
struct dgn_topology dungeon_topology = {DUMMY};
struct dgn_topology dungeon_topology = { DUMMY };
struct q_score quest_status = DUMMY;
struct q_score quest_status = DUMMY;
NEARDATA int warn_obj_cnt = 0;
NEARDATA int smeq[MAXNROFROOMS+1] = DUMMY;
NEARDATA int smeq[MAXNROFROOMS + 1] = DUMMY;
NEARDATA int doorindex = 0;
NEARDATA char *save_cm = 0;
NEARDATA struct kinfo killer = DUMMY;
NEARDATA long done_money = 0;
const char *nomovemsg = 0;
NEARDATA char plname[PL_NSIZ] = DUMMY; /* player name */
NEARDATA char plname[PL_NSIZ] = DUMMY; /* player name */
NEARDATA char pl_character[PL_CSIZ] = DUMMY;
NEARDATA char pl_race = '\0';
NEARDATA char pl_fruit[PL_FSIZ] = DUMMY;
NEARDATA struct fruit *ffruit = (struct fruit *)0;
NEARDATA struct fruit *ffruit = (struct fruit *) 0;
NEARDATA char tune[6] = DUMMY;
@@ -71,16 +70,15 @@ NEARDATA long yn_number = 0L;
const char disclosure_options[] = "iavgco";
#if defined(MICRO) || defined(WIN32)
char hackdir[PATHLEN]; /* where rumors, help, record are */
# ifdef MICRO
char levels[PATHLEN]; /* where levels are */
# endif
char hackdir[PATHLEN]; /* where rumors, help, record are */
#ifdef MICRO
char levels[PATHLEN]; /* where levels are */
#endif
#endif /* MICRO || WIN32 */
#ifdef MFLOPPY
char permbones[PATHLEN]; /* where permanent copy of bones go */
int ramdisk = FALSE; /* whether to copy bones to levels or not */
char permbones[PATHLEN]; /* where permanent copy of bones go */
int ramdisk = FALSE; /* whether to copy bones to levels or not */
int saveprompt = TRUE;
const char *alllevels = "levels.*";
const char *allbones = "bones*.*";
@@ -91,43 +89,45 @@ struct linfo level_info[MAXLINFO];
NEARDATA struct sinfo program_state;
/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */
const schar xdir[10] = { -1,-1, 0, 1, 1, 1, 0,-1, 0, 0 };
const schar ydir[10] = { 0,-1,-1,-1, 0, 1, 1, 1, 0, 0 };
const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1,-1 };
const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 };
const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 };
const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 };
NEARDATA schar tbx = 0, tby = 0; /* mthrowu: target */
NEARDATA schar tbx = 0, tby = 0; /* mthrowu: target */
/* for xname handling of multiple shot missile volleys:
number of shots, index of current one, validity check, shoot vs throw */
NEARDATA struct multishot m_shot = { 0, 0, STRANGE_OBJECT, FALSE };
NEARDATA dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */
NEARDATA dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */
NEARDATA s_level *sp_levchn;
NEARDATA stairway upstair = { 0, 0, { 0,0 }, 0 }, dnstair = { 0, 0, { 0,0 }, 0 };
NEARDATA stairway upladder = { 0, 0, { 0,0 }, 0 }, dnladder = { 0, 0, { 0,0 }, 0 };
NEARDATA stairway sstairs = { 0, 0, { 0,0 }, 0 };
NEARDATA stairway upstair = { 0, 0, { 0, 0 }, 0 },
dnstair = { 0, 0, { 0, 0 }, 0 };
NEARDATA stairway upladder = { 0, 0, { 0, 0 }, 0 },
dnladder = { 0, 0, { 0, 0 }, 0 };
NEARDATA stairway sstairs = { 0, 0, { 0, 0 }, 0 };
NEARDATA dest_area updest = { 0, 0, 0, 0, 0, 0, 0, 0 };
NEARDATA dest_area dndest = { 0, 0, 0, 0, 0, 0, 0, 0 };
NEARDATA coord inv_pos = { 0, 0 };
NEARDATA boolean defer_see_monsters = FALSE;
NEARDATA boolean in_mklev = FALSE;
NEARDATA boolean stoned = FALSE; /* done to monsters hit by 'c' */
NEARDATA boolean stoned = FALSE; /* done to monsters hit by 'c' */
NEARDATA boolean unweapon = FALSE;
NEARDATA boolean mrg_to_wielded = FALSE;
/* weapon picked is merged with wielded one */
/* weapon picked is merged with wielded one */
NEARDATA boolean in_steed_dismounting = FALSE;
NEARDATA coord bhitpos = DUMMY;
NEARDATA coord doors[DOORMAX] = {DUMMY};
NEARDATA coord doors[DOORMAX] = { DUMMY };
NEARDATA struct mkroom rooms[(MAXNROFROOMS+1)*2] = {DUMMY};
NEARDATA struct mkroom* subrooms = &rooms[MAXNROFROOMS+1];
NEARDATA struct mkroom rooms[(MAXNROFROOMS + 1) * 2] = { DUMMY };
NEARDATA struct mkroom *subrooms = &rooms[MAXNROFROOMS + 1];
struct mkroom *upstairs_room, *dnstairs_room, *sstairs_room;
dlevel_t level; /* level map */
struct trap *ftrap = (struct trap *)0;
dlevel_t level; /* level map */
struct trap *ftrap = (struct trap *) 0;
NEARDATA struct monst youmonst = DUMMY;
NEARDATA struct context_info context = DUMMY;
NEARDATA struct flag flags = DUMMY;
@@ -139,61 +139,60 @@ NEARDATA struct you u = DUMMY;
NEARDATA time_t ubirthday = DUMMY;
NEARDATA struct u_realtime urealtime = DUMMY;
schar lastseentyp[COLNO][ROWNO] = {
DUMMY
}; /* last seen/touched dungeon typ */
schar lastseentyp[COLNO][ROWNO] = {DUMMY}; /* last seen/touched dungeon typ */
NEARDATA struct obj *invent = (struct obj *)0,
*uwep = (struct obj *)0, *uarm = (struct obj *)0,
*uswapwep = (struct obj *)0,
*uquiver = (struct obj *)0, /* quiver */
*uarmu = (struct obj *)0, /* under-wear, so to speak */
*uskin = (struct obj *)0, /* dragon armor, if a dragon */
*uarmc = (struct obj *)0, *uarmh = (struct obj *)0,
*uarms = (struct obj *)0, *uarmg = (struct obj *)0,
*uarmf = (struct obj *)0, *uamul = (struct obj *)0,
*uright = (struct obj *)0,
*uleft = (struct obj *)0,
*ublindf = (struct obj *)0,
*uchain = (struct obj *)0,
*uball = (struct obj *)0;
/* some objects need special handling during destruction or placement */
NEARDATA struct obj
*current_wand = 0, /* wand currently zapped/applied */
*thrownobj = 0, /* object in flight due to throwing */
*kickedobj = 0; /* object in flight due to kicking */
*invent = (struct obj *) 0,
*uwep = (struct obj *) 0, *uarm = (struct obj *) 0,
*uswapwep = (struct obj *) 0,
*uquiver = (struct obj *) 0, /* quiver */
*uarmu = (struct obj *) 0, /* under-wear, so to speak */
*uskin = (struct obj *) 0, /* dragon armor, if a dragon */
*uarmc = (struct obj *) 0, *uarmh = (struct obj *) 0,
*uarms = (struct obj *) 0, *uarmg = (struct obj *) 0,
*uarmf = (struct obj *) 0, *uamul = (struct obj *) 0,
*uright = (struct obj *) 0, *uleft = (struct obj *) 0,
*ublindf = (struct obj *) 0, *uchain = (struct obj *) 0,
*uball = (struct obj *) 0;
/* some objects need special handling during destruction or placement */
NEARDATA struct obj *current_wand = 0, /* wand currently zapped/applied */
*thrownobj = 0, /* object in flight due to throwing */
*kickedobj = 0; /* object in flight due to kicking */
#ifdef TEXTCOLOR
/*
* This must be the same order as used for buzz() in zap.c.
*/
const int zapcolors[NUM_ZAP] = {
HI_ZAP, /* 0 - missile */
CLR_ORANGE, /* 1 - fire */
CLR_WHITE, /* 2 - frost */
HI_ZAP, /* 3 - sleep */
CLR_BLACK, /* 4 - death */
CLR_WHITE, /* 5 - lightning */
CLR_YELLOW, /* 6 - poison gas */
CLR_GREEN, /* 7 - acid */
HI_ZAP, /* 0 - missile */
CLR_ORANGE, /* 1 - fire */
CLR_WHITE, /* 2 - frost */
HI_ZAP, /* 3 - sleep */
CLR_BLACK, /* 4 - death */
CLR_WHITE, /* 5 - lightning */
CLR_YELLOW, /* 6 - poison gas */
CLR_GREEN, /* 7 - acid */
};
#endif /* text color */
const int shield_static[SHIELD_COUNT] = {
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
};
NEARDATA struct spell spl_book[MAXSPELL + 1] = {DUMMY};
NEARDATA struct spell spl_book[MAXSPELL + 1] = { DUMMY };
NEARDATA long moves = 1L, monstermoves = 1L;
/* These diverge when player is Fast */
/* These diverge when player is Fast */
NEARDATA long wailmsg = 0L;
/* objects that are moving to another dungeon level */
NEARDATA struct obj *migrating_objs = (struct obj *)0;
NEARDATA struct obj *migrating_objs = (struct obj *) 0;
/* objects not yet paid for */
NEARDATA struct obj *billobjs = (struct obj *)0;
NEARDATA struct obj *billobjs = (struct obj *) 0;
/* used to zero all elements of a struct obj */
NEARDATA struct obj zeroobj = DUMMY;
@@ -204,61 +203,63 @@ NEARDATA anything zeroany;
NEARDATA char dogname[PL_PSIZ] = DUMMY;
NEARDATA char catname[PL_PSIZ] = DUMMY;
NEARDATA char horsename[PL_PSIZ] = DUMMY;
char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */
char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */
/* monsters that went down/up together with @ */
NEARDATA struct monst *mydogs = (struct monst *)0;
NEARDATA struct monst *mydogs = (struct monst *) 0;
/* monsters that are moving to another dungeon level */
NEARDATA struct monst *migrating_mons = (struct monst *)0;
NEARDATA struct monst *migrating_mons = (struct monst *) 0;
NEARDATA struct mvitals mvitals[NUMMONS];
NEARDATA struct c_color_names c_color_names = {
"black", "amber", "golden",
"light blue", "red", "green",
"silver", "blue", "purple",
"white", "orange"
"black", "amber", "golden", "light blue", "red", "green",
"silver", "blue", "purple", "white", "orange"
};
struct menucoloring *menu_colorings = NULL;
const char *c_obj_colors[] = {
"black", /* CLR_BLACK */
"red", /* CLR_RED */
"green", /* CLR_GREEN */
"brown", /* CLR_BROWN */
"blue", /* CLR_BLUE */
"magenta", /* CLR_MAGENTA */
"cyan", /* CLR_CYAN */
"gray", /* CLR_GRAY */
"transparent", /* no_color */
"orange", /* CLR_ORANGE */
"bright green", /* CLR_BRIGHT_GREEN */
"yellow", /* CLR_YELLOW */
"bright blue", /* CLR_BRIGHT_BLUE */
"bright magenta", /* CLR_BRIGHT_MAGENTA */
"bright cyan", /* CLR_BRIGHT_CYAN */
"white", /* CLR_WHITE */
"black", /* CLR_BLACK */
"red", /* CLR_RED */
"green", /* CLR_GREEN */
"brown", /* CLR_BROWN */
"blue", /* CLR_BLUE */
"magenta", /* CLR_MAGENTA */
"cyan", /* CLR_CYAN */
"gray", /* CLR_GRAY */
"transparent", /* no_color */
"orange", /* CLR_ORANGE */
"bright green", /* CLR_BRIGHT_GREEN */
"yellow", /* CLR_YELLOW */
"bright blue", /* CLR_BRIGHT_BLUE */
"bright magenta", /* CLR_BRIGHT_MAGENTA */
"bright cyan", /* CLR_BRIGHT_CYAN */
"white", /* CLR_WHITE */
};
struct c_common_strings c_common_strings = {
"Nothing happens.", "That's enough tries!",
"That is a silly thing to %s.", "shudder for a moment.",
"something", "Something", "You can move again.", "Never mind.",
"vision quickly clears.", {"the", "your"}
};
struct c_common_strings c_common_strings = { "Nothing happens.",
"That's enough tries!",
"That is a silly thing to %s.",
"shudder for a moment.",
"something",
"Something",
"You can move again.",
"Never mind.",
"vision quickly clears.",
{ "the", "your" } };
/* NOTE: the order of these words exactly corresponds to the
order of oc_material values #define'd in objclass.h. */
const char *materialnm[] = {
"mysterious", "liquid", "wax", "organic", "flesh",
"paper", "cloth", "leather", "wooden", "bone", "dragonhide",
"iron", "metal", "copper", "silver", "gold", "platinum", "mithril",
"plastic", "glass", "gemstone", "stone"
};
const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
"flesh", "paper", "cloth", "leather",
"wooden", "bone", "dragonhide", "iron",
"metal", "copper", "silver", "gold",
"platinum", "mithril", "plastic", "glass",
"gemstone", "stone" };
/* Vision */
NEARDATA boolean vision_full_recalc = 0;
NEARDATA char **viz_array = 0;/* used in cansee() and couldsee() macros */
NEARDATA char **viz_array = 0; /* used in cansee() and couldsee() macros */
/* Global windowing data, defined here for multi-window-system support */
NEARDATA winid WIN_MESSAGE = WIN_ERR;
@@ -268,62 +269,63 @@ NEARDATA winid WIN_STATUS = WIN_ERR;
NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR;
char toplines[TBUFSZ];
/* Windowing stuff that's really tty oriented, but present for all ports */
struct tc_gbl_data tc_gbl_data = { 0,0, 0,0 }; /* AS,AE, LI,CO */
struct tc_gbl_data tc_gbl_data = { 0, 0, 0, 0 }; /* AS,AE, LI,CO */
char *fqn_prefix[PREFIX_COUNT] = { (char *)0, (char *)0, (char *)0, (char *)0,
(char *)0, (char *)0, (char *)0, (char *)0,
(char *)0 , (char *)0 };
char *fqn_prefix[PREFIX_COUNT] = { (char *) 0, (char *) 0, (char *) 0,
(char *) 0, (char *) 0, (char *) 0,
(char *) 0, (char *) 0, (char *) 0,
(char *) 0 };
#ifdef PREFIXES_IN_USE
char *fqn_prefix_names[PREFIX_COUNT] = { "hackdir", "leveldir", "savedir",
"bonesdir", "datadir", "scoredir",
"lockdir", "sysconfdir", "configdir",
"troubledir" };
char *fqn_prefix_names[PREFIX_COUNT] = {
"hackdir", "leveldir", "savedir", "bonesdir", "datadir",
"scoredir", "lockdir", "sysconfdir", "configdir", "troubledir"
};
#endif
NEARDATA struct savefile_info sfcap = {
#ifdef NHSTDC
0x00000000UL
0x00000000UL
#else
0x00000000L
0x00000000L
#endif
#if defined(COMPRESS) || defined(ZLIB_COMP)
| SFI1_EXTERNALCOMP
| SFI1_EXTERNALCOMP
#endif
#if defined(ZEROCOMP)
| SFI1_ZEROCOMP
| SFI1_ZEROCOMP
#endif
#if defined(RLECOMP)
| SFI1_RLECOMP
| SFI1_RLECOMP
#endif
,
,
#ifdef NHSTDC
0x00000000UL, 0x00000000UL
0x00000000UL, 0x00000000UL
#else
0x00000000L, 0x00000000L
0x00000000L, 0x00000000L
#endif
};
NEARDATA struct savefile_info sfrestinfo, sfsaveinfo = {
#ifdef NHSTDC
0x00000000UL
0x00000000UL
#else
0x00000000L
0x00000000L
#endif
#if defined(COMPRESS) || defined(ZLIB_COMP)
| SFI1_EXTERNALCOMP
| SFI1_EXTERNALCOMP
#endif
#if defined(ZEROCOMP)
| SFI1_ZEROCOMP
| SFI1_ZEROCOMP
#endif
#if defined(RLECOMP)
| SFI1_RLECOMP
| SFI1_RLECOMP
#endif
,
,
#ifdef NHSTDC
0x00000000UL, 0x00000000UL
0x00000000UL, 0x00000000UL
#else
0x00000000L, 0x00000000L
0x00000000L, 0x00000000L
#endif
};
+987 -873
View File
File diff suppressed because it is too large Load Diff
+1555 -1495
View File
File diff suppressed because it is too large Load Diff
+1263 -1138
View File
File diff suppressed because it is too large Load Diff
+197 -182
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 dlb.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 dlb.c $NHDT-Date: 1431192761 2015/05/09 17:32:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.13 $ */
/* NetHack 3.6 dlb.c $Date: 2012/02/16 03:01:37 $ $Revision: 1.10 $ */
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */
/* NetHack may be freely redistributed. See license for details. */
@@ -13,12 +13,12 @@
#define DATAPREFIX 4
#if defined(OVERLAY)
# define STATIC_DCL extern
# define STATIC_OVL
#else /* !OVERLAY */
# define STATIC_DCL static
# define STATIC_OVL static
#endif /* OVERLAY */
#define STATIC_DCL extern
#define STATIC_OVL
#else /* !OVERLAY */
#define STATIC_DCL static
#define STATIC_OVL static
#endif /* OVERLAY */
#ifdef DLB
/*
@@ -30,17 +30,17 @@
typedef struct dlb_procs {
boolean NDECL((*dlb_init_proc));
void NDECL((*dlb_cleanup_proc));
boolean FDECL((*dlb_fopen_proc), (DLB_P,const char *,const char *));
boolean FDECL((*dlb_fopen_proc), (DLB_P, const char *, const char *));
int FDECL((*dlb_fclose_proc), (DLB_P));
int FDECL((*dlb_fread_proc), (char *,int,int,DLB_P));
int FDECL((*dlb_fseek_proc), (DLB_P,long,int));
char *FDECL((*dlb_fgets_proc), (char *,int,DLB_P));
int FDECL((*dlb_fread_proc), (char *, int, int, DLB_P));
int FDECL((*dlb_fseek_proc), (DLB_P, long, int));
char *FDECL((*dlb_fgets_proc), (char *, int, DLB_P));
int FDECL((*dlb_fgetc_proc), (DLB_P));
long FDECL((*dlb_ftell_proc), (DLB_P));
} dlb_procs_t;
/* without extern.h via hack.h, these haven't been declared for us */
extern FILE *FDECL(fopen_datafile, (const char *,const char *,int));
extern FILE *FDECL(fopen_datafile, (const char *, const char *, int));
#ifdef DLBLIB
/*
@@ -62,28 +62,26 @@ extern FILE *FDECL(fopen_datafile, (const char *,const char *,int));
#define MAX_LIBS 4
static library dlb_libs[MAX_LIBS];
STATIC_DCL boolean FDECL(readlibdir,(library *lp));
STATIC_DCL boolean FDECL(find_file,(const char *name, library **lib, long *startp,
long *sizep));
STATIC_DCL boolean FDECL(readlibdir, (library * lp));
STATIC_DCL boolean FDECL(find_file, (const char *name, library **lib,
long *startp, long *sizep));
STATIC_DCL boolean NDECL(lib_dlb_init);
STATIC_DCL void NDECL(lib_dlb_cleanup);
STATIC_DCL boolean FDECL(lib_dlb_fopen,(dlb *, const char *, const char *));
STATIC_DCL int FDECL(lib_dlb_fclose,(dlb *));
STATIC_DCL int FDECL(lib_dlb_fread,(char *, int, int, dlb *));
STATIC_DCL int FDECL(lib_dlb_fseek,(dlb *, long, int));
STATIC_DCL char *FDECL(lib_dlb_fgets,(char *, int, dlb *));
STATIC_DCL int FDECL(lib_dlb_fgetc,(dlb *));
STATIC_DCL long FDECL(lib_dlb_ftell,(dlb *));
STATIC_DCL boolean FDECL(lib_dlb_fopen, (dlb *, const char *, const char *));
STATIC_DCL int FDECL(lib_dlb_fclose, (dlb *));
STATIC_DCL int FDECL(lib_dlb_fread, (char *, int, int, dlb *));
STATIC_DCL int FDECL(lib_dlb_fseek, (dlb *, long, int));
STATIC_DCL char *FDECL(lib_dlb_fgets, (char *, int, dlb *));
STATIC_DCL int FDECL(lib_dlb_fgetc, (dlb *));
STATIC_DCL long FDECL(lib_dlb_ftell, (dlb *));
/* not static because shared with dlb_main.c */
boolean FDECL(open_library,(const char *lib_name, library *lp));
void FDECL(close_library,(library *lp));
boolean FDECL(open_library, (const char *lib_name, library *lp));
void FDECL(close_library, (library * lp));
/* without extern.h via hack.h, these haven't been declared for us */
extern char *FDECL(eos, (char *));
/*
* Read the directory out of the library. Return 1 if successful,
* 0 if it failed.
@@ -116,8 +114,8 @@ extern char *FDECL(eos, (char *));
*
* followed by the contents of the files
*/
#define DLB_MIN_VERS 1 /* min library version readable by this code */
#define DLB_MAX_VERS 1 /* max library version readable by this code */
#define DLB_MIN_VERS 1 /* min library version readable by this code */
#define DLB_MAX_VERS 1 /* max library version readable by this code */
/*
* Read the directory from the library file. This will allocate and
@@ -128,43 +126,44 @@ extern char *FDECL(eos, (char *));
*/
STATIC_OVL boolean
readlibdir(lp)
library *lp; /* library pointer to fill in */
library *lp; /* library pointer to fill in */
{
int i;
char *sp;
long liboffset, totalsize;
if (fscanf(lp->fdata, "%ld %ld %ld %ld %ld\n",
&lp->rev,&lp->nentries,&lp->strsize,&liboffset,&totalsize) != 5)
return FALSE;
if (lp->rev > DLB_MAX_VERS || lp->rev < DLB_MIN_VERS) return FALSE;
if (fscanf(lp->fdata, "%ld %ld %ld %ld %ld\n", &lp->rev, &lp->nentries,
&lp->strsize, &liboffset, &totalsize) != 5)
return FALSE;
if (lp->rev > DLB_MAX_VERS || lp->rev < DLB_MIN_VERS)
return FALSE;
lp->dir = (libdir *) alloc(lp->nentries * sizeof(libdir));
lp->sspace = (char *) alloc(lp->strsize);
/* read in each directory entry */
for (i = 0, sp = lp->sspace; i < lp->nentries; i++) {
lp->dir[i].fname = sp;
if (fscanf(lp->fdata, "%c%s %ld\n",
&lp->dir[i].handling, sp, &lp->dir[i].foffset) != 3) {
free((genericptr_t) lp->dir);
free((genericptr_t) lp->sspace);
lp->dir = (libdir *) 0;
lp->sspace = (char *) 0;
return FALSE;
}
sp = eos(sp) + 1;
lp->dir[i].fname = sp;
if (fscanf(lp->fdata, "%c%s %ld\n", &lp->dir[i].handling, sp,
&lp->dir[i].foffset) != 3) {
free((genericptr_t) lp->dir);
free((genericptr_t) lp->sspace);
lp->dir = (libdir *) 0;
lp->sspace = (char *) 0;
return FALSE;
}
sp = eos(sp) + 1;
}
/* calculate file sizes using offset information */
for (i = 0; i < lp->nentries; i++) {
if (i == lp->nentries - 1)
lp->dir[i].fsize = totalsize - lp->dir[i].foffset;
else
lp->dir[i].fsize = lp->dir[i+1].foffset - lp->dir[i].foffset;
if (i == lp->nentries - 1)
lp->dir[i].fsize = totalsize - lp->dir[i].foffset;
else
lp->dir[i].fsize = lp->dir[i + 1].foffset - lp->dir[i].foffset;
}
(void) fseek(lp->fdata, 0L, SEEK_SET); /* reset back to zero */
(void) fseek(lp->fdata, 0L, SEEK_SET); /* reset back to zero */
lp->fmark = 0;
return TRUE;
@@ -176,23 +175,23 @@ readlibdir(lp)
*/
STATIC_OVL boolean
find_file(name, lib, startp, sizep)
const char *name;
library **lib;
long *startp, *sizep;
const char *name;
library **lib;
long *startp, *sizep;
{
int i, j;
library *lp;
for (i = 0; i < MAX_LIBS && dlb_libs[i].fdata; i++) {
lp = &dlb_libs[i];
for (j = 0; j < lp->nentries; j++) {
if (FILENAME_CMP(name, lp->dir[j].fname) == 0) {
*lib = lp;
*startp = lp->dir[j].foffset;
*sizep = lp->dir[j].fsize;
return TRUE;
}
}
lp = &dlb_libs[i];
for (j = 0; j < lp->nentries; j++) {
if (FILENAME_CMP(name, lp->dir[j].fname) == 0) {
*lib = lp;
*startp = lp->dir[j].foffset;
*sizep = lp->dir[j].fsize;
return TRUE;
}
}
}
*lib = (library *) 0;
*startp = *sizep = 0;
@@ -205,32 +204,32 @@ find_file(name, lib, startp, sizep)
*/
boolean
open_library(lib_name, lp)
const char *lib_name;
library *lp;
const char *lib_name;
library *lp;
{
boolean status = FALSE;
lp->fdata = fopen_datafile(lib_name, RDBMODE, DATAPREFIX);
if (lp->fdata) {
if (readlibdir(lp)) {
status = TRUE;
} else {
(void) fclose(lp->fdata);
lp->fdata = (FILE *) 0;
}
if (readlibdir(lp)) {
status = TRUE;
} else {
(void) fclose(lp->fdata);
lp->fdata = (FILE *) 0;
}
}
return status;
}
void
close_library(lp)
library *lp;
library *lp;
{
(void) fclose(lp->fdata);
free((genericptr_t) lp->dir);
free((genericptr_t) lp->sspace);
(void) memset((char *)lp, 0, sizeof(library));
(void) memset((char *) lp, 0, sizeof(library));
}
/*
@@ -241,14 +240,15 @@ STATIC_OVL boolean
lib_dlb_init(VOID_ARGS)
{
/* zero out array */
(void) memset((char *)&dlb_libs[0], 0, sizeof(dlb_libs));
(void) memset((char *) &dlb_libs[0], 0, sizeof(dlb_libs));
/* To open more than one library, add open library calls here. */
if (!open_library(DLBFILE, &dlb_libs[0])) return FALSE;
if (!open_library(DLBFILE, &dlb_libs[0]))
return FALSE;
#ifdef DLBFILE2
if (!open_library(DLBFILE2, &dlb_libs[1])) {
close_library(&dlb_libs[0]);
return FALSE;
if (!open_library(DLBFILE2, &dlb_libs[1])) {
close_library(&dlb_libs[0]);
return FALSE;
}
#endif
return TRUE;
@@ -261,35 +261,35 @@ lib_dlb_cleanup(VOID_ARGS)
/* close the data file(s) */
for (i = 0; i < MAX_LIBS && dlb_libs[i].fdata; i++)
close_library(&dlb_libs[i]);
close_library(&dlb_libs[i]);
}
/*ARGSUSED*/
STATIC_OVL boolean
lib_dlb_fopen(dp, name, mode)
dlb *dp;
const char *name;
const char *mode UNUSED;
dlb *dp;
const char *name;
const char *mode UNUSED;
{
long start, size;
library *lp;
/* look up file in directory */
if (find_file(name, &lp, &start, &size)) {
dp->lib = lp;
dp->start = start;
dp->size = size;
dp->mark = 0;
return TRUE;
dp->lib = lp;
dp->start = start;
dp->size = size;
dp->mark = 0;
return TRUE;
}
return FALSE; /* failed */
return FALSE; /* failed */
}
/*ARGUSED*/
STATIC_OVL int
lib_dlb_fclose(dp)
dlb *dp UNUSED;
dlb *dp UNUSED;
{
/* nothing needs to be done */
return 0;
@@ -297,21 +297,22 @@ lib_dlb_fclose(dp)
STATIC_OVL int
lib_dlb_fread(buf, size, quan, dp)
char *buf;
int size, quan;
dlb *dp;
char *buf;
int size, quan;
dlb *dp;
{
long pos, nread, nbytes;
/* make sure we don't read into the next file */
if ((dp->size - dp->mark) < (size * quan))
quan = (dp->size - dp->mark) / size;
if (quan == 0) return 0;
quan = (dp->size - dp->mark) / size;
if (quan == 0)
return 0;
pos = dp->start + dp->mark;
if (dp->lib->fmark != pos) {
fseek(dp->lib->fdata, pos, SEEK_SET); /* check for error??? */
dp->lib->fmark = pos;
fseek(dp->lib->fdata, pos, SEEK_SET); /* check for error??? */
dp->lib->fmark = pos;
}
nread = fread(buf, size, quan, dp->lib->fdata);
@@ -324,19 +325,27 @@ lib_dlb_fread(buf, size, quan, dp)
STATIC_OVL int
lib_dlb_fseek(dp, pos, whence)
dlb *dp;
long pos;
int whence;
dlb *dp;
long pos;
int whence;
{
long curpos;
switch (whence) {
case SEEK_CUR: curpos = dp->mark + pos; break;
case SEEK_END: curpos = dp->size - pos; break;
default: /* set */ curpos = pos; break;
case SEEK_CUR:
curpos = dp->mark + pos;
break;
case SEEK_END:
curpos = dp->size - pos;
break;
default: /* set */
curpos = pos;
break;
}
if (curpos < 0) curpos = 0;
if (curpos > dp->size) curpos = dp->size;
if (curpos < 0)
curpos = 0;
if (curpos > dp->size)
curpos = dp->size;
dp->mark = curpos;
return 0;
@@ -344,30 +353,33 @@ lib_dlb_fseek(dp, pos, whence)
STATIC_OVL char *
lib_dlb_fgets(buf, len, dp)
char *buf;
int len;
dlb *dp;
char *buf;
int len;
dlb *dp;
{
int i;
char *bp, c = 0;
if (len <= 0) return buf; /* sanity check */
if (len <= 0)
return buf; /* sanity check */
/* return NULL on EOF */
if (dp->mark >= dp->size) return (char *) 0;
if (dp->mark >= dp->size)
return (char *) 0;
len--; /* save room for null */
for (i = 0, bp = buf;
i < len && dp->mark < dp->size && c != '\n'; i++, bp++) {
if (dlb_fread(bp, 1, 1, dp) <= 0) break; /* EOF or error */
c = *bp;
len--; /* save room for null */
for (i = 0, bp = buf; i < len && dp->mark < dp->size && c != '\n';
i++, bp++) {
if (dlb_fread(bp, 1, 1, dp) <= 0)
break; /* EOF or error */
c = *bp;
}
*bp = '\0';
#if defined(MSDOS) || defined(WIN32)
if ((bp = index(buf, '\r')) != 0) {
*bp++ = '\n';
*bp = '\0';
*bp++ = '\n';
*bp = '\0';
}
#endif
@@ -376,51 +388,40 @@ lib_dlb_fgets(buf, len, dp)
STATIC_OVL int
lib_dlb_fgetc(dp)
dlb *dp;
dlb *dp;
{
char c;
if (lib_dlb_fread(&c, 1, 1, dp) != 1) return EOF;
if (lib_dlb_fread(&c, 1, 1, dp) != 1)
return EOF;
return (int) c;
}
STATIC_OVL long
lib_dlb_ftell(dp)
dlb *dp;
dlb *dp;
{
return dp->mark;
}
const dlb_procs_t lib_dlb_procs = {
lib_dlb_init,
lib_dlb_cleanup,
lib_dlb_fopen,
lib_dlb_fclose,
lib_dlb_fread,
lib_dlb_fseek,
lib_dlb_fgets,
lib_dlb_fgetc,
lib_dlb_ftell
};
const dlb_procs_t lib_dlb_procs = { lib_dlb_init, lib_dlb_cleanup,
lib_dlb_fopen, lib_dlb_fclose,
lib_dlb_fread, lib_dlb_fseek,
lib_dlb_fgets, lib_dlb_fgetc,
lib_dlb_ftell };
#endif /* DLBLIB */
#ifdef DLBRSRC
const dlb_procs_t rsrc_dlb_procs = {
rsrc_dlb_init,
rsrc_dlb_cleanup,
rsrc_dlb_fopen,
rsrc_dlb_fclose,
rsrc_dlb_fread,
rsrc_dlb_fseek,
rsrc_dlb_fgets,
rsrc_dlb_fgetc,
rsrc_dlb_ftell
};
const dlb_procs_t rsrc_dlb_procs = { rsrc_dlb_init, rsrc_dlb_cleanup,
rsrc_dlb_fopen, rsrc_dlb_fclose,
rsrc_dlb_fread, rsrc_dlb_fseek,
rsrc_dlb_fgets, rsrc_dlb_fgetc,
rsrc_dlb_ftell };
#endif
/* Global wrapper functions ------------------------------------------------ */
/* Global wrapper functions ------------------------------------------------
*/
#define do_dlb_init (*dlb_procs->dlb_init_proc)
#define do_dlb_cleanup (*dlb_procs->dlb_cleanup_proc)
@@ -440,14 +441,14 @@ dlb_init()
{
if (!dlb_initialized) {
#ifdef DLBLIB
dlb_procs = &lib_dlb_procs;
dlb_procs = &lib_dlb_procs;
#endif
#ifdef DLBRSRC
dlb_procs = &rsrc_dlb_procs;
dlb_procs = &rsrc_dlb_procs;
#endif
if (dlb_procs)
dlb_initialized = do_dlb_init();
if (dlb_procs)
dlb_initialized = do_dlb_init();
}
return dlb_initialized;
@@ -457,100 +458,114 @@ void
dlb_cleanup()
{
if (dlb_initialized) {
do_dlb_cleanup();
dlb_initialized = FALSE;
do_dlb_cleanup();
dlb_initialized = FALSE;
}
}
dlb *
dlb_fopen(name, mode)
const char *name, *mode;
const char *name, *mode;
{
FILE *fp;
dlb *dp;
if (!dlb_initialized) return (dlb *) 0;
if (!dlb_initialized)
return (dlb *) 0;
/* only support reading; ignore possible binary flag */
if (!mode || mode[0] != 'r') return (dlb *)0;
/* only support reading; ignore possible binary flag */
if (!mode || mode[0] != 'r')
return (dlb *) 0;
dp = (dlb *) alloc(sizeof(dlb));
if (do_dlb_fopen(dp, name, mode))
dp->fp = (FILE *) 0;
dp->fp = (FILE *) 0;
else if ((fp = fopen_datafile(name, mode, DATAPREFIX)) != 0)
dp->fp = fp;
dp->fp = fp;
else {
/* can't find anything */
free((genericptr_t) dp);
dp = (dlb *) 0;
}
/* can't find anything */
free((genericptr_t) dp);
dp = (dlb *) 0;
}
return dp;
}
int
dlb_fclose(dp)
dlb *dp;
dlb *dp;
{
int ret = 0;
int ret = 0;
if (dlb_initialized) {
if (dp->fp) ret = fclose(dp->fp);
else ret = do_dlb_fclose(dp);
if (dp->fp)
ret = fclose(dp->fp);
else
ret = do_dlb_fclose(dp);
free((genericptr_t) dp);
free((genericptr_t) dp);
}
return ret;
}
int
dlb_fread(buf, size, quan, dp)
char *buf;
int size, quan;
dlb *dp;
char *buf;
int size, quan;
dlb *dp;
{
if (!dlb_initialized || size <= 0 || quan <= 0) return 0;
if (dp->fp) return (int) fread(buf, size, quan, dp->fp);
if (!dlb_initialized || size <= 0 || quan <= 0)
return 0;
if (dp->fp)
return (int) fread(buf, size, quan, dp->fp);
return do_dlb_fread(buf, size, quan, dp);
}
int
dlb_fseek(dp, pos, whence)
dlb *dp;
long pos;
int whence;
dlb *dp;
long pos;
int whence;
{
if (!dlb_initialized) return EOF;
if (dp->fp) return fseek(dp->fp, pos, whence);
if (!dlb_initialized)
return EOF;
if (dp->fp)
return fseek(dp->fp, pos, whence);
return do_dlb_fseek(dp, pos, whence);
}
char *
dlb_fgets(buf, len, dp)
char *buf;
int len;
dlb *dp;
char *buf;
int len;
dlb *dp;
{
if (!dlb_initialized) return (char *) 0;
if (dp->fp) return fgets(buf, len, dp->fp);
if (!dlb_initialized)
return (char *) 0;
if (dp->fp)
return fgets(buf, len, dp->fp);
return do_dlb_fgets(buf, len, dp);
}
int
dlb_fgetc(dp)
dlb *dp;
dlb *dp;
{
if (!dlb_initialized) return EOF;
if (dp->fp) return fgetc(dp->fp);
if (!dlb_initialized)
return EOF;
if (dp->fp)
return fgetc(dp->fp);
return do_dlb_fgetc(dp);
}
long
dlb_ftell(dp)
dlb *dp;
dlb *dp;
{
if (!dlb_initialized) return 0;
if (dp->fp) return ftell(dp->fp);
if (!dlb_initialized)
return 0;
if (dp->fp)
return ftell(dp->fp);
return do_dlb_ftell(dp);
}
+822 -778
View File
File diff suppressed because it is too large Load Diff
+782 -749
View File
File diff suppressed because it is too large Load Diff
+1894 -1736
View File
File diff suppressed because it is too large Load Diff
+846 -792
View File
File diff suppressed because it is too large Load Diff
+880 -808
View File
File diff suppressed because it is too large Load Diff
+1471 -1366
View File
File diff suppressed because it is too large Load Diff
+1467 -1399
View File
File diff suppressed because it is too large Load Diff
+511 -515
View File
File diff suppressed because it is too large Load Diff
+1569 -1455
View File
File diff suppressed because it is too large Load Diff
+2385 -2291
View File
File diff suppressed because it is too large Load Diff
+1247 -1164
View File
File diff suppressed because it is too large Load Diff
+1027 -981
View File
File diff suppressed because it is too large Load Diff
+235 -208
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 exper.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 exper.c $NHDT-Date: 1431192764 2015/05/09 17:32:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
/* NetHack 3.6 exper.c $Date: 2009/05/06 10:46:24 $ $Revision: 1.19 $ */
/* SCCS Id: @(#)exper.c 3.5 2005/09/19 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -14,28 +14,30 @@ STATIC_OVL long
newuexp(lev)
int lev;
{
if (lev < 10) return (10L * (1L << lev));
if (lev < 20) return (10000L * (1L << (lev - 10)));
return (10000000L * ((long)(lev - 19)));
if (lev < 10)
return (10L * (1L << lev));
if (lev < 20)
return (10000L * (1L << (lev - 10)));
return (10000000L * ((long) (lev - 19)));
}
STATIC_OVL int
enermod(en)
int en;
{
switch (Role_switch) {
case PM_PRIEST:
case PM_WIZARD:
return(2 * en);
case PM_HEALER:
case PM_KNIGHT:
return((3 * en) / 2);
case PM_BARBARIAN:
case PM_VALKYRIE:
return((3 * en) / 4);
default:
return (en);
}
switch (Role_switch) {
case PM_PRIEST:
case PM_WIZARD:
return (2 * en);
case PM_HEALER:
case PM_KNIGHT:
return ((3 * en) / 2);
case PM_BARBARIAN:
case PM_VALKYRIE:
return ((3 * en) / 4);
default:
return (en);
}
}
/* calculate spell power/energy points for new level */
@@ -45,178 +47,199 @@ newpw()
int en = 0, enrnd, enfix;
if (u.ulevel == 0) {
en = urole.enadv.infix + urace.enadv.infix;
if (urole.enadv.inrnd > 0) en += rnd(urole.enadv.inrnd);
if (urace.enadv.inrnd > 0) en += rnd(urace.enadv.inrnd);
en = urole.enadv.infix + urace.enadv.infix;
if (urole.enadv.inrnd > 0)
en += rnd(urole.enadv.inrnd);
if (urace.enadv.inrnd > 0)
en += rnd(urace.enadv.inrnd);
} else {
enrnd = (int)ACURR(A_WIS) / 2;
if (u.ulevel < urole.xlev) {
enrnd += urole.enadv.lornd + urace.enadv.lornd;
enfix = urole.enadv.lofix + urace.enadv.lofix;
} else {
enrnd += urole.enadv.hirnd + urace.enadv.hirnd;
enfix = urole.enadv.hifix + urace.enadv.hifix;
}
en = enermod(rn1(enrnd, enfix));
enrnd = (int) ACURR(A_WIS) / 2;
if (u.ulevel < urole.xlev) {
enrnd += urole.enadv.lornd + urace.enadv.lornd;
enfix = urole.enadv.lofix + urace.enadv.lofix;
} else {
enrnd += urole.enadv.hirnd + urace.enadv.hirnd;
enfix = urole.enadv.hifix + urace.enadv.hifix;
}
en = enermod(rn1(enrnd, enfix));
}
if (en <= 0) en = 1;
if (u.ulevel < MAXULEV) u.ueninc[u.ulevel] = (xchar)en;
if (en <= 0)
en = 1;
if (u.ulevel < MAXULEV)
u.ueninc[u.ulevel] = (xchar) en;
return en;
}
int
experience(mtmp, nk) /* return # of exp points for mtmp after nk killed */
register struct monst *mtmp;
register int nk;
int experience(mtmp, nk) /* return # of exp points for mtmp after nk killed */
register struct monst *mtmp;
register int nk;
{
register struct permonst *ptr = mtmp->data;
int i, tmp, tmp2;
register struct permonst *ptr = mtmp->data;
int i, tmp, tmp2;
tmp = 1 + mtmp->m_lev * mtmp->m_lev;
tmp = 1 + mtmp->m_lev * mtmp->m_lev;
/* For higher ac values, give extra experience */
if ((i = find_mac(mtmp)) < 3) tmp += (7 - i) * ((i < 0) ? 2 : 1);
/* For higher ac values, give extra experience */
if ((i = find_mac(mtmp)) < 3)
tmp += (7 - i) * ((i < 0) ? 2 : 1);
/* For very fast monsters, give extra experience */
if (ptr->mmove > NORMAL_SPEED)
tmp += (ptr->mmove > (3*NORMAL_SPEED/2)) ? 5 : 3;
/* For very fast monsters, give extra experience */
if (ptr->mmove > NORMAL_SPEED)
tmp += (ptr->mmove > (3 * NORMAL_SPEED / 2)) ? 5 : 3;
/* For each "special" attack type give extra experience */
for(i = 0; i < NATTK; i++) {
/* For each "special" attack type give extra experience */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].aatyp;
if (tmp2 > AT_BUTT) {
if (tmp2 == AT_WEAP)
tmp += 5;
else if (tmp2 == AT_MAGC)
tmp += 10;
else
tmp += 3;
}
}
tmp2 = ptr->mattk[i].aatyp;
if(tmp2 > AT_BUTT) {
/* For each "special" damage type give extra experience */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].adtyp;
if (tmp2 > AD_PHYS && tmp2 < AD_BLND)
tmp += 2 * mtmp->m_lev;
else if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_SLIM))
tmp += 50;
else if (tmp2 != AD_PHYS)
tmp += mtmp->m_lev;
/* extra heavy damage bonus */
if ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23)
tmp += mtmp->m_lev;
if (tmp2 == AD_WRAP && ptr->mlet == S_EEL && !Amphibious)
tmp += 1000;
}
if(tmp2 == AT_WEAP) tmp += 5;
else if(tmp2 == AT_MAGC) tmp += 10;
else tmp += 3;
}
}
/* For certain "extra nasty" monsters, give even more */
if (extra_nasty(ptr))
tmp += (7 * mtmp->m_lev);
/* For each "special" damage type give extra experience */
for(i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].adtyp;
if(tmp2 > AD_PHYS && tmp2 < AD_BLND) tmp += 2*mtmp->m_lev;
else if((tmp2 == AD_DRLI) || (tmp2 == AD_STON) ||
(tmp2 == AD_SLIM)) tmp += 50;
else if(tmp2 != AD_PHYS) tmp += mtmp->m_lev;
/* extra heavy damage bonus */
if((int)(ptr->mattk[i].damd * ptr->mattk[i].damn) > 23)
tmp += mtmp->m_lev;
if (tmp2 == AD_WRAP && ptr->mlet == S_EEL && !Amphibious)
tmp += 1000;
}
/* For certain "extra nasty" monsters, give even more */
if (extra_nasty(ptr)) tmp += (7 * mtmp->m_lev);
/* For higher level monsters, an additional bonus is given */
if(mtmp->m_lev > 8) tmp += 50;
/* For higher level monsters, an additional bonus is given */
if (mtmp->m_lev > 8)
tmp += 50;
#ifdef MAIL
/* Mail daemons put up no fight. */
if(mtmp->data == &mons[PM_MAIL_DAEMON]) tmp = 1;
/* Mail daemons put up no fight. */
if (mtmp->data == &mons[PM_MAIL_DAEMON])
tmp = 1;
#endif
if (mtmp->mrevived || mtmp->mcloned) {
/*
* Reduce experience awarded for repeated killings of
* "the same monster". Kill count includes all of this
* monster's type which have been killed--including the
* current monster--regardless of how they were created.
* 1.. 20 full experience
* 21.. 40 xp / 2
* 41.. 80 xp / 4
* 81..120 xp / 8
* 121..180 xp / 16
* 181..240 xp / 32
* 241..255+ xp / 64
*/
for (i = 0, tmp2 = 20; nk > tmp2 && tmp > 1; ++i) {
tmp = (tmp + 1) / 2;
nk -= tmp2;
if (i & 1) tmp2 += 20;
}
}
if (mtmp->mrevived || mtmp->mcloned) {
/*
* Reduce experience awarded for repeated killings of
* "the same monster". Kill count includes all of this
* monster's type which have been killed--including the
* current monster--regardless of how they were created.
* 1.. 20 full experience
* 21.. 40 xp / 2
* 41.. 80 xp / 4
* 81..120 xp / 8
* 121..180 xp / 16
* 181..240 xp / 32
* 241..255+ xp / 64
*/
for (i = 0, tmp2 = 20; nk > tmp2 && tmp > 1; ++i) {
tmp = (tmp + 1) / 2;
nk -= tmp2;
if (i & 1)
tmp2 += 20;
}
}
return(tmp);
return (tmp);
}
void
more_experienced(exper, rexp)
register int exper, rexp;
register int exper, rexp;
{
long newexp = u.uexp + exper;
long rexpincr = 4*exper + rexp;
long newrexp = u.urexp + rexpincr;
long newexp = u.uexp + exper;
long rexpincr = 4 * exper + rexp;
long newrexp = u.urexp + rexpincr;
/* cap experience and score on wraparound */
if (newexp < 0 && exper > 0) newexp = LONG_MAX;
if (newrexp < 0 && rexpincr > 0) newrexp = LONG_MAX;
u.uexp = newexp;
u.urexp = newrexp;
/* cap experience and score on wraparound */
if (newexp < 0 && exper > 0)
newexp = LONG_MAX;
if (newrexp < 0 && rexpincr > 0)
newrexp = LONG_MAX;
u.uexp = newexp;
u.urexp = newrexp;
if(exper
if (exper
#ifdef SCORE_ON_BOTL
|| flags.showscore
|| flags.showscore
#endif
) context.botl = 1;
if (u.urexp >= (Role_if(PM_WIZARD) ? 1000 : 2000))
flags.beginner = 0;
)
context.botl = 1;
if (u.urexp >= (Role_if(PM_WIZARD) ? 1000 : 2000))
flags.beginner = 0;
}
void
losexp(drainer) /* e.g., hit by drain life attack */
const char *drainer; /* cause of death, if drain should be fatal */
void losexp(drainer) /* e.g., hit by drain life attack */
const char *drainer; /* cause of death, if drain should be fatal */
{
register int num;
register int num;
/* override life-drain resistance when handling an explicit
wizard mode request to reduce level; never fatal though */
if (drainer && !strcmp(drainer, "#levelchange"))
drainer = 0;
else
if (resists_drli(&youmonst)) return;
/* override life-drain resistance when handling an explicit
wizard mode request to reduce level; never fatal though */
if (drainer && !strcmp(drainer, "#levelchange"))
drainer = 0;
else if (resists_drli(&youmonst))
return;
if (u.ulevel > 1) {
pline("%s level %d.", Goodbye(), u.ulevel--);
/* remove intrinsic abilities */
adjabil(u.ulevel + 1, u.ulevel);
reset_rndmonst(NON_PM); /* new monster selection */
} else {
if (drainer) {
killer.format = KILLED_BY;
if (killer.name != drainer) Strcpy(killer.name, drainer);
done(DIED);
}
/* no drainer or lifesaved */
u.uexp = 0;
}
num = (int) u.uhpinc[u.ulevel];
u.uhpmax -= num;
if (u.uhpmax < 1) u.uhpmax = 1;
u.uhp -= num;
if (u.uhp < 1) u.uhp = 1;
else if (u.uhp > u.uhpmax) u.uhp = u.uhpmax;
if (u.ulevel > 1) {
pline("%s level %d.", Goodbye(), u.ulevel--);
/* remove intrinsic abilities */
adjabil(u.ulevel + 1, u.ulevel);
reset_rndmonst(NON_PM); /* new monster selection */
} else {
if (drainer) {
killer.format = KILLED_BY;
if (killer.name != drainer)
Strcpy(killer.name, drainer);
done(DIED);
}
/* no drainer or lifesaved */
u.uexp = 0;
}
num = (int) u.uhpinc[u.ulevel];
u.uhpmax -= num;
if (u.uhpmax < 1)
u.uhpmax = 1;
u.uhp -= num;
if (u.uhp < 1)
u.uhp = 1;
else if (u.uhp > u.uhpmax)
u.uhp = u.uhpmax;
num = (int) u.ueninc[u.ulevel];
u.uenmax -= num;
if (u.uenmax < 0) u.uenmax = 0;
u.uen -= num;
if (u.uen < 0) u.uen = 0;
else if (u.uen > u.uenmax) u.uen = u.uenmax;
num = (int) u.ueninc[u.ulevel];
u.uenmax -= num;
if (u.uenmax < 0)
u.uenmax = 0;
u.uen -= num;
if (u.uen < 0)
u.uen = 0;
else if (u.uen > u.uenmax)
u.uen = u.uenmax;
if (u.uexp > 0)
u.uexp = newuexp(u.ulevel) - 1;
if (u.uexp > 0)
u.uexp = newuexp(u.ulevel) - 1;
if (Upolyd) {
num = monhp_per_lvl(&youmonst);
u.mhmax -= num;
u.mh -= num;
if (u.mh <= 0) rehumanize();
}
if (Upolyd) {
num = monhp_per_lvl(&youmonst);
u.mhmax -= num;
u.mh -= num;
if (u.mh <= 0)
rehumanize();
}
context.botl = 1;
context.botl = 1;
}
/*
@@ -228,50 +251,53 @@ const char *drainer; /* cause of death, if drain should be fatal */
void
newexplevel()
{
if (u.ulevel < MAXULEV && u.uexp >= newuexp(u.ulevel))
pluslvl(TRUE);
if (u.ulevel < MAXULEV && u.uexp >= newuexp(u.ulevel))
pluslvl(TRUE);
}
void
pluslvl(incr)
boolean incr; /* true iff via incremental experience growth */
{ /* (false for potion of gain level) */
int hpinc, eninc;
boolean incr; /* true iff via incremental experience growth */
{ /* (false for potion of gain level) */
int hpinc, eninc;
if (!incr) You_feel("more experienced.");
if (!incr)
You_feel("more experienced.");
/* increase hit points (when polymorphed, do monster form first
in order to retain normal human/whatever increase for later) */
if (Upolyd) {
hpinc = monhp_per_lvl(&youmonst);
u.mhmax += hpinc;
u.mh += hpinc;
}
hpinc = newhp();
u.uhpmax += hpinc;
u.uhp += hpinc;
/* increase hit points (when polymorphed, do monster form first
in order to retain normal human/whatever increase for later) */
if (Upolyd) {
hpinc = monhp_per_lvl(&youmonst);
u.mhmax += hpinc;
u.mh += hpinc;
}
hpinc = newhp();
u.uhpmax += hpinc;
u.uhp += hpinc;
/* increase spell power/energy points */
eninc = newpw();
u.uenmax += eninc;
u.uen += eninc;
/* increase spell power/energy points */
eninc = newpw();
u.uenmax += eninc;
u.uen += eninc;
/* increase level (unless already maxxed) */
if (u.ulevel < MAXULEV) {
/* increase experience points to reflect new level */
if (incr) {
long tmp = newuexp(u.ulevel + 1);
if (u.uexp >= tmp) u.uexp = tmp - 1;
} else {
u.uexp = newuexp(u.ulevel);
}
++u.ulevel;
if (u.ulevelmax < u.ulevel) u.ulevelmax = u.ulevel;
pline("Welcome to experience level %d.", u.ulevel);
adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */
reset_rndmonst(NON_PM); /* new monster selection */
}
context.botl = 1;
/* increase level (unless already maxxed) */
if (u.ulevel < MAXULEV) {
/* increase experience points to reflect new level */
if (incr) {
long tmp = newuexp(u.ulevel + 1);
if (u.uexp >= tmp)
u.uexp = tmp - 1;
} else {
u.uexp = newuexp(u.ulevel);
}
++u.ulevel;
if (u.ulevelmax < u.ulevel)
u.ulevelmax = u.ulevel;
pline("Welcome to experience level %d.", u.ulevel);
adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */
reset_rndmonst(NON_PM); /* new monster selection */
}
context.botl = 1;
}
/* compute a random amount of experience points suitable for the hero's
@@ -279,27 +305,28 @@ boolean incr; /* true iff via incremental experience growth */
level plus a random portion of what it takes to get to the next level */
long
rndexp(gaining)
boolean gaining; /* gaining XP via potion vs setting XP for polyself */
boolean gaining; /* gaining XP via potion vs setting XP for polyself */
{
long minexp, maxexp, diff, factor, result;
long minexp, maxexp, diff, factor, result;
minexp = (u.ulevel == 1) ? 0L : newuexp(u.ulevel - 1);
maxexp = newuexp(u.ulevel);
diff = maxexp - minexp, factor = 1L;
/* make sure that `diff' is an argument which rn2() can handle */
while (diff >= (long)LARGEST_INT)
diff /= 2L, factor *= 2L;
result = minexp + factor * (long)rn2((int)diff);
/* 3.4.1: if already at level 30, add to current experience
points rather than to threshold needed to reach the current
level; otherwise blessed potions of gain level can result
in lowering the experience points instead of raising them */
if (u.ulevel == MAXULEV && gaining) {
result += (u.uexp - minexp);
/* avoid wrapping (over 400 blessed potions needed for that...) */
if (result < u.uexp) result = u.uexp;
}
return result;
minexp = (u.ulevel == 1) ? 0L : newuexp(u.ulevel - 1);
maxexp = newuexp(u.ulevel);
diff = maxexp - minexp, factor = 1L;
/* make sure that `diff' is an argument which rn2() can handle */
while (diff >= (long) LARGEST_INT)
diff /= 2L, factor *= 2L;
result = minexp + factor * (long) rn2((int) diff);
/* 3.4.1: if already at level 30, add to current experience
points rather than to threshold needed to reach the current
level; otherwise blessed potions of gain level can result
in lowering the experience points instead of raising them */
if (u.ulevel == MAXULEV && gaining) {
result += (u.uexp - minexp);
/* avoid wrapping (over 400 blessed potions needed for that...) */
if (result < u.uexp)
result = u.uexp;
}
return result;
}
/*exper.c*/
+603 -542
View File
File diff suppressed because it is too large Load Diff
+318 -288
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extralev.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 extralev.c $NHDT-Date: 1431192759 2015/05/09 17:32:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* NetHack 3.6 extralev.c $Date: 2010/01/10 02:35:19 $ $Revision: 1.5 $ */
/* Copyright 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -10,11 +10,11 @@
#include "hack.h"
struct rogueroom {
xchar rlx, rly;
xchar dx, dy;
boolean real;
uchar doortable;
int nroom; /* Only meaningful for "real" rooms */
xchar rlx, rly;
xchar dx, dy;
boolean real;
uchar doortable;
int nroom; /* Only meaningful for "real" rooms */
};
#define UP 1
#define DOWN 2
@@ -22,317 +22,347 @@ struct rogueroom {
#define RIGHT 8
static NEARDATA struct rogueroom r[3][3];
STATIC_DCL void FDECL(roguejoin,(int,int,int,int,int));
STATIC_DCL void FDECL(roguecorr,(int,int,int));
STATIC_DCL void FDECL(miniwalk,(int,int));
STATIC_DCL void FDECL(roguejoin, (int, int, int, int, int));
STATIC_DCL void FDECL(roguecorr, (int, int, int));
STATIC_DCL void FDECL(miniwalk, (int, int));
STATIC_OVL
void
roguejoin(x1,y1,x2,y2, horiz)
int x1,y1,x2,y2;
roguejoin(x1, y1, x2, y2, horiz)
int x1, y1, x2, y2;
int horiz;
{
register int x,y,middle;
if (horiz) {
middle = x1 + rn2(x2-x1+1);
for(x=min(x1,middle); x<=max(x1,middle); x++)
corr(x, y1);
for(y=min(y1,y2); y<=max(y1,y2); y++)
corr(middle,y);
for(x=min(middle,x2); x<=max(middle,x2); x++)
corr(x, y2);
} else {
middle = y1 + rn2(y2-y1+1);
for(y=min(y1,middle); y<=max(y1,middle); y++)
corr(x1, y);
for(x=min(x1,x2); x<=max(x1,x2); x++)
corr(x, middle);
for(y=min(middle,y2); y<=max(middle,y2); y++)
corr(x2,y);
}
register int x, y, middle;
if (horiz) {
middle = x1 + rn2(x2 - x1 + 1);
for (x = min(x1, middle); x <= max(x1, middle); x++)
corr(x, y1);
for (y = min(y1, y2); y <= max(y1, y2); y++)
corr(middle, y);
for (x = min(middle, x2); x <= max(middle, x2); x++)
corr(x, y2);
} else {
middle = y1 + rn2(y2 - y1 + 1);
for (y = min(y1, middle); y <= max(y1, middle); y++)
corr(x1, y);
for (x = min(x1, x2); x <= max(x1, x2); x++)
corr(x, middle);
for (y = min(middle, y2); y <= max(middle, y2); y++)
corr(x2, y);
}
}
STATIC_OVL
void
roguecorr(x, y, dir)
int x,y,dir;
int x, y, dir;
{
register int fromx, fromy, tox, toy;
register int fromx, fromy, tox, toy;
if (dir==DOWN) {
r[x][y].doortable &= ~DOWN;
if (!r[x][y].real) {
fromx = r[x][y].rlx; fromy = r[x][y].rly;
fromx += 1 + 26*x; fromy += 7*y;
} else {
fromx = r[x][y].rlx + rn2(r[x][y].dx);
fromy = r[x][y].rly + r[x][y].dy;
fromx += 1 + 26*x; fromy += 7*y;
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?",fromx,
fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromy++;
}
if(y >= 2) {
impossible("down door from %d,%d going nowhere?",x,y);
return;
}
y++;
r[x][y].doortable &= ~UP;
if (!r[x][y].real) {
tox = r[x][y].rlx; toy = r[x][y].rly;
tox += 1 + 26*x; toy += 7*y;
} else {
tox = r[x][y].rlx + rn2(r[x][y].dx);
toy = r[x][y].rly - 1;
tox += 1 + 26*x; toy += 7*y;
if (!IS_WALL(levl[tox][toy].typ))
impossible("up: no wall at %d,%d?",tox,toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
toy--;
}
roguejoin(fromx, fromy, tox, toy, FALSE);
return;
} else if (dir == RIGHT) {
r[x][y].doortable &= ~RIGHT;
if (!r[x][y].real) {
fromx = r[x][y].rlx; fromy = r[x][y].rly;
fromx += 1 + 26*x; fromy += 7*y;
} else {
fromx = r[x][y].rlx + r[x][y].dx;
fromy = r[x][y].rly + rn2(r[x][y].dy);
fromx += 1 + 26*x; fromy += 7*y;
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?",fromx,
fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromx++;
}
if(x >= 2) {
impossible("right door from %d,%d going nowhere?",x,y);
return;
}
x++;
r[x][y].doortable &= ~LEFT;
if (!r[x][y].real) {
tox = r[x][y].rlx; toy = r[x][y].rly;
tox += 1 + 26*x; toy += 7*y;
} else {
tox = r[x][y].rlx - 1;
toy = r[x][y].rly + rn2(r[x][y].dy);
tox += 1 + 26*x; toy += 7*y;
if (!IS_WALL(levl[tox][toy].typ))
impossible("left: no wall at %d,%d?",tox,toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
tox--;
}
roguejoin(fromx, fromy, tox, toy, TRUE);
return;
} else impossible("corridor in direction %d?",dir);
if (dir == DOWN) {
r[x][y].doortable &= ~DOWN;
if (!r[x][y].real) {
fromx = r[x][y].rlx;
fromy = r[x][y].rly;
fromx += 1 + 26 * x;
fromy += 7 * y;
} else {
fromx = r[x][y].rlx + rn2(r[x][y].dx);
fromy = r[x][y].rly + r[x][y].dy;
fromx += 1 + 26 * x;
fromy += 7 * y;
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromy++;
}
if (y >= 2) {
impossible("down door from %d,%d going nowhere?", x, y);
return;
}
y++;
r[x][y].doortable &= ~UP;
if (!r[x][y].real) {
tox = r[x][y].rlx;
toy = r[x][y].rly;
tox += 1 + 26 * x;
toy += 7 * y;
} else {
tox = r[x][y].rlx + rn2(r[x][y].dx);
toy = r[x][y].rly - 1;
tox += 1 + 26 * x;
toy += 7 * y;
if (!IS_WALL(levl[tox][toy].typ))
impossible("up: no wall at %d,%d?", tox, toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
toy--;
}
roguejoin(fromx, fromy, tox, toy, FALSE);
return;
} else if (dir == RIGHT) {
r[x][y].doortable &= ~RIGHT;
if (!r[x][y].real) {
fromx = r[x][y].rlx;
fromy = r[x][y].rly;
fromx += 1 + 26 * x;
fromy += 7 * y;
} else {
fromx = r[x][y].rlx + r[x][y].dx;
fromy = r[x][y].rly + rn2(r[x][y].dy);
fromx += 1 + 26 * x;
fromy += 7 * y;
if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR;
fromx++;
}
if (x >= 2) {
impossible("right door from %d,%d going nowhere?", x, y);
return;
}
x++;
r[x][y].doortable &= ~LEFT;
if (!r[x][y].real) {
tox = r[x][y].rlx;
toy = r[x][y].rly;
tox += 1 + 26 * x;
toy += 7 * y;
} else {
tox = r[x][y].rlx - 1;
toy = r[x][y].rly + rn2(r[x][y].dy);
tox += 1 + 26 * x;
toy += 7 * y;
if (!IS_WALL(levl[tox][toy].typ))
impossible("left: no wall at %d,%d?", tox, toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR;
tox--;
}
roguejoin(fromx, fromy, tox, toy, TRUE);
return;
} else
impossible("corridor in direction %d?", dir);
}
/* Modified walkfrom() from mkmaze.c */
STATIC_OVL
void
miniwalk(x, y)
int x,y;
{
register int q, dir;
int dirs[4];
while(1) {
q = 0;
#define doorhere (r[x][y].doortable)
if (x>0 && (!(doorhere & LEFT)) &&
(!r[x-1][y].doortable || !rn2(10)))
dirs[q++] = 0;
if (x<2 && (!(doorhere & RIGHT)) &&
(!r[x+1][y].doortable || !rn2(10)))
dirs[q++] = 1;
if (y>0 && (!(doorhere & UP)) &&
(!r[x][y-1].doortable || !rn2(10)))
dirs[q++] = 2;
if (y<2 && (!(doorhere & DOWN)) &&
(!r[x][y+1].doortable || !rn2(10)))
dirs[q++] = 3;
/* Rogue levels aren't just 3 by 3 mazes; they have some extra
* connections, thus that 1/10 chance
*/
if (!q) return;
dir = dirs[rn2(q)];
switch(dir) { /* Move in direction */
case 0: doorhere |= LEFT;
x--;
doorhere |= RIGHT;
break;
case 1: doorhere |= RIGHT;
x++;
doorhere |= LEFT;
break;
case 2: doorhere |= UP;
y--;
doorhere |= DOWN;
break;
case 3: doorhere |= DOWN;
y++;
doorhere |= UP;
break;
}
miniwalk(x,y);
}
}
void
makeroguerooms() {
register int x,y;
/* Rogue levels are structured 3 by 3, with each section containing
* a room or an intersection. The minimum width is 2 each way.
* One difference between these and "real" Rogue levels: real Rogue
* uses 24 rows and NetHack only 23. So we cheat a bit by making the
* second row of rooms not as deep.
*
* Each normal space has 6/7 rows and 25 columns in which a room may
* actually be placed. Walls go from rows 0-5/6 and columns 0-24.
* Not counting walls, the room may go in
* rows 1-5 and columns 1-23 (numbering starting at 0). A room
* coordinate of this type may be converted to a level coordinate
* by adding 1+28*x to the column, and 7*y to the row. (The 1
* is because column 0 isn't used [we only use 1-78]).
* Room height may be 2-4 (2-5 on last row), length 2-23 (not
* counting walls)
*/
#define here r[x][y]
nroom = 0;
for(y=0; y<3; y++) for(x=0; x<3; x++) {
/* Note: we want to insure at least 1 room. So, if the
* first 8 are all dummies, force the last to be a room.
*/
if (!rn2(5) && (nroom || (x<2 && y<2))) {
/* Arbitrary: dummy rooms may only go where real
* ones do.
*/
here.real = FALSE;
here.rlx = rn1(22, 2);
here.rly = rn1((y==2)?4:3, 2);
} else {
here.real = TRUE;
here.dx = rn1(22, 2); /* 2-23 long, plus walls */
here.dy = rn1((y==2)?4:3, 2); /* 2-5 high, plus walls */
/* boundaries of room floor */
here.rlx = rnd(23 - here.dx + 1);
here.rly = rnd(((y==2) ? 5 : 4)- here.dy + 1);
nroom++;
}
here.doortable = 0;
}
miniwalk(rn2(3), rn2(3));
nroom = 0;
for(y=0; y<3; y++) for(x=0; x<3; x++) {
if (here.real) { /* Make a room */
int lowx, lowy, hix, hiy;
r[x][y].nroom = nroom;
smeq[nroom] = nroom;
lowx = 1 + 26*x + here.rlx;
lowy = 7*y + here.rly;
hix = 1 + 26*x + here.rlx + here.dx - 1;
hiy = 7*y + here.rly + here.dy - 1;
/* Strictly speaking, it should be lit only if above
* level 10, but since Rogue rooms are only
* encountered below level 10, use !rn2(7).
*/
add_room(lowx, lowy, hix, hiy,
(boolean) !rn2(7), OROOM, FALSE);
}
}
/* Now, add connecting corridors. */
for(y=0; y<3; y++) for(x=0; x<3; x++) {
if (here.doortable & DOWN)
roguecorr(x, y, DOWN);
if (here.doortable & RIGHT)
roguecorr(x, y, RIGHT);
if (here.doortable & LEFT)
impossible ("left end of %d, %d never connected?",x,y);
if (here.doortable & UP)
impossible ("up end of %d, %d never connected?",x,y);
}
}
void
corr(x,y)
int x, y;
{
if (rn2(50)) {
levl[x][y].typ = CORR;
} else {
levl[x][y].typ = SCORR;
}
register int q, dir;
int dirs[4];
while (1) {
q = 0;
#define doorhere (r[x][y].doortable)
if (x > 0 && (!(doorhere & LEFT))
&& (!r[x - 1][y].doortable || !rn2(10)))
dirs[q++] = 0;
if (x < 2 && (!(doorhere & RIGHT))
&& (!r[x + 1][y].doortable || !rn2(10)))
dirs[q++] = 1;
if (y > 0 && (!(doorhere & UP))
&& (!r[x][y - 1].doortable || !rn2(10)))
dirs[q++] = 2;
if (y < 2 && (!(doorhere & DOWN))
&& (!r[x][y + 1].doortable || !rn2(10)))
dirs[q++] = 3;
/* Rogue levels aren't just 3 by 3 mazes; they have some extra
* connections, thus that 1/10 chance
*/
if (!q)
return;
dir = dirs[rn2(q)];
switch (dir) { /* Move in direction */
case 0:
doorhere |= LEFT;
x--;
doorhere |= RIGHT;
break;
case 1:
doorhere |= RIGHT;
x++;
doorhere |= LEFT;
break;
case 2:
doorhere |= UP;
y--;
doorhere |= DOWN;
break;
case 3:
doorhere |= DOWN;
y++;
doorhere |= UP;
break;
}
miniwalk(x, y);
}
}
void
makeroguerooms()
{
register int x, y;
/* Rogue levels are structured 3 by 3, with each section containing
* a room or an intersection. The minimum width is 2 each way.
* One difference between these and "real" Rogue levels: real Rogue
* uses 24 rows and NetHack only 23. So we cheat a bit by making the
* second row of rooms not as deep.
*
* Each normal space has 6/7 rows and 25 columns in which a room may
* actually be placed. Walls go from rows 0-5/6 and columns 0-24.
* Not counting walls, the room may go in
* rows 1-5 and columns 1-23 (numbering starting at 0). A room
* coordinate of this type may be converted to a level coordinate
* by adding 1+28*x to the column, and 7*y to the row. (The 1
* is because column 0 isn't used [we only use 1-78]).
* Room height may be 2-4 (2-5 on last row), length 2-23 (not
* counting walls)
*/
#define here r[x][y]
nroom = 0;
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++) {
/* Note: we want to insure at least 1 room. So, if the
* first 8 are all dummies, force the last to be a room.
*/
if (!rn2(5) && (nroom || (x < 2 && y < 2))) {
/* Arbitrary: dummy rooms may only go where real
* ones do.
*/
here.real = FALSE;
here.rlx = rn1(22, 2);
here.rly = rn1((y == 2) ? 4 : 3, 2);
} else {
here.real = TRUE;
here.dx = rn1(22, 2); /* 2-23 long, plus walls */
here.dy = rn1((y == 2) ? 4 : 3, 2); /* 2-5 high, plus walls */
/* boundaries of room floor */
here.rlx = rnd(23 - here.dx + 1);
here.rly = rnd(((y == 2) ? 5 : 4) - here.dy + 1);
nroom++;
}
here.doortable = 0;
}
miniwalk(rn2(3), rn2(3));
nroom = 0;
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++) {
if (here.real) { /* Make a room */
int lowx, lowy, hix, hiy;
r[x][y].nroom = nroom;
smeq[nroom] = nroom;
lowx = 1 + 26 * x + here.rlx;
lowy = 7 * y + here.rly;
hix = 1 + 26 * x + here.rlx + here.dx - 1;
hiy = 7 * y + here.rly + here.dy - 1;
/* Strictly speaking, it should be lit only if above
* level 10, but since Rogue rooms are only
* encountered below level 10, use !rn2(7).
*/
add_room(lowx, lowy, hix, hiy, (boolean) !rn2(7), OROOM,
FALSE);
}
}
/* Now, add connecting corridors. */
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++) {
if (here.doortable & DOWN)
roguecorr(x, y, DOWN);
if (here.doortable & RIGHT)
roguecorr(x, y, RIGHT);
if (here.doortable & LEFT)
impossible("left end of %d, %d never connected?", x, y);
if (here.doortable & UP)
impossible("up end of %d, %d never connected?", x, y);
}
}
void
corr(x, y)
int x, y;
{
if (rn2(50)) {
levl[x][y].typ = CORR;
} else {
levl[x][y].typ = SCORR;
}
}
void
makerogueghost()
{
register struct monst *ghost;
struct obj *ghostobj;
struct mkroom *croom;
int x,y;
register struct monst *ghost;
struct obj *ghostobj;
struct mkroom *croom;
int x, y;
if (!nroom) return; /* Should never happen */
croom = &rooms[rn2(nroom)];
x = somex(croom); y = somey(croom);
if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS)))
return;
ghost->msleeping = 1;
ghost = christen_monst(ghost, roguename());
if (!nroom)
return; /* Should never happen */
croom = &rooms[rn2(nroom)];
x = somex(croom);
y = somey(croom);
if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS)))
return;
ghost->msleeping = 1;
ghost = christen_monst(ghost, roguename());
if (rn2(4)) {
ghostobj = mksobj_at(FOOD_RATION, x, y, FALSE, FALSE);
ghostobj->quan = (long) rnd(7);
ghostobj->owt = weight(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(MACE, x, y, FALSE, FALSE);
ghostobj->spe = rnd(3);
if (rn2(4)) curse(ghostobj);
} else {
ghostobj = mksobj_at(TWO_HANDED_SWORD, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (rn2(4)) curse(ghostobj);
}
ghostobj = mksobj_at(BOW, x, y, FALSE, FALSE);
ghostobj->spe = 1;
if (rn2(4)) curse(ghostobj);
if (rn2(4)) {
ghostobj = mksobj_at(FOOD_RATION, x, y, FALSE, FALSE);
ghostobj->quan = (long) rnd(7);
ghostobj->owt = weight(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(MACE, x, y, FALSE, FALSE);
ghostobj->spe = rnd(3);
if (rn2(4))
curse(ghostobj);
} else {
ghostobj = mksobj_at(TWO_HANDED_SWORD, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (rn2(4))
curse(ghostobj);
}
ghostobj = mksobj_at(BOW, x, y, FALSE, FALSE);
ghostobj->spe = 1;
if (rn2(4))
curse(ghostobj);
ghostobj = mksobj_at(ARROW, x, y, FALSE, FALSE);
ghostobj->spe = 0;
ghostobj->quan = (long) rn1(10,25);
ghostobj->owt = weight(ghostobj);
if (rn2(4)) curse(ghostobj);
ghostobj = mksobj_at(ARROW, x, y, FALSE, FALSE);
ghostobj->spe = 0;
ghostobj->quan = (long) rn1(10, 25);
ghostobj->owt = weight(ghostobj);
if (rn2(4))
curse(ghostobj);
if (rn2(2)) {
ghostobj = mksobj_at(RING_MAIL, x, y, FALSE, FALSE);
ghostobj->spe = rn2(3);
if (!rn2(3)) ghostobj->oerodeproof = TRUE;
if (rn2(4)) curse(ghostobj);
} else {
ghostobj = mksobj_at(PLATE_MAIL, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (!rn2(3)) ghostobj->oerodeproof = TRUE;
if (rn2(4)) curse(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(FAKE_AMULET_OF_YENDOR, x, y, TRUE, FALSE);
ghostobj->known = TRUE;
}
if (rn2(2)) {
ghostobj = mksobj_at(RING_MAIL, x, y, FALSE, FALSE);
ghostobj->spe = rn2(3);
if (!rn2(3))
ghostobj->oerodeproof = TRUE;
if (rn2(4))
curse(ghostobj);
} else {
ghostobj = mksobj_at(PLATE_MAIL, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (!rn2(3))
ghostobj->oerodeproof = TRUE;
if (rn2(4))
curse(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(FAKE_AMULET_OF_YENDOR, x, y, TRUE, FALSE);
ghostobj->known = TRUE;
}
}
/*extralev.c*/
+1268 -1208
View File
File diff suppressed because it is too large Load Diff
+491 -471
View File
File diff suppressed because it is too large Load Diff
+1597 -1478
View File
File diff suppressed because it is too large Load Diff
+461 -441
View File
File diff suppressed because it is too large Load Diff
+1532 -1319
View File
File diff suppressed because it is too large Load Diff
+353 -327
View File
@@ -1,11 +1,11 @@
/* NetHack 3.6 light.c $NHDT-Date: 1426465436 2015/03/16 00:23:56 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.17 $ */
/* NetHack 3.6 light.c $NHDT-Date: 1431192764 2015/05/09 17:32:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
/* NetHack 3.6 light.c $Date: 2009/05/06 10:46:38 $ $Revision: 1.15 $ */
/* SCCS Id: @(#)light.c 3.5 2009/01/20 */
/* Copyright (c) Dean Luick, 1994 */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "lev.h" /* for checking save modes */
#include "lev.h" /* for checking save modes */
/*
* Mobile light sources.
@@ -41,8 +41,8 @@
*/
/* flags */
#define LSF_SHOW 0x1 /* display the light source */
#define LSF_NEEDS_FIXUP 0x2 /* need oid fixup */
#define LSF_SHOW 0x1 /* display the light source */
#define LSF_NEEDS_FIXUP 0x2 /* need oid fixup */
static light_source *light_base = 0;
@@ -53,19 +53,18 @@ STATIC_DCL int FDECL(maybe_write_ls, (int, int, BOOLEAN_P));
extern char circle_data[];
extern char circle_start[];
/* Create a new light source. */
void
new_light_source(x, y, range, type, id)
xchar x, y;
int range, type;
anything *id;
xchar x, y;
int range, type;
anything *id;
{
light_source *ls;
if (range > MAX_RADIUS || range < 1) {
impossible("new_light_source: illegal range %d", range);
return;
impossible("new_light_source: illegal range %d", range);
return;
}
ls = (light_source *) alloc(sizeof(light_source));
@@ -79,7 +78,7 @@ new_light_source(x, y, range, type, id)
ls->flags = 0;
light_base = ls;
vision_full_recalc = 1; /* make the source show up */
vision_full_recalc = 1; /* make the source show up */
}
/*
@@ -88,8 +87,8 @@ new_light_source(x, y, range, type, id)
*/
void
del_light_source(type, id)
int type;
anything *id;
int type;
anything *id;
{
light_source *curr, *prev;
anything tmp_id;
@@ -99,35 +98,40 @@ del_light_source(type, id)
has only been partially restored during a level change
(in particular: chameleon vs prot. from shape changers) */
switch (type) {
case LS_OBJECT: tmp_id.a_uint = id->a_obj->o_id;
break;
case LS_MONSTER: tmp_id.a_uint = id->a_monst->m_id;
break;
default: tmp_id.a_uint = 0;
break;
case LS_OBJECT:
tmp_id.a_uint = id->a_obj->o_id;
break;
case LS_MONSTER:
tmp_id.a_uint = id->a_monst->m_id;
break;
default:
tmp_id.a_uint = 0;
break;
}
for (prev = 0, curr = light_base; curr; prev = curr, curr = curr->next) {
if (curr->type != type) continue;
if (curr->id.a_obj == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj)) {
if (prev)
prev->next = curr->next;
else
light_base = curr->next;
if (curr->type != type)
continue;
if (curr->id.a_obj
== ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj)) {
if (prev)
prev->next = curr->next;
else
light_base = curr->next;
free((genericptr_t)curr);
vision_full_recalc = 1;
return;
}
free((genericptr_t) curr);
vision_full_recalc = 1;
return;
}
}
impossible("del_light_source: not found type=%d, id=%s",
type, fmt_ptr((genericptr_t)id->a_obj));
impossible("del_light_source: not found type=%d, id=%s", type,
fmt_ptr((genericptr_t) id->a_obj));
}
/* Mark locations that are temporarily lit via mobile light sources. */
void
do_light_sources(cs_rows)
char **cs_rows;
char **cs_rows;
{
int x, y, min_x, max_x, max_y, offset;
char *limits;
@@ -136,142 +140,149 @@ do_light_sources(cs_rows)
char *row;
for (ls = light_base; ls; ls = ls->next) {
ls->flags &= ~LSF_SHOW;
ls->flags &= ~LSF_SHOW;
/*
* Check for moved light sources. It may be possible to
* save some effort if an object has not moved, but not in
* the current setup -- we need to recalculate for every
* vision recalc.
*/
if (ls->type == LS_OBJECT) {
if (get_obj_location(ls->id.a_obj, &ls->x, &ls->y, 0))
ls->flags |= LSF_SHOW;
} else if (ls->type == LS_MONSTER) {
if (get_mon_location(ls->id.a_monst, &ls->x, &ls->y, 0))
ls->flags |= LSF_SHOW;
}
/*
* Check for moved light sources. It may be possible to
* save some effort if an object has not moved, but not in
* the current setup -- we need to recalculate for every
* vision recalc.
*/
if (ls->type == LS_OBJECT) {
if (get_obj_location(ls->id.a_obj, &ls->x, &ls->y, 0))
ls->flags |= LSF_SHOW;
} else if (ls->type == LS_MONSTER) {
if (get_mon_location(ls->id.a_monst, &ls->x, &ls->y, 0))
ls->flags |= LSF_SHOW;
}
/* minor optimization: don't bother with duplicate light sources */
/* at hero */
if (ls->x == u.ux && ls->y == u.uy) {
if (at_hero_range >= ls->range)
ls->flags &= ~LSF_SHOW;
else
at_hero_range = ls->range;
}
/* minor optimization: don't bother with duplicate light sources */
/* at hero */
if (ls->x == u.ux && ls->y == u.uy) {
if (at_hero_range >= ls->range)
ls->flags &= ~LSF_SHOW;
else
at_hero_range = ls->range;
}
if (ls->flags & LSF_SHOW) {
/*
* Walk the points in the circle and see if they are
* visible from the center. If so, mark'em.
*
* Kevin's tests indicated that doing this brute-force
* method is faster for radius <= 3 (or so).
*/
limits = circle_ptr(ls->range);
if ((max_y = (ls->y + ls->range)) >= ROWNO) max_y = ROWNO-1;
if ((y = (ls->y - ls->range)) < 0) y = 0;
for (; y <= max_y; y++) {
row = cs_rows[y];
offset = limits[abs(y - ls->y)];
if ((min_x = (ls->x - offset)) < 0) min_x = 0;
if ((max_x = (ls->x + offset)) >= COLNO) max_x = COLNO-1;
if (ls->flags & LSF_SHOW) {
/*
* Walk the points in the circle and see if they are
* visible from the center. If so, mark'em.
*
* Kevin's tests indicated that doing this brute-force
* method is faster for radius <= 3 (or so).
*/
limits = circle_ptr(ls->range);
if ((max_y = (ls->y + ls->range)) >= ROWNO)
max_y = ROWNO - 1;
if ((y = (ls->y - ls->range)) < 0)
y = 0;
for (; y <= max_y; y++) {
row = cs_rows[y];
offset = limits[abs(y - ls->y)];
if ((min_x = (ls->x - offset)) < 0)
min_x = 0;
if ((max_x = (ls->x + offset)) >= COLNO)
max_x = COLNO - 1;
if (ls->x == u.ux && ls->y == u.uy) {
/*
* If the light source is located at the hero, then
* we can use the COULD_SEE bits already calcualted
* by the vision system. More importantly than
* this optimization, is that it allows the vision
* system to correct problems with clear_path().
* The function clear_path() is a simple LOS
* path checker that doesn't go out of its way
* make things look "correct". The vision system
* does this.
*/
for (x = min_x; x <= max_x; x++)
if (row[x] & COULD_SEE)
row[x] |= TEMP_LIT;
} else {
for (x = min_x; x <= max_x; x++)
if ((ls->x == x && ls->y == y)
|| clear_path((int)ls->x, (int) ls->y, x, y))
row[x] |= TEMP_LIT;
}
}
}
if (ls->x == u.ux && ls->y == u.uy) {
/*
* If the light source is located at the hero, then
* we can use the COULD_SEE bits already calcualted
* by the vision system. More importantly than
* this optimization, is that it allows the vision
* system to correct problems with clear_path().
* The function clear_path() is a simple LOS
* path checker that doesn't go out of its way
* make things look "correct". The vision system
* does this.
*/
for (x = min_x; x <= max_x; x++)
if (row[x] & COULD_SEE)
row[x] |= TEMP_LIT;
} else {
for (x = min_x; x <= max_x; x++)
if ((ls->x == x && ls->y == y)
|| clear_path((int) ls->x, (int) ls->y, x, y))
row[x] |= TEMP_LIT;
}
}
}
}
}
/* (mon->mx == 0) implies migrating */
#define mon_is_local(mon) ((mon)->mx > 0)
#define mon_is_local(mon) ((mon)->mx > 0)
struct monst *
find_mid(nid, fmflags)
unsigned nid;
unsigned fmflags;
{
struct monst *mtmp;
struct monst *mtmp;
if (!nid)
return &youmonst;
if (fmflags & FM_FMON)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (!DEADMONSTER(mtmp) && mtmp->m_id == nid) return mtmp;
if (fmflags & FM_MIGRATE)
for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon)
if (mtmp->m_id == nid) return mtmp;
if (fmflags & FM_MYDOGS)
for (mtmp = mydogs; mtmp; mtmp = mtmp->nmon)
if (mtmp->m_id == nid) return mtmp;
return (struct monst *) 0;
if (!nid)
return &youmonst;
if (fmflags & FM_FMON)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (!DEADMONSTER(mtmp) && mtmp->m_id == nid)
return mtmp;
if (fmflags & FM_MIGRATE)
for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon)
if (mtmp->m_id == nid)
return mtmp;
if (fmflags & FM_MYDOGS)
for (mtmp = mydogs; mtmp; mtmp = mtmp->nmon)
if (mtmp->m_id == nid)
return mtmp;
return (struct monst *) 0;
}
/* Save all light sources of the given range. */
void
save_light_sources(fd, mode, range)
int fd, mode, range;
int fd, mode, range;
{
int count, actual, is_global;
light_source **prev, *curr;
if (perform_bwrite(mode)) {
count = maybe_write_ls(fd, range, FALSE);
bwrite(fd, (genericptr_t) &count, sizeof count);
actual = maybe_write_ls(fd, range, TRUE);
if (actual != count)
panic("counted %d light sources, wrote %d! [range=%d]",
count, actual, range);
count = maybe_write_ls(fd, range, FALSE);
bwrite(fd, (genericptr_t) &count, sizeof count);
actual = maybe_write_ls(fd, range, TRUE);
if (actual != count)
panic("counted %d light sources, wrote %d! [range=%d]", count,
actual, range);
}
if (release_data(mode)) {
for (prev = &light_base; (curr = *prev) != 0; ) {
if (!curr->id.a_monst) {
impossible("save_light_sources: no id! [range=%d]", range);
is_global = 0;
} else
switch (curr->type) {
case LS_OBJECT:
is_global = !obj_is_local(curr->id.a_obj);
break;
case LS_MONSTER:
is_global = !mon_is_local(curr->id.a_monst);
break;
default:
is_global = 0;
impossible("save_light_sources: bad type (%d) [range=%d]",
curr->type, range);
break;
}
/* if global and not doing local, or vice versa, remove it */
if (is_global ^ (range == RANGE_LEVEL)) {
*prev = curr->next;
free((genericptr_t)curr);
} else {
prev = &(*prev)->next;
}
}
for (prev = &light_base; (curr = *prev) != 0;) {
if (!curr->id.a_monst) {
impossible("save_light_sources: no id! [range=%d]", range);
is_global = 0;
} else
switch (curr->type) {
case LS_OBJECT:
is_global = !obj_is_local(curr->id.a_obj);
break;
case LS_MONSTER:
is_global = !mon_is_local(curr->id.a_monst);
break;
default:
is_global = 0;
impossible("save_light_sources: bad type (%d) [range=%d]",
curr->type, range);
break;
}
/* if global and not doing local, or vice versa, remove it */
if (is_global ^ (range == RANGE_LEVEL)) {
*prev = curr->next;
free((genericptr_t) curr);
} else {
prev = &(*prev)->next;
}
}
}
}
@@ -281,7 +292,7 @@ save_light_sources(fd, mode, range)
*/
void
restore_light_sources(fd)
int fd;
int fd;
{
int count;
light_source *ls;
@@ -290,45 +301,45 @@ restore_light_sources(fd)
mread(fd, (genericptr_t) &count, sizeof count);
while (count-- > 0) {
ls = (light_source *) alloc(sizeof(light_source));
mread(fd, (genericptr_t) ls, sizeof(light_source));
ls->next = light_base;
light_base = ls;
ls = (light_source *) alloc(sizeof(light_source));
mread(fd, (genericptr_t) ls, sizeof(light_source));
ls->next = light_base;
light_base = ls;
}
}
/* Relink all lights that are so marked. */
void
relink_light_sources(ghostly)
boolean ghostly;
boolean ghostly;
{
char which;
unsigned nid;
light_source *ls;
for (ls = light_base; ls; ls = ls->next) {
if (ls->flags & LSF_NEEDS_FIXUP) {
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
if (ghostly) {
if (!lookup_id_mapping(ls->id.a_uint, &nid))
impossible("relink_light_sources: no id mapping");
} else
nid = ls->id.a_uint;
if (ls->type == LS_OBJECT) {
which = 'o';
ls->id.a_obj = find_oid(nid);
} else {
which = 'm';
ls->id.a_monst = find_mid(nid, FM_EVERYWHERE);
}
if (!ls->id.a_monst)
impossible("relink_light_sources: cant find %c_id %d",
which, nid);
} else
impossible("relink_light_sources: bad type (%d)", ls->type);
if (ls->flags & LSF_NEEDS_FIXUP) {
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
if (ghostly) {
if (!lookup_id_mapping(ls->id.a_uint, &nid))
impossible("relink_light_sources: no id mapping");
} else
nid = ls->id.a_uint;
if (ls->type == LS_OBJECT) {
which = 'o';
ls->id.a_obj = find_oid(nid);
} else {
which = 'm';
ls->id.a_monst = find_mid(nid, FM_EVERYWHERE);
}
if (!ls->id.a_monst)
impossible("relink_light_sources: cant find %c_id %d",
which, nid);
} else
impossible("relink_light_sources: bad type (%d)", ls->type);
ls->flags &= ~LSF_NEEDS_FIXUP;
}
ls->flags &= ~LSF_NEEDS_FIXUP;
}
}
}
@@ -339,35 +350,36 @@ relink_light_sources(ghostly)
*/
STATIC_OVL int
maybe_write_ls(fd, range, write_it)
int fd, range;
boolean write_it;
int fd, range;
boolean write_it;
{
int count = 0, is_global;
light_source *ls;
for (ls = light_base; ls; ls = ls->next) {
if (!ls->id.a_monst) {
impossible("maybe_write_ls: no id! [range=%d]", range);
continue;
}
switch (ls->type) {
case LS_OBJECT:
is_global = !obj_is_local(ls->id.a_obj);
break;
case LS_MONSTER:
is_global = !mon_is_local(ls->id.a_monst);
break;
default:
is_global = 0;
impossible("maybe_write_ls: bad type (%d) [range=%d]",
ls->type, range);
break;
}
/* if global and not doing local, or vice versa, count it */
if (is_global ^ (range == RANGE_LEVEL)) {
count++;
if (write_it) write_ls(fd, ls);
}
if (!ls->id.a_monst) {
impossible("maybe_write_ls: no id! [range=%d]", range);
continue;
}
switch (ls->type) {
case LS_OBJECT:
is_global = !obj_is_local(ls->id.a_obj);
break;
case LS_MONSTER:
is_global = !mon_is_local(ls->id.a_monst);
break;
default:
is_global = 0;
impossible("maybe_write_ls: bad type (%d) [range=%d]", ls->type,
range);
break;
}
/* if global and not doing local, or vice versa, count it */
if (is_global ^ (range == RANGE_LEVEL)) {
count++;
if (write_it)
write_ls(fd, ls);
}
}
return count;
@@ -376,52 +388,54 @@ maybe_write_ls(fd, range, write_it)
/* Write a light source structure to disk. */
STATIC_OVL void
write_ls(fd, ls)
int fd;
light_source *ls;
int fd;
light_source *ls;
{
anything arg_save;
struct obj *otmp;
struct monst *mtmp;
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
if (ls->flags & LSF_NEEDS_FIXUP)
bwrite(fd, (genericptr_t)ls, sizeof(light_source));
else {
/* replace object pointer with id for write, then put back */
arg_save = ls->id;
if (ls->type == LS_OBJECT) {
otmp = ls->id.a_obj;
ls->id = zeroany;
ls->id.a_uint = otmp->o_id;
if (find_oid((unsigned)ls->id.a_uint) != otmp)
impossible("write_ls: can't find obj #%u!", ls->id.a_uint);
} else { /* ls->type == LS_MONSTER */
mtmp = (struct monst *)ls->id.a_monst;
ls->id = zeroany;
ls->id.a_uint = mtmp->m_id;
if (find_mid((unsigned)ls->id.a_uint, FM_EVERYWHERE) != mtmp)
impossible("write_ls: can't find mon #%u!", ls->id.a_uint);
}
ls->flags |= LSF_NEEDS_FIXUP;
bwrite(fd, (genericptr_t)ls, sizeof(light_source));
ls->id = arg_save;
ls->flags &= ~LSF_NEEDS_FIXUP;
}
if (ls->flags & LSF_NEEDS_FIXUP)
bwrite(fd, (genericptr_t) ls, sizeof(light_source));
else {
/* replace object pointer with id for write, then put back */
arg_save = ls->id;
if (ls->type == LS_OBJECT) {
otmp = ls->id.a_obj;
ls->id = zeroany;
ls->id.a_uint = otmp->o_id;
if (find_oid((unsigned) ls->id.a_uint) != otmp)
impossible("write_ls: can't find obj #%u!",
ls->id.a_uint);
} else { /* ls->type == LS_MONSTER */
mtmp = (struct monst *) ls->id.a_monst;
ls->id = zeroany;
ls->id.a_uint = mtmp->m_id;
if (find_mid((unsigned) ls->id.a_uint, FM_EVERYWHERE) != mtmp)
impossible("write_ls: can't find mon #%u!",
ls->id.a_uint);
}
ls->flags |= LSF_NEEDS_FIXUP;
bwrite(fd, (genericptr_t) ls, sizeof(light_source));
ls->id = arg_save;
ls->flags &= ~LSF_NEEDS_FIXUP;
}
} else {
impossible("write_ls: bad type (%d)", ls->type);
impossible("write_ls: bad type (%d)", ls->type);
}
}
/* Change light source's ID from src to dest. */
void
obj_move_light_source(src, dest)
struct obj *src, *dest;
struct obj *src, *dest;
{
light_source *ls;
for (ls = light_base; ls; ls = ls->next)
if (ls->type == LS_OBJECT && ls->id.a_obj == src)
ls->id.a_obj = dest;
if (ls->type == LS_OBJECT && ls->id.a_obj == src)
ls->id.a_obj = dest;
src->lamplit = 0;
dest->lamplit = 1;
}
@@ -439,41 +453,43 @@ any_light_source()
*/
void
snuff_light_source(x, y)
int x, y;
int x, y;
{
light_source *ls;
struct obj *obj;
for (ls = light_base; ls; ls = ls->next)
/*
Is this position check valid??? Can I assume that the positions
will always be correct because the objects would have been
updated with the last vision update? [Is that recent enough???]
*/
if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
obj = ls->id.a_obj;
if (obj_is_burning(obj)) {
/* The only way to snuff Sunsword is to unwield it. Darkness
* scrolls won't affect it. (If we got here because it was
* dropped or thrown inside a monster, this won't matter anyway
* because it will go out when dropped.)
*/
if (artifact_light(obj)) continue;
end_burn(obj, obj->otyp != MAGIC_LAMP);
/*
* The current ls element has just been removed (and
* ls->next is now invalid). Return assuming that there
* is only one light source attached to each object.
*/
return;
}
}
/*
Is this position check valid??? Can I assume that the positions
will always be correct because the objects would have been
updated with the last vision update? [Is that recent enough???]
*/
if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
obj = ls->id.a_obj;
if (obj_is_burning(obj)) {
/* The only way to snuff Sunsword is to unwield it. Darkness
* scrolls won't affect it. (If we got here because it was
* dropped or thrown inside a monster, this won't matter
* anyway
* because it will go out when dropped.)
*/
if (artifact_light(obj))
continue;
end_burn(obj, obj->otyp != MAGIC_LAMP);
/*
* The current ls element has just been removed (and
* ls->next is now invalid). Return assuming that there
* is only one light source attached to each object.
*/
return;
}
}
}
/* Return TRUE if object sheds any light at all. */
boolean
obj_sheds_light(obj)
struct obj *obj;
struct obj *obj;
{
/* so far, only burning objects shed light */
return obj_is_burning(obj);
@@ -482,39 +498,39 @@ obj_sheds_light(obj)
/* Return TRUE if sheds light AND will be snuffed by end_burn(). */
boolean
obj_is_burning(obj)
struct obj *obj;
struct obj *obj;
{
return (obj->lamplit &&
(obj->otyp == MAGIC_LAMP || ignitable(obj) || artifact_light(obj)));
return (obj->lamplit && (obj->otyp == MAGIC_LAMP || ignitable(obj)
|| artifact_light(obj)));
}
/* copy the light source(s) attachted to src, and attach it/them to dest */
void
obj_split_light_source(src, dest)
struct obj *src, *dest;
struct obj *src, *dest;
{
light_source *ls, *new_ls;
for (ls = light_base; ls; ls = ls->next)
if (ls->type == LS_OBJECT && ls->id.a_obj == src) {
/*
* Insert the new source at beginning of list. This will
* never interfere us walking down the list - we are already
* past the insertion point.
*/
new_ls = (light_source *) alloc(sizeof(light_source));
*new_ls = *ls;
if (Is_candle(src)) {
/* split candles may emit less light than original group */
ls->range = candle_light_range(src);
new_ls->range = candle_light_range(dest);
vision_full_recalc = 1; /* in case range changed */
}
new_ls->id.a_obj = dest;
new_ls->next = light_base;
light_base = new_ls;
dest->lamplit = 1; /* now an active light source */
}
if (ls->type == LS_OBJECT && ls->id.a_obj == src) {
/*
* Insert the new source at beginning of list. This will
* never interfere us walking down the list - we are already
* past the insertion point.
*/
new_ls = (light_source *) alloc(sizeof(light_source));
*new_ls = *ls;
if (Is_candle(src)) {
/* split candles may emit less light than original group */
ls->range = candle_light_range(src);
new_ls->range = candle_light_range(dest);
vision_full_recalc = 1; /* in case range changed */
}
new_ls->id.a_obj = dest;
new_ls->next = light_base;
light_base = new_ls;
dest->lamplit = 1; /* now an active light source */
}
}
/* light source `src' has been folded into light source `dest';
@@ -526,14 +542,15 @@ struct obj *src, *dest;
light_source *ls;
/* src == dest implies adding to candelabrum */
if (src != dest) end_burn(src, TRUE); /* extinguish candles */
if (src != dest)
end_burn(src, TRUE); /* extinguish candles */
for (ls = light_base; ls; ls = ls->next)
if (ls->type == LS_OBJECT && ls->id.a_obj == dest) {
ls->range = candle_light_range(dest);
vision_full_recalc = 1; /* in case range changed */
break;
}
if (ls->type == LS_OBJECT && ls->id.a_obj == dest) {
ls->range = candle_light_range(dest);
vision_full_recalc = 1; /* in case range changed */
break;
}
}
/* light source `obj' is being made brighter or dimmer */
@@ -545,11 +562,12 @@ int new_radius;
light_source *ls;
for (ls = light_base; ls; ls = ls->next)
if (ls->type == LS_OBJECT && ls->id.a_obj == obj) {
if (new_radius != ls->range) vision_full_recalc = 1;
ls->range = new_radius;
return;
}
if (ls->type == LS_OBJECT && ls->id.a_obj == obj) {
if (new_radius != ls->range)
vision_full_recalc = 1;
ls->range = new_radius;
return;
}
impossible("obj_adjust_light_radius: can't find %s", xname(obj));
}
@@ -562,34 +580,34 @@ struct obj *obj;
int radius;
if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
/*
* The special candelabrum emits more light than the
* corresponding number of candles would.
* 1..3 candles, range 2 (minimum range);
* 4..6 candles, range 3 (normal lamp range);
* 7 candles, range 4 (bright).
*/
radius = (obj->spe < 4) ? 2 : (obj->spe < 7) ? 3 : 4;
/*
* The special candelabrum emits more light than the
* corresponding number of candles would.
* 1..3 candles, range 2 (minimum range);
* 4..6 candles, range 3 (normal lamp range);
* 7 candles, range 4 (bright).
*/
radius = (obj->spe < 4) ? 2 : (obj->spe < 7) ? 3 : 4;
} else if (Is_candle(obj)) {
/*
* Range is incremented by powers of 7 so that it will take
* wizard mode quantities of candles to get more light than
* from a lamp, without imposing an arbitrary limit.
* 1..6 candles, range 2;
* 7..48 candles, range 3;
* 49..342 candles, range 4; &c.
*/
long n = obj->quan;
/*
* Range is incremented by powers of 7 so that it will take
* wizard mode quantities of candles to get more light than
* from a lamp, without imposing an arbitrary limit.
* 1..6 candles, range 2;
* 7..48 candles, range 3;
* 49..342 candles, range 4; &c.
*/
long n = obj->quan;
radius = 1; /* always incremented at least once */
do {
radius++;
n /= 7L;
} while (n > 0L);
radius = 1; /* always incremented at least once */
do {
radius++;
n /= 7L;
} while (n > 0L);
} else {
/* we're only called for lit candelabrum or candles */
/* impossible("candlelight for %d?", obj->otyp); */
radius = 3; /* lamp's value */
/* we're only called for lit candelabrum or candles */
/* impossible("candlelight for %d?", obj->otyp); */
radius = 3; /* lamp's value */
}
return radius;
}
@@ -607,7 +625,8 @@ struct obj *obj;
*/
/* sanity check [simplifies usage by bless()/curse()/&c] */
if (!obj->lamplit || !artifact_light(obj)) return 0;
if (!obj->lamplit || !artifact_light(obj))
return 0;
/* cursed radius of 1 is not noticeable for an item that's
carried by the hero but is if it's carried by a monster
@@ -621,10 +640,14 @@ arti_light_description(obj)
struct obj *obj;
{
switch (arti_light_radius(obj)) {
case 3: return "brilliantly"; /* blessed */
case 2: return "brightly"; /* uncursed */
case 1: return "dimly"; /* cursed */
default: break;
case 3:
return "brilliantly"; /* blessed */
case 2:
return "brightly"; /* uncursed */
case 1:
return "dimly"; /* cursed */
default:
break;
}
return "strangely";
}
@@ -636,31 +659,34 @@ wiz_light_sources()
char buf[BUFSZ];
light_source *ls;
win = create_nhwindow(NHW_MENU); /* corner text window */
if (win == WIN_ERR) return 0;
win = create_nhwindow(NHW_MENU); /* corner text window */
if (win == WIN_ERR)
return 0;
Sprintf(buf, "Mobile light sources: hero @ (%2d,%2d)", u.ux, u.uy);
putstr(win, 0, buf);
putstr(win, 0, "");
if (light_base) {
putstr(win, 0, "location range flags type id");
putstr(win, 0, "-------- ----- ------ ---- -------");
for (ls = light_base; ls; ls = ls->next) {
Sprintf(buf, " %2d,%2d %2d 0x%04x %s %s",
ls->x, ls->y, ls->range, ls->flags,
(ls->type == LS_OBJECT ? "obj" :
ls->type == LS_MONSTER ?
(mon_is_local(ls->id.a_monst) ? "mon" :
(ls->id.a_monst == &youmonst) ? "you" :
"<m>") : /* migrating monster */
"???"),
fmt_ptr(ls->id.a_void));
putstr(win, 0, buf);
}
putstr(win, 0, "location range flags type id");
putstr(win, 0, "-------- ----- ------ ---- -------");
for (ls = light_base; ls; ls = ls->next) {
Sprintf(buf, " %2d,%2d %2d 0x%04x %s %s", ls->x, ls->y,
ls->range, ls->flags,
(ls->type == LS_OBJECT
? "obj"
: ls->type == LS_MONSTER
? (mon_is_local(ls->id.a_monst)
? "mon"
: (ls->id.a_monst == &youmonst) ? "you"
: "<m>")
: /* migrating monster */
"???"),
fmt_ptr(ls->id.a_void));
putstr(win, 0, buf);
}
} else
putstr(win, 0, "<none>");
putstr(win, 0, "<none>");
display_nhwindow(win, FALSE);
destroy_nhwindow(win);
+861 -823
View File
File diff suppressed because it is too large Load Diff
+326 -317
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mail.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 mail.c $NHDT-Date: 1431192758 2015/05/09 17:32:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.6 mail.c $Date: 2009/05/06 10:46:41 $ $Revision: 1.12 $ */
/* SCCS Id: @(#)mail.c 3.5 2008/01/30 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -22,7 +22,8 @@
* - Open the file MAIL and do fstat instead of stat for efficiency.
* (But sh uses stat, so this cannot be too bad.)
* - Examine the mail and produce a scroll of mail named "From somebody".
* - Invoke MAILREADER in such a way that only this single letter is read.
* - Invoke MAILREADER in such a way that only this single letter is
*read.
* - Do something to the text when the scroll is enchanted or cancelled.
* - Make the daemon always appear at a stairwell, and have it find a
* path to the hero.
@@ -33,86 +34,87 @@
* random intervals.
*/
STATIC_DCL boolean FDECL(md_start,(coord *));
STATIC_DCL boolean FDECL(md_stop,(coord *, coord *));
STATIC_DCL boolean FDECL(md_rush,(struct monst *,int,int));
STATIC_DCL boolean FDECL(md_start, (coord *));
STATIC_DCL boolean FDECL(md_stop, (coord *, coord *));
STATIC_DCL boolean FDECL(md_rush, (struct monst *, int, int));
STATIC_DCL void FDECL(newmail, (struct mail_info *));
extern char *viz_rmin, *viz_rmax; /* line-of-sight limits (vision.c) */
extern char *viz_rmin, *viz_rmax; /* line-of-sight limits (vision.c) */
# if !defined(UNIX) && !defined(VMS)
#if !defined(UNIX) && !defined(VMS)
int mustgetmail = -1;
# endif
#endif
# ifdef UNIX
#ifdef UNIX
#include <sys/stat.h>
#include <pwd.h>
/* DON'T trust all Unices to declare getpwuid() in <pwd.h> */
# if !defined(_BULL_SOURCE) && !defined(__sgi) && !defined(_M_UNIX)
# if !defined(SUNOS4) && !(defined(ULTRIX) && defined(__GNUC__))
#if !defined(_BULL_SOURCE) && !defined(__sgi) && !defined(_M_UNIX)
#if !defined(SUNOS4) && !(defined(ULTRIX) && defined(__GNUC__))
/* DO trust all SVR4 to typedef uid_t in <sys/types.h> (probably to a long) */
# if defined(POSIX_TYPES) || defined(SVR4) || defined(HPUX)
extern struct passwd *FDECL(getpwuid,(uid_t));
# else
extern struct passwd *FDECL(getpwuid,(int));
# endif
# endif
# endif
static struct stat omstat,nmstat;
static char *mailbox = (char *)0;
#if defined(POSIX_TYPES) || defined(SVR4) || defined(HPUX)
extern struct passwd *FDECL(getpwuid, (uid_t));
#else
extern struct passwd *FDECL(getpwuid, (int));
#endif
#endif
#endif
static struct stat omstat, nmstat;
static char *mailbox = (char *) 0;
static long laststattime;
# if !defined(MAILPATH) && defined(AMS) /* Just a placeholder for AMS */
# define MAILPATH "/dev/null"
# endif
# if !defined(MAILPATH) && (defined(LINUX) || defined(__osf__))
# define MAILPATH "/var/spool/mail/"
# endif
# if !defined(MAILPATH) && defined(__FreeBSD__)
# define MAILPATH "/var/mail/"
# endif
# if !defined(MAILPATH) && (defined(BSD) || defined(ULTRIX))
# define MAILPATH "/usr/spool/mail/"
# endif
# if !defined(MAILPATH) && (defined(SYSV) || defined(HPUX))
# define MAILPATH "/usr/mail/"
# endif
#if !defined(MAILPATH) && defined(AMS) /* Just a placeholder for AMS */
#define MAILPATH "/dev/null"
#endif
#if !defined(MAILPATH) && (defined(LINUX) || defined(__osf__))
#define MAILPATH "/var/spool/mail/"
#endif
#if !defined(MAILPATH) && defined(__FreeBSD__)
#define MAILPATH "/var/mail/"
#endif
#if !defined(MAILPATH) && (defined(BSD) || defined(ULTRIX))
#define MAILPATH "/usr/spool/mail/"
#endif
#if !defined(MAILPATH) && (defined(SYSV) || defined(HPUX))
#define MAILPATH "/usr/mail/"
#endif
void
getmailstatus()
{
if(!mailbox && !(mailbox = nh_getenv("MAIL"))) {
# ifdef MAILPATH
# ifdef AMS
struct passwd ppasswd;
if (!mailbox && !(mailbox = nh_getenv("MAIL"))) {
#ifdef MAILPATH
#ifdef AMS
struct passwd ppasswd;
(void) memcpy(&ppasswd, getpwuid(getuid()), sizeof(struct passwd));
if (ppasswd.pw_dir) {
mailbox = (char *) alloc((unsigned) strlen(ppasswd.pw_dir)+sizeof(AMS_MAILBOX));
Strcpy(mailbox, ppasswd.pw_dir);
Strcat(mailbox, AMS_MAILBOX);
} else
return;
# else
const char *pw_name = getpwuid(getuid())->pw_name;
mailbox = (char *) alloc(sizeof(MAILPATH)+strlen(pw_name));
Strcpy(mailbox, MAILPATH);
Strcat(mailbox, pw_name);
# endif /* AMS */
# else
return;
# endif
}
if(stat(mailbox, &omstat)){
# ifdef PERMANENT_MAILBOX
pline("Cannot get status of MAIL=\"%s\".", mailbox);
mailbox = 0;
# else
omstat.st_mtime = 0;
# endif
}
(void) memcpy(&ppasswd, getpwuid(getuid()), sizeof(struct passwd));
if (ppasswd.pw_dir) {
mailbox = (char *) alloc((unsigned) strlen(ppasswd.pw_dir)
+ sizeof(AMS_MAILBOX));
Strcpy(mailbox, ppasswd.pw_dir);
Strcat(mailbox, AMS_MAILBOX);
} else
return;
#else
const char *pw_name = getpwuid(getuid())->pw_name;
mailbox = (char *) alloc(sizeof(MAILPATH) + strlen(pw_name));
Strcpy(mailbox, MAILPATH);
Strcat(mailbox, pw_name);
#endif /* AMS */
#else
return;
#endif
}
if (stat(mailbox, &omstat)) {
#ifdef PERMANENT_MAILBOX
pline("Cannot get status of MAIL=\"%s\".", mailbox);
mailbox = 0;
#else
omstat.st_mtime = 0;
#endif
}
}
# endif /* UNIX */
#endif /* UNIX */
/*
* Pick coordinates for a starting position for the mail daemon. Called
@@ -120,22 +122,22 @@ getmailstatus()
*/
STATIC_OVL boolean
md_start(startp)
coord *startp;
coord *startp;
{
coord testcc; /* scratch coordinates */
int row; /* current row we are checking */
int lax; /* if TRUE, pick a position in sight. */
int dd; /* distance to current point */
int max_distance; /* max distance found so far */
coord testcc; /* scratch coordinates */
int row; /* current row we are checking */
int lax; /* if TRUE, pick a position in sight. */
int dd; /* distance to current point */
int max_distance; /* max distance found so far */
/*
* If blind and not telepathic, then it doesn't matter what we pick ---
* the hero is not going to see it anyway. So pick a nearby position.
*/
if (Blind && !Blind_telepat) {
if (!enexto(startp, u.ux, u.uy, (struct permonst *) 0))
return FALSE; /* no good posiitons */
return TRUE;
if (!enexto(startp, u.ux, u.uy, (struct permonst *) 0))
return FALSE; /* no good posiitons */
return TRUE;
}
/*
@@ -143,14 +145,14 @@ md_start(startp)
* hero.
*/
if (couldsee(upstair.sx, upstair.sy)) {
startp->x = upstair.sx;
startp->y = upstair.sy;
return TRUE;
startp->x = upstair.sx;
startp->y = upstair.sy;
return TRUE;
}
if (couldsee(dnstair.sx, dnstair.sy)) {
startp->x = dnstair.sx;
startp->y = dnstair.sy;
return TRUE;
startp->x = dnstair.sx;
startp->y = dnstair.sy;
return TRUE;
}
/*
@@ -162,52 +164,51 @@ md_start(startp)
* The arrays viz_rmin[] and viz_rmax[] are set even when blind. These
* are the LOS limits for each row.
*/
lax = 0; /* be picky */
lax = 0; /* be picky */
max_distance = -1;
retry:
for (row = 0; row < ROWNO; row++) {
if (viz_rmin[row] < viz_rmax[row]) {
/* There are valid positions on this row. */
dd = distu(viz_rmin[row],row);
if (dd > max_distance) {
if (lax) {
max_distance = dd;
startp->y = row;
startp->x = viz_rmin[row];
} else if (enexto(&testcc, (xchar)viz_rmin[row], row,
(struct permonst *) 0) &&
!cansee(testcc.x, testcc.y) &&
couldsee(testcc.x, testcc.y)) {
max_distance = dd;
*startp = testcc;
}
}
dd = distu(viz_rmax[row],row);
if (dd > max_distance) {
if (lax) {
max_distance = dd;
startp->y = row;
startp->x = viz_rmax[row];
} else if (enexto(&testcc, (xchar)viz_rmax[row], row,
(struct permonst *) 0) &&
!cansee(testcc.x,testcc.y) &&
couldsee(testcc.x, testcc.y)) {
if (viz_rmin[row] < viz_rmax[row]) {
/* There are valid positions on this row. */
dd = distu(viz_rmin[row], row);
if (dd > max_distance) {
if (lax) {
max_distance = dd;
startp->y = row;
startp->x = viz_rmin[row];
max_distance = dd;
*startp = testcc;
}
}
}
} else if (enexto(&testcc, (xchar) viz_rmin[row], row,
(struct permonst *) 0)
&& !cansee(testcc.x, testcc.y)
&& couldsee(testcc.x, testcc.y)) {
max_distance = dd;
*startp = testcc;
}
}
dd = distu(viz_rmax[row], row);
if (dd > max_distance) {
if (lax) {
max_distance = dd;
startp->y = row;
startp->x = viz_rmax[row];
} else if (enexto(&testcc, (xchar) viz_rmax[row], row,
(struct permonst *) 0)
&& !cansee(testcc.x, testcc.y)
&& couldsee(testcc.x, testcc.y)) {
max_distance = dd;
*startp = testcc;
}
}
}
}
if (max_distance < 0) {
if (!lax) {
lax = 1; /* just find a position */
goto retry;
}
return FALSE;
if (!lax) {
lax = 1; /* just find a position */
goto retry;
}
return FALSE;
}
return TRUE;
@@ -221,41 +222,38 @@ retry:
*/
STATIC_OVL boolean
md_stop(stopp, startp)
coord *stopp; /* stopping position (we fill it in) */
coord *startp; /* starting positon (read only) */
coord *stopp; /* stopping position (we fill it in) */
coord *startp; /* starting positon (read only) */
{
int x, y, distance, min_distance = -1;
for (x = u.ux-1; x <= u.ux+1; x++)
for (y = u.uy-1; y <= u.uy+1; y++) {
if (!isok(x, y) || (x == u.ux && y == u.uy)) continue;
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
if (!isok(x, y) || (x == u.ux && y == u.uy))
continue;
if (accessible(x, y) && !MON_AT(x,y)) {
distance = dist2(x,y,startp->x,startp->y);
if (min_distance < 0 || distance < min_distance ||
(distance == min_distance && rn2(2))) {
stopp->x = x;
stopp->y = y;
min_distance = distance;
}
}
}
if (accessible(x, y) && !MON_AT(x, y)) {
distance = dist2(x, y, startp->x, startp->y);
if (min_distance < 0 || distance < min_distance
|| (distance == min_distance && rn2(2))) {
stopp->x = x;
stopp->y = y;
min_distance = distance;
}
}
}
/* If we didn't find a good spot, try enexto(). */
if (min_distance < 0 &&
!enexto(stopp, u.ux, u.uy, &mons[PM_MAIL_DAEMON]))
return FALSE;
if (min_distance < 0 && !enexto(stopp, u.ux, u.uy, &mons[PM_MAIL_DAEMON]))
return FALSE;
return TRUE;
}
/* Let the mail daemon have a larger vocabulary. */
static NEARDATA const char *mail_text[] = {
"Gangway!",
"Look out!",
"Pardon me!"
};
#define md_exclamations() (mail_text[rn2(3)])
static NEARDATA const char *mail_text[] = { "Gangway!", "Look out!",
"Pardon me!" };
#define md_exclamations() (mail_text[rn2(3)])
/*
* Make the mail daemon run through the dungeon. The daemon will run over
@@ -264,23 +262,23 @@ static NEARDATA const char *mail_text[] = {
* TRUE otherwise.
*/
STATIC_OVL boolean
md_rush(md,tx,ty)
struct monst *md;
register int tx, ty; /* destination of mail daemon */
md_rush(md, tx, ty)
struct monst *md;
register int tx, ty; /* destination of mail daemon */
{
struct monst *mon; /* displaced monster */
register int dx, dy; /* direction counters */
int fx = md->mx, fy = md->my; /* current location */
int nfx = fx, nfy = fy, /* new location */
d1, d2; /* shortest distances */
struct monst *mon; /* displaced monster */
register int dx, dy; /* direction counters */
int fx = md->mx, fy = md->my; /* current location */
int nfx = fx, nfy = fy, /* new location */
d1, d2; /* shortest distances */
/*
* It is possible that the monster at (fx,fy) is not the md when:
* the md rushed the hero and failed, and is now starting back.
*/
if (m_at(fx, fy) == md) {
remove_monster(fx, fy); /* pick up from orig position */
newsym(fx, fy);
remove_monster(fx, fy); /* pick up from orig position */
newsym(fx, fy);
}
/*
@@ -288,47 +286,50 @@ md_rush(md,tx,ty)
* dungeon.
*/
while (1) {
/* Find a good location next to (fx,fy) closest to (tx,ty). */
d1 = dist2(fx,fy,tx,ty);
for (dx = -1; dx <= 1; dx++) for(dy = -1; dy <= 1; dy++)
if ((dx || dy) && isok(fx+dx,fy+dy) &&
!IS_STWALL(levl[fx+dx][fy+dy].typ)) {
d2 = dist2(fx+dx,fy+dy,tx,ty);
if (d2 < d1) {
d1 = d2;
nfx = fx+dx;
nfy = fy+dy;
}
}
/* Find a good location next to (fx,fy) closest to (tx,ty). */
d1 = dist2(fx, fy, tx, ty);
for (dx = -1; dx <= 1; dx++)
for (dy = -1; dy <= 1; dy++)
if ((dx || dy) && isok(fx + dx, fy + dy)
&& !IS_STWALL(levl[fx + dx][fy + dy].typ)) {
d2 = dist2(fx + dx, fy + dy, tx, ty);
if (d2 < d1) {
d1 = d2;
nfx = fx + dx;
nfy = fy + dy;
}
}
/* Break if the md couldn't find a new position. */
if (nfx == fx && nfy == fy) break;
/* Break if the md couldn't find a new position. */
if (nfx == fx && nfy == fy)
break;
fx = nfx; /* this is our new position */
fy = nfy;
fx = nfx; /* this is our new position */
fy = nfy;
/* Break if the md reaches its destination. */
if (fx == tx && fy == ty) break;
/* Break if the md reaches its destination. */
if (fx == tx && fy == ty)
break;
if ((mon = m_at(fx,fy)) != 0) /* save monster at this position */
verbalize1(md_exclamations());
else if (fx == u.ux && fy == u.uy)
verbalize("Excuse me.");
if ((mon = m_at(fx, fy)) != 0) /* save monster at this position */
verbalize1(md_exclamations());
else if (fx == u.ux && fy == u.uy)
verbalize("Excuse me.");
place_monster(md,fx,fy); /* put md down */
newsym(fx,fy); /* see it */
flush_screen(0); /* make sure md shows up */
delay_output(); /* wait a little bit */
place_monster(md, fx, fy); /* put md down */
newsym(fx, fy); /* see it */
flush_screen(0); /* make sure md shows up */
delay_output(); /* wait a little bit */
/* Remove md from the dungeon. Restore original mon, if necessary. */
if (mon) {
if ((mon->mx != fx) || (mon->my != fy))
place_worm_seg(mon, fx, fy);
else
place_monster(mon, fx, fy);
} else
remove_monster(fx, fy);
newsym(fx,fy);
/* Remove md from the dungeon. Restore original mon, if necessary. */
if (mon) {
if ((mon->mx != fx) || (mon->my != fy))
place_worm_seg(mon, fx, fy);
else
place_monster(mon, fx, fy);
} else
remove_monster(fx, fy);
newsym(fx, fy);
}
/*
@@ -336,28 +337,27 @@ md_rush(md,tx,ty)
* very unlikely). If one exists, then have the md leave in disgust.
*/
if ((mon = m_at(fx, fy)) != 0) {
place_monster(md, fx, fy); /* display md with text below */
newsym(fx, fy);
verbalize("This place's too crowded. I'm outta here.");
place_monster(md, fx, fy); /* display md with text below */
newsym(fx, fy);
verbalize("This place's too crowded. I'm outta here.");
if ((mon->mx != fx) || (mon->my != fy)) /* put mon back */
place_worm_seg(mon, fx, fy);
else
place_monster(mon, fx, fy);
if ((mon->mx != fx) || (mon->my != fy)) /* put mon back */
place_worm_seg(mon, fx, fy);
else
place_monster(mon, fx, fy);
newsym(fx, fy);
return FALSE;
newsym(fx, fy);
return FALSE;
}
place_monster(md, fx, fy); /* place at final spot */
place_monster(md, fx, fy); /* place at final spot */
newsym(fx, fy);
flush_screen(0);
delay_output(); /* wait a little bit */
delay_output(); /* wait a little bit */
return TRUE;
}
/* Deliver a scroll of mail. */
/*ARGSUSED*/
STATIC_OVL void
@@ -369,59 +369,63 @@ struct mail_info *info;
boolean message_seen = FALSE;
/* Try to find good starting and stopping places. */
if (!md_start(&start) || !md_stop(&stop,&start)) goto give_up;
if (!md_start(&start) || !md_stop(&stop, &start))
goto give_up;
/* Make the daemon. Have it rush towards the hero. */
if (!(md = makemon(&mons[PM_MAIL_DAEMON], start.x, start.y, NO_MM_FLAGS)))
goto give_up;
if (!md_rush(md, stop.x, stop.y)) goto go_back;
goto give_up;
if (!md_rush(md, stop.x, stop.y))
goto go_back;
message_seen = TRUE;
verbalize("%s, %s! %s.", Hello(md), plname, info->display_txt);
if (info->message_typ) {
struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
if (info->object_nam)
obj = oname(obj, info->object_nam);
if (info->response_cmd)
new_omailcmd(obj, info->response_cmd);
if (info->object_nam)
obj = oname(obj, info->object_nam);
if (info->response_cmd)
new_omailcmd(obj, info->response_cmd);
if (distu(md->mx,md->my) > 2)
verbalize("Catch!");
display_nhwindow(WIN_MESSAGE, FALSE);
obj = hold_another_object(obj, "Oops!",
(const char *)0, (const char *)0);
if (distu(md->mx, md->my) > 2)
verbalize("Catch!");
display_nhwindow(WIN_MESSAGE, FALSE);
obj = hold_another_object(obj, "Oops!", (const char *) 0,
(const char *) 0);
}
/* zip back to starting location */
/* zip back to starting location */
go_back:
(void) md_rush(md, start.x, start.y);
mongone(md);
/* deliver some classes of messages even if no daemon ever shows up */
/* deliver some classes of messages even if no daemon ever shows up */
give_up:
if (!message_seen && info->message_typ == MSG_OTHER)
pline("Hark! \"%s.\"", info->display_txt);
pline("Hark! \"%s.\"", info->display_txt);
}
# if !defined(UNIX) && !defined(VMS)
#if !defined(UNIX) && !defined(VMS)
void
ckmailstatus()
{
if (u.uswallow || !flags.biff) return;
if (mustgetmail < 0) {
if (u.uswallow || !flags.biff)
return;
if (mustgetmail < 0) {
#if defined(AMIGA) || defined(MSDOS) || defined(TOS)
mustgetmail=(moves<2000)?(100+rn2(2000)):(2000+rn2(3000));
mustgetmail = (moves < 2000) ? (100 + rn2(2000)) : (2000 + rn2(3000));
#endif
return;
}
if (--mustgetmail <= 0) {
static struct mail_info
deliver = {MSG_MAIL,"I have some mail for you",0,0};
newmail(&deliver);
mustgetmail = -1;
}
return;
}
if (--mustgetmail <= 0) {
static struct mail_info deliver = { MSG_MAIL,
"I have some mail for you", 0,
0 };
newmail(&deliver);
mustgetmail = -1;
}
}
/*ARGSUSED*/
@@ -430,72 +434,71 @@ readmail(otmp)
struct obj *otmp;
{
static char *junk[] = {
NULL, /* placeholder for "Report bugs to <devteam@nethack.org>.", */
"Please disregard previous letter.",
"Welcome to NetHack.",
NULL, /* placeholder for "Report bugs to <devteam@nethack.org>.", */
"Please disregard previous letter.", "Welcome to NetHack.",
#ifdef AMIGA
"Only Amiga makes it possible.",
"CATS have all the answers.",
"Only Amiga makes it possible.", "CATS have all the answers.",
#endif
"This mail complies with the Yendorian Anti-Spam Act (YASA)",
"Please find enclosed a small token to represent your Owlbear",
"**FR33 P0T10N 0F FULL H34L1NG**",
"Please return to sender (Asmodeus)",
"Buy a potion of gain level for only $19.99! Guaranteed to be blessed!",
"Invitation: Visit the NetHack web site at http://www.nethack.org!"
"This mail complies with the Yendorian Anti-Spam Act (YASA)",
"Please find enclosed a small token to represent your Owlbear",
"**FR33 P0T10N 0F FULL H34L1NG**",
"Please return to sender (Asmodeus)", "Buy a potion of gain level "
"for only $19.99! Guaranteed "
"to be blessed!",
"Invitation: Visit the NetHack web site at http://www.nethack.org!"
};
/* XXX replace with more general substitution code and add local
* contact message. Also use DEVTEAM_URL */
if(junk[0] == NULL){
/* XXX replace with more general substitution code and add local
* contact message. Also use DEVTEAM_URL */
if (junk[0] == NULL) {
#define BUGS_FORMAT "Report bugs to %s."
junk[0] = (char *)alloc(strlen(BUGS_FORMAT) + strlen(DEVTEAM_EMAIL));
sprintf(junk[0], DEVTEAM_EMAIL);
junk[0] = (char *) alloc(strlen(BUGS_FORMAT) + strlen(DEVTEAM_EMAIL));
sprintf(junk[0], DEVTEAM_EMAIL);
#undef BUGS_FORMAT
}
if (Blind) {
pline("Unfortunately you cannot see what it says.");
pline("Unfortunately you cannot see what it says.");
} else
pline("It reads: \"%s\"", junk[rn2(SIZE(junk))]);
pline("It reads: \"%s\"", junk[rn2(SIZE(junk))]);
}
# endif /* !UNIX && !VMS */
#endif /* !UNIX && !VMS */
# ifdef UNIX
#ifdef UNIX
void
ckmailstatus()
{
if(!mailbox || u.uswallow || !flags.biff
# ifdef MAILCKFREQ
|| moves < laststattime + MAILCKFREQ
# endif
)
return;
if (!mailbox || u.uswallow || !flags.biff
#ifdef MAILCKFREQ
|| moves < laststattime + MAILCKFREQ
#endif
)
return;
laststattime = moves;
if(stat(mailbox, &nmstat)){
# ifdef PERMANENT_MAILBOX
pline("Cannot get status of MAIL=\"%s\" anymore.", mailbox);
mailbox = 0;
# else
nmstat.st_mtime = 0;
# endif
} else if(nmstat.st_mtime > omstat.st_mtime) {
if (nmstat.st_size) {
static struct mail_info deliver = {
# ifndef NO_MAILREADER
MSG_MAIL, "I have some mail for you",
# else
/* suppress creation and delivery of scroll of mail */
MSG_OTHER, "You have some mail in the outside world",
# endif
0, 0
};
newmail(&deliver);
}
getmailstatus(); /* might be too late ... */
}
laststattime = moves;
if (stat(mailbox, &nmstat)) {
#ifdef PERMANENT_MAILBOX
pline("Cannot get status of MAIL=\"%s\" anymore.", mailbox);
mailbox = 0;
#else
nmstat.st_mtime = 0;
#endif
} else if (nmstat.st_mtime > omstat.st_mtime) {
if (nmstat.st_size) {
static struct mail_info deliver = {
#ifndef NO_MAILREADER
MSG_MAIL, "I have some mail for you",
#else
/* suppress creation and delivery of scroll of mail */
MSG_OTHER, "You have some mail in the outside world",
#endif
0, 0
};
newmail(&deliver);
}
getmailstatus(); /* might be too late ... */
}
}
/*ARGSUSED*/
@@ -503,31 +506,31 @@ void
readmail(otmp)
struct obj *otmp;
{
# ifdef DEF_MAILREADER /* This implies that UNIX is defined */
register const char *mr = 0;
#ifdef DEF_MAILREADER /* This implies that UNIX is defined */
register const char *mr = 0;
display_nhwindow(WIN_MESSAGE, FALSE);
if(!(mr = nh_getenv("MAILREADER")))
mr = DEF_MAILREADER;
display_nhwindow(WIN_MESSAGE, FALSE);
if (!(mr = nh_getenv("MAILREADER")))
mr = DEF_MAILREADER;
if(child(1)){
(void) execl(mr, mr, (char *)0);
terminate(EXIT_FAILURE);
}
# else
# ifndef AMS /* AMS mailboxes are directories */
display_file(mailbox, TRUE);
# endif /* AMS */
# endif /* DEF_MAILREADER */
if (child(1)) {
(void) execl(mr, mr, (char *) 0);
terminate(EXIT_FAILURE);
}
#else
#ifndef AMS /* AMS mailboxes are directories */
display_file(mailbox, TRUE);
#endif /* AMS */
#endif /* DEF_MAILREADER */
/* get new stat; not entirely correct: there is a small time
window where we do not see new mail */
getmailstatus();
/* get new stat; not entirely correct: there is a small time
window where we do not see new mail */
getmailstatus();
}
# endif /* UNIX */
#endif /* UNIX */
# ifdef VMS
#ifdef VMS
extern NDECL(struct mail_info *parse_next_broadcast);
@@ -538,14 +541,15 @@ ckmailstatus()
{
struct mail_info *brdcst;
if (u.uswallow || !flags.biff) return;
if (u.uswallow || !flags.biff)
return;
while (broadcasts > 0) { /* process all trapped broadcasts [until] */
broadcasts--;
if ((brdcst = parse_next_broadcast()) != 0) {
newmail(brdcst);
break; /* only handle one real message at a time */
}
while (broadcasts > 0) { /* process all trapped broadcasts [until] */
broadcasts--;
if ((brdcst = parse_next_broadcast()) != 0) {
newmail(brdcst);
break; /* only handle one real message at a time */
}
}
}
@@ -553,35 +557,40 @@ void
readmail(otmp)
struct obj *otmp;
{
# ifdef SHELL /* can't access mail reader without spawning subprocess */
#ifdef SHELL /* can't access mail reader without spawning subprocess */
const char *txt, *cmd;
char *p, buf[BUFSZ], qbuf[BUFSZ];
int len;
/* there should be a command in OMAILCMD */
if (has_oname(otmp)) txt = ONAME(otmp);
else txt = "";
if (has_oname(otmp))
txt = ONAME(otmp);
else
txt = "";
len = strlen(txt);
if (has_omailcmd(otmp))
cmd = OMAILCMD(otmp);
if (!cmd || !*cmd) cmd = "SPAWN";
cmd = OMAILCMD(otmp);
if (!cmd || !*cmd)
cmd = "SPAWN";
Sprintf(qbuf, "System command (%s)", cmd);
getlin(qbuf, buf);
if (*buf != '\033') {
for (p = eos(buf); p > buf; *p = '\0')
if (*--p != ' ') break; /* strip trailing spaces */
if (*buf) cmd = buf; /* use user entered command */
if (!strcmpi(cmd, "SPAWN") || !strcmp(cmd, "!"))
cmd = (char *) 0; /* interactive escape */
for (p = eos(buf); p > buf; *p = '\0')
if (*--p != ' ')
break; /* strip trailing spaces */
if (*buf)
cmd = buf; /* use user entered command */
if (!strcmpi(cmd, "SPAWN") || !strcmp(cmd, "!"))
cmd = (char *) 0; /* interactive escape */
vms_doshell(cmd, TRUE);
(void) sleep(1);
vms_doshell(cmd, TRUE);
(void) sleep(1);
}
# endif /* SHELL */
#endif /* SHELL */
}
# endif /* VMS */
#endif /* VMS */
#endif /* MAIL */
/*mail.c*/
+1652 -1481
View File
File diff suppressed because it is too large Load Diff
+209 -197
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mapglyph.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 mapglyph.c $NHDT-Date: 1431192760 2015/05/09 17:32:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */
/* NetHack 3.6 mapglyph.c $Date: 2009/05/06 10:46:45 $ $Revision: 1.24 $ */
/* SCCS Id: @(#)mapglyph.c 3.5 2006/10/01 */
/* Copyright (c) David Cohrs, 1991 */
@@ -6,36 +6,37 @@
#include "hack.h"
#if defined(TTY_GRAPHICS)
#include "wintty.h" /* for prototype of has_color() only */
#include "wintty.h" /* for prototype of has_color() only */
#endif
#include "color.h"
#define HI_DOMESTIC CLR_WHITE /* monst.c */
#define HI_DOMESTIC CLR_WHITE /* monst.c */
int explcolors[] = {
CLR_BLACK, /* dark */
CLR_GREEN, /* noxious */
CLR_BROWN, /* muddy */
CLR_BLUE, /* wet */
CLR_MAGENTA, /* magical */
CLR_ORANGE, /* fiery */
CLR_WHITE, /* frosty */
CLR_BLACK, /* dark */
CLR_GREEN, /* noxious */
CLR_BROWN, /* muddy */
CLR_BLUE, /* wet */
CLR_MAGENTA, /* magical */
CLR_ORANGE, /* fiery */
CLR_WHITE, /* frosty */
};
#if !defined(TTY_GRAPHICS)
#define has_color(n) TRUE
#define has_color(n) TRUE
#endif
#ifdef TEXTCOLOR
#define zap_color(n) color = iflags.use_color ? zapcolors[n] : NO_COLOR
#define zap_color(n) color = iflags.use_color ? zapcolors[n] : NO_COLOR
#define cmap_color(n) color = iflags.use_color ? defsyms[n].color : NO_COLOR
#define obj_color(n) color = iflags.use_color ? objects[n].oc_color : NO_COLOR
#define mon_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
#define obj_color(n) color = iflags.use_color ? objects[n].oc_color : NO_COLOR
#define mon_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
#define invis_color(n) color = NO_COLOR
#define pet_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
#define warn_color(n) color = iflags.use_color ? def_warnsyms[n].color : NO_COLOR
#define pet_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
#define warn_color(n) \
color = iflags.use_color ? def_warnsyms[n].color : NO_COLOR
#define explode_color(n) color = iflags.use_color ? explcolors[n] : NO_COLOR
#else /* no text color */
#else /* no text color */
#define zap_color(n)
#define cmap_color(n)
@@ -47,13 +48,13 @@ int explcolors[] = {
#define explode_color(n)
#endif
# if defined(USE_TILES) && defined(MSDOS)
#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \
SYMHANDLING(H_IBM) && !iflags.grmode)
# else
#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \
SYMHANDLING(H_IBM))
# endif
#if defined(USE_TILES) && defined(MSDOS)
#define HAS_ROGUE_IBM_GRAPHICS \
(currentgraphics == ROGUESET && SYMHANDLING(H_IBM) && !iflags.grmode)
#else
#define HAS_ROGUE_IBM_GRAPHICS \
(currentgraphics == ROGUESET && SYMHANDLING(H_IBM))
#endif
/*ARGSUSED*/
int
@@ -62,14 +63,14 @@ int glyph, *ocolor, x, y;
int *ochar;
unsigned *ospecial;
{
register int offset, idx;
int color = NO_COLOR;
nhsym ch;
unsigned special = 0;
/* condense multiple tests in macro version down to single */
boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS;
boolean has_rogue_color = (has_rogue_ibm_graphics &&
(symset[currentgraphics].nocolor == 0));
register int offset, idx;
int color = NO_COLOR;
nhsym ch;
unsigned special = 0;
/* condense multiple tests in macro version down to single */
boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS;
boolean has_rogue_color =
(has_rogue_ibm_graphics && (symset[currentgraphics].nocolor == 0));
/*
* Map the glyph back to a character and color.
@@ -77,138 +78,147 @@ unsigned *ospecial;
* Warning: For speed, this makes an assumption on the order of
* offsets. The order is set in display.h.
*/
if ((offset = (glyph - GLYPH_STATUE_OFF)) >= 0) { /* a statue */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = CLR_RED;
else
obj_color(STATUE);
special |= MG_STATUE;
} else if ((offset = (glyph - GLYPH_WARNING_OFF)) >= 0) { /* a warning flash */
idx = offset + SYM_OFF_W;
if (has_rogue_color)
color = NO_COLOR;
else
warn_color(offset);
} else if ((offset = (glyph - GLYPH_SWALLOW_OFF)) >= 0) { /* swallow */
/* see swallow_to_glyph() in display.c */
idx = (S_sw_tl + (offset & 0x7)) + SYM_OFF_P;
if (has_rogue_color && iflags.use_color)
color = NO_COLOR;
else
mon_color(offset >> 3);
} else if ((offset = (glyph - GLYPH_ZAP_OFF)) >= 0) { /* zap beam */
/* see zapdir_to_glyph() in display.c */
idx = (S_vbeam + (offset & 0x3)) + SYM_OFF_P;
if (has_rogue_color && iflags.use_color)
color = NO_COLOR;
else
zap_color((offset >> 2));
} else if ((offset = (glyph - GLYPH_EXPLODE_OFF)) >= 0) { /* explosion */
idx = ((offset % MAXEXPCHARS) + S_explode1) + SYM_OFF_P;
explode_color(offset / MAXEXPCHARS);
} else if ((offset = (glyph - GLYPH_CMAP_OFF)) >= 0) { /* cmap */
idx = offset + SYM_OFF_P;
if (has_rogue_color && iflags.use_color) {
if (offset >= S_vwall && offset <= S_hcdoor)
color = CLR_BROWN;
else if (offset >= S_arrow_trap && offset <= S_polymorph_trap)
color = CLR_MAGENTA;
else if (offset == S_corr || offset == S_litcorr)
color = CLR_GRAY;
else if (offset >= S_room && offset <= S_water && offset != S_darkroom)
color = CLR_GREEN;
else
color = NO_COLOR;
} else
if ((offset = (glyph - GLYPH_STATUE_OFF)) >= 0) { /* a statue */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = CLR_RED;
else
obj_color(STATUE);
special |= MG_STATUE;
} else if ((offset = (glyph - GLYPH_WARNING_OFF))
>= 0) { /* a warning flash */
idx = offset + SYM_OFF_W;
if (has_rogue_color)
color = NO_COLOR;
else
warn_color(offset);
} else if ((offset = (glyph - GLYPH_SWALLOW_OFF)) >= 0) { /* swallow */
/* see swallow_to_glyph() in display.c */
idx = (S_sw_tl + (offset & 0x7)) + SYM_OFF_P;
if (has_rogue_color && iflags.use_color)
color = NO_COLOR;
else
mon_color(offset >> 3);
} else if ((offset = (glyph - GLYPH_ZAP_OFF)) >= 0) { /* zap beam */
/* see zapdir_to_glyph() in display.c */
idx = (S_vbeam + (offset & 0x3)) + SYM_OFF_P;
if (has_rogue_color && iflags.use_color)
color = NO_COLOR;
else
zap_color((offset >> 2));
} else if ((offset = (glyph - GLYPH_EXPLODE_OFF)) >= 0) { /* explosion */
idx = ((offset % MAXEXPCHARS) + S_explode1) + SYM_OFF_P;
explode_color(offset / MAXEXPCHARS);
} else if ((offset = (glyph - GLYPH_CMAP_OFF)) >= 0) { /* cmap */
idx = offset + SYM_OFF_P;
if (has_rogue_color && iflags.use_color) {
if (offset >= S_vwall && offset <= S_hcdoor)
color = CLR_BROWN;
else if (offset >= S_arrow_trap && offset <= S_polymorph_trap)
color = CLR_MAGENTA;
else if (offset == S_corr || offset == S_litcorr)
color = CLR_GRAY;
else if (offset >= S_room && offset <= S_water
&& offset != S_darkroom)
color = CLR_GREEN;
else
color = NO_COLOR;
} else
#ifdef TEXTCOLOR
/* provide a visible difference if normal and lit corridor
* use the same symbol */
if (iflags.use_color && offset == S_litcorr &&
showsyms[idx] == showsyms[S_corr + SYM_OFF_P])
color = CLR_WHITE;
else
/* provide a visible difference if normal and lit corridor
* use the same symbol */
if (iflags.use_color && offset == S_litcorr
&& showsyms[idx] == showsyms[S_corr + SYM_OFF_P])
color = CLR_WHITE;
else
#endif
cmap_color(offset);
} else if ((offset = (glyph - GLYPH_OBJ_OFF)) >= 0) { /* object */
idx = objects[offset].oc_class + SYM_OFF_O;
if (offset == BOULDER && iflags.bouldersym)
idx = SYM_BOULDER + SYM_OFF_X;
if (has_rogue_color && iflags.use_color) {
switch(objects[offset].oc_class) {
case COIN_CLASS: color = CLR_YELLOW; break;
case FOOD_CLASS: color = CLR_RED; break;
default: color = CLR_BRIGHT_BLUE; break;
}
} else
obj_color(offset);
} else if ((offset = (glyph - GLYPH_RIDDEN_OFF)) >= 0) { /* mon ridden */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
/* This currently implies that the hero is here -- monsters */
/* don't ride (yet...). Should we set it to yellow like in */
/* the monster case below? There is no equivalent in rogue. */
color = NO_COLOR; /* no need to check iflags.use_color */
else
mon_color(offset);
special |= MG_RIDDEN;
} else if ((offset = (glyph - GLYPH_BODY_OFF)) >= 0) { /* a corpse */
idx = objects[CORPSE].oc_class + SYM_OFF_O;
if (has_rogue_color && iflags.use_color)
color = CLR_RED;
else
mon_color(offset);
special |= MG_CORPSE;
} else if ((offset = (glyph - GLYPH_DETECT_OFF)) >= 0) { /* mon detect */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
mon_color(offset);
/* Disabled for now; anyone want to get reverse video to work? */
/* is_reverse = TRUE; */
special |= MG_DETECT;
} else if ((offset = (glyph - GLYPH_INVIS_OFF)) >= 0) { /* invisible */
idx = SYM_INVISIBLE + SYM_OFF_X;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
invis_color(offset);
special |= MG_INVIS;
} else if ((offset = (glyph - GLYPH_PET_OFF)) >= 0) { /* a pet */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
pet_color(offset);
special |= MG_PET;
} else { /* a monster */
idx = mons[glyph].mlet + SYM_OFF_M;
if (has_rogue_color && iflags.use_color) {
if (x == u.ux && y == u.uy)
/* actually player should be yellow-on-gray if in a corridor */
color = CLR_YELLOW;
else
color = NO_COLOR;
} else {
mon_color(glyph);
/* special case the hero for `showrace' option */
cmap_color(offset);
} else if ((offset = (glyph - GLYPH_OBJ_OFF)) >= 0) { /* object */
idx = objects[offset].oc_class + SYM_OFF_O;
if (offset == BOULDER && iflags.bouldersym)
idx = SYM_BOULDER + SYM_OFF_X;
if (has_rogue_color && iflags.use_color) {
switch (objects[offset].oc_class) {
case COIN_CLASS:
color = CLR_YELLOW;
break;
case FOOD_CLASS:
color = CLR_RED;
break;
default:
color = CLR_BRIGHT_BLUE;
break;
}
} else
obj_color(offset);
} else if ((offset = (glyph - GLYPH_RIDDEN_OFF)) >= 0) { /* mon ridden */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
/* This currently implies that the hero is here -- monsters */
/* don't ride (yet...). Should we set it to yellow like in */
/* the monster case below? There is no equivalent in rogue. */
color = NO_COLOR; /* no need to check iflags.use_color */
else
mon_color(offset);
special |= MG_RIDDEN;
} else if ((offset = (glyph - GLYPH_BODY_OFF)) >= 0) { /* a corpse */
idx = objects[CORPSE].oc_class + SYM_OFF_O;
if (has_rogue_color && iflags.use_color)
color = CLR_RED;
else
mon_color(offset);
special |= MG_CORPSE;
} else if ((offset = (glyph - GLYPH_DETECT_OFF)) >= 0) { /* mon detect */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
mon_color(offset);
/* Disabled for now; anyone want to get reverse video to work? */
/* is_reverse = TRUE; */
special |= MG_DETECT;
} else if ((offset = (glyph - GLYPH_INVIS_OFF)) >= 0) { /* invisible */
idx = SYM_INVISIBLE + SYM_OFF_X;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
invis_color(offset);
special |= MG_INVIS;
} else if ((offset = (glyph - GLYPH_PET_OFF)) >= 0) { /* a pet */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = NO_COLOR; /* no need to check iflags.use_color */
else
pet_color(offset);
special |= MG_PET;
} else { /* a monster */
idx = mons[glyph].mlet + SYM_OFF_M;
if (has_rogue_color && iflags.use_color) {
if (x == u.ux && y == u.uy)
/* actually player should be yellow-on-gray if in a corridor
*/
color = CLR_YELLOW;
else
color = NO_COLOR;
} else {
mon_color(glyph);
/* special case the hero for `showrace' option */
#ifdef TEXTCOLOR
if (iflags.use_color && x == u.ux && y == u.uy &&
flags.showrace && !Upolyd)
color = HI_DOMESTIC;
if (iflags.use_color && x == u.ux && y == u.uy && flags.showrace
&& !Upolyd)
color = HI_DOMESTIC;
#endif
}
}
}
ch = showsyms[idx];
#ifdef TEXTCOLOR
/* Turn off color if no color defined, or rogue level w/o PC graphics. */
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_color))
color = NO_COLOR;
color = NO_COLOR;
#endif
*ochar = (int)ch;
*ochar = (int) ch;
*ospecial = special;
#ifdef TEXTCOLOR
*ocolor = color;
@@ -220,9 +230,9 @@ char *
encglyph(glyph)
int glyph;
{
static char encbuf[20];
Sprintf(encbuf, "\\G%04X%04X", context.rndencode, glyph);
return encbuf;
static char encbuf[20];
Sprintf(encbuf, "\\G%04X%04X", context.rndencode, glyph);
return encbuf;
}
/*
@@ -230,7 +240,7 @@ int glyph;
* contain a sequence of characters representing:
* \GXXXXNNNN a glyph value, encoded by encglyph().
*
* For window ports that haven't yet written their own
* For window ports that haven't yet written their own
* XXX_putmixed() routine, this general one can be used.
* It replaces the encoded glyph sequence with a single
* showsyms[] char, then just passes that string onto
@@ -239,39 +249,41 @@ int glyph;
void
genl_putmixed(window, attr, str)
winid window;
int attr;
const char *str;
winid window;
int attr;
const char *str;
{
char buf[BUFSZ];
const char *cp = str;
char *put = buf;
while (*cp) {
if (*cp == '\\') {
int rndchk = 0, so = 0, gv = 0, ch, oc, dcount;
unsigned os;
const char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
const char *save_cp = cp;
cp++;
switch(*cp) {
case 'G': /* glyph value \GXXXXNNNN*/
dcount = 0;
for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++)
rndchk = (int)((rndchk * 16) + ((int)(dp - hex) / 2));
char buf[BUFSZ];
const char *cp = str;
char *put = buf;
while (*cp) {
if (*cp == '\\') {
int rndchk = 0, so = 0, gv = 0, ch, oc, dcount;
unsigned os;
const char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
const char *save_cp = cp;
if (rndchk == context.rndencode) {
dcount = 0;
for (; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++)
gv = (int)((gv * 16) + ((int)(dp - hex) / 2));
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
*put++ = showsyms[so];
} else {
/* possible forgery - leave it the way it is */
cp = save_cp;
}
break;
# if 0
cp++;
switch (*cp) {
case 'G': /* glyph value \GXXXXNNNN*/
dcount = 0;
for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 4);
cp++)
rndchk = (int) ((rndchk * 16) + ((int) (dp - hex) / 2));
if (rndchk == context.rndencode) {
dcount = 0;
for (; *cp && (dp = index(hex, *cp)) && (dcount++ < 4);
cp++)
gv = (int) ((gv * 16) + ((int) (dp - hex) / 2));
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
*put++ = showsyms[so];
} else {
/* possible forgery - leave it the way it is */
cp = save_cp;
}
break;
#if 0
case 'S': /* symbol offset */
dcount = 0;
for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++)
@@ -284,15 +296,15 @@ genl_putmixed(window, attr, str)
}
*put++ = showsyms[so];
break;
# endif
case '\\':
break;
}
}
*put++ = *cp++;
}
*put = '\0';
/* now send it to the normal putstr */
putstr(window, attr, buf);
#endif
case '\\':
break;
}
}
*put++ = *cp++;
}
*put = '\0';
/* now send it to the normal putstr */
putstr(window, attr, buf);
}
/*mapglyph.c*/
+648 -615
View File
File diff suppressed because it is too large Load Diff
+1307 -1204
View File
File diff suppressed because it is too large Load Diff
+2445 -2272
View File
File diff suppressed because it is too large Load Diff
+330 -315
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 minion.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 minion.c $NHDT-Date: 1431192768 2015/05/09 17:32:48 $ $NHDT-Branch: master $:$NHDT-Revision: 1.31 $ */
/* NetHack 3.6 minion.c $Date: 2009/05/06 10:46:52 $ $Revision: 1.26 $ */
/* SCCS Id: @(#)minion.c 3.5 2008/11/14 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -10,131 +10,140 @@ void
newemin(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!EMIN(mtmp)) {
EMIN(mtmp) = (struct emin *)alloc(sizeof(struct emin));
(void) memset((genericptr_t) EMIN(mtmp), 0, sizeof(struct emin));
}
if (!mtmp->mextra)
mtmp->mextra = newmextra();
if (!EMIN(mtmp)) {
EMIN(mtmp) = (struct emin *) alloc(sizeof(struct emin));
(void) memset((genericptr_t) EMIN(mtmp), 0, sizeof(struct emin));
}
}
void
free_emin(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && EMIN(mtmp)) {
free((genericptr_t) EMIN(mtmp));
EMIN(mtmp) = (struct emin *)0;
}
mtmp->isminion = 0;
if (mtmp->mextra && EMIN(mtmp)) {
free((genericptr_t) EMIN(mtmp));
EMIN(mtmp) = (struct emin *) 0;
}
mtmp->isminion = 0;
}
/* count the number of monsters on the level */
int
monster_census(spotted)
boolean spotted; /* seen|sensed vs all */
boolean spotted; /* seen|sensed vs all */
{
struct monst *mtmp;
int count = 0;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp)) continue;
if (spotted && !canspotmon(mtmp)) continue;
++count;
if (DEADMONSTER(mtmp))
continue;
if (spotted && !canspotmon(mtmp))
continue;
++count;
}
return count;
}
int
msummon(mon) /* mon summons a monster */
int msummon(mon) /* mon summons a monster */
struct monst *mon;
{
struct permonst *ptr;
int dtype = NON_PM, cnt = 0, result = 0, census;
aligntyp atyp;
struct monst *mtmp;
struct permonst *ptr;
int dtype = NON_PM, cnt = 0, result = 0, census;
aligntyp atyp;
struct monst *mtmp;
if (mon) {
ptr = mon->data;
atyp = mon->ispriest ? EPRI(mon)->shralign :
mon->isminion ? EMIN(mon)->min_align :
(ptr->maligntyp == A_NONE) ? A_NONE : sgn(ptr->maligntyp);
} else {
ptr = &mons[PM_WIZARD_OF_YENDOR];
atyp = (ptr->maligntyp==A_NONE) ? A_NONE : sgn(ptr->maligntyp);
}
if (mon) {
ptr = mon->data;
atyp = mon->ispriest ? EPRI(mon)->shralign
: mon->isminion ? EMIN(mon)->min_align
: (ptr->maligntyp == A_NONE)
? A_NONE
: sgn(ptr->maligntyp);
} else {
ptr = &mons[PM_WIZARD_OF_YENDOR];
atyp = (ptr->maligntyp == A_NONE) ? A_NONE : sgn(ptr->maligntyp);
}
if (is_dprince(ptr) || (ptr == &mons[PM_WIZARD_OF_YENDOR])) {
dtype = (!rn2(20)) ? dprince(atyp) :
(!rn2(4)) ? dlord(atyp) : ndemon(atyp);
cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
} else if (is_dlord(ptr)) {
dtype = (!rn2(50)) ? dprince(atyp) :
(!rn2(20)) ? dlord(atyp) : ndemon(atyp);
cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
} else if (is_ndemon(ptr)) {
dtype = (!rn2(20)) ? dlord(atyp) :
(!rn2(6)) ? ndemon(atyp) : monsndx(ptr);
cnt = 1;
} else if (is_lminion(mon)) {
dtype = (is_lord(ptr) && !rn2(20)) ? llord() :
(is_lord(ptr) || !rn2(6)) ? lminion() : monsndx(ptr);
cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
} else if (ptr == &mons[PM_ANGEL]) {
/* non-lawful angels can also summon */
if (!rn2(6)) {
switch (atyp) { /* see summon_minion */
case A_NEUTRAL:
dtype = PM_AIR_ELEMENTAL + rn2(4);
break;
case A_CHAOTIC:
case A_NONE:
dtype = ndemon(atyp);
break;
}
} else {
dtype = PM_ANGEL;
}
cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
}
if (is_dprince(ptr) || (ptr == &mons[PM_WIZARD_OF_YENDOR])) {
dtype = (!rn2(20)) ? dprince(atyp) : (!rn2(4)) ? dlord(atyp)
: ndemon(atyp);
cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
} else if (is_dlord(ptr)) {
dtype = (!rn2(50)) ? dprince(atyp) : (!rn2(20)) ? dlord(atyp)
: ndemon(atyp);
cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
} else if (is_ndemon(ptr)) {
dtype = (!rn2(20)) ? dlord(atyp) : (!rn2(6)) ? ndemon(atyp)
: monsndx(ptr);
cnt = 1;
} else if (is_lminion(mon)) {
dtype = (is_lord(ptr) && !rn2(20))
? llord()
: (is_lord(ptr) || !rn2(6)) ? lminion() : monsndx(ptr);
cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
} else if (ptr == &mons[PM_ANGEL]) {
/* non-lawful angels can also summon */
if (!rn2(6)) {
switch (atyp) { /* see summon_minion */
case A_NEUTRAL:
dtype = PM_AIR_ELEMENTAL + rn2(4);
break;
case A_CHAOTIC:
case A_NONE:
dtype = ndemon(atyp);
break;
}
} else {
dtype = PM_ANGEL;
}
cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
}
if (dtype == NON_PM) return 0;
if (dtype == NON_PM)
return 0;
/* sanity checks */
if (cnt > 1 && (mons[dtype].geno & G_UNIQ)) cnt = 1;
/*
* If this daemon is unique and being re-summoned (the only way we
* could get this far with an extinct dtype), try another.
*/
if (mvitals[dtype].mvflags & G_GONE) {
dtype = ndemon(atyp);
if (dtype == NON_PM) return 0;
}
/* sanity checks */
if (cnt > 1 && (mons[dtype].geno & G_UNIQ))
cnt = 1;
/*
* If this daemon is unique and being re-summoned (the only way we
* could get this far with an extinct dtype), try another.
*/
if (mvitals[dtype].mvflags & G_GONE) {
dtype = ndemon(atyp);
if (dtype == NON_PM)
return 0;
}
/* some candidates can generate a group of monsters, so simple
count of non-null makemon() result is not sufficient */
census = monster_census(FALSE);
/* some candidates can generate a group of monsters, so simple
count of non-null makemon() result is not sufficient */
census = monster_census(FALSE);
while (cnt > 0) {
mtmp = makemon(&mons[dtype], u.ux, u.uy, MM_EMIN);
if (mtmp) {
result++;
/* an angel's alignment should match the summoner */
if (dtype == PM_ANGEL) {
mtmp->isminion = 1;
EMIN(mtmp)->min_align = atyp;
/* renegade if same alignment but not peaceful
or peaceful but different alignment */
EMIN(mtmp)->renegade =
(atyp != u.ualign.type) ^ !mtmp->mpeaceful;
}
}
cnt--;
}
while (cnt > 0) {
mtmp = makemon(&mons[dtype], u.ux, u.uy, MM_EMIN);
if (mtmp) {
result++;
/* an angel's alignment should match the summoner */
if (dtype == PM_ANGEL) {
mtmp->isminion = 1;
EMIN(mtmp)->min_align = atyp;
/* renegade if same alignment but not peaceful
or peaceful but different alignment */
EMIN(mtmp)->renegade =
(atyp != u.ualign.type) ^ !mtmp->mpeaceful;
}
}
cnt--;
}
/* how many monsters exist now compared to before? */
if (result) result = monster_census(FALSE) - census;
/* how many monsters exist now compared to before? */
if (result)
result = monster_census(FALSE) - census;
return result;
return result;
}
void
@@ -145,261 +154,265 @@ boolean talk;
register struct monst *mon;
int mnum;
switch ((int)alignment) {
case A_LAWFUL:
mnum = lminion();
break;
case A_NEUTRAL:
mnum = PM_AIR_ELEMENTAL + rn2(4);
break;
case A_CHAOTIC:
case A_NONE:
mnum = ndemon(alignment);
break;
default:
impossible("unaligned player?");
mnum = ndemon(A_NONE);
break;
switch ((int) alignment) {
case A_LAWFUL:
mnum = lminion();
break;
case A_NEUTRAL:
mnum = PM_AIR_ELEMENTAL + rn2(4);
break;
case A_CHAOTIC:
case A_NONE:
mnum = ndemon(alignment);
break;
default:
impossible("unaligned player?");
mnum = ndemon(A_NONE);
break;
}
if (mnum == NON_PM) {
mon = 0;
mon = 0;
} else if (mnum == PM_ANGEL) {
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;
EMIN(mon)->renegade = FALSE;
}
} else if (mnum != PM_SHOPKEEPER && mnum != PM_GUARD &&
mnum != PM_ALIGNED_PRIEST && mnum != PM_HIGH_PRIEST) {
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;
EMIN(mon)->renegade = FALSE;
}
} else if (mnum != PM_SHOPKEEPER && mnum != PM_GUARD
&& mnum != PM_ALIGNED_PRIEST && mnum != PM_HIGH_PRIEST) {
/* This was mons[mnum].pxlth == 0 but is this restriction
appropriate or necessary now that the structures are separate? */
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;
EMIN(mon)->renegade = FALSE;
}
appropriate or necessary now that the structures are separate? */
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;
EMIN(mon)->renegade = FALSE;
}
} else {
mon = makemon(&mons[mnum], u.ux, u.uy, NO_MM_FLAGS);
mon = makemon(&mons[mnum], u.ux, u.uy, NO_MM_FLAGS);
}
if (mon) {
if (talk) {
pline_The("voice of %s booms:", align_gname(alignment));
verbalize("Thou shalt pay for thine indiscretion!");
if (!Blind)
pline("%s appears before you.", Amonnam(mon));
mon->mstrategy &= ~STRAT_APPEARMSG;
}
mon->mpeaceful = FALSE;
/* don't call set_malign(); player was naughty */
if (talk) {
pline_The("voice of %s booms:", align_gname(alignment));
verbalize("Thou shalt pay for thine indiscretion!");
if (!Blind)
pline("%s appears before you.", Amonnam(mon));
mon->mstrategy &= ~STRAT_APPEARMSG;
}
mon->mpeaceful = FALSE;
/* don't call set_malign(); player was naughty */
}
}
#define Athome (Inhell && (mtmp->cham == NON_PM))
#define Athome (Inhell && (mtmp->cham == NON_PM))
int
demon_talk(mtmp) /* returns 1 if it won't attack. */
int demon_talk(mtmp) /* returns 1 if it won't attack. */
register struct monst *mtmp;
{
long cash, demand, offer;
long cash, demand, offer;
if (uwep && uwep->oartifact == ART_EXCALIBUR) {
pline("%s looks very angry.", Amonnam(mtmp));
mtmp->mpeaceful = mtmp->mtame = 0;
set_malign(mtmp);
newsym(mtmp->mx, mtmp->my);
return 0;
}
if (uwep && uwep->oartifact == ART_EXCALIBUR) {
pline("%s looks very angry.", Amonnam(mtmp));
mtmp->mpeaceful = mtmp->mtame = 0;
set_malign(mtmp);
newsym(mtmp->mx, mtmp->my);
return 0;
}
if (is_fainted()) {
reset_faint(); /* if fainted - wake up */
} else {
stop_occupation();
if (multi > 0) { nomul(0); unmul((char *)0); }
}
if (is_fainted()) {
reset_faint(); /* if fainted - wake up */
} else {
stop_occupation();
if (multi > 0) {
nomul(0);
unmul((char *) 0);
}
}
/* Slight advantage given. */
if (is_dprince(mtmp->data) && mtmp->minvis) {
boolean wasunseen = !canspotmon(mtmp);
/* Slight advantage given. */
if (is_dprince(mtmp->data) && mtmp->minvis) {
boolean wasunseen = !canspotmon(mtmp);
mtmp->minvis = mtmp->perminvis = 0;
if (wasunseen && canspotmon(mtmp)) {
pline("%s appears before you.", Amonnam(mtmp));
mtmp->mstrategy &= ~STRAT_APPEARMSG;
}
newsym(mtmp->mx,mtmp->my);
}
if (youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */
pline("%s says, \"Good hunting, %s.\"",
Amonnam(mtmp), flags.female ? "Sister" : "Brother");
if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
return(1);
}
cash = money_cnt(invent);
demand = (cash * (rnd(80) + 20 * Athome)) /
(100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp))));
mtmp->minvis = mtmp->perminvis = 0;
if (wasunseen && canspotmon(mtmp)) {
pline("%s appears before you.", Amonnam(mtmp));
mtmp->mstrategy &= ~STRAT_APPEARMSG;
}
newsym(mtmp->mx, mtmp->my);
}
if (youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */
pline("%s says, \"Good hunting, %s.\"", Amonnam(mtmp),
flags.female ? "Sister" : "Brother");
if (!tele_restrict(mtmp))
(void) rloc(mtmp, FALSE);
return (1);
}
cash = money_cnt(invent);
demand =
(cash * (rnd(80) + 20 * Athome))
/ (100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp))));
if (!demand || multi < 0) { /* you have no gold or can't move */
mtmp->mpeaceful = 0;
set_malign(mtmp);
return 0;
} else {
/* make sure that the demand is unmeetable if the monster
has the Amulet, preventing monster from being satisified
and removed from the game (along with said Amulet...) */
if (mon_has_amulet(mtmp))
demand = cash + (long)rn1(1000,40);
if (!demand || multi < 0) { /* you have no gold or can't move */
mtmp->mpeaceful = 0;
set_malign(mtmp);
return 0;
} else {
/* make sure that the demand is unmeetable if the monster
has the Amulet, preventing monster from being satisified
and removed from the game (along with said Amulet...) */
if (mon_has_amulet(mtmp))
demand = cash + (long) rn1(1000, 40);
pline("%s demands %ld %s for safe passage.",
Amonnam(mtmp), demand, currency(demand));
pline("%s demands %ld %s for safe passage.", Amonnam(mtmp), demand,
currency(demand));
if ((offer = bribe(mtmp)) >= demand) {
pline("%s vanishes, laughing about cowardly mortals.",
Amonnam(mtmp));
} else if (offer > 0L && (long)rnd(40) > (demand - offer)) {
pline("%s scowls at you menacingly, then vanishes.",
Amonnam(mtmp));
} else {
pline("%s gets angry...", Amonnam(mtmp));
mtmp->mpeaceful = 0;
set_malign(mtmp);
return 0;
}
}
mongone(mtmp);
return(1);
if ((offer = bribe(mtmp)) >= demand) {
pline("%s vanishes, laughing about cowardly mortals.",
Amonnam(mtmp));
} else if (offer > 0L && (long) rnd(40) > (demand - offer)) {
pline("%s scowls at you menacingly, then vanishes.",
Amonnam(mtmp));
} else {
pline("%s gets angry...", Amonnam(mtmp));
mtmp->mpeaceful = 0;
set_malign(mtmp);
return 0;
}
}
mongone(mtmp);
return (1);
}
long
bribe(mtmp)
struct monst *mtmp;
{
char buf[BUFSZ];
long offer;
long umoney = money_cnt(invent);
char buf[BUFSZ];
long offer;
long umoney = money_cnt(invent);
getlin("How much will you offer?", buf);
if (sscanf(buf, "%ld", &offer) != 1) offer = 0L;
getlin("How much will you offer?", buf);
if (sscanf(buf, "%ld", &offer) != 1)
offer = 0L;
/*Michael Paddon -- fix for negative offer to monster*/
/*JAR880815 - */
if (offer < 0L) {
You("try to shortchange %s, but fumble.",
mon_nam(mtmp));
return 0L;
} else if (offer == 0L) {
You("refuse.");
return 0L;
} else if (offer >= umoney) {
You("give %s all your gold.", mon_nam(mtmp));
offer = umoney;
} else {
You("give %s %ld %s.", mon_nam(mtmp), offer, currency(offer));
}
(void) money2mon(mtmp, offer);
context.botl = 1;
return(offer);
/*Michael Paddon -- fix for negative offer to monster*/
/*JAR880815 - */
if (offer < 0L) {
You("try to shortchange %s, but fumble.", mon_nam(mtmp));
return 0L;
} else if (offer == 0L) {
You("refuse.");
return 0L;
} else if (offer >= umoney) {
You("give %s all your gold.", mon_nam(mtmp));
offer = umoney;
} else {
You("give %s %ld %s.", mon_nam(mtmp), offer, currency(offer));
}
(void) money2mon(mtmp, offer);
context.botl = 1;
return (offer);
}
int
dprince(atyp)
aligntyp atyp;
{
int tryct, pm;
int tryct, pm;
for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) {
pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
if (!(mvitals[pm].mvflags & G_GONE) &&
(atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return(pm);
}
return(dlord(atyp)); /* approximate */
for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) {
pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
if (!(mvitals[pm].mvflags & G_GONE)
&& (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return (pm);
}
return (dlord(atyp)); /* approximate */
}
int
dlord(atyp)
aligntyp atyp;
{
int tryct, pm;
int tryct, pm;
for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) {
pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
if (!(mvitals[pm].mvflags & G_GONE) &&
(atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return(pm);
}
return(ndemon(atyp)); /* approximate */
for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) {
pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
if (!(mvitals[pm].mvflags & G_GONE)
&& (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return (pm);
}
return (ndemon(atyp)); /* approximate */
}
/* create lawful (good) lord */
int
llord()
{
if (!(mvitals[PM_ARCHON].mvflags & G_GONE))
return(PM_ARCHON);
if (!(mvitals[PM_ARCHON].mvflags & G_GONE))
return (PM_ARCHON);
return(lminion()); /* approximate */
return (lminion()); /* approximate */
}
int
lminion()
{
int tryct;
struct permonst *ptr;
int tryct;
struct permonst *ptr;
for (tryct = 0; tryct < 20; tryct++) {
ptr = mkclass(S_ANGEL,0);
if (ptr && !is_lord(ptr))
return(monsndx(ptr));
}
for (tryct = 0; tryct < 20; tryct++) {
ptr = mkclass(S_ANGEL, 0);
if (ptr && !is_lord(ptr))
return (monsndx(ptr));
}
return NON_PM;
return NON_PM;
}
int
ndemon(atyp)
aligntyp atyp;
{
int tryct;
struct permonst *ptr;
int tryct;
struct permonst *ptr;
for (tryct = 0; tryct < 20; tryct++) {
ptr = mkclass(S_DEMON, 0);
if (ptr && is_ndemon(ptr) &&
(atyp == A_NONE || sgn(ptr->maligntyp) == sgn(atyp)))
return(monsndx(ptr));
}
for (tryct = 0; tryct < 20; tryct++) {
ptr = mkclass(S_DEMON, 0);
if (ptr && is_ndemon(ptr)
&& (atyp == A_NONE || sgn(ptr->maligntyp) == sgn(atyp)))
return (monsndx(ptr));
}
return NON_PM;
return NON_PM;
}
/* guardian angel has been affected by conflict so is abandoning hero */
void
lose_guardian_angel(mon)
struct monst *mon; /* if null, angel hasn't been created yet */
struct monst *mon; /* if null, angel hasn't been created yet */
{
coord mm;
int i;
if (mon) {
if (canspotmon(mon)) {
if (!Deaf) {
pline("%s rebukes you, saying:", Monnam(mon));
verbalize("Since you desire conflict, have some more!");
} else {
pline("%s vanishes!", Monnam(mon));
}
}
mongone(mon);
if (canspotmon(mon)) {
if (!Deaf) {
pline("%s rebukes you, saying:", Monnam(mon));
verbalize("Since you desire conflict, have some more!");
} else {
pline("%s vanishes!", Monnam(mon));
}
}
mongone(mon);
}
/* create 2 to 4 hostile angels to replace the lost guardian */
for (i = rn1(3,2); i > 0; --i) {
mm.x = u.ux;
mm.y = u.uy;
if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL]))
(void) mk_roamer(&mons[PM_ANGEL], u.ualign.type,
mm.x, mm.y, FALSE);
for (i = rn1(3, 2); i > 0; --i) {
mm.x = u.ux;
mm.y = u.uy;
if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL]))
(void) mk_roamer(&mons[PM_ANGEL], u.ualign.type, mm.x, mm.y,
FALSE);
}
}
@@ -411,47 +424,49 @@ gain_guardian_angel()
struct obj *otmp;
coord mm;
Hear_again(); /* attempt to cure any deafness now (divine
message will be heard even if that fails) */
Hear_again(); /* attempt to cure any deafness now (divine
message will be heard even if that fails) */
if (Conflict) {
pline("A voice booms:");
verbalize("Thy desire for conflict shall be fulfilled!");
/* send in some hostile angels instead */
lose_guardian_angel((struct monst *)0);
} else if (u.ualign.record > 8) { /* fervent */
pline("A voice whispers:");
verbalize("Thou hast been worthy of me!");
mm.x = u.ux;
mm.y = u.uy;
if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL]) &&
(mtmp = mk_roamer(&mons[PM_ANGEL], u.ualign.type,
mm.x, mm.y, TRUE)) != 0) {
mtmp->mstrategy &= ~STRAT_APPEARMSG;
if (!Blind)
pline("An angel appears near you.");
else
You_feel("the presence of a friendly angel near you.");
/* guardian angel -- the one case mtame doesn't
* imply an edog structure, so we don't want to
* call tamedog().
*/
mtmp->mtame = 10;
/* make him strong enough vs. endgame foes */
mtmp->m_lev = rn1(8,15);
mtmp->mhp = mtmp->mhpmax = d((int)mtmp->m_lev,10) + 30 + rnd(30);
if ((otmp = select_hwep(mtmp)) == 0) {
otmp = mksobj(SILVER_SABER, FALSE, FALSE);
if (mpickobj(mtmp, otmp))
panic("merged weapon?");
}
bless(otmp);
if (otmp->spe < 4) otmp->spe += rnd(4);
if ((otmp = which_armor(mtmp, W_ARMS)) == 0 ||
otmp->otyp != SHIELD_OF_REFLECTION) {
(void) mongets(mtmp, AMULET_OF_REFLECTION);
m_dowear(mtmp, TRUE);
}
}
pline("A voice booms:");
verbalize("Thy desire for conflict shall be fulfilled!");
/* send in some hostile angels instead */
lose_guardian_angel((struct monst *) 0);
} else if (u.ualign.record > 8) { /* fervent */
pline("A voice whispers:");
verbalize("Thou hast been worthy of me!");
mm.x = u.ux;
mm.y = u.uy;
if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL])
&& (mtmp = mk_roamer(&mons[PM_ANGEL], u.ualign.type, mm.x, mm.y,
TRUE)) != 0) {
mtmp->mstrategy &= ~STRAT_APPEARMSG;
if (!Blind)
pline("An angel appears near you.");
else
You_feel("the presence of a friendly angel near you.");
/* guardian angel -- the one case mtame doesn't
* imply an edog structure, so we don't want to
* call tamedog().
*/
mtmp->mtame = 10;
/* make him strong enough vs. endgame foes */
mtmp->m_lev = rn1(8, 15);
mtmp->mhp = mtmp->mhpmax =
d((int) mtmp->m_lev, 10) + 30 + rnd(30);
if ((otmp = select_hwep(mtmp)) == 0) {
otmp = mksobj(SILVER_SABER, FALSE, FALSE);
if (mpickobj(mtmp, otmp))
panic("merged weapon?");
}
bless(otmp);
if (otmp->spe < 4)
otmp->spe += rnd(4);
if ((otmp = which_armor(mtmp, W_ARMS)) == 0
|| otmp->otyp != SHIELD_OF_REFLECTION) {
(void) mongets(mtmp, AMULET_OF_REFLECTION);
m_dowear(mtmp, TRUE);
}
}
}
}
+1227 -1118
View File
File diff suppressed because it is too large Load Diff
+316 -310
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mkmap.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 mkmap.c $NHDT-Date: 1431192762 2015/05/09 17:32:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
/* NetHack 3.6 mkmap.c $Date: 2009/05/06 10:46:55 $ $Revision: 1.12 $ */
/* SCCS Id: @(#)mkmap.c 3.5 2008/02/29 */
/* Copyright (c) J. C. Collet, M. Stephenson and D. Cohrs, 1992 */
@@ -7,19 +7,20 @@
#include "hack.h"
#include "sp_lev.h"
#define HEIGHT (ROWNO - 1)
#define WIDTH (COLNO - 2)
#define HEIGHT (ROWNO - 1)
#define WIDTH (COLNO - 2)
STATIC_DCL void FDECL(init_map,(SCHAR_P));
STATIC_DCL void FDECL(init_fill,(SCHAR_P,SCHAR_P));
STATIC_DCL schar FDECL(get_map,(int,int,SCHAR_P));
STATIC_DCL void FDECL(pass_one,(SCHAR_P,SCHAR_P));
STATIC_DCL void FDECL(pass_two,(SCHAR_P,SCHAR_P));
STATIC_DCL void FDECL(pass_three,(SCHAR_P,SCHAR_P));
STATIC_DCL void FDECL(init_map, (SCHAR_P));
STATIC_DCL void FDECL(init_fill, (SCHAR_P, SCHAR_P));
STATIC_DCL schar FDECL(get_map, (int, int, SCHAR_P));
STATIC_DCL void FDECL(pass_one, (SCHAR_P, SCHAR_P));
STATIC_DCL void FDECL(pass_two, (SCHAR_P, SCHAR_P));
STATIC_DCL void FDECL(pass_three, (SCHAR_P, SCHAR_P));
STATIC_DCL void NDECL(wallify_map);
STATIC_DCL void FDECL(join_map,(SCHAR_P,SCHAR_P));
STATIC_DCL void FDECL(finish_map,(SCHAR_P,SCHAR_P,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
STATIC_DCL void FDECL(remove_room,(unsigned));
STATIC_DCL void FDECL(join_map, (SCHAR_P, SCHAR_P));
STATIC_DCL void FDECL(finish_map,
(SCHAR_P, SCHAR_P, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL void FDECL(remove_room, (unsigned));
void FDECL(mkmap, (lev_init *));
char *new_locations;
@@ -28,129 +29,127 @@ static int n_loc_filled;
STATIC_OVL void
init_map(bg_typ)
schar bg_typ;
schar bg_typ;
{
register int i,j;
register int i, j;
for(i=1; i<COLNO; i++)
for(j=0; j<ROWNO; j++)
levl[i][j].typ = bg_typ;
for (i = 1; i < COLNO; i++)
for (j = 0; j < ROWNO; j++)
levl[i][j].typ = bg_typ;
}
STATIC_OVL void
init_fill(bg_typ, fg_typ)
schar bg_typ, fg_typ;
schar bg_typ, fg_typ;
{
register int i,j;
long limit, count;
register int i, j;
long limit, count;
limit = (WIDTH * HEIGHT * 2) / 5;
count = 0;
while(count < limit) {
i = rn1(WIDTH-1, 2);
j = rnd(HEIGHT-1);
if (levl[i][j].typ == bg_typ) {
levl[i][j].typ = fg_typ;
count++;
}
}
limit = (WIDTH * HEIGHT * 2) / 5;
count = 0;
while (count < limit) {
i = rn1(WIDTH - 1, 2);
j = rnd(HEIGHT - 1);
if (levl[i][j].typ == bg_typ) {
levl[i][j].typ = fg_typ;
count++;
}
}
}
STATIC_OVL schar
get_map(col,row, bg_typ)
int col,row;
schar bg_typ;
get_map(col, row, bg_typ)
int col, row;
schar bg_typ;
{
if (col <= 0 || row < 0 || col > WIDTH || row >= HEIGHT)
return bg_typ;
return levl[col][row].typ;
if (col <= 0 || row < 0 || col > WIDTH || row >= HEIGHT)
return bg_typ;
return levl[col][row].typ;
}
static int dirs[16] = {
-1, -1 /**/, -1, 0 /**/, -1, 1 /**/,
0, -1 /**/, 0, 1 /**/,
1, -1 /**/, 1, 0 /**/, 1, 1};
static int dirs[16] = { -1, -1 /**/, -1, 0 /**/, -1, 1 /**/, 0, -1 /**/,
0, 1 /**/, 1, -1 /**/, 1, 0 /**/, 1, 1 };
STATIC_OVL void
pass_one(bg_typ, fg_typ)
schar bg_typ, fg_typ;
schar bg_typ, fg_typ;
{
register int i,j;
short count, dr;
register int i, j;
short count, dr;
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++) {
for(count=0, dr=0; dr < 8; dr++)
if(get_map(i+dirs[dr*2], j+dirs[(dr*2)+1], bg_typ)
== fg_typ)
count++;
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++) {
for (count = 0, dr = 0; dr < 8; dr++)
if (get_map(i + dirs[dr * 2], j + dirs[(dr * 2) + 1], bg_typ)
== fg_typ)
count++;
switch(count) {
case 0 : /* death */
case 1 :
case 2:
levl[i][j].typ = bg_typ;
break;
case 5:
case 6:
case 7:
case 8:
levl[i][j].typ = fg_typ;
break;
default:
break;
}
}
switch (count) {
case 0: /* death */
case 1:
case 2:
levl[i][j].typ = bg_typ;
break;
case 5:
case 6:
case 7:
case 8:
levl[i][j].typ = fg_typ;
break;
default:
break;
}
}
}
#define new_loc(i,j) *(new_locations+ ((j)*(WIDTH+1)) + (i))
#define new_loc(i, j) *(new_locations + ((j) * (WIDTH + 1)) + (i))
STATIC_OVL void
pass_two(bg_typ, fg_typ)
schar bg_typ, fg_typ;
schar bg_typ, fg_typ;
{
register int i,j;
short count, dr;
register int i, j;
short count, dr;
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++) {
for(count=0, dr=0; dr < 8; dr++)
if(get_map(i+dirs[dr*2], j+dirs[(dr*2)+1], bg_typ)
== fg_typ)
count++;
if (count == 5)
new_loc(i,j) = bg_typ;
else
new_loc(i,j) = get_map(i,j, bg_typ);
}
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++) {
for (count = 0, dr = 0; dr < 8; dr++)
if (get_map(i + dirs[dr * 2], j + dirs[(dr * 2) + 1], bg_typ)
== fg_typ)
count++;
if (count == 5)
new_loc(i, j) = bg_typ;
else
new_loc(i, j) = get_map(i, j, bg_typ);
}
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++)
levl[i][j].typ = new_loc(i,j);
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++)
levl[i][j].typ = new_loc(i, j);
}
STATIC_OVL void
pass_three(bg_typ, fg_typ)
schar bg_typ, fg_typ;
schar bg_typ, fg_typ;
{
register int i,j;
short count, dr;
register int i, j;
short count, dr;
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++) {
for(count=0, dr=0; dr < 8; dr++)
if(get_map(i+dirs[dr*2], j+dirs[(dr*2)+1], bg_typ)
== fg_typ)
count++;
if (count < 3)
new_loc(i,j) = bg_typ;
else
new_loc(i,j) = get_map(i,j, bg_typ);
}
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++) {
for (count = 0, dr = 0; dr < 8; dr++)
if (get_map(i + dirs[dr * 2], j + dirs[(dr * 2) + 1], bg_typ)
== fg_typ)
count++;
if (count < 3)
new_loc(i, j) = bg_typ;
else
new_loc(i, j) = get_map(i, j, bg_typ);
}
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++)
levl[i][j].typ = new_loc(i,j);
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++)
levl[i][j].typ = new_loc(i, j);
}
/*
@@ -161,88 +160,92 @@ pass_three(bg_typ, fg_typ)
*/
void
flood_fill_rm(sx, sy, rmno, lit, anyroom)
int sx;
register int sy;
register int rmno;
boolean lit;
boolean anyroom;
int sx;
register int sy;
register int rmno;
boolean lit;
boolean anyroom;
{
register int i;
int nx;
schar fg_typ = levl[sx][sy].typ;
/* back up to find leftmost uninitialized location */
while (sx > 0 &&
(anyroom ? IS_ROOM(levl[sx][sy].typ) : levl[sx][sy].typ == fg_typ) &&
(int) levl[sx][sy].roomno != rmno)
sx--;
while (sx > 0 && (anyroom ? IS_ROOM(levl[sx][sy].typ)
: levl[sx][sy].typ == fg_typ)
&& (int) levl[sx][sy].roomno != rmno)
sx--;
sx++; /* compensate for extra decrement */
/* assume sx,sy is valid */
if(sx < min_rx) min_rx = sx;
if(sy < min_ry) min_ry = sy;
if (sx < min_rx)
min_rx = sx;
if (sy < min_ry)
min_ry = sy;
for(i=sx; i<=WIDTH && levl[i][sy].typ == fg_typ; i++) {
levl[i][sy].roomno = rmno;
levl[i][sy].lit = lit;
if(anyroom) {
/* add walls to room as well */
register int ii,jj;
for(ii= (i == sx ? i-1 : i); ii <= i+1; ii++)
for(jj = sy-1; jj <= sy+1; jj++)
if(isok(ii,jj) &&
(IS_WALL(levl[ii][jj].typ) ||
IS_DOOR(levl[ii][jj].typ) ||
levl[ii][jj].typ == SDOOR)) {
levl[ii][jj].edge = 1;
if(lit) levl[ii][jj].lit = lit;
if ((int) levl[ii][jj].roomno != rmno)
levl[ii][jj].roomno = SHARED;
}
}
n_loc_filled++;
for (i = sx; i <= WIDTH && levl[i][sy].typ == fg_typ; i++) {
levl[i][sy].roomno = rmno;
levl[i][sy].lit = lit;
if (anyroom) {
/* add walls to room as well */
register int ii, jj;
for (ii = (i == sx ? i - 1 : i); ii <= i + 1; ii++)
for (jj = sy - 1; jj <= sy + 1; jj++)
if (isok(ii, jj) && (IS_WALL(levl[ii][jj].typ)
|| IS_DOOR(levl[ii][jj].typ)
|| levl[ii][jj].typ == SDOOR)) {
levl[ii][jj].edge = 1;
if (lit)
levl[ii][jj].lit = lit;
if ((int) levl[ii][jj].roomno != rmno)
levl[ii][jj].roomno = SHARED;
}
}
n_loc_filled++;
}
nx = i;
if(isok(sx,sy-1)) {
for(i=sx; i<nx; i++)
if(levl[i][sy-1].typ == fg_typ) {
if ((int) levl[i][sy-1].roomno != rmno)
flood_fill_rm(i,sy-1,rmno,lit,anyroom);
} else {
if((i>sx || isok(i-1,sy-1)) &&
levl[i-1][sy-1].typ == fg_typ) {
if ((int) levl[i-1][sy-1].roomno != rmno)
flood_fill_rm(i-1,sy-1,rmno,lit,anyroom);
}
if((i<nx-1 || isok(i+1,sy-1)) &&
levl[i+1][sy-1].typ == fg_typ) {
if ((int) levl[i+1][sy-1].roomno != rmno)
flood_fill_rm(i+1,sy-1,rmno,lit,anyroom);
}
}
if (isok(sx, sy - 1)) {
for (i = sx; i < nx; i++)
if (levl[i][sy - 1].typ == fg_typ) {
if ((int) levl[i][sy - 1].roomno != rmno)
flood_fill_rm(i, sy - 1, rmno, lit, anyroom);
} else {
if ((i > sx || isok(i - 1, sy - 1))
&& levl[i - 1][sy - 1].typ == fg_typ) {
if ((int) levl[i - 1][sy - 1].roomno != rmno)
flood_fill_rm(i - 1, sy - 1, rmno, lit, anyroom);
}
if ((i < nx - 1 || isok(i + 1, sy - 1))
&& levl[i + 1][sy - 1].typ == fg_typ) {
if ((int) levl[i + 1][sy - 1].roomno != rmno)
flood_fill_rm(i + 1, sy - 1, rmno, lit, anyroom);
}
}
}
if(isok(sx,sy+1)) {
for(i=sx; i<nx; i++)
if(levl[i][sy+1].typ == fg_typ) {
if ((int) levl[i][sy+1].roomno != rmno)
flood_fill_rm(i,sy+1,rmno,lit,anyroom);
} else {
if((i>sx || isok(i-1,sy+1)) &&
levl[i-1][sy+1].typ == fg_typ) {
if ((int) levl[i-1][sy+1].roomno != rmno)
flood_fill_rm(i-1,sy+1,rmno,lit,anyroom);
}
if((i<nx-1 || isok(i+1,sy+1)) &&
levl[i+1][sy+1].typ == fg_typ) {
if ((int) levl[i+1][sy+1].roomno != rmno)
flood_fill_rm(i+1,sy+1,rmno,lit,anyroom);
}
}
if (isok(sx, sy + 1)) {
for (i = sx; i < nx; i++)
if (levl[i][sy + 1].typ == fg_typ) {
if ((int) levl[i][sy + 1].roomno != rmno)
flood_fill_rm(i, sy + 1, rmno, lit, anyroom);
} else {
if ((i > sx || isok(i - 1, sy + 1))
&& levl[i - 1][sy + 1].typ == fg_typ) {
if ((int) levl[i - 1][sy + 1].roomno != rmno)
flood_fill_rm(i - 1, sy + 1, rmno, lit, anyroom);
}
if ((i < nx - 1 || isok(i + 1, sy + 1))
&& levl[i + 1][sy + 1].typ == fg_typ) {
if ((int) levl[i + 1][sy + 1].roomno != rmno)
flood_fill_rm(i + 1, sy + 1, rmno, lit, anyroom);
}
}
}
if(nx > max_rx) max_rx = nx - 1; /* nx is just past valid region */
if(sy > max_ry) max_ry = sy;
if (nx > max_rx)
max_rx = nx - 1; /* nx is just past valid region */
if (sy > max_ry)
max_ry = sy;
}
/*
@@ -252,24 +255,25 @@ flood_fill_rm(sx, sy, rmno, lit, anyroom)
STATIC_OVL void
wallify_map()
{
int x, y, xx, yy;
for(x = 1; x < COLNO; x++)
for(y = 0; y < ROWNO; y++)
if(levl[x][y].typ == STONE) {
for(yy = y - 1; yy <= y+1; yy++)
for(xx = x - 1; xx <= x+1; xx++)
if(isok(xx,yy) && levl[xx][yy].typ == ROOM) {
if(yy != y) levl[x][y].typ = HWALL;
else levl[x][y].typ = VWALL;
}
}
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++)
if (levl[x][y].typ == STONE) {
for (yy = y - 1; yy <= y + 1; yy++)
for (xx = x - 1; xx <= x + 1; xx++)
if (isok(xx, yy) && levl[xx][yy].typ == ROOM) {
if (yy != y)
levl[x][y].typ = HWALL;
else
levl[x][y].typ = VWALL;
}
}
}
STATIC_OVL void
join_map(bg_typ, fg_typ)
schar bg_typ, fg_typ;
schar bg_typ, fg_typ;
{
register struct mkroom *croom, *croom2;
@@ -277,35 +281,36 @@ join_map(bg_typ, fg_typ)
int sx, sy;
coord sm, em;
/* first, use flood filling to find all of the regions that need joining */
for(i=2; i<=WIDTH; i++)
for(j=1; j<HEIGHT; j++) {
if(levl[i][j].typ == fg_typ && levl[i][j].roomno == NO_ROOM) {
min_rx = max_rx = i;
min_ry = max_ry = j;
n_loc_filled = 0;
flood_fill_rm(i,j,nroom+ROOMOFFSET,FALSE,FALSE);
if(n_loc_filled > 3) {
add_room(min_rx, min_ry, max_rx, max_ry,
FALSE, OROOM, TRUE);
rooms[nroom-1].irregular = TRUE;
if(nroom >= (MAXNROFROOMS*2))
goto joinm;
} else {
/*
* it's a tiny hole; erase it from the map to avoid
* having the player end up here with no way out.
*/
for(sx = min_rx; sx<=max_rx; sx++)
for(sy = min_ry; sy<=max_ry; sy++)
if ((int) levl[sx][sy].roomno ==
nroom + ROOMOFFSET) {
levl[sx][sy].typ = bg_typ;
levl[sx][sy].roomno = NO_ROOM;
}
}
}
}
/* first, use flood filling to find all of the regions that need joining
*/
for (i = 2; i <= WIDTH; i++)
for (j = 1; j < HEIGHT; j++) {
if (levl[i][j].typ == fg_typ && levl[i][j].roomno == NO_ROOM) {
min_rx = max_rx = i;
min_ry = max_ry = j;
n_loc_filled = 0;
flood_fill_rm(i, j, nroom + ROOMOFFSET, FALSE, FALSE);
if (n_loc_filled > 3) {
add_room(min_rx, min_ry, max_rx, max_ry, FALSE, OROOM,
TRUE);
rooms[nroom - 1].irregular = TRUE;
if (nroom >= (MAXNROFROOMS * 2))
goto joinm;
} else {
/*
* it's a tiny hole; erase it from the map to avoid
* having the player end up here with no way out.
*/
for (sx = min_rx; sx <= max_rx; sx++)
for (sy = min_ry; sy <= max_ry; sy++)
if ((int) levl[sx][sy].roomno
== nroom + ROOMOFFSET) {
levl[sx][sy].typ = bg_typ;
levl[sx][sy].roomno = NO_ROOM;
}
}
}
}
joinm:
/*
@@ -314,59 +319,61 @@ joinm:
* so don't call sort_rooms(), which can screw up the roomno's
* validity in the levl structure.
*/
for(croom = &rooms[0], croom2 = croom + 1; croom2 < &rooms[nroom]; ) {
/* pick random starting and end locations for "corridor" */
if(!somexy(croom, &sm) || !somexy(croom2, &em)) {
/* ack! -- the level is going to be busted */
/* arbitrarily pick centers of both rooms and hope for the best */
impossible("No start/end room loc in join_map.");
sm.x = croom->lx + ((croom->hx - croom->lx) / 2);
sm.y = croom->ly + ((croom->hy - croom->ly) / 2);
em.x = croom2->lx + ((croom2->hx - croom2->lx) / 2);
em.y = croom2->ly + ((croom2->hy - croom2->ly) / 2);
}
for (croom = &rooms[0], croom2 = croom + 1; croom2 < &rooms[nroom];) {
/* pick random starting and end locations for "corridor" */
if (!somexy(croom, &sm) || !somexy(croom2, &em)) {
/* ack! -- the level is going to be busted */
/* arbitrarily pick centers of both rooms and hope for the best */
impossible("No start/end room loc in join_map.");
sm.x = croom->lx + ((croom->hx - croom->lx) / 2);
sm.y = croom->ly + ((croom->hy - croom->ly) / 2);
em.x = croom2->lx + ((croom2->hx - croom2->lx) / 2);
em.y = croom2->ly + ((croom2->hy - croom2->ly) / 2);
}
(void) dig_corridor(&sm, &em, FALSE, fg_typ, bg_typ);
(void) dig_corridor(&sm, &em, FALSE, fg_typ, bg_typ);
/* choose next region to join */
/* only increment croom if croom and croom2 are non-overlapping */
if(croom2->lx > croom->hx ||
((croom2->ly > croom->hy || croom2->hy < croom->ly) && rn2(3))) {
croom = croom2;
}
croom2++; /* always increment the next room */
/* choose next region to join */
/* only increment croom if croom and croom2 are non-overlapping */
if (croom2->lx > croom->hx
|| ((croom2->ly > croom->hy || croom2->hy < croom->ly)
&& rn2(3))) {
croom = croom2;
}
croom2++; /* always increment the next room */
}
}
STATIC_OVL void
finish_map(fg_typ, bg_typ, lit, walled, icedpools)
schar fg_typ, bg_typ;
boolean lit, walled, icedpools;
schar fg_typ, bg_typ;
boolean lit, walled, icedpools;
{
int i, j;
int i, j;
if(walled) wallify_map();
if (walled)
wallify_map();
if(lit) {
for(i=1; i<COLNO; i++)
for(j=0; j<ROWNO; j++)
if((!IS_ROCK(fg_typ) && levl[i][j].typ == fg_typ) ||
(!IS_ROCK(bg_typ) && levl[i][j].typ == bg_typ) ||
(bg_typ == TREE && levl[i][j].typ == bg_typ) ||
(walled && IS_WALL(levl[i][j].typ)))
levl[i][j].lit = TRUE;
for(i = 0; i < nroom; i++)
rooms[i].rlit = 1;
}
/* light lava even if everything's otherwise unlit;
ice might be frozen pool rather than frozen moat */
for(i=1; i<COLNO; i++)
for(j=0; j<ROWNO; j++) {
if (levl[i][j].typ == LAVAPOOL)
levl[i][j].lit = TRUE;
else if (levl[i][j].typ == ICE)
levl[i][j].icedpool = icedpools ? ICED_POOL : ICED_MOAT;
}
if (lit) {
for (i = 1; i < COLNO; i++)
for (j = 0; j < ROWNO; j++)
if ((!IS_ROCK(fg_typ) && levl[i][j].typ == fg_typ)
|| (!IS_ROCK(bg_typ) && levl[i][j].typ == bg_typ)
|| (bg_typ == TREE && levl[i][j].typ == bg_typ)
|| (walled && IS_WALL(levl[i][j].typ)))
levl[i][j].lit = TRUE;
for (i = 0; i < nroom; i++)
rooms[i].rlit = 1;
}
/* light lava even if everything's otherwise unlit;
ice might be frozen pool rather than frozen moat */
for (i = 1; i < COLNO; i++)
for (j = 0; j < ROWNO; j++) {
if (levl[i][j].typ == LAVAPOOL)
levl[i][j].lit = TRUE;
else if (levl[i][j].typ == ICE)
levl[i][j].icedpool = icedpools ? ICED_POOL : ICED_MOAT;
}
}
/*
@@ -380,25 +387,27 @@ finish_map(fg_typ, bg_typ, lit, walled, icedpools)
*/
void
remove_rooms(lx, ly, hx, hy)
int lx, ly, hx, hy;
int lx, ly, hx, hy;
{
int i;
struct mkroom *croom;
for (i = nroom - 1; i >= 0; --i) {
croom = &rooms[i];
if (croom->hx < lx || croom->lx >= hx ||
croom->hy < ly || croom->ly >= hy) continue; /* no overlap */
croom = &rooms[i];
if (croom->hx < lx || croom->lx >= hx || croom->hy < ly
|| croom->ly >= hy)
continue; /* no overlap */
if (croom->lx < lx || croom->hx >= hx ||
croom->ly < ly || croom->hy >= hy) { /* partial overlap */
/* TODO: ensure remaining parts of room are still joined */
if (croom->lx < lx || croom->hx >= hx || croom->ly < ly
|| croom->hy >= hy) { /* partial overlap */
/* TODO: ensure remaining parts of room are still joined */
if (!croom->irregular) impossible("regular room in joined map");
} else {
/* total overlap, remove the room */
remove_room((unsigned)i);
}
if (!croom->irregular)
impossible("regular room in joined map");
} else {
/* total overlap, remove the room */
remove_room((unsigned) i);
}
}
}
@@ -410,7 +419,7 @@ remove_rooms(lx, ly, hx, hy)
*/
STATIC_OVL void
remove_room(roomno)
unsigned roomno;
unsigned roomno;
{
struct mkroom *croom = &rooms[roomno];
struct mkroom *maxroom = &rooms[--nroom];
@@ -418,70 +427,67 @@ remove_room(roomno)
unsigned oroomno;
if (croom != maxroom) {
/* since the order in the array only matters for making corridors,
* copy the last room over the one being removed on the assumption
* that corridors have already been dug. */
(void) memcpy((genericptr_t)croom, (genericptr_t)maxroom,
sizeof(struct mkroom));
/* since the order in the array only matters for making corridors,
* copy the last room over the one being removed on the assumption
* that corridors have already been dug. */
(void) memcpy((genericptr_t) croom, (genericptr_t) maxroom,
sizeof(struct mkroom));
/* since maxroom moved, update affected level roomno values */
oroomno = nroom + ROOMOFFSET;
roomno += ROOMOFFSET;
for (i = croom->lx; i <= croom->hx; ++i)
for (j = croom->ly; j <= croom->hy; ++j) {
if (levl[i][j].roomno == oroomno)
levl[i][j].roomno = roomno;
}
/* since maxroom moved, update affected level roomno values */
oroomno = nroom + ROOMOFFSET;
roomno += ROOMOFFSET;
for (i = croom->lx; i <= croom->hx; ++i)
for (j = croom->ly; j <= croom->hy; ++j) {
if (levl[i][j].roomno == oroomno)
levl[i][j].roomno = roomno;
}
}
maxroom->hx = -1; /* just like add_room */
maxroom->hx = -1; /* just like add_room */
}
#define N_P1_ITER 1 /* tune map generation via this value */
#define N_P2_ITER 1 /* tune map generation via this value */
#define N_P3_ITER 2 /* tune map smoothing via this value */
#define N_P1_ITER 1 /* tune map generation via this value */
#define N_P2_ITER 1 /* tune map generation via this value */
#define N_P3_ITER 2 /* tune map smoothing via this value */
void
mkmap(init_lev)
lev_init *init_lev;
lev_init *init_lev;
{
schar bg_typ = init_lev->bg,
fg_typ = init_lev->fg;
boolean smooth = init_lev->smoothed,
join = init_lev->joined;
xchar lit = init_lev->lit,
walled = init_lev->walled;
int i;
schar bg_typ = init_lev->bg, fg_typ = init_lev->fg;
boolean smooth = init_lev->smoothed, join = init_lev->joined;
xchar lit = init_lev->lit, walled = init_lev->walled;
int i;
if(lit < 0)
lit = (rnd(1+abs(depth(&u.uz))) < 11 && rn2(77)) ? 1 : 0;
if (lit < 0)
lit = (rnd(1 + abs(depth(&u.uz))) < 11 && rn2(77)) ? 1 : 0;
new_locations = (char *)alloc((WIDTH+1) * HEIGHT);
new_locations = (char *) alloc((WIDTH + 1) * HEIGHT);
init_map(bg_typ);
init_fill(bg_typ, fg_typ);
init_map(bg_typ);
init_fill(bg_typ, fg_typ);
for(i = 0; i < N_P1_ITER; i++)
pass_one(bg_typ, fg_typ);
for (i = 0; i < N_P1_ITER; i++)
pass_one(bg_typ, fg_typ);
for(i = 0; i < N_P2_ITER; i++)
pass_two(bg_typ, fg_typ);
for (i = 0; i < N_P2_ITER; i++)
pass_two(bg_typ, fg_typ);
if(smooth)
for(i = 0; i < N_P3_ITER; i++)
pass_three(bg_typ, fg_typ);
if (smooth)
for (i = 0; i < N_P3_ITER; i++)
pass_three(bg_typ, fg_typ);
if(join)
join_map(bg_typ, fg_typ);
if (join)
join_map(bg_typ, fg_typ);
finish_map(fg_typ, bg_typ, (boolean)lit, (boolean)walled,
init_lev->icedpools);
/* a walled, joined level is cavernous, not mazelike -dlc */
if (walled && join) {
level.flags.is_maze_lev = FALSE;
level.flags.is_cavernous_lev = TRUE;
}
free(new_locations);
finish_map(fg_typ, bg_typ, (boolean) lit, (boolean) walled,
init_lev->icedpools);
/* a walled, joined level is cavernous, not mazelike -dlc */
if (walled && join) {
level.flags.is_maze_lev = FALSE;
level.flags.is_cavernous_lev = TRUE;
}
free(new_locations);
}
/*mkmap.c*/
+1068 -1003
View File
File diff suppressed because it is too large Load Diff
+1165 -1033
View File
File diff suppressed because it is too large Load Diff
+699 -581
View File
File diff suppressed because it is too large Load Diff
+1604 -1399
View File
File diff suppressed because it is too large Load Diff
+703 -613
View File
File diff suppressed because it is too large Load Diff
+1273 -1185
View File
File diff suppressed because it is too large Load Diff
+3024 -3268
View File
File diff suppressed because it is too large Load Diff
+291 -250
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mplayer.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 mplayer.c $NHDT-Date: 1431192769 2015/05/09 17:32:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.6 mplayer.c $Date: 2009/05/06 10:47:09 $ $Revision: 1.11 $ */
/* SCCS Id: @(#)mplayer.c 3.5 2006/12/15 */
/* Copyright (c) Izchak Miller, 1992. */
@@ -17,53 +17,55 @@ STATIC_DCL void FDECL(mk_mplayer_armor, (struct monst *, SHORT_P));
* Same first name is entered once within each team.
*/
static const char *developers[] = {
/* devteam */
"Dave", "Dean", "Eric", "Izchak", "Janet", "Jessie",
"Ken", "Kevin", "Michael", "Mike", "Pat", "Paul", "Steve", "Timo",
"Warwick",
/* PC team */
"Bill", "Eric", "Keizo", "Ken", "Kevin", "Michael", "Mike", "Paul",
"Stephen", "Steve", "Timo", "Yitzhak",
/* Amiga team */
"Andy", "Gregg", "Janne", "Keni", "Mike", "Olaf", "Richard",
/* Mac team */
"Andy", "Chris", "Dean", "Jon", "Jonathan", "Kevin", "Wang",
/* Atari team */
"Eric", "Marvin", "Warwick",
/* NT team */
"Alex", "Dion", "Michael",
/* OS/2 team */
"Helge", "Ron", "Timo",
/* VMS team */
"Joshua", "Pat",
""};
/* devteam */
"Dave", "Dean", "Eric", "Izchak", "Janet", "Jessie",
"Ken", "Kevin", "Michael", "Mike", "Pat", "Paul",
"Steve", "Timo", "Warwick",
/* PC team */
"Bill", "Eric", "Keizo", "Ken", "Kevin", "Michael",
"Mike", "Paul", "Stephen", "Steve", "Timo", "Yitzhak",
/* Amiga team */
"Andy", "Gregg", "Janne", "Keni", "Mike", "Olaf",
"Richard",
/* Mac team */
"Andy", "Chris", "Dean", "Jon", "Jonathan", "Kevin",
"Wang",
/* Atari team */
"Eric", "Marvin", "Warwick",
/* NT team */
"Alex", "Dion", "Michael",
/* OS/2 team */
"Helge", "Ron", "Timo",
/* VMS team */
"Joshua", "Pat", ""
};
/* return a randomly chosen developer name */
STATIC_OVL const char *
dev_name()
{
register int i, m = 0, n = SIZE(developers);
register struct monst *mtmp;
register boolean match;
register int i, m = 0, n = SIZE(developers);
register struct monst *mtmp;
register boolean match;
do {
match = FALSE;
i = rn2(n);
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if(!is_mplayer(mtmp->data)) continue;
if(!strncmp(developers[i],
(has_mname(mtmp)) ? MNAME(mtmp) : "",
strlen(developers[i]))) {
match = TRUE;
break;
}
}
m++;
} while (match && m < 100); /* m for insurance */
do {
match = FALSE;
i = rn2(n);
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (!is_mplayer(mtmp->data))
continue;
if (!strncmp(developers[i], (has_mname(mtmp)) ? MNAME(mtmp) : "",
strlen(developers[i]))) {
match = TRUE;
break;
}
}
m++;
} while (match && m < 100); /* m for insurance */
if (match) return (const char *)0;
return(developers[i]);
if (match)
return (const char *) 0;
return (developers[i]);
}
STATIC_OVL void
@@ -71,24 +73,24 @@ get_mplname(mtmp, nam)
register struct monst *mtmp;
char *nam;
{
boolean fmlkind = is_female(mtmp->data);
const char *devnam;
boolean fmlkind = is_female(mtmp->data);
const char *devnam;
devnam = dev_name();
if (!devnam)
Strcpy(nam, fmlkind ? "Eve" : "Adam");
else if (fmlkind && !!strcmp(devnam, "Janet"))
Strcpy(nam, rn2(2) ? "Maud" : "Eve");
else Strcpy(nam, devnam);
devnam = dev_name();
if (!devnam)
Strcpy(nam, fmlkind ? "Eve" : "Adam");
else if (fmlkind && !!strcmp(devnam, "Janet"))
Strcpy(nam, rn2(2) ? "Maud" : "Eve");
else
Strcpy(nam, devnam);
if (fmlkind || !strcmp(nam, "Janet"))
mtmp->female = 1;
else
mtmp->female = 0;
Strcat(nam, " the ");
Strcat(nam, rank_of((int)mtmp->m_lev,
monsndx(mtmp->data),
(boolean)mtmp->female));
if (fmlkind || !strcmp(nam, "Janet"))
mtmp->female = 1;
else
mtmp->female = 0;
Strcat(nam, " the ");
Strcat(nam, rank_of((int) mtmp->m_lev, monsndx(mtmp->data),
(boolean) mtmp->female));
}
STATIC_OVL void
@@ -96,19 +98,23 @@ mk_mplayer_armor(mon, typ)
struct monst *mon;
short typ;
{
struct obj *obj;
struct obj *obj;
if (typ == STRANGE_OBJECT) return;
obj = mksobj(typ, FALSE, FALSE);
if (!rn2(3)) obj->oerodeproof = 1;
if (!rn2(3)) curse(obj);
if (!rn2(3)) bless(obj);
/* Most players who get to the endgame who have cursed equipment
* have it because the wizard or other monsters cursed it, so its
* chances of having plusses is the same as usual....
*/
obj->spe = rn2(10) ? (rn2(3) ? rn2(5) : rn1(4,4)) : -rnd(3);
(void) mpickobj(mon, obj);
if (typ == STRANGE_OBJECT)
return;
obj = mksobj(typ, FALSE, FALSE);
if (!rn2(3))
obj->oerodeproof = 1;
if (!rn2(3))
curse(obj);
if (!rn2(3))
bless(obj);
/* Most players who get to the endgame who have cursed equipment
* have it because the wizard or other monsters cursed it, so its
* chances of having plusses is the same as usual....
*/
obj->spe = rn2(10) ? (rn2(3) ? rn2(5) : rn1(4, 4)) : -rnd(3);
(void) mpickobj(mon, obj);
}
struct monst *
@@ -117,166 +123,199 @@ register struct permonst *ptr;
xchar x, y;
register boolean special;
{
register struct monst *mtmp;
char nam[PL_NSIZ];
register struct monst *mtmp;
char nam[PL_NSIZ];
if(!is_mplayer(ptr))
return((struct monst *)0);
if (!is_mplayer(ptr))
return ((struct monst *) 0);
if(MON_AT(x, y))
(void) rloc(m_at(x, y), FALSE); /* insurance */
if (MON_AT(x, y))
(void) rloc(m_at(x, y), FALSE); /* insurance */
if(!In_endgame(&u.uz)) special = FALSE;
if (!In_endgame(&u.uz))
special = FALSE;
if ((mtmp = makemon(ptr, x, y, NO_MM_FLAGS)) != 0) {
short weapon = rn2(2) ? LONG_SWORD : rnd_class(SPEAR, BULLWHIP);
short armor = rnd_class(GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL);
short cloak = !rn2(8) ? STRANGE_OBJECT :
rnd_class(OILSKIN_CLOAK, CLOAK_OF_DISPLACEMENT);
short helm = !rn2(8) ? STRANGE_OBJECT :
rnd_class(ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY);
short shield = !rn2(8) ? STRANGE_OBJECT :
rnd_class(ELVEN_SHIELD, SHIELD_OF_REFLECTION);
int quan;
struct obj *otmp;
if ((mtmp = makemon(ptr, x, y, NO_MM_FLAGS)) != 0) {
short weapon = rn2(2) ? LONG_SWORD : rnd_class(SPEAR, BULLWHIP);
short armor =
rnd_class(GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL);
short cloak = !rn2(8)
? STRANGE_OBJECT
: rnd_class(OILSKIN_CLOAK, CLOAK_OF_DISPLACEMENT);
short helm = !rn2(8) ? STRANGE_OBJECT : rnd_class(ELVEN_LEATHER_HELM,
HELM_OF_TELEPATHY);
short shield = !rn2(8)
? STRANGE_OBJECT
: rnd_class(ELVEN_SHIELD, SHIELD_OF_REFLECTION);
int quan;
struct obj *otmp;
mtmp->m_lev = (special ? rn1(16,15) : rnd(16));
mtmp->mhp = mtmp->mhpmax = d((int)mtmp->m_lev,10) +
(special ? (30 + rnd(30)) : 30);
if(special) {
get_mplname(mtmp, nam);
mtmp = christen_monst(mtmp, nam);
/* that's why they are "stuck" in the endgame :-) */
(void)mongets(mtmp, FAKE_AMULET_OF_YENDOR);
}
mtmp->mpeaceful = 0;
set_malign(mtmp); /* peaceful may have changed again */
mtmp->m_lev = (special ? rn1(16, 15) : rnd(16));
mtmp->mhp = mtmp->mhpmax =
d((int) mtmp->m_lev, 10) + (special ? (30 + rnd(30)) : 30);
if (special) {
get_mplname(mtmp, nam);
mtmp = christen_monst(mtmp, nam);
/* that's why they are "stuck" in the endgame :-) */
(void) mongets(mtmp, FAKE_AMULET_OF_YENDOR);
}
mtmp->mpeaceful = 0;
set_malign(mtmp); /* peaceful may have changed again */
switch(monsndx(ptr)) {
case PM_ARCHEOLOGIST:
if (rn2(2)) weapon = BULLWHIP;
break;
case PM_BARBARIAN:
if (rn2(2)) {
weapon = rn2(2) ? TWO_HANDED_SWORD : BATTLE_AXE;
shield = STRANGE_OBJECT;
}
if (rn2(2)) armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
if (helm == HELM_OF_BRILLIANCE) helm = STRANGE_OBJECT;
break;
case PM_CAVEMAN:
case PM_CAVEWOMAN:
if (rn2(4)) weapon = MACE;
else if (rn2(2)) weapon = CLUB;
if (helm == HELM_OF_BRILLIANCE) helm = STRANGE_OBJECT;
break;
case PM_HEALER:
if (rn2(4)) weapon = QUARTERSTAFF;
else if (rn2(2)) weapon = rn2(2) ? UNICORN_HORN : SCALPEL;
if (rn2(4)) helm = rn2(2) ? HELM_OF_BRILLIANCE : HELM_OF_TELEPATHY;
if (rn2(2)) shield = STRANGE_OBJECT;
break;
case PM_KNIGHT:
if (rn2(4)) weapon = LONG_SWORD;
if (rn2(2)) armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
break;
case PM_MONK:
weapon = !rn2(3) ? SHURIKEN : STRANGE_OBJECT;
armor = STRANGE_OBJECT;
cloak = ROBE;
if (rn2(2)) shield = STRANGE_OBJECT;
break;
case PM_PRIEST:
case PM_PRIESTESS:
if (rn2(2)) weapon = MACE;
if (rn2(2)) armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
if (rn2(4)) cloak = ROBE;
if (rn2(4)) helm = rn2(2) ? HELM_OF_BRILLIANCE : HELM_OF_TELEPATHY;
if (rn2(2)) shield = STRANGE_OBJECT;
break;
case PM_RANGER:
if (rn2(2)) weapon = ELVEN_DAGGER;
break;
case PM_ROGUE:
if (rn2(2)) weapon = rn2(2) ? SHORT_SWORD : ORCISH_DAGGER;
break;
case PM_SAMURAI:
if (rn2(2)) weapon = KATANA;
break;
case PM_TOURIST:
/* Defaults are just fine */
break;
case PM_VALKYRIE:
if (rn2(2)) weapon = WAR_HAMMER;
if (rn2(2)) armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
break;
case PM_WIZARD:
if (rn2(4)) weapon = rn2(2) ? QUARTERSTAFF : ATHAME;
if (rn2(2)) {
armor = rn2(2) ? BLACK_DRAGON_SCALE_MAIL :
SILVER_DRAGON_SCALE_MAIL;
cloak = CLOAK_OF_MAGIC_RESISTANCE;
}
if (rn2(4)) helm = HELM_OF_BRILLIANCE;
shield = STRANGE_OBJECT;
break;
default: impossible("bad mplayer monster");
weapon = 0;
break;
}
switch (monsndx(ptr)) {
case PM_ARCHEOLOGIST:
if (rn2(2))
weapon = BULLWHIP;
break;
case PM_BARBARIAN:
if (rn2(2)) {
weapon = rn2(2) ? TWO_HANDED_SWORD : BATTLE_AXE;
shield = STRANGE_OBJECT;
}
if (rn2(2))
armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
if (helm == HELM_OF_BRILLIANCE)
helm = STRANGE_OBJECT;
break;
case PM_CAVEMAN:
case PM_CAVEWOMAN:
if (rn2(4))
weapon = MACE;
else if (rn2(2))
weapon = CLUB;
if (helm == HELM_OF_BRILLIANCE)
helm = STRANGE_OBJECT;
break;
case PM_HEALER:
if (rn2(4))
weapon = QUARTERSTAFF;
else if (rn2(2))
weapon = rn2(2) ? UNICORN_HORN : SCALPEL;
if (rn2(4))
helm = rn2(2) ? HELM_OF_BRILLIANCE : HELM_OF_TELEPATHY;
if (rn2(2))
shield = STRANGE_OBJECT;
break;
case PM_KNIGHT:
if (rn2(4))
weapon = LONG_SWORD;
if (rn2(2))
armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
break;
case PM_MONK:
weapon = !rn2(3) ? SHURIKEN : STRANGE_OBJECT;
armor = STRANGE_OBJECT;
cloak = ROBE;
if (rn2(2))
shield = STRANGE_OBJECT;
break;
case PM_PRIEST:
case PM_PRIESTESS:
if (rn2(2))
weapon = MACE;
if (rn2(2))
armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
if (rn2(4))
cloak = ROBE;
if (rn2(4))
helm = rn2(2) ? HELM_OF_BRILLIANCE : HELM_OF_TELEPATHY;
if (rn2(2))
shield = STRANGE_OBJECT;
break;
case PM_RANGER:
if (rn2(2))
weapon = ELVEN_DAGGER;
break;
case PM_ROGUE:
if (rn2(2))
weapon = rn2(2) ? SHORT_SWORD : ORCISH_DAGGER;
break;
case PM_SAMURAI:
if (rn2(2))
weapon = KATANA;
break;
case PM_TOURIST:
/* Defaults are just fine */
break;
case PM_VALKYRIE:
if (rn2(2))
weapon = WAR_HAMMER;
if (rn2(2))
armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
break;
case PM_WIZARD:
if (rn2(4))
weapon = rn2(2) ? QUARTERSTAFF : ATHAME;
if (rn2(2)) {
armor = rn2(2) ? BLACK_DRAGON_SCALE_MAIL
: SILVER_DRAGON_SCALE_MAIL;
cloak = CLOAK_OF_MAGIC_RESISTANCE;
}
if (rn2(4))
helm = HELM_OF_BRILLIANCE;
shield = STRANGE_OBJECT;
break;
default:
impossible("bad mplayer monster");
weapon = 0;
break;
}
if (weapon != STRANGE_OBJECT) {
otmp = mksobj(weapon, TRUE, FALSE);
otmp->spe = (special ? rn1(5,4) : rn2(4));
if (!rn2(3)) otmp->oerodeproof = 1;
else if (!rn2(2)) otmp->greased = 1;
if (special && rn2(2))
otmp = mk_artifact(otmp, A_NONE);
/* usually increase stack size if stackable weapon */
if (objects[otmp->otyp].oc_merge && !otmp->oartifact)
otmp->quan += (long) rn2(is_spear(otmp) ? 4 : 8);
/* mplayers knew better than to overenchant Magicbane */
if (otmp->oartifact == ART_MAGICBANE)
otmp->spe = rnd(4);
(void) mpickobj(mtmp, otmp);
}
if (weapon != STRANGE_OBJECT) {
otmp = mksobj(weapon, TRUE, FALSE);
otmp->spe = (special ? rn1(5, 4) : rn2(4));
if (!rn2(3))
otmp->oerodeproof = 1;
else if (!rn2(2))
otmp->greased = 1;
if (special && rn2(2))
otmp = mk_artifact(otmp, A_NONE);
/* usually increase stack size if stackable weapon */
if (objects[otmp->otyp].oc_merge && !otmp->oartifact)
otmp->quan += (long) rn2(is_spear(otmp) ? 4 : 8);
/* mplayers knew better than to overenchant Magicbane */
if (otmp->oartifact == ART_MAGICBANE)
otmp->spe = rnd(4);
(void) mpickobj(mtmp, otmp);
}
if(special) {
if (!rn2(10))
(void) mongets(mtmp, rn2(3) ? LUCKSTONE : LOADSTONE);
mk_mplayer_armor(mtmp, armor);
mk_mplayer_armor(mtmp, cloak);
mk_mplayer_armor(mtmp, helm);
mk_mplayer_armor(mtmp, shield);
if (rn2(8))
mk_mplayer_armor(mtmp, rnd_class(LEATHER_GLOVES,
GAUNTLETS_OF_DEXTERITY));
if (rn2(8))
mk_mplayer_armor(mtmp, rnd_class(LOW_BOOTS, LEVITATION_BOOTS));
m_dowear(mtmp, TRUE);
if (special) {
if (!rn2(10))
(void) mongets(mtmp, rn2(3) ? LUCKSTONE : LOADSTONE);
mk_mplayer_armor(mtmp, armor);
mk_mplayer_armor(mtmp, cloak);
mk_mplayer_armor(mtmp, helm);
mk_mplayer_armor(mtmp, shield);
if (rn2(8))
mk_mplayer_armor(
mtmp, rnd_class(LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY));
if (rn2(8))
mk_mplayer_armor(mtmp,
rnd_class(LOW_BOOTS, LEVITATION_BOOTS));
m_dowear(mtmp, TRUE);
quan = rn2(3) ? rn2(3) : rn2(16);
while(quan--)
(void)mongets(mtmp, rnd_class(DILITHIUM_CRYSTAL, JADE));
/* To get the gold "right" would mean a player can double his */
/* gold supply by killing one mplayer. Not good. */
mkmonmoney(mtmp, rn2(1000));
quan = rn2(10);
while(quan--)
(void) mpickobj(mtmp, mkobj(RANDOM_CLASS, FALSE));
}
quan = rnd(3);
while(quan--)
(void)mongets(mtmp, rnd_offensive_item(mtmp));
quan = rnd(3);
while(quan--)
(void)mongets(mtmp, rnd_defensive_item(mtmp));
quan = rnd(3);
while(quan--)
(void)mongets(mtmp, rnd_misc_item(mtmp));
}
quan = rn2(3) ? rn2(3) : rn2(16);
while (quan--)
(void) mongets(mtmp, rnd_class(DILITHIUM_CRYSTAL, JADE));
/* To get the gold "right" would mean a player can double his */
/* gold supply by killing one mplayer. Not good. */
mkmonmoney(mtmp, rn2(1000));
quan = rn2(10);
while (quan--)
(void) mpickobj(mtmp, mkobj(RANDOM_CLASS, FALSE));
}
quan = rnd(3);
while (quan--)
(void) mongets(mtmp, rnd_offensive_item(mtmp));
quan = rnd(3);
while (quan--)
(void) mongets(mtmp, rnd_defensive_item(mtmp));
quan = rnd(3);
while (quan--)
(void) mongets(mtmp, rnd_misc_item(mtmp));
}
return(mtmp);
return (mtmp);
}
/* create the indicated number (num) of monster-players,
@@ -291,50 +330,52 @@ create_mplayers(num, special)
register int num;
boolean special;
{
int pm, x, y;
struct monst fakemon;
int pm, x, y;
struct monst fakemon;
while(num) {
int tryct = 0;
while (num) {
int tryct = 0;
/* roll for character class */
pm = PM_ARCHEOLOGIST + rn2(PM_WIZARD - PM_ARCHEOLOGIST + 1);
fakemon.data = &mons[pm];
/* roll for character class */
pm = PM_ARCHEOLOGIST + rn2(PM_WIZARD - PM_ARCHEOLOGIST + 1);
fakemon.data = &mons[pm];
/* roll for an available location */
do {
x = rn1(COLNO-4, 2);
y = rnd(ROWNO-2);
} while(!goodpos(x, y, &fakemon, 0) && tryct++ <= 50);
/* roll for an available location */
do {
x = rn1(COLNO - 4, 2);
y = rnd(ROWNO - 2);
} while (!goodpos(x, y, &fakemon, 0) && tryct++ <= 50);
/* if pos not found in 50 tries, don't bother to continue */
if(tryct > 50) return;
/* if pos not found in 50 tries, don't bother to continue */
if (tryct > 50)
return;
(void) mk_mplayer(&mons[pm], (xchar)x, (xchar)y, special);
num--;
}
(void) mk_mplayer(&mons[pm], (xchar) x, (xchar) y, special);
num--;
}
}
void
mplayer_talk(mtmp)
register struct monst *mtmp;
{
static const char *same_class_msg[3] = {
"I can't win, and neither will you!",
"You don't deserve to win!",
"Mine should be the honor, not yours!",
}, *other_class_msg[3] = {
"The low-life wants to talk, eh?",
"Fight, scum!",
"Here is what I have to say!",
};
static const char *same_class_msg[3] =
{
"I can't win, and neither will you!", "You don't deserve to win!",
"Mine should be the honor, not yours!",
},
*other_class_msg[3] = {
"The low-life wants to talk, eh?", "Fight, scum!",
"Here is what I have to say!",
};
if(mtmp->mpeaceful) return; /* will drop to humanoid talk */
if (mtmp->mpeaceful)
return; /* will drop to humanoid talk */
pline("Talk? -- %s",
(mtmp->data == &mons[urole.malenum] ||
mtmp->data == &mons[urole.femalenum]) ?
same_class_msg[rn2(3)] : other_class_msg[rn2(3)]);
pline("Talk? -- %s", (mtmp->data == &mons[urole.malenum]
|| mtmp->data == &mons[urole.femalenum])
? same_class_msg[rn2(3)]
: other_class_msg[rn2(3)]);
}
/*mplayer.c*/
+734 -700
View File
File diff suppressed because it is too large Load Diff
+1916 -1788
View File
File diff suppressed because it is too large Load Diff
+612 -585
View File
File diff suppressed because it is too large Load Diff
+426 -410
View File
File diff suppressed because it is too large Load Diff
+967 -820
View File
File diff suppressed because it is too large Load Diff
+1386 -1277
View File
File diff suppressed because it is too large Load Diff
+4170 -3896
View File
File diff suppressed because it is too large Load Diff
+789 -722
View File
File diff suppressed because it is too large Load Diff
+2022 -1904
View File
File diff suppressed because it is too large Load Diff
+403 -360
View File
@@ -1,9 +1,10 @@
/* NetHack 3.6 pline.c $NHDT-Date: 1429666920 2015/04/22 01:42:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.37 $ */
/* NetHack 3.6 pline.c $NHDT-Date: 1431192765 2015/05/09 17:32:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.40 $ */
/* NetHack 3.6 pline.c $Date: 2013/02/09 01:33:37 $ $Revision: 1.30 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers \
*/
#include "hack.h"
static boolean no_repeat = FALSE;
@@ -18,84 +19,93 @@ static char *FDECL(You_buf, (int));
#if defined(USE_STDARG) || defined(USE_VARARGS)
static void FDECL(vpline, (const char *, va_list));
void
pline VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, char *);
vpline(line, VA_ARGS);
VA_END();
void pline
VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, char *);
vpline(line, VA_ARGS);
VA_END();
}
# ifdef USE_STDARG
#ifdef USE_STDARG
static void
vpline(const char *line, va_list the_args) {
# else
vpline(const char *line, va_list the_args)
{
#else
static void
vpline(line, the_args) const char *line; va_list the_args; {
# endif
vpline(line, the_args)
const char *line;
va_list the_args;
{
#endif
#else /* USE_STDARG | USE_VARARG */
#else /* USE_STDARG | USE_VARARG */
#define vpline pline
void
pline VA_DECL(const char *, line)
#endif /* USE_STDARG | USE_VARARG */
void pline
VA_DECL(const char *, line)
#endif /* USE_STDARG | USE_VARARG */
char pbuf[3*BUFSZ];
int ln;
/* Do NOT use VA_START and VA_END in here... see above */
char pbuf[3 * BUFSZ];
int ln;
/* Do NOT use VA_START and VA_END in here... see above */
if (!line || !*line) return;
if (!line || !*line)
return;
#ifdef HANGUPHANDLING
if (program_state.done_hup) return;
if (program_state.done_hup)
return;
#endif
if (program_state.wizkit_wishing) return;
if (program_state.wizkit_wishing)
return;
if (index(line, '%')) {
Vsprintf(pbuf,line,VA_ARGS);
line = pbuf;
}
if ((ln = (int)strlen(line)) > BUFSZ-1) {
if (line != pbuf) /* no '%' was present */
(void)strncpy(pbuf, line, BUFSZ-1); /* caveat: unterminated */
/* truncate, preserving the final 3 characters:
"___ extremely long text" -> "___ extremely l...ext"
(this may be suboptimal if overflow is less than 3) */
(void)strncpy(pbuf + BUFSZ-1 - 6, "...", 3);
/* avoid strncpy; buffers could overlap if excess is small */
pbuf[BUFSZ-1 - 3] = line[ln - 3];
pbuf[BUFSZ-1 - 2] = line[ln - 2];
pbuf[BUFSZ-1 - 1] = line[ln - 1];
pbuf[BUFSZ-1] = '\0';
line = pbuf;
}
if (!iflags.window_inited) {
raw_print(line);
iflags.last_msg = PLNMSG_UNKNOWN;
return;
}
if (index(line, '%')) {
Vsprintf(pbuf, line, VA_ARGS);
line = pbuf;
}
if ((ln = (int) strlen(line)) > BUFSZ - 1) {
if (line != pbuf) /* no '%' was present */
(void) strncpy(pbuf, line, BUFSZ - 1); /* caveat: unterminated */
/* truncate, preserving the final 3 characters:
"___ extremely long text" -> "___ extremely l...ext"
(this may be suboptimal if overflow is less than 3) */
(void) strncpy(pbuf + BUFSZ - 1 - 6, "...", 3);
/* avoid strncpy; buffers could overlap if excess is small */
pbuf[BUFSZ - 1 - 3] = line[ln - 3];
pbuf[BUFSZ - 1 - 2] = line[ln - 2];
pbuf[BUFSZ - 1 - 1] = line[ln - 1];
pbuf[BUFSZ - 1] = '\0';
line = pbuf;
}
if (!iflags.window_inited) {
raw_print(line);
iflags.last_msg = PLNMSG_UNKNOWN;
return;
}
#ifndef MAC
if (no_repeat && !strcmp(line, toplines))
return;
if (no_repeat && !strcmp(line, toplines))
return;
#endif /* MAC */
if (vision_full_recalc) vision_recalc(0);
if (u.ux) flush_screen(1); /* %% */
putstr(WIN_MESSAGE, 0, line);
/* this gets cleared after every pline message */
iflags.last_msg = PLNMSG_UNKNOWN;
if (vision_full_recalc)
vision_recalc(0);
if (u.ux)
flush_screen(1); /* %% */
putstr(WIN_MESSAGE, 0, line);
/* this gets cleared after every pline message */
iflags.last_msg = PLNMSG_UNKNOWN;
}
/*VARARGS1*/
void
Norep VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, const char *);
no_repeat = TRUE;
vpline(line, VA_ARGS);
no_repeat = FALSE;
VA_END();
return;
void Norep
VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, const char *);
no_repeat = TRUE;
vpline(line, VA_ARGS);
no_repeat = FALSE;
VA_END();
return;
}
/* work buffer for You(), &c and verbalize() */
@@ -106,126 +116,128 @@ static char *
You_buf(siz)
int siz;
{
if (siz > you_buf_siz) {
if (you_buf) free((genericptr_t) you_buf);
you_buf_siz = siz + 10;
you_buf = (char *) alloc((unsigned) you_buf_siz);
}
return you_buf;
if (siz > you_buf_siz) {
if (you_buf)
free((genericptr_t) you_buf);
you_buf_siz = siz + 10;
you_buf = (char *) alloc((unsigned) you_buf_siz);
}
return you_buf;
}
void
free_youbuf()
{
if (you_buf) free((genericptr_t) you_buf), you_buf = (char *)0;
you_buf_siz = 0;
if (you_buf)
free((genericptr_t) you_buf), you_buf = (char *) 0;
you_buf_siz = 0;
}
/* `prefix' must be a string literal, not a pointer */
#define YouPrefix(pointer,prefix,text) \
Strcpy((pointer = You_buf((int)(strlen(text) + sizeof prefix))), prefix)
#define YouPrefix(pointer, prefix, text) \
Strcpy((pointer = You_buf((int) (strlen(text) + sizeof prefix))), prefix)
#define YouMessage(pointer,prefix,text) \
strcat((YouPrefix(pointer, prefix, text), pointer), text)
#define YouMessage(pointer, prefix, text) \
strcat((YouPrefix(pointer, prefix, text), pointer), text)
/*VARARGS1*/
void
You VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "You ", line), VA_ARGS);
VA_END();
void You
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "You ", line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
Your VA_DECL(const char *,line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "Your ", line), VA_ARGS);
VA_END();
void Your
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "Your ", line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
You_feel VA_DECL(const char *,line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
if (Unaware)
YouPrefix(tmp, "You dream that you feel ", line);
else
YouPrefix(tmp, "You feel ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
You_cant VA_DECL(const char *,line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "You can't ", line), VA_ARGS);
VA_END();
void You_feel
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
if (Unaware)
YouPrefix(tmp, "You dream that you feel ", line);
else
YouPrefix(tmp, "You feel ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
pline_The VA_DECL(const char *,line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "The ", line), VA_ARGS);
VA_END();
void You_cant
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "You can't ", line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
There VA_DECL(const char *,line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "There ", line), VA_ARGS);
VA_END();
void pline_The
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "The ", line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
You_hear VA_DECL(const char *,line)
char *tmp;
if (Deaf || !flags.acoustics) return;
VA_START(line);
VA_INIT(line, const char *);
if (Underwater)
YouPrefix(tmp, "You barely hear ", line);
else if (Unaware)
YouPrefix(tmp, "You dream that you hear ", line);
else
YouPrefix(tmp, "You hear ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
void There
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
vpline(YouMessage(tmp, "There ", line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void
You_see VA_DECL(const char *,line)
char *tmp;
void You_hear
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
if (Unaware)
YouPrefix(tmp, "You dream that you see ", line);
else if (Blind) /* caller should have caught this... */
YouPrefix(tmp, "You sense ", line);
else
YouPrefix(tmp, "You see ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
if (Deaf || !flags.acoustics)
return;
VA_START(line);
VA_INIT(line, const char *);
if (Underwater)
YouPrefix(tmp, "You barely hear ", line);
else if (Unaware)
YouPrefix(tmp, "You dream that you hear ", line);
else
YouPrefix(tmp, "You hear ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
}
/*VARARGS1*/
void You_see
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
if (Unaware)
YouPrefix(tmp, "You dream that you see ", line);
else if (Blind) /* caller should have caught this... */
YouPrefix(tmp, "You sense ", line);
else
YouPrefix(tmp, "You see ", line);
vpline(strcat(tmp, line), VA_ARGS);
VA_END();
}
/* Print a message inside double-quotes.
@@ -233,18 +245,18 @@ You_see VA_DECL(const char *,line)
* Gods can speak directly to you in spite of deafness.
*/
/*VARARGS1*/
void
verbalize VA_DECL(const char *,line)
char *tmp;
void verbalize
VA_DECL(const char *, line)
char *tmp;
VA_START(line);
VA_INIT(line, const char *);
tmp = You_buf((int)strlen(line) + sizeof "\"\"");
Strcpy(tmp, "\"");
Strcat(tmp, line);
Strcat(tmp, "\"");
vpline(tmp, VA_ARGS);
VA_END();
VA_START(line);
VA_INIT(line, const char *);
tmp = You_buf((int) strlen(line) + sizeof "\"\"");
Strcpy(tmp, "\"");
Strcat(tmp, line);
Strcat(tmp, "\"");
vpline(tmp, VA_ARGS);
VA_END();
}
/*VARARGS1*/
@@ -253,75 +265,83 @@ verbalize VA_DECL(const char *,line)
*/
#if defined(USE_STDARG) || defined(USE_VARARGS)
static void FDECL(vraw_printf,(const char *,va_list));
static void FDECL(vraw_printf, (const char *, va_list));
void
raw_printf VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, char *);
vraw_printf(line, VA_ARGS);
VA_END();
void raw_printf
VA_DECL(const char *, line)
VA_START(line);
VA_INIT(line, char *);
vraw_printf(line, VA_ARGS);
VA_END();
}
# ifdef USE_STDARG
#ifdef USE_STDARG
static void
vraw_printf(const char *line, va_list the_args) {
# else
vraw_printf(const char *line, va_list the_args)
{
#else
static void
vraw_printf(line, the_args) const char *line; va_list the_args; {
# endif
#else /* USE_STDARG | USE_VARARG */
void
raw_printf VA_DECL(const char *, line)
vraw_printf(line, the_args)
const char *line;
va_list the_args;
{
#endif
char pbuf[3*BUFSZ];
int ln;
/* Do NOT use VA_START and VA_END in here... see above */
#else /* USE_STDARG | USE_VARARG */
if (index(line, '%')) {
Vsprintf(pbuf,line,VA_ARGS);
line = pbuf;
}
if ((ln = (int)strlen(line)) > BUFSZ-1) {
if (line != pbuf) line = strncpy(pbuf, line, BUFSZ-1);
/* unlike pline, we don't futz around to keep last few chars */
pbuf[BUFSZ-1] = '\0'; /* terminate strncpy or truncate vsprintf */
}
raw_print(line);
void raw_printf
VA_DECL(const char *, line)
#endif
char pbuf[3 * BUFSZ];
int ln;
/* Do NOT use VA_START and VA_END in here... see above */
if (index(line, '%')) {
Vsprintf(pbuf, line, VA_ARGS);
line = pbuf;
}
if ((ln = (int) strlen(line)) > BUFSZ - 1) {
if (line != pbuf)
line = strncpy(pbuf, line, BUFSZ - 1);
/* unlike pline, we don't futz around to keep last few chars */
pbuf[BUFSZ - 1] = '\0'; /* terminate strncpy or truncate vsprintf */
}
raw_print(line);
}
/*VARARGS1*/
void
impossible VA_DECL(const char *, s)
char pbuf[2*BUFSZ];
VA_START(s);
VA_INIT(s, const char *);
if (program_state.in_impossible)
panic("impossible called impossible");
void impossible
VA_DECL(const char *, s)
char pbuf[2 * BUFSZ];
VA_START(s);
VA_INIT(s, const char *);
if (program_state.in_impossible)
panic("impossible called impossible");
program_state.in_impossible = 1;
Vsprintf(pbuf, s, VA_ARGS);
pbuf[BUFSZ-1] = '\0'; /* sanity */
paniclog("impossible", pbuf);
pline("%s", pbuf);
pline("Program in disorder - perhaps you'd better #quit.");
program_state.in_impossible = 0;
VA_END();
program_state.in_impossible = 1;
Vsprintf(pbuf, s, VA_ARGS);
pbuf[BUFSZ - 1] = '\0'; /* sanity */
paniclog("impossible", pbuf);
pline("%s", pbuf);
pline("Program in disorder - perhaps you'd better #quit.");
program_state.in_impossible = 0;
VA_END();
}
const char *
align_str(alignment)
aligntyp alignment;
aligntyp alignment;
{
switch ((int)alignment) {
case A_CHAOTIC: return "chaotic";
case A_NEUTRAL: return "neutral";
case A_LAWFUL: return "lawful";
case A_NONE: return "unaligned";
switch ((int) alignment) {
case A_CHAOTIC:
return "chaotic";
case A_NEUTRAL:
return "neutral";
case A_LAWFUL:
return "lawful";
case A_NONE:
return "unaligned";
}
return "unknown";
}
@@ -330,171 +350,194 @@ void
mstatusline(mtmp)
register struct monst *mtmp;
{
aligntyp alignment = mon_aligntyp(mtmp);
char info[BUFSZ], monnambuf[BUFSZ];
aligntyp alignment = mon_aligntyp(mtmp);
char info[BUFSZ], monnambuf[BUFSZ];
info[0] = 0;
if (mtmp->mtame) { Strcat(info, ", tame");
if (wizard) {
Sprintf(eos(info), " (%d", mtmp->mtame);
if (!mtmp->isminion)
Sprintf(eos(info), "; hungry %ld; apport %d",
EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport);
Strcat(info, ")");
}
}
else if (mtmp->mpeaceful) Strcat(info, ", peaceful");
if (mtmp->cham >= LOW_PM && mtmp->data != &mons[mtmp->cham])
/* don't reveal the innate form (chameleon, vampire, &c),
just expose the fact that this current form isn't it */
Strcat(info, ", shapechanger");
/* pets eating mimic corpses mimic while eating, so this comes first */
if (mtmp->meating) Strcat(info, ", eating");
/* a stethoscope exposes mimic before getting here so this
won't be relevant for it, but wand of probing doesn't */
if (mtmp->m_ap_type)
Sprintf(eos(info), ", mimicking %s",
(mtmp->m_ap_type == M_AP_FURNITURE) ?
an(defsyms[mtmp->mappearance].explanation) :
(mtmp->m_ap_type == M_AP_OBJECT) ?
((mtmp->mappearance == GOLD_PIECE) ? "gold" :
an(simple_typename(mtmp->mappearance))) :
(mtmp->m_ap_type == M_AP_MONSTER) ?
an(mons[mtmp->mappearance].mname) :
something); /* impossible... */
if (mtmp->mcan) Strcat(info, ", cancelled");
if (mtmp->mconf) Strcat(info, ", confused");
if (mtmp->mblinded || !mtmp->mcansee)
Strcat(info, ", blind");
if (mtmp->mstun) Strcat(info, ", stunned");
if (mtmp->msleeping) Strcat(info, ", asleep");
#if 0 /* unfortunately mfrozen covers temporary sleep and being busy
(donning armor, for instance) as well as paralysis */
info[0] = 0;
if (mtmp->mtame) {
Strcat(info, ", tame");
if (wizard) {
Sprintf(eos(info), " (%d", mtmp->mtame);
if (!mtmp->isminion)
Sprintf(eos(info), "; hungry %ld; apport %d",
EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport);
Strcat(info, ")");
}
} else if (mtmp->mpeaceful)
Strcat(info, ", peaceful");
if (mtmp->cham >= LOW_PM && mtmp->data != &mons[mtmp->cham])
/* don't reveal the innate form (chameleon, vampire, &c),
just expose the fact that this current form isn't it */
Strcat(info, ", shapechanger");
/* pets eating mimic corpses mimic while eating, so this comes first */
if (mtmp->meating)
Strcat(info, ", eating");
/* a stethoscope exposes mimic before getting here so this
won't be relevant for it, but wand of probing doesn't */
if (mtmp->m_ap_type)
Sprintf(eos(info), ", mimicking %s",
(mtmp->m_ap_type == M_AP_FURNITURE)
? an(defsyms[mtmp->mappearance].explanation)
: (mtmp->m_ap_type == M_AP_OBJECT)
? ((mtmp->mappearance == GOLD_PIECE)
? "gold"
: an(simple_typename(mtmp->mappearance)))
: (mtmp->m_ap_type == M_AP_MONSTER)
? an(mons[mtmp->mappearance].mname)
: something); /* impossible... */
if (mtmp->mcan)
Strcat(info, ", cancelled");
if (mtmp->mconf)
Strcat(info, ", confused");
if (mtmp->mblinded || !mtmp->mcansee)
Strcat(info, ", blind");
if (mtmp->mstun)
Strcat(info, ", stunned");
if (mtmp->msleeping)
Strcat(info, ", asleep");
#if 0 /* unfortunately mfrozen covers temporary sleep and being busy \
(donning armor, for instance) as well as paralysis */
else if (mtmp->mfrozen) Strcat(info, ", paralyzed");
#else
else if (mtmp->mfrozen || !mtmp->mcanmove)
Strcat(info, ", can't move");
else if (mtmp->mfrozen || !mtmp->mcanmove)
Strcat(info, ", can't move");
#endif
/* [arbitrary reason why it isn't moving] */
else if (mtmp->mstrategy & STRAT_WAITMASK)
Strcat(info, ", meditating");
if (mtmp->mflee) Strcat(info, ", scared");
if (mtmp->mtrapped) Strcat(info, ", trapped");
if (mtmp->mspeed) Strcat(info,
mtmp->mspeed == MFAST ? ", fast" :
mtmp->mspeed == MSLOW ? ", slow" :
", ???? speed");
if (mtmp->mundetected) Strcat(info, ", concealed");
if (mtmp->minvis) Strcat(info, ", invisible");
if (mtmp == u.ustuck) Strcat(info,
sticks(youmonst.data) ? ", held by you" :
!u.uswallow ? ", holding you" :
attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_DGST) ?
", digesting you" :
is_animal(u.ustuck->data) ? ", swallowing you" :
", engulfing you");
if (mtmp == u.usteed) Strcat(info, ", carrying you");
/* [arbitrary reason why it isn't moving] */
else if (mtmp->mstrategy & STRAT_WAITMASK)
Strcat(info, ", meditating");
if (mtmp->mflee)
Strcat(info, ", scared");
if (mtmp->mtrapped)
Strcat(info, ", trapped");
if (mtmp->mspeed)
Strcat(info, mtmp->mspeed == MFAST ? ", fast" : mtmp->mspeed == MSLOW
? ", slow"
: ", ???? speed");
if (mtmp->mundetected)
Strcat(info, ", concealed");
if (mtmp->minvis)
Strcat(info, ", invisible");
if (mtmp == u.ustuck)
Strcat(info, sticks(youmonst.data)
? ", held by you"
: !u.uswallow ? ", holding you"
: attacktype_fordmg(u.ustuck->data,
AT_ENGL, AD_DGST)
? ", digesting you"
: is_animal(u.ustuck->data)
? ", swallowing you"
: ", engulfing you");
if (mtmp == u.usteed)
Strcat(info, ", carrying you");
/* avoid "Status of the invisible newt ..., invisible" */
/* and unlike a normal mon_nam, use "saddled" even if it has a name */
Strcpy(monnambuf, x_monnam(mtmp, ARTICLE_THE, (char *)0,
(SUPPRESS_IT|SUPPRESS_INVISIBLE), FALSE));
/* avoid "Status of the invisible newt ..., invisible" */
/* and unlike a normal mon_nam, use "saddled" even if it has a name */
Strcpy(monnambuf, x_monnam(mtmp, ARTICLE_THE, (char *) 0,
(SUPPRESS_IT | SUPPRESS_INVISIBLE), FALSE));
pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.",
monnambuf,
align_str(alignment),
mtmp->m_lev,
mtmp->mhp,
mtmp->mhpmax,
find_mac(mtmp),
info);
pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.", monnambuf,
align_str(alignment), mtmp->m_lev, mtmp->mhp, mtmp->mhpmax,
find_mac(mtmp), info);
}
void
ustatusline()
{
char info[BUFSZ];
char info[BUFSZ];
info[0] = '\0';
if (Sick) {
Strcat(info, ", dying from");
if (u.usick_type & SICK_VOMITABLE)
Strcat(info, " food poisoning");
if (u.usick_type & SICK_NONVOMITABLE) {
if (u.usick_type & SICK_VOMITABLE)
Strcat(info, " and");
Strcat(info, " illness");
}
}
if (Stoned) Strcat(info, ", solidifying");
if (Slimed) Strcat(info, ", becoming slimy");
if (Strangled) Strcat(info, ", being strangled");
if (Vomiting) Strcat(info, ", nauseated"); /* !"nauseous" */
if (Confusion) Strcat(info, ", confused");
if (Blind) {
Strcat(info, ", blind");
if (u.ucreamed) {
if ((long)u.ucreamed < Blinded || Blindfolded
|| !haseyes(youmonst.data))
Strcat(info, ", cover");
Strcat(info, "ed by sticky goop");
} /* note: "goop" == "glop"; variation is intentional */
}
if (Stunned) Strcat(info, ", stunned");
if (!u.usteed && Wounded_legs) {
const char *what = body_part(LEG);
if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
what = makeplural(what);
Sprintf(eos(info), ", injured %s", what);
}
if (Glib) Sprintf(eos(info), ", slippery %s",
makeplural(body_part(HAND)));
if (u.utrap) Strcat(info, ", trapped");
if (Fast) Strcat(info, Very_fast ?
", very fast" : ", fast");
if (u.uundetected) Strcat(info, ", concealed");
if (Invis) Strcat(info, ", invisible");
if (u.ustuck) {
if (sticks(youmonst.data))
Strcat(info, ", holding ");
else
Strcat(info, ", held by ");
Strcat(info, mon_nam(u.ustuck));
}
info[0] = '\0';
if (Sick) {
Strcat(info, ", dying from");
if (u.usick_type & SICK_VOMITABLE)
Strcat(info, " food poisoning");
if (u.usick_type & SICK_NONVOMITABLE) {
if (u.usick_type & SICK_VOMITABLE)
Strcat(info, " and");
Strcat(info, " illness");
}
}
if (Stoned)
Strcat(info, ", solidifying");
if (Slimed)
Strcat(info, ", becoming slimy");
if (Strangled)
Strcat(info, ", being strangled");
if (Vomiting)
Strcat(info, ", nauseated"); /* !"nauseous" */
if (Confusion)
Strcat(info, ", confused");
if (Blind) {
Strcat(info, ", blind");
if (u.ucreamed) {
if ((long) u.ucreamed < Blinded || Blindfolded
|| !haseyes(youmonst.data))
Strcat(info, ", cover");
Strcat(info, "ed by sticky goop");
} /* note: "goop" == "glop"; variation is intentional */
}
if (Stunned)
Strcat(info, ", stunned");
if (!u.usteed && Wounded_legs) {
const char *what = body_part(LEG);
if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
what = makeplural(what);
Sprintf(eos(info), ", injured %s", what);
}
if (Glib)
Sprintf(eos(info), ", slippery %s", makeplural(body_part(HAND)));
if (u.utrap)
Strcat(info, ", trapped");
if (Fast)
Strcat(info, Very_fast ? ", very fast" : ", fast");
if (u.uundetected)
Strcat(info, ", concealed");
if (Invis)
Strcat(info, ", invisible");
if (u.ustuck) {
if (sticks(youmonst.data))
Strcat(info, ", holding ");
else
Strcat(info, ", held by ");
Strcat(info, mon_nam(u.ustuck));
}
pline("Status of %s (%s%s): Level %d HP %d(%d) AC %d%s.",
plname,
(u.ualign.record >= 20) ? "piously " :
(u.ualign.record > 13) ? "devoutly " :
(u.ualign.record > 8) ? "fervently " :
(u.ualign.record > 3) ? "stridently " :
(u.ualign.record == 3) ? "" :
(u.ualign.record >= 1) ? "haltingly " :
(u.ualign.record == 0) ? "nominally " :
"insufficiently ",
align_str(u.ualign.type),
Upolyd ? mons[u.umonnum].mlevel : u.ulevel,
Upolyd ? u.mh : u.uhp,
Upolyd ? u.mhmax : u.uhpmax,
u.uac,
info);
pline("Status of %s (%s%s): Level %d HP %d(%d) AC %d%s.", plname,
(u.ualign.record >= 20)
? "piously "
: (u.ualign.record > 13)
? "devoutly "
: (u.ualign.record > 8)
? "fervently "
: (u.ualign.record > 3)
? "stridently "
: (u.ualign.record == 3)
? ""
: (u.ualign.record >= 1)
? "haltingly "
: (u.ualign.record == 0)
? "nominally "
: "insufficiently ",
align_str(u.ualign.type),
Upolyd ? mons[u.umonnum].mlevel : u.ulevel, Upolyd ? u.mh : u.uhp,
Upolyd ? u.mhmax : u.uhpmax, u.uac, info);
}
void
self_invis_message()
{
pline("%s %s.",
Hallucination ? "Far out, man! You" : "Gee! All of a sudden, you",
See_invisible ? "can see right through yourself" :
"can't see yourself");
pline("%s %s.",
Hallucination ? "Far out, man! You" : "Gee! All of a sudden, you",
See_invisible ? "can see right through yourself"
: "can't see yourself");
}
void
pudding_merge_message(otmp, otmp2)
struct obj* otmp;
struct obj* otmp2;
struct obj *otmp;
struct obj *otmp2;
{
boolean visible = cansee(otmp->ox, otmp->oy) || cansee(otmp2->ox, otmp2->oy);
boolean visible =
cansee(otmp->ox, otmp->oy) || cansee(otmp2->ox, otmp2->oy);
boolean onfloor = otmp->where == OBJ_FLOOR || otmp2->where == OBJ_FLOOR;
boolean inpack = carried(otmp) || carried(otmp2);
@@ -506,16 +549,16 @@ struct obj* otmp2;
} else if (inpack) {
Your("pack reaches out and grabs something!");
}
/* even though we can see where they should be,
/* even though we can see where they should be,
* they'll be out of our view (minvent or container)
* so don't actually show anything */
} else if (onfloor || inpack) {
pline("The %s coalesce%s.", makeplural(obj_typename(otmp->otyp)),
inpack ? " inside your pack" : "");
inpack ? " inside your pack" : "");
}
} else {
You_hear("a faint sloshing sound.");
}
}
/*pline.c*/
+1483 -1398
View File
File diff suppressed because it is too large Load Diff
+1846 -1768
View File
File diff suppressed because it is too large Load Diff
+1643 -1475
View File
File diff suppressed because it is too large Load Diff
+591 -540
View File
File diff suppressed because it is too large Load Diff
+267 -231
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 quest.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 quest.c $NHDT-Date: 1431192766 2015/05/09 17:32:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.17 $ */
/* NetHack 3.6 quest.c $Date: 2009/05/06 10:47:33 $ $Revision: 1.10 $ */
/* SCCS Id: @(#)quest.c 3.5 2006/08/05 */
/* Copyright 1991, M. Stephenson */
@@ -11,8 +11,8 @@
#include "quest.h"
#include "qtext.h"
#define Not_firsttime (on_level(&u.uz0, &u.uz))
#define Qstat(x) (quest_status.x)
#define Not_firsttime (on_level(&u.uz0, &u.uz))
#define Qstat(x) (quest_status.x)
STATIC_DCL void NDECL(on_start);
STATIC_DCL void NDECL(on_locate);
@@ -25,101 +25,110 @@ STATIC_DCL void NDECL(chat_with_nemesis);
STATIC_DCL void NDECL(chat_with_guardian);
STATIC_DCL void FDECL(prisoner_speaks, (struct monst *));
STATIC_OVL void
on_start()
{
if(!Qstat(first_start)) {
qt_pager(QT_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);
else qt_pager(QT_OTHERTIME);
}
if (!Qstat(first_start)) {
qt_pager(QT_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);
else
qt_pager(QT_OTHERTIME);
}
}
STATIC_OVL void
on_locate()
{
/* the locate messages are phrased in a manner such that they only
make sense when arriving on the level from above */
boolean from_above = (u.uz0.dlevel < u.uz.dlevel);
/* the locate messages are phrased in a manner such that they only
make sense when arriving on the level from above */
boolean from_above = (u.uz0.dlevel < u.uz.dlevel);
if (Qstat(killed_nemesis)) {
return;
} else if (!Qstat(first_locate)) {
if (from_above) qt_pager(QT_FIRSTLOCATE);
/* 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);
}
if (Qstat(killed_nemesis)) {
return;
} else if (!Qstat(first_locate)) {
if (from_above)
qt_pager(QT_FIRSTLOCATE);
/* 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);
}
}
STATIC_OVL void
on_goal()
{
if (Qstat(killed_nemesis)) {
return;
} else if (!Qstat(made_goal)) {
qt_pager(QT_FIRSTGOAL);
Qstat(made_goal) = 1;
} else {
qt_pager(QT_NEXTGOAL);
if(Qstat(made_goal) < 7) Qstat(made_goal)++;
}
if (Qstat(killed_nemesis)) {
return;
} else if (!Qstat(made_goal)) {
qt_pager(QT_FIRSTGOAL);
Qstat(made_goal) = 1;
} else {
qt_pager(QT_NEXTGOAL);
if (Qstat(made_goal) < 7)
Qstat(made_goal)++;
}
}
void
onquest()
{
if(u.uevent.qcompleted || Not_firsttime) return;
if(!Is_special(&u.uz)) return;
if (u.uevent.qcompleted || Not_firsttime)
return;
if (!Is_special(&u.uz))
return;
if(Is_qstart(&u.uz)) on_start();
else if(Is_qlocate(&u.uz)) on_locate();
else if(Is_nemesis(&u.uz)) on_goal();
return;
if (Is_qstart(&u.uz))
on_start();
else if (Is_qlocate(&u.uz))
on_locate();
else if (Is_nemesis(&u.uz))
on_goal();
return;
}
void
nemdead()
{
if(!Qstat(killed_nemesis)) {
Qstat(killed_nemesis) = TRUE;
qt_pager(QT_KILLEDNEM);
}
if (!Qstat(killed_nemesis)) {
Qstat(killed_nemesis) = TRUE;
qt_pager(QT_KILLEDNEM);
}
}
void
artitouch(obj)
struct obj *obj;
{
if(!Qstat(touched_artifact)) {
/* in case we haven't seen the item yet (ie, currently blinded),
this quest message describes it by name so mark it as seen */
obj->dknown = 1;
/* only give this message once */
Qstat(touched_artifact) = TRUE;
qt_pager(QT_GOTIT);
exercise(A_WIS, TRUE);
}
if (!Qstat(touched_artifact)) {
/* in case we haven't seen the item yet (ie, currently blinded),
this quest message describes it by name so mark it as seen */
obj->dknown = 1;
/* only give this message once */
Qstat(touched_artifact) = TRUE;
qt_pager(QT_GOTIT);
exercise(A_WIS, TRUE);
}
}
/* external hook for do.c (level change check) */
boolean
ok_to_quest()
{
return((boolean)((Qstat(got_quest) || Qstat(got_thanks)))
&& (is_pure(FALSE) > 0));
return ((boolean)((Qstat(got_quest) || Qstat(got_thanks)))
&& (is_pure(FALSE) > 0));
}
STATIC_OVL boolean
not_capable()
{
return((boolean)(u.ulevel < MIN_QUEST_LEVEL));
return ((boolean)(u.ulevel < MIN_QUEST_LEVEL));
}
STATIC_OVL int
@@ -130,22 +139,23 @@ boolean talk;
aligntyp original_alignment = u.ualignbase[A_ORIGINAL];
if (wizard && talk) {
if (u.ualign.type != original_alignment) {
You("are currently %s instead of %s.",
align_str(u.ualign.type), align_str(original_alignment));
} else if (u.ualignbase[A_CURRENT] != original_alignment) {
You("have converted.");
} else if (u.ualign.record < MIN_QUEST_ALIGN) {
You("are currently %d and require %d.",
u.ualign.record, MIN_QUEST_ALIGN);
if (yn_function("adjust?", (char *)0, 'y') == 'y')
u.ualign.record = MIN_QUEST_ALIGN;
}
if (u.ualign.type != original_alignment) {
You("are currently %s instead of %s.", align_str(u.ualign.type),
align_str(original_alignment));
} else if (u.ualignbase[A_CURRENT] != original_alignment) {
You("have converted.");
} else if (u.ualign.record < MIN_QUEST_ALIGN) {
You("are currently %d and require %d.", u.ualign.record,
MIN_QUEST_ALIGN);
if (yn_function("adjust?", (char *) 0, 'y') == 'y')
u.ualign.record = MIN_QUEST_ALIGN;
}
}
purity = (u.ualign.record >= MIN_QUEST_ALIGN &&
u.ualign.type == original_alignment &&
u.ualignbase[A_CURRENT] == original_alignment) ? 1 :
(u.ualignbase[A_CURRENT] != original_alignment) ? -1 : 0;
purity = (u.ualign.record >= MIN_QUEST_ALIGN
&& u.ualign.type == original_alignment
&& u.ualignbase[A_CURRENT] == original_alignment)
? 1
: (u.ualignbase[A_CURRENT] != original_alignment) ? -1 : 0;
return purity;
}
@@ -166,21 +176,24 @@ boolean seal;
br = dungeon_branch("The Quest");
dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1;
portal_flag = u.uevent.qexpelled ? 0 : /* returned via artifact? */
!seal ? 1 : -1;
schedule_goto(dest, FALSE, FALSE, portal_flag, (char *)0, (char *)0);
if (seal) { /* remove the portal to the quest - sealing it off */
int reexpelled = u.uevent.qexpelled;
u.uevent.qexpelled = 1;
remdun_mapseen(quest_dnum);
/* Delete the near portal now; the far (main dungeon side)
portal will be deleted as part of arrival on that level.
If monster movement is in progress, any who haven't moved
yet will now miss out on a chance to wander through it... */
for (t = ftrap; t; t = t->ntrap)
if (t->ttyp == MAGIC_PORTAL) break;
if (t) deltrap(t); /* (display might be briefly out of sync) */
else if (!reexpelled) impossible("quest portal already gone?");
portal_flag = u.uevent.qexpelled ? 0 : /* returned via artifact? */
!seal ? 1 : -1;
schedule_goto(dest, FALSE, FALSE, portal_flag, (char *) 0, (char *) 0);
if (seal) { /* remove the portal to the quest - sealing it off */
int reexpelled = u.uevent.qexpelled;
u.uevent.qexpelled = 1;
remdun_mapseen(quest_dnum);
/* Delete the near portal now; the far (main dungeon side)
portal will be deleted as part of arrival on that level.
If monster movement is in progress, any who haven't moved
yet will now miss out on a chance to wander through it... */
for (t = ftrap; t; t = t->ntrap)
if (t->ttyp == MAGIC_PORTAL)
break;
if (t)
deltrap(t); /* (display might be briefly out of sync) */
else if (!reexpelled)
impossible("quest portal already gone?");
}
}
@@ -191,213 +204,236 @@ boolean seal;
and using the magic portal to return to the dungeon. */
void
finish_quest(obj)
struct obj *obj; /* quest artifact; possibly null if carrying Amulet */
struct obj *obj; /* quest artifact; possibly null if carrying Amulet */
{
struct obj *otmp;
struct obj *otmp;
if (u.uhave.amulet) { /* unlikely but not impossible */
qt_pager(QT_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);
/* should have obtained bell during quest;
if not, suggest returning for it now */
if ((otmp = carrying(BELL_OF_OPENING)) == 0)
com_pager(5);
}
Qstat(got_thanks) = TRUE;
if (u.uhave.amulet) { /* unlikely but not impossible */
qt_pager(QT_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);
/* should have obtained bell during quest;
if not, suggest returning for it now */
if ((otmp = carrying(BELL_OF_OPENING)) == 0)
com_pager(5);
}
Qstat(got_thanks) = TRUE;
if (obj) {
u.uevent.qcompleted = 1; /* you did it! */
/* behave as if leader imparts sufficient info about the
quest artifact */
fully_identify_obj(obj);
update_inventory();
}
if (obj) {
u.uevent.qcompleted = 1; /* you did it! */
/* behave as if leader imparts sufficient info about the
quest artifact */
fully_identify_obj(obj);
update_inventory();
}
}
STATIC_OVL void
chat_with_leader()
{
/* Rule 0: Cheater checks. */
if(u.uhave.questart && !Qstat(met_nemesis))
Qstat(cheater) = TRUE;
/* Rule 0: Cheater checks. */
if (u.uhave.questart && !Qstat(met_nemesis))
Qstat(cheater) = TRUE;
/* It is possible for you to get the amulet without completing
* the quest. If so, try to induce the player to quest.
*/
if(Qstat(got_thanks)) {
/* Rule 1: You've gone back with/without the amulet. */
if(u.uhave.amulet) finish_quest((struct obj *)0);
/* It is possible for you to get the amulet without completing
* the quest. If so, try to induce the player to quest.
*/
if (Qstat(got_thanks)) {
/* Rule 1: You've gone back with/without the amulet. */
if (u.uhave.amulet)
finish_quest((struct obj *) 0);
/* Rule 2: You've gone back before going for the amulet. */
else qt_pager(QT_POSTHANKS);
}
/* Rule 2: You've gone back before going for the amulet. */
else
qt_pager(QT_POSTHANKS);
}
/* Rule 3: You've got the artifact and are back to return it. */
else if(u.uhave.questart) {
struct obj *otmp;
/* Rule 3: You've got the artifact and are back to return it. */
else if (u.uhave.questart) {
struct obj *otmp;
for (otmp = invent; otmp; otmp = otmp->nobj)
if (is_quest_artifact(otmp)) break;
for (otmp = invent; otmp; otmp = otmp->nobj)
if (is_quest_artifact(otmp))
break;
finish_quest(otmp);
finish_quest(otmp);
/* Rule 4: You haven't got the artifact yet. */
} else if(Qstat(got_quest)) {
qt_pager(rn1(10, QT_ENCOURAGE));
/* Rule 4: You haven't got the artifact yet. */
} else if (Qstat(got_quest)) {
qt_pager(rn1(10, QT_ENCOURAGE));
/* Rule 5: You aren't yet acceptable - or are you? */
} else {
if(!Qstat(met_leader)) {
qt_pager(QT_FIRSTLEADER);
Qstat(met_leader) = TRUE;
Qstat(not_ready) = 0;
} else qt_pager(QT_NEXTLEADER);
/* the quest leader might have passed through the portal into
the regular dungeon; none of the remaining make sense there */
if (!on_level(&u.uz, &qstart_level)) return;
/* Rule 5: You aren't yet acceptable - or are you? */
} else {
if (!Qstat(met_leader)) {
qt_pager(QT_FIRSTLEADER);
Qstat(met_leader) = TRUE;
Qstat(not_ready) = 0;
} else
qt_pager(QT_NEXTLEADER);
/* the quest leader might have passed through the portal into
the regular dungeon; none of the remaining make sense there */
if (!on_level(&u.uz, &qstart_level))
return;
if(not_capable()) {
qt_pager(QT_BADLEVEL);
exercise(A_WIS, TRUE);
expulsion(FALSE);
} else if(is_pure(TRUE) < 0) {
com_pager(QT_BANISHED);
expulsion(TRUE);
} else if(is_pure(TRUE) == 0) {
qt_pager(QT_BADALIGN);
if(Qstat(not_ready) == MAX_QUEST_TRIES) {
qt_pager(QT_LASTLEADER);
expulsion(TRUE);
} else {
Qstat(not_ready)++;
exercise(A_WIS, TRUE);
expulsion(FALSE);
}
} else { /* You are worthy! */
qt_pager(QT_ASSIGNQUEST);
exercise(A_WIS, TRUE);
Qstat(got_quest) = TRUE;
}
}
if (not_capable()) {
qt_pager(QT_BADLEVEL);
exercise(A_WIS, TRUE);
expulsion(FALSE);
} else if (is_pure(TRUE) < 0) {
com_pager(QT_BANISHED);
expulsion(TRUE);
} else if (is_pure(TRUE) == 0) {
qt_pager(QT_BADALIGN);
if (Qstat(not_ready) == MAX_QUEST_TRIES) {
qt_pager(QT_LASTLEADER);
expulsion(TRUE);
} else {
Qstat(not_ready)++;
exercise(A_WIS, TRUE);
expulsion(FALSE);
}
} else { /* You are worthy! */
qt_pager(QT_ASSIGNQUEST);
exercise(A_WIS, TRUE);
Qstat(got_quest) = TRUE;
}
}
}
void
leader_speaks(mtmp)
register struct monst *mtmp;
register struct monst *mtmp;
{
/* maybe you attacked leader? */
if(!mtmp->mpeaceful) {
Qstat(pissed_off) = TRUE;
mtmp->mstrategy &= ~STRAT_WAITMASK; /* end the inaction */
}
/* the quest leader might have passed through the portal into the
regular dungeon; if so, mustn't perform "backwards expulsion" */
if (!on_level(&u.uz, &qstart_level)) return;
/* maybe you attacked leader? */
if (!mtmp->mpeaceful) {
Qstat(pissed_off) = TRUE;
mtmp->mstrategy &= ~STRAT_WAITMASK; /* end the inaction */
}
/* the quest leader might have passed through the portal into the
regular dungeon; if so, mustn't perform "backwards expulsion" */
if (!on_level(&u.uz, &qstart_level))
return;
if(Qstat(pissed_off)) {
qt_pager(QT_LASTLEADER);
expulsion(TRUE);
} else chat_with_leader();
if (Qstat(pissed_off)) {
qt_pager(QT_LASTLEADER);
expulsion(TRUE);
} else
chat_with_leader();
}
STATIC_OVL void
chat_with_nemesis()
{
/* The nemesis will do most of the talking, but... */
qt_pager(rn1(10, QT_DISCOURAGE));
if(!Qstat(met_nemesis)) Qstat(met_nemesis++);
/* The nemesis will do most of the talking, but... */
qt_pager(rn1(10, QT_DISCOURAGE));
if (!Qstat(met_nemesis))
Qstat(met_nemesis++);
}
void
nemesis_speaks()
{
if(!Qstat(in_battle)) {
if(u.uhave.questart) qt_pager(QT_NEMWANTSIT);
else if(Qstat(made_goal) == 1 || !Qstat(met_nemesis))
qt_pager(QT_FIRSTNEMESIS);
else if(Qstat(made_goal) < 4) qt_pager(QT_NEXTNEMESIS);
else if(Qstat(made_goal) < 7) qt_pager(QT_OTHERNEMESIS);
else if(!rn2(5)) qt_pager(rn1(10, QT_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));
if (!Qstat(in_battle)) {
if (u.uhave.questart)
qt_pager(QT_NEMWANTSIT);
else if (Qstat(made_goal) == 1 || !Qstat(met_nemesis))
qt_pager(QT_FIRSTNEMESIS);
else if (Qstat(made_goal) < 4)
qt_pager(QT_NEXTNEMESIS);
else if (Qstat(made_goal) < 7)
qt_pager(QT_OTHERNEMESIS);
else if (!rn2(5))
qt_pager(rn1(10, QT_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));
}
STATIC_OVL void
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));
else
qt_pager(rn1(5, QT_GUARDTALK));
/* These guys/gals really don't have much to say... */
if (u.uhave.questart && Qstat(killed_nemesis))
qt_pager(rn1(5, QT_GUARDTALK2));
else
qt_pager(rn1(5, QT_GUARDTALK));
}
STATIC_OVL void
prisoner_speaks (mtmp)
register struct monst *mtmp;
prisoner_speaks(mtmp)
register struct monst *mtmp;
{
if (mtmp->data == &mons[PM_PRISONER] &&
(mtmp->mstrategy & STRAT_WAITMASK)) {
/* Awaken the prisoner */
if (canseemon(mtmp))
pline("%s speaks:", Monnam(mtmp));
verbalize("I'm finally free!");
mtmp->mstrategy &= ~STRAT_WAITMASK;
mtmp->mpeaceful = 1;
if (mtmp->data == &mons[PM_PRISONER]
&& (mtmp->mstrategy & STRAT_WAITMASK)) {
/* Awaken the prisoner */
if (canseemon(mtmp))
pline("%s speaks:", Monnam(mtmp));
verbalize("I'm finally free!");
mtmp->mstrategy &= ~STRAT_WAITMASK;
mtmp->mpeaceful = 1;
/* Your god is happy... */
adjalign(3);
/* Your god is happy... */
adjalign(3);
/* ...But the guards are not */
(void) angry_guards(FALSE);
}
return;
/* ...But the guards are not */
(void) angry_guards(FALSE);
}
return;
}
void
quest_chat(mtmp)
register struct monst *mtmp;
register struct monst *mtmp;
{
if (mtmp->m_id == Qstat(leader_m_id)) {
chat_with_leader();
return;
chat_with_leader();
return;
}
switch (mtmp->data->msound) {
case MS_NEMESIS:
chat_with_nemesis();
break;
case MS_GUARDIAN:
chat_with_guardian();
break;
default:
impossible("quest_chat: Unknown quest character %s.", mon_nam(mtmp));
}
switch(mtmp->data->msound) {
case MS_NEMESIS: chat_with_nemesis(); break;
case MS_GUARDIAN: chat_with_guardian(); break;
default: impossible("quest_chat: Unknown quest character %s.",
mon_nam(mtmp));
}
}
void
quest_talk(mtmp)
register struct monst *mtmp;
register struct monst *mtmp;
{
if (mtmp->m_id == Qstat(leader_m_id)) {
leader_speaks(mtmp);
return;
leader_speaks(mtmp);
return;
}
switch (mtmp->data->msound) {
case MS_NEMESIS:
nemesis_speaks();
break;
case MS_DJINNI:
prisoner_speaks(mtmp);
break;
default:
break;
}
switch(mtmp->data->msound) {
case MS_NEMESIS: nemesis_speaks(); break;
case MS_DJINNI: prisoner_speaks(mtmp); break;
default: break;
}
}
void
quest_stat_check(mtmp)
struct monst *mtmp;
struct monst *mtmp;
{
if(mtmp->data->msound == MS_NEMESIS)
Qstat(in_battle) = (mtmp->mcanmove && !mtmp->msleeping &&
monnear(mtmp, u.ux, u.uy));
if (mtmp->data->msound == MS_NEMESIS)
Qstat(in_battle) =
(mtmp->mcanmove && !mtmp->msleeping && monnear(mtmp, u.ux, u.uy));
}
/*quest.c*/
+395 -352
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 questpgr.c $NHDT-Date: 1426465439 2015/03/16 00:23:59 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.6 questpgr.c $NHDT-Date: 1431192763 2015/05/09 17:32:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
/* NetHack 3.6 questpgr.c $Date: 2012/02/02 09:18:14 $ $Revision: 1.14 $ */
/* Copyright 1991, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */
@@ -10,7 +10,7 @@
#include "qtext.h"
#define QTEXT_FILE "quest.dat"
#define QTEXT_FILE "quest.dat"
#ifdef TTY_GRAPHICS
#include "wintty.h"
@@ -19,218 +19,218 @@
/* from sp_lev.c, for deliver_splev_message() */
extern char *lev_message;
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 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 NDECL(convert_line);
STATIC_DCL void FDECL(deliver_by_pline, (struct qtmsg *));
STATIC_DCL void FDECL(deliver_by_window, (struct qtmsg *,int));
STATIC_DCL void FDECL(deliver_by_window, (struct qtmsg *, int));
STATIC_DCL boolean FDECL(skip_pager, (BOOLEAN_P));
static char in_line[QTEXT_IN_SIZ], out_line[QTEXT_OUTSIZ], cvt_buf[64];
static struct qtlists qt_list;
static dlb *msg_file;
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];
static char nambuf[sizeof cvt_buf];
#ifdef DEBUG
static void NDECL(dump_qtlist);
static void
dump_qtlist() /* dump the character msg list to check appearance */
dump_qtlist() /* dump the character msg list to check appearance */
{
struct qtmsg *msg;
struct qtmsg *msg;
if (!explicitdebug(__FILE__)) return;
if (!explicitdebug(__FILE__))
return;
for (msg = qt_list.chrole; msg->msgnum > 0; msg++) {
pline("msgnum %d: delivery %c",
msg->msgnum, msg->delivery);
for (msg = qt_list.chrole; msg->msgnum > 0; msg++) {
pline("msgnum %d: delivery %c", msg->msgnum, msg->delivery);
#ifdef TTY_GRAPHICS
more();
more();
#endif
(void) dlb_fseek(msg_file, msg->offset, SEEK_SET);
deliver_by_window(msg, NHW_TEXT);
}
(void) dlb_fseek(msg_file, msg->offset, SEEK_SET);
deliver_by_window(msg, NHW_TEXT);
}
}
#else
static void
dump_qtlist() { }
dump_qtlist()
{
}
#endif /* !DEBUG */
static void
Fread(ptr, size, nitems, stream)
genericptr_t ptr;
int size, nitems;
dlb *stream;
genericptr_t ptr;
int size, nitems;
dlb *stream;
{
int cnt;
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));
}
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_OVL struct qtmsg *
construct_qtlist(hdr_offset)
long hdr_offset;
long hdr_offset;
{
struct qtmsg *msg_list;
int n_msgs;
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));
(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);
/*
* 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);
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];
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);
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.
*/
/*
* 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);
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.
*/
/*
* 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;
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 */
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 */
if (!qt_list.common || !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 (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;
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;
}
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;
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;
}
const char *
ldrname() /* return your role leader's name */
const char *ldrname() /* return your role leader's name */
{
int i = urole.ldrnum;
int i = urole.ldrnum;
Sprintf(nambuf, "%s%s",
type_is_pname(&mons[i]) ? "" : "the ",
mons[i].mname);
return nambuf;
Sprintf(nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ",
mons[i].mname);
return nambuf;
}
STATIC_OVL const char *
intermed() /* return your intermediate target string */
STATIC_OVL const char *intermed() /* return your intermediate target string */
{
return (urole.intermed);
return (urole.intermed);
}
boolean
is_quest_artifact(otmp)
struct obj *otmp;
{
return((boolean)(otmp->oartifact == urole.questarti));
return ((boolean)(otmp->oartifact == urole.questarti));
}
STATIC_OVL const char *neminame() /* return your role nemesis' name */
{
int i = urole.neminum;
Sprintf(nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ",
mons[i].mname);
return nambuf;
}
STATIC_OVL const char *
neminame() /* return your role nemesis' name */
guardname() /* return your role leader's guard monster name */
{
int i = urole.neminum;
int i = urole.guardnum;
Sprintf(nambuf, "%s%s",
type_is_pname(&mons[i]) ? "" : "the ",
mons[i].mname);
return nambuf;
return (mons[i].mname);
}
STATIC_OVL const char *
guardname() /* return your role leader's guard monster name */
STATIC_OVL const char *homebase() /* return your role leader's location */
{
int i = urole.guardnum;
return(mons[i].mname);
}
STATIC_OVL const char *
homebase() /* return your role leader's location */
{
return(urole.homebase);
return (urole.homebase);
}
/* 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' */
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 */
char lwhich = lowc(which); /* H,I,J -> h,i,j */
/*
* Invalid subject (not d,l,n,o) yields neuter, singular result.
@@ -240,202 +240,237 @@ char who, /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => artifact */
* and makesingular() understands how to handle "the foos of bar".
*/
if (who == 'o' && strcmpi(cvt_buf, makesingular(cvt_buf))) {
pnoun = (lwhich == 'h') ? "they" :
(lwhich == 'i') ? "them" :
(lwhich == 'j') ? "their" : "?";
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 : "?";
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]);
if (lwhich != which)
cvt_buf[0] = highc(cvt_buf[0]);
return;
}
STATIC_OVL struct qtmsg *
msg_in(qtm_list, msgnum)
struct qtmsg *qtm_list;
int msgnum;
int msgnum;
{
struct qtmsg *qt_msg;
struct qtmsg *qt_msg;
for (qt_msg = qtm_list; qt_msg->msgnum > 0; qt_msg++)
if (qt_msg->msgnum == msgnum) return(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);
return ((struct qtmsg *) 0);
}
STATIC_OVL void
convert_arg(c)
char c;
{
register const char *str;
register const char *str;
switch (c) {
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 ");
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);
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);
}
STATIC_OVL void
convert_line()
{
char *c, *cc;
char xbuf[BUFSZ];
char *c, *cc;
char xbuf[BUFSZ];
cc = out_line;
for (c = xcrypt(in_line, xbuf); *c; c++) {
cc = out_line;
for (c = xcrypt(in_line, xbuf); *c; c++) {
*cc = 0;
switch (*c) {
case '\r':
case '\n':
*(++cc) = 0;
return;
*cc = 0;
switch(*c) {
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 */
case '\r':
case '\n':
*(++cc) = 0;
return;
/* capitalize */
case 'C':
cvt_buf[0] = highc(cvt_buf[0]);
break;
case '%':
if (*(c+1)) {
convert_arg(*(++c));
switch (*(++c)) {
/* 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;
/* 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 */
/* pluralize */
case 'P':
cvt_buf[0] = highc(cvt_buf[0]);
case 'p':
Strcpy(cvt_buf, makeplural(cvt_buf));
break;
/* capitalize */
case 'C': cvt_buf[0] = highc(cvt_buf[0]);
break;
/* append possessive suffix */
case 'S':
cvt_buf[0] = highc(cvt_buf[0]);
case 's':
Strcpy(cvt_buf, s_suffix(cvt_buf));
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;
/* strip any "the" prefix */
case 't':
if (!strncmpi(cvt_buf, "the ", 4)) {
Strcat(cc, &cvt_buf[4]);
cc += strlen(cc);
continue; /* for */
}
break;
/* pluralize */
case 'P': cvt_buf[0] = highc(cvt_buf[0]);
case 'p': Strcpy(cvt_buf, makeplural(cvt_buf));
break;
default:
--c; /* undo switch increment */
break;
}
Strcat(cc, cvt_buf);
cc += strlen(cvt_buf);
break;
} /* else fall through */
/* 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 + sizeof out_line)
panic("convert_line: overflow");
*cc = 0;
return;
default:
*cc++ = *c;
break;
}
}
if (cc >= out_line + sizeof out_line)
panic("convert_line: overflow");
*cc = 0;
return;
}
STATIC_OVL void
deliver_by_pline(qt_msg)
struct qtmsg *qt_msg;
{
long size;
for (size = 0; size < qt_msg->size; size += (long)strlen(in_line)) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_line();
pline1(out_line);
}
long size;
for (size = 0; size < qt_msg->size; size += (long) strlen(in_line)) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_line();
pline1(out_line);
}
}
STATIC_OVL void
@@ -443,97 +478,104 @@ deliver_by_window(qt_msg, how)
struct qtmsg *qt_msg;
int how;
{
long size;
winid datawin = create_nhwindow(how);
long size;
winid datawin = create_nhwindow(how);
for (size = 0; size < qt_msg->size; size += (long)strlen(in_line)) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_line();
putstr(datawin, 0, out_line);
}
display_nhwindow(datawin, TRUE);
destroy_nhwindow(datawin);
for (size = 0; size < qt_msg->size; size += (long) strlen(in_line)) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_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 can have a one-line summary which is put there for ^P recall */
if (qt_msg->summary_size) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_line();
putmsghistory(out_line, FALSE);
}
/* block messages delivered by window aren't kept in message history
but can have a one-line summary which is put there for ^P recall */
if (qt_msg->summary_size) {
(void) dlb_fgets(in_line, QTEXT_IN_SIZ, msg_file);
convert_line();
putmsghistory(out_line, FALSE);
}
}
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;
/* 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;
}
void
com_pager(msgnum)
int msgnum;
int msgnum;
{
struct qtmsg *qt_msg;
struct qtmsg *qt_msg;
if (skip_pager(TRUE)) return;
if (skip_pager(TRUE))
return;
if (!(qt_msg = msg_in(qt_list.common, msgnum))) {
impossible("com_pager: message %d not found.", msgnum);
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;
(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;
}
void
qt_pager(msgnum)
int msgnum;
int msgnum;
{
struct qtmsg *qt_msg;
struct qtmsg *qt_msg;
if (skip_pager(FALSE)) return;
if (skip_pager(FALSE))
return;
if (!(qt_msg = msg_in(qt_list.chrole, msgnum))) {
impossible("qt_pager: message %d not found.", msgnum);
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;
(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;
}
struct permonst *
qt_montype()
{
int qpm;
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));
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));
}
/* special levels can include a custom arrival message; display it */
@@ -544,23 +586,24 @@ deliver_splev_message()
/* 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);
/* 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;
it reads from in_line[] and writes to out_line[] */
(void)xcrypt(in_line, in_line);
convert_line();
pline1(out_line);
/* convert_line() expects encrypted input;
it reads from in_line[] and writes to out_line[] */
(void) xcrypt(in_line, in_line);
convert_line();
pline1(out_line);
if ((nl = index(str, '\n')) == 0) break; /* done if no newline */
}
if ((nl = index(str, '\n')) == 0)
break; /* done if no newline */
}
free((genericptr_t)lev_message);
lev_message = 0;
free((genericptr_t) lev_message);
lev_message = 0;
}
}
+1947 -1903
View File
File diff suppressed because it is too large Load Diff
+94 -87
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 rect.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 rect.c $NHDT-Date: 1431192769 2015/05/09 17:32:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* NetHack 3.6 rect.c $Date: 2009/05/06 10:47:37 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)rect.c 3.5 1990/02/22 */
/* Copyright (c) 1990 by Jean-Christophe Collet */
@@ -8,18 +8,18 @@
int FDECL(get_rect_ind, (NhRect *));
STATIC_DCL boolean FDECL(intersect, (NhRect *,NhRect *,NhRect *));
STATIC_DCL boolean FDECL(intersect, (NhRect *, NhRect *, NhRect *));
/*
* In this file, we will handle the various rectangle functions we
* need for room generation.
*/
/*
* In this file, we will handle the various rectangle functions we
* need for room generation.
*/
#define MAXRECT 50
#define XLIM 4
#define YLIM 3
#define MAXRECT 50
#define XLIM 4
#define YLIM 3
static NhRect rect[MAXRECT+1];
static NhRect rect[MAXRECT + 1];
static int rect_cnt;
/*
@@ -30,10 +30,10 @@ static int rect_cnt;
void
init_rect()
{
rect_cnt = 1;
rect[0].lx = rect[0].ly = 0;
rect[0].hx = COLNO - 1;
rect[0].hy = ROWNO - 1;
rect_cnt = 1;
rect[0].lx = rect[0].ly = 0;
rect[0].hx = COLNO - 1;
rect[0].hy = ROWNO - 1;
}
/*
@@ -45,17 +45,19 @@ int
get_rect_ind(r)
NhRect *r;
{
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
lx = r->lx; ly = r->ly;
hx = r->hx; hy = r->hy;
for (i=0,rectp = &rect[0];i<rect_cnt;i++,rectp++)
if ( lx == rectp->lx && ly == rectp->ly &&
hx == rectp->hx && hy == rectp->hy)
return i;
return -1;
lx = r->lx;
ly = r->ly;
hx = r->hx;
hy = r->hy;
for (i = 0, rectp = &rect[0]; i < rect_cnt; i++, rectp++)
if (lx == rectp->lx && ly == rectp->ly && hx == rectp->hx
&& hy == rectp->hy)
return i;
return -1;
}
/*
@@ -66,17 +68,19 @@ NhRect *
get_rect(r)
NhRect *r;
{
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
lx = r->lx; ly = r->ly;
hx = r->hx; hy = r->hy;
for (i=0,rectp = &rect[0];i<rect_cnt;i++,rectp++)
if ( lx >= rectp->lx && ly >= rectp->ly &&
hx <= rectp->hx && hy <= rectp->hy)
return rectp;
return 0;
lx = r->lx;
ly = r->ly;
hx = r->hx;
hy = r->hy;
for (i = 0, rectp = &rect[0]; i < rect_cnt; i++, rectp++)
if (lx >= rectp->lx && ly >= rectp->ly && hx <= rectp->hx
&& hy <= rectp->hy)
return rectp;
return 0;
}
/*
@@ -86,7 +90,7 @@ NhRect *r;
NhRect *
rnd_rect()
{
return rect_cnt > 0 ? &rect[rn2(rect_cnt)] : 0;
return rect_cnt > 0 ? &rect[rn2(rect_cnt)] : 0;
}
/*
@@ -99,18 +103,18 @@ STATIC_OVL boolean
intersect(r1, r2, r3)
NhRect *r1, *r2, *r3;
{
if (r2->lx > r1->hx || r2->ly > r1->hy ||
r2->hx < r1->lx || r2->hy < r1->ly)
return FALSE;
if (r2->lx > r1->hx || r2->ly > r1->hy || r2->hx < r1->lx
|| r2->hy < r1->ly)
return FALSE;
r3->lx = (r2->lx > r1->lx ? r2->lx : r1->lx);
r3->ly = (r2->ly > r1->ly ? r2->ly : r1->ly);
r3->hx = (r2->hx > r1->hx ? r1->hx : r2->hx);
r3->hy = (r2->hy > r1->hy ? r1->hy : r2->hy);
r3->lx = (r2->lx > r1->lx ? r2->lx : r1->lx);
r3->ly = (r2->ly > r1->ly ? r2->ly : r1->ly);
r3->hx = (r2->hx > r1->hx ? r1->hx : r2->hx);
r3->hy = (r2->hy > r1->hy ? r1->hy : r2->hy);
if (r3->lx > r3->hx || r3->ly > r3->hy)
return FALSE;
return TRUE;
if (r3->lx > r3->hx || r3->ly > r3->hy)
return FALSE;
return TRUE;
}
/*
@@ -121,11 +125,11 @@ void
remove_rect(r)
NhRect *r;
{
int ind;
int ind;
ind = get_rect_ind(r);
if ( ind >=0 )
rect[ind] = rect[--rect_cnt];
ind = get_rect_ind(r);
if (ind >= 0)
rect[ind] = rect[--rect_cnt];
}
/*
@@ -136,15 +140,16 @@ void
add_rect(r)
NhRect *r;
{
if (rect_cnt >= MAXRECT) {
if (wizard) pline("MAXRECT may be too small.");
return;
}
/* Check that this NhRect is not included in another one */
if (get_rect(r))
return;
rect[rect_cnt] = *r;
rect_cnt++;
if (rect_cnt >= MAXRECT) {
if (wizard)
pline("MAXRECT may be too small.");
return;
}
/* Check that this NhRect is not included in another one */
if (get_rect(r))
return;
rect[rect_cnt] = *r;
rect_cnt++;
}
/*
@@ -158,37 +163,39 @@ void
split_rects(r1, r2)
NhRect *r1, *r2;
{
NhRect r, old_r;
int i;
NhRect r, old_r;
int i;
old_r = *r1;
remove_rect(r1);
old_r = *r1;
remove_rect(r1);
/* Walk down since rect_cnt & rect[] will change... */
for (i=rect_cnt-1; i>=0; i--)
if (intersect(&rect[i], r2, &r))
split_rects(&rect[i], &r);
if (r2->ly - old_r.ly-1 > (old_r.hy < ROWNO - 1 ? 2*YLIM : YLIM+1)+4) {
r = old_r;
r.hy = r2->ly - 2;
add_rect(&r);
}
if (r2->lx - old_r.lx-1 > (old_r.hx < COLNO - 1 ? 2*XLIM : XLIM+1)+4) {
r = old_r;
r.hx = r2->lx - 2;
add_rect(&r);
}
if (old_r.hy - r2->hy-1 > (old_r.ly > 0 ? 2*YLIM : YLIM+1)+4) {
r = old_r;
r.ly = r2->hy + 2;
add_rect(&r);
}
if (old_r.hx - r2->hx-1 > (old_r.lx > 0 ? 2*XLIM : XLIM+1)+4) {
r = old_r;
r.lx = r2->hx + 2;
add_rect(&r);
}
/* Walk down since rect_cnt & rect[] will change... */
for (i = rect_cnt - 1; i >= 0; i--)
if (intersect(&rect[i], r2, &r))
split_rects(&rect[i], &r);
if (r2->ly - old_r.ly - 1
> (old_r.hy < ROWNO - 1 ? 2 * YLIM : YLIM + 1) + 4) {
r = old_r;
r.hy = r2->ly - 2;
add_rect(&r);
}
if (r2->lx - old_r.lx - 1
> (old_r.hx < COLNO - 1 ? 2 * XLIM : XLIM + 1) + 4) {
r = old_r;
r.hx = r2->lx - 2;
add_rect(&r);
}
if (old_r.hy - r2->hy - 1 > (old_r.ly > 0 ? 2 * YLIM : YLIM + 1) + 4) {
r = old_r;
r.ly = r2->hy + 2;
add_rect(&r);
}
if (old_r.hx - r2->hx - 1 > (old_r.lx > 0 ? 2 * XLIM : XLIM + 1) + 4) {
r = old_r;
r.lx = r2->hx + 2;
add_rect(&r);
}
}
/*rect.c*/
+401 -389
View File
File diff suppressed because it is too large Load Diff
+1058 -1020
View File
File diff suppressed because it is too large Load Diff
+111 -107
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 rip.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 rip.c $NHDT-Date: 1431192765 2015/05/09 17:32:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */
/* NetHack 3.6 rip.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.11 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -7,13 +7,14 @@
STATIC_DCL void FDECL(center, (int, char *));
#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS)
# define TEXT_TOMBSTONE
#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
|| defined(MSWIN_GRAPHICS)
#define TEXT_TOMBSTONE
#endif
#if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
# ifndef TEXT_TOMBSTONE
# define TEXT_TOMBSTONE
# endif
#ifndef TEXT_TOMBSTONE
#define TEXT_TOMBSTONE
#endif
#endif
#ifdef TEXT_TOMBSTONE
@@ -21,53 +22,54 @@ STATIC_DCL void FDECL(center, (int, char *));
#ifndef NH320_DEDICATION
/* A normal tombstone for end of game display. */
static const char *rip_txt[] = {
" ----------",
" / \\",
" / REST \\",
" / IN \\",
" / PEACE \\",
" / \\",
" | |", /* Name of player */
" | |", /* Amount of $ */
" | |", /* Type of death */
" | |", /* . */
" | |", /* . */
" | |", /* . */
" | 1001 |", /* Real year of death */
" *| * * * | *",
" _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
0
" ----------",
" / \\",
" / REST \\",
" / IN \\",
" / PEACE \\",
" / \\",
" | |", /* Name of player */
" | |", /* Amount of $ */
" | |", /* Type of death */
" | |", /* . */
" | |", /* . */
" | |", /* . */
" | 1001 |", /* Real year of death */
" *| * * * | *",
" _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 0
};
#define STONE_LINE_CENT 28 /* char[] element of center of stone face */
#else /* NH320_DEDICATION */
#define STONE_LINE_CENT 28 /* char[] element of center of stone face */
#else /* NH320_DEDICATION */
/* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
static const char *rip_txt[] = {
" ---------- ----------",
" / \\ / \\",
" / REST \\ / This \\",
" / IN \\ / release of \\",
" / PEACE \\ / NetHack is \\",
" / \\ / dedicated to \\",
" | | | the memory of |",
" | | | |",
" | | | Izchak Miller |",
" | | | 1935 - 1994 |",
" | | | |",
" | | | Ascended |",
" | 1001 | | |",
" * | * * * | * * | * * * | *",
" _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
0
" ---------- ----------",
" / \\ / \\",
" / REST \\ / This \\",
" / IN \\ / release of \\",
" / PEACE \\ / NetHack is \\",
" / \\ / dedicated to \\",
" | | | the memory of |",
" | | | |",
" | | | Izchak Miller |",
" | | | 1935 - 1994 |",
" | | | |",
" | | | Ascended |",
" | 1001 | | |",
" * | * * * | * * | * * * | *",
" _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/"
"|_)____",
0
};
#define STONE_LINE_CENT 19 /* char[] element of center of stone face */
#endif /* NH320_DEDICATION */
#define STONE_LINE_LEN 16 /* # chars that fit on one line
* (note 1 ' ' border)
*/
#define NAME_LINE 6 /* *char[] line # for player name */
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
#define DEATH_LINE 8 /* *char[] line # for death description */
#define YEAR_LINE 12 /* *char[] line # for year */
#define STONE_LINE_CENT 19 /* char[] element of center of stone face */
#endif /* NH320_DEDICATION */
#define STONE_LINE_LEN \
16 /* # chars that fit on one line \
* (note 1 ' ' border) \
*/
#define NAME_LINE 6 /* *char[] line # for player name */
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
#define DEATH_LINE 8 /* *char[] line # for death description */
#define YEAR_LINE 12 /* *char[] line # for year */
static char **rip;
@@ -76,83 +78,85 @@ center(line, text)
int line;
char *text;
{
register char *ip,*op;
ip = text;
op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)];
while(*ip) *op++ = *ip++;
register char *ip, *op;
ip = text;
op = &rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)];
while (*ip)
*op++ = *ip++;
}
void
genl_outrip(tmpwin, how, when)
winid tmpwin;
int how;
time_t when;
{
register char **dp;
register char *dpx;
char buf[BUFSZ];
long year;
register int x;
int line;
register char **dp;
register char *dpx;
char buf[BUFSZ];
long year;
register int x;
int line;
rip = dp = (char **) alloc(sizeof(rip_txt));
for (x = 0; rip_txt[x]; ++x)
dp[x] = dupstr(rip_txt[x]);
dp[x] = (char *)0;
rip = dp = (char **) alloc(sizeof(rip_txt));
for (x = 0; rip_txt[x]; ++x)
dp[x] = dupstr(rip_txt[x]);
dp[x] = (char *) 0;
/* Put name on stone */
Sprintf(buf, "%s", plname);
buf[STONE_LINE_LEN] = 0;
center(NAME_LINE, buf);
/* Put name on stone */
Sprintf(buf, "%s", plname);
buf[STONE_LINE_LEN] = 0;
center(NAME_LINE, buf);
/* Put $ on stone */
Sprintf(buf, "%ld Au", done_money);
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
center(GOLD_LINE, buf);
/* Put $ on stone */
Sprintf(buf, "%ld Au", done_money);
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
center(GOLD_LINE, buf);
/* Put together death description */
formatkiller(buf, sizeof buf, how);
/* Put together death description */
formatkiller(buf, sizeof buf, how);
/* Put death type on stone */
for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
register int i,i0;
char tmpchar;
/* Put death type on stone */
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
register int i, i0;
char tmpchar;
if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
for(i = STONE_LINE_LEN;
((i0 > STONE_LINE_LEN) && i); i--)
if(dpx[i] == ' ') i0 = i;
if(!i) i0 = STONE_LINE_LEN;
}
tmpchar = dpx[i0];
dpx[i0] = 0;
center(line, dpx);
if (tmpchar != ' ') {
dpx[i0] = tmpchar;
dpx= &dpx[i0];
} else dpx= &dpx[i0+1];
}
if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
if (dpx[i] == ' ')
i0 = i;
if (!i)
i0 = STONE_LINE_LEN;
}
tmpchar = dpx[i0];
dpx[i0] = 0;
center(line, dpx);
if (tmpchar != ' ') {
dpx[i0] = tmpchar;
dpx = &dpx[i0];
} else
dpx = &dpx[i0 + 1];
}
/* Put year on stone */
year = yyyymmdd(when) / 10000L;
Sprintf(buf, "%4ld", year);
center(YEAR_LINE, buf);
/* Put year on stone */
year = yyyymmdd(when) / 10000L;
Sprintf(buf, "%4ld", year);
center(YEAR_LINE, buf);
putstr(tmpwin, 0, "");
for(; *dp; dp++)
putstr(tmpwin, 0, *dp);
putstr(tmpwin, 0, "");
for (; *dp; dp++)
putstr(tmpwin, 0, *dp);
putstr(tmpwin, 0, "");
putstr(tmpwin, 0, "");
putstr(tmpwin, 0, "");
putstr(tmpwin, 0, "");
for (x = 0; rip_txt[x]; x++) {
free((genericptr_t)rip[x]);
}
free((genericptr_t)rip);
rip = 0;
for (x = 0; rip_txt[x]; x++) {
free((genericptr_t) rip[x]);
}
free((genericptr_t) rip);
rip = 0;
}
#endif /* TEXT_TOMBSTONE */
#endif /* TEXT_TOMBSTONE */
/*rip.c*/
+94 -90
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 rnd.c $NHDT-Date: 1426465440 2015/03/16 00:24:00 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.8 $ */
/* NetHack 3.6 rnd.c $NHDT-Date: 1431192762 2015/05/09 17:32:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.14 $ */
/* NetHack 3.6 rnd.c $Date: 2009/05/06 10:47:41 $ $Revision: 1.7 $ */
/* SCCS Id: @(#)rnd.c 3.5 2004/08/27 */
/* NetHack may be freely redistributed. See license for details. */
@@ -6,126 +6,125 @@
#include "hack.h"
/* "Rand()"s definition is determined by [OS]conf.h */
#if defined(LINT) && defined(UNIX) /* rand() is long... */
#if defined(LINT) && defined(UNIX) /* rand() is long... */
extern int NDECL(rand);
#define RND(x) (rand() % x)
#define RND(x) (rand() % x)
#else /* LINT */
# if defined(UNIX) || defined(RANDOM)
#define RND(x) (int)(Rand() % (long)(x))
# else
#if defined(UNIX) || defined(RANDOM)
#define RND(x) (int)(Rand() % (long) (x))
#else
/* Good luck: the bottom order bits are cyclic. */
#define RND(x) (int)((Rand()>>3) % (x))
# endif
#define RND(x) (int)((Rand() >> 3) % (x))
#endif
#endif /* LINT */
int
rn2(x) /* 0 <= rn2(x) < x */
int rn2(x) /* 0 <= rn2(x) < x */
register int x;
{
#ifdef BETA
if (x <= 0) {
debugpline1("rn2(%d) attempted", x);
return(0);
}
x = RND(x);
return(x);
if (x <= 0) {
debugpline1("rn2(%d) attempted", x);
return (0);
}
x = RND(x);
return (x);
#else
return(RND(x));
return (RND(x));
#endif
}
int
rnl(x) /* 0 <= rnl(x) < x; sometimes subtracting Luck */
register int x; /* good luck approaches 0, bad luck approaches (x-1) */
int rnl(x) /* 0 <= rnl(x) < x; sometimes subtracting Luck */
register int x; /* good luck approaches 0, bad luck approaches (x-1) */
{
register int i, adjustment;
register int i, adjustment;
#ifdef BETA
if (x <= 0) {
debugpline1("rnl(%d) attempted", x);
return(0);
}
if (x <= 0) {
debugpline1("rnl(%d) attempted", x);
return (0);
}
#endif
adjustment = Luck;
if (x <= 15) {
/* for small ranges, use Luck/3 (rounded away from 0);
also guard against architecture-specific differences
of integer division involving negative values */
adjustment = (abs(adjustment) + 1) / 3 * sgn(adjustment);
/*
* 11..13 -> 4
* 8..10 -> 3
* 5.. 7 -> 2
* 2.. 4 -> 1
* -1,0,1 -> 0 (no adjustment)
* -4..-2 -> -1
* -7..-5 -> -2
* -10..-8 -> -3
* -13..-11-> -4
*/
}
adjustment = Luck;
if (x <= 15) {
/* for small ranges, use Luck/3 (rounded away from 0);
also guard against architecture-specific differences
of integer division involving negative values */
adjustment = (abs(adjustment) + 1) / 3 * sgn(adjustment);
/*
* 11..13 -> 4
* 8..10 -> 3
* 5.. 7 -> 2
* 2.. 4 -> 1
* -1,0,1 -> 0 (no adjustment)
* -4..-2 -> -1
* -7..-5 -> -2
* -10..-8 -> -3
* -13..-11-> -4
*/
}
i = RND(x);
if (adjustment && rn2(37 + abs(adjustment))) {
i -= adjustment;
if (i < 0) i = 0;
else if (i >= x) i = x-1;
}
return i;
i = RND(x);
if (adjustment && rn2(37 + abs(adjustment))) {
i -= adjustment;
if (i < 0)
i = 0;
else if (i >= x)
i = x - 1;
}
return i;
}
int
rnd(x) /* 1 <= rnd(x) <= x */
int rnd(x) /* 1 <= rnd(x) <= x */
register int x;
{
#ifdef BETA
if (x <= 0) {
debugpline1("rnd(%d) attempted", x);
return(1);
}
x = RND(x)+1;
return(x);
if (x <= 0) {
debugpline1("rnd(%d) attempted", x);
return (1);
}
x = RND(x) + 1;
return (x);
#else
return(RND(x)+1);
return (RND(x) + 1);
#endif
}
int
d(n,x) /* n <= d(n,x) <= (n*x) */
int d(n, x) /* n <= d(n,x) <= (n*x) */
register int n, x;
{
register int tmp = n;
register int tmp = n;
#ifdef BETA
if (x < 0 || n < 0 || (x == 0 && n != 0)) {
debugpline2("d(%d,%d) attempted", n, x);
return(1);
}
if (x < 0 || n < 0 || (x == 0 && n != 0)) {
debugpline2("d(%d,%d) attempted", n, x);
return (1);
}
#endif
while(n--) tmp += RND(x);
return(tmp); /* Alea iacta est. -- J.C. */
while (n--)
tmp += RND(x);
return (tmp); /* Alea iacta est. -- J.C. */
}
int
rne(x)
register int x;
{
register int tmp, utmp;
register int tmp, utmp;
utmp = (u.ulevel < 15) ? 5 : u.ulevel/3;
tmp = 1;
while (tmp < utmp && !rn2(x))
tmp++;
return tmp;
utmp = (u.ulevel < 15) ? 5 : u.ulevel / 3;
tmp = 1;
while (tmp < utmp && !rn2(x))
tmp++;
return tmp;
/* was:
* tmp = 1;
* while(!rn2(x)) tmp++;
* return(min(tmp,(u.ulevel < 15) ? 5 : u.ulevel/3));
* which is clearer but less efficient and stands a vanishingly
* small chance of overflowing tmp
*/
/* was:
* tmp = 1;
* while(!rn2(x)) tmp++;
* return(min(tmp,(u.ulevel < 15) ? 5 : u.ulevel/3));
* which is clearer but less efficient and stands a vanishingly
* small chance of overflowing tmp
*/
}
int
@@ -133,17 +132,22 @@ rnz(i)
int i;
{
#ifdef LINT
int x = i;
int tmp = 1000;
int x = i;
int tmp = 1000;
#else
register long x = i;
register long tmp = 1000;
register long x = i;
register long tmp = 1000;
#endif
tmp += rn2(1000);
tmp *= rne(4);
if (rn2(2)) { x *= tmp; x /= 1000; }
else { x *= 1000; x /= tmp; }
return((int)x);
tmp += rn2(1000);
tmp *= rne(4);
if (rn2(2)) {
x *= tmp;
x /= 1000;
} else {
x *= 1000;
x /= tmp;
}
return ((int) x);
}
/*rnd.c*/
+1598 -1245
View File
File diff suppressed because it is too large Load Diff
+381 -364
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 rumors.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 rumors.c $NHDT-Date: 1431192757 2015/05/09 17:32:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.6 rumors.c $Date: 2012/05/11 22:36:33 $ $Revision: 1.17 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -51,7 +51,7 @@ static unsigned long true_rumor_start, false_rumor_start;
/* rumor end offsets are signed because they're compared with [dlb_]ftell() */
static long true_rumor_end, false_rumor_end;
/* oracles are handled differently from rumors... */
static int oracle_flg = 0; /* -1=>don't use, 0=>need init, 1=>init done */
static int oracle_flg = 0; /* -1=>don't use, 0=>need init, 1=>init done */
static unsigned oracle_cnt = 0;
static unsigned long *oracle_loc = 0;
@@ -59,26 +59,26 @@ STATIC_OVL void
init_rumors(fp)
dlb *fp;
{
static const char rumors_header[] = "%d,%ld,%lx;%d,%ld,%lx;0,0,%lx\n";
int true_count, false_count; /* in file but not used here */
unsigned long eof_offset;
char line[BUFSZ];
static const char rumors_header[] = "%d,%ld,%lx;%d,%ld,%lx;0,0,%lx\n";
int true_count, false_count; /* in file but not used here */
unsigned long eof_offset;
char line[BUFSZ];
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment */
(void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, rumors_header,
&true_count, &true_rumor_size, &true_rumor_start,
&false_count, &false_rumor_size, &false_rumor_start,
&eof_offset) == 7 &&
true_rumor_size > 0L && false_rumor_size > 0L) {
true_rumor_end = (long)true_rumor_start + true_rumor_size;
/* assert( true_rumor_end == false_rumor_start ); */
false_rumor_end = (long)false_rumor_start + false_rumor_size;
/* assert( false_rumor_end == eof_offset ); */
} else {
true_rumor_size = -1L; /* init failed */
(void) dlb_fclose(fp);
}
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment */
(void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, rumors_header, &true_count, &true_rumor_size,
&true_rumor_start, &false_count, &false_rumor_size,
&false_rumor_start, &eof_offset) == 7
&& true_rumor_size > 0L
&& false_rumor_size > 0L) {
true_rumor_end = (long) true_rumor_start + true_rumor_size;
/* assert( true_rumor_end == false_rumor_start ); */
false_rumor_end = (long) false_rumor_start + false_rumor_size;
/* assert( false_rumor_end == eof_offset ); */
} else {
true_rumor_size = -1L; /* init failed */
(void) dlb_fclose(fp);
}
}
/* exclude_cookie is a hack used because we sometimes want to get rumors in a
@@ -90,86 +90,90 @@ char *
getrumor(truth, rumor_buf, exclude_cookie)
int truth; /* 1=true, -1=false, 0=either */
char *rumor_buf;
boolean exclude_cookie;
boolean exclude_cookie;
{
dlb *rumors;
long tidbit, beginning;
char *endp, line[BUFSZ], xbuf[BUFSZ];
dlb *rumors;
long tidbit, beginning;
char *endp, line[BUFSZ], xbuf[BUFSZ];
rumor_buf[0] = '\0';
if (true_rumor_size < 0L) /* we couldn't open RUMORFILE */
return rumor_buf;
rumor_buf[0] = '\0';
if (true_rumor_size < 0L) /* we couldn't open RUMORFILE */
return rumor_buf;
rumors = dlb_fopen(RUMORFILE, "r");
rumors = dlb_fopen(RUMORFILE, "r");
if (rumors) {
int count = 0;
int adjtruth;
if (rumors) {
int count = 0;
int adjtruth;
do {
rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors);
if (true_rumor_size < 0L) { /* init failed */
Sprintf(rumor_buf, "Error reading \"%.80s\".",
RUMORFILE);
return rumor_buf;
}
}
/*
* input: 1 0 -1
* rn2 \ +1 2=T 1=T 0=F
* adj./ +0 1=T 0=F -1=F
*/
switch (adjtruth = truth + rn2(2)) {
case 2: /*(might let a bogus input arg sneak thru)*/
case 1: beginning = (long)true_rumor_start;
tidbit = Rand() % true_rumor_size;
break;
case 0: /* once here, 0 => false rather than "either"*/
case -1: beginning = (long)false_rumor_start;
tidbit = Rand() % false_rumor_size;
break;
default:
impossible("strange truth value for rumor");
return strcpy(rumor_buf, "Oops...");
}
(void) dlb_fseek(rumors, beginning + tidbit, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors);
if (!dlb_fgets(line, sizeof line, rumors) ||
(adjtruth > 0 && dlb_ftell(rumors) > true_rumor_end)) {
/* reached end of rumors -- go back to beginning */
(void) dlb_fseek(rumors, beginning, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors);
}
if ((endp = index(line, '\n')) != 0) *endp = 0;
Strcat(rumor_buf, xcrypt(line, xbuf));
} while (count++ < 50 && exclude_cookie &&
(strstri(rumor_buf, "fortune") || strstri(rumor_buf, "pity")));
(void) dlb_fclose(rumors);
if (count >= 50)
impossible("Can't find non-cookie rumor?");
else if (!in_mklev) /* avoid exercizing wisdom for graffiti */
exercise(A_WIS, (adjtruth > 0));
} else {
pline("Can't open rumors file!");
true_rumor_size = -1; /* don't try to open it again */
}
do {
rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors);
if (true_rumor_size < 0L) { /* init failed */
Sprintf(rumor_buf, "Error reading \"%.80s\".", RUMORFILE);
return rumor_buf;
}
}
/*
* input: 1 0 -1
* rn2 \ +1 2=T 1=T 0=F
* adj./ +0 1=T 0=F -1=F
*/
switch (adjtruth = truth + rn2(2)) {
case 2: /*(might let a bogus input arg sneak thru)*/
case 1:
beginning = (long) true_rumor_start;
tidbit = Rand() % true_rumor_size;
break;
case 0: /* once here, 0 => false rather than "either"*/
case -1:
beginning = (long) false_rumor_start;
tidbit = Rand() % false_rumor_size;
break;
default:
impossible("strange truth value for rumor");
return strcpy(rumor_buf, "Oops...");
}
(void) dlb_fseek(rumors, beginning + tidbit, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors);
if (!dlb_fgets(line, sizeof line, rumors)
|| (adjtruth > 0 && dlb_ftell(rumors) > true_rumor_end)) {
/* reached end of rumors -- go back to beginning */
(void) dlb_fseek(rumors, beginning, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors);
}
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Strcat(rumor_buf, xcrypt(line, xbuf));
} while (
count++ < 50 && exclude_cookie
&& (strstri(rumor_buf, "fortune") || strstri(rumor_buf, "pity")));
(void) dlb_fclose(rumors);
if (count >= 50)
impossible("Can't find non-cookie rumor?");
else if (!in_mklev) /* avoid exercizing wisdom for graffiti */
exercise(A_WIS, (adjtruth > 0));
} else {
pline("Can't open rumors file!");
true_rumor_size = -1; /* don't try to open it again */
}
/* this is safe either way, so do it always since we can't get the definition
* out of makedefs.c
*/
#define PAD_RUMORS_TO
#ifdef PAD_RUMORS_TO
/* remove padding */
{
char *x = eos(rumor_buf) - 1;
/* remove padding */
{
char *x = eos(rumor_buf) - 1;
while(x > rumor_buf && *x=='_') x--;
*++x = '\n';
*x = '\0';
}
while (x > rumor_buf && *x == '_')
x--;
*++x = '\n';
*x = '\0';
}
#endif
return rumor_buf;
return rumor_buf;
}
/*
@@ -178,95 +182,101 @@ boolean exclude_cookie;
void
rumor_check()
{
dlb *rumors;
winid tmpwin;
char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ];
dlb *rumors;
winid tmpwin;
char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ];
if (true_rumor_size < 0L) { /* we couldn't open RUMORFILE */
no_rumors:
pline("rumors not accessible.");
return;
}
if (true_rumor_size < 0L) { /* we couldn't open RUMORFILE */
no_rumors:
pline("rumors not accessible.");
return;
}
rumors = dlb_fopen(RUMORFILE, "r");
rumors = dlb_fopen(RUMORFILE, "r");
if (rumors) {
long ftell_rumor_start = 0L;
if (rumors) {
long ftell_rumor_start = 0L;
rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors);
if (true_rumor_size < 0L) goto no_rumors; /* init failed */
}
tmpwin = create_nhwindow(NHW_TEXT);
rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors);
if (true_rumor_size < 0L)
goto no_rumors; /* init failed */
}
tmpwin = create_nhwindow(NHW_TEXT);
/*
* reveal the values.
*/
/*
* reveal the values.
*/
Sprintf(rumor_buf,
"T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long)true_rumor_start, true_rumor_start,
true_rumor_end, (unsigned long)true_rumor_end,
true_rumor_size, (unsigned long)true_rumor_size);
putstr(tmpwin, 0, rumor_buf);
Sprintf(rumor_buf,
"F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long)false_rumor_start, false_rumor_start,
false_rumor_end, (unsigned long)false_rumor_end,
false_rumor_size, (unsigned long)false_rumor_size);
putstr(tmpwin, 0, rumor_buf);
/*
* check the first rumor (start of true rumors) by
* skipping the first two lines.
*
* Then seek to the start of the false rumors (based on
* the value read in rumors, and display it.
*/
rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long)true_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0) *endp = 0;
Sprintf(rumor_buf, "T %06ld %s", ftell_rumor_start,
xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
/* find last true rumor */
while (dlb_fgets(line, sizeof line, rumors) &&
dlb_ftell(rumors) < true_rumor_end)
continue;
if ((endp = index(line, '\n')) != 0) *endp = 0;
Sprintf(rumor_buf, " %6s %s", "", xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
Sprintf(
rumor_buf,
"T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long) true_rumor_start, true_rumor_start, true_rumor_end,
(unsigned long) true_rumor_end, true_rumor_size,
(unsigned long) true_rumor_size);
putstr(tmpwin, 0, rumor_buf);
rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long)false_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0) *endp = 0;
Sprintf(rumor_buf, "F %06ld %s", ftell_rumor_start,
xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
/* find last false rumor */
while (dlb_fgets(line, sizeof line, rumors) &&
dlb_ftell(rumors) < false_rumor_end)
continue;
if ((endp = index(line, '\n')) != 0) *endp = 0;
Sprintf(rumor_buf, " %6s %s", "", xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
Sprintf(
rumor_buf,
"F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long) false_rumor_start, false_rumor_start, false_rumor_end,
(unsigned long) false_rumor_end, false_rumor_size,
(unsigned long) false_rumor_size);
putstr(tmpwin, 0, rumor_buf);
(void) dlb_fclose(rumors);
display_nhwindow(tmpwin, TRUE);
destroy_nhwindow(tmpwin);
} else {
impossible("Can't open rumors file!");
true_rumor_size = -1; /* don't try to open it again */
}
/*
* check the first rumor (start of true rumors) by
* skipping the first two lines.
*
* Then seek to the start of the false rumors (based on
* the value read in rumors, and display it.
*/
rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long) true_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Sprintf(rumor_buf, "T %06ld %s", ftell_rumor_start,
xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
/* find last true rumor */
while (dlb_fgets(line, sizeof line, rumors)
&& dlb_ftell(rumors) < true_rumor_end)
continue;
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Sprintf(rumor_buf, " %6s %s", "", xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long) false_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Sprintf(rumor_buf, "F %06ld %s", ftell_rumor_start,
xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
/* find last false rumor */
while (dlb_fgets(line, sizeof line, rumors)
&& dlb_ftell(rumors) < false_rumor_end)
continue;
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Sprintf(rumor_buf, " %6s %s", "", xcrypt(line, xbuf));
putstr(tmpwin, 0, rumor_buf);
(void) dlb_fclose(rumors);
display_nhwindow(tmpwin, TRUE);
destroy_nhwindow(tmpwin);
} else {
impossible("Can't open rumors file!");
true_rumor_size = -1; /* don't try to open it again */
}
}
/* Gets a random line of text from file 'fname', and returns it. */
char *
get_rnd_text(fname, buf)
@@ -280,126 +290,129 @@ char *buf;
fh = dlb_fopen(fname, "r");
if (fh) {
/* TODO: cache sizetxt, starttxt, endtxt. maybe cache file contents? */
long sizetxt = 0, starttxt = 0, endtxt = 0, tidbit = 0;
char *endp, line[BUFSZ], xbuf[BUFSZ];
(void) dlb_fgets(line, sizeof line, fh); /* skip "don't edit" comment */
/* TODO: cache sizetxt, starttxt, endtxt. maybe cache file contents?
*/
long sizetxt = 0, starttxt = 0, endtxt = 0, tidbit = 0;
char *endp, line[BUFSZ], xbuf[BUFSZ];
(void) dlb_fgets(line, sizeof line,
fh); /* skip "don't edit" comment */
(void) dlb_fseek(fh, 0L, SEEK_CUR);
starttxt = dlb_ftell(fh);
(void) dlb_fseek(fh, 0L, SEEK_END);
endtxt = dlb_ftell(fh);
sizetxt = endtxt - starttxt;
tidbit = Rand() % sizetxt;
(void) dlb_fseek(fh, 0L, SEEK_CUR);
starttxt = dlb_ftell(fh);
(void) dlb_fseek(fh, 0L, SEEK_END);
endtxt = dlb_ftell(fh);
sizetxt = endtxt - starttxt;
tidbit = Rand() % sizetxt;
(void) dlb_fseek(fh, starttxt + tidbit, SEEK_SET);
(void) dlb_fgets(line, sizeof line, fh);
if (!dlb_fgets(line, sizeof line, fh)) {
(void) dlb_fseek(fh, starttxt, SEEK_SET);
(void) dlb_fgets(line, sizeof line, fh);
}
if ((endp = index(line, '\n')) != 0) *endp = 0;
Strcat(buf, xcrypt(line, xbuf));
(void) dlb_fclose(fh);
} else impossible("Can't open file %s!", fname);
(void) dlb_fseek(fh, starttxt + tidbit, SEEK_SET);
(void) dlb_fgets(line, sizeof line, fh);
if (!dlb_fgets(line, sizeof line, fh)) {
(void) dlb_fseek(fh, starttxt, SEEK_SET);
(void) dlb_fgets(line, sizeof line, fh);
}
if ((endp = index(line, '\n')) != 0)
*endp = 0;
Strcat(buf, xcrypt(line, xbuf));
(void) dlb_fclose(fh);
} else
impossible("Can't open file %s!", fname);
return buf;
}
void
outrumor(truth, mechanism)
int truth; /* 1=true, -1=false, 0=either */
int mechanism;
{
static const char fortune_msg[] =
"This cookie has a scrap of paper inside.";
const char *line;
char buf[BUFSZ];
boolean reading = (mechanism == BY_COOKIE ||
mechanism == BY_PAPER);
static const char fortune_msg[] =
"This cookie has a scrap of paper inside.";
const char *line;
char buf[BUFSZ];
boolean reading = (mechanism == BY_COOKIE || mechanism == BY_PAPER);
if (reading) {
/* deal with various things that prevent reading */
if (is_fainted() && mechanism == BY_COOKIE)
return;
else if (Blind) {
if (mechanism == BY_COOKIE)
pline(fortune_msg);
pline("What a pity that you cannot read it!");
return;
}
}
line = getrumor(truth, buf, reading ? FALSE : TRUE);
if (!*line)
line = "NetHack rumors file closed for renovation.";
switch (mechanism) {
case BY_ORACLE:
/* Oracle delivers the rumor */
pline("True to her word, the Oracle %ssays: ",
(!rn2(4) ? "offhandedly " : (!rn2(3) ? "casually " :
(rn2(2) ? "nonchalantly " : ""))));
verbalize1(line);
/* [WIS exercized by getrumor()] */
return;
case BY_COOKIE:
pline(fortune_msg);
/* FALLTHRU */
case BY_PAPER:
pline("It reads:");
break;
}
pline1(line);
if (reading) {
/* deal with various things that prevent reading */
if (is_fainted() && mechanism == BY_COOKIE)
return;
else if (Blind) {
if (mechanism == BY_COOKIE)
pline(fortune_msg);
pline("What a pity that you cannot read it!");
return;
}
}
line = getrumor(truth, buf, reading ? FALSE : TRUE);
if (!*line)
line = "NetHack rumors file closed for renovation.";
switch (mechanism) {
case BY_ORACLE:
/* Oracle delivers the rumor */
pline("True to her word, the Oracle %ssays: ",
(!rn2(4) ? "offhandedly "
: (!rn2(3) ? "casually "
: (rn2(2) ? "nonchalantly " : ""))));
verbalize1(line);
/* [WIS exercized by getrumor()] */
return;
case BY_COOKIE:
pline(fortune_msg);
/* FALLTHRU */
case BY_PAPER:
pline("It reads:");
break;
}
pline1(line);
}
STATIC_OVL void
init_oracles(fp)
dlb *fp;
{
register int i;
char line[BUFSZ];
int cnt = 0;
register int i;
char line[BUFSZ];
int cnt = 0;
/* this assumes we're only called once */
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment*/
(void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, "%5d\n", &cnt) == 1 && cnt > 0) {
oracle_cnt = (unsigned) cnt;
oracle_loc = (unsigned long *)alloc((unsigned)cnt * sizeof (long));
for (i = 0; i < cnt; i++) {
(void) dlb_fgets(line, sizeof line, fp);
(void) sscanf(line, "%5lx\n", &oracle_loc[i]);
}
}
return;
/* this assumes we're only called once */
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment*/
(void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, "%5d\n", &cnt) == 1 && cnt > 0) {
oracle_cnt = (unsigned) cnt;
oracle_loc = (unsigned long *) alloc((unsigned) cnt * sizeof(long));
for (i = 0; i < cnt; i++) {
(void) dlb_fgets(line, sizeof line, fp);
(void) sscanf(line, "%5lx\n", &oracle_loc[i]);
}
}
return;
}
void
save_oracles(fd, mode)
int fd, mode;
{
if (perform_bwrite(mode)) {
bwrite(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt);
if (oracle_cnt)
bwrite(fd, (genericptr_t)oracle_loc, oracle_cnt*sizeof (long));
}
if (release_data(mode)) {
if (oracle_cnt) {
free((genericptr_t)oracle_loc);
oracle_loc = 0, oracle_cnt = 0, oracle_flg = 0;
}
}
if (perform_bwrite(mode)) {
bwrite(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt);
if (oracle_cnt)
bwrite(fd, (genericptr_t) oracle_loc, oracle_cnt * sizeof(long));
}
if (release_data(mode)) {
if (oracle_cnt) {
free((genericptr_t) oracle_loc);
oracle_loc = 0, oracle_cnt = 0, oracle_flg = 0;
}
}
}
void
restore_oracles(fd)
int fd;
{
mread(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt);
if (oracle_cnt) {
oracle_loc = (unsigned long *)alloc(oracle_cnt * sizeof (long));
mread(fd, (genericptr_t) oracle_loc, oracle_cnt * sizeof (long));
oracle_flg = 1; /* no need to call init_oracles() */
}
mread(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt);
if (oracle_cnt) {
oracle_loc = (unsigned long *) alloc(oracle_cnt * sizeof(long));
mread(fd, (genericptr_t) oracle_loc, oracle_cnt * sizeof(long));
oracle_flg = 1; /* no need to call init_oracles() */
}
}
void
@@ -407,126 +420,130 @@ outoracle(special, delphi)
boolean special;
boolean delphi;
{
char line[COLNO];
char *endp;
dlb *oracles;
int oracle_idx;
char xbuf[BUFSZ];
char line[COLNO];
char *endp;
dlb *oracles;
int oracle_idx;
char xbuf[BUFSZ];
if(oracle_flg < 0 || /* couldn't open ORACLEFILE */
(oracle_flg > 0 && oracle_cnt == 0)) /* oracles already exhausted */
return;
if (oracle_flg < 0 || /* couldn't open ORACLEFILE */
(oracle_flg > 0 && oracle_cnt == 0)) /* oracles already exhausted */
return;
oracles = dlb_fopen(ORACLEFILE, "r");
oracles = dlb_fopen(ORACLEFILE, "r");
if (oracles) {
winid tmpwin;
if (oracle_flg == 0) { /* if this is the first outoracle() */
init_oracles(oracles);
oracle_flg = 1;
if (oracle_cnt == 0) return;
}
/* oracle_loc[0] is the special oracle; */
/* oracle_loc[1..oracle_cnt-1] are normal ones */
if (oracle_cnt <= 1 && !special) return; /*(shouldn't happen)*/
oracle_idx = special ? 0 : rnd((int) oracle_cnt - 1);
(void) dlb_fseek(oracles, (long)oracle_loc[oracle_idx],
SEEK_SET);
if (!special) /* move offset of very last one into this slot */
oracle_loc[oracle_idx] = oracle_loc[--oracle_cnt];
if (oracles) {
winid tmpwin;
if (oracle_flg == 0) { /* if this is the first outoracle() */
init_oracles(oracles);
oracle_flg = 1;
if (oracle_cnt == 0)
return;
}
/* oracle_loc[0] is the special oracle; */
/* oracle_loc[1..oracle_cnt-1] are normal ones */
if (oracle_cnt <= 1 && !special)
return; /*(shouldn't happen)*/
oracle_idx = special ? 0 : rnd((int) oracle_cnt - 1);
(void) dlb_fseek(oracles, (long) oracle_loc[oracle_idx], SEEK_SET);
if (!special) /* move offset of very last one into this slot */
oracle_loc[oracle_idx] = oracle_loc[--oracle_cnt];
tmpwin = create_nhwindow(NHW_TEXT);
if (delphi)
putstr(tmpwin, 0, special ?
"The Oracle scornfully takes all your money and says:" :
"The Oracle meditates for a moment and then intones:");
else
putstr(tmpwin, 0, "The message reads:");
putstr(tmpwin, 0, "");
tmpwin = create_nhwindow(NHW_TEXT);
if (delphi)
putstr(
tmpwin, 0,
special
? "The Oracle scornfully takes all your money and says:"
: "The Oracle meditates for a moment and then intones:");
else
putstr(tmpwin, 0, "The message reads:");
putstr(tmpwin, 0, "");
while(dlb_fgets(line, COLNO, oracles) && strcmp(line,"---\n")) {
if ((endp = index(line, '\n')) != 0) *endp = 0;
putstr(tmpwin, 0, xcrypt(line, xbuf));
}
display_nhwindow(tmpwin, TRUE);
destroy_nhwindow(tmpwin);
(void) dlb_fclose(oracles);
} else {
pline("Can't open oracles file!");
oracle_flg = -1; /* don't try to open it again */
}
while (dlb_fgets(line, COLNO, oracles) && strcmp(line, "---\n")) {
if ((endp = index(line, '\n')) != 0)
*endp = 0;
putstr(tmpwin, 0, xcrypt(line, xbuf));
}
display_nhwindow(tmpwin, TRUE);
destroy_nhwindow(tmpwin);
(void) dlb_fclose(oracles);
} else {
pline("Can't open oracles file!");
oracle_flg = -1; /* don't try to open it again */
}
}
int
doconsult(oracl)
register struct monst *oracl;
{
long umoney;
int u_pay, minor_cost = 50, major_cost = 500 + 50 * u.ulevel;
int add_xpts;
char qbuf[QBUFSZ];
long umoney;
int u_pay, minor_cost = 50, major_cost = 500 + 50 * u.ulevel;
int add_xpts;
char qbuf[QBUFSZ];
multi = 0;
umoney = money_cnt(invent);
multi = 0;
umoney = money_cnt(invent);
if (!oracl) {
There("is no one here to consult.");
return 0;
} else if (!oracl->mpeaceful) {
pline("%s is in no mood for consultations.", Monnam(oracl));
return 0;
} else if (!umoney) {
You("have no money.");
return 0;
}
if (!oracl) {
There("is no one here to consult.");
return 0;
} else if (!oracl->mpeaceful) {
pline("%s is in no mood for consultations.", Monnam(oracl));
return 0;
} else if (!umoney) {
You("have no money.");
return 0;
}
Sprintf(qbuf,
"\"Wilt thou settle for a minor consultation?\" (%d %s)",
minor_cost, currency((long)minor_cost));
switch (ynq(qbuf)) {
default:
case 'q':
return 0;
case 'y':
if (umoney < (long)minor_cost) {
You("don't even have enough money for that!");
return 0;
}
u_pay = minor_cost;
break;
case 'n':
if (umoney <= (long)minor_cost || /* don't even ask */
(oracle_cnt == 1 || oracle_flg < 0)) return 0;
Sprintf(qbuf,
"\"Then dost thou desire a major one?\" (%d %s)",
major_cost, currency((long)major_cost));
if (yn(qbuf) != 'y') return 0;
u_pay = (umoney < (long)major_cost) ? (int)umoney : major_cost;
break;
}
money2mon(oracl, (long)u_pay);
context.botl = 1;
add_xpts = 0; /* first oracle of each type gives experience points */
if (u_pay == minor_cost) {
outrumor(1, BY_ORACLE);
if (!u.uevent.minor_oracle)
add_xpts = u_pay / (u.uevent.major_oracle ? 25 : 10);
/* 5 pts if very 1st, or 2 pts if major already done */
u.uevent.minor_oracle = TRUE;
} else {
boolean cheapskate = u_pay < major_cost;
outoracle(cheapskate, TRUE);
if (!cheapskate && !u.uevent.major_oracle)
add_xpts = u_pay / (u.uevent.minor_oracle ? 25 : 10);
/* ~100 pts if very 1st, ~40 pts if minor already done */
u.uevent.major_oracle = TRUE;
exercise(A_WIS, !cheapskate);
}
if (add_xpts) {
more_experienced(add_xpts, u_pay/50);
newexplevel();
}
return 1;
Sprintf(qbuf, "\"Wilt thou settle for a minor consultation?\" (%d %s)",
minor_cost, currency((long) minor_cost));
switch (ynq(qbuf)) {
default:
case 'q':
return 0;
case 'y':
if (umoney < (long) minor_cost) {
You("don't even have enough money for that!");
return 0;
}
u_pay = minor_cost;
break;
case 'n':
if (umoney <= (long) minor_cost || /* don't even ask */
(oracle_cnt == 1 || oracle_flg < 0))
return 0;
Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)",
major_cost, currency((long) major_cost));
if (yn(qbuf) != 'y')
return 0;
u_pay = (umoney < (long) major_cost) ? (int) umoney : major_cost;
break;
}
money2mon(oracl, (long) u_pay);
context.botl = 1;
add_xpts = 0; /* first oracle of each type gives experience points */
if (u_pay == minor_cost) {
outrumor(1, BY_ORACLE);
if (!u.uevent.minor_oracle)
add_xpts = u_pay / (u.uevent.major_oracle ? 25 : 10);
/* 5 pts if very 1st, or 2 pts if major already done */
u.uevent.minor_oracle = TRUE;
} else {
boolean cheapskate = u_pay < major_cost;
outoracle(cheapskate, TRUE);
if (!cheapskate && !u.uevent.major_oracle)
add_xpts = u_pay / (u.uevent.minor_oracle ? 25 : 10);
/* ~100 pts if very 1st, ~40 pts if minor already done */
u.uevent.major_oracle = TRUE;
exercise(A_WIS, !cheapskate);
}
if (add_xpts) {
more_experienced(add_xpts, u_pay / 50);
newexplevel();
}
return 1;
}
/*rumors.c*/
+938 -900
View File
File diff suppressed because it is too large Load Diff
+3169 -3027
View File
File diff suppressed because it is too large Load Diff
+553 -435
View File
File diff suppressed because it is too large Load Diff
+418 -399
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 sit.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 sit.c $NHDT-Date: 1431192756 2015/05/09 17:32:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.48 $ */
/* NetHack 3.6 sit.c $Date: 2012/02/06 04:17:25 $ $Revision: 1.31 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -9,429 +9,448 @@
void
take_gold()
{
struct obj *otmp, *nobj;
int lost_money = 0;
for (otmp = invent; otmp; otmp = nobj) {
nobj = otmp->nobj;
if (otmp->oclass == COIN_CLASS) {
lost_money = 1;
remove_worn_item(otmp, FALSE);
delobj(otmp);
}
}
if (!lost_money) {
You_feel("a strange sensation.");
} else {
You("notice you have no money!");
context.botl = 1;
}
struct obj *otmp, *nobj;
int lost_money = 0;
for (otmp = invent; otmp; otmp = nobj) {
nobj = otmp->nobj;
if (otmp->oclass == COIN_CLASS) {
lost_money = 1;
remove_worn_item(otmp, FALSE);
delobj(otmp);
}
}
if (!lost_money) {
You_feel("a strange sensation.");
} else {
You("notice you have no money!");
context.botl = 1;
}
}
int
dosit()
{
static const char sit_message[] = "sit on the %s.";
register struct trap *trap = t_at(u.ux,u.uy);
register int typ = levl[u.ux][u.uy].typ;
static const char sit_message[] = "sit on the %s.";
register struct trap *trap = t_at(u.ux, u.uy);
register int typ = levl[u.ux][u.uy].typ;
if (u.usteed) {
You("are already sitting on %s.", mon_nam(u.usteed));
return (0);
}
if (u.uundetected && is_hider(youmonst.data) && u.umonnum != PM_TRAPPER)
u.uundetected = 0; /* no longer on the ceiling */
if (u.usteed) {
You("are already sitting on %s.", mon_nam(u.usteed));
return (0);
}
if (u.uundetected && is_hider(youmonst.data) && u.umonnum != PM_TRAPPER)
u.uundetected = 0; /* no longer on the ceiling */
if (!can_reach_floor(FALSE)) {
if (u.uswallow)
There("are no seats in here!");
else if (Levitation)
You("tumble in place.");
else
You("are sitting on air.");
return 0;
} else if (u.ustuck && !sticks(youmonst.data)) {
/* holding monster is next to hero rather than beneath, but
hero is in no condition to actually sit at has/her own spot */
if (humanoid(u.ustuck->data))
pline("%s won't offer %s lap.",
Monnam(u.ustuck), mhis(u.ustuck));
else
pline("%s has no lap.", Monnam(u.ustuck));
return 0;
} else if (is_pool(u.ux, u.uy) && !Underwater) { /* water walking */
goto in_water;
}
if (!can_reach_floor(FALSE)) {
if (u.uswallow)
There("are no seats in here!");
else if (Levitation)
You("tumble in place.");
else
You("are sitting on air.");
return 0;
} else if (u.ustuck && !sticks(youmonst.data)) {
/* holding monster is next to hero rather than beneath, but
hero is in no condition to actually sit at has/her own spot */
if (humanoid(u.ustuck->data))
pline("%s won't offer %s lap.", Monnam(u.ustuck), mhis(u.ustuck));
else
pline("%s has no lap.", Monnam(u.ustuck));
return 0;
} else if (is_pool(u.ux, u.uy) && !Underwater) { /* water walking */
goto in_water;
}
if (OBJ_AT(u.ux, u.uy) &&
/* ensure we're not standing on the precipice */
!uteetering_at_seen_pit(trap)) {
register struct obj *obj;
if (OBJ_AT(u.ux, u.uy) &&
/* ensure we're not standing on the precipice */
!uteetering_at_seen_pit(trap)) {
register struct obj *obj;
obj = level.objects[u.ux][u.uy];
if (youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) {
You("coil up around your %shoard.",
(obj->quan + money_cnt(invent) < u.ulevel*1000) ? "meager " : "");
} else {
You("sit on %s.", the(xname(obj)));
if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH))
pline("It's not very comfortable...");
}
} else if (trap != 0 || (u.utrap && (u.utraptype >= TT_LAVA))) {
if (u.utrap) {
exercise(A_WIS, FALSE); /* you're getting stuck longer */
if (u.utraptype == TT_BEARTRAP) {
You_cant("sit down with your %s in the bear trap.",
body_part(FOOT));
u.utrap++;
} else if (u.utraptype == TT_PIT) {
if (trap && trap->ttyp == SPIKED_PIT) {
You("sit down on a spike. Ouch!");
losehp(Half_physical_damage ? rn2(2) : 1,
"sitting on an iron spike", KILLED_BY);
exercise(A_STR, FALSE);
} else
You("sit down in the pit.");
u.utrap += rn2(5);
} else if (u.utraptype == TT_WEB) {
You("sit in the spider web and get entangled further!");
u.utrap += rn1(10, 5);
} else if (u.utraptype == TT_LAVA) {
/* Must have fire resistance or they'd be dead already */
You("sit in the lava!");
if (Slimed) burn_away_slime();
u.utrap += rnd(4);
losehp(d(2,10), "sitting in lava", KILLED_BY); /* lava damage */
} else if (u.utraptype == TT_INFLOOR ||
u.utraptype == TT_BURIEDBALL) {
You_cant("maneuver to sit!");
u.utrap++;
}
} else {
You("sit down.");
dotrap(trap, 0);
}
} else if(Underwater || Is_waterlevel(&u.uz)) {
if (Is_waterlevel(&u.uz))
There("are no cushions floating nearby.");
else
You("sit down on the muddy bottom.");
} else if(is_pool(u.ux, u.uy)) {
in_water:
You("sit in the water.");
if (!rn2(10) && uarm)
(void) water_damage(uarm, "armor", TRUE);
if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS)
(void) water_damage(uarm, "armor", TRUE);
} else if(IS_SINK(typ)) {
You(sit_message, defsyms[S_sink].explanation);
Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside");
} else if(IS_ALTAR(typ)) {
You(sit_message, defsyms[S_altar].explanation);
altar_wrath(u.ux, u.uy);
} else if(IS_GRAVE(typ)) {
You(sit_message, defsyms[S_grave].explanation);
} else if(typ == STAIRS) {
You(sit_message, "stairs");
} else if(typ == LADDER) {
You(sit_message, "ladder");
} else if (is_lava(u.ux, u.uy)) {
/* must be WWalking */
You(sit_message, "lava");
burn_away_slime();
if (likes_lava(youmonst.data)) {
pline_The("lava feels warm.");
return 1;
}
pline_The("lava burns you!");
losehp(d((Fire_resistance ? 2 : 10), 10), /* lava damage */
"sitting on lava", KILLED_BY);
} else if (is_ice(u.ux, u.uy)) {
You(sit_message, defsyms[S_ice].explanation);
if (!Cold_resistance) pline_The("ice feels cold.");
} else if (typ == DRAWBRIDGE_DOWN) {
You(sit_message, "drawbridge");
} else if(IS_THRONE(typ)) {
You(sit_message, defsyms[S_throne].explanation);
if (rnd(6) > 4) {
switch (rnd(13)) {
case 1:
(void) adjattrib(rn2(A_MAX), -rn1(4,3), FALSE);
losehp(rnd(10), "cursed throne", KILLED_BY_AN);
break;
case 2:
(void) adjattrib(rn2(A_MAX), 1, FALSE);
break;
case 3:
pline("A%s electric shock shoots through your body!",
(Shock_resistance) ? "n" : " massive");
losehp(Shock_resistance ? rnd(6) : rnd(30),
"electric chair", KILLED_BY_AN);
exercise(A_CON, FALSE);
break;
case 4:
You_feel("much, much better!");
if (Upolyd) {
if (u.mh >= (u.mhmax - 5)) u.mhmax += 4;
u.mh = u.mhmax;
}
if(u.uhp >= (u.uhpmax - 5)) u.uhpmax += 4;
u.uhp = u.uhpmax;
make_blinded(0L,TRUE);
make_sick(0L, (char *) 0, FALSE, SICK_ALL);
heal_legs();
context.botl = 1;
break;
case 5:
take_gold();
break;
case 6:
if(u.uluck + rn2(5) < 0) {
You_feel("your luck is changing.");
change_luck(1);
} else makewish();
break;
case 7:
{
register int cnt = rnd(10);
obj = level.objects[u.ux][u.uy];
if (youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) {
You("coil up around your %shoard.",
(obj->quan + money_cnt(invent) < u.ulevel * 1000) ? "meager "
: "");
} else {
You("sit on %s.", the(xname(obj)));
if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH))
pline("It's not very comfortable...");
}
} else if (trap != 0 || (u.utrap && (u.utraptype >= TT_LAVA))) {
if (u.utrap) {
exercise(A_WIS, FALSE); /* you're getting stuck longer */
if (u.utraptype == TT_BEARTRAP) {
You_cant("sit down with your %s in the bear trap.",
body_part(FOOT));
u.utrap++;
} else if (u.utraptype == TT_PIT) {
if (trap && trap->ttyp == SPIKED_PIT) {
You("sit down on a spike. Ouch!");
losehp(Half_physical_damage ? rn2(2) : 1,
"sitting on an iron spike", KILLED_BY);
exercise(A_STR, FALSE);
} else
You("sit down in the pit.");
u.utrap += rn2(5);
} else if (u.utraptype == TT_WEB) {
You("sit in the spider web and get entangled further!");
u.utrap += rn1(10, 5);
} else if (u.utraptype == TT_LAVA) {
/* Must have fire resistance or they'd be dead already */
You("sit in the lava!");
if (Slimed)
burn_away_slime();
u.utrap += rnd(4);
losehp(d(2, 10), "sitting in lava",
KILLED_BY); /* lava damage */
} else if (u.utraptype == TT_INFLOOR
|| u.utraptype == TT_BURIEDBALL) {
You_cant("maneuver to sit!");
u.utrap++;
}
} else {
You("sit down.");
dotrap(trap, 0);
}
} else if (Underwater || Is_waterlevel(&u.uz)) {
if (Is_waterlevel(&u.uz))
There("are no cushions floating nearby.");
else
You("sit down on the muddy bottom.");
} else if (is_pool(u.ux, u.uy)) {
in_water:
You("sit in the water.");
if (!rn2(10) && uarm)
(void) water_damage(uarm, "armor", TRUE);
if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS)
(void) water_damage(uarm, "armor", TRUE);
} else if (IS_SINK(typ)) {
You(sit_message, defsyms[S_sink].explanation);
Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside");
} else if (IS_ALTAR(typ)) {
You(sit_message, defsyms[S_altar].explanation);
altar_wrath(u.ux, u.uy);
} else if (IS_GRAVE(typ)) {
You(sit_message, defsyms[S_grave].explanation);
} else if (typ == STAIRS) {
You(sit_message, "stairs");
} else if (typ == LADDER) {
You(sit_message, "ladder");
} else if (is_lava(u.ux, u.uy)) {
/* must be WWalking */
You(sit_message, "lava");
burn_away_slime();
if (likes_lava(youmonst.data)) {
pline_The("lava feels warm.");
return 1;
}
pline_The("lava burns you!");
losehp(d((Fire_resistance ? 2 : 10), 10), /* lava damage */
"sitting on lava", KILLED_BY);
} else if (is_ice(u.ux, u.uy)) {
You(sit_message, defsyms[S_ice].explanation);
if (!Cold_resistance)
pline_The("ice feels cold.");
} else if (typ == DRAWBRIDGE_DOWN) {
You(sit_message, "drawbridge");
} else if (IS_THRONE(typ)) {
You(sit_message, defsyms[S_throne].explanation);
if (rnd(6) > 4) {
switch (rnd(13)) {
case 1:
(void) adjattrib(rn2(A_MAX), -rn1(4, 3), FALSE);
losehp(rnd(10), "cursed throne", KILLED_BY_AN);
break;
case 2:
(void) adjattrib(rn2(A_MAX), 1, FALSE);
break;
case 3:
pline("A%s electric shock shoots through your body!",
(Shock_resistance) ? "n" : " massive");
losehp(Shock_resistance ? rnd(6) : rnd(30), "electric chair",
KILLED_BY_AN);
exercise(A_CON, FALSE);
break;
case 4:
You_feel("much, much better!");
if (Upolyd) {
if (u.mh >= (u.mhmax - 5))
u.mhmax += 4;
u.mh = u.mhmax;
}
if (u.uhp >= (u.uhpmax - 5))
u.uhpmax += 4;
u.uhp = u.uhpmax;
make_blinded(0L, TRUE);
make_sick(0L, (char *) 0, FALSE, SICK_ALL);
heal_legs();
context.botl = 1;
break;
case 5:
take_gold();
break;
case 6:
if (u.uluck + rn2(5) < 0) {
You_feel("your luck is changing.");
change_luck(1);
} else
makewish();
break;
case 7: {
register int cnt = rnd(10);
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("Thy audience hath been summoned, %s!",
flags.female ? "Dame" : "Sire");
while(cnt--)
(void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
break;
}
case 8:
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("By thine Imperious order, %s...",
flags.female ? "Dame" : "Sire");
do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
break;
case 9:
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("A curse upon thee for sitting upon this most holy throne!");
if (Luck > 0) {
make_blinded(Blinded + rn1(100,250),TRUE);
} else rndcurse();
break;
case 10:
if (Luck < 0 || (HSee_invisible & INTRINSIC)) {
if (level.flags.nommap) {
pline("A terrible drone fills your head!");
make_confused((HConfusion & TIMEOUT) +
(long)rnd(30), FALSE);
} else {
pline("An image forms in your mind.");
do_mapping();
}
} else {
Your("vision becomes clear.");
HSee_invisible |= FROMOUTSIDE;
newsym(u.ux, u.uy);
}
break;
case 11:
if (Luck < 0) {
You_feel("threatened.");
aggravate();
} else {
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("Thy audience hath been summoned, %s!",
flags.female ? "Dame" : "Sire");
while (cnt--)
(void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
break;
}
case 8:
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("By thine Imperious order, %s...",
flags.female ? "Dame" : "Sire");
do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
break;
case 9:
/* Magical voice not affected by deafness */
pline("A voice echoes:");
verbalize("A curse upon thee for sitting upon this most holy "
"throne!");
if (Luck > 0) {
make_blinded(Blinded + rn1(100, 250), TRUE);
} else
rndcurse();
break;
case 10:
if (Luck < 0 || (HSee_invisible & INTRINSIC)) {
if (level.flags.nommap) {
pline("A terrible drone fills your head!");
make_confused((HConfusion & TIMEOUT) + (long) rnd(30),
FALSE);
} else {
pline("An image forms in your mind.");
do_mapping();
}
} else {
Your("vision becomes clear.");
HSee_invisible |= FROMOUTSIDE;
newsym(u.ux, u.uy);
}
break;
case 11:
if (Luck < 0) {
You_feel("threatened.");
aggravate();
} else {
You_feel("a wrenching sensation.");
tele(); /* teleport him */
}
break;
case 12:
You("are granted an insight!");
if (invent) {
/* rn2(5) agrees w/seffects() */
identify_pack(rn2(5), FALSE);
}
break;
case 13:
Your("mind turns into a pretzel!");
make_confused((HConfusion & TIMEOUT) + (long) rn1(7, 16),
FALSE);
break;
default:
impossible("throne effect");
break;
}
} else {
if (is_prince(youmonst.data))
You_feel("very comfortable here.");
else
You_feel("somehow out of place...");
}
You_feel("a wrenching sensation.");
tele(); /* teleport him */
}
break;
case 12:
You("are granted an insight!");
if (invent) {
/* rn2(5) agrees w/seffects() */
identify_pack(rn2(5), FALSE);
}
break;
case 13:
Your("mind turns into a pretzel!");
make_confused((HConfusion & TIMEOUT) + (long)rn1(7,16),
FALSE);
break;
default: impossible("throne effect");
break;
}
} else {
if (is_prince(youmonst.data))
You_feel("very comfortable here.");
else
You_feel("somehow out of place...");
}
if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
/* may have teleported */
levl[u.ux][u.uy].typ = ROOM;
pline_The("throne vanishes in a puff of logic.");
newsym(u.ux, u.uy);
}
} else if (lays_eggs(youmonst.data)) {
struct obj *uegg;
if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
/* may have teleported */
levl[u.ux][u.uy].typ = ROOM;
pline_The("throne vanishes in a puff of logic.");
newsym(u.ux,u.uy);
}
} else if (lays_eggs(youmonst.data)) {
struct obj *uegg;
if (!flags.female) {
pline(Hallucination ? "You may think you are a platypus but a "
"male still can't lay eggs!"
: "Males can't lay eggs!");
return 0;
} else if (u.uhunger < (int) objects[EGG].oc_nutrition) {
You("don't have enough energy to lay an egg.");
return 0;
}
if (!flags.female) {
pline(Hallucination ?
"You may think you are a platypus but a male still can't lay eggs!" :
"Males can't lay eggs!");
return 0;
} else if (u.uhunger < (int)objects[EGG].oc_nutrition) {
You("don't have enough energy to lay an egg.");
return 0;
}
uegg = mksobj(EGG, FALSE, FALSE);
uegg->spe = 1;
uegg->quan = 1L;
uegg->owt = weight(uegg);
/* this sets hatch timers if appropriate */
set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
uegg->known = uegg->dknown = 1;
You("lay an egg.");
dropy(uegg);
stackobj(uegg);
morehungry((int)objects[EGG].oc_nutrition);
} else {
pline("Having fun sitting on the %s?", surface(u.ux,u.uy));
}
return(1);
uegg = mksobj(EGG, FALSE, FALSE);
uegg->spe = 1;
uegg->quan = 1L;
uegg->owt = weight(uegg);
/* this sets hatch timers if appropriate */
set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
uegg->known = uegg->dknown = 1;
You("lay an egg.");
dropy(uegg);
stackobj(uegg);
morehungry((int) objects[EGG].oc_nutrition);
} else {
pline("Having fun sitting on the %s?", surface(u.ux, u.uy));
}
return (1);
}
void
rndcurse() /* curse a few inventory items at random! */
void rndcurse() /* curse a few inventory items at random! */
{
int nobj = 0;
int cnt, onum;
struct obj *otmp;
static const char mal_aura[] = "feel a malignant aura surround %s.";
int nobj = 0;
int cnt, onum;
struct obj *otmp;
static const char mal_aura[] = "feel a malignant aura surround %s.";
if (uwep && (uwep->oartifact == ART_MAGICBANE) && rn2(20)) {
You(mal_aura, "the magic-absorbing blade");
return;
}
if (uwep && (uwep->oartifact == ART_MAGICBANE) && rn2(20)) {
You(mal_aura, "the magic-absorbing blade");
return;
}
if(Antimagic) {
shieldeff(u.ux, u.uy);
You(mal_aura, "you");
}
if (Antimagic) {
shieldeff(u.ux, u.uy);
You(mal_aura, "you");
}
for (otmp = invent; otmp; otmp = otmp->nobj) {
/* gold isn't subject to being cursed or blessed */
if (otmp->oclass == COIN_CLASS) continue;
nobj++;
}
if (nobj) {
for (cnt = rnd(6/((!!Antimagic) + (!!Half_spell_damage) + 1));
cnt > 0; cnt--) {
onum = rnd(nobj);
for (otmp = invent; otmp; otmp = otmp->nobj) {
/* as above */
if (otmp->oclass == COIN_CLASS) continue;
if (--onum == 0) break; /* found the target */
}
/* the !otmp case should never happen; picking an already
cursed item happens--avoid "resists" message in that case */
if (!otmp || otmp->cursed) continue; /* next target */
for (otmp = invent; otmp; otmp = otmp->nobj) {
/* gold isn't subject to being cursed or blessed */
if (otmp->oclass == COIN_CLASS)
continue;
nobj++;
}
if (nobj) {
for (cnt = rnd(6 / ((!!Antimagic) + (!!Half_spell_damage) + 1));
cnt > 0; cnt--) {
onum = rnd(nobj);
for (otmp = invent; otmp; otmp = otmp->nobj) {
/* as above */
if (otmp->oclass == COIN_CLASS)
continue;
if (--onum == 0)
break; /* found the target */
}
/* the !otmp case should never happen; picking an already
cursed item happens--avoid "resists" message in that case */
if (!otmp || otmp->cursed)
continue; /* next target */
if(otmp->oartifact && spec_ability(otmp, SPFX_INTEL) &&
rn2(10) < 8) {
pline("%s!", Tobjnam(otmp, "resist"));
continue;
}
if (otmp->oartifact && spec_ability(otmp, SPFX_INTEL)
&& rn2(10) < 8) {
pline("%s!", Tobjnam(otmp, "resist"));
continue;
}
if(otmp->blessed)
unbless(otmp);
else
curse(otmp);
}
update_inventory();
}
if (otmp->blessed)
unbless(otmp);
else
curse(otmp);
}
update_inventory();
}
/* treat steed's saddle as extended part of hero's inventory */
if (u.usteed && !rn2(4) &&
(otmp = which_armor(u.usteed, W_SADDLE)) != 0 &&
!otmp->cursed) { /* skip if already cursed */
if (otmp->blessed)
unbless(otmp);
else
curse(otmp);
if (!Blind) {
pline("%s %s.",
Yobjnam2(otmp, "glow"),
hcolor(otmp->cursed ? NH_BLACK : (const char *)"brown"));
otmp->bknown = TRUE;
}
}
/* treat steed's saddle as extended part of hero's inventory */
if (u.usteed && !rn2(4) && (otmp = which_armor(u.usteed, W_SADDLE)) != 0
&& !otmp->cursed) { /* skip if already cursed */
if (otmp->blessed)
unbless(otmp);
else
curse(otmp);
if (!Blind) {
pline("%s %s.", Yobjnam2(otmp, "glow"),
hcolor(otmp->cursed ? NH_BLACK : (const char *) "brown"));
otmp->bknown = TRUE;
}
}
}
void
attrcurse() /* remove a random INTRINSIC ability */
void attrcurse() /* remove a random INTRINSIC ability */
{
switch(rnd(11)) {
case 1 : if (HFire_resistance & INTRINSIC) {
HFire_resistance &= ~INTRINSIC;
You_feel("warmer.");
break;
}
case 2 : if (HTeleportation & INTRINSIC) {
HTeleportation &= ~INTRINSIC;
You_feel("less jumpy.");
break;
}
case 3 : if (HPoison_resistance & INTRINSIC) {
HPoison_resistance &= ~INTRINSIC;
You_feel("a little sick!");
break;
}
case 4 : if (HTelepat & INTRINSIC) {
HTelepat &= ~INTRINSIC;
if (Blind && !Blind_telepat)
see_monsters(); /* Can't sense mons anymore! */
Your("senses fail!");
break;
}
case 5 : if (HCold_resistance & INTRINSIC) {
HCold_resistance &= ~INTRINSIC;
You_feel("cooler.");
break;
}
case 6 : if (HInvis & INTRINSIC) {
HInvis &= ~INTRINSIC;
You_feel("paranoid.");
break;
}
case 7 : if (HSee_invisible & INTRINSIC) {
HSee_invisible &= ~INTRINSIC;
You("%s!", Hallucination ? "tawt you taw a puttie tat"
: "thought you saw something");
break;
}
case 8 : if (HFast & INTRINSIC) {
HFast &= ~INTRINSIC;
You_feel("slower.");
break;
}
case 9 : if (HStealth & INTRINSIC) {
HStealth &= ~INTRINSIC;
You_feel("clumsy.");
break;
}
case 10: if (HProtection & INTRINSIC) {
HProtection &= ~INTRINSIC;
You_feel("vulnerable.");
break;
}
case 11: if (HAggravate_monster & INTRINSIC) {
HAggravate_monster &= ~INTRINSIC;
You_feel("less attractive.");
break;
}
default: break;
}
switch (rnd(11)) {
case 1:
if (HFire_resistance & INTRINSIC) {
HFire_resistance &= ~INTRINSIC;
You_feel("warmer.");
break;
}
case 2:
if (HTeleportation & INTRINSIC) {
HTeleportation &= ~INTRINSIC;
You_feel("less jumpy.");
break;
}
case 3:
if (HPoison_resistance & INTRINSIC) {
HPoison_resistance &= ~INTRINSIC;
You_feel("a little sick!");
break;
}
case 4:
if (HTelepat & INTRINSIC) {
HTelepat &= ~INTRINSIC;
if (Blind && !Blind_telepat)
see_monsters(); /* Can't sense mons anymore! */
Your("senses fail!");
break;
}
case 5:
if (HCold_resistance & INTRINSIC) {
HCold_resistance &= ~INTRINSIC;
You_feel("cooler.");
break;
}
case 6:
if (HInvis & INTRINSIC) {
HInvis &= ~INTRINSIC;
You_feel("paranoid.");
break;
}
case 7:
if (HSee_invisible & INTRINSIC) {
HSee_invisible &= ~INTRINSIC;
You("%s!", Hallucination ? "tawt you taw a puttie tat"
: "thought you saw something");
break;
}
case 8:
if (HFast & INTRINSIC) {
HFast &= ~INTRINSIC;
You_feel("slower.");
break;
}
case 9:
if (HStealth & INTRINSIC) {
HStealth &= ~INTRINSIC;
You_feel("clumsy.");
break;
}
case 10:
if (HProtection & INTRINSIC) {
HProtection &= ~INTRINSIC;
You_feel("vulnerable.");
break;
}
case 11:
if (HAggravate_monster & INTRINSIC) {
HAggravate_monster &= ~INTRINSIC;
You_feel("less attractive.");
break;
}
default:
break;
}
}
/*sit.c*/
+875 -855
View File
File diff suppressed because it is too large Load Diff
+3565 -3173
View File
File diff suppressed because it is too large Load Diff
+1227 -1142
View File
File diff suppressed because it is too large Load Diff
+492 -434
View File
File diff suppressed because it is too large Load Diff
+526 -522
View File
File diff suppressed because it is too large Load Diff
+62 -59
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 sys.c $NHDT-Date: 1426544797 2015/03/16 22:26:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.6 sys.c $NHDT-Date: 1431192764 2015/05/09 17:32:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.32 $ */
/* NetHack 3.6 sys.c $Date: 2012/03/10 02:22:07 $ $Revision: 1.12 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -19,75 +19,78 @@ struct sysopt sysopt;
void
sys_early_init()
{
sysopt.support = NULL;
sysopt.recover = NULL;
sysopt.support = NULL;
sysopt.recover = NULL;
#ifdef SYSCF
sysopt.wizards = NULL;
sysopt.wizards = NULL;
#else
sysopt.wizards = dupstr(WIZARD_NAME);
sysopt.wizards = dupstr(WIZARD_NAME);
#endif
#if defined(SYSCF) || !defined(DEBUGFILES)
sysopt.debugfiles = NULL;
sysopt.debugfiles = NULL;
#else
sysopt.debugfiles = dupstr(DEBUGFILES);
sysopt.debugfiles = dupstr(DEBUGFILES);
#endif
sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
sysopt.shellers = NULL;
sysopt.explorers = NULL;
sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
sysopt.shellers = NULL;
sysopt.explorers = NULL;
sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
/* record file */
sysopt.persmax = PERSMAX;
sysopt.entrymax = ENTRYMAX;
sysopt.pointsmin = POINTSMIN;
sysopt.pers_is_uid = PERS_IS_UID;
sysopt.tt_oname_maxrank = 10;
/* record file */
sysopt.persmax = PERSMAX;
sysopt.entrymax = ENTRYMAX;
sysopt.pointsmin = POINTSMIN;
sysopt.pers_is_uid = PERS_IS_UID;
sysopt.tt_oname_maxrank = 10;
/* sanity checks */
if(PERSMAX<1) sysopt.persmax = 1;
if(ENTRYMAX<10) sysopt.entrymax = 10;
if(POINTSMIN<1) sysopt.pointsmin = 1;
if(PERS_IS_UID != 0 && PERS_IS_UID != 1)
panic("config error: PERS_IS_UID must be either 0 or 1");
/* sanity checks */
if (PERSMAX < 1)
sysopt.persmax = 1;
if (ENTRYMAX < 10)
sysopt.entrymax = 10;
if (POINTSMIN < 1)
sysopt.pointsmin = 1;
if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
panic("config error: PERS_IS_UID must be either 0 or 1");
#ifdef PANICTRACE
/* panic options */
sysopt.gdbpath = dupstr(GDBPATH);
sysopt.greppath = dupstr(GREPPATH);
# ifdef BETA
sysopt.panictrace_gdb = 1;
# ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 2;
# endif
# else
sysopt.panictrace_gdb = 0;
# ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 0;
# endif
# endif
/* panic options */
sysopt.gdbpath = dupstr(GDBPATH);
sysopt.greppath = dupstr(GREPPATH);
#ifdef BETA
sysopt.panictrace_gdb = 1;
#ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 2;
#endif
#else
sysopt.panictrace_gdb = 0;
#ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 0;
#endif
#endif
#endif
sysopt.check_save_uid = 1;
sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce);
sysopt.check_save_uid = 1;
sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce);
}
void
sysopt_release()
{
if (sysopt.support)
free(sysopt.support), sysopt.support = NULL;
if (sysopt.recover)
free(sysopt.recover), sysopt.recover = NULL;
if (sysopt.wizards)
free(sysopt.wizards), sysopt.wizards = NULL;
if (sysopt.debugfiles)
free(sysopt.debugfiles), sysopt.debugfiles = NULL;
if (sysopt.support)
free(sysopt.support), sysopt.support = NULL;
if (sysopt.recover)
free(sysopt.recover), sysopt.recover = NULL;
if (sysopt.wizards)
free(sysopt.wizards), sysopt.wizards = NULL;
if (sysopt.debugfiles)
free(sysopt.debugfiles), sysopt.debugfiles = NULL;
#ifdef PANICTRACE
if (sysopt.gdbpath)
free(sysopt.gdbpath), sysopt.gdbpath = NULL;
if (sysopt.greppath)
free (sysopt.greppath), sysopt.greppath = NULL;
if (sysopt.gdbpath)
free(sysopt.gdbpath), sysopt.gdbpath = NULL;
if (sysopt.greppath)
free(sysopt.greppath), sysopt.greppath = NULL;
#endif
}
@@ -96,12 +99,12 @@ extern struct attack sa_no[NATTK];
void
sysopt_seduce_set(val)
int val;
int val;
{
struct attack *setval = val ? sa_yes : sa_no;
int x;
for(x=0; x<NATTK; x++){
mons[PM_INCUBUS].mattk[x] = setval[x];
mons[PM_SUCCUBUS].mattk[x] = setval[x];
}
struct attack *setval = val ? sa_yes : sa_no;
int x;
for (x = 0; x < NATTK; x++) {
mons[PM_INCUBUS].mattk[x] = setval[x];
mons[PM_SUCCUBUS].mattk[x] = setval[x];
}
}
+1023 -984
View File
File diff suppressed because it is too large Load Diff
+1266 -1237
View File
File diff suppressed because it is too large Load Diff
+851 -809
View File
File diff suppressed because it is too large Load Diff
+29 -25
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 track.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 track.c $NHDT-Date: 1431192763 2015/05/09 17:32:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
/* NetHack 3.6 track.c $Date: 2009/05/06 10:48:00 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)track.c 3.5 87/08/08 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -7,7 +7,7 @@
#include "hack.h"
#define UTSZ 50
#define UTSZ 50
STATIC_VAR NEARDATA int utcnt, utpnt;
STATIC_VAR NEARDATA coord utrack[UTSZ];
@@ -15,18 +15,20 @@ STATIC_VAR NEARDATA coord utrack[UTSZ];
void
initrack()
{
utcnt = utpnt = 0;
utcnt = utpnt = 0;
}
/* add to track */
void
settrack()
{
if(utcnt < UTSZ) utcnt++;
if(utpnt == UTSZ) utpnt = 0;
utrack[utpnt].x = u.ux;
utrack[utpnt].y = u.uy;
utpnt++;
if (utcnt < UTSZ)
utcnt++;
if (utpnt == UTSZ)
utpnt = 0;
utrack[utpnt].x = u.ux;
utrack[utpnt].y = u.uy;
utpnt++;
}
coord *
@@ -36,25 +38,27 @@ register int x, y;
register int cnt, ndist;
register coord *tc;
cnt = utcnt;
for(tc = &utrack[utpnt]; cnt--; ){
if(tc == utrack) tc = &utrack[UTSZ-1];
else tc--;
ndist = distmin(x,y,tc->x,tc->y);
for (tc = &utrack[utpnt]; cnt--;) {
if (tc == utrack)
tc = &utrack[UTSZ - 1];
else
tc--;
ndist = distmin(x, y, tc->x, tc->y);
/* if far away, skip track entries til we're closer */
if(ndist > 2) {
ndist -= 2; /* be careful due to extra decrement at top of loop */
cnt -= ndist;
if(cnt <= 0)
return (coord *) 0; /* too far away, no matches possible */
if(tc < &utrack[ndist])
tc += (UTSZ-ndist);
else
tc -= ndist;
} else if(ndist <= 1)
return(ndist ? tc : 0);
/* if far away, skip track entries til we're closer */
if (ndist > 2) {
ndist -= 2; /* be careful due to extra decrement at top of loop */
cnt -= ndist;
if (cnt <= 0)
return (coord *) 0; /* too far away, no matches possible */
if (tc < &utrack[ndist])
tc += (UTSZ - ndist);
else
tc -= ndist;
} else if (ndist <= 1)
return (ndist ? tc : 0);
}
return (coord *)0;
return (coord *) 0;
}
/*track.c*/
+4044 -3867
View File
File diff suppressed because it is too large Load Diff
+947 -807
View File
File diff suppressed because it is too large Load Diff
+2297 -2223
View File
File diff suppressed because it is too large Load Diff
+763 -714
View File
File diff suppressed because it is too large Load Diff
+142 -128
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 version.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 version.c $NHDT-Date: 1431192762 2015/05/09 17:32:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.29 $ */
/* NetHack 3.6 version.c $Date: 2012/01/04 18:52:36 $ $Revision: 1.26 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -23,7 +23,7 @@ char *
version_string(buf)
char *buf;
{
return strcpy(buf, VERSION_STRING);
return strcpy(buf, VERSION_STRING);
}
/* fill and return the given buffer with the long nethack version string */
@@ -31,86 +31,91 @@ char *
getversionstring(buf)
char *buf;
{
Strcpy(buf, VERSION_ID);
Strcpy(buf, VERSION_ID);
#if defined(BETA) && defined(BETA_INFO)
Sprintf(eos(buf), " %s", BETA_INFO);
Sprintf(eos(buf), " %s", BETA_INFO);
#endif
#if defined(RUNTIME_PORT_ID)
append_port_id(buf);
append_port_id(buf);
#endif
return buf;
return buf;
}
/* the 'v' command */
int
doversion()
{
char buf[BUFSZ];
char buf[BUFSZ];
pline1(getversionstring(buf));
return 0;
pline1(getversionstring(buf));
return 0;
}
/* the '#version' command; also a choice for '?' */
int
doextversion()
{
dlb *f;
char *cr, buf[BUFSZ];
winid win = create_nhwindow(NHW_TEXT);
dlb *f;
char *cr, buf[BUFSZ];
winid win = create_nhwindow(NHW_TEXT);
/* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
the file manually so we can include dynamic version info */
putstr(win, 0, getversionstring(buf));
/* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
the file manually so we can include dynamic version info */
putstr(win, 0, getversionstring(buf));
f = dlb_fopen(OPTIONS_USED, "r");
if (!f) {
putstr(win, 0, "");
Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
putstr(win, 0, buf);
} else {
/*
* already inserted above:
* + outdented program name and version plus build date and time
* dat/options; display the contents with lines prefixed by '-' deleted:
* - blank-line
* - indented program name and version
* blank-line
* outdented feature header
* - blank-line
* indented feature list
* spread over multiple lines
* blank-line
* outdented windowing header
* - blank-line
* indented windowing choices with
* optional second line for default
* - blank-line
* - EOF
*/
boolean prolog = TRUE; /* to skip indented program name */
f = dlb_fopen(OPTIONS_USED, "r");
if (!f) {
putstr(win, 0, "");
Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
putstr(win, 0, buf);
} else {
/*
* already inserted above:
* + outdented program name and version plus build date and time
* dat/options; display the contents with lines prefixed by '-'
* deleted:
* - blank-line
* - indented program name and version
* blank-line
* outdented feature header
* - blank-line
* indented feature list
* spread over multiple lines
* blank-line
* outdented windowing header
* - blank-line
* indented windowing choices with
* optional second line for default
* - blank-line
* - EOF
*/
boolean prolog = TRUE; /* to skip indented program name */
while (dlb_fgets(buf, BUFSZ, f)) {
if ((cr = index(buf, '\n')) != 0) *cr = 0;
if ((cr = index(buf, '\r')) != 0) *cr = 0;
if (index(buf, '\t') != 0) (void) tabexpand(buf);
while (dlb_fgets(buf, BUFSZ, f)) {
if ((cr = index(buf, '\n')) != 0)
*cr = 0;
if ((cr = index(buf, '\r')) != 0)
*cr = 0;
if (index(buf, '\t') != 0)
(void) tabexpand(buf);
if (*buf && *buf != ' ') {
/* found outdented header; insert a separator since we'll
have skipped corresponding blank line inside the file */
putstr(win, 0, "");
prolog = FALSE;
}
/* skip blank lines and prolog (progame name plus version) */
if (prolog || !*buf) continue;
if (*buf && *buf != ' ') {
/* found outdented header; insert a separator since we'll
have skipped corresponding blank line inside the file */
putstr(win, 0, "");
prolog = FALSE;
}
/* skip blank lines and prolog (progame name plus version) */
if (prolog || !*buf)
continue;
putstr(win, 0, buf);
}
(void) dlb_fclose(f);
display_nhwindow(win, FALSE);
destroy_nhwindow(win);
}
return 0;
putstr(win, 0, buf);
}
(void) dlb_fclose(f);
display_nhwindow(win, FALSE);
destroy_nhwindow(win);
}
return 0;
}
#ifdef MICRO
@@ -118,7 +123,7 @@ boolean
comp_times(filetime)
long filetime;
{
return((boolean)(filetime < BUILD_TIME));
return ((boolean)(filetime < BUILD_TIME));
}
#endif
@@ -128,33 +133,33 @@ struct version_info *version_data;
const char *filename;
boolean complain;
{
if (
if (
#ifdef VERSION_COMPATIBILITY
version_data->incarnation < VERSION_COMPATIBILITY ||
version_data->incarnation > VERSION_NUMBER
version_data->incarnation < VERSION_COMPATIBILITY
|| version_data->incarnation > VERSION_NUMBER
#else
version_data->incarnation != VERSION_NUMBER
version_data->incarnation != VERSION_NUMBER
#endif
) {
if (complain)
pline("Version mismatch for file \"%s\".", filename);
return FALSE;
} else if (
) {
if (complain)
pline("Version mismatch for file \"%s\".", filename);
return FALSE;
} else if (
#ifndef IGNORED_FEATURES
version_data->feature_set != VERSION_FEATURES ||
version_data->feature_set != VERSION_FEATURES ||
#else
(version_data->feature_set & ~IGNORED_FEATURES) !=
(VERSION_FEATURES & ~IGNORED_FEATURES) ||
(version_data->feature_set & ~IGNORED_FEATURES)
!= (VERSION_FEATURES & ~IGNORED_FEATURES)
||
#endif
version_data->entity_count != VERSION_SANITY1 ||
version_data->struct_sizes1 != VERSION_SANITY2 ||
version_data->struct_sizes2 != VERSION_SANITY3) {
if (complain)
pline("Configuration incompatibility for file \"%s\".",
filename);
return FALSE;
}
return TRUE;
version_data->entity_count != VERSION_SANITY1
|| version_data->struct_sizes1 != VERSION_SANITY2
|| version_data->struct_sizes2 != VERSION_SANITY3) {
if (complain)
pline("Configuration incompatibility for file \"%s\".", filename);
return FALSE;
}
return TRUE;
}
/* this used to be based on file date and somewhat OS-dependant,
@@ -169,17 +174,18 @@ const char *name;
boolean verbose = name ? TRUE : FALSE;
rlen = read(fd, (genericptr_t) &vers_info, sizeof vers_info);
minit(); /* ZEROCOMP */
minit(); /* ZEROCOMP */
if (rlen == 0) {
if (verbose) {
pline("File \"%s\" is empty?", name);
wait_synch();
}
return FALSE;
if (verbose) {
pline("File \"%s\" is empty?", name);
wait_synch();
}
return FALSE;
}
if (!check_version(&vers_info, name, verbose)) {
if (verbose) wait_synch();
return FALSE;
if (verbose)
wait_synch();
return FALSE;
}
return TRUE;
}
@@ -188,16 +194,17 @@ void
store_version(fd)
int fd;
{
static const struct version_info version_data = {
VERSION_NUMBER, VERSION_FEATURES,
VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3
};
static const struct version_info version_data = {
VERSION_NUMBER, VERSION_FEATURES, VERSION_SANITY1, VERSION_SANITY2,
VERSION_SANITY3
};
bufoff(fd);
/* bwrite() before bufon() uses plain write() */
bwrite(fd,(genericptr_t)&version_data,(unsigned)(sizeof version_data));
bufon(fd);
return;
bufoff(fd);
/* bwrite() before bufon() uses plain write() */
bwrite(fd, (genericptr_t) &version_data,
(unsigned) (sizeof version_data));
bufon(fd);
return;
}
#ifdef AMIGA
@@ -208,37 +215,40 @@ unsigned long
get_feature_notice_ver(str)
char *str;
{
char buf[BUFSZ];
int ver_maj, ver_min, patch;
char *istr[3];
int j = 0;
char buf[BUFSZ];
int ver_maj, ver_min, patch;
char *istr[3];
int j = 0;
if (!str) return 0L;
str = strcpy(buf, str);
istr[j] = str;
while (*str) {
if (*str == '.') {
*str++ = '\0';
j++;
istr[j] = str;
if (j == 2) break;
} else if (index("0123456789", *str) != 0) {
str++;
} else
return 0L;
}
if (j != 2) return 0L;
ver_maj = atoi(istr[0]);
ver_min = atoi(istr[1]);
patch = atoi(istr[2]);
return FEATURE_NOTICE_VER(ver_maj,ver_min,patch);
/* macro from hack.h */
if (!str)
return 0L;
str = strcpy(buf, str);
istr[j] = str;
while (*str) {
if (*str == '.') {
*str++ = '\0';
j++;
istr[j] = str;
if (j == 2)
break;
} else if (index("0123456789", *str) != 0) {
str++;
} else
return 0L;
}
if (j != 2)
return 0L;
ver_maj = atoi(istr[0]);
ver_min = atoi(istr[1]);
patch = atoi(istr[2]);
return FEATURE_NOTICE_VER(ver_maj, ver_min, patch);
/* macro from hack.h */
}
unsigned long
get_current_feature_ver()
{
return FEATURE_NOTICE_VER(VERSION_MAJOR,VERSION_MINOR,PATCHLEVEL);
return FEATURE_NOTICE_VER(VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL);
}
/*ARGUSED*/
@@ -247,16 +257,20 @@ copyright_banner_line(indx)
int indx;
{
#ifdef COPYRIGHT_BANNER_A
if (indx == 1) return COPYRIGHT_BANNER_A;
if (indx == 1)
return COPYRIGHT_BANNER_A;
#endif
#ifdef COPYRIGHT_BANNER_B
if (indx == 2) return COPYRIGHT_BANNER_B;
if (indx == 2)
return COPYRIGHT_BANNER_B;
#endif
#ifdef COPYRIGHT_BANNER_C
if (indx == 3) return COPYRIGHT_BANNER_C;
if (indx == 3)
return COPYRIGHT_BANNER_C;
#endif
#ifdef COPYRIGHT_BANNER_D
if (indx == 4) return COPYRIGHT_BANNER_D;
if (indx == 4)
return COPYRIGHT_BANNER_D;
#endif
return "";
}
+1747 -1559
View File
File diff suppressed because it is too large Load Diff
+1005 -889
View File
File diff suppressed because it is too large Load Diff
+132 -114
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 were.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 were.c $NHDT-Date: 1431192757 2015/05/09 17:32:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.17 $ */
/* NetHack 3.6 were.c $Date: 2011/02/28 11:29:27 $ $Revision: 1.14 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -9,44 +9,57 @@ void
were_change(mon)
register struct monst *mon;
{
if (!is_were(mon->data))
return;
if (!is_were(mon->data))
return;
if (is_human(mon->data)) {
if (!Protection_from_shape_changers &&
!rn2(night() ? (flags.moonphase == FULL_MOON ? 3 : 30)
: (flags.moonphase == FULL_MOON ? 10 : 50))) {
new_were(mon); /* change into animal form */
if (!Deaf && !canseemon(mon)) {
const char *howler;
if (is_human(mon->data)) {
if (!Protection_from_shape_changers
&& !rn2(night() ? (flags.moonphase == FULL_MOON ? 3 : 30)
: (flags.moonphase == FULL_MOON ? 10 : 50))) {
new_were(mon); /* change into animal form */
if (!Deaf && !canseemon(mon)) {
const char *howler;
switch (monsndx(mon->data)) {
case PM_WEREWOLF: howler = "wolf"; break;
case PM_WEREJACKAL: howler = "jackal"; break;
default: howler = (char *)0; break;
}
if (howler)
You_hear("a %s howling at the moon.", howler);
}
}
} else if (!rn2(30) || Protection_from_shape_changers) {
new_were(mon); /* change back into human form */
}
switch (monsndx(mon->data)) {
case PM_WEREWOLF:
howler = "wolf";
break;
case PM_WEREJACKAL:
howler = "jackal";
break;
default:
howler = (char *) 0;
break;
}
if (howler)
You_hear("a %s howling at the moon.", howler);
}
}
} else if (!rn2(30) || Protection_from_shape_changers) {
new_were(mon); /* change back into human form */
}
}
int
counter_were(pm)
int pm;
{
switch(pm) {
case PM_WEREWOLF: return(PM_HUMAN_WEREWOLF);
case PM_HUMAN_WEREWOLF: return(PM_WEREWOLF);
case PM_WEREJACKAL: return(PM_HUMAN_WEREJACKAL);
case PM_HUMAN_WEREJACKAL: return(PM_WEREJACKAL);
case PM_WERERAT: return(PM_HUMAN_WERERAT);
case PM_HUMAN_WERERAT: return(PM_WERERAT);
default: return NON_PM;
}
switch (pm) {
case PM_WEREWOLF:
return (PM_HUMAN_WEREWOLF);
case PM_HUMAN_WEREWOLF:
return (PM_WEREWOLF);
case PM_WEREJACKAL:
return (PM_HUMAN_WEREJACKAL);
case PM_HUMAN_WEREJACKAL:
return (PM_WEREJACKAL);
case PM_WERERAT:
return (PM_HUMAN_WERERAT);
case PM_HUMAN_WERERAT:
return (PM_WERERAT);
default:
return NON_PM;
}
}
/* convert monsters similar to werecritters into appropriate werebeast */
@@ -59,19 +72,19 @@ int pm;
case PM_SEWER_RAT:
case PM_GIANT_RAT:
case PM_RABID_RAT:
return PM_WERERAT;
return PM_WERERAT;
case PM_WEREJACKAL:
case PM_JACKAL:
case PM_FOX:
case PM_COYOTE:
return PM_WEREJACKAL;
return PM_WEREJACKAL;
case PM_WEREWOLF:
case PM_WOLF:
case PM_WARG:
case PM_WINTER_WOLF:
return PM_WEREWOLF;
return PM_WEREWOLF;
default:
break;
break;
}
return NON_PM;
}
@@ -80,108 +93,113 @@ void
new_were(mon)
register struct monst *mon;
{
register int pm;
register int pm;
pm = counter_were(monsndx(mon->data));
if (pm < LOW_PM) {
impossible("unknown lycanthrope %s.", mon->data->mname);
return;
}
pm = counter_were(monsndx(mon->data));
if (pm < LOW_PM) {
impossible("unknown lycanthrope %s.", mon->data->mname);
return;
}
if(canseemon(mon) && !Hallucination)
pline("%s changes into a %s.", Monnam(mon),
is_human(&mons[pm]) ? "human" :
mons[pm].mname+4);
if (canseemon(mon) && !Hallucination)
pline("%s changes into a %s.", Monnam(mon),
is_human(&mons[pm]) ? "human" : mons[pm].mname + 4);
set_mon_data(mon, &mons[pm], 0);
if (mon->msleeping || !mon->mcanmove) {
/* transformation wakens and/or revitalizes */
mon->msleeping = 0;
mon->mfrozen = 0; /* not asleep or paralyzed */
mon->mcanmove = 1;
}
/* regenerate by 1/4 of the lost hit points */
mon->mhp += (mon->mhpmax - mon->mhp) / 4;
newsym(mon->mx,mon->my);
mon_break_armor(mon, FALSE);
possibly_unwield(mon, FALSE);
set_mon_data(mon, &mons[pm], 0);
if (mon->msleeping || !mon->mcanmove) {
/* transformation wakens and/or revitalizes */
mon->msleeping = 0;
mon->mfrozen = 0; /* not asleep or paralyzed */
mon->mcanmove = 1;
}
/* regenerate by 1/4 of the lost hit points */
mon->mhp += (mon->mhpmax - mon->mhp) / 4;
newsym(mon->mx, mon->my);
mon_break_armor(mon, FALSE);
possibly_unwield(mon, FALSE);
}
int
were_summon(ptr,yours,visible,genbuf) /* were-creature (even you) summons a horde */
int were_summon(ptr, yours, visible,
genbuf) /* were-creature (even you) summons a horde */
register struct permonst *ptr;
register boolean yours;
int *visible; /* number of visible helpers created */
int *visible; /* number of visible helpers created */
char *genbuf;
{
register int i, typ, pm = monsndx(ptr);
register struct monst *mtmp;
int total = 0;
register int i, typ, pm = monsndx(ptr);
register struct monst *mtmp;
int total = 0;
*visible = 0;
if(Protection_from_shape_changers && !yours)
return 0;
for(i = rnd(5); i > 0; i--) {
switch(pm) {
case PM_WERERAT:
case PM_HUMAN_WERERAT:
typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ;
if (genbuf) Strcpy(genbuf, "rat");
break;
case PM_WEREJACKAL:
case PM_HUMAN_WEREJACKAL:
typ = PM_JACKAL;
if (genbuf) Strcpy(genbuf, "jackal");
break;
case PM_WEREWOLF:
case PM_HUMAN_WEREWOLF:
typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ;
if (genbuf) Strcpy(genbuf, "wolf");
break;
default:
continue;
}
mtmp = makemon(&mons[typ], u.ux, u.uy, NO_MM_FLAGS);
if (mtmp) {
total++;
if (canseemon(mtmp)) *visible += 1;
}
if (yours && mtmp)
(void) tamedog(mtmp, (struct obj *) 0);
}
return total;
*visible = 0;
if (Protection_from_shape_changers && !yours)
return 0;
for (i = rnd(5); i > 0; i--) {
switch (pm) {
case PM_WERERAT:
case PM_HUMAN_WERERAT:
typ =
rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT;
if (genbuf)
Strcpy(genbuf, "rat");
break;
case PM_WEREJACKAL:
case PM_HUMAN_WEREJACKAL:
typ = PM_JACKAL;
if (genbuf)
Strcpy(genbuf, "jackal");
break;
case PM_WEREWOLF:
case PM_HUMAN_WEREWOLF:
typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF;
if (genbuf)
Strcpy(genbuf, "wolf");
break;
default:
continue;
}
mtmp = makemon(&mons[typ], u.ux, u.uy, NO_MM_FLAGS);
if (mtmp) {
total++;
if (canseemon(mtmp))
*visible += 1;
}
if (yours && mtmp)
(void) tamedog(mtmp, (struct obj *) 0);
}
return total;
}
void
you_were()
{
char qbuf[QBUFSZ];
boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
char qbuf[QBUFSZ];
boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
if (Unchanging || (u.umonnum == u.ulycn)) return;
if (controllable_poly) {
/* `+4' => skip "were" prefix to get name of beast */
Sprintf(qbuf, "Do you want to change into %s?",
an(mons[u.ulycn].mname+4));
if(yn(qbuf) == 'n') return;
}
(void) polymon(u.ulycn);
if (Unchanging || (u.umonnum == u.ulycn))
return;
if (controllable_poly) {
/* `+4' => skip "were" prefix to get name of beast */
Sprintf(qbuf, "Do you want to change into %s?",
an(mons[u.ulycn].mname + 4));
if (yn(qbuf) == 'n')
return;
}
(void) polymon(u.ulycn);
}
void
you_unwere(purify)
boolean purify;
{
boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
if (purify) {
You_feel("purified.");
u.ulycn = NON_PM; /* cure lycanthropy */
}
if (!Unchanging && is_were(youmonst.data) &&
(!controllable_poly || yn("Remain in beast form?") == 'n'))
rehumanize();
if (purify) {
You_feel("purified.");
u.ulycn = NON_PM; /* cure lycanthropy */
}
if (!Unchanging && is_were(youmonst.data)
&& (!controllable_poly || yn("Remain in beast form?") == 'n'))
rehumanize();
}
/*were.c*/

Some files were not shown because too many files have changed in this diff Show More