sprintf doesn't necessarily return its first arg
[unix-history] / usr / src / games / sail / pl_2.c
CommitLineData
b5f0675e 1/*
1e008c14
DF
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.
b5f0675e
EW
5 */
6
5f9f07ce 7#ifndef lint
1e008c14
DF
8static char sccsid[] = "@(#)pl_2.c 5.1 (Berkeley) %G%";
9#endif not lint
7fc06086 10
5f9f07ce
CL
11#include "player.h"
12
fe0cae24 13play()
5f9f07ce 14{
fe0cae24 15 register struct ship *sp;
5f9f07ce 16
fe0cae24
EW
17 for (;;) {
18 switch (sgetch("~\b", (struct ship *)0, 0)) {
19 case 'm':
20 acceptmove();
b3a57661 21 break;
fe0cae24
EW
22 case 's':
23 acceptsignal();
b3a57661 24 break;
fe0cae24
EW
25 case 'g':
26 grapungrap();
b3a57661 27 break;
fe0cae24
EW
28 case 'u':
29 unfoulplayer();
b3a57661 30 break;
fe0cae24
EW
31 case 'v':
32 Signal("%s", (struct ship *)0, version);
b3a57661 33 break;
fe0cae24
EW
34 case 'b':
35 acceptboard();
b3a57661 36 break;
fe0cae24
EW
37 case 'f':
38 acceptcombat();
39 break;
40 case 'l':
41 loadplayer();
42 break;
43 case 'c':
44 changesail();
b3a57661
EW
45 break;
46 case 'r':
fe0cae24 47 repair();
b3a57661 48 break;
fe0cae24
EW
49 case 'B':
50 Signal("'Hands to stations!'", (struct ship *)0);
51 unboard(ms, ms, 1); /* cancel DBP's */
52 unboard(ms, ms, 0); /* cancel offense */
b3a57661 53 break;
fe0cae24
EW
54 case '\f':
55 centerview();
490c485f 56 blockalarm();
fe0cae24
EW
57 draw_board();
58 draw_screen();
490c485f 59 unblockalarm();
b3a57661 60 break;
fe0cae24
EW
61 case 'L':
62 mf->loadL = L_EMPTY;
63 mf->loadR = L_EMPTY;
64 mf->readyL = R_EMPTY;
65 mf->readyR = R_EMPTY;
66 Signal("Broadsides unloaded", (struct ship *)0);
67 break;
68 case 'q':
69 Signal("Type 'Q' to quit", (struct ship *)0);
70 break;
71 case 'Q':
72 leave(LEAVE_QUIT);
73 break;
74 case 'I':
75 foreachship(sp)
76 if (sp != ms)
77 eyeball(sp);
78 break;
79 case 'i':
80 if ((sp = closestenemy(ms, 0, 1)) == 0)
81 Signal("No more ships left.");
b3a57661 82 else
fe0cae24 83 eyeball(sp);
b3a57661 84 break;
fe0cae24
EW
85 case 'C':
86 centerview();
490c485f 87 blockalarm();
fe0cae24 88 draw_view();
490c485f 89 unblockalarm();
5f9f07ce 90 break;
fe0cae24
EW
91 case 'U':
92 upview();
490c485f 93 blockalarm();
fe0cae24 94 draw_view();
490c485f 95 unblockalarm();
5f9f07ce 96 break;
fe0cae24
EW
97 case 'D':
98 case 'N':
99 downview();
490c485f 100 blockalarm();
fe0cae24 101 draw_view();
490c485f 102 unblockalarm();
5f9f07ce 103 break;
fe0cae24
EW
104 case 'H':
105 leftview();
490c485f 106 blockalarm();
fe0cae24 107 draw_view();
490c485f 108 unblockalarm();
fe0cae24
EW
109 break;
110 case 'J':
111 rightview();
490c485f 112 blockalarm();
fe0cae24 113 draw_view();
490c485f 114 unblockalarm();
fe0cae24
EW
115 break;
116 case 'F':
117 lookout();
118 break;
119 case 'S':
120 dont_adjust = !dont_adjust;
490c485f 121 blockalarm();
04bbf8e2 122 draw_turn();
490c485f 123 unblockalarm();
5f9f07ce 124 break;
b3a57661 125 }
5f9f07ce 126 }
5f9f07ce 127}