most of these are like, eg
void foo(int[2]);
with either of these
void foo(int*) { ... }
void foo(int[]) { ... }
in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.
found by GCC 12.
Prior to this change, savenames() would store "objects" in save files as a
blob, and restnames() would load it and overwrite "objects". But since
objclass::oc_name and oc_descr are pointers to string constants, they would
be invalid when the next time the process is spawned, and opening the
inventory would crash by dereferencing invalid pointers.
Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.
GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH
Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
and optionally randomise worm lengths. Just exit instead of
continuing with a nonsense display if the window shrinks (and
for consistency if it grows).
Most of the ideas and code from RVP. Bugs and man page mangling
from me.
(Very long worms in a smallish window could result in the max number of
worms being 0...)
While here (also suggested by RVP) seed the random number generator,
also add a -S option to set the seed (note: while this is documented
in the updated man page, it does not appear in the usage message in
case of an error ... not likely to be used often enough to include there).
Also some minor improvements suggested by RVP:
delete the prototype for main()
exit curses mode before abort() (which should not happen, but...)
no need to return (->exit) after abort() as modern abort() can
never return.
In addition, check for extraneous (ignored) (non-option) args.
Check for absurdly small or big screens (the worm placement algorithm
doesn't work well for lines of columns < 3, and the abort() mentioned
above actually happens if one of those is == 1).
More flavours of worms added.
Some minor man page wording improvements.
it lost the ability to run flat out (no sleeps) - which while not
very useful for actually observing the behaviour of various Nematoda,
can be useful when 'worms' is being used to generate cpu heat - it
turns out to be a simple tool to make all of the app itself, the
xterm it runs in (when running under X) and the X server, all more
or less continuously busy - a trivial perpetual CPU load generator.
Changing that was not a simple matter of just allowing -d 0..1000
rather than -d 1..1000 which had always been the limits on -d, as
previously, simply by excluding 0, common error checking wasn't
essential. -djunk would return 0 which was invalid, and so an error
- that it was invalid because 0 < 1, rather than because "junk" is not
a number wasn't material.
Now we need some slightly more elaborate error checking code for the
-d value, and if we're going to do that, may as well do the same for
the -l and -n options, which also take numeric values. That is, it
will no longer be possible to say:
worms -n "5 worms"
Just the number is allowed (but -d now allows a "ms" or "us" suffix).
While here, place a reasonable upper limit (depending upon the
screen size, and worm length) upon the number of worms, so they
have somewhere to go, rather than just on top of each other.
exit(1) from the errx() rather than 0, in the case that curses
initscr() fails (doesn't seem right that it should appear as a
successful run of worms, if it never managed to start).
A couple more minor 80 column violations are handled, without
further penalty, in this update (one simply vanishes, the other
is wrapped).
Note that this sounds like a lot, but it is really all just minor
internal bookkeeping updates - the only real advertised user visible
change is the ability to use -d0 which just restores that which was
the default (though it could never be set via the option) until Oct 2020
- so really all that's happening is replacing minor functionality lost
then, while leaving the change of the default delay that that change
made, untouched.
No man page update required (that never excluded -d0).
If this code were just a few chars over the limit, it might get
let off with a warning, but 214 in an 80 zone is way beyond that.
Six months loss of coding licence, and a 214000 character fine.
NFCI.
(I verified the the code was unchanged by joining the resulting
lines back into one again, and then diff'ing that line against
the original - it is identical).
to hold the termcap entry, back when worms used termcap rather than
curses, and termcap was termcap, rather that a terminfo wannabe.
This should have been removed when worms was converted to curses in
1999, but wasn't, so worms has been doing a meaningless malloc(1024)
and never using the result, ever since.
While here, since the line needed changing anyway to remove mp,
change a malloc() of a product into calloc() so it can deal with
any possible (admittedly extremely unlikely here) integer overflows.
NFCI
- To enable stand still mode (robot is not moving but waiting in place),
specify a scorefile on the command line called <directory>/stand_still
- To enable pattern roll mode (robot is changing which move to look first)
specify a scorefile on the command line called <directory>/pattern_roll
Instead of searching for the best black and white moves, search instead
for our and their best moves. This makes the code simpler and more
uniform, as the strategy is the same for Black and White.
No functional change.
Previously, the (invalid) debug command 'o,' succeeded to parse and led
to out-of-bounds memory access. Add proper parsing for the arguments of
that debug command. Add a short usage for that debug command, as
guessing the usage from the previous code was time-consuming due to the
large amount of ad-hoc low-level parsing code.
When leaving debug mode, clear the debug prompt.
In 2009, GCC had complained that the overlap_info might only be
partially filled. All possible code paths are sane though, so that was
probably a bug in GCC.
Remove the comment and the unnecessary initialization, rename the
variable since it doesn't match its behavior anymore. Sync nearby
comments with reality; there is no array anywhere near.
No functional change.
Assisted by WARNS=6. At that level, there are several warnings about
type conversion between small integer types that would only clutter the
code, therefore stay at WARNS=5. Same for lint's -aa option.
No functional change.
Previously, when starting a new game, the user coordinate was kept at
the previously selected spot. Since playing in the center is common
sense, reset the coordinate.
As all access to the bit sets happens through the unsigned spot_index
type, drop the type casts in the macros.
No functional change on 2s complement machines.