mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-23 16:10:09 +00:00
net: convert NQ "ban" command to server side
This is actually broken for now (the local client/admin won't have privileges to run the command), but I have a plan... Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
6702163b81
commit
160408c7cb
2
NQ/net.h
2
NQ/net.h
@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define NET_H
|
||||
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
|
||||
/* net.h -- quake's interface to the networking layer */
|
||||
|
||||
@ -329,5 +330,6 @@ extern qboolean slistSilent;
|
||||
extern qboolean slistLocal;
|
||||
|
||||
void NET_Slist_f(void);
|
||||
void NET_Ban_f(client_t *client);
|
||||
|
||||
#endif /* NET_H */
|
||||
|
@ -71,36 +71,23 @@ StrAddr(netadr_t *addr)
|
||||
static netadr_t banAddr = { .ip.l = INADDR_ANY };
|
||||
static netadr_t banMask = { .ip.l = INADDR_NONE };
|
||||
|
||||
static void
|
||||
NET_Ban_f(void)
|
||||
void
|
||||
NET_Ban_f(client_t *client)
|
||||
{
|
||||
char addrStr[32];
|
||||
char maskStr[32];
|
||||
|
||||
if (cmd_source == src_command) {
|
||||
if (!sv.active) {
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
}
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
|
||||
switch (Cmd_Argc()) {
|
||||
case 1:
|
||||
if (banAddr.ip.l != INADDR_ANY) {
|
||||
strcpy(addrStr, NET_AdrToString(&banAddr));
|
||||
strcpy(maskStr, NET_AdrToString(&banMask));
|
||||
if (cmd_source == src_command)
|
||||
Con_Printf("Banning %s [%s]\n", addrStr, maskStr);
|
||||
else
|
||||
SV_ClientPrintf(host_client, "Banning %s [%s]\n", addrStr, maskStr);
|
||||
SV_ClientPrintf(client, "Banning %s [%s]\n", addrStr, maskStr);
|
||||
} else {
|
||||
if (cmd_source == src_command)
|
||||
Con_Printf("Banning not active\n");
|
||||
else
|
||||
SV_ClientPrintf(host_client, "Banning not active\n");
|
||||
SV_ClientPrintf(client, "Banning not active\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -118,10 +105,7 @@ NET_Ban_f(void)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (cmd_source == src_command)
|
||||
Con_Printf("BAN ip_address [mask]\n");
|
||||
else
|
||||
SV_ClientPrintf(host_client, "BAN ip_address [mask]\n");
|
||||
SV_ClientPrintf(client, "BAN ip_address [mask]\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -722,7 +706,7 @@ Datagram_Init(void)
|
||||
if (num_inited == 0)
|
||||
return -1;
|
||||
|
||||
Cmd_AddCommand("ban", NET_Ban_f);
|
||||
Cmd_AddCommand("ban", NULL);
|
||||
Cmd_AddCommand("test", Test_f);
|
||||
Cmd_AddCommand("test2", Test2_f);
|
||||
|
||||
|
21
NQ/sv_user.c
21
NQ/sv_user.c
@ -1158,15 +1158,14 @@ static client_command_t client_commands[] = {
|
||||
{ "kill", SV_Kill_f },
|
||||
{ "pause", SV_Pause_f },
|
||||
{ "kick", SV_Kick_f },
|
||||
{ "ban", NET_Ban_f },
|
||||
{ "prespawn", SV_PreSpawn_f },
|
||||
{ "spawn", SV_Spawn_f },
|
||||
{ "begin", SV_Begin_f },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
/* FIXME - Won't need to return result after all commands have been
|
||||
properly converted. Can enable error message then too. */
|
||||
static qboolean
|
||||
static void
|
||||
SV_ExecuteClientCommand(const char *command_string, client_t *client)
|
||||
{
|
||||
client_command_t *command;
|
||||
@ -1176,11 +1175,9 @@ SV_ExecuteClientCommand(const char *command_string, client_t *client)
|
||||
for (command = client_commands; command->name; command++) {
|
||||
if (!strcmp(Cmd_Argv(0), command->name)) {
|
||||
command->func(client);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Con_Printf("Bad client command: %s\n", Cmd_Argv(0));
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1195,7 +1192,6 @@ SV_ReadClientMessage(client_t *client)
|
||||
{
|
||||
const char *message;
|
||||
int ret, cmd;
|
||||
qboolean found;
|
||||
|
||||
do {
|
||||
nextmsg:
|
||||
@ -1234,16 +1230,7 @@ SV_ReadClientMessage(client_t *client)
|
||||
|
||||
case clc_stringcmd:
|
||||
message = MSG_ReadString();
|
||||
found = SV_ExecuteClientCommand(message, client);
|
||||
if (found)
|
||||
break;
|
||||
|
||||
if (!strncasecmp(message, "ban", 3)) {
|
||||
Cmd_ExecuteString(message, src_client);
|
||||
} else {
|
||||
Con_DPrintf("%s tried to %s\n", client->name, message);
|
||||
ret = 0;
|
||||
}
|
||||
SV_ExecuteClientCommand(message, client);
|
||||
break;
|
||||
|
||||
case clc_disconnect:
|
||||
|
Loading…
Reference in New Issue
Block a user