Merge branch 'NetHack-3.6.2'
This commit is contained in:
@@ -556,6 +556,7 @@ typedef unsigned char uchar;
|
||||
|
||||
#endif
|
||||
|
||||
#define USE_ISAAC64 /* Use cross-plattform, bundled RNG */
|
||||
|
||||
/* End of Section 4 */
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ struct multishot {
|
||||
boolean s;
|
||||
};
|
||||
|
||||
E NEARDATA boolean has_strong_rngseed;
|
||||
E const int shield_static[];
|
||||
|
||||
#include "spell.h"
|
||||
|
||||
@@ -146,9 +146,9 @@
|
||||
*
|
||||
* Respectively return a random monster, object, or trap number.
|
||||
*/
|
||||
#define random_monster() rn2(NUMMONS)
|
||||
#define random_object() rn1(NUM_OBJECTS - 1, 1)
|
||||
#define random_trap() rn1(TRAPNUM - 1, 1)
|
||||
#define random_monster(rng) rng(NUMMONS)
|
||||
#define random_object(rng) (rng(NUM_OBJECTS - 1) + 1)
|
||||
#define random_trap(rng) (rng(TRAPNUM - 1) + 1)
|
||||
|
||||
/*
|
||||
* what_obj()
|
||||
@@ -156,11 +156,23 @@
|
||||
* what_trap()
|
||||
*
|
||||
* If hallucinating, choose a random object/monster, otherwise, use the one
|
||||
* given.
|
||||
* given. Use the given rng to handle hallucination.
|
||||
*/
|
||||
#define what_obj(obj) (Hallucination ? random_object() : obj)
|
||||
#define what_mon(mon) (Hallucination ? random_monster() : mon)
|
||||
#define what_trap(trp) (Hallucination ? random_trap() : trp)
|
||||
#define what_obj(obj, rng) (Hallucination ? random_object(rng) : obj)
|
||||
#define what_mon(mon, rng) (Hallucination ? random_monster(rng) : mon)
|
||||
#define what_trap(trp, rng) (Hallucination ? random_trap(rng) : trp)
|
||||
|
||||
/*
|
||||
* newsym_rn2
|
||||
*
|
||||
* An appropriate random number generator for use with newsym(), when
|
||||
* randomness is needed there. This is currently hardcoded as
|
||||
* rn2_on_display_rng, but is futureproofed for cases where we might
|
||||
* want to prevent display-random objects entering the character's
|
||||
* memory (this isn't important at present but may be if we need
|
||||
* reproducible gameplay for some reason).
|
||||
*/
|
||||
#define newsym_rn2 rn2_on_display_rng
|
||||
|
||||
/*
|
||||
* covers_objects()
|
||||
@@ -196,9 +208,10 @@
|
||||
* Display the hero. It is assumed that all checks necessary to determine
|
||||
* _if_ the hero can be seen have already been done.
|
||||
*/
|
||||
#define maybe_display_usteed(otherwise_self) \
|
||||
((u.usteed && mon_visible(u.usteed)) ? ridden_mon_to_glyph(u.usteed) \
|
||||
: (otherwise_self))
|
||||
#define maybe_display_usteed(otherwise_self) \
|
||||
((u.usteed && mon_visible(u.usteed)) \
|
||||
? ridden_mon_to_glyph(u.usteed, rn2_on_display_rng) \
|
||||
: (otherwise_self))
|
||||
|
||||
#define display_self() \
|
||||
show_glyph(u.ux, u.uy, \
|
||||
@@ -282,27 +295,27 @@
|
||||
#define GLYPH_INVISIBLE GLYPH_INVIS_OFF
|
||||
|
||||
#define warning_to_glyph(mwarnlev) ((mwarnlev) + GLYPH_WARNING_OFF)
|
||||
#define mon_to_glyph(mon) \
|
||||
((int) what_mon(monsndx((mon)->data)) + GLYPH_MON_OFF)
|
||||
#define detected_mon_to_glyph(mon) \
|
||||
((int) what_mon(monsndx((mon)->data)) + GLYPH_DETECT_OFF)
|
||||
#define ridden_mon_to_glyph(mon) \
|
||||
((int) what_mon(monsndx((mon)->data)) + GLYPH_RIDDEN_OFF)
|
||||
#define pet_to_glyph(mon) \
|
||||
((int) what_mon(monsndx((mon)->data)) + GLYPH_PET_OFF)
|
||||
#define mon_to_glyph(mon, rng) \
|
||||
((int) what_mon(monsndx((mon)->data), rng) + GLYPH_MON_OFF)
|
||||
#define detected_mon_to_glyph(mon, rng) \
|
||||
((int) what_mon(monsndx((mon)->data), rng) + GLYPH_DETECT_OFF)
|
||||
#define ridden_mon_to_glyph(mon, rng) \
|
||||
((int) what_mon(monsndx((mon)->data), rng) + GLYPH_RIDDEN_OFF)
|
||||
#define pet_to_glyph(mon, rng) \
|
||||
((int) what_mon(monsndx((mon)->data), rng) + GLYPH_PET_OFF)
|
||||
|
||||
/* This has the unfortunate side effect of needing a global variable */
|
||||
/* to store a result. 'otg_temp' is defined and declared in decl.{ch}. */
|
||||
#define random_obj_to_glyph() \
|
||||
((g.otg_temp = random_object()) == CORPSE \
|
||||
? random_monster() + GLYPH_BODY_OFF \
|
||||
#define random_obj_to_glyph(rng) \
|
||||
((g.otg_temp = random_object(rng)) == CORPSE \
|
||||
? random_monster(rng) + GLYPH_BODY_OFF \
|
||||
: g.otg_temp + GLYPH_OBJ_OFF)
|
||||
|
||||
#define obj_to_glyph(obj) \
|
||||
#define obj_to_glyph(obj, rng) \
|
||||
(((obj)->otyp == STATUE) \
|
||||
? statue_to_glyph(obj) \
|
||||
? statue_to_glyph(obj, rng) \
|
||||
: Hallucination \
|
||||
? random_obj_to_glyph() \
|
||||
? random_obj_to_glyph(rng) \
|
||||
: ((obj)->otyp == CORPSE) \
|
||||
? (int) (obj)->corpsenm + GLYPH_BODY_OFF \
|
||||
: (int) (obj)->otyp + GLYPH_OBJ_OFF)
|
||||
@@ -310,16 +323,16 @@
|
||||
/* MRKR: Statues now have glyphs corresponding to the monster they */
|
||||
/* represent and look like monsters when you are hallucinating. */
|
||||
|
||||
#define statue_to_glyph(obj) \
|
||||
(Hallucination ? random_monster() + GLYPH_MON_OFF \
|
||||
#define statue_to_glyph(obj, rng) \
|
||||
(Hallucination ? random_monster(rng) + GLYPH_MON_OFF \
|
||||
: (int) (obj)->corpsenm + GLYPH_STATUE_OFF)
|
||||
|
||||
#define cmap_to_glyph(cmap_idx) ((int) (cmap_idx) + GLYPH_CMAP_OFF)
|
||||
#define explosion_to_glyph(expltype, idx) \
|
||||
((((expltype) * MAXEXPCHARS) + ((idx) - S_explode1)) + GLYPH_EXPLODE_OFF)
|
||||
|
||||
#define trap_to_glyph(trap) \
|
||||
cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp)))
|
||||
#define trap_to_glyph(trap, rng) \
|
||||
cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp, rng)))
|
||||
|
||||
/* Not affected by hallucination. Gives a generic body for CORPSE */
|
||||
/* MRKR: ...and the generic statue */
|
||||
|
||||
@@ -926,7 +926,8 @@ E char *FDECL(strstri, (const char *, const char *));
|
||||
#endif
|
||||
E boolean
|
||||
FDECL(fuzzymatch, (const char *, const char *, const char *, BOOLEAN_P));
|
||||
E void NDECL(setrandom);
|
||||
E void FDECL(init_random, (int FDECL((*fn), (int))));
|
||||
E void FDECL(reseed_random, (int FDECL((*fn), (int))));
|
||||
E time_t NDECL(getnow);
|
||||
E int NDECL(getyear);
|
||||
#if 0
|
||||
@@ -2104,7 +2105,12 @@ E void FDECL(genl_outrip, (winid, int, time_t));
|
||||
|
||||
/* ### rnd.c ### */
|
||||
|
||||
#ifdef USE_ISAAC64
|
||||
E void FDECL(init_isaac64, (unsigned long, int FDECL((*fn), (int))));
|
||||
E long NDECL(nhrand);
|
||||
#endif
|
||||
E int FDECL(rn2, (int));
|
||||
E int FDECL(rn2_on_display_rng, (int));
|
||||
E int FDECL(rnl, (int));
|
||||
E int FDECL(rnd, (int));
|
||||
E int FDECL(d, (int, int));
|
||||
@@ -2149,7 +2155,7 @@ E const char *NDECL(Goodbye);
|
||||
/* ### rumors.c ### */
|
||||
|
||||
E char *FDECL(getrumor, (int, char *, BOOLEAN_P));
|
||||
E char *FDECL(get_rnd_text, (const char *, char *));
|
||||
E char *FDECL(get_rnd_text, (const char *, char *, int FDECL((*), (int))));
|
||||
E void FDECL(outrumor, (int, int));
|
||||
E void FDECL(outoracle, (BOOLEAN_P, BOOLEAN_P));
|
||||
E void FDECL(save_oracles, (int, int));
|
||||
|
||||
@@ -7,35 +7,47 @@
|
||||
#ifndef INTEGER_H
|
||||
#define INTEGER_H
|
||||
|
||||
#if defined(__STDC__) && __STDC__ >= 199101L
|
||||
|
||||
#if defined(__STDC__) && __STDC_VERSION__ >= 199101L
|
||||
/* The compiler claims to conform to C99. Use stdint.h */
|
||||
#include <stdint.h>
|
||||
#define SKIP_STDINT_WORKAROUND
|
||||
#else
|
||||
# if defined(HAS_STDINT_H)
|
||||
/* Some compilers have stdint.h but don't conform to all of C99. */
|
||||
#include <stdint.h>
|
||||
#define SKIP_STDINT_WORKAROUND
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_STDINT_WORKAROUND /* !C99 */
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(__386__)
|
||||
/* Open Watcom providing a 16 bit build for MS-DOS or OS/2 */
|
||||
/* int is 16 bits; use long for 32 bits */
|
||||
typedef long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
#else
|
||||
/* Otherwise, assume either a 32- or 64-bit compiler */
|
||||
/* long may be 64 bits; use int for 32 bits */
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
#endif /* !C99 */
|
||||
|
||||
/* Provide uint8, int16, uint16, int32, uint32, int64 and uint64 */
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
|
||||
#else /* !C99 */
|
||||
|
||||
/* Provide uint8, int16, uint16, int32 and uint32 */
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(__386__)
|
||||
/* Open Watcom providing a 16 bit build for MS-DOS or OS/2 */
|
||||
/* int is 16 bits; use long for 32 bits */
|
||||
typedef long int32;
|
||||
typedef unsigned long uint32;
|
||||
#else
|
||||
/* Otherwise, assume either a 32- or 64-bit compiler */
|
||||
/* long may be 64 bits; use int for 32 bits */
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
|
||||
#endif /* !C99 */
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
#endif /* INTEGER_H */
|
||||
|
||||
89
include/isaac64.h
Normal file
89
include/isaac64.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* CC0 (Public domain) - see http://creativecommons.org/publicdomain/zero/1.0/ for details */
|
||||
#if !defined(_isaac64_H)
|
||||
# define _isaac64_H (1)
|
||||
# include <integer.h>
|
||||
|
||||
|
||||
|
||||
typedef struct isaac64_ctx isaac64_ctx;
|
||||
|
||||
|
||||
|
||||
#define ISAAC64_SZ_LOG (8)
|
||||
#define ISAAC64_SZ (1<<ISAAC64_SZ_LOG)
|
||||
#define ISAAC64_SEED_SZ_MAX (ISAAC64_SZ<<3)
|
||||
|
||||
|
||||
|
||||
/*ISAAC is the most advanced of a series of pseudo-random number generators
|
||||
designed by Robert J. Jenkins Jr. in 1996.
|
||||
http://www.burtleburtle.net/bob/rand/isaac.html
|
||||
This is the 64-bit version.
|
||||
To quote:
|
||||
ISAAC-64 generates a different sequence than ISAAC, but it uses the same
|
||||
principles.
|
||||
It uses 64-bit arithmetic.
|
||||
It generates a 64-bit result every 19 instructions.
|
||||
All cycles are at least 2**72 values, and the average cycle length is
|
||||
2**16583.*/
|
||||
struct isaac64_ctx{
|
||||
unsigned n;
|
||||
uint64_t r[ISAAC64_SZ];
|
||||
uint64_t m[ISAAC64_SZ];
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
uint64_t c;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* isaac64_init - Initialize an instance of the ISAAC64 random number generator.
|
||||
* @_ctx: The ISAAC64 instance to initialize.
|
||||
* @_seed: The specified seed bytes.
|
||||
* This may be NULL if _nseed is less than or equal to zero.
|
||||
* @_nseed: The number of bytes to use for the seed.
|
||||
* If this is greater than ISAAC64_SEED_SZ_MAX, the extra bytes are
|
||||
* ignored.
|
||||
*/
|
||||
void isaac64_init(isaac64_ctx *_ctx,const unsigned char *_seed,int _nseed);
|
||||
|
||||
/**
|
||||
* isaac64_reseed - Mix a new batch of entropy into the current state.
|
||||
* To reset ISAAC64 to a known state, call isaac64_init() again instead.
|
||||
* @_ctx: The instance to reseed.
|
||||
* @_seed: The specified seed bytes.
|
||||
* This may be NULL if _nseed is zero.
|
||||
* @_nseed: The number of bytes to use for the seed.
|
||||
* If this is greater than ISAAC64_SEED_SZ_MAX, the extra bytes are
|
||||
* ignored.
|
||||
*/
|
||||
void isaac64_reseed(isaac64_ctx *_ctx,const unsigned char *_seed,int _nseed);
|
||||
/**
|
||||
* isaac64_next_uint64 - Return the next random 64-bit value.
|
||||
* @_ctx: The ISAAC64 instance to generate the value with.
|
||||
*/
|
||||
uint64_t isaac64_next_uint64(isaac64_ctx *_ctx);
|
||||
/**
|
||||
* isaac64_next_uint - Uniform random integer less than the given value.
|
||||
* @_ctx: The ISAAC64 instance to generate the value with.
|
||||
* @_n: The upper bound on the range of numbers returned (not inclusive).
|
||||
* This must be greater than zero and less than 2**64.
|
||||
* To return integers in the full range 0...2**64-1, use
|
||||
* isaac64_next_uint64() instead.
|
||||
* Return: An integer uniformly distributed between 0 and _n-1 (inclusive).
|
||||
*/
|
||||
uint64_t isaac64_next_uint(isaac64_ctx *_ctx,uint64_t _n);
|
||||
/**
|
||||
* isaac64_next_float - Uniform random float in the range [0,1).
|
||||
* @_ctx: The ISAAC64 instance to generate the value with.
|
||||
* Returns a high-quality float uniformly distributed between 0 (inclusive)
|
||||
* and 1 (exclusive).
|
||||
* All of the float's mantissa bits are random, e.g., the least significant bit
|
||||
* may still be non-zero even if the value is less than 0.5, and any
|
||||
* representable float in the range [0,1) has a chance to be returned, though
|
||||
* values very close to zero become increasingly unlikely.
|
||||
* To generate cheaper float values that do not have these properties, use
|
||||
* ldexpf((float)isaac64_next_uint64(_ctx),-64);
|
||||
*/
|
||||
|
||||
#endif
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
/* #define SHELL */ /* nt use of pcsys routines caused a hang */
|
||||
|
||||
#define RANDOM /* have Berkeley random(3) */
|
||||
#define TEXTCOLOR /* Color text */
|
||||
|
||||
#define EXEPATH /* Allow .exe location to be used as HACKDIR */
|
||||
@@ -25,8 +24,7 @@
|
||||
game */
|
||||
|
||||
#define SYSCF /* Use a global configuration */
|
||||
#define SYSCF_FILE "sysconf" /* Use a file to hold the SYSCF configuration \
|
||||
*/
|
||||
#define SYSCF_FILE "sysconf" /* Use a file to hold the SYSCF configuration */
|
||||
|
||||
#define DUMPLOG /* Enable dumplog files */
|
||||
/*#define DUMPLOG_FILE "nethack-%n-%d.log"*/
|
||||
@@ -35,9 +33,8 @@
|
||||
#define USER_SOUNDS
|
||||
|
||||
/*#define CHANGE_COLOR*/ /* allow palette changes */
|
||||
#define SELECTSAVED /* Provide menu of saved games to choose from at start \
|
||||
*/
|
||||
|
||||
#define SELECTSAVED /* Provide menu of saved games to choose from at start */
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* The remaining code shouldn't need modification.
|
||||
@@ -131,6 +128,9 @@ extern void FDECL(interject, (int));
|
||||
/* suppress a warning in cppregex.cpp */
|
||||
#pragma warning(disable : 4101) /* unreferenced local variable */
|
||||
#endif
|
||||
#ifndef HAS_STDINT_H
|
||||
#define HAS_STDINT_H /* force include of stdint.h in integer.h */
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* The following is needed for prototypes of certain functions */
|
||||
@@ -180,10 +180,17 @@ extern void FDECL(interject, (int));
|
||||
#include <time.h>
|
||||
|
||||
#define USE_STDARG
|
||||
#ifdef RANDOM
|
||||
|
||||
/* Use the high quality random number routines. */
|
||||
#define Rand() random()
|
||||
#ifdef USE_ISAAC64
|
||||
#undef RANDOM
|
||||
#else
|
||||
#define RANDOM
|
||||
#define Rand() random()
|
||||
#endif
|
||||
|
||||
/* Fall back to C's if nothing else, but this really isn't acceptable */
|
||||
#if !defined(USE_ISAAC64) && !defined(RANDOM)
|
||||
#define Rand() rand()
|
||||
#endif
|
||||
|
||||
|
||||
@@ -78,11 +78,12 @@
|
||||
#include <time.h>
|
||||
|
||||
/* the high quality random number routines */
|
||||
|
||||
#ifdef RANDOM
|
||||
#define Rand() random()
|
||||
#else
|
||||
#define Rand() rand()
|
||||
#ifndef USE_ISAAC64
|
||||
# ifdef RANDOM
|
||||
# define Rand() random()
|
||||
# else
|
||||
# define Rand() rand()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* file creation mask */
|
||||
|
||||
@@ -236,11 +236,13 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef RANDOM
|
||||
/* Use the high quality random number routines. */
|
||||
#define Rand() random()
|
||||
#else
|
||||
#define Rand() rand()
|
||||
/* the high quality random number routines */
|
||||
#ifndef USE_ISAAC64
|
||||
# ifdef RANDOM
|
||||
# define Rand() random()
|
||||
# else
|
||||
# define Rand() rand()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef TOS
|
||||
|
||||
@@ -347,11 +347,14 @@
|
||||
#endif
|
||||
|
||||
/* Use the high quality random number routines. */
|
||||
#if defined(BSD) || defined(LINUX) || defined(ULTRIX) || defined(CYGWIN32) \
|
||||
/* the high quality random number routines */
|
||||
#ifndef USE_ISAAC64
|
||||
# if defined(BSD) || defined(LINUX) || defined(ULTRIX) || defined(CYGWIN32) \
|
||||
|| defined(RANDOM) || defined(__APPLE__)
|
||||
#define Rand() random()
|
||||
#else
|
||||
#define Rand() lrand48()
|
||||
# define Rand() random()
|
||||
# else
|
||||
# define Rand() lrand48()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef TIMED_DELAY
|
||||
@@ -408,5 +411,18 @@
|
||||
# define RUNTIME_PASTEBUF_SUPPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* /dev/random is blocking on Linux, so there we default to /dev/urandom which
|
||||
* should still be good enough.
|
||||
* BSD systems usually have /dev/random that is supposed to be used.
|
||||
*/
|
||||
#ifdef LINUX
|
||||
# define DEV_RANDOM "/dev/urandom"
|
||||
#else
|
||||
# ifdef BSD
|
||||
# define DEV_RANDOM "/dev/random"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* UNIXCONF_H */
|
||||
#endif /* UNIX */
|
||||
|
||||
@@ -243,17 +243,19 @@ typedef __mode_t mode_t;
|
||||
#define rindex strrchr
|
||||
|
||||
/* Use the high quality random number routines. */
|
||||
#if defined(RANDOM)
|
||||
#define Rand() random()
|
||||
#ifndef USE_ISAAC64
|
||||
# if defined(RANDOM)
|
||||
# define Rand() random()
|
||||
/* VMS V7 adds these entry points to DECC$SHR; stick with the nethack-supplied
|
||||
code to avoid having to deal with version-specific conditionalized builds
|
||||
*/
|
||||
#define random nh_random
|
||||
#define srandom nh_srandom
|
||||
#define initstate nh_initstate
|
||||
#define setstate nh_setstate
|
||||
#else
|
||||
#define Rand() rand()
|
||||
# define random nh_random
|
||||
# define srandom nh_srandom
|
||||
# define initstate nh_initstate
|
||||
# define setstate nh_setstate
|
||||
# else
|
||||
# define Rand() rand()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
|
||||
@@ -141,11 +141,14 @@
|
||||
#define index strchr
|
||||
#define rindex strrchr
|
||||
#define USE_STDARG
|
||||
#ifdef RANDOM
|
||||
|
||||
/* Use the high quality random number routines. */
|
||||
#define Rand() random()
|
||||
#else
|
||||
#define Rand() rand()
|
||||
#ifndef USE_ISAAC64
|
||||
# ifdef RANDOM
|
||||
# define Rand() random()
|
||||
# else
|
||||
# define Rand() rand()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define FCMASK 0660 /* file creation mask */
|
||||
|
||||
Reference in New Issue
Block a user