When a single word exceeds the visible message-window width the
wrap loop found no whitespace, called outmore(cw), and continued
without advancing str -- and on the next iteration curx==0 took
it straight back to the same spot. Force-break the word at the
column boundary when we are already at the start of a line.
Also reset the wrapping static flag to 0 after the NHW_BASE wrap
cleanup runs, so the cleanup fires once after a wrap instead of
on every subsequent putstr.
Make the BufferQueueChar macro bounds-check KbdBuffered against
KBDBUFFER internally so the RAWKEY and NEWSIZE 'R'-64 paths can
no longer push past the 10-byte queue; widen KbdBuffered to int
so the counter cannot wrap silently in the queue-scan loops.
In amii_cleanup move kill_nhwindows()/DeleteMsgPort() outside
the Forbid()/Permit() pair: CloseWindow can wait on layers.library
semaphores on OS 3.x and that is unsafe under Forbid. Keep only
the IDCMP-flush loop inside.
Guard the gd lookup in DoMenuScroll's GADGETUP/MOUSEMOVE branches
so a window with no GadgetID==1 does not deref NULL; match the
existing guards in the keyboard-scroll branches. In the keyboard
selector and MENU_UNSELECT_ALL paths, only mutate items with
canselect set so a non-selectable header cannot have its str
stomped. Clamp MENU_LAST_PAGE topidx to >= 0. Make find_menu_item
return NULL on negative idx instead of the head item. Guard the
PROMPTFIRST data[] shuffle behind cury > 0.
In amii_destroy_nhwindow's NHW_OVER branch use cw->win with a NULL
guard instead of dereferencing amii_wins[WIN_OVER]->win blindly.
Range-check the type argument to amii_create_nhwindow. Fix the
*argv_in[1] precedence bug so the -L/-l flag does not deref NULL
when it is the last argument. Wrap AllocAslRequest result in a
NULL check before AslRequestTags/FreeAslRequest.
Defensively bounds-check the idx argument to DispCol. Replace
the -25937 signed-int literal in clipwin's PropInfo with the
equivalent UWORD value 39599. Simplify amii_start_menu's free
loop; switch DoMenuScroll's inventory title and Count display to
Snprintf, and stop passing countString to pline as a format.
Right-size the Intuition string-gadget buffer to BUFSZ so a caller
with a BUFSZ-sized buffer cannot be overflowed. Enlarge the
amii_yn_function prompt buffer to fit the worst-case query + resp
+ def + trailing space and switch the appends to Snprintf with
remaining-space tracking. Replace sprintf in amii_display_file's
"Can't display X: Y" path with Snprintf. In EditColor's Save path
drop the strcpy/strcat chain that could trail off the end of
oname/nname when dirname returned a near-full path; use Snprintf
instead. Rewrite dirname() to copy first and truncate the copy,
so it no longer briefly NULs the caller's string.
Add AMII_PALETTE_SIZE / AMIV_PALETTE_SIZE in amiconf.h to make the
actual populated portion of the init-map arrays explicit. Drop the
redundant extern void exit() declaration. Annotate Abort with
NORETURN in both amiconf.h and winproto.h; drop the duplicate Abort
declaration further down winproto.h.
Convert the bare-token "CLIPPING must be defined" assertion in
windefs.h into a real #error directive.
Comment in winext.h to disambiguate the three similarly named
amii*_init*map palette arrays.
The UNTESTED #ifdef in freediskspace was never gated by any hints
file, so the unsigned-long-long path could only be enabled by a
stray manual #define -- in which case the return type is still
long and silently truncates. Remove the branches.
In fopenp the separator '/' write was unchecked: when the path
segment exactly filled the buffer to BUFSIZ-2 it would land at
buf[BUFSIZ-1] and the follow-on NUL would write past the end.
Guard the write.
Replace #pragma-pack BMP header reads with little-endian byte
readers so the tool works on any host endianness. Add dimension
and color-count range checks, zero-init pixel remap table, check
calloc, free bmpdata on early returns, send malloc errors to
stderr. Add bp>xbuf guards to xpmgetline's strip loop.
- amii_set_text_font called CloseLibrary(DiskfontBase) outside the
OpenLibrary guard; on Kickstart V36+ that is a no-op for a NULL
handle, but on V33/V34 it is undefined. Move the close inside
the if-block where DiskfontBase is known non-NULL.
- amii_get_ext_cmd's bounds check used BUFSZ for an obufp[100]
buffer; the tighter COLNO check actually bounded it but the
expression was misleading. Use sizeof obufp.
- MyAllocBitMap left bm->bm.Planes[] uninitialized; InitBitMap only
fills BytesPerRow/Rows/Flags/Depth, not Planes[]. If AllocRaster
fails mid-loop, MyFreeBitMap was iterating up to Depth and would
pass uninitialized stack-garbage pointers to FreeRaster. Zero
Planes[] before the alloc loop.
- ReadImageFile leaked iffparse.library, the IFFHandle, the DOS file
handle, and any open-IFF state on every panic path. On AmigaOS
those handles are not auto-reclaimed when the process dies, so
each failure stranded resources until reboot. Restructure to a
single cleanup label and free in reverse-acquisition order before
panicking.
- OpenIFF returns an error code that was being thrown away, so a
failed open would feed corrupt state to ParseIFF. Check and
bail.
- MyAllocBitMap left bm->mflags uninitialized, so MyFreeBitMap took the
wrong path between FreeRaster and FreeMem and intermittently corrupted
exec's free list (Software Failure 0x81000005, DEADEND in FreeMem).
- The NHW_OVER window is BORDERLESS, so attaching WINDOWSIZING |
WINDOWDRAG | WINDOWCLOSE created phantom gadgets that hit-test against
unrelated input. Pressing ESC while the overview was selected fired
CLOSEWINDOW and destroyed the window underneath the running code,
leading to wild-PC crashes. Drop the gadget flags; SHIFT-HELP already
toggles the overview cleanly via delayed_key_action.
- amii_destroy_nhwindow only reset WIN_MAP / WIN_STATUS / WIN_MESSAGE /
WIN_INVEN; WIN_OVER and WIN_BASE kept pointing at freed slots, so any
later 'WIN_X != WIN_ERR && amii_wins[WIN_X]->win' check dereferenced
NULL. Reset them too.
Without the dependency, 'make amigapkg' would copy whatever was
already in targets/amiga/ without ever rebuilding when sources
changed -- silently shipping a stale binary.
- fname[18]/sprintf risks overflow for >=10 in any version field;
switch to snprintf into a wider static buffer.
- (1L << i) for i==31 (or shifting into the depth-loop terminator)
is undefined for signed long; use 1UL.
- Drop unused cnt= from amii_display_nhwindow's DoMenuScroll call;
the menu return value is consumed elsewhere, not here.
When a vault guard is being moving off the map to <0,0> to wait until
his temporary corridor gets removed, don't try to update the map for
that off-the-screen location in order to avoid triggering impossible()
from newsym().
Plus a trivial tweak to NH_abort(). Its argument is never modified so
declare it as such.
DoMenuScroll dropped IDCMP messages for non-owner windows -- so a
resize of WIN_INVEN or close-gadget on WIN_OVER during a menu never
reached the game state. Forward those to ProcessMessage;
VANILLAKEY/RAWKEY stay with the menu.
The macros were strcmp("amiv", windowprocs.name)==0 at every reference
-- 72 sites including inner loops. Use the 5.0 core's WINDOWPORT(wn)
which compares wp_id.
Tile loading hard-coded "NetHack:tiles/tiles{16,32}.iff" and PORT_HELP
hard-coded "nethack:amii.hlp". Route through fqname(DATAPREFIX) so
DATADIR= overrides apply. Refresh amii.hlp to 5.0 content, ship it via
amigapkg, and document HACKDIR / SAVEDIR / BONESDIR examples in
nethack.cnf.
Remove legacy compiler guards and stale extern declarations (the
ami_wbench_* family, CopyFile, ami_argset, ami_mkargline, FromWBench).
Drop unused AMII_*_VOLUME / DEFAULT_ICON macros and the
IDCMP_CLOSEWINDOW auto-define.
Delete amigst.c (empty) and amitty.c (TTY/BBS stub). Drop WINVERS_AMIT,
SUPERBITMAP_MAP, EXTMENU, SHELL/dosh(), and the bbs_id reference in
src/files.c.
- 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.