summaryrefslogtreecommitdiffstats
path: root/source/y/bsd-games/patches/0007-Unsorted-Debian-patches.patch
blob: a31120a9e85e256d640ad7f9039ff2573043c52d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
From: Tobias Quathamer <toddy@debian.org>
Date: Mon, 26 Mar 2012 10:07:17 +0200
Subject: Unsorted Debian patches

---
 adventure/crc.c                  |  4 +++-
 arithmetic/arithmetic.6          |  2 +-
 backgammon/backgammon/move.c     |  3 +++
 backgammon/common_source/allow.c |  4 +++-
 backgammon/teachgammon/ttext1.c  |  2 +-
 backgammon/teachgammon/ttext2.c  |  2 +-
 dab/gamescreen.h                 |  6 ++---
 dm/dm.c                          |  6 ++---
 fish/Makefrag                    |  8 ++++---
 fish/fish.6                      |  4 ++--
 gomoku/gomoku.6                  |  2 +-
 hack/Makefrag                    |  3 ++-
 hack/config.h                    | 15 ++++++++-----
 hunt/hunt/hunt.6.in              |  2 +-
 hunt/hunt/hunt.c                 |  6 +++--
 hunt/hunt/playit.c               |  4 ++--
 number/number.c                  | 47 ++++++++++++++++++++++++++--------------
 sail/pl_main.c                   |  2 +-
 tests/number.-0.1                |  2 +-
 tetris/scores.c                  | 17 +++++++++------
 trek/setup.c                     |  5 ++++-
 21 files changed, 92 insertions(+), 54 deletions(-)

diff --git a/adventure/crc.c b/adventure/crc.c
index 66504f1..c6ee5f1 100644
--- a/adventure/crc.c
+++ b/adventure/crc.c
@@ -42,6 +42,8 @@ __RCSID("$NetBSD: crc.c,v 1.8 2003/08/07 09:36:50 agc Exp $");
 #endif
 #endif /* not lint */
 
