Added InactivateClient and ReconnectClient natives to SDKTools (bug 4931, r=fyren).

This commit is contained in:
Brian Simon 2011-07-06 18:11:02 -04:00
parent bb48a16466
commit 838e8c7b35
8 changed files with 201 additions and 2 deletions

View File

@ -38,6 +38,7 @@ for i in SM.sdkInfo:
'vnatives.cpp',
'voice.cpp',
'vsound.cpp',
'clientnatives.cpp',
'hooks.cpp',
'gamerulesnatives.cpp',
'vstringtable.cpp',

View File

@ -22,7 +22,8 @@ USEMETA = true
OBJECTS = sdk/smsdk_ext.cpp extension.cpp vdecoder.cpp vcallbuilder.cpp vcaller.cpp \
vnatives.cpp vsound.cpp tenatives.cpp trnatives.cpp tempents.cpp vstringtable.cpp \
vhelpers.cpp vglobals.cpp voice.cpp inputnatives.cpp teamnatives.cpp output.cpp \
outputnatives.cpp hooks.cpp gamerulesnatives.cpp CDetour/detours.cpp asm/asm.c
outputnatives.cpp hooks.cpp gamerulesnatives.cpp CDetour/detours.cpp asm/asm.c \
clientnatives.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###

View File

@ -0,0 +1,97 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod SDKTools Extension
* Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include "clientnatives.h"
#include "iserver.h"
#include "iclient.h"
static cell_t smn_InactivateClient(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
if (player == NULL)
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
}
if (!iserver)
{
pContext->ThrowNativeError("IServer is null");
}
IClient* pClient = iserver->GetClient(params[1] - 1);
if (pClient)
{
pClient->Inactivate();
}
else
{
pContext->ThrowNativeError("Could not get IClient for client %d", params[1]);
}
return 1;
}
static cell_t smn_ReconnectClient(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
if (player == NULL)
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
}
if (!iserver)
{
pContext->ThrowNativeError("IServer is null");
}
IClient* pClient = iserver->GetClient(params[1] - 1);
if (pClient)
{
pClient->Reconnect();
}
else
{
pContext->ThrowNativeError("Could not get IClient for client %d", params[1]);
}
return 1;
}
sp_nativeinfo_t g_ClientNatives[] =
{
{ "InactivateClient", smn_InactivateClient },
{ "ReconnectClient", smn_ReconnectClient },
{ NULL, NULL },
};

View File

@ -0,0 +1,37 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod SDKTools Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SDKTOOLS_CLIENTNATIVES_H_
#define _INCLUDE_SDKTOOLS_CLIENTNATIVES_H_
static cell_t smn_InactivateClient(IPluginContext *pContext, const cell_t *params);
static cell_t smn_ReconnectClient(IPluginContext *pContext, const cell_t *params);
#endif

View File

@ -42,7 +42,7 @@
#include "hooks.h"
#include "gamerulesnatives.h"
#include <ISDKTools.h>
#include "clientnatives.h"
/**
* @file extension.cpp
* @brief Implements SDK Tools extension code.
@ -86,6 +86,7 @@ extern sp_nativeinfo_t g_VoiceNatives[];
extern sp_nativeinfo_t g_EntInputNatives[];
extern sp_nativeinfo_t g_TeamNatives[];
extern sp_nativeinfo_t g_GameRulesNatives[];
extern sp_nativeinfo_t g_ClientNatives[];
static void InitSDKToolsAPI();
@ -110,6 +111,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
sharesys->AddNatives(myself, g_TeamNatives);
sharesys->AddNatives(myself, g_EntOutputNatives);
sharesys->AddNatives(myself, g_GameRulesNatives);
sharesys->AddNatives(myself, g_ClientNatives);
SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers);

View File

@ -1518,6 +1518,10 @@
RelativePath="..\asm\asm.c"
>
</File>
<File
RelativePath="..\clientnatives.cpp"
>
</File>
<File
RelativePath="..\CDetour\detours.cpp"
>
@ -1604,6 +1608,10 @@
RelativePath="..\CellRecipientFilter.h"
>
</File>
<File
RelativePath="..\clientnatives.h"
>
</File>
<File
RelativePath="..\extension.h"
>

View File

@ -50,6 +50,7 @@
#include <sdktools_entoutput>
#include <sdktools_hooks>
#include <sdktools_gamerules>
#include <sdktools_client>
enum SDKCallType
{

View File

@ -0,0 +1,52 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _sdktools_client_included
#endinput
#endif
#define _sdktools_client_included
/**
* Sets the client to an inactive state waiting for a new map
*
* @param client The client index
* @noreturn
*/
native InactivateClient(client);
/**
* Reconnect a client without dropping the netchannel
*
* @param client The client index
* @noreturn
*/
native ReconnectClient(client);