diff options
Diffstat (limited to 'games/worms')
-rw-r--r-- | games/worms/worms.6 | 7 | ||||
-rw-r--r-- | games/worms/worms.c | 12 |
2 files changed, 15 insertions, 4 deletions
diff --git a/games/worms/worms.6 b/games/worms/worms.6 index 98e1fd4f2b8..6a47e7c9762 100644 --- a/games/worms/worms.6 +++ b/games/worms/worms.6 @@ -1,4 +1,4 @@ -.\" $OpenBSD: worms.6,v 1.10 2003/06/03 03:01:42 millert Exp $ +.\" $OpenBSD: worms.6,v 1.11 2004/01/08 20:38:29 millert Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -59,7 +59,10 @@ Makes each worm leave a trail behind it. Specifies a delay, in milliseconds, between each update. This is useful for fast terminals. Reasonable values are around 20-200. -The default is 0. +The default is based on the terminal speed. +If the terminal is 9600 baud or slower no delay is used. +Otherwise, the delay is computed via the following formula: +.Dl delay = speed / 9600 - 1. .It Fl l Specifies a length for each worm; the default is 16. .It Fl n diff --git a/games/worms/worms.c b/games/worms/worms.c index eece179e73e..b8b51dd6f92 100644 --- a/games/worms/worms.c +++ b/games/worms/worms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worms.c,v 1.15 2003/06/03 03:01:42 millert Exp $ */ +/* $OpenBSD: worms.c,v 1.16 2004/01/08 20:38:29 millert Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: worms.c,v 1.15 2003/06/03 03:01:42 millert Exp $"; +static char rcsid[] = "$OpenBSD: worms.c,v 1.16 2004/01/08 20:38:29 millert Exp $"; #endif #endif /* not lint */ @@ -67,6 +67,7 @@ static char rcsid[] = "$OpenBSD: worms.c,v 1.15 2003/06/03 03:01:42 millert Exp #include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <termios.h> #include <unistd.h> static const struct options { @@ -193,8 +194,15 @@ main(argc, argv) int CO, LI, last, bottom, ch, length, number, trail; short **ref; const char *field; + struct termios term; + speed_t speed; u_int delay = 0; + /* set default delay based on terminal baud rate */ + if (tcgetattr(STDOUT_FILENO, &term) == 0 && + (speed = cfgetospeed(&term)) > B9600) + delay = (speed / B9600) - 1; + length = 16; number = 3; trail = ' '; |