xref: /original-bsd/games/sail/parties.c (revision 542201aa)
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[] = "@(#)parties.c	5.2 (Berkeley) 03/09/88";
15 #endif /* not lint */
16 
17 #include "externs.h"
18 
19 meleeing(from, to)
20 struct ship *from;
21 register struct ship *to;
22 {
23 	register struct BP *p = from->file->OBP;
24 	register struct BP *q = p + NBP;
25 
26 	for (; p < q; p++)
27 		if (p->turnsent && p->toship == to)
28 			return 1;
29 	return 0;
30 }
31 
32 boarding(from, isdefense)
33 register struct ship *from;
34 char isdefense;
35 {
36 	register struct BP *p = isdefense ? from->file->DBP : from->file->OBP;
37 	register struct BP *q = p + NBP;
38 
39 	for (; p < q; p++)
40 		if (p->turnsent)
41 			return 1;
42 	return 0;
43 }
44 
45 unboard(ship, to, isdefense)
46 register struct ship *ship, *to;
47 register char isdefense;
48 {
49 	register struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP;
50 	register n;
51 
52 	for (n = 0; n < NBP; p++, n++)
53 		if (p->turnsent && (p->toship == to || isdefense || ship == to))
54 			Write(isdefense ? W_DBP : W_OBP, ship, 0, n, 0, 0, 0);
55 }
56