-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrywin.c
948 lines (828 loc) · 20.6 KB
/
entrywin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
/*
* entrywin.c
*
* The original newwin.c split into two sections this one handling all the motd
* and entry window stuff
*
*/
#include "copyright.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include <sys/types.h>
#ifdef hpux
#include <time.h>
#else /* hpux */
#include <sys/time.h>
#endif /* hpux */
#include "netrek.h"
#include "bitmaps/clockbitmap.h"
#ifdef RECORD
#include "recorder.h"
#endif
struct list {
char bold;
struct list *next;
char *data;
};
static struct list *motddata = NULL; /* pointer to first bit of motddata */
static struct list *valuedata = NULL; /* pointer to server status info */
static int first = 1;
#if __STDC__ || defined(__cplusplus)
#define P_(s) s
#else
#define P_(s) ()
#endif
static int lineOnPage P_((int l, int line));
static void showPics P_((W_Window win, int l));
static void showValues P_((void));
#undef P_
#define NRHEADERS 4
static struct piclist *motdPics = NULL;
int newMotdStuff = 0; /* set to 1 when new motd packets arrive */
int MaxMotdLine = 0;
#ifdef EM
/*
* if a motd line from the server is this, the client will junk all motd *
* data it currently has. New data may be received
*/
#define MOTDCLEARLINE "\033\030CLEAR_MOTD"
#endif
#define SIZEOF(a) (sizeof (a) / sizeof (*(a)))
#define BOXSIDE (WINSIDE / 5)
#define TILESIDE 16
#define MESSAGESIZE 20
#define STATSIZE (MESSAGESIZE * 2 + BORDER)
#define YOFF 0
#define stipple_width 16
#define stipple_height 16
static char stipple_bits[] =
{
0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08,
0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80,
0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08,
0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80};
/* This routine throws up an entry window for the player. */
void
entrywindow(team, s_type)
int *team, *s_type;
{
int typeok = 0, i = 0;
W_Event event;
int lastplayercount[4];
int okayMask, lastOkayMask;
int resetting = 0;
int tiled = 0;
long lasttime = -1, now;
int spareTime = 240; /* Allow them an extra 240 seconds,
* as long as they are active */
long startTime, elapsed = 0;
struct timeval tv;
fd_set mask;
#ifdef AUTOLOGIN
static int first = 1;
#endif
int draw_motd = 1;
/* The following allows quick choosing of teams */
if (fastQuit) {
if (me->p_flags & PFSELFDEST) {
*team = -1;
return;
} else
fastQuit = 0;
}
lastOkayMask = okayMask = tournMask;
for (i = 0; i < 4; i++) {
if (okayMask & (1 << i)) {
tiled = 0;
} else {
tiled = 1;
}
if (tiled) {
W_TileWindow(teamWin[i], stipple);
} else {
W_UnTileWindow(teamWin[i]);
}
W_MapWindow(teamWin[i]);
lastplayercount[i] = -1; /* force redraw first time through */
}
W_MapWindow(qwin);
*team = -1;
startTime = mstime();
/*
if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE)
*/
#ifdef AUTOLOGIN
if(first && autologin){
first = 0; /* expose will draw motd */
draw_motd = 0;
}
#endif
if (W_IsMapped(playerw))
playerlist();
do {
while (!W_EventsPending()) {
#ifdef PING
/*
* changes here so that client reads from server whenever available
* instead of waiting 1 second each time. This has no affect on
* anything since we time(0) autoquit anyway
*/
#endif
tv.tv_sec = 1;
tv.tv_usec = 0;
FD_ZERO(&mask);
FD_SET(W_Socket(), &mask);
FD_SET(sock, &mask);
if (udpSock >= 0)
FD_SET(udpSock, &mask);
select(32, &mask, 0, 0, &tv);
if (FD_ISSET(sock, &mask) ||
(udpSock >= 0 && FD_ISSET(udpSock, &mask))) {
readFromServer(&mask);
}
now = mstime();
elapsed = now - startTime;
if (elapsed > AUTOQUIT * 1000) {
printf("Auto-Quit.\n");
*team = 4;
break;
}
if(newMotdStuff || draw_motd){
draw_motd = 0;
showMotd(w, motd_line);
showValues();
}
if (lasttime != now/1000){
/* this info is updated only once per second anyway */
if (W_IsMapped(playerw)) {
#ifdef EM
if (sortPlayers) {
if(!teamOrder) /* DBP */
Sorted_playerlist2();
else Sorted_playerlist3(); /* DBP */
}
else
#endif
playerlist2();
}
showTimeLeft(elapsed/1000, AUTOQUIT);
lasttime = now/1000;
}
okayMask = tournMask;
for (i = 0; i < 4; i++) {
if ((okayMask ^ lastOkayMask) & (1 << i)) {
if (okayMask & (1 << i)) {
W_UnTileWindow(teamWin[i]);
} else {
W_TileWindow(teamWin[i], stipple);
}
lastplayercount[i] = -1; /* force update */
}
redrawTeam(teamWin[i], i, &lastplayercount[i]);
}
lastOkayMask = okayMask;
}
if (*team == 4)
break;
/* an event happened -- reset timer, process event */
now = mstime();
if((now - startTime)/1000 <= spareTime){
spareTime -= (now - startTime)/1000;
startTime = now;
} else {
startTime += spareTime * 1000;
spareTime = 0;
}
#if 0
if (!W_EventsPending())
continue;
#endif
W_NextEvent(&event);
typeok = 1;
switch ((int) event.type) {
case W_EV_KEY:
switch (event.key) {
case 's':
*s_type = SCOUT;
break;
case 'd':
*s_type = DESTROYER;
break;
case 'c':
*s_type = CRUISER;
break;
case 'b':
*s_type = BATTLESHIP;
break;
#ifdef GALAXY
case 'g':
*s_type = SGALAXY;
break;
#endif /* GALAXY */
case 'X':
*s_type = ATT;
break;
case 'a':
*s_type = ASSAULT;
break;
case 'o':
*s_type = STARBASE;
break;
default:
typeok = 0;
break;
}
if(motdWin && event.Window == motdWin)
motdWinEvent(event.key);
else if (event.Window == w) {
switch (event.key) {
case 'y':
if (resetting) {
sendResetStatsReq('Y');
warning("OK, your stats have been reset.");
resetting = 0;
}
break;
case 'n':
if (resetting) {
warning("I didn't think so.");
resetting = 0;
}
break;
case 'R':
warning("Are you sure you want to reset your stats?");
resetting = 1;
break;
case 'f': /* Scroll motd forward */
motd_line = motd_line + LINESPERPAGE;
if (motd_line > MaxMotdLine) {
motd_line = motd_line - LINESPERPAGE;
break;
}
showMotd(w, motd_line);
break;
case 'b': /* Scroll motd backward */
if (motd_line == 0)
break;
motd_line = motd_line - LINESPERPAGE;
if (motd_line < 0)
motd_line = 0;
showMotd(w, motd_line);
break;
case 'j':
if(motd_line + LINESPERPAGE == MaxMotdLine)
break;
motd_line++;
showMotd(w, motd_line);
break;
case 'k':
if(!motd_line)
break;
motd_line--;
showMotd(w, motd_line);
break;
case 'M':
showMotdWin();
break;
#ifdef EM
case 'S':
SaveMotd();
break;
#endif
}
}
/* No break, we just fall through */
case W_EV_BUTTON:
if (typeok == 0)
break;
for (i = 0; i < 4; i++)
if (event.Window == teamWin[i]) {
*team = i;
break;
}
if (event.Window == qwin /* new */ &&
event.type == W_EV_BUTTON) {
*team = 4;
break;
}
if (*team != -1 && !teamRequest(*team, *s_type)) {
*team = -1;
}
if (udpWin && event.Window == udpWin){
udpaction(&event); /* UDP */
}
break;
case W_EV_EXPOSE:
for (i = 0; i < 4; i++)
if (event.Window == teamWin[i]) {
lastplayercount[i] = -1; /* force update */
redrawTeam(teamWin[i], i, &lastplayercount[i]);
break;
}
if (event.Window == qwin){
redrawQuit();
showTimeLeft(elapsed/1000, AUTOQUIT);
}
else if (event.Window == tstatw)
redrawTstats();
else if (event.Window == iconWin)
drawIcon();
else if (event.Window == w){
showMotd(w, motd_line);
}
else if(event.Window == mapw){
show_death(); /* keep death message */
showValues();
}
else if (event.Window == helpWin)
fillhelp();
#ifdef XTREKRC_HELP
else if (defWin && (event.Window == defWin))
showdef();
#endif
else if (event.Window == playerw)
playerlist();
else if (event.Window == warnw)
W_ClearWindow(warnw);
else if (event.Window == messagew)
smess_refresh();
else if (motdWin && event.Window == motdWin)
showMotd(motdWin, motdw_line);
break;
}
} while (*team < 0);
if (event.Window != qwin)
warning("Welcome aboard Captain!");
if (*team == 4) {
*team = -1;
return;
}
for (i = 0; i < 4; i++)
W_UnmapWindow(teamWin[i]);
W_UnmapWindow(qwin);
}
/* Attempt to pick specified team & ship */
int
teamRequest(team, ship)
int team, ship;
{
int lastTime;
pickOk = -1;
sendTeamReq(team, ship);
lastTime = time(NULL);
while (pickOk == -1) {
if (lastTime + 3 < time(NULL)) {
sendTeamReq(team, ship);
}
socketPause();
readFromServer(NULL);
if (isServerDead()) {
printf("Whoops! We've been ghostbusted!\n");
printf("Pray for a miracle!\n");
/* UDP fail-safe */
commMode = commModeReq = COMM_TCP;
commSwitchTimeout = 0;
if (udpSock >= 0)
closeUdpConn();
if (udpWin) {
udprefresh(UDP_CURRENT);
udprefresh(UDP_STATUS);
}
connectToServer(nextSocket);
printf("Yea! We've been resurrected!\n");
pickOk = 0;
break;
}
}
#ifdef RECORD
teamReq = team;
#endif
return (pickOk);
}
int
numShips(owner)
int owner;
{
int i, num = 0;
struct player *p;
for (i = 0, p = players; i < MAXPLAYER; i++, p++)
if (p->p_status == PALIVE && p->p_team == owner)
num++;
return (num);
}
#ifdef unused
realNumShips(owner)
{
int i, num = 0;
struct player *p;
for (i = 0, p = players; i < MAXPLAYER; i++, p++)
if (p->p_status != PFREE &&
p->p_team == owner)
num++;
return (num);
}
deadTeam(owner)
int owner;
/* The team is dead if it has no planets and cannot coup it's home planet */
{
int i, num = 0;
struct planet *p;
if (planets[remap[owner] * 10 - 10].pl_couptime == 0)
return (0);
for (i = 0, p = planets; i < MAXPLANETS; i++, p++) {
if (p->pl_owner & owner) {
num++;
}
}
if (num != 0)
return (0);
return (1);
}
#endif
static char *AUTHOR[] =
{
"",
"--- XtrekII Release Version 6.1 ---",
"By Chris Guthrie, Ed James,",
"Scott Silvey, and Kevin Smith",
"Amdahl UDP Revision", /* UDP */
};
int
checkBold(line)
/* Determine if that line should be highlighted on sign-on screen */
/* Which is done when it is the players own score being displayed */
char *line;
{
char *s, *t;
int i;
int end = 0;
if (strlen(line) < 60)
return (0);
if (me == NULL)
return (0);
s = line + 4;
t = me->p_name;
for (i = 0; i < 16; i++) {
if (!end) {
if (*t == '\0')
end = 1;
else if (*t != *s)
return (0);
}
if (end) {
if (*s != ' ')
return (0);
}
s++;
t++;
}
return (1);
}
void
showMotd(motdwin, atline)
W_Window motdwin;
int atline;
{
FILE *fopen();
int i, length, top, center;
register struct list *data;
int count;
if(!motdwin) return;
newMotdStuff = 0;
W_ClearWindow(motdwin);
for (i = 0; i < SIZEOF(AUTHOR); i++) {
length = strlen(AUTHOR[i]);
center = WINSIDE / 2 - (length * W_Textwidth) / 2;
W_WriteText(motdwin, center, i * W_Textheight, textColor, AUTHOR[i],
length, W_RegularFont);
}
top = LINESSTART;
if (first) {
first = 0;
data = motddata;
while (data != NULL) {
data->bold = checkBold(data->data);
data = data->next;
}
}
data = motddata;
for (i = 0; i < atline; i++) {
if (data == NULL) {
atline = 0;
data = motddata;
break;
}
data = data->next;
}
count = LINESPERPAGE;
for (i = top; i < 50; i++) {
if (data == NULL)
break;
if (!strcmp(data->data, STATUS_TOKEN)) /* ATM */
break;
if (data->bold) {
W_WriteText(motdwin, 20, i * W_Textheight, textColor, data->data,
strlen(data->data), W_BoldFont);
} else {
W_WriteText(motdwin, 20, i * W_Textheight, textColor, data->data,
strlen(data->data), W_RegularFont);
}
data = data->next;
count--;
if (count <= 0)
break;
}
showPics(motdwin, atline);
}
static int
lineOnPage(l, line)
int l, line;
{
return l >= line && l <= line + LINESPERPAGE;
}
static void
showPics(win, l)
W_Window win;
int l;
{
struct piclist *temp;
register x,y;
temp = motdPics;
while (temp != NULL) {
if (lineOnPage(temp->line, l)){
y = ((temp->line+1 - l) + LINESSTART) * W_Textheight
+ temp->y + W_Textheight/2;
x = temp->x;
if (temp->thepic){
W_WriteWinBitmap(win, x, y, temp->thepic,
temp->color);
}
else {
W_MakeLine(win, x, y,
x + temp->width - 1, y + temp->height - 1, W_Grey);
W_MakeLine(win, x, y + temp->height - 1,
x + temp->width - 1, y, W_Grey);
W_MakeLine(win, x, y,
x + temp->width - 1, y, W_Grey);
W_MakeLine(win, x, y,
x, y + temp->height - 1, W_Grey);
W_MakeLine(win, x, y + temp->height - 1,
x + temp->width - 1, y + temp->height - 1, W_Grey);
W_MakeLine(win, x + temp->width - 1, y + temp->height - 1,
x + temp->width - 1, y, W_Grey);
}
}
temp = temp->next;
}
}
/*
* ATM: show the current values of the .sysdef parameters.
*/
static void
showValues()
{
int i;
static char *msg = "OPTIONS SET WHEN YOU STARTED WERE:";
register struct list *data = valuedata;
if(!data) return;
data = data->next; /* skip the status token */
W_WriteText(mapw, 20, 14 * W_Textheight, textColor, msg,
strlen(msg), W_RegularFont);
for (i = 16; i < 50; i += 2) {
if (data == NULL)
break;
if (data->data[0] == '+') /* quick boldface hack */
W_WriteText(mapw, 20, i * W_Textheight, textColor, data->data + 1,
strlen(data->data) - 1, W_BoldFont);
else
W_WriteText(mapw, 20, i * W_Textheight, textColor, data->data,
strlen(data->data), W_RegularFont);
data = data->next;
}
}
static struct piclist **motd_buftail = &motdPics, *currpic;
void
ClearMotd()
{
struct piclist *temppic;
struct list *temp, *temp2;
while (motdPics) {
temppic = motdPics;
motdPics = temppic->next;
if (temppic->thepic)
W_FreeBitmap(temppic->thepic);
free(temppic);
}
motd_buftail = &motdPics;
currpic = NULL;
temp = motddata; /* start of motd information */
while (temp != NULL) {
temp2 = temp;
temp = temp->next;
free(temp2->data);
free(temp2);
}
first = 1; /* so that it'll check bold next time around */
}
void
newMotdPic(index, x, y, l, color)
int index, x,y,l, color;
{
struct piclist *temp, *i;
if (lineOnPage(l, motd_line)){
newMotdStuff = 1; /* set flag for event loop */
}
temp = (*motd_buftail) =
(struct piclist *) malloc(sizeof(struct piclist));
temp->next = NULL;
temp->index = index;
temp->x = x;
temp->y = y;
temp->line = l;
temp->color = color;
temp->width = 100;
temp->height = 100;
temp->thepic = NULL;
for(i=motdPics; i != temp; i=i->next){
/* bitmap sharing */
if(i->index == index){
temp->width = i->width;
temp->height = i->height;
temp->thepic = i->thepic;
}
}
currpic = temp;
motd_buftail = &(temp->next);
}
void
newMotdPicBitmap(size, width, height, bits)
int size;
int width, height;
char *bits;
{
currpic->width = width;
currpic->height = height;
currpic->thepic = bits ?
W_StoreBitmap(width, height, bits, motdWin) : 0;
}
void
newMotdLine(line)
char *line;
{
static struct list **temp = &motddata;
static int statmode = 0;/* ATM */
newMotdStuff = 1;
if (!statmode && !strcmp(line, STATUS_TOKEN))
statmode = 1;
if (!statmode)
MaxMotdLine++; /* ATM - don't show on left */
(*temp) = (struct list *) malloc(sizeof(struct list));
if ((*temp) == NULL) { /* malloc error checking -- 10/30/92 EM */
printf("Warning: Couldn't malloc space for a new motd line!");
return;
}
#ifdef EM
/* Motd clearing code */
if (strcmp(line, MOTDCLEARLINE) == 0) {
ClearMotd();
return;
}
#endif
(*temp)->next = NULL;
(*temp)->data = malloc(strlen(line) + 1);
strcpy((*temp)->data, line);
if(!valuedata && (strcmp((*temp)->data, STATUS_TOKEN) == 0))
valuedata = *temp;
temp = &((*temp)->next);
}
/* ARGSUSED */
void
getResources(prog)
char *prog;
{
getTiles();
}
void
getTiles()
{
if (!stipple)
stipple = W_StoreBitmap(stipple_width, stipple_height, stipple_bits, w);
}
void
redrawTeam(win, teamNo, lastnum)
W_Window win;
int teamNo;
int *lastnum;
{
char buf[BUFSIZ];
static char *teams[] =
{"Federation", "Romulan", "Klingon", "Orion"};
int num = numShips(1 << teamNo);
/* Only redraw if number of players has changed */
if (*lastnum == num)
return;
W_ClearWindow(win);
W_WriteText(win, 5, 5, shipCol[teamNo + 1], teams[teamNo],
strlen(teams[teamNo]), W_RegularFont);
(void) sprintf(buf, "%d", num);
W_MaskText(win, 35, 46, shipCol[teamNo + 1], buf, strlen(buf),
W_BigFont);
*lastnum = num;
}
void
redrawQuit()
{
W_WriteText(qwin, 5, 5, textColor, "Quit xtrek", 10, W_RegularFont);
}
void
drawIcon()
{
W_WriteBitmap(0, 0, icon, W_White);
}
#define CLOCK_WID (BOXSIDE * 9 / 10)
#define CLOCK_HEI (BOXSIDE * 2 / 3)
#define CLOCK_BDR 0
#define CLOCK_X (BOXSIDE / 2 - CLOCK_WID / 2)
#define CLOCK_Y (BOXSIDE / 2 - CLOCK_HEI / 2)
#define PI 3.141592654
void
showTimeLeft(time, max)
int time, max;
{
char buf[BUFSIZ], *cp;
int cx, cy, ex, ey, tx, ty;
if ((max - time) < 10 && time & 1) {
W_Beep();
}
/* XFIX */
W_ClearArea(qwin, CLOCK_X, CLOCK_Y, CLOCK_WID, CLOCK_HEI);
cx = CLOCK_X + CLOCK_WID / 2;
cy = CLOCK_Y + (CLOCK_HEI - W_Textheight) / 2;
ex = cx - clock_width / 2;
ey = cy - clock_height / 2;
W_WriteBitmap(ex, ey, clockpic, foreColor);
ex = cx - clock_width * sin(2 * PI * time / max) / 2;
ey = cy - clock_height * cos(2 * PI * time / max) / 2;
W_MakeLine(qwin, cx, cy, ex, ey, foreColor);
sprintf(buf, "%d", max - time);
tx = cx - W_Textwidth * strlen(buf) / 2;
ty = cy - W_Textheight / 2;
W_WriteText(qwin, tx, ty, textColor, buf, strlen(buf), W_RegularFont);
cp = "Auto Quit";
tx = CLOCK_X + cx - W_Textwidth * strlen(cp) / 2;
ty = CLOCK_Y + CLOCK_HEI - W_Textheight;
W_WriteText(qwin, tx, ty, textColor, cp, strlen(cp), W_RegularFont);
}
void
do_refit(type)
int type;
{
sendRefitReq(type);
localflags &= ~PFREFIT;
}
#ifdef EM
#define DEFAULT_SAVEFILE "netrek_motd"
/* default file to save motd into */
/* save all the motd data into a save file! */
void
SaveMotd()
{
FILE *fp;
struct list *mtd_ptr = NULL;
char *nameptr;
time_t time_clock;
char buf[BUFSIZ],
buf2[BUFSIZ];
if ((nameptr = getdefault("motd.savefile")) == NULL){
sprintf(buf, "%s.%s", DEFAULT_SAVEFILE, serverName);
nameptr = buf;
}
#ifdef SHOW_DEFAULTS
show_defaults("string", "motd.savefile", DEFAULT_SAVEFILE,
"Name of file to save motd in if 'S' typed in entry window.");
#endif
fp = fopen(nameptr, "a");
if (fp == NULL) {
perror(nameptr);
return;
}
time_clock = time(NULL);
if (fprintf(fp, "Motd data captured at %s\n", ctime(&time_clock)) < 0) {
perror(nameptr);
fclose(fp);
return;
}
for (mtd_ptr = motddata; mtd_ptr != NULL; mtd_ptr = mtd_ptr->next) {
if (fprintf(fp, "%s\n", mtd_ptr->data) < 0) {
fprintf(stderr, "Error writing motd!\n");
perror("fprintf error");
fclose(fp);
}
}
sprintf(buf2, "Netrek motd saved in %s\n", nameptr);
warning(buf2);
fclose(fp);
}
#endif