|
|
1.1 root 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: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)dr_5.c 5.4 (Berkeley) 6/1/90";
22: #endif /* not lint */
23:
24: #include "externs.h"
25:
26: subtract(from, totalfrom, crewfrom, fromcap, pcfrom)
27: struct ship *from, *fromcap;
28: int pcfrom;
29: register int totalfrom, crewfrom[3];
30: {
31: register int n;
32:
33: if (fromcap == from && totalfrom) { /* if not captured */
34: for (n = 0; n < 3; n++) {
35: if (totalfrom > crewfrom[n]) {
36: totalfrom -= crewfrom[n];
37: crewfrom[n] = 0;
38: } else {
39: crewfrom[n] -= totalfrom;
40: totalfrom = 0;
41: }
42: }
43: Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0);
44: } else if (totalfrom) {
45: pcfrom -= totalfrom;
46: pcfrom = pcfrom < 0 ? 0 : pcfrom;
47: Write(W_PCREW, from, 0, pcfrom, 0, 0, 0);
48: }
49: }
50:
51: mensent(from, to, crew, captured, pc, isdefense)
52: struct ship *from, *to, **captured;
53: int crew[3], *pc;
54: char isdefense;
55: { /* returns # of crew squares sent */
56: int men = 0;
57: register int n;
58: int c1, c2, c3;
59: register struct BP *bp;
60:
61: *pc = from->file->pcrew;
62: *captured = from->file->captured;
63: crew[0] = from->specs->crew1;
64: crew[1] = from->specs->crew2;
65: crew[2] = from->specs->crew3;
66: bp = isdefense ? from->file->DBP : from->file->OBP;
67: for (n=0; n < NBP; n++, bp++) {
68: if (bp->turnsent && bp->toship == to)
69: men += bp->mensent;
70: }
71: if (men) {
72: c1 = men/100 ? crew[0] : 0;
73: c2 = (men%100)/10 ? crew[1] : 0;
74: c3 = men/10 ? crew[2] : 0;
75: c3 = *captured == 0 ? crew[2] : *pc;
76: } else
77: c1 = c2 = c3 = 0;
78: return(c1 + c2 + c3);
79: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.