annotate beeplite.c @ 2:fba0b6e6cdc7

Added tag ALPHA for changeset ff5e05767bd3
author darius@midget.dons.net.au
date Tue, 23 Oct 2007 10:09:09 +0930
parents ff5e05767bd3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
1 /* $Id: beeplite.c,v 1.1.1.1 1997/12/06 05:41:28 darius Exp $ */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
2
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
3 #ifdef BEEPLITE
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
4 /*
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
5 * beeplite.c
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
6 */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
7 #include "copyright.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
8
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
9 #include <stdio.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
10 #include <stdlib.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
11 #include <signal.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
12 #include <ctype.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
13 #ifndef SERVER
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
14 #include "Wlib.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
15 #endif
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
16 #include "defs.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
17 #include "struct.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
18 #include "data.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
19
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
20 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
21 rcdlite(dist)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
22 struct distress *dist; /* the info */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
23 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
24 char message[100];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
25 int len = 0;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
26
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
27 if (!F_allow_beeplite)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
28 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
29
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
30 if ((dist == NULL) ||
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
31 (dist->sender == me->p_no) ||
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
32 (distlite[dist->distype] == NULL))
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
33 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
34
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
35 len = makedistress(dist, message, distlite[dist->distype]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
36
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
37 if (len <= 0)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
38 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
39
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
40 makelite(dist, message);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
41 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
42
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
43 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
44 litedefaults()
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
45 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
46 if (distlite[take] == NULL)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
47 distlite[take] = "/c/l";
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
48 if (distlite[base_ogg] == NULL)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
49 distlite[base_ogg] = "/g/m";
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
50 if (distlite[pickup] == NULL)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
51 distlite[pickup] = "/p";
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
52 if (distlite[generic] == NULL)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
53 distlite[generic] = "%?%S=SB%{/c%}";
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
54 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
55
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
56 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
57 liteplanet(l, col)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
58 struct planet *l;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
59 W_Color col;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
60 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
61 if (!(F_beeplite_flags & LITE_PLANETS))
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
62 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
63
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
64 emph_planet_seq_n[l->pl_no] = beep_lite_cycle_time_planet;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
65 emph_planet_color[l->pl_no] = col;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
66 l->pl_flags |= PLREDRAW; /* Leave redraw on until done highlighting */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
67 #if 0
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
68 l->pl_flags |= PLCLEAR; /* Leave redraw on until done highlighting */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
69 #endif
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
70 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
71
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
72 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
73 liteplayer(j, col)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
74 struct player *j;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
75 W_Color col;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
76 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
77 if (!(F_beeplite_flags & (LITE_PLAYERS_MAP | LITE_PLAYERS_LOCAL)) &&
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
78 !((j == me) && (F_beeplite_flags & LITE_SELF)))
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
79 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
80
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
81 if (!j || (j->p_flags & PFCLOAK))
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
82 return;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
83
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
84 redrawPlayer[j->p_no] = 1;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
85
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
86 emph_player_seq_n[j->p_no] = beep_lite_cycle_time_player;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
87 emph_player_color[j->p_no] = col;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
88 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
89
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
90
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
91 /* small permutation on makedistress. Searches for the highliting
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
92 ** arguments, ignores everything else.
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
93 */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
94
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
95 makelite(dist, pm)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
96 struct distress *dist; /* the info */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
97 char *pm; /* macro to parse, used for distress and
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
98 macro */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
99 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
100 struct player *sender;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
101 struct player *j;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
102 struct planet *l;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
103 char *strcap();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
104 char c;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
105 W_Color lcol;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
106
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
107 sender = &players[dist->sender];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
108
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
109 if (!(*pm)) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
110 return (0);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
111 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
112 /* first step is to substitute variables */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
113 while (*pm) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
114 if (*pm == '/') {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
115 pm++;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
116
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
117 if (!pm)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
118 continue;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
119
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
120 if (F_beeplite_flags & LITE_COLOR) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
121 /* color lite -JR */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
122 switch (toupper(*(pm + 1))) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
123 case 'G':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
124 lcol = W_Green;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
125 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
126 case 'Y':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
127 lcol = W_Yellow;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
128 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
129 case 'R':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
130 lcol = W_Red;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
131 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
132 case 'C':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
133 lcol = W_Cyan;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
134 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
135 case 'E':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
136 lcol = W_Grey;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
137 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
138 case 'W':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
139 default:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
140 lcol = W_White;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
141 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
142 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
143 } else
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
144 lcol = W_White;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
145
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
146 switch (c = *(pm++)) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
147
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
148 case 'P': /* push player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
149 case 'G': /* push friendly player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
150 case 'H': /* push enemy target player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
151
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
152 case 'p': /* push player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
153 case 'g': /* push friendly player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
154 case 'h': /* push enemy target player id into buf */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
155
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
156 switch (c) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
157 case 'p':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
158 j = &players[dist->tclose_j];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
159 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
160 case 'g':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
161 j = &players[dist->tclose_fr];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
162 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
163 case 'h':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
164 j = &players[dist->tclose_en];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
165 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
166 case 'P':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
167 j = &players[dist->close_j];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
168 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
169 case 'G':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
170 j = &players[dist->close_fr];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
171 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
172 default:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
173 j = &players[dist->close_en];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
174 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
175 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
176 liteplayer(j, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
177 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
178
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
179 case 'B': /* highlites planet nearest sender */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
180 case 'b':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
181 l = &planets[dist->close_pl];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
182 liteplanet(l, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
183 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
184 case 'L': /* highlites planet nearest pointer */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
185 case 'l':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
186 l = &planets[dist->tclose_pl];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
187 liteplanet(l, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
188 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
189 case 'U': /* highlites enemy nearest pointer */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
190 case 'u':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
191 j = &players[dist->tclose_en];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
192 liteplayer(j, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
193 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
194 case 'c': /* highlites sender */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
195 case 'I':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
196 case 'i':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
197 liteplayer(sender, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
198 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
199 case 'M': /* highlites me */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
200 case 'm':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
201 liteplayer(me, lcol);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
202 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
203 case '0':
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
204 if (F_beeplite_flags & LITE_SOUNDS)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
205 W_Beep();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
206 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
207 default:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
208 /* try to continue
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
209 ** bad macro character is skipped entirely,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
210 ** the message will be parsed without whatever argument has occurred. - jn
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
211 */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
212 warning("Bad Macro character in distress!");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
213 fprintf(stderr, "Unrecognizable special character in distress pass 1: %c\n", *(pm - 1));
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
214 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
215 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
216 } else {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
217 pm++;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
218 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
219
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
220 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
221
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
222
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
223 return (1);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
224 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
225
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
226
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
227 #endif /* BEEPLITE */