share+amiga: gate pcmain.c nhuuid for CROSS_TO_AMIGA, drop amidos.c copy

amidos.c had a byte-identical copy of the RFC 4122 v4 generator
already living under CROSS_TO_ATARI in sys/share/pcmain.c.
This commit is contained in:
Ingo Paschke
2026-05-22 15:20:50 -04:00
committed by nhmall
parent 189a0b8c3f
commit ced5744fe6
2 changed files with 56 additions and 48 deletions
-38
View File
@@ -45,44 +45,6 @@ amiga_self_assign(void)
UnLock(dup);
}
/* Generate an RFC 4122 v4 UUID for this game. Draw bytes from the
core's ISAAC64 RNG, which init_random() seeded before we get here. */
void
get_nhuuid(void)
{
uchar bytes[16];
int i;
if (svn.nhuuid[0])
return;
for (i = 0; i < 16; i++)
bytes[i] = (uchar) rn2(256);
/* RFC 4122: version=4 (random), variant=10. */
bytes[6] = (bytes[6] & 0x0F) | 0x40;
bytes[8] = (bytes[8] & 0x3F) | 0x80;
Snprintf(svn.nhuuid, sizeof svn.nhuuid,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x",
bytes[0], bytes[1], bytes[2], bytes[3],
bytes[4], bytes[5],
bytes[6], bytes[7],
bytes[8], bytes[9],
bytes[10], bytes[11], bytes[12], bytes[13],
bytes[14], bytes[15]);
}
void
free_nhuuid(void)
{
int i;
for (i = 0; i < SIZE(svn.nhuuid); i++) {
svn.nhuuid[i] = 0;
}
}
#include "winext.h"
#include "winproto.h"
+56 -10
View File
@@ -12,7 +12,7 @@
#include <signal.h>
#endif
#if !defined(AMIGA) && !defined(__DJGPP__)
#if !defined(AMIGA) && !defined(__DJGPP__) && !defined(__MINT__)
#include <sys\stat.h>
#else
#include <sys/stat.h>
@@ -27,9 +27,7 @@ char orgdir[PATHLEN]; /* also used in pcsys.c, amidos.c */
#ifdef TOS
boolean run_from_desktop = TRUE; /* should we pause before exiting?? */
#ifdef __GNUC__
long _stksize = 16 * 1024;
#endif
/* _stksize is owned by sys/atari/tos.c for the 5.0 GEM build. */
#endif
#ifdef AMIGA
@@ -119,7 +117,6 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
#endif
#ifdef TOS
long clock_time;
if (*argv[0]) { /* only a CLI can give us argv[0] */
gh.hname = argv[0];
run_from_desktop = FALSE;
@@ -342,10 +339,6 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/*
* It seems you really want to play.
*/
#ifdef TOS
if (comp_times((long) time(&clock_time)))
error("Your clock is incorrectly set!");
#endif
if (!dlb_init()) {
pline(
"%s\n%s\n%s\n%s\n\nNetHack was unable to open the required file "
@@ -779,7 +772,48 @@ free_nhuuid(void)
}
#endif
#if defined(CROSS_TO_AMIGA)
#if defined(CROSS_TO_ATARI) || defined(CROSS_TO_AMIGA)
/* Generate an RFC 4122 v4 UUID for this game. Draw bytes from the
core's ISAAC64 RNG, which init_random() seeded before we get here. */
void
get_nhuuid(void)
{
uchar bytes[16];
int i;
if (svn.nhuuid[0])
return;
for (i = 0; i < 16; i++)
bytes[i] = (uchar) rn2(256);
/* RFC 4122: version=4 (random), variant=10. */
bytes[6] = (bytes[6] & 0x0F) | 0x40;
bytes[8] = (bytes[8] & 0x3F) | 0x80;
Snprintf(svn.nhuuid, sizeof svn.nhuuid,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x",
bytes[0], bytes[1], bytes[2], bytes[3],
bytes[4], bytes[5],
bytes[6], bytes[7],
bytes[8], bytes[9],
bytes[10], bytes[11], bytes[12], bytes[13],
bytes[14], bytes[15]);
}
void
free_nhuuid(void)
{
int i;
for (i = 0; i < SIZE(svn.nhuuid); i++) {
svn.nhuuid[i] = 0;
}
}
#endif
#if defined(CROSS_TO_AMIGA) || defined(CROSS_TO_ATARI)
#ifdef CROSS_TO_AMIGA
void msmsg
VA_DECL(const char *, fmt)
{
@@ -790,6 +824,18 @@ VA_DECL(const char *, fmt)
VA_END();
return;
}
#endif
#ifdef CROSS_TO_ATARI
void
msmsg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
fflush(stdout);
}
#endif
unsigned long
sys_random_seed(void)