annotate dmessage.c @ 3:5a977ccbc7a9 default tip

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