Amiga: more review fixes
- NHW_BASE / NHW_OVER collided with NHW_PERMINVENT=6; renumber off NHW_LAST_TYPE. - GlyphToIcon used > 10000 instead of >=. - make_menu_items sized array by sizeof(amii_menu_item) instead of menu_item. - DoMenuScroll could deref NULL amip on SELECTUP. - get_nhuuid uses ISAAC64 rn2() instead of hand-rolled LCG. - fopenp's bound check fired one byte too late. - winami.p had stale signatures for amii_end_menu, amii_select_menu, amii_suspend_nhwindows.
This commit is contained in:
+2
-2
@@ -117,8 +117,8 @@ typedef struct WEVENT {
|
||||
/* port specific variable declarations */
|
||||
extern winid WIN_BASE;
|
||||
extern winid WIN_OVER;
|
||||
#define NHW_BASE 6
|
||||
#define NHW_OVER 7 /* overview window */
|
||||
#define NHW_BASE (NHW_LAST_TYPE + 1)
|
||||
#define NHW_OVER (NHW_LAST_TYPE + 2) /* overview window */
|
||||
|
||||
extern struct amii_WinDesc *amii_wins[MAXWIN + 1];
|
||||
|
||||
|
||||
+5
-16
@@ -47,30 +47,19 @@ amiga_self_assign(void)
|
||||
UnLock(dup);
|
||||
}
|
||||
|
||||
/* Generate an RFC 4122 v4 UUID for this game. Entropy comes from
|
||||
DateStamp + the running task's address mixed through a small LCG. */
|
||||
/* 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];
|
||||
struct DateStamp ds;
|
||||
unsigned long x;
|
||||
int i;
|
||||
|
||||
if (svn.nhuuid[0])
|
||||
return;
|
||||
|
||||
DateStamp(&ds);
|
||||
x = (unsigned long) ds.ds_Days
|
||||
^ ((unsigned long) ds.ds_Minute << 16)
|
||||
^ ((unsigned long) ds.ds_Tick << 8)
|
||||
^ (unsigned long) FindTask(NULL);
|
||||
/* Classic glibc/POSIX rand() LCG (Knuth, C99 7.22.2.1). Full period
|
||||
2^32; we read bits 16-23 to skip the LCG's bad low bits. */
|
||||
for (i = 0; i < 16; i++) {
|
||||
x = x * 1103515245u + 12345u;
|
||||
bytes[i] = (uchar) (x >> 16);
|
||||
}
|
||||
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;
|
||||
@@ -481,7 +470,7 @@ fopenp(const char *name, const char *mode)
|
||||
while (pp && *pp) {
|
||||
bp = buf;
|
||||
while (*pp && *pp != PATHSEP) {
|
||||
if (bp > buf + BUFSIZ - 1)
|
||||
if (bp >= buf + BUFSIZ - 1)
|
||||
return (NULL);
|
||||
lastch = *bp++ = *pp++;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ make_menu_items(struct amii_WinDesc *cw, menu_item **rmip)
|
||||
}
|
||||
|
||||
if (idx) {
|
||||
mmip = *rmip = (menu_item *) alloc(idx * sizeof(*mip));
|
||||
mmip = *rmip = (menu_item *) alloc(idx * sizeof(menu_item));
|
||||
for (mip = cw->menu.items; mip; mip = mip->next) {
|
||||
if (mip->selected) {
|
||||
mmip->item = mip->identifier;
|
||||
@@ -982,8 +982,8 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
|
||||
amip->str[SOFF + 2] = '-';
|
||||
}
|
||||
}
|
||||
if (counting && amip->selected && amip->canselect
|
||||
&& amip->selector) {
|
||||
if (amip && counting && amip->selected
|
||||
&& amip->canselect && amip->selector) {
|
||||
amip->count = count;
|
||||
reset_counting = TRUE;
|
||||
amip->str[SOFF + 2] = '#';
|
||||
|
||||
@@ -340,6 +340,11 @@ struct win_setup new_wins[] = {
|
||||
22,
|
||||
78 },
|
||||
|
||||
/* NHW_PERMINVENT — placeholder; port does not implement persistent
|
||||
inventory yet, but the slot must exist because new_wins[] is
|
||||
indexed by NHW_* type. */
|
||||
{ { 0 } },
|
||||
|
||||
/* NHW_BASE */
|
||||
{ { 0, 0, WIDTH, WINDOWHEIGHT, 0xff, 0xff,
|
||||
RAWKEY | MENUPICK | MOUSEBUTTONS,
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ void amii_raw_print(const char *);
|
||||
void amii_raw_print_bold(const char *);
|
||||
void amii_start_menu(winid , unsigned long );
|
||||
void amii_add_menu(winid, const glyph_info *, const anything *, char, char, int, int, const char *, unsigned int);
|
||||
void amii_end_menu(winid , char , const char * , const char *);
|
||||
char amii_select_menu(winid );
|
||||
void amii_end_menu(winid, const char *);
|
||||
int amii_select_menu(winid, int, menu_item **);
|
||||
void amii_update_inventory(int);
|
||||
void amii_mark_synch (void);
|
||||
void amii_wait_synch (void);
|
||||
@@ -46,7 +46,7 @@ void cursor_on(winid );
|
||||
void amii_getret (void);
|
||||
void amii_getlin(const char * , char *);
|
||||
void getlind(const char * , char * , const char *);
|
||||
void amii_suspend_nhwindows(char * );
|
||||
void amii_suspend_nhwindows(const char *);
|
||||
void amii_resume_nhwindows(void);
|
||||
void amii_bell(void);
|
||||
void EditColor(void);
|
||||
|
||||
+1
-1
@@ -805,7 +805,7 @@ GlyphToIcon(int glyph)
|
||||
glyph_info gi;
|
||||
|
||||
map_glyphinfo(0, 0, glyph, 0, &gi);
|
||||
if (glyph > 10000)
|
||||
if (glyph >= 10000)
|
||||
return glyph;
|
||||
return (gi.gm.tileidx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user