1 /* $OpenBSD: pl_4.c,v 1.7 2016/01/08 20:26:33 mestre 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 <ctype.h> 34 35 #include "extern.h" 36 #include "player.h" 37 38 void 39 changesail(void) 40 { 41 int rig, full; 42 43 rig = mc->rig1; 44 full = mf->FS; 45 if (windspeed == 6 || (windspeed == 5 && mc->class > 4)) 46 rig = 0; 47 if (mc->crew3 && rig) { 48 if (!full) { 49 if (sgetch("Increase to Full sails? ", 50 (struct ship *)0, 1) == 'y') { 51 changed = 1; 52 Write(W_FS, ms, 1, 0, 0, 0); 53 } 54 } else { 55 if (sgetch("Reduce to Battle sails? ", 56 (struct ship *)0, 1) == 'y') { 57 Write(W_FS, ms, 0, 0, 0, 0); 58 changed = 1; 59 } 60 } 61 } else if (!rig) 62 Msg("Sails rent to pieces"); 63 } 64 65 void 66 acceptsignal(void) 67 { 68 char buf[60]; 69 char *p = buf; 70 71 *p++ = '"'; 72 sgetstr("Message? ", p, sizeof buf - 2); 73 while (*p++) 74 ; 75 p[-1] = '"'; 76 *p = 0; 77 Writestr(W_SIGNAL, ms, buf); 78 } 79 80 void 81 lookout(void) 82 { 83 struct ship *sp; 84 char buf[3]; 85 char c; 86 87 sgetstr("What ship? ", buf, sizeof buf); 88 foreachship(sp) { 89 c = *countryname[sp->nationality]; 90 if ((c == *buf || tolower((unsigned char)c) == *buf || colours(sp) == *buf) 91 && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1] 92 || buf[1] == '?')) { 93 eyeball(sp); 94 } 95 } 96 } 97 98 const char * 99 saywhat(struct ship *sp, int flag) 100 { 101 if (sp->file->captain[0]) 102 return sp->file->captain; 103 else if (sp->file->struck) 104 return "(struck)"; 105 else if (sp->file->captured != 0) 106 return "(captured)"; 107 else if (flag) 108 return "(available)"; 109 else 110 return "(computer)"; 111 } 112 113 void 114 eyeball(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