118711Sedward /* 260846Sbostic * Copyright (c) 1983, 1993 360846Sbostic * The Regents of the University of California. All rights reserved. 433695Sbostic * 542604Sbostic * %sccs.include.redist.c% 618711Sedward */ 718711Sedward 811588Sleres #ifndef lint 9*69068Sbostic static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 04/28/95"; 1033695Sbostic #endif /* not lint */ 1118711Sedward 12*69068Sbostic #include "extern.h" 1311588Sleres 1411588Sleres subtract(from, totalfrom, crewfrom, fromcap, pcfrom) 1514009Sedward struct ship *from, *fromcap; 1614009Sedward int pcfrom; 1711588Sleres register int totalfrom, crewfrom[3]; 1811588Sleres { 1911588Sleres register int n; 2011588Sleres 2114009Sedward if (fromcap == from && totalfrom) { /* if not captured */ 2214009Sedward for (n = 0; n < 3; n++) { 2314009Sedward if (totalfrom > crewfrom[n]) { 2411588Sleres totalfrom -= crewfrom[n]; 2511588Sleres crewfrom[n] = 0; 2614009Sedward } else { 2711588Sleres crewfrom[n] -= totalfrom; 2811588Sleres totalfrom = 0; 2911588Sleres } 3011588Sleres } 3114009Sedward Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0); 3214009Sedward } else if (totalfrom) { 3311588Sleres pcfrom -= totalfrom; 3411588Sleres pcfrom = pcfrom < 0 ? 0 : pcfrom; 3514009Sedward Write(W_PCREW, from, 0, pcfrom, 0, 0, 0); 3611588Sleres } 3711588Sleres } 3811588Sleres 3914009Sedward mensent(from, to, crew, captured, pc, isdefense) 4014009Sedward struct ship *from, *to, **captured; 4114009Sedward int crew[3], *pc; 4214009Sedward char isdefense; 4311588Sleres { /* returns # of crew squares sent */ 4411588Sleres int men = 0; 4511588Sleres register int n; 4611588Sleres int c1, c2, c3; 4714009Sedward register struct BP *bp; 4811588Sleres 4914009Sedward *pc = from->file->pcrew; 5014009Sedward *captured = from->file->captured; 5114009Sedward crew[0] = from->specs->crew1; 5214009Sedward crew[1] = from->specs->crew2; 5314009Sedward crew[2] = from->specs->crew3; 5414009Sedward bp = isdefense ? from->file->DBP : from->file->OBP; 5514009Sedward for (n=0; n < NBP; n++, bp++) { 5614009Sedward if (bp->turnsent && bp->toship == to) 5714009Sedward men += bp->mensent; 5811588Sleres } 5914009Sedward if (men) { 6011588Sleres c1 = men/100 ? crew[0] : 0; 6111588Sleres c2 = (men%100)/10 ? crew[1] : 0; 6211588Sleres c3 = men/10 ? crew[2] : 0; 6314009Sedward c3 = *captured == 0 ? crew[2] : *pc; 6411588Sleres } else 6511588Sleres c1 = c2 = c3 = 0; 6611588Sleres return(c1 + c2 + c3); 6711588Sleres } 68