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[] = "@(#)pl_4.c 5.1 (Berkeley) 5/29/85"; 9: #endif not lint 10: 11: #include "player.h" 12: 13: changesail() 14: { 15: int rig, full; 16: 17: rig = mc->rig1; 18: full = mf->FS; 19: if (windspeed == 6 || windspeed == 5 && mc->class > 4) 20: rig = 0; 21: if (mc->crew3 && rig) { 22: if (!full) { 23: if (sgetch("Increase to Full sails? ", 24: (struct ship *)0, 1) == 'y') { 25: changed = 1; 26: Write(W_FS, ms, 0, 1, 0, 0, 0); 27: } 28: } else { 29: if (sgetch("Reduce to Battle sails? ", 30: (struct ship *)0, 1) == 'y') { 31: Write(W_FS, ms, 0, 0, 0, 0, 0); 32: changed = 1; 33: } 34: } 35: } else if (!rig) 36: Signal("Sails rent to pieces", (struct ship *)0); 37: } 38: 39: acceptsignal() 40: { 41: char buf[60]; 42: register char *p = buf; 43: 44: *p++ = '"'; 45: sgetstr("Message? ", p, sizeof buf - 2); 46: while (*p++) 47: ; 48: p[-1] = '"'; 49: *p = 0; 50: Write(W_SIGNAL, ms, 1, (int)buf, 0, 0, 0); 51: } 52: 53: lookout() 54: { 55: register struct ship *sp; 56: char buf[3]; 57: register char c; 58: 59: sgetstr("What ship? ", buf, sizeof buf); 60: foreachship(sp) { 61: c = *countryname[sp->nationality]; 62: if ((c == *buf || tolower(c) == *buf || colours(sp) == *buf) 63: && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1] 64: || buf[1] == '?')) { 65: eyeball(sp); 66: } 67: } 68: } 69: 70: char * 71: saywhat(sp, flag) 72: register struct ship *sp; 73: char flag; 74: { 75: if (sp->file->captain[0]) 76: return sp->file->captain; 77: else if (sp->file->struck) 78: return "(struck)"; 79: else if (sp->file->captured != 0) 80: return "(captured)"; 81: else if (flag) 82: return "(available)"; 83: else 84: return "(computer)"; 85: } 86: 87: eyeball(ship) 88: register struct ship *ship; 89: { 90: int i; 91: 92: if (ship->file->dir != 0) { 93: Signal("Sail ho! (range %d, %s)", 94: (struct ship *)0, range(ms, ship), saywhat(ship, 0)); 95: i = portside(ms, ship, 1) - mf->dir; 96: if (i <= 0) 97: i += 8; 98: Signal("%s (%c%c) %s %s %s.", 99: ship, countryname[ship->nationality], 100: classname[ship->specs->class], directionname[i]); 101: } 102: }