Commit Graph

2336 Commits

Author SHA1 Message Date
mrg b44101216d fix new GCC 12 warning that can't happen by forcing unsigned context for
values that are always positive by this point.
2023-08-01 07:55:57 +00:00
mrg f8570f8a97 fix simple mis-matched function prototype and definitions.
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.
2023-08-01 07:04:14 +00:00
pho 9904cea545 hack(6): Fix a segfault that occurs when ASLR is enabled
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.
2023-07-30 09:23:21 +00:00
nia d92552c3ea tetris(6): Support the informal standard of allowing setting NO_COLOR
in the environment to disable the use of color. (no-color.org)
2023-07-01 10:51:35 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
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.
2023-06-03 09:09:01 +00:00
andvar 9719c27fea fix various typos in comments. 2023-06-01 20:15:16 +00:00
mrg cefbb2f39f add 2004's "@" definition. 2023-06-01 04:08:36 +00:00
dholland 75411a3871 add a fortune 2023-05-28 03:35:24 +00:00
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
rillig e550a84370 cgram: replace comments with code
No binary change.
2023-05-10 12:30:27 +00:00
christos 8499346dc4 Handle OpenSSL-3.x 2023-05-09 20:02:59 +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
rillig 952d3d39d2 quiz: fix wrong usage of the <ctype.h> functions 2023-01-22 17:19:11 +00:00
ryoon 3d47461f07 Define yes as extern veriable to fix build
PR bin/57164 is insufficient.
2023-01-06 19:02:02 +00:00
christos ab841a2491 PR/57164: Greywolf: Add -y to cribbage to keep playing without asking 2023-01-06 17:13:46 +00:00
nia 4441b2db86 -h doesn't sort numerically, pointed out by various 2022-10-25 19:33:00 +00:00
nia 44a8f0feb5 various tips/simplifications from UnitedBSD 2022-10-25 15:44:02 +00:00
dholland 93a94d32f0 fortunes: add something 2022-09-09 19:37:15 +00:00
dholland 82db4c7824 fortunes: add something 2022-08-26 20:07:04 +00:00
uwe 7a3a96c13a ching(6): Fix formatting. .Pp is not .br
The man returns to the proper path.  Auspicious.
2022-08-19 00:40:20 +00:00
andvar 5a58ccfbec fix various typos in comments, documentation and messages.
mainly s/paramater/parameter/ and s/reduntant/redundant/.
2022-08-07 11:06:18 +00:00
rillig f1e042b8d2 fix references in manual pages to the reference documentation 2022-06-28 20:12:52 +00:00
andvar 0e5bc969e0 fix various typos in comments. 2022-06-27 22:41:28 +00:00
christos 02e7c0b99a Enable FANCY mode for debugging purposes:
- 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
2022-06-27 18:48:49 +00:00
rillig a37d11d413 gomoku: remove redundant parentheses
No binary change.
2022-06-19 10:33:17 +00:00
rillig 3dd0208726 gomoku: reduce usage of magic numbers in the code
No binary change.
2022-06-19 10:23:48 +00:00
rillig 158db354d4 cgram: allow cursor navigation with KEY_BEG as well 2022-06-12 14:59:44 +00:00
christos 780fb67fe8 Elide vax breakage 2022-05-31 19:11:58 +00:00
rillig 2309756cc1 gomoku: clean up variable names, add empty lines
No binary change.
2022-05-29 22:03:29 +00:00
rillig b29fe38f22 gomoku: clean up color handling in 'pickmove'
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.
2022-05-29 21:47:12 +00:00
rillig e17d9875fe gomoku: clean up 'pickmove' stylistically
No functional change.
2022-05-29 21:38:36 +00:00
rillig a9ff97e44e gomoku: migrate remaining functions to type player_color
No functional change.
2022-05-29 21:02:37 +00:00
rillig 2a44525455 gomoku: make parsing of the debug command 'o' robust
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.
2022-05-29 20:21:28 +00:00
rillig 6084941245 gomoku: clean up overlap info in 'checkframes'
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.
2022-05-29 18:25:39 +00:00
rillig 388688984b gomoku: do not scan the upper border for combos
Adding the '+ 1' to the row coordinate added an offset of 20, while the
intended offset was 1.

No functional change, just a bit faster.
2022-05-29 18:05:25 +00:00
rillig fe75e7f249 gomoku: refine the type of some functions and variables
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.
2022-05-29 17:01:42 +00:00
rillig 1f981c0ac1 gomoku: when starting a new game, start in the middle of the board
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.
2022-05-29 16:30:44 +00:00
rillig 28df150fd1 gomoku: after accepting a spot via the mouse, clear current coordinate 2022-05-29 16:19:52 +00:00
rillig 6b2dc434d3 gomoku: add type player_color
No functional change.
2022-05-29 15:31:12 +00:00
rillig d48c60b1a6 gomoku: use unsigned integers for bit sets
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.
2022-05-29 15:16:11 +00:00
rillig e3d95fb4b0 gomoku: provide a more gentle introduction to the code
No binary change.
2022-05-29 14:50:37 +00:00
rillig 7167cb1f23 gomoku: don't use 'i' as special-purpose variable name
No binary change.
2022-05-29 14:37:44 +00:00
rillig 5a52a51bdb gomoku: consistently name the offset of a spot in a frame 'off'
Leave 'i' for general purpose loops.

No functional change.
2022-05-29 14:01:57 +00:00
rillig 5e10e7e916 gomoku: add data type for one of the 4 directions of a frame
No functional change.
2022-05-29 13:49:10 +00:00