26
static int talkative = 0;
28
static char cursor = '_';
30
char *getaddr(char who), *getaddr2(int flags, int recip);
33
#define BLANKCHAR(col, n) W_ClearArea(messagew, 5+W_Textwidth*(col), 5, \
34
W_Textwidth * (n), W_Textheight);
35
#define DRAWCURSOR(col) W_WriteText(messagew, 5+W_Textwidth*(col), 5, \
36
textColor, &cursor, 1, W_RegularFont);
37
#define TESTCAP(c,s) (c ? strcap(s) : s)
39
/* Routines to handle multi-window messaging */
42
int len = strlen(outmessage);
44
#ifdef XTRA_MESSAGE_UI
46
W_WriteText(w, 5, HUDoffset, textColor,
47
outmessage, len, W_RegularFont);
50
W_ClearWindow(messagew);
51
if (len == 0 && talkative < 5 && !isServerDead()) {
52
W_WriteText(messagew, 5, 5, W_Red,
53
"Talk to everyone, click here, type, press enter. "
54
"Read and learn.", -1, W_RegularFont);
56
W_WriteText(messagew, 5, 5, textColor,
57
outmessage, len, W_RegularFont);
61
void AddChar(char *twochar)
64
#ifdef XTRA_MESSAGE_UI
66
W_WriteText(w, 5 + W_Textwidth * lcount, HUDoffset, textColor,
67
twochar, 2, W_RegularFont);
70
W_WriteText(messagew, 5 + W_Textwidth * lcount, 5, textColor,
71
twochar, 2, W_RegularFont);
73
void BlankChar(int HUDoffsetcol, int len)
76
#ifdef XTRA_MESSAGE_UI
78
W_ClearArea(w, 5 + W_Textwidth * (HUDoffsetcol), HUDoffset,
79
W_Textwidth * (len), W_Textheight);
82
W_ClearArea(messagew, 5 + W_Textwidth * (HUDoffsetcol), 5,
83
W_Textwidth * (len), W_Textheight);
85
void DrawCursor(int col)
88
#ifdef XTRA_MESSAGE_UI
90
W_WriteText(w, 5 + W_Textwidth * (col), HUDoffset,
91
textColor, &cursor, 1, W_RegularFont);
94
W_WriteText(messagew, 5 + W_Textwidth * (col), 5,
95
textColor, &cursor, 1, W_RegularFont);
99
void smessage(char ichar)
102
char *getaddr(char who);
104
static char addr, *addr_str, *pm;
110
#ifdef XTRA_MESSAGE_UI
111
/* Figure out where to put the message on the local */
118
HUDoffset = W_WindowHeight(w) - W_Textheight - 5;
125
/* Put the proper recipient in the window */
130
if ((pm = INDEX((char *) keys, ichar)))
131
ichar = macroKeys[((int) pm) - ((int) keys)].dest;
135
if ((ichar == 't') || (ichar == 'T'))
136
addr = teamlet[me->p_team];
139
addr_str = getaddr(addr);
142
/* print error message */
147
strcat(outmessage, addr_str);
150
while (strlen(outmessage) < ADDRLEN)
152
strcat(outmessage, " ");
154
strcat(outmessage, "_");
156
/* Display the header */
162
if (ichar == ((char) ('h' + 96)) || ichar == ((char) ('H' + 96)))
164
else if (ichar == ((char) ('[' + 96)))
166
else if (ichar == ((char) ('m' + 96)) || ichar == ((char) ('M' + 96)))
168
else if (ichar == ((char) ('j' + 96)) || ichar == ((char) ('J' + 96)))
170
else if (ichar == ((char) ('u' + 96)) || ichar == ((char) ('U' + 96)))
173
switch ((unsigned char) ichar & ~(0x80))
175
case '\b': /* character erase */
177
if (--lcount < ADDRLEN)
182
BlankChar(lcount + 1, 1);
184
outmessage[lcount + 1] = '\0';
185
outmessage[lcount] = cursor;
188
case '\033': /* abort message */
189
BlankChar(0, lcount + 1);
193
for (i = 0; i < 80; i++)
195
outmessage[i] = '\0';
200
case 23: /* erase to start, but continue in message mode */
201
while (--lcount >= ADDRLEN)
203
BlankChar(lcount + 1, 1);
205
outmessage[lcount + 1] = '\0';
206
outmessage[lcount] = cursor;
210
case '\r': /* send message */
212
buf[lcount - ADDRLEN] = '\0';
214
for (i = 0; i < 80; i++)
216
outmessage[i] = '\0';
221
pmessage(buf, 0, MALL);
224
pmessage(buf, FED, MTEAM);
227
pmessage(buf, ROM, MTEAM);
230
pmessage(buf, KLI, MTEAM);
233
pmessage(buf, ORI, MTEAM);
236
pmessage(buf, 0, MGOD);
241
pmessage(buf, 0, MTOOLS);
246
pmessage(buf, 0, MMOO);
258
if (players[addr - '0'].p_status == PFREE)
260
warning("That player left the game. message not sent.");
263
pmessage(buf, addr - '0', MINDIV);
291
if (players[addr - 'a' + 10].p_status == PFREE)
293
warning("That player left the game. message not sent.");
296
pmessage(buf, addr - 'a' + 10, MINDIV);
299
warning("Not legal recipient");
301
BlankChar(0, lcount + 1);
307
default: /* add character */
313
if (iscntrl((unsigned char) ichar & ~(0x80)))
318
outmessage[lcount] = ichar;
319
outmessage[lcount + 1] = cursor;
320
buf[(lcount++) - ADDRLEN] = ichar;
325
void pmessage(char *str, int recip, int group)
329
/* message length failsafe and last message saving - jn 6/17/93 */
330
lastMessage[0] = '\0';
331
strncat(lastMessage, str, 79);
344
strcpy(defaultsFile, str);
345
sprintf(mbuf, "changing defaultsFile to %s", str);
349
sendMessage(str, group, recip);
352
if ((group == MTEAM && recip != me->p_team) ||
353
(group == MINDIV && recip != me->p_no))
355
sprintf(newbuf, "%s %s", getaddr2(group, recip), str);
357
dmessage(newbuf, group, me->p_no, recip);
369
return (getaddr2(MALL, 0));
371
return (getaddr2(MTEAM, FED));
373
return (getaddr2(MTEAM, ROM));
375
return (getaddr2(MTEAM, KLI));
377
return (getaddr2(MTEAM, ORI));
379
return (getaddr2(MGOD, 0));
381
return (getaddr2(MMOO, 0));
385
return (getaddr2(MTOOLS, 0));
398
if (players[who - '0'].p_status == PFREE)
400
warning("Slot is not alive.");
403
return (getaddr2(MINDIV, who - '0'));
431
if (who - 'a' + 10 > MAXPLAYER)
433
warning("Player is not in game");
436
if (players[who - 'a' + 10].p_status == PFREE)
438
warning("Slot is not alive.");
442
return (getaddr2(MINDIV, who - 'a' + 10));
445
warning("Not legal recipient");
450
char *getaddr2(int flags, int recip)
452
static char addrmesg[ADDRLEN];
454
(void) sprintf(addrmesg, " %c%c->", teamlet[me->p_team], shipnos[me->p_no]);
458
(void) sprintf(&addrmesg[5], "ALL");
461
(void) sprintf(&addrmesg[5], teamshort[recip]);
466
(void) sprintf(&addrmesg[5], "?? ");
471
/* printf("smessage:getaddr2 recip=%d\n",recip); */
472
(void) sprintf(&addrmesg[5], "%c%c ",
473
teamlet[players[recip].p_team], shipnos[recip]);
478
(void) sprintf(&addrmesg[5], "GOD");
483
(void) sprintf(addrmesg, "COW: sh>");
488
(void) sprintf(&addrmesg[5], "MOO");
494
void message_on(void)
497
W_DefineTextCursor(w);
498
W_DefineTextCursor(mapw);
500
#ifdef XTRA_MESSAGE_UI
507
void message_off(void)
510
W_DefineLocalcursor(w);
511
W_DefineMapcursor(mapw);
514
#ifdef XTRA_MESSAGE_UI
515
void message_hold(void)
525
/* Used in NEWMACRO, useful elsewhere also */
527
getgroup(char addr, int *recip)
579
if (players[addr - '0'].p_status == PFREE)
581
warning("That player left the game. message not sent.");
613
if (players[addr - 'a' + 10].p_status == PFREE)
615
warning("That player left the game. message not sent.");
618
*recip = addr - 'a' + 10;
622
warning("Not legal recipient");
628
void pnbtmacro(int c)
630
switch (macro[c].who)
633
pmessage(macro[c].string, 0, MALL);
636
pmessage(macro[c].string, FED, MTEAM);
639
pmessage(macro[c].string, ROM, MTEAM);
642
pmessage(macro[c].string, KLI, MTEAM);
645
pmessage(macro[c].string, ORI, MTEAM);
648
pmessage(macro[c].string, me->p_team, MTEAM);