first cut at new makefile; file reorg, new depend
[unix-history] / usr / src / games / sail / parties.c
CommitLineData
b5f0675e 1/*
1e008c14 2 * Copyright (c) 1983 Regents of the University of California.
c0ca48ec
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
65c7d3b6
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
b5f0675e
EW
16 */
17
0bcf0267 18#ifndef lint
65c7d3b6 19static char sccsid[] = "@(#)parties.c 5.3 (Berkeley) %G%";
c0ca48ec 20#endif /* not lint */
b3a57661 21
0bcf0267
CL
22#include "externs.h"
23
24meleeing(from, to)
b3a57661
EW
25struct ship *from;
26register struct ship *to;
0bcf0267 27{
b3a57661
EW
28 register struct BP *p = from->file->OBP;
29 register struct BP *q = p + NBP;
0bcf0267 30
b3a57661
EW
31 for (; p < q; p++)
32 if (p->turnsent && p->toship == to)
33 return 1;
34 return 0;
0bcf0267
CL
35}
36
b3a57661
EW
37boarding(from, isdefense)
38register struct ship *from;
39char isdefense;
0bcf0267 40{
b3a57661
EW
41 register struct BP *p = isdefense ? from->file->DBP : from->file->OBP;
42 register struct BP *q = p + NBP;
0bcf0267 43
b3a57661
EW
44 for (; p < q; p++)
45 if (p->turnsent)
46 return 1;
47 return 0;
0bcf0267
CL
48}
49
b3a57661
EW
50unboard(ship, to, isdefense)
51register struct ship *ship, *to;
52register char isdefense;
0bcf0267 53{
b3a57661
EW
54 register struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP;
55 register n;
0bcf0267 56
b3a57661
EW
57 for (n = 0; n < NBP; p++, n++)
58 if (p->turnsent && (p->toship == to || isdefense || ship == to))
59 Write(isdefense ? W_DBP : W_OBP, ship, 0, n, 0, 0, 0);
0bcf0267 60}