xref: /original-bsd/games/battlestar/misc.c (revision 5d3a6356)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #ifndef lint
14 static char sccsid[] = "@(#)misc.c	5.1 (Berkeley) 05/08/88";
15 #endif /* not lint */
16 
17 #include "externs.h"
18 
19 card(array, size)		/* for beenthere, injuries */
20 	register char *array;
21 	int size;
22 {
23 	register char *end = array + size;
24 	register int i = 0;
25 
26 	while (array < end)
27 		if (*array++)
28 			i++;
29 	return (i);
30 }
31 
32 ucard(array)
33 	register unsigned *array;
34 {
35 	register int j = 0, n;
36 
37 	for (n = 0; n < NUMOFOBJECTS; n++)
38 		if (testbit(array, n))
39 			    j++;
40 	return (j);
41 }
42