Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/worm Check for screen sizes that are too small. Fix o...



details:   https://anonhg.NetBSD.org/src/rev/8ac390446a84
branches:  trunk
changeset: 514344:8ac390446a84
user:      jsm <jsm%NetBSD.org@localhost>
date:      Thu Aug 30 10:49:50 2001 +0000

description:
Check for screen sizes that are too small.  Fix off-by-one error in
trying to place the prize.  Position the score appropriately for
screens that may not be 80 columns wide.

diffstat:

 games/worm/worm.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r 33a04bc3ab01 -r 8ac390446a84 games/worm/worm.c
--- a/games/worm/worm.c Thu Aug 30 09:32:23 2001 +0000
+++ b/games/worm/worm.c Thu Aug 30 10:49:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: worm.c,v 1.20 2001/08/29 23:25:58 jsm Exp $    */
+/*     $NetBSD: worm.c,v 1.21 2001/08/30 10:49:50 jsm Exp $    */
 
 /*
  * Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)worm.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: worm.c,v 1.20 2001/08/29 23:25:58 jsm Exp $");
+__RCSID("$NetBSD: worm.c,v 1.21 2001/08/30 10:49:50 jsm Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,6 +117,15 @@
 #endif
        slow = (baudrate() <= 1200);
        clear();
+       if (COLS < 18 || LINES < 5) {
+               /*
+                * Insufficient room for the line with " Worm" and the
+                * score if fewer than 18 columns; insufficient room for
+                * anything much if fewer than 5 lines.
+                */
+               endwin();
+               errx(1, "screen too small");
+       }
        if (argc == 2)
                start_len = atoi(argv[1]);
        if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3))
@@ -225,7 +234,7 @@
        struct body * bp;
 {
        do {
-               bp->y = rnd(LINES-3)+ 2;
+               bp->y = rnd(LINES-3)+ 1;
                bp->x = rnd(COLS-3) + 1;
                wmove(tv, bp->y, bp->x);
        } while(winch(tv) != ' ');
@@ -311,7 +320,7 @@
                prize();
                score += growing;
                running = 0;
-               wmove(stw, 0, 68);
+               wmove(stw, 0, COLS - 12);
                wprintw(stw, "Score: %3d", score);
                wrefresh(stw);
        }



Home | Main Index | Thread Index | Old Index