[nat] Remove the datagram test commands

They seem to be related to the server list protocol, probably from its
development, but no longer needed.
This commit is contained in:
Bill Currie 2021-04-04 18:31:57 +09:00
parent 5f682ff1df
commit a630c95eb6

View file

@ -516,288 +516,6 @@ NET_Stats_f (void)
}
}
static qboolean testInProgress = false;
static int testPollCount;
static int testDriver;
static int testSocket;
static void Test_Poll (void *);
PollProcedure testPollProcedure = { NULL, 0.0, Test_Poll };
static void
Test_Poll (void *unused)
{
netadr_t clientaddr;
int control;
int len;
char name[32]; //FIXME: overflow
char address[64]; //FIXME: overflow
int colors;
int frags;
int connectTime;
byte playerNumber;
net_landriverlevel = testDriver;
while (1) {
len = dfunc.Read (testSocket, net_message->message->data,
net_message->message->maxsize, &clientaddr);
if (len < (int) sizeof (int)) {
break;
}
net_message->message->cursize = len;
MSG_BeginReading (net_message);
control = MSG_ReadLongBE (net_message);
if (control == -1) {
break;
}
if ((control & (~NETFLAG_LENGTH_MASK)) != (int) NETFLAG_CTL) {
break;
}
if ((control & NETFLAG_LENGTH_MASK) != len) {
break;
}
if (MSG_ReadByte (net_message) != CCREP_PLAYER_INFO) {
Sys_Error ("Unexpected repsonse to Player Info request");
}
playerNumber = MSG_ReadByte (net_message);
strcpy (name, MSG_ReadString (net_message));
colors = MSG_ReadLong (net_message);
frags = MSG_ReadLong (net_message);
connectTime = MSG_ReadLong (net_message);
strcpy (address, MSG_ReadString (net_message));
Sys_Printf ("%d, %s\n frags:%3i colors:%u %u time:%u\n %s\n",
playerNumber, name, frags, colors >> 4, colors & 0x0f,
connectTime / 60, address);
}
testPollCount--;
if (testPollCount) {
SchedulePollProcedure (&testPollProcedure, 0.1);
} else {
dfunc.CloseSocket (testSocket);
testInProgress = false;
}
}
static void
Test_f (void)
{
const char *host;
int n;
int max = MAX_SCOREBOARD;
netadr_t sendaddr;
if (testInProgress) {
return;
}
host = Cmd_Argv (1);
if (host && hostCacheCount) {
for (n = 0; n < hostCacheCount; n++)
if (strcasecmp (host, hostcache[n].name) == 0) {
if (hostcache[n].driver != myDriverLevel) {
continue;
}
net_landriverlevel = hostcache[n].ldriver;
max = hostcache[n].maxusers;
memcpy (&sendaddr, &hostcache[n].addr, sizeof (netadr_t));
break;
}
if (n < hostCacheCount) {
goto JustDoIt;
}
}
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers;
net_landriverlevel++) {
if (!net_landrivers[net_landriverlevel].initialized) {
continue;
}
// see if we can resolve the host name
if (dfunc.GetAddrFromName (host, &sendaddr) != -1) {
break;
}
}
if (net_landriverlevel == net_numlandrivers) {
return;
}
JustDoIt:
testSocket = dfunc.OpenSocket (0);
if (testSocket == -1) {
return;
}
testInProgress = true;
testPollCount = 20;
testDriver = net_landriverlevel;
for (n = 0; n < max; n++) {
SZ_Clear (net_message->message);
// save space for the header, filled in later
MSG_WriteLong (net_message->message, 0);
MSG_WriteByte (net_message->message, CCREQ_PLAYER_INFO);
MSG_WriteByte (net_message->message, n);
MSG_PokeLongBE (net_message->message, 0,
NETFLAG_CTL | net_message->message->cursize);
dfunc.Write (testSocket, net_message->message->data,
net_message->message->cursize, &sendaddr);
}
SZ_Clear (net_message->message);
SchedulePollProcedure (&testPollProcedure, 0.1);
}
static qboolean test2InProgress = false;
static int test2Driver;
static int test2Socket;
static void Test2_Poll (void *);
PollProcedure test2PollProcedure = { NULL, 0.0, Test2_Poll };
static void
Test2_Poll (void *unused)
{
netadr_t clientaddr;
int control;
int len;
char name[256]; //FIXME: overflow
char value[256]; //FIXME: overflow
net_landriverlevel = test2Driver;
name[0] = 0;
len = dfunc.Read (test2Socket, net_message->message->data,
net_message->message->maxsize, &clientaddr);
if (len < (int) sizeof (int)) {
goto Reschedule;
}
net_message->message->cursize = len;
MSG_BeginReading (net_message);
control = MSG_ReadLongBE (net_message);
if (control == -1) {
goto Error;
}
if ((control & (~NETFLAG_LENGTH_MASK)) != (int) NETFLAG_CTL) {
goto Error;
}
if ((control & NETFLAG_LENGTH_MASK) != len) {
goto Error;
}
if (MSG_ReadByte (net_message) != CCREP_RULE_INFO) {
goto Error;
}
strcpy (name, MSG_ReadString (net_message));
if (name[0] == 0) {
goto Done;
}
strcpy (value, MSG_ReadString (net_message));
Sys_Printf ("%-16.16s %-16.16s\n", name, value);
SZ_Clear (net_message->message);
// save space for the header, filled in later
MSG_WriteLong (net_message->message, 0);
MSG_WriteByte (net_message->message, CCREQ_RULE_INFO);
MSG_WriteString (net_message->message, name);
MSG_PokeLongBE (net_message->message, 0,
NETFLAG_CTL | net_message->message->cursize);
dfunc.Write (test2Socket, net_message->message->data,
net_message->message->cursize, &clientaddr);
SZ_Clear (net_message->message);
Reschedule:
SchedulePollProcedure (&test2PollProcedure, 0.05);
return;
Error:
Sys_Printf ("Unexpected repsonse to Rule Info request\n");
Done:
dfunc.CloseSocket (test2Socket);
test2InProgress = false;
return;
}
static void
Test2_f (void)
{
const char *host;
int n;
netadr_t sendaddr;
if (test2InProgress) {
return;
}
host = Cmd_Argv (1);
if (host && hostCacheCount) {
for (n = 0; n < hostCacheCount; n++) {
if (strcasecmp (host, hostcache[n].name) == 0) {
if (hostcache[n].driver != myDriverLevel) {
continue;
}
net_landriverlevel = hostcache[n].ldriver;
memcpy (&sendaddr, &hostcache[n].addr, sizeof (netadr_t));
break;
}
}
if (n < hostCacheCount) {
goto JustDoIt;
}
}
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers;
net_landriverlevel++) {
if (!net_landrivers[net_landriverlevel].initialized) {
continue;
}
// see if we can resolve the host name
if (dfunc.GetAddrFromName (host, &sendaddr) != -1) {
break;
}
}
if (net_landriverlevel == net_numlandrivers) {
return;
}
JustDoIt:
test2Socket = dfunc.OpenSocket (0);
if (test2Socket == -1) {
return;
}
test2InProgress = true;
test2Driver = net_landriverlevel;
SZ_Clear (net_message->message);
// save space for the header, filled in later
MSG_WriteLong (net_message->message, 0);
MSG_WriteByte (net_message->message, CCREQ_RULE_INFO);
MSG_WriteString (net_message->message, "");
MSG_PokeLongBE (net_message->message, 0,
NETFLAG_CTL | net_message->message->cursize);
dfunc.Write (test2Socket, net_message->message->data,
net_message->message->cursize, &sendaddr);
SZ_Clear (net_message->message);
SchedulePollProcedure (&test2PollProcedure, 0.05);
}
int
Datagram_Init (void)
{
@ -823,8 +541,6 @@ Datagram_Init (void)
#ifdef BAN_TEST
Cmd_AddCommand ("ban", NET_Ban_f, "No Description");
#endif
Cmd_AddCommand ("test", Test_f, "No Description");
Cmd_AddCommand ("test2", Test2_f, "No Description");
return 0;
}