+#include <limits.h>
+
 #include "extern.h"
 
 const unsigned long crctab[] = {
@@ -125,7 +127,7 @@ crc(ptr, nr)		/* Process nr bytes at a time; ptr points to them */
 
 	while (nr > 0)
 		for (p = ptr; nr--; ++p) {
-			if (!(i = crcval >> 24 ^ *p)) {
+			if (!(i = crcval >> (sizeof(crcval) * CHAR_BIT - 8) ^ *p)) {
 				i = step++;
 				if (step >= sizeof(crctab) / sizeof(crctab[0]))
 					step = 0;
diff --git a/arithmetic/arithmetic.6 b/arithmetic/arithmetic.6
index b8d4d8f..bc41bca 100644
--- a/arithmetic/arithmetic.6
+++ b/arithmetic/arithmetic.6
@@ -79,7 +79,7 @@ divide by or subtract will be between 0 and
 .Nm
 will not ask you to divide by 0.)
 The default
-.I range
+.It range
 is 10.
 .El
 .Pp
diff --git a/backgammon/backgammon/move.c b/backgammon/backgammon/move.c
index 9fd81f1..027cab5 100644
--- a/backgammon/backgammon/move.c
+++ b/backgammon/backgammon/move.c
@@ -152,6 +152,9 @@ move(okay)
 	trymove(0, 0);
 	pickmove();
 
+	if (d0)
+		swap;
+
 	/* print move */
 	writel(" and moves ");
 	for (i = 0; i < mvlim; i++) {
diff --git a/backgammon/common_source/allow.c b/backgammon/common_source/allow.c
index f6bae78..8189f07 100644
--- a/backgammon/common_source/allow.c
+++ b/backgammon/common_source/allow.c
@@ -83,8 +83,10 @@ movallow()
 				p[i--] = bar;
 				if (p[i] != bar)
 					continue;
-				else
+				else if (d0)
 					break;
+				swap;
+				continue;
 			}
 			if (d0 || m == 4)
 				break;
diff --git a/backgammon/teachgammon/ttext1.c b/backgammon/teachgammon/ttext1.c
index 82db223..73ea6ee 100644
--- a/backgammon/teachgammon/ttext1.c
+++ b/backgammon/teachgammon/ttext1.c
@@ -94,7 +94,7 @@ const char   *const intro2[] = {
 	"\n   Although not indicated on the board, the players' homes are",
 	"located just to the right of the board.  A player's men are placed",
 	"there when they are removed from the board.  The board you just",
-	"saw was in it's initial position.  All games start with the board",
+	"saw was in its initial position.  All games start with the board",
 	"looking like this.  Notice that red's pieces are represented by the",
 	"letter 'r' and white's pieces are represented by the letter 'w'.",
 	"Also, a position may have zero or more pieces on it, e.g.  posi-",
diff --git a/backgammon/teachgammon/ttext2.c b/backgammon/teachgammon/ttext2.c
index 5e827d7..eb9a083 100644
--- a/backgammon/teachgammon/ttext2.c
+++ b/backgammon/teachgammon/ttext2.c
@@ -65,7 +65,7 @@ const char   *const stragy[] = {
 	"points in a row) are difficult to form, many points nestled close-",
 	"ly together produce a formidable barrier.  Also, while it is good",
 	"to move back men forward, doing so lessens the opportunity for you",
-	"to hit men.  Finally, remember that once the two player's have",
+	"to hit men.  Finally, remember that once the two players have",
 	"passed each other on the board, there is no chance of either team",
 	"being hit, so the game reduces to a race off the board.  Addi-",
 	"tional hints on strategy are presented in the practice game.",
diff --git a/dab/gamescreen.h b/dab/gamescreen.h
index ca90cb3..b3db2ea 100644
--- a/dab/gamescreen.h
+++ b/dab/gamescreen.h
@@ -70,9 +70,9 @@ class GAMESCREEN {
     virtual void redraw(void) = 0;			// Refresh
     virtual int getinput(void) = 0;			// Get user input
     virtual void bell(void) = 0;			// Beep
-    virtual void score(size_t p, const PLAYER& p) = 0;	// Post current score
-    virtual void games(size_t p, const PLAYER& p) = 0;	// Post games won
-    virtual void total(size_t p, const PLAYER& p) = 0;	// Post total score
+    virtual void score(size_t s, const PLAYER& p) = 0;	// Post current score
+    virtual void games(size_t s, const PLAYER& p) = 0;	// Post games won
+    virtual void total(size_t s, const PLAYER& p) = 0;	// Post total score
     virtual void ties(const PLAYER& p) = 0;		// Post tie games
 };
 
diff --git a/dm/dm.c b/dm/dm.c
index c131904..16129d8 100644
--- a/dm/dm.c
+++ b/dm/dm.c
@@ -134,19 +134,19 @@ read_config()
 	while (fgets(lbuf, sizeof(lbuf), cfp))
 		switch (*lbuf) {
 		case 'b':		/* badtty */
-			if (sscanf(lbuf, "%s%s", f1, f2) != 2 ||
+			if (sscanf(lbuf, "%39s%39s", f1, f2) != 2 ||
 			    strcasecmp(f1, "badtty"))
 				break;
 			c_tty(f2);
 			break;
 		case 'g':		/* game */
-			if (sscanf(lbuf, "%s%s%s%s%s",
+			if (sscanf(lbuf, "%39s%39s%39s%39s%39s",
 			    f1, f2, f3, f4, f5) != 5 || strcasecmp(f1, "game"))
 				break;
 			c_game(f2, f3, f4, f5);
 			break;
 		case 't':		/* time */
-			if (sscanf(lbuf, "%s%s%s%s", f1, f2, f3, f4) != 4 ||
+			if (sscanf(lbuf, "%39s%39s%39s%39s", f1, f2, f3, f4) != 4 ||
 			    strcasecmp(f1, "time"))
 				break;
 			c_day(f2, f3, f4);
diff --git a/fish/Makefrag b/fish/Makefrag
index 1039af5..1fec493 100644
--- a/fish/Makefrag
+++ b/fish/Makefrag
@@ -31,7 +31,9 @@ fish_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(FISH_INSTRFILE))
 fish_all:	fish/fish fish/fish.instr fish/fish.6
 
 fish_install:	fish_all
-	$(INSTALL_BINARY) fish/fish $(INSTALL_PREFIX)$(GAMESDIR)/fish
-	$(HIDE_GAME) fish
+	$(INSTALL_BINARY) fish/fish $(INSTALL_PREFIX)$(GAMESDIR)/go-fish
+	$(HIDE_GAME) go-fish
 	$(INSTALL_DATA) fish/fish.instr $(INSTALL_PREFIX)$(FISH_INSTRFILE)
-	$(INSTALL_MANUAL) fish/fish.6
+	ln -sf fish.6 fish/go-fish.6 # hack for rename
+	$(INSTALL_MANUAL) fish/go-fish.6
+	rm -f fish/go-fish.6
diff --git a/fish/fish.6 b/fish/fish.6
index 398c55f..46eef2b 100644
--- a/fish/fish.6
+++ b/fish/fish.6
@@ -30,10 +30,10 @@
 .\"	@(#)fish.6	8.1 (Berkeley) 5/31/93
 .\"
 .Dd May 31, 1993
-.Dt FISH 6
+.Dt GO-FISH 6
 .Os
 .Sh NAME
-.Nm fish
+.Nm go-fish
 .Nd play
 .Dq Go Fish
 .Sh SYNOPSIS
diff --git a/gomoku/gomoku.6 b/gomoku/gomoku.6
index f78eb0e..024da85 100644
--- a/gomoku/gomoku.6
+++ b/gomoku/gomoku.6
@@ -45,7 +45,7 @@
 .Op Ar inputfile
 .Sh DESCRIPTION
 .Nm
-is a two player game were the object is to get 5 in a row horizontally,
+is a two player game where the object is to get 5 in a row horizontally,
 vertically or diagonally on a 19 by 19 grid.
 By convention, black always moves first.
 With no arguments,
diff --git a/hack/Makefrag b/hack/Makefrag
index eabbd2a..5807ef0 100644
--- a/hack/Makefrag
+++ b/hack/Makefrag
@@ -56,7 +56,8 @@ hack_install:	hack_all
 	$(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/hack
 	$(HIDE_GAME) hack
 	$(INSTALL_HACK_DIR) $(INSTALL_PREFIX)$(HACK_DIR)
-	set -e; for f in data help hh rumors; do $(INSTALL_DATA) hack/$$f $(INSTALL_PREFIX)$(HACK_DIR)/$$f; done
+	install -d $(INSTALL_PREFIX)/usr/share/games/bsdgames/hack
+	set -e; for f in data help hh rumors; do $(INSTALL_DATA) hack/$$f $(INSTALL_PREFIX)/usr/share/games/bsdgames/hack/$$f; done
 	$(INSTALL_SCORE_FILE) $(HACK_DIR)/perm
 	$(INSTALL_SCORE_FILE) $(HACK_DIR)/record
 	$(INSTALL_MANUAL) hack/hack.6
diff --git a/hack/config.h b/hack/config.h
index ad3bbcf..03a8b02 100644
--- a/hack/config.h
+++ b/hack/config.h
@@ -88,13 +88,18 @@
 /* #define PYRAMID_BUG */	/* avoid a bug on the Pyramid */
 /* #define NOWAITINCLUDE */	/* neither <wait.h> nor <sys/wait.h> exists */
 
-#define WIZARD  "bruno"	/* the person allowed to use the -D option */
+/*
+ * Debian mods: use root for WIZARD, and move files that are static to
+ * /usr/share/ -- JEH
+ */
+#define WIZARD  "root"	/* the person allowed to use the -D option */
+#define SHAREDIR "/usr/share/games/bsdgames/hack/"
 #define RECORD	"record"/* the file containing the list of topscorers */
 #define	NEWS	"news"	/* the file containing the latest hack news */
-#define	HELP	"help"	/* the file containing a description of the commands */
-#define	SHELP	"hh"	/* abbreviated form of the same */
-#define	RUMORFILE	"rumors"	/* a file with fortune cookies */
-#define	DATAFILE	"data"	/* a file giving the meaning of symbols used */
+#define	HELP	SHAREDIR "help"	/* the file containing a description of the commands */
+#define	SHELP	SHAREDIR "hh"	/* abbreviated form of the same */
+#define	RUMORFILE	SHAREDIR "rumors"	/* a file with fortune cookies */
+#define	DATAFILE	SHAREDIR "data"	/* a file giving the meaning of symbols used */
 #define	FMASK	0660	/* file creation mask */
 #define	HLOCK	"perm"	/* an empty file used for locking purposes */
 #define LLOCK	"safelock"	/* link to previous */
diff --git a/hunt/hunt/hunt.6.in b/hunt/hunt/hunt.6.in
index 406296e..22e45ec 100644
--- a/hunt/hunt/hunt.6.in
+++ b/hunt/hunt/hunt.6.in
@@ -387,7 +387,7 @@ how many of player's shots were ducked
 how many slime kills player had
 .It enemy
 how many enemies were killed
-.tI friend
+.It friend
 how many friends were killed (self and same team)
 .It deaths
 how many times player died
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index 11f4c44..28321bc 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -394,7 +394,8 @@ broadcast_vec(s, vector)
 
 	vec_cnt = 0;
 	for (ip = ifp; ip; ip = ip->ifa_next)
-		if ((ip->ifa_addr->sa_family == AF_INET) &&
+		if (ip->ifa_addr &&
+		    (ip->ifa_addr->sa_family == AF_INET) &&
 		    (ip->ifa_flags & IFF_BROADCAST))
 			vec_cnt++;
 
@@ -405,7 +406,8 @@ broadcast_vec(s, vector)
 
 	vec_cnt = 0;
 	for (ip = ifp; ip; ip = ip->ifa_next)
-		if ((ip->ifa_addr->sa_family == AF_INET) &&
+		if (ip->ifa_addr &&
+		    (ip->ifa_addr->sa_family == AF_INET) &&
 		    (ip->ifa_flags & IFF_BROADCAST))
 			memcpy(&(*vector)[vec_cnt++], ip->ifa_broadaddr,
 			       sizeof(struct sockaddr_in));
diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c
index 9acf86e..881a4e7 100644
--- a/hunt/hunt/playit.c
+++ b/hunt/hunt/playit.c
@@ -114,7 +114,7 @@ playit()
 		bad_con();
 		/* NOTREACHED */
 	}
-	if (ntohl(version) != (unsigned long)HUNT_VERSION) {
+	if (ntohl(version) != (uint32_t)HUNT_VERSION) {
 		bad_ver();
 		/* NOTREACHED */
 	}
@@ -649,7 +649,7 @@ do_message()
 		bad_con();
 		/* NOTREACHED */
 	}
-	if (ntohl(version) != (unsigned long)HUNT_VERSION) {
+	if (ntohl(version) != (uint32_t)HUNT_VERSION) {
 		bad_ver();
 		/* NOTREACHED */
 	}
diff --git a/number/number.c b/number/number.c
index c7559e1..3086a86 100644
--- a/number/number.c
+++ b/number/number.c
@@ -78,9 +78,9 @@ static const char	*const name1[] = {
 
 void	convert(char *);
 int	main(int, char *[]);
-int	number(const char *, int);
-void	pfract(int);
-int	unit(int, const char *);
+int	number(const char *, int, int *);
+void	pfract(int, int);
+int	unit(int, const char *, int *);
 void	usage(void) __attribute__((__noreturn__));
 
 int lflag;
@@ -131,7 +131,7 @@ void
 convert(line)
 	char *line;
 {
-	int flen, len, rval;
+	int flen, len, rval, singular;
 	char *p, *fraction;
 
 	flen = 0;
@@ -174,7 +174,7 @@ badnum:			errx(1, "illegal number: %s", line);
 		--len;
 	}
 
-	rval = len > 0 ? unit(len, line) : 0;
+	rval = len > 0 ? unit(len, line, &singular) : 0;
 	if (fraction != NULL && flen != 0)
 		for (p = fraction; *p != '\0'; ++p)
 			if (*p != '0') {
@@ -182,10 +182,10 @@ badnum:			errx(1, "illegal number: %s", line);
 					(void)printf("%sand%s",
 					    lflag ? " " : "",
 					    lflag ? " " : "\n");
-				if (unit(flen, fraction)) {
+				if (unit(flen, fraction, &singular)) {
 					if (lflag)
 						(void)printf(" ");
-					pfract(flen);
+					pfract(flen, singular);
 					rval = 1;
 				}
 				break;
@@ -197,9 +197,10 @@ badnum:			errx(1, "illegal number: %s", line);
 }
 
 int
-unit(len, p)
+unit(len, p, singular)
 	int len;
 	const char *p;
+	int *singular;
 {
 	int off, rval;
 
@@ -208,7 +209,7 @@ unit(len, p)
 		if (len % 3) {
 			off = len % 3;
 			len -= off;
-			if (number(p, off)) {
+			if (number(p, off, singular)) {
 				rval = 1;
 				(void)printf(" %s%s",
 				    name3[len / 3], lflag ? " " : ".\n");
@@ -217,14 +218,16 @@ unit(len, p)
 		}
 		for (; len > 3; p += 3) {
 			len -= 3;
-			if (number(p, 3)) {
+			if (number(p, 3, singular)) {
 				rval = 1;
 				(void)printf(" %s%s",
 				    name3[len / 3], lflag ? " " : ".\n");
 			}
 		}
 	}
-	if (number(p, len)) {
+	if (number(p, len, singular)) {
+		if (rval)
+			*singular = 0;
 		if (!lflag)
 			(void)printf(".\n");
 		rval = 1;
@@ -233,17 +236,20 @@ unit(len, p)
 }
 
 int
-number(p, len)
+number(p, len, singular)
 	const char *p;
 	int len;
+	int *singular;
 {
 	int val, rval;
 
 	rval = 0;
+	*singular = 1;
 	switch (len) {
 	case 3:
 		if (*p != '0') {
 			rval = 1;
+			*singular = 0;
 			(void)printf("%s hundred", name1[*p - '0']);
 		}
 		++p;
@@ -262,33 +268,42 @@ number(p, len)
 			}
 			rval = 1;
 		}
+		if (val != 1)
+			*singular = 0;
 		break;
 	case 1:
 		if (*p != '0') {
 			rval = 1;
 			(void)printf("%s", name1[*p - '0']);
 		}
+		if (*p != '1')
+			*singular = 0;
 	}
 	return (rval);
 }
 
 void
-pfract(len)
+pfract(len, singular)
 	int len;
+	int singular;
 {
 	static const char *const pref[] = { "", "ten-", "hundred-" };
 
 	switch(len) {
 	case 1:
-		(void)printf("tenths.\n");
+		(void)printf("tenth");
 		break;
 	case 2:
-		(void)printf("hundredths.\n");
+		(void)printf("hundredth");
 		break;
 	default:
-		(void)printf("%s%sths.\n", pref[len % 3], name3[len / 3]);
+		(void)printf("%s%sth", pref[len % 3], name3[len / 3]);
 		break;
 	}
+	if (!singular) {
+		printf("s");
+	}
+	printf(".\n");
 }
 
 void
diff --git a/sail/pl_main.c b/sail/pl_main.c
index 6183420..b8b26b1 100644
--- a/sail/pl_main.c
+++ b/sail/pl_main.c
@@ -219,7 +219,7 @@ reprint:
 		printf("\nInitial broadside %s (grape, chain, round, double): ",
 			n ? "right" : "left");
 		fflush(stdout);
-		scanf("%s", buf);
+		scanf("%9s", buf);
 		switch (*buf) {
 		case 'g':
 			load = L_GRAPE;
diff --git a/tests/number.-0.1 b/tests/number.-0.1
index fea1e89..69c365b 100644
--- a/tests/number.-0.1
+++ b/tests/number.-0.1
@@ -1,3 +1,3 @@
 minus
 one.
-tenths.
+tenth.
diff --git a/tetris/scores.c b/tetris/scores.c
index d731e25..c2d36c9 100644
--- a/tetris/scores.c
+++ b/tetris/scores.c
@@ -335,7 +335,8 @@ checkscores(hs, num)
 				continue;
 			}
 		}
-		levelfound[sp->hs_level] = 1;
+		if (sp->hs_level < NLEVELS && sp->hs_level >= 0)
+			levelfound[sp->hs_level] = 1;
 		i++, sp++;
 	}
 	return (num > MAXHISCORES ? MAXHISCORES : num);
@@ -374,11 +375,13 @@ showscores(level)
 	for (i = MINLEVEL; i < NLEVELS; i++)
 		levelfound[i] = 0;
 	for (i = 0, sp = scores; i < nscores; i++, sp++) {
-		if (levelfound[sp->hs_level])
-			sp->hs_time = 0;
-		else {
-			sp->hs_time = 1;
-			levelfound[sp->hs_level] = 1;
+		if (sp->hs_level < NLEVELS && sp->hs_level >= 0) {
+			if (levelfound[sp->hs_level])
+				sp->hs_time = 0;
+			else {
+				sp->hs_time = 1;
+				levelfound[sp->hs_level] = 1;
+			}
 		}
 	}
 
@@ -433,7 +436,7 @@ printem(level, offset, hs, n, me)
 				continue;
 			}
 			sp = &hs[item];
-			(void)sprintf(buf,
+			(void)snprintf(buf, sizeof(buf),
 			    "%3d%c %6d  %-11s (%6d on %d)",
 			    item + offset, sp->hs_time ? '*' : ' ',
 			    sp->hs_score * sp->hs_level,
diff --git a/trek/setup.c b/trek/setup.c
index 1f14f27..fab5136 100644
--- a/trek/setup.c
+++ b/trek/setup.c
@@ -234,11 +234,14 @@ setup()
 	for (i = 0; i < NQUADS; i++)
 		for (j = 0; j < NQUADS; j++)
 		{
+			signed char tmp;
 			q = &Quad[i][j];
 			q->klings = q->bases = 0;
 			q->scanned = -1;
 			q->stars = ranf(9) + 1;
-			q->holes = ranf(3) - q->stars / 5;
+			tmp = ranf(3) - q->stars / 5;
+			tmp = tmp < 0 ? 0 : tmp;
+			q->holes = tmp;
 			q->qsystemname = 0;
 		}