Module Name:    src
Committed By:   martin
Date:           Tue Apr 25 16:12:05 UTC 2023

Modified Files:
        src/games/worms [netbsd-10]: worms.6 worms.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #148):

        games/worms/worms.c: revision 1.24
        games/worms/worms.c: revision 1.25
        games/worms/worms.c: revision 1.26
        games/worms/worms.c: revision 1.27
        games/worms/worms.c: revision 1.28
        games/worms/worms.c: revision 1.29
        games/worms/worms.6: revision 1.17

Garbage collect "char *mp" - it used to point at memory malloc()'d
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

80 column police.

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).

When worms default delay was changed from 0, to 20ms (Oct 2020)
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).

Correct some unfortunate behaviour in extreme cases pointed out by RVP.
(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.

Typo in an error message (pointed out by RVP; Thanks)

Another err message typo!   (found this one myself!!)


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.6.1 src/games/worms/worms.6
cvs rdiff -u -r1.23 -r1.23.6.1 src/games/worms/worms.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Reply via email to