split some code into separate files

new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
This commit is contained in:
nhmall
2024-03-07 11:01:04 -05:00
parent c22900fb63
commit 50811037f3
43 changed files with 5913 additions and 5677 deletions
+81
View File
@@ -227,4 +227,85 @@ rnz(int i)
return (int) x;
}
/* Sets the seed for the random number generator */
#ifdef USE_ISAAC64
static void
set_random(unsigned long seed,
int (*fn)(int))
{
init_isaac64(seed, fn);
}
#else /* USE_ISAAC64 */
/*ARGSUSED*/
static void
set_random(unsigned long seed,
int (*fn)(int) UNUSED)
{
/*
* The types are different enough here that sweeping the different
* routine names into one via #defines is even more confusing.
*/
# ifdef RANDOM /* srandom() from sys/share/random.c */
srandom((unsigned int) seed);
# else
# if defined(__APPLE__) || defined(BSD) || defined(LINUX) \
|| defined(ULTRIX) || defined(CYGWIN32) /* system srandom() */
# if defined(BSD) && !defined(POSIX_TYPES) && defined(SUNOS4)
(void)
# endif
srandom((int) seed);
# else
# ifdef UNIX /* system srand48() */
srand48((long) seed);
# else /* poor quality system routine */
srand((int) seed);
# endif
# endif
# endif
}
#endif /* USE_ISAAC64 */
/* An appropriate version of this must always be provided in
port-specific code somewhere. It returns a number suitable
as seed for the random number generator */
extern unsigned long sys_random_seed(void);
/*
* Initializes the random number generator.
* Only call once.
*/
void
init_random(int (*fn)(int))
{
set_random(sys_random_seed(), fn);
}
/* Reshuffles the random number generator. */
void
reseed_random(int (*fn)(int))
{
/* only reseed if we are certain that the seed generation is unguessable
* by the players. */
if (has_strong_rngseed)
init_random(fn);
}
/* randomize the given list of numbers 0 <= i < count */
void
shuffle_int_array(int *indices, int count)
{
int i, iswap, temp;
for (i = count - 1; i > 0; i--) {
if ((iswap = rn2(i + 1)) == i)
continue;
temp = indices[i];
indices[i] = indices[iswap];
indices[iswap] = temp;
}
}
/*rnd.c*/