finalized api by adding limited interception

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401432
This commit is contained in:
David Anderson 2007-09-14 03:01:14 +00:00
parent c230444274
commit bb0678c1ac

View File

@ -54,7 +54,7 @@ public:
{
g_pOnBanClient = g_Forwards.CreateForward(
"OnBanClient",
ET_Ignore,
ET_Event,
7,
NULL,
Param_Cell,
@ -66,7 +66,7 @@ public:
Param_Cell);
g_pOnBanIdentity = g_Forwards.CreateForward(
"OnBanIdentity",
ET_Ignore,
ET_Event,
6,
NULL,
Param_String,
@ -77,7 +77,7 @@ public:
Param_Cell);
g_pOnRemoveBan = g_Forwards.CreateForward(
"OnRemoveBan",
ET_Ignore,
ET_Event,
4,
NULL,
Param_String,
@ -122,6 +122,7 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
strncopy(identity, r_identity, sizeof(identity));
UTIL_ReplaceAll(identity, sizeof(identity), ";", "");
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnBanIdentity->GetFunctionCount() > 0)
{
g_pOnBanIdentity->PushString(identity);
@ -130,9 +131,11 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
g_pOnBanIdentity->PushString(ban_reason);
g_pOnBanIdentity->PushString(ban_cmd);
g_pOnBanIdentity->PushCell(ban_source);
g_pOnBanIdentity->Execute(NULL);
g_pOnBanIdentity->Execute(&handled);
}
if (!handled)
{
bool write_ban = ((ban_flags & BANFLAG_NOWRITE) != BANFLAG_NOWRITE);
char command[256];
@ -170,6 +173,7 @@ static cell_t BanIdentity(IPluginContext *pContext, const cell_t *params)
{
return 0;
}
}
return 1;
}
@ -195,17 +199,20 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
strncopy(identity, r_identity, sizeof(identity));
UTIL_ReplaceAll(identity, sizeof(identity), ";", "");
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnRemoveBan->GetFunctionCount() > 0)
{
g_pOnRemoveBan->PushString(identity);
g_pOnRemoveBan->PushCell(ban_flags);
g_pOnRemoveBan->PushString(ban_cmd);
g_pOnRemoveBan->PushCell(ban_source);
g_pOnRemoveBan->Execute(NULL);
g_pOnRemoveBan->Execute(&handled);
}
char command[256];
if (ban_by_ip)
{
if (!handled)
{
UTIL_Format(
command,
@ -215,7 +222,10 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
engine->ServerCommand(command);
engine->ServerCommand("writeip\n");
}
}
else if (!g_HL2.IsLANServer())
{
if (!handled)
{
UTIL_Format(
command,
@ -225,6 +235,7 @@ static cell_t RemoveBan(IPluginContext *pContext, const cell_t *params)
engine->ServerCommand(command);
engine->ServerCommand("writeid\n");
}
}
else
{
return 0;
@ -293,6 +304,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("No valid ban method flags specified");
}
cell_t handled = 0;
if (ban_cmd[0] != '\0' && g_pOnBanClient->GetFunctionCount() > 0)
{
g_pOnBanClient->PushCell(client);
@ -302,7 +314,7 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
g_pOnBanClient->PushString(kick_message);
g_pOnBanClient->PushString(ban_cmd);
g_pOnBanClient->PushCell(ban_source);
g_pOnBanClient->Execute(NULL);
g_pOnBanClient->Execute(&handled);
}
/* Sanitize the kick message */
@ -311,6 +323,8 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
kick_message = "Kicked";
}
if (!handled)
{
if ((ban_flags & BANFLAG_IP) == BANFLAG_IP)
{
/* Get the IP address and strip the port */
@ -367,6 +381,11 @@ static cell_t BanClient(IPluginContext *pContext, const cell_t *params)
engine->ServerCommand("writeid\n");
}
}
}
else if ((ban_flags & BANFLAG_NOKICK) != BANFLAG_NOKICK)
{
pClient->Disconnect("%s", kick_message);
}
return 1;