Mercurial > ~darius > hgwebdir.cgi > paradise_client
comparison dmessage.c @ 3:5a977ccbc7a9 default tip
Empty changelog
author | darius |
---|---|
date | Sat, 06 Dec 1997 05:41:29 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:fba0b6e6cdc7 | 3:5a977ccbc7a9 |
---|---|
1 /* $Id: dmessage.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */ | |
2 | |
3 /* | |
4 * dmessage.c | |
5 * | |
6 * for the client of a socket based protocol. | |
7 * code for message window scrollback added by Bill Dyess 12/7/93 | |
8 */ | |
9 #include "copyright.h" | |
10 | |
11 #include <stdio.h> | |
12 #include <math.h> | |
13 #include <string.h> | |
14 #include <ctype.h> | |
15 #ifdef __STDC__ | |
16 #include <stdlib.h> | |
17 #endif | |
18 #include "Wlib.h" | |
19 #include "defs.h" | |
20 #include "struct.h" | |
21 #include "data.h" | |
22 #include "proto.h" | |
23 #ifdef SOUND | |
24 #include "Slib.h" | |
25 #endif | |
26 | |
27 #define MESSAGESIZE 20 | |
28 #define YOFF 0 | |
29 | |
30 struct messageData { | |
31 char *message; | |
32 unsigned char flags, from, to; | |
33 }; | |
34 | |
35 struct messageNode { | |
36 struct messageData *line; | |
37 struct messageNode *next, *prev; | |
38 }; | |
39 | |
40 /* Prototypes */ | |
41 int instr P((char *string1, char *string2)); | |
42 void CheckFeatures P((char *m)); | |
43 void print_message | |
44 P((char *message, unsigned int flags, unsigned int from, | |
45 unsigned int to, struct messageData * data, | |
46 W_Window winmask, int backwards)); | |
47 void evalFlags P((int type, char *flagList)); | |
48 | |
49 void initMessageWindows() | |
50 { | |
51 int i; | |
52 char *s; | |
53 | |
54 messWin[WALL].window = W_MakeScrollingWindow("review_all", WINSIDE + BORDER, | |
55 YOFF + WINSIDE + 3 * BORDER + 2 * MESSAGESIZE, 80, 10, 0, "xterm", BORDER); | |
56 messWin[WTEAM].window = W_MakeScrollingWindow("review_team", WINSIDE + BORDER, | |
57 YOFF + WINSIDE + 4 * BORDER + 2 * MESSAGESIZE + 10 * W_Textheight + 8, | |
58 80, 5, 0, "xterm", BORDER); | |
59 messWin[WINDIV].window = W_MakeScrollingWindow("review_your", WINSIDE + BORDER, | |
60 YOFF + WINSIDE + 5 * BORDER + 2 * MESSAGESIZE + 15 * W_Textheight + 16, | |
61 80, 4, 0, "xterm", BORDER); | |
62 messWin[WKILL].window = W_MakeScrollingWindow("review_kill", WINSIDE + BORDER, | |
63 YOFF + WINSIDE + 6 * BORDER + 2 * MESSAGESIZE + 19 * W_Textheight + 24, | |
64 80, 6, 0, "xterm", BORDER); | |
65 messWin[WPHASER].window = W_MakeScrollingWindow("review_phaser", WINSIDE + | |
66 BORDER, YOFF + WINSIDE + 7 * BORDER + 2 * MESSAGESIZE + 24 * W_Textheight | |
67 + 32, 80, 3, 0, "xterm", BORDER); | |
68 messWin[WREVIEW].window = W_MakeScrollingWindow("review", WINSIDE + BORDER, | |
69 YOFF + WINSIDE + 3 * BORDER + 2 * MESSAGESIZE, | |
70 80, 20, 0, "xterm", BORDER); | |
71 | |
72 /* | |
73 initialize the 'allow' flags. Any window can display any message. | |
74 [BDyess] | |
75 */ | |
76 s = stringDefault("review_all.allow", "MA"); | |
77 evalFlags(WALL, s); | |
78 s = stringDefault("review_team.allow", "T"); | |
79 evalFlags(WTEAM, s); | |
80 s = stringDefault("review_your.allow", "I"); | |
81 evalFlags(WINDIV, s); | |
82 s = stringDefault("review_kill.allow", "K"); | |
83 evalFlags(WKILL, s); | |
84 s = stringDefault("review_phaser.allow", "P"); | |
85 evalFlags(WPHASER, s); | |
86 s = stringDefault("review.allow", "MATIKP"); | |
87 evalFlags(WREVIEW, s); | |
88 | |
89 for (i = 0; i < WNUM; i++) { | |
90 messWin[i].head = messWin[i].curHead = NULL; | |
91 } | |
92 } | |
93 | |
94 void | |
95 evalFlags(type, flagList) | |
96 int type; | |
97 char *flagList; | |
98 { | |
99 char *orig=flagList; | |
100 | |
101 messWin[type].flags = 0; | |
102 while (*flagList) { | |
103 switch (toupper(*flagList)) { | |
104 case 'A': | |
105 messWin[type].flags |= WA_ALL; | |
106 break; | |
107 case 'T': | |
108 messWin[type].flags |= WA_TEAM; | |
109 break; | |
110 case 'I': | |
111 messWin[type].flags |= WA_INDIV; | |
112 break; | |
113 case 'K': | |
114 messWin[type].flags |= WA_KILL; | |
115 break; | |
116 case 'P': | |
117 messWin[type].flags |= WA_PHASER; | |
118 break; | |
119 case 'M': | |
120 messWin[type].flags |= WA_MACRO; | |
121 break; | |
122 default: | |
123 printf("Invalid allow flag '%c' in allow list, ignoring\n", | |
124 *flagList); | |
125 break; | |
126 } | |
127 flagList++; | |
128 } | |
129 free(orig); | |
130 } | |
131 | |
132 void | |
133 messageWinEvent(evt) | |
134 W_Event *evt; | |
135 /* handles the mouse and keyboard events that happen in one of the message | |
136 windows. For key events, if the event is within the team or all window then | |
137 it will automatically start the message for you, with destination to the | |
138 player's team or ALL, respectively. If it's a button event, it will scroll | |
139 the message window back, forward, or to start (left, right, and middle | |
140 button respectively). It beeps if there is no messages to scroll (ie at | |
141 the top or bottom already). [BDyess] 12/07/93 */ | |
142 { | |
143 struct messageNode **headpntr, *runner, *newcpntr; | |
144 struct messageData *j; | |
145 int windowHeight; | |
146 register int i; | |
147 W_Window window = evt->Window; | |
148 int key = evt->key; | |
149 int scroll=0; | |
150 | |
151 if (!W_IsMapped(window)) | |
152 return; | |
153 | |
154 if (evt->type == W_EV_KEY) { | |
155 if (key == ('e' + 128)) { /* erase window [BDyess] */ | |
156 W_ClearWindow(window); | |
157 } else if(key == ('p'+128)) { | |
158 scroll = -1; | |
159 } else if(key == ('n'+128)) { | |
160 scroll = 1; | |
161 } else if (window == messWin[WALL].window) { | |
162 smessage_ahead('A', key); | |
163 } else if (window == messWin[WTEAM].window) { | |
164 smessage_ahead('T', key); | |
165 } else { | |
166 smessage(key); | |
167 } | |
168 if(!scroll) | |
169 return; | |
170 } | |
171 headpntr = NULL; | |
172 for (i = 0; i < WNUM; i++) { | |
173 if (window == messWin[i].window) { | |
174 headpntr = &messWin[i].curHead; | |
175 break; | |
176 } | |
177 } | |
178 | |
179 runner = *headpntr; | |
180 if (runner == NULL) { | |
181 if(scrollBeep) | |
182 W_Beep(); | |
183 return; | |
184 } | |
185 windowHeight = W_WindowHeight(window); | |
186 | |
187 if(scroll==-1) { | |
188 for (i = 0; (i < windowHeight) && runner; i++, runner = runner->next) | |
189 ; | |
190 if (runner == NULL) { | |
191 if (scrollBeep) | |
192 W_Beep(); | |
193 return; | |
194 } | |
195 j=runner->line; | |
196 print_message(j->message, j->flags, j->from, j->to, NULL, window, 1); | |
197 *headpntr = (*headpntr)->next; | |
198 return; | |
199 } else if(scroll==1) { | |
200 if(runner->prev == NULL) { | |
201 if (scrollBeep) | |
202 W_Beep(); | |
203 return; | |
204 } | |
205 j=runner->prev->line; | |
206 print_message(j->message, j->flags, j->from, j->to, NULL, window, 0); | |
207 *headpntr = (*headpntr)->prev; | |
208 return; | |
209 } | |
210 switch (key) { | |
211 case W_LBUTTON: | |
212 for (i = 0; (i < windowHeight-1) && runner->next; i++, runner = runner->next) | |
213 ; | |
214 newcpntr=runner; | |
215 | |
216 if (runner->next == NULL) { | |
217 if (scrollBeep) | |
218 W_Beep(); | |
219 break; | |
220 } | |
221 runner=runner->next; | |
222 for (i = 0; (i < windowHeight-1) && runner; i++, runner = runner->next) { | |
223 j=runner->line; | |
224 print_message(j->message, j->flags, j->from, j->to, NULL, window, 1); | |
225 } | |
226 if(i<windowHeight-1) { | |
227 for(;i<windowHeight-1;i++) | |
228 W_WriteText(window,0,-1,0,"",0,0); | |
229 } | |
230 *headpntr=newcpntr; | |
231 break; | |
232 case W_RBUTTON: | |
233 if (runner->prev == NULL) { | |
234 if (scrollBeep) | |
235 W_Beep(); | |
236 break; | |
237 } | |
238 for (i = 0; (i < windowHeight-1) && runner->prev; i++, runner = runner->prev) { | |
239 j=runner->prev->line; | |
240 print_message(j->message, j->flags, j->from, j->to, NULL, window, 0); | |
241 } | |
242 *headpntr = runner; | |
243 break; | |
244 case W_MBUTTON: | |
245 if (runner->prev == NULL) { | |
246 if (scrollBeep) | |
247 W_Beep(); | |
248 break; | |
249 } | |
250 W_ClearWindow(window); | |
251 while (runner->prev) | |
252 runner = runner->prev; | |
253 *headpntr = runner; | |
254 for (i = 0; i < windowHeight && runner->next; i++, runner = runner->next); | |
255 while (runner) { | |
256 j = runner->line; | |
257 print_message(j->message, j->flags, j->from, j->to, NULL, window, 0); | |
258 runner = runner->prev; | |
259 } | |
260 break; | |
261 } | |
262 } | |
263 | |
264 void | |
265 rsvp_borg_call(message, from) | |
266 char *message; | |
267 int from; | |
268 { | |
269 #if 0 | |
270 int len, pos; | |
271 len = strlen(message); | |
272 pos = len - 5; | |
273 if (strncmp(message + pos, " ", 5) == 0) | |
274 #else | |
275 char *chk; | |
276 | |
277 if (strlen(message) < 15) | |
278 return; | |
279 for (chk = message + 10; *chk && *chk == ' '; chk++) | |
280 /* empty body */ ; | |
281 if (*chk) | |
282 return; | |
283 #endif | |
284 { | |
285 char buf[120]; | |
286 | |
287 sprintf(buf, "Paradise Client %s (%s)", CLIENTVERS, | |
288 #ifdef __osf__ | |
289 "DEC OSF/1" | |
290 #else | |
291 #ifdef NeXT | |
292 "NeXT" | |
293 #else | |
294 #ifdef ultrix | |
295 "DEC Ultrix" | |
296 #else | |
297 #if defined(sparc) && defined(SVR4) | |
298 "Solaris" | |
299 #else | |
300 #ifdef sparc | |
301 "SUN4/Sparc" | |
302 #else | |
303 #ifdef sun | |
304 "SUN3" | |
305 #else | |
306 #ifdef sequent | |
307 "sequent" | |
308 #else | |
309 #ifdef hpux | |
310 "hpux" | |
311 #else | |
312 #ifdef AIX | |
313 "AIX" | |
314 #else | |
315 #ifdef vax | |
316 "vax" | |
317 #else | |
318 #ifdef sgi | |
319 "sgi/IRIX" | |
320 #else | |
321 #ifdef apollo | |
322 "apollo" | |
323 #else | |
324 #ifdef RS6K | |
325 "RS6K" | |
326 #else | |
327 #ifdef linux | |
328 "Linux" | |
329 #else | |
330 #ifdef __NetBSD__ | |
331 "NetBSD" | |
332 #else | |
333 #ifdef __FreeBSD__ | |
334 "FreeBSD" | |
335 #else | |
336 #ifdef AMIGA | |
337 "Amiga" | |
338 #else | |
339 "generic" | |
340 #endif /* Amiga */ | |
341 #endif /* linux */ | |
342 #endif /* RS6K */ | |
343 #endif /* apollo */ | |
344 #endif /* sgi */ | |
345 #endif /* vax */ | |
346 #endif /* AIX */ | |
347 #endif /* hpux */ | |
348 #endif /* sequent */ | |
349 #endif /* sun */ | |
350 #endif /* sparc */ | |
351 #endif /* solaris */ | |
352 #endif /* ultrix */ | |
353 #endif /* NeXT */ | |
354 #endif /* __osf__ */ | |
355 #endif /* FreeBSD */ | |
356 #endif /* NetBSD */ | |
357 ); | |
358 if (from == 255) { | |
359 sendMessage(buf, MGOD, 0); | |
360 } else | |
361 sendMessage(buf, MINDIV, from); | |
362 } | |
363 } | |
364 | |
365 void | |
366 logit(message) | |
367 char *message; | |
368 /* logs the given message if the 'logmess' variable is set to one. It send the | |
369 message to stdout by default, or to a file if one is defined. [BDyess] */ | |
370 { | |
371 if (!logmess) | |
372 return; | |
373 if (logfilehandle && logFile) { | |
374 fprintf(logfilehandle, "%s\n", message); | |
375 fflush(logfilehandle); | |
376 } else { | |
377 printf("%s\n", message); | |
378 } | |
379 } | |
380 | |
381 void | |
382 writeMessage(data, message, color, len, winmask, type, backwards) | |
383 struct messageData *data; | |
384 char *message; | |
385 W_Color color; | |
386 int len; | |
387 W_Window winmask; | |
388 int type; | |
389 int backwards; | |
390 { | |
391 struct messageNode *newhead; | |
392 struct messageWin *j; | |
393 | |
394 if (data != NULL) { | |
395 #ifdef SPEECH /* was AMIGA... ya never know ;-) */ | |
396 if (((S_SpeakYour && type & WA_INDIV) || | |
397 (S_SpeakTeam && type & WA_TEAM) || | |
398 (S_SpeakAll && type & WA_ALL) || | |
399 (S_SpeakKill && type & WA_KILL)) && | |
400 ((strncmp(message,"GOD->",5) != 0) || S_SpeakGod) && | |
401 ((data->from != me->p_no) || S_SpeakSelf)) { | |
402 S_SpeakString(message, len); | |
403 } | |
404 #endif /* SPEECH */ | |
405 #ifdef SOUND | |
406 if ((type & WA_INDIV) && data->from != me->p_no) { | |
407 S_PlaySound(S_WHISTLE); | |
408 } | |
409 #endif | |
410 for (j = &messWin[0]; j < &messWin[WNUM]; j++) { | |
411 if (!(j->flags & type)) | |
412 continue; | |
413 newhead = (struct messageNode *) malloc(sizeof(struct messageNode)); | |
414 newhead->next = j->head; | |
415 if (newhead->next) | |
416 newhead->next->prev = newhead; | |
417 newhead->prev = NULL; | |
418 newhead->line = data; | |
419 if (j->head == j->curHead) { | |
420 /* we aren't currently scrolled back [BDyess] */ | |
421 W_WriteText(j->window, 0, 0, color, message, len, 0); | |
422 j->curHead = newhead; | |
423 } | |
424 j->head = newhead; | |
425 } | |
426 } else { /* we're drawing a new page */ | |
427 for (j = &messWin[0]; j < &messWin[WNUM]; j++) { | |
428 if (!(j->flags & type)) | |
429 continue; | |
430 if (j->window != winmask) | |
431 continue; | |
432 W_WriteText(j->window, 0, (backwards ? -1 : 0), color, message, len, 0); | |
433 } | |
434 } | |
435 } | |
436 | |
437 void | |
438 print_message(message, flags, from, to, data, winmask, backwards) | |
439 char *message; | |
440 unsigned int flags, from, to; | |
441 struct messageData *data; | |
442 W_Window winmask; | |
443 int backwards; | |
444 /* this function determines the color that the given message should be and | |
445 then passes it to writeMessage, where the data structure for the scroll | |
446 back code is created and also where the winmask test is done. The winmask | |
447 determines what window the message is written to, useful when calling this | |
448 routine from the scrollback routines. If winmask == NULL it doesn't | |
449 limit printing at all, eg team messages will go to the team window and to | |
450 the total review window. [BDyess] 12/07/93 */ | |
451 { | |
452 register int len; | |
453 W_Color color; | |
454 W_Window targwin; | |
455 | |
456 #define take MTEAM + MTAKE + MVALID | |
457 #define destroy MTEAM + MDEST + MVALID | |
458 #define kill MALL + MKILL + MVALID | |
459 #define killp MALL + MKILLP + MVALID | |
460 #define killa MALL + MKILLA + MVALID | |
461 #define bomb MTEAM + MBOMB + MVALID | |
462 #define team MTEAM + MVALID | |
463 #define conq MALL + MCONQ + MVALID | |
464 | |
465 len = strlen(message); | |
466 if (from == 254) { /* client passing info around */ | |
467 switch (showPhaser) { | |
468 case 0: | |
469 break; | |
470 case 1: | |
471 writeMessage(data, message, textColor, len, winmask, WA_KILL | WA_REVIEW, backwards); | |
472 break; | |
473 case 2: | |
474 writeMessage(data, message, textColor, len, winmask, WA_REVIEW | WA_PHASER, backwards); | |
475 break; | |
476 case 3: | |
477 writeMessage(data, message, textColor, len, winmask, WA_REVIEW, backwards); | |
478 break; | |
479 } | |
480 return; | |
481 } | |
482 if (from == 255) { | |
483 if (flags == MCONFIG + MINDIV + MVALID) { | |
484 /* printf("Going to checkfeatures\n");*/ | |
485 CheckFeatures(message); | |
486 return; | |
487 } | |
488 /* From God */ | |
489 color = textColor; | |
490 } else { | |
491 /* kludge to fix the occasional incorrect color message */ | |
492 if (*message == ' ' && from != me->p_no) { | |
493 /* XXX fix to handle funky teams */ | |
494 switch (*(message + 1)) { | |
495 case 'F': | |
496 color = W_Yellow; | |
497 break; | |
498 case 'R': | |
499 color = W_Red; | |
500 break; | |
501 case 'K': | |
502 color = W_Green; | |
503 break; | |
504 case 'O': | |
505 color = W_Cyan; | |
506 break; | |
507 case 'I': | |
508 color = W_Grey; | |
509 break; | |
510 default: | |
511 color = playerColor(&(players[from])); | |
512 } | |
513 } else | |
514 color = playerColor(&(players[from])); | |
515 } | |
516 | |
517 /* added/modified to fit with the scrollback feature 1/94 -JR */ | |
518 if (!paradise && niftyNewMessages) { | |
519 if (flags == conq) { | |
520 /* output conquer stuff to stdout in addition to message window */ | |
521 fprintf(stdout, "%s\n", message); | |
522 if (instr(message, "kill")) { | |
523 fprintf(stdout, "NOTE: The server here does not properly set message flags\n"); | |
524 fprintf(stdout, "You should probably pester the server god to update....\n"); | |
525 } | |
526 } | |
527 if ((flags == team) || (flags == take) || (flags == destroy)) { | |
528 writeMessage(data, message, color, len, winmask, WA_TEAM | WA_REVIEW, backwards); | |
529 targwin = messWin[WTEAM].window; | |
530 } else if ((flags == kill) || (flags == killp) || (flags == killa) || (flags == bomb)) { | |
531 writeMessage(data, message, color, len, winmask, | |
532 WA_KILL | (reportKills ? WA_REVIEW : 0), backwards); | |
533 targwin = messWin[WKILL].window; | |
534 } else if (flags & MINDIV) { | |
535 writeMessage(data, message, color, len, winmask, (WA_INDIV | WA_REVIEW), backwards); | |
536 targwin = messWin[WINDIV].window; | |
537 } else if (flags == (MMACRO | MALL)) { | |
538 writeMessage(data, message, color, len, winmask, (WA_MACRO | WA_REVIEW), backwards); | |
539 targwin = messWin[WALL].window; | |
540 } else { | |
541 /* | |
542 if we don't know where the message belongs by this time, stick | |
543 it in the all board... | |
544 */ | |
545 writeMessage(data, message, color, len, winmask, (WA_ALL | WA_REVIEW), backwards); | |
546 targwin = messWin[WALL].window; | |
547 } | |
548 } else { | |
549 | |
550 /* | |
551 Kludge stuff for report kills... | |
552 */ | |
553 if ((strncmp(message, "GOD->ALL", 8) == 0 && | |
554 (instr(message, "was kill") || | |
555 instr(message, "killed by"))) || | |
556 instr(message, "burned to a crisp by") || | |
557 instr(message, "shot down by") || | |
558 (*message != ' ' && instr(message, "We are being attacked"))) { | |
559 writeMessage(data, message, color, len, winmask, | |
560 WA_KILL | (reportKills ? WA_REVIEW : 0), backwards); | |
561 return; | |
562 } | |
563 /* | |
564 note: messages are kept track of even if the associated window is | |
565 not mapped. This allows the window to be later mapped and have | |
566 all the past messages. [BDyess] | |
567 */ | |
568 if (flags & MTEAM) { | |
569 writeMessage(data, message, color, len, winmask, WA_TEAM | WA_REVIEW, backwards); | |
570 targwin = messWin[WTEAM].window; | |
571 } else if (flags & MINDIV) { | |
572 writeMessage(data, message, color, len, winmask, WA_INDIV | WA_REVIEW, backwards); | |
573 targwin = messWin[WINDIV].window; | |
574 } else if (flags == (MMACRO | MALL)) { | |
575 writeMessage(data, message, color, len, winmask, WA_MACRO | WA_REVIEW, backwards); | |
576 targwin = messWin[WALL].window; | |
577 } else { | |
578 writeMessage(data, message, color, len, winmask, WA_ALL | WA_REVIEW, backwards); | |
579 targwin = messWin[WALL].window; | |
580 } | |
581 } | |
582 /* | |
583 send warnings to warning or message window, if player doesn't have | |
584 messag es mapped | |
585 */ | |
586 if ((use_msgw && (targwin == messWin[WINDIV].window || targwin == messWin[WTEAM].window)) || | |
587 (!W_IsMapped(targwin) && !W_IsMapped(messWin[WREVIEW].window))) { | |
588 if (!messpend && messagew) { /* don't collide with messages being | |
589 written! */ | |
590 W_ClearWindow(messagew); | |
591 W_WriteText(messagew, 5, 5, color, message, len, W_RegularFont); | |
592 } else | |
593 warning(message); | |
594 } | |
595 } | |
596 | |
597 void | |
598 dmessage(message, flags, from, to) | |
599 char *message; | |
600 unsigned int flags, from, to; | |
601 /* prints the given message by going though several subroutines. Here, it first | |
602 creates the data structure that holds the message info and logs the message, | |
603 then sends it on it's subroutine path to print it to the correct window(s). | |
604 This is a good place to handle any special-functions that occur due to | |
605 incoming messages. The data structure for the scroll back is like this: | |
606 each window has a head pointer that points to the top of its message | |
607 list. Each list only contains the messages that go to it's window. The | |
608 lists have pointers to the message itself, so that only one copy of the | |
609 message exists even if it is displayed on several windows. Each list also | |
610 has a current head pointer that points to the record that is at the bottom | |
611 of that current window. If the current head pointer and the head pointer | |
612 are different, then the window must be scrolled back. In such a case, new | |
613 messages are still received but not printed. [BDyess] 12/07/93 */ | |
614 { | |
615 struct messageData *data; | |
616 struct distress dist; | |
617 int len; | |
618 | |
619 #ifdef RC_DISTRESS | |
620 /* aha! A new type distress/macro call came in. parse it appropriately */ | |
621 if (F_gen_distress && (flags == (MTEAM | MDISTR | MVALID))) { | |
622 HandleGenDistr(message, from, to, &dist); | |
623 len = makedistress(&dist, message, distmacro[dist.distype].macro); | |
624 #ifdef BEEPLITE | |
625 if (UseLite) | |
626 rcdlite(&dist); | |
627 #endif | |
628 if (len <= 0) | |
629 return; | |
630 flags ^= MDISTR; | |
631 } | |
632 #endif | |
633 /* | |
634 add create message data struct. Used for message scrollback | |
635 capability. [BDyess] | |
636 */ | |
637 data = (struct messageData *) malloc(sizeof(struct messageData)); | |
638 data->message = (char *) strdup(message); | |
639 data->flags = flags; | |
640 data->from = from; | |
641 data->to = to; | |
642 /* | |
643 keep track of how many queued messages there are for use with the | |
644 infoIcon [BDyess] | |
645 */ | |
646 if (infoIcon) { | |
647 if (to == me->p_no && flags & MINDIV) { /* personal message */ | |
648 me_messages++; | |
649 } else if (flags & MTEAM) { /* team message */ | |
650 team_messages++; | |
651 } else { /* message for all */ | |
652 all_messages++; | |
653 } | |
654 if (iconified) | |
655 drawIcon(); | |
656 } | |
657 logit(message); | |
658 | |
659 /* | |
660 fix for upgrade bug. Forced UDP would resend numbers, (thinking them | |
661 speed changes) screwing up upgrading on those twinkish sturgeon | |
662 servers. [BDyess] | |
663 */ | |
664 if (strncmp(message, "UPG->", 5) == 0) | |
665 upgrading = 1; | |
666 if (upgrading && !(me->p_flags & PFORBIT)) | |
667 upgrading = 0; | |
668 | |
669 if ((from != me->p_no) || pigSelf) | |
670 rsvp_borg_call(message, from); | |
671 | |
672 /* beep when a personal message is sent while iconified [BDyess] */ | |
673 if (to == me->p_no && (flags & MINDIV) && iconified) { | |
674 W_Beep(); | |
675 } | |
676 if (from == 255 && | |
677 strcmp(message, "Tractor beam aborted warp engagement") == 0) { | |
678 me->p_flags &= ~PFWARPPREP; | |
679 } | |
680 print_message(message, flags, from, to, data, NULL, 0); | |
681 } | |
682 | |
683 | |
684 int | |
685 instr(string1, string2) | |
686 char *string1, *string2; | |
687 { | |
688 char *s; | |
689 int length; | |
690 | |
691 length = strlen(string2); | |
692 for (s = string1; *s != 0; s++) { | |
693 if (*s == *string2 && strncmp(s, string2, length) == 0) | |
694 return (1); | |
695 } | |
696 return (0); | |
697 } | |
698 | |
699 void | |
700 CheckFeatures(m) | |
701 char *m; | |
702 /* I don't know if this works correctly or not. It is ripped from BRM and has | |
703 been modified a bit to fit. Right now it doesn't do anything. [BDyess] */ | |
704 { | |
705 char buf[BUFSIZ]; | |
706 char *pek = &m[10]; | |
707 | |
708 if ((int) strlen(m) < 11) | |
709 return; | |
710 | |
711 while ((*pek == ' ') && (*pek != '\0')) | |
712 pek++; | |
713 | |
714 strcpy(buf, "Paradise Client: "); | |
715 | |
716 if (!strcmp(pek, "NO_VIEW_BOX")) { | |
717 allowViewBox = 0; | |
718 strcat(buf, pek); | |
719 } | |
720 #ifdef CONTINUOUS_MOUSE | |
721 if (!strcmp(pek, "NO_CONTINUOUS_MOUSE")) { | |
722 allowContinuousMouse = 0; | |
723 strcat(buf, pek); | |
724 } | |
725 #endif /* CONTINUOUS_MOUSE */ | |
726 if (!strcmp(pek, "NO_SHOW_ALL_TRACTORS")) { | |
727 allowShowAllTractorPressor = 0; | |
728 strcat(buf, pek); | |
729 } | |
730 if (!strcmp(pek, "HIDE_PLAYERLIST_ON_ENTRY")) { | |
731 allowPlayerlist = 0; | |
732 strcat(buf, pek); | |
733 } | |
734 if (!strcmp(pek, "NO_NEWMACRO")) { | |
735 /* UseNewMacro = 0;*/ | |
736 strcat(buf, pek); | |
737 } | |
738 if (!strcmp(pek, "NO_SMARTMACRO")) { | |
739 /* UseSmartMacro = 0;*/ | |
740 strcat(buf, pek); | |
741 } | |
742 if (!strcmp(pek, "WHY_DEAD")) { | |
743 why_dead = 1; | |
744 strcat(buf, pek); | |
745 } | |
746 if (!strcmp(pek, "RC_DISTRESS")) { | |
747 /* gen_distress = 1;*/ | |
748 /* distmacro = dist_prefered;*/ | |
749 strcat(buf, pek); | |
750 } | |
751 /* what the hell is this? - jmn */ | |
752 if (!strncmp(pek, "INFO", 4)) { | |
753 strcat(buf, pek); | |
754 } | |
755 if (strlen(buf) == strlen("Paradise Client: ")) { | |
756 strcat(buf, "UNKNOWN FEATURE: "); | |
757 strcat(buf, pek); | |
758 } | |
759 buf[79] = '\0'; | |
760 | |
761 printf("%s\n", buf); | |
762 | |
763 W_WriteText(messWin[WREVIEW].window, 0, 0, W_White, buf, strlen(buf), 0); | |
764 W_WriteText(messWin[WALL].window, 0, 0, W_White, buf, strlen(buf), 0); | |
765 } | |
766 | |
767 void | |
768 sendVersion() | |
769 { | |
770 static int version_sent = 0; | |
771 char buf[80]; | |
772 | |
773 if (!version_sent) { | |
774 version_sent = 1; | |
775 sprintf(buf, "@%s", CLIENTVERS); | |
776 pmessage(buf, me->p_no, MINDIV | MCONFIG); | |
777 } | |
778 } |