mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
Attempt to fix alphageek's compile problem, and clean up other horrors.
This commit is contained in:
parent
e74d05c12b
commit
872c2f5c5f
1 changed files with 28 additions and 54 deletions
|
@ -127,6 +127,7 @@ server_t *
|
||||||
SVL_New (netadr_t *adr)
|
SVL_New (netadr_t *adr)
|
||||||
{
|
{
|
||||||
server_t *sv;
|
server_t *sv;
|
||||||
|
|
||||||
sv = (server_t *) calloc (1, sizeof (server_t));
|
sv = (server_t *) calloc (1, sizeof (server_t));
|
||||||
sv->heartbeat = 0;
|
sv->heartbeat = 0;
|
||||||
sv->info[0] = 0;
|
sv->info[0] = 0;
|
||||||
|
@ -178,8 +179,9 @@ SVL_Find (netadr_t adr)
|
||||||
static void
|
static void
|
||||||
NET_Filter (void)
|
NET_Filter (void)
|
||||||
{
|
{
|
||||||
netadr_t filter_adr;
|
|
||||||
int hold_port;
|
int hold_port;
|
||||||
|
netadr_t filter_adr;
|
||||||
|
filter_t *filter;
|
||||||
|
|
||||||
hold_port = net_from.port;
|
hold_port = net_from.port;
|
||||||
NET_StringToAdr ("127.0.0.1:26950", &filter_adr);
|
NET_StringToAdr ("127.0.0.1:26950", &filter_adr);
|
||||||
|
@ -191,9 +193,8 @@ NET_Filter (void)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if no compare with filter list
|
|
||||||
filter_t *filter;
|
|
||||||
|
|
||||||
|
// if no compare with filter list
|
||||||
if ((filter = FL_Find (net_from))) {
|
if ((filter = FL_Find (net_from))) {
|
||||||
NET_CopyAdr (&net_from, &filter->to);
|
NET_CopyAdr (&net_from, &filter->to);
|
||||||
net_from.port = hold_port;
|
net_from.port = hold_port;
|
||||||
|
@ -203,8 +204,9 @@ NET_Filter (void)
|
||||||
void
|
void
|
||||||
SV_InitNet (void)
|
SV_InitNet (void)
|
||||||
{
|
{
|
||||||
int port;
|
char str[64];
|
||||||
int p;
|
int port, p;
|
||||||
|
FILE *filters;
|
||||||
|
|
||||||
port = PORT_MASTER;
|
port = PORT_MASTER;
|
||||||
p = COM_CheckParm ("-port");
|
p = COM_CheckParm ("-port");
|
||||||
|
@ -215,9 +217,6 @@ SV_InitNet (void)
|
||||||
NET_Init (port);
|
NET_Init (port);
|
||||||
|
|
||||||
// Add filters
|
// Add filters
|
||||||
FILE *filters;
|
|
||||||
char str[64];
|
|
||||||
|
|
||||||
if ((filters = fopen ("filters.ini", "rt"))) {
|
if ((filters = fopen ("filters.ini", "rt"))) {
|
||||||
while (fgets (str, 64, filters)) {
|
while (fgets (str, 64, filters)) {
|
||||||
Cbuf_AddText (mst_cbuf, "filter add ");
|
Cbuf_AddText (mst_cbuf, "filter add ");
|
||||||
|
@ -260,18 +259,15 @@ AnalysePacket (void)
|
||||||
c = p[0];
|
c = p[0];
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
Con_Printf (" \\n ");
|
Con_Printf (" \\n ");
|
||||||
|
|
||||||
else if (c >= 32 && c <= 127)
|
else if (c >= 32 && c <= 127)
|
||||||
Con_Printf (" %c ", c);
|
Con_Printf (" %c ", c);
|
||||||
|
|
||||||
else if (c < 10)
|
else if (c < 10)
|
||||||
Con_Printf (" \\%1i ", c);
|
Con_Printf (" \\%1i ", c);
|
||||||
|
|
||||||
else if (c < 100)
|
else if (c < 100)
|
||||||
Con_Printf (" \\%2i ", c);
|
Con_Printf (" \\%2i ", c);
|
||||||
|
|
||||||
else
|
else
|
||||||
Con_Printf ("\\%3i ", c);
|
Con_Printf ("\\%3i ", c);
|
||||||
|
|
||||||
if (i % 8 == 7)
|
if (i % 8 == 7)
|
||||||
Con_Printf ("\n");
|
Con_Printf ("\n");
|
||||||
}
|
}
|
||||||
|
@ -320,8 +316,7 @@ Mst_Packet (void)
|
||||||
char msg;
|
char msg;
|
||||||
server_t *sv;
|
server_t *sv;
|
||||||
|
|
||||||
|
// NET_Filter();
|
||||||
// NET_Filter();
|
|
||||||
msg = net_message->message->data[1];
|
msg = net_message->message->data[1];
|
||||||
if (msg == A2A_PING) {
|
if (msg == A2A_PING) {
|
||||||
NET_Filter ();
|
NET_Filter ();
|
||||||
|
@ -331,9 +326,7 @@ Mst_Packet (void)
|
||||||
SVL_Add (sv);
|
SVL_Add (sv);
|
||||||
}
|
}
|
||||||
sv->timeout = Sys_DoubleTime ();
|
sv->timeout = Sys_DoubleTime ();
|
||||||
}
|
} else if (msg == S2M_HEARTBEAT) {
|
||||||
|
|
||||||
else if (msg == S2M_HEARTBEAT) {
|
|
||||||
NET_Filter ();
|
NET_Filter ();
|
||||||
Con_Printf ("%s >> S2M_HEARTBEAT\n", NET_AdrToString (net_from));
|
Con_Printf ("%s >> S2M_HEARTBEAT\n", NET_AdrToString (net_from));
|
||||||
if (!(sv = SVL_Find (net_from))) {
|
if (!(sv = SVL_Find (net_from))) {
|
||||||
|
@ -341,24 +334,18 @@ Mst_Packet (void)
|
||||||
SVL_Add (sv);
|
SVL_Add (sv);
|
||||||
}
|
}
|
||||||
sv->timeout = Sys_DoubleTime ();
|
sv->timeout = Sys_DoubleTime ();
|
||||||
}
|
} else if (msg == S2M_SHUTDOWN) {
|
||||||
|
|
||||||
else if (msg == S2M_SHUTDOWN) {
|
|
||||||
NET_Filter ();
|
NET_Filter ();
|
||||||
Con_Printf ("%s >> S2M_SHUTDOWN\n", NET_AdrToString (net_from));
|
Con_Printf ("%s >> S2M_SHUTDOWN\n", NET_AdrToString (net_from));
|
||||||
if ((sv = SVL_Find (net_from))) {
|
if ((sv = SVL_Find (net_from))) {
|
||||||
SVL_Remove (sv);
|
SVL_Remove (sv);
|
||||||
free (sv);
|
free (sv);
|
||||||
}
|
}
|
||||||
}
|
} else if (msg == 'c') {
|
||||||
|
|
||||||
else if (msg == 'c') {
|
|
||||||
Con_Printf ("%s >> ", NET_AdrToString (net_from));
|
Con_Printf ("%s >> ", NET_AdrToString (net_from));
|
||||||
Con_Printf ("Gamespy server list request\n");
|
Con_Printf ("Gamespy server list request\n");
|
||||||
Mst_SendList ();
|
Mst_SendList ();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
byte *p;
|
byte *p;
|
||||||
|
|
||||||
p = net_message->message->data;
|
p = net_message->message->data;
|
||||||
|
@ -366,9 +353,7 @@ Mst_Packet (void)
|
||||||
Con_Printf ("Pingtool server list request\n");
|
Con_Printf ("Pingtool server list request\n");
|
||||||
if (p[0] == 0 && p[1] == 'y') {
|
if (p[0] == 0 && p[1] == 'y') {
|
||||||
Mst_SendList ();
|
Mst_SendList ();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
Con_Printf ("%s >> ", NET_AdrToString (net_from));
|
Con_Printf ("%s >> ", NET_AdrToString (net_from));
|
||||||
Con_Printf ("%c\n", net_message->message->data[1]);
|
Con_Printf ("%c\n", net_message->message->data[1]);
|
||||||
AnalysePacket ();
|
AnalysePacket ();
|
||||||
|
@ -387,7 +372,8 @@ SV_ReadPackets (void)
|
||||||
void
|
void
|
||||||
SV_ConnectionlessPacket (void)
|
SV_ConnectionlessPacket (void)
|
||||||
{
|
{
|
||||||
Con_Printf ("%s>>%s\n", NET_AdrToString (net_from), net_message->message->data);
|
Con_Printf ("%s>>%s\n", NET_AdrToString (net_from),
|
||||||
|
net_message->message->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int argv_index_add;
|
int argv_index_add;
|
||||||
|
@ -399,8 +385,8 @@ Cmd_FilterAdd (void)
|
||||||
netadr_t to, from;
|
netadr_t to, from;
|
||||||
|
|
||||||
if (Cmd_Argc () < 4 + argv_index_add) {
|
if (Cmd_Argc () < 4 + argv_index_add) {
|
||||||
Con_Printf
|
Con_Printf ("Invalid command parameters. "
|
||||||
("Invalid command parameters. Usage:\nfilter add x.x.x.x:port x.x.x.x:port\n\n");
|
"Usage:\nfilter add x.x.x.x:port x.x.x.x:port\n\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NET_StringToAdr (Cmd_Argv (2 + argv_index_add), &from);
|
NET_StringToAdr (Cmd_Argv (2 + argv_index_add), &from);
|
||||||
|
@ -414,9 +400,7 @@ Cmd_FilterAdd (void)
|
||||||
Cmd_Argv (3 + argv_index_add));
|
Cmd_Argv (3 + argv_index_add));
|
||||||
filter = FL_New (&from, &to);
|
filter = FL_New (&from, &to);
|
||||||
FL_Add (filter);
|
FL_Add (filter);
|
||||||
}
|
} else
|
||||||
|
|
||||||
else
|
|
||||||
Con_Printf ("%s already defined\n\n", Cmd_Argv (2 + argv_index_add));
|
Con_Printf ("%s already defined\n\n", Cmd_Argv (2 + argv_index_add));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,8 +411,8 @@ Cmd_FilterRemove (void)
|
||||||
netadr_t from;
|
netadr_t from;
|
||||||
|
|
||||||
if (Cmd_Argc () < 3 + argv_index_add) {
|
if (Cmd_Argc () < 3 + argv_index_add) {
|
||||||
Con_Printf
|
Con_Printf ("Invalid command parameters. Usage:\n"
|
||||||
("Invalid command parameters. Usage:\nfilter remove x.x.x.x:port\n\n");
|
"filter remove x.x.x.x:port\n\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NET_StringToAdr (Cmd_Argv (2 + argv_index_add), &from);
|
NET_StringToAdr (Cmd_Argv (2 + argv_index_add), &from);
|
||||||
|
@ -436,9 +420,7 @@ Cmd_FilterRemove (void)
|
||||||
Con_Printf ("Removed %s\n\n", Cmd_Argv (2 + argv_index_add));
|
Con_Printf ("Removed %s\n\n", Cmd_Argv (2 + argv_index_add));
|
||||||
FL_Remove (filter);
|
FL_Remove (filter);
|
||||||
free (filter);
|
free (filter);
|
||||||
}
|
} else
|
||||||
|
|
||||||
else
|
|
||||||
Con_Printf ("Cannot find %s\n\n", Cmd_Argv (2 + argv_index_add));
|
Con_Printf ("Cannot find %s\n\n", Cmd_Argv (2 + argv_index_add));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,24 +451,17 @@ Cmd_Filter_f (void)
|
||||||
argv_index_add = 0;
|
argv_index_add = 0;
|
||||||
if (!strcmp (Cmd_Argv (1), "add"))
|
if (!strcmp (Cmd_Argv (1), "add"))
|
||||||
Cmd_FilterAdd ();
|
Cmd_FilterAdd ();
|
||||||
|
|
||||||
else if (!strcmp (Cmd_Argv (1), "remove"))
|
else if (!strcmp (Cmd_Argv (1), "remove"))
|
||||||
Cmd_FilterRemove ();
|
Cmd_FilterRemove ();
|
||||||
|
|
||||||
else if (!strcmp (Cmd_Argv (1), "clear"))
|
else if (!strcmp (Cmd_Argv (1), "clear"))
|
||||||
Cmd_FilterClear ();
|
Cmd_FilterClear ();
|
||||||
|
|
||||||
else if (Cmd_Argc () == 3) {
|
else if (Cmd_Argc () == 3) {
|
||||||
argv_index_add = -1;
|
argv_index_add = -1;
|
||||||
Cmd_FilterAdd ();
|
Cmd_FilterAdd ();
|
||||||
}
|
} else if (Cmd_Argc () == 2) {
|
||||||
|
|
||||||
else if (Cmd_Argc () == 2) {
|
|
||||||
argv_index_add = -1;
|
argv_index_add = -1;
|
||||||
Cmd_FilterRemove ();
|
Cmd_FilterRemove ();
|
||||||
}
|
} else
|
||||||
|
|
||||||
else
|
|
||||||
Cmd_FilterList ();
|
Cmd_FilterList ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,11 +471,12 @@ SV_WriteFilterList (void)
|
||||||
FILE *filters;
|
FILE *filters;
|
||||||
|
|
||||||
if ((filters = fopen ("filters.ini", "wt"))) {
|
if ((filters = fopen ("filters.ini", "wt"))) {
|
||||||
|
filter_t *filter;
|
||||||
|
|
||||||
if (filter_list == NULL) {
|
if (filter_list == NULL) {
|
||||||
fclose (filters);
|
fclose (filters);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filter_t *filter;
|
|
||||||
|
|
||||||
for (filter = filter_list; filter; filter = filter->next) {
|
for (filter = filter_list; filter; filter = filter->next) {
|
||||||
fprintf (filters, "%s", NET_AdrToString (filter->from));
|
fprintf (filters, "%s", NET_AdrToString (filter->from));
|
||||||
|
@ -524,7 +500,6 @@ SV_Shutdown (void)
|
||||||
static void
|
static void
|
||||||
SV_TimeOut (void)
|
SV_TimeOut (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Remove listed severs that havnt sent a heartbeat for some time
|
// Remove listed severs that havnt sent a heartbeat for some time
|
||||||
double time = Sys_DoubleTime ();
|
double time = Sys_DoubleTime ();
|
||||||
server_t *sv;
|
server_t *sv;
|
||||||
|
@ -532,6 +507,7 @@ SV_TimeOut (void)
|
||||||
|
|
||||||
if (sv_list == NULL)
|
if (sv_list == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (sv = sv_list; sv;) {
|
for (sv = sv_list; sv;) {
|
||||||
if (sv->timeout + SV_TIMEOUT < time) {
|
if (sv->timeout + SV_TIMEOUT < time) {
|
||||||
next = sv->next;
|
next = sv->next;
|
||||||
|
@ -539,9 +515,7 @@ SV_TimeOut (void)
|
||||||
SVL_Remove (sv);
|
SVL_Remove (sv);
|
||||||
free (sv);
|
free (sv);
|
||||||
sv = next;
|
sv = next;
|
||||||
}
|
} else
|
||||||
|
|
||||||
else
|
|
||||||
sv = sv->next;
|
sv = sv->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue