Terrible things were done in the name of pacifying some ancient LINT
program: undo all that.
NitroHack commit 5de56436e4ec278b5b30ffd4b74482815c3aaff5
Also clean up some weird formatting caused by cproto in src/hacklib.c.
Now compiles with gcc -Werror=old-style-definition. It should also be
valid C23, although I haven't tried compiling with -std=c2x yet -
there might be something else making it invalid.
This also allows getting rid of (UN)WIDENED_PROTOTYPES and _P defines.
I kept OBJ_P, MONST_P, and DLB_P for now.
Done mostly by running
cproto -Iinclude -C"int\nf(\n\ta,\n\tb)" -F"int\nf(a, b)" -pa
then
sed -i 's/^\(\(static \)\?[a-zA-Z]\+\) $/\1/'
on each file, with some manual corrections/adjustments done after and
anything cproto can't handle manually converted. The sed is to remove
the extra space that cproto adds at the end of the line with the
return type name.
"register" is inconsistently sometimes removed - generally, I removed
it when I did it manually but cproto didn't. GCC ignores register
anyway so this shouldn't matter much.
Always enabled:
SYSV, LINUX, POSIX_TYPES
Removed:
LATTICE, BSD, ULTRIX, ultrix, ULTRIX_PROTO, AIX_31, _BULL_SOURCE,
_AIX32, NeXT, SUNOS4, BOS, GENIX, HISX, UNIXPC, CYGWIN32, HPUX, SVR4,
PCMUSIC, DGUX, AMIX, LSC, DLBRSRC, OPTION_LISTS_ONLY
(Some of these, specifically PCMUSIC, DLBRSRC, and OPTION_LISTS_ONLY
are not UNIX-related. I just forgot to remove them earlier.)
Also:
Fix a "#ifdef GOLDotmp" in artifact.c (this exists in dNetHack,
presumably a bad find/replace for obj -> otmp).
Clean up system.h by including header files where possible.
Unfortunately, we can't include term.h since some of the macro
names (like bell) conflict.
Based on vanilla commit fabf9cd9017ce13e31f47e364cd15a2daff9f75a:
VA_DECL/VA_END usage
Make the variadic functions look more like ordinary code rather than
have the function opening brace be hidden inside the VA_DECL() macro.
That brace is still there, but VA_DECL() now needs to be followed by
a visible brace (which introduces a nested block rather than the
start of the funciton). VA_END() now provides a hidden closing brace
to end the nested block, and the existing closing brace still matches
the one in VA_DECL().
Sample usage:
void foo VA_DECL(int, arg) --macro expansion has a hidden opening brace
{ --new, explicit opening brace (actually introduces a nested block)
VA_START(bar);
...code for foo...
VA_END(); --expansion now provides a closing brace for the nested block
} --existing closing brace, still pairs with the hidden one in VA_DECL()
This should help if/when another round of reformatting ever takes place,
and also with editors or other tools that do brace/bracket/parenthesis
matching.
I had forgotten that there were variadic functions in sys/* and ended
up modifying a lot more files than intended. The majority of changes
to those just inserted a new '{' line so that revised VA_END()'s '}'
won't introduce a syntax error. A couple of them needed VA_END() moved
so that local variables wouldn't go out of scope too soon. Only the
Unix ones have been tested.
IBMgraphics support is implemented by translating to UTF-8, so it
requires a UTF-8 supporting terminal, but not code page 437.
Also:
-Enable HAVE_SETLOCALE by default (it is part of standard C and
required for curses UTF8graphics support).
-Use a new check for UTF-8 support (taken from UnNetHack). It is
slower (it works by writing two non-breaking spaces and checking the
cursor position), but should be better at detecting UTF-8 support than
the old one.
--A side-effect of these changes is that UTF8graphics is now default
with many configurations: this was always supposed to be the
case (there is code for detecting support for various symsets and
setting them if applicable as the default), but the check for
UTF8graphics only happened if HAVE_SETLOCALE was set (which was
disabled by default). The new check for UTF8graphics does not use
setlocale and HAVE_SETLOCALE is default now anyway.
-Remove default angel symbol overrides from IBMgraphics because they
were broken: they didn't work if you started the game with IBMgraphics
and the "monsters" option set (but did if you switched to IBMgraphics
later), and weren't reset when you switched away from IBMgraphics,
resulting in broken symbols until you restarted the game. I'm not
sure what the proper solution for this is: the game shouldn't override
the player's settings, but the "monsters" option doesn't support
UTF-8, and changing some other monster symbols shouldn't make it
impossible to use the fancy angel symbols.
-Fix some curses memory leaks.
Based on the following commits from UnNetHack:
f6e3f519e: Support UTF8graphics on curses
4931c6d2d: Support IBMgraphics on curses
fb551d4d1: Default to UTF8graphics on supporting terminals
d19886aae: Fix memory leaks in curses port
As well as several commits fixing bugs in the previously listed commits:
704efb5be: UTF-8 detection: re-read current terminal settings before disabling read timeout
2db4b9dba: More careful setting the terminal into raw mode
ec0a68fb5: Remove unnecessary utf8 initialization code
Funnily enough, this only affects the maze levels between the Challenge and the Castle.
Literally every level of Gehennom is a special level (or is the invocation level).