1 /* $OpenBSD: pl_4.c,v 1.4 2009/10/27 23:59:27 deraadt Exp $ */ 2 /* $NetBSD: pl_4.c,v 1.4 1995/04/24 12:25:17 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1983, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 #include "player.h" 34 35 void 36 changesail() 37 { 38 int rig, full; 39 40 rig = mc->rig1; 41 full = mf->FS; 42 if (windspeed == 6 || (windspeed == 5 && mc->class > 4)) 43 rig = 0; 44 if (mc->crew3 && rig) { 45 if (!full) { 46 if (sgetch("Increase to Full sails? ", 47 (struct ship *)0, 1) == 'y') { 48 changed = 1; 49 Write(W_FS, ms, 1, 0, 0, 0); 50 } 51 } else { 52 if (sgetch("Reduce to Battle sails? ", 53 (struct ship *)0, 1) == 'y') { 54 Write(W_FS, ms, 0, 0, 0, 0); 55 changed = 1; 56 } 57 } 58 } else if (!rig) 59 Msg("Sails rent to pieces"); 60 } 61 62 void 63 acceptsignal() 64 { 65 char buf[60]; 66 char *p = buf; 67 68 *p++ = '"'; 69 sgetstr("Message? ", p, sizeof buf - 2); 70 while (*p++) 71 ; 72 p[-1] = '"'; 73 *p = 0; 74 Writestr(W_SIGNAL, ms, buf); 75 } 76 77 void 78 lookout() 79 { 80 struct ship *sp; 81 char buf[3]; 82 char c; 83 84 sgetstr("What ship? ", buf, sizeof buf); 85 foreachship(sp) { 86 c = *countryname[sp->nationality]; 87 if ((c == *buf || tolower(c) == *buf || colours(sp) == *buf) 88 && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1] 89 || buf[1] == '?')) { 90 eyeball(sp); 91 } 92 } 93 } 94 95 const char * 96 saywhat(sp, flag) 97 struct ship *sp; 98 char flag; 99 { 100 if (sp->file->captain[0]) 101 return sp->file->captain; 102 else if (sp->file->struck) 103 return "(struck)"; 104 else if (sp->file->captured != 0) 105 return "(captured)"; 106 else if (flag) 107 return "(available)"; 108 else 109 return "(computer)"; 110 } 111 112 void 113 eyeball(ship) 114 struct ship *ship; 115 { 116 int i; 117 118 if (ship->file->dir != 0) { 119 Msg("Sail ho! (range %d, %s)", 120 range(ms, ship), saywhat(ship, 0)); 121 i = portside(ms, ship, 1) - mf->dir; 122 if (i <= 0) 123 i += 8; 124 Signal("$$ %s %s %s.", 125 ship, countryname[ship->nationality], 126 classname[ship->specs->class], directionname[i]); 127 } 128 } 129