Commit Graph

47 Commits

Author SHA1 Message Date
kre 061aa945dd When using -H, make the appearance of the worm head depend upon the body
(more than it did before).
2023-05-12 13:29:41 +00:00
kre 8552e825c7 Add a little optional colour, optionally distinguish worm heads,
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.
2023-04-26 22:58:09 +00:00
kre 960a3d1781 Another err message typo! (found this one myself!!) 2023-04-19 09:39:29 +00:00
kre 85eb242dbc Typo in an error message (pointed out by RVP; Thanks) 2023-04-19 07:40:49 +00:00
kre e92b04bbd5 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.
2023-04-18 15:02:22 +00:00
kre f71e70709c 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).
2023-04-15 15:21:56 +00:00
kre 4e195bc50c 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).
2023-04-15 13:40:23 +00:00
kre 6fa96c66bf 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
2023-04-15 13:00:30 +00:00
nia 7aac251b81 worms(6): Use a reasonable default delay for non-1980s terminals.
This is still fast, but not unreasonably fast.
2020-10-14 07:32:53 +00:00
wiz fb9125d78a - improve wording
- sort option list
- add argument names in option list and descriptions and adjust table width
- improve punctuation
- bump date

From Bug Hunting.
2012-08-12 17:30:03 +00:00
dholland 277bd0756c WARNS=5, and make WARNS=5 the default for src/games. 2012-06-19 05:46:08 +00:00
plunky 9f61b80465 NULL does not need a cast 2011-08-31 16:24:54 +00:00
he 76d4444c78 When using -lcurses, you also need -lterminfo.
This fixes the build for sun2, and also builds with LDSTATIC=-static,
since archive libraries don't record inter-library dependencies.
2010-02-06 23:45:24 +00:00
dholland da121b3331 sprinkle static 2009-08-12 08:54:54 +00:00
joerg aee82d7c52 Fix preamble 2009-03-11 13:06:10 +00:00
drochner 432ec04420 if initscr() fails, exit with a message rather than crash in the
next curses call
2008-08-08 16:10:47 +00:00
lukem 2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
dholland d4f48e67da Make the default WARNS for games 4. The only game that needs to set WARNS
to anything else now is rogue, so clear WARNS from the other makefiles.
2008-01-28 07:03:58 +00:00
perry 8b0f9554ff convert __attribute__s to applicable cdefs.h macros 2007-12-15 19:44:37 +00:00
rillig 54195a73e6 Increased WARNS to 4, since it passes both gcc333 and gcc411 on i386. 2007-06-06 06:10:50 +00:00
christos 42728e787e Slimy worms are clean enough for level 3. 2004-11-13 10:22:13 +00:00
christos 82345479d5 Don't try to catch SIGSTOP... 2004-09-12 04:51:32 +00:00
hubertf 6162c9b1a1 Properly handle -d 1000, OK'd by jsm 2004-03-29 20:30:03 +00:00
jsm a12bf9a7e0 Hide the cursor if possible. From OpenBSD. 2004-02-08 22:21:57 +00:00
jsm cb5fd8342e Remove uses of __P. 2004-01-27 20:30:28 +00:00
agc e5aeb4ea46 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22269, verified by myself.
2003-08-07 09:36:50 +00:00
wiz 0d22e30cd0 New sentences begin on new lines.
Patch from Richard Elz, slightly improved by yours truly.
2002-09-26 16:12:39 +00:00
wiz 834bb1b3ab Whitespace and/or punctuation fixes. 2001-04-02 22:42:37 +00:00
hubertf a71d955669 This patch converts worms(6) to use curses, thereby
simplifying the code and improving its portability.  It also adds a
delay option from OpenBSD, to allow reasonable speed display on fast
terminals, adds use of const, and fixes signal handling and use of
errx() where appropriate.

Patch supplied in PR 6661 by Joseph Myers <jsm28@cam.ac.uk>.
1999-07-30 02:23:27 +00:00
erh 55f3a4b91b Fix .Bl/.El imbalance. 1999-03-10 09:29:08 +00:00
hubertf 1c9494f62b mark non-returning functions (PR#6144 by Joseph Myers <jsm28@cam.ac.uk>) 1998-09-13 15:27:25 +00:00
fair dc026e0515 Change occurrences of "UNIX" to .Ux or .At as appropriate. 1998-04-28 06:00:51 +00:00
jtc 2065ddb3da Simply include -lcurses instead of -lcurses -ltermcap 1998-02-18 22:37:30 +00:00
lukem e9954a7422 WARNSify 1997-10-12 02:12:45 +00:00
cgd 1f32e00e53 fix window size update code. 1995-04-22 08:09:22 +00:00
cgd 5725dd8581 un-munge import; it apparently didn't import properly. 1995-04-22 08:07:59 +00:00
cgd ff134ba07f rough cleanup of import. RCS Ids 1995-04-22 08:00:54 +00:00
jtc 2536b9a62f Make man page and usage message agree with the code.
Fix from Hubert Feyrer.
1995-01-31 15:54:01 +00:00
cgd c4c01d75b2 specify man pages the new way. 1994-12-22 09:31:26 +00:00
mycroft 3719ae5272 Clean this up a little, and use TOCGWINSW. 1994-04-05 00:21:20 +00:00
jtc defa0d9f09 Update to use new -mandoc macros. 1993-08-05 01:46:15 +00:00
mycroft e9d867ef50 Add RCS identifiers. 1993-08-01 17:54:45 +00:00
mycroft b1bd4afedc Add RCS indentifiers. 1993-08-01 07:42:49 +00:00
mycroft cda4f8f6ee Add RCS identifiers. 1993-08-01 05:37:30 +00:00
mycroft f7f4b85ce9 Cleanup for GCC 2. 1993-04-18 21:52:18 +00:00
cgd f620d7d9f6 got rid of unnecessary -lcompat and associated dependency 1993-03-23 02:44:38 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00