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