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