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