Commit | Line | Data |
---|---|---|
b5f0675e | 1 | /* |
1e008c14 | 2 | * Copyright (c) 1983 Regents of the University of California. |
c0ca48ec KB |
3 | * All rights reserved. |
4 | * | |
b2e7427f | 5 | * %sccs.include.redist.c% |
b5f0675e EW |
6 | */ |
7 | ||
3df86079 | 8 | #ifndef lint |
b2e7427f | 9 | static char sccsid[] = "@(#)dr_5.c 5.4 (Berkeley) %G%"; |
c0ca48ec | 10 | #endif /* not lint */ |
b5f0675e | 11 | |
3df86079 CL |
12 | #include "externs.h" |
13 | ||
14 | subtract(from, totalfrom, crewfrom, fromcap, pcfrom) | |
b3a57661 EW |
15 | struct ship *from, *fromcap; |
16 | int pcfrom; | |
3df86079 CL |
17 | register int totalfrom, crewfrom[3]; |
18 | { | |
19 | register int n; | |
20 | ||
b3a57661 EW |
21 | if (fromcap == from && totalfrom) { /* if not captured */ |
22 | for (n = 0; n < 3; n++) { | |
23 | if (totalfrom > crewfrom[n]) { | |
3df86079 CL |
24 | totalfrom -= crewfrom[n]; |
25 | crewfrom[n] = 0; | |
b3a57661 | 26 | } else { |
3df86079 CL |
27 | crewfrom[n] -= totalfrom; |
28 | totalfrom = 0; | |
29 | } | |
3df86079 | 30 | } |
b3a57661 EW |
31 | Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0); |
32 | } else if (totalfrom) { | |
3df86079 CL |
33 | pcfrom -= totalfrom; |
34 | pcfrom = pcfrom < 0 ? 0 : pcfrom; | |
b3a57661 | 35 | Write(W_PCREW, from, 0, pcfrom, 0, 0, 0); |
3df86079 CL |
36 | } |
37 | } | |
38 | ||
b3a57661 EW |
39 | mensent(from, to, crew, captured, pc, isdefense) |
40 | struct ship *from, *to, **captured; | |
41 | int crew[3], *pc; | |
42 | char isdefense; | |
3df86079 CL |
43 | { /* returns # of crew squares sent */ |
44 | int men = 0; | |
45 | register int n; | |
46 | int c1, c2, c3; | |
b3a57661 | 47 | register struct BP *bp; |
3df86079 | 48 | |
b3a57661 EW |
49 | *pc = from->file->pcrew; |
50 | *captured = from->file->captured; | |
51 | crew[0] = from->specs->crew1; | |
52 | crew[1] = from->specs->crew2; | |
53 | crew[2] = from->specs->crew3; | |
54 | bp = isdefense ? from->file->DBP : from->file->OBP; | |
55 | for (n=0; n < NBP; n++, bp++) { | |
56 | if (bp->turnsent && bp->toship == to) | |
57 | men += bp->mensent; | |
3df86079 | 58 | } |
b3a57661 | 59 | if (men) { |
3df86079 CL |
60 | c1 = men/100 ? crew[0] : 0; |
61 | c2 = (men%100)/10 ? crew[1] : 0; | |
62 | c3 = men/10 ? crew[2] : 0; | |
b3a57661 | 63 | c3 = *captured == 0 ? crew[2] : *pc; |
3df86079 CL |
64 | } else |
65 | c1 = c2 = c3 = 0; | |
66 | return(c1 + c2 + c3); | |
67 | } |