copyright message
[unix-history] / usr / src / games / sail / pl_4.c
CommitLineData
b5f0675e
EW
1/*
2 * Copyright (c) 1983 Regents of the University of California,
3 * All rights reserved. Redistribution permitted subject to
4 * the terms of the Berkeley Software License Agreement.
5 */
6
d8ada91f 7#ifndef lint
b5f0675e 8static char *sccsid = "@(#)pl_4.c 2.4 85/04/23";
d8ada91f
EW
9#endif
10
11#include "player.h"
12
13changesail()
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) {
789d5e82
EW
23 if (sgetch("Increase to Full sails? ",
24 (struct ship *)0, 1) == 'y') {
d8ada91f
EW
25 changed = 1;
26 Write(W_FS, ms, 0, 1, 0, 0, 0);
27 }
28 } else {
789d5e82
EW
29 if (sgetch("Reduce to Battle sails? ",
30 (struct ship *)0, 1) == 'y') {
d8ada91f
EW
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
d8ada91f
EW
39acceptsignal()
40{
41 char buf[60];
42 register char *p = buf;
43
d8ada91f 44 *p++ = '"';
9c4d91cb 45 sgetstr("Message? ", p, sizeof buf - 2);
d8ada91f
EW
46 while (*p++)
47 ;
48 p[-1] = '"';
066b3d96 49 *p = 0;
d8ada91f
EW
50 Write(W_SIGNAL, ms, 1, (int)buf, 0, 0, 0);
51}
52
fe0cae24 53lookout()
d8ada91f
EW
54{
55 register struct ship *sp;
fe0cae24
EW
56 char buf[3];
57 register char c;
d8ada91f 58
fe0cae24 59 sgetstr("What ship? ", buf, sizeof buf);
d8ada91f 60 foreachship(sp) {
fe0cae24
EW
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);
d8ada91f
EW
66 }
67 }
d8ada91f
EW
68}
69
fe0cae24
EW
70char *
71saywhat(sp, flag)
72register struct ship *sp;
73char flag;
d8ada91f 74{
fe0cae24
EW
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)";
d8ada91f 83 else
fe0cae24 84 return "(computer)";
d8ada91f
EW
85}
86
fe0cae24
EW
87eyeball(ship)
88register struct ship *ship;
d8ada91f 89{
fe0cae24
EW
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]);
d8ada91f 101 }
d8ada91f 102}