-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathqstat.c
11725 lines (9898 loc) · 277 KB
/
qstat.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
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* qstat
* by Steve Jankowski
* http://www.qstat.org
*
* Thanks to Per Hammer for the OS/2 patches ([email protected])
* Thanks to John Ross Hunt for the OpenVMS Alpha patches ([email protected])
* Thanks to Scott MacFiggen for the quicksort code ([email protected])
* Thanks to Simon Garner for the XML patch ([email protected])
* Thanks to Bob Marriott for the Ghost Recon code ([email protected])
*
* Inspired by QuakePing by Len Norton
*
* Copyright 1996,1997,1998,1999,2000,2001,2002,2003,2004 by Steve Jankowski
*
* Licensed under the Artistic License, see LICENSE.txt for license terms
*/
#define RECV_BUF 204800
/* OS/2 defines */
#ifdef __OS2__
#define BSD_SELECT
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <assert.h>
#define QUERY_PACKETS
#include "qstat.h"
#include "packet_manip.h"
#include "config.h"
#include "xform.h"
#ifndef _WIN32
#include <signal.h>
#include <unistd.h>
#include <sys/socket.h>
#ifndef VMS
#include <sys/param.h>
#endif
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <arpa/inet.h>
#ifndef F_SETFL
#include <fcntl.h>
#endif
#ifdef __hpux
extern int h_errno;
#define STATIC static
#else
#define STATIC
#endif
#define INVALID_SOCKET -1
#ifndef INADDR_NONE
#define INADDR_NONE ~0
#endif
#define sockerr() errno
#else /* _WIN32 */
#include "utils.h"
#endif /* !_WIN32 */
#ifdef __OS2__
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include <utils.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define close(a) soclose(a)
#endif /* __OS2__ */
#ifndef FD_SETSIZE
#define FD_SETSIZE 64
#endif
/* Figure out whether to use poll() or select()
*/
#ifndef USE_POLL
#ifndef USE_SELECT
#ifdef sun
#define USE_POLL
#endif
#ifdef linux
#define USE_POLL
#include <poll.h>
#endif
#ifdef __linux__
#define USE_POLL
#include <poll.h>
#endif
#ifdef __linux
#define USE_POLL
#include <poll.h>
#endif
#ifdef __hpux
#define USE_POLL
#include <sys/poll.h>
#endif
#ifdef __OpenBSD__
#define USE_POLL
#include <sys/poll.h>
#endif
#ifdef _AIX
#define USE_POLL
#include <poll.h>
#endif
#ifdef _WIN32
#define USE_SELECT
#endif
#ifdef __EMX__
#define USE_SELECT
#endif
#endif /* USE_SELECT */
#endif /* USE_POLL */
/* If did not chose, then use select()
*/
#ifndef USE_POLL
#ifndef USE_SELECT
#define USE_SELECT
#endif
#endif
#include "debug.h"
server_type *types;
int n_server_types;
char *qstat_version = QSTAT_VERSION;
/*
* Values set by command-line arguments
*/
int hostname_lookup = 0; /* set if -H was specified */
int new_style = 1; /* unset if -old was specified */
int n_retries = DEFAULT_RETRIES;
int retry_interval = DEFAULT_RETRY_INTERVAL;
int master_retry_interval = DEFAULT_RETRY_INTERVAL * 4;
int syncconnect = 0;
int get_player_info = 0;
int get_server_rules = 0;
int up_servers_only = 0;
int no_full_servers = 0;
int no_empty_servers = 0;
int no_header_display = 0;
int raw_display = 0;
char *raw_delimiter = "\t";
char *multi_delimiter = "|";
int player_address = 0;
int max_simultaneous = MAXFD_DEFAULT;
int sendinterval = 5;
extern int xform_names;
extern int xform_strip_unprintable;
extern int xform_hex_player_names;
extern int xform_hex_server_names;
extern int xform_strip_carets;
extern int xform_html_names;
extern int html_mode;
int raw_arg = 0;
int show_game_in_raw = 0;
int progress = 0;
int num_servers_total = 0;
int num_players_total = 0;
int max_players_total = 0;
int num_servers_returned = 0;
int num_servers_timed_out = 0;
int num_servers_down = 0;
server_type *default_server_type = NULL;
FILE *OF; /* output file */
unsigned int source_ip = INADDR_ANY;
unsigned short source_port_low = 0;
unsigned short source_port_high = 0;
unsigned short source_port = 0;
int show_game_port = 0;
int no_port_offset = 0;
int output_bom = 0;
int xml_display = 0;
int xml_encoding = ENCODING_LATIN_1;
#define SUPPORTED_SERVER_SORT "pgihn"
#define SUPPORTED_PLAYER_SORT "PFTNS"
#define SUPPORTED_SORT_KEYS "l" SUPPORTED_SERVER_SORT SUPPORTED_PLAYER_SORT
char sort_keys[32];
int player_sort = 0;
int server_sort = 0;
int qpartition(void **array, int i, int j, int (*compare)(void *, void *));
void sort_servers(struct qserver **array, int size);
void sort_players(struct qserver *server);
int server_compare(struct qserver *one, struct qserver *two);
int player_compare(struct player *one, struct player *two);
int process_func_ret(struct qserver *server, int ret);
int connection_inprogress();
void clear_socketerror();
int show_errors = 0;
static int noserverdups = 1;
#define DEFAULT_COLOR_NAMES_RAW 0
#define DEFAULT_COLOR_NAMES_DISPLAY 1
int color_names = -1;
#define SECONDS 0
#define CLOCK_TIME 1
#define STOPWATCH_TIME 2
#define DEFAULT_TIME_FMT_RAW SECONDS
#define DEFAULT_TIME_FMT_DISPLAY CLOCK_TIME
int time_format = -1;
struct qserver *servers = NULL;
struct qserver **last_server = &servers;
struct qserver **connmap = NULL;
int max_connmap;
struct qserver *last_server_bind = NULL;
struct qserver *first_server_bind = NULL;
int connected = 0;
time_t run_timeout = 0;
time_t start_time;
int waiting_for_masters;
#define ADDRESS_HASH_LENGTH 2999
static unsigned num_servers;/* current number of servers in memory */
static struct qserver **server_hash[ADDRESS_HASH_LENGTH];
static unsigned int server_hash_len[ADDRESS_HASH_LENGTH];
static void free_server_hash();
static void xml_display_player_info_info(struct player *player);
char *DOWN = "DOWN";
char *SYSERROR = "SYSERROR";
char *TIMEOUT = "TIMEOUT";
char *MASTER = "MASTER";
char *SERVERERROR = "ERROR";
char *HOSTNOTFOUND = "HOSTNOTFOUND";
char *BFRIS_SERVER_NAME = "BFRIS Server";
char *GAMESPY_MASTER_NAME = "Gamespy Master";
int display_prefix = 0;
char *current_filename;
int current_fileline;
int count_bits(int n);
static int qserver_get_timeout(struct qserver *server, struct timeval *now);
static int wait_for_timeout(unsigned int ms);
static void finish_output();
static int decode_stefmaster_packet(struct qserver *server, char *pkt, int pktlen);
static int decode_q3master_packet(struct qserver *server, char *ikt, int pktlen);
char *ut2003_strdup(const char *string, const char *end, char **next);
void free_server(struct qserver *server);
void free_player(struct player *player);
void free_rule(struct rule *rule);
void standard_display_server(struct qserver *server);
/* MODIFY HERE
* Change these functions to display however you want
*/
void
display_server(struct qserver *server)
{
if (player_sort) {
sort_players(server);
}
if (raw_display) {
raw_display_server(server);
} else if (xml_display) {
xml_display_server(server);
} else if (json_display) {
json_display_server(server);
} else if (have_server_template()) {
template_display_server(server);
} else {
standard_display_server(server);
}
free_server(server);
}
void
standard_display_server(struct qserver *server)
{
char prefix[64];
if (display_prefix) {
sprintf(prefix, "%-4s ", server->type->type_prefix);
} else {
prefix[0] = '\0';
}
if ((server->server_name == DOWN) || (server->server_name == SYSERROR)) {
if (!up_servers_only) {
xform_printf(OF, "%s%-16s %10s\n", prefix, (hostname_lookup) ? server->host_name : server->arg, server->server_name);
}
return;
}
if (server->server_name == TIMEOUT) {
if (server->flags & FLAG_BROADCAST && server->n_servers) {
xform_printf(OF, "%s%-16s %d servers\n", prefix, server->arg, server->n_servers);
} else if (!up_servers_only) {
xform_printf(OF, "%s%-16s no response\n", prefix, (hostname_lookup) ? server->host_name : server->arg);
}
return;
}
if (server->type->master) {
display_qwmaster(server);
return;
}
if (no_full_servers && (server->num_players >= server->max_players)) {
return;
}
if (no_empty_servers && (server->num_players == 0)) {
return;
}
if (server->error != NULL) {
xform_printf(OF, "%s%-21s ERROR <%s>\n", prefix, (hostname_lookup) ? server->host_name : server->arg, server->error);
return;
}
if (new_style) {
char *game = get_qw_game(server);
int map_name_width = 8, game_width = 0;
switch (server->type->id) {
case QW_SERVER:
case Q2_SERVER:
case Q3_SERVER:
game_width = 9;
break;
case TRIBES2_SERVER:
map_name_width = 14;
game_width = 8;
break;
case GHOSTRECON_SERVER:
map_name_width = 15;
game_width = 15;
break;
case HL_SERVER:
map_name_width = 12;
break;
default:
break;
}
xform_printf(OF,
"%s%-21s %2d/%-2d %2d/%-2d %*s %6d / %1d %*s %s\n",
prefix,
(hostname_lookup) ? server->host_name : server->arg,
server->num_players,
server->max_players,
server->num_spectators,
server->max_spectators,
map_name_width,
(server->map_name) ? xform_name(server->map_name, server) : "?",
server->n_requests ? server->ping_total / server->n_requests : 999,
server->n_retries,
game_width,
game,
xform_name(server->server_name, server)
);
if (get_server_rules && (NULL != server->type->display_rule_func)) {
server->type->display_rule_func(server);
}
if (get_player_info && (NULL != server->type->display_player_func)) {
server->type->display_player_func(server);
}
} else {
char name[512];
sprintf(name, "\"%s\"", server->server_name);
xform_printf(OF,
"%-16s %10s map %s at %22s %d/%d players %d ms\n",
(hostname_lookup) ? server->host_name : server->arg,
name,
server->map_name,
server->address,
server->num_players,
server->max_players,
server->n_requests ? server->ping_total / server->n_requests : 999
);
}
}
void
display_qwmaster(struct qserver *server)
{
char *prefix;
prefix = server->type->type_prefix;
if (server->error != NULL) {
xform_printf(OF,
"%s %-17s ERROR <%s>\n",
prefix,
(hostname_lookup) ? server->host_name : server->arg,
server->error
);
} else {
xform_printf(OF,
"%s %-17s %d servers %6d / %1d\n",
prefix,
(hostname_lookup) ? server->host_name : server->arg,
server->n_servers,
server->n_requests ? server->ping_total / server->n_requests : 999,
server->n_retries
);
}
}
void
display_header()
{
if (!no_header_display) {
xform_printf(OF, "%-16s %8s %8s %15s %s\n", "ADDRESS", "PLAYERS", "MAP", "RESPONSE TIME", "NAME");
}
}
void
display_server_rules(struct qserver *server)
{
struct rule *rule;
int printed = 0;
rule = server->rules;
for ( ; rule != NULL; rule = rule->next) {
if (((server->type->id != Q_SERVER) && (server->type->id != H2_SERVER)) || !is_default_rule(rule)) {
xform_printf(OF, "%c%s=%s", (printed) ? ',' : '\t', rule->name, rule->value);
printed++;
}
}
if (printed) {
fputs("\n", OF);
}
}
void
display_q_player_info(struct qserver *server)
{
char fmt[128];
struct player *player;
strcpy(fmt, "\t#%-2d %3d frags %9s ");
if (color_names) {
strcat(fmt, "%9s:%-9s ");
} else {
strcat(fmt, "%2s:%-2s ");
}
if (player_address) {
strcat(fmt, "%22s ");
} else {
strcat(fmt, "%s");
}
strcat(fmt, "%s\n");
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, fmt,
player->number,
player->frags,
play_time(player->connect_time, 1),
quake_color(player->shirt_color),
quake_color(player->pants_color),
(player_address) ? player->address : "",
xform_name(player->name, server)
);
}
}
void
display_qw_player_info(struct qserver *server)
{
char fmt[128];
struct player *player;
strcpy(fmt, "\t#%-6d %5d frags %6s@%-5s %8s");
if (color_names) {
strcat(fmt, "%9s:%-9s ");
} else {
strcat(fmt, "%2s:%-2s ");
}
strcat(fmt, "%12s %s\n");
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, fmt,
player->number,
player->frags,
play_time(player->connect_time, 0),
ping_time(player->ping),
player->skin ? player->skin : "",
quake_color(player->shirt_color),
quake_color(player->pants_color),
xform_name(player->name, server),
xform_name(player->team_name, server)
);
}
}
void
display_q2_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
if (server->flags & FLAG_PLAYER_TEAMS) {
xform_printf(OF, "\t%3d frags team#%d %8s %s\n", player->frags, player->team, ping_time(player->ping), xform_name(player->name, server));
} else {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, ping_time(player->ping), xform_name(player->name, server));
}
}
}
void
display_unreal_player_info(struct qserver *server)
{
struct player *player;
static const char *fmt_team_number = "\t%3d frags team#%-3d %7s %s\n";
static const char *fmt_team_name = "\t%3d frags %8s %7s %s\n";
static const char *fmt_no_team = "\t%3d frags %8s %s\n";
player = server->players;
for ( ; player != NULL; player = player->next) {
if (server->flags & FLAG_PLAYER_TEAMS) {
// we use (player->score) ? player->score : player->frags,
// so we get details from halo
if (player->team_name) {
xform_printf(OF, fmt_team_name,
(player->score && NA_INT != player->score) ? player->score : player->frags,
player->team_name,
ping_time(player->ping),
xform_name(player->name, server)
);
} else {
xform_printf(OF, fmt_team_number,
(player->score && NA_INT != player->score) ? player->score : player->frags,
player->team,
ping_time(player->ping),
xform_name(player->name, server)
);
}
} else {
xform_printf(OF, fmt_no_team, player->frags, ping_time(player->ping), xform_name(player->name, server));
}
}
}
void
display_shogo_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, ping_time(player->ping), xform_name(player->name, server));
}
}
void
display_halflife_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, play_time(player->connect_time, 1), xform_name(player->name, server));
}
}
void
display_fl_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %8s %s\n", player->frags, ping_time(player->ping), play_time(player->connect_time, 1), xform_name(player->name, server));
}
}
void
display_tribes_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%4d score team#%d %8s %s\n", player->frags, player->team, ping_time(player->ping), xform_name(player->name, server)
);
}
}
void
display_tribes2_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\tscore %4d %14s %s\n",
player->frags,
player->team_name ? player->team_name : (player->number == TRIBES_TEAM ? "TEAM" : "?"),
xform_name(player->name, server)
);
}
}
void
display_bfris_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\ttid: %d, ship: %d, team: %s, ping: %d, score: %d, kills: %d, name: %s\n",
player->number,
player->ship,
player->team_name,
player->ping,
player->score,
player->frags,
xform_name(player->name, server)
);
}
}
void
display_descent3_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %3d deaths team#%-3d %7s %s\n",
player->frags,
player->deaths,
player->team,
ping_time(player->ping),
xform_name(player->name, server)
);
}
}
void
display_ghostrecon_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\tdead=%3d team#%-3d %s\n", player->deaths, player->team, xform_name(player->name, server));
}
}
void
display_eye_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
if (player->team_name) {
xform_printf(OF, "\tscore %4d %6s team %12s %s\n",
player->score,
ping_time(player->ping),
player->team_name,
xform_name(player->name, server)
);
} else {
xform_printf(OF, "\tscore %4d %6s team#%d %s\n",
player->score,
ping_time(player->ping),
player->team,
xform_name(player->name, server)
);
}
}
}
int
calculate_armyops_score(struct player *player)
{
/* Calculates a player's score for ArmyOps from the basic components */
int score = 0;
int kill_score = 0;
struct info *info;
for (info = player->info; info; info = info->next) {
if ((0 == strcmp(info->name, "leader")) || (0 == strcmp(info->name, "goal")) || (0 == strcmp(info->name, "roe"))) {
score += atoi(info->value);
} else if ((0 == strcmp(info->name, "kia")) || (0 == strcmp(info->name, "enemy"))) {
kill_score += atoi(info->value);
}
}
if (kill_score > 0) {
score += kill_score;
}
return (score);
}
void
display_gs2_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
if (player->team_name) {
xform_printf(OF, "\tscore %4d %6s team %12s %s\n",
player->score,
ping_time(player->ping),
player->team_name,
xform_name(player->name, server)
);
} else {
xform_printf(OF, "\tscore %4d %6s team#%d %s\n",
player->score,
ping_time(player->ping),
player->team,
xform_name(player->name, server)
);
}
}
}
void
display_armyops_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
player->score = calculate_armyops_score(player);
}
display_gs2_player_info(server);
}
void
display_ts2_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%6s %s\n", ping_time(player->ping), xform_name(player->name, server));
}
}
void
display_ts3_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%s\n", xform_name(player->name, server));
}
}
void
display_starmade_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%s\n", xform_name(player->name, server));
}
}
void
display_bfbc2_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%s\n", xform_name(player->name, server));
}
}
void
display_wic_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t#%-4d score %4d team %12s role %12s %s\n",
player->number,
player->score,
player->team_name,
player->tribe_tag ? player->tribe_tag : "",
xform_name(player->name, server)
);
}
}
void
display_ventrilo_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t# %d ping %s time %d cid %i ch %s name %s\n",
player->number,
ping_time(player->ping),
player->connect_time,
player->team,
player->team_name,
xform_name(player->name, server)
);
}
}
void
display_tm_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%6s %s\n", ping_time(player->ping), xform_name(player->name, server));
}
}
void
display_doom3_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
if (player->tribe_tag) {
xform_printf(OF, "\t#%-4d score %4d %6s team %12s %s\n",
player->number,
player->score,
ping_time(player->ping),
player->tribe_tag,
xform_name(player->name, server)
);
} else {
xform_printf(OF, "\t#%-4d score %4d %6s team#%d %s\n",
player->number,
player->score,
ping_time(player->ping),
player->team,
xform_name(player->name, server)
);
}
}
}
void
display_ravenshield_player_info(struct qserver *server)
{
struct player *player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, play_time(player->connect_time, 1), xform_name(player->name, server));
}
}
void
display_savage_player_info(struct qserver *server)
{
struct player *player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, play_time(player->connect_time, 1), xform_name(player->name, server));
}
}
void
display_farcry_player_info(struct qserver *server)
{
struct player *player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%3d frags %8s %s\n", player->frags, play_time(player->connect_time, 1), xform_name(player->name, server));
}
}
void
display_tee_player_info(struct qserver *server)
{
struct player *player;
player = server->players;
for ( ; player != NULL; player = player->next) {
xform_printf(OF, "\t%4d score %s\n", player->score, xform_name(player->name, server));
}
}
char *
get_qw_game(struct qserver *server)
{
struct rule *rule;
char *game_rule = server->type->game_rule;
if ((game_rule == NULL) || (*game_rule == '\0')) {
return ("");
}
rule = server->rules;
for ( ; rule != NULL; rule = rule->next) {
if (strcmp(rule->name, game_rule) == 0) {
if ((server->type->id == Q3_SERVER) && (strcmp(rule->value, "baseq3") == 0)) {
return ("");
}
return (rule->value);
}
}
rule = server->rules;
for ( ; rule != NULL; rule = rule->next) {
if ((0 == strcmp(rule->name, "game")) || (0 == strcmp(rule->name, "fs_game"))) {
return (rule->value);
}
}
return ("");
}
/* Raw output for web master types
*/
#define RD raw_delimiter
void
raw_display_server(struct qserver *server)
{
char *prefix;
int ping_time;