Added InactivateClient and ReconnectClient natives to SDKTools (bug 4931, r=fyren).
Added InactivateClient and ReconnectClient natives to SDKTools (
bug 4931, r=fyren).
1.1 --- a/extensions/sdktools/AMBuilder Wed Jul 06 17:56:40 2011 -0400
1.2 +++ b/extensions/sdktools/AMBuilder Wed Jul 06 18:11:02 2011 -0400
1.3 @@ -38,6 +38,7 @@
1.4 'vnatives.cpp',
1.5 'voice.cpp',
1.6 'vsound.cpp',
1.7 + 'clientnatives.cpp',
1.8 'hooks.cpp',
1.9 'gamerulesnatives.cpp',
1.10 'vstringtable.cpp',
2.1 --- a/extensions/sdktools/Makefile Wed Jul 06 17:56:40 2011 -0400
2.2 +++ b/extensions/sdktools/Makefile Wed Jul 06 18:11:02 2011 -0400
2.3 @@ -22,7 +22,8 @@
2.4 OBJECTS = sdk/smsdk_ext.cpp extension.cpp vdecoder.cpp vcallbuilder.cpp vcaller.cpp \
2.5 vnatives.cpp vsound.cpp tenatives.cpp trnatives.cpp tempents.cpp vstringtable.cpp \
2.6 vhelpers.cpp vglobals.cpp voice.cpp inputnatives.cpp teamnatives.cpp output.cpp \
2.7 - outputnatives.cpp hooks.cpp gamerulesnatives.cpp CDetour/detours.cpp asm/asm.c
2.8 + outputnatives.cpp hooks.cpp gamerulesnatives.cpp CDetour/detours.cpp asm/asm.c \
2.9 + clientnatives.cpp
2.10
2.11 ##############################################
2.12 ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/extensions/sdktools/clientnatives.cpp Wed Jul 06 18:11:02 2011 -0400
3.3 @@ -0,0 +1,97 @@
3.4 +/**
3.5 + * vim: set ts=4 :
3.6 + * =============================================================================
3.7 + * SourceMod SDKTools Extension
3.8 + * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
3.9 + * =============================================================================
3.10 + *
3.11 + * This program is free software; you can redistribute it and/or modify it under
3.12 + * the terms of the GNU General Public License, version 3.0, as published by the
3.13 + * Free Software Foundation.
3.14 + *
3.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
3.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3.18 + * details.
3.19 + *
3.20 + * You should have received a copy of the GNU General Public License along with
3.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
3.22 + *
3.23 + * As a special exception, AlliedModders LLC gives you permission to link the
3.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
3.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
3.26 + * by the Valve Corporation. You must obey the GNU General Public License in
3.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
3.28 + * this exception to all derivative works. AlliedModders LLC defines further
3.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
3.30 + * or <http://www.sourcemod.net/license.php>.
3.31 + *
3.32 + * Version: $Id$
3.33 + */
3.34 +
3.35 +
3.36 +#include "extension.h"
3.37 +#include "clientnatives.h"
3.38 +#include "iserver.h"
3.39 +#include "iclient.h"
3.40 +
3.41 +static cell_t smn_InactivateClient(IPluginContext *pContext, const cell_t *params)
3.42 +{
3.43 + IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
3.44 +
3.45 + if (player == NULL)
3.46 + {
3.47 + return pContext->ThrowNativeError("Invalid client index %d", params[1]);
3.48 + }
3.49 +
3.50 +
3.51 + if (!iserver)
3.52 + {
3.53 + pContext->ThrowNativeError("IServer is null");
3.54 + }
3.55 +
3.56 + IClient* pClient = iserver->GetClient(params[1] - 1);
3.57 + if (pClient)
3.58 + {
3.59 + pClient->Inactivate();
3.60 + }
3.61 + else
3.62 + {
3.63 + pContext->ThrowNativeError("Could not get IClient for client %d", params[1]);
3.64 + }
3.65 +
3.66 + return 1;
3.67 +}
3.68 +
3.69 +static cell_t smn_ReconnectClient(IPluginContext *pContext, const cell_t *params)
3.70 +{
3.71 + IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
3.72 +
3.73 + if (player == NULL)
3.74 + {
3.75 + return pContext->ThrowNativeError("Invalid client index %d", params[1]);
3.76 + }
3.77 +
3.78 + if (!iserver)
3.79 + {
3.80 + pContext->ThrowNativeError("IServer is null");
3.81 + }
3.82 +
3.83 + IClient* pClient = iserver->GetClient(params[1] - 1);
3.84 + if (pClient)
3.85 + {
3.86 + pClient->Reconnect();
3.87 + }
3.88 + else
3.89 + {
3.90 + pContext->ThrowNativeError("Could not get IClient for client %d", params[1]);
3.91 + }
3.92 + return 1;
3.93 +}
3.94 +
3.95 +sp_nativeinfo_t g_ClientNatives[] =
3.96 +{
3.97 + { "InactivateClient", smn_InactivateClient },
3.98 + { "ReconnectClient", smn_ReconnectClient },
3.99 + { NULL, NULL },
3.100 +};
3.101 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/extensions/sdktools/clientnatives.h Wed Jul 06 18:11:02 2011 -0400
4.3 @@ -0,0 +1,37 @@
4.4 +/**
4.5 + * vim: set ts=4 :
4.6 + * =============================================================================
4.7 + * SourceMod SDKTools Extension
4.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
4.9 + * =============================================================================
4.10 + *
4.11 + * This program is free software; you can redistribute it and/or modify it under
4.12 + * the terms of the GNU General Public License, version 3.0, as published by the
4.13 + * Free Software Foundation.
4.14 + *
4.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
4.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4.18 + * details.
4.19 + *
4.20 + * You should have received a copy of the GNU General Public License along with
4.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
4.22 + *
4.23 + * As a special exception, AlliedModders LLC gives you permission to link the
4.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
4.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
4.26 + * by the Valve Corporation. You must obey the GNU General Public License in
4.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
4.28 + * this exception to all derivative works. AlliedModders LLC defines further
4.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
4.30 + * or <http://www.sourcemod.net/license.php>.
4.31 + *
4.32 + * Version: $Id$
4.33 + */
4.34 +#ifndef _INCLUDE_SDKTOOLS_CLIENTNATIVES_H_
4.35 +#define _INCLUDE_SDKTOOLS_CLIENTNATIVES_H_
4.36 +
4.37 +static cell_t smn_InactivateClient(IPluginContext *pContext, const cell_t *params);
4.38 +static cell_t smn_ReconnectClient(IPluginContext *pContext, const cell_t *params);
4.39 +
4.40 +#endif
4.41 \ No newline at end of file
5.1 --- a/extensions/sdktools/extension.cpp Wed Jul 06 17:56:40 2011 -0400
5.2 +++ b/extensions/sdktools/extension.cpp Wed Jul 06 18:11:02 2011 -0400
5.3 @@ -42,7 +42,7 @@
5.4 #include "hooks.h"
5.5 #include "gamerulesnatives.h"
5.6 #include <ISDKTools.h>
5.7 -
5.8 +#include "clientnatives.h"
5.9 /**
5.10 * @file extension.cpp
5.11 * @brief Implements SDK Tools extension code.
5.12 @@ -86,6 +86,7 @@
5.13 extern sp_nativeinfo_t g_EntInputNatives[];
5.14 extern sp_nativeinfo_t g_TeamNatives[];
5.15 extern sp_nativeinfo_t g_GameRulesNatives[];
5.16 +extern sp_nativeinfo_t g_ClientNatives[];
5.17
5.18 static void InitSDKToolsAPI();
5.19
5.20 @@ -110,6 +111,7 @@
5.21 sharesys->AddNatives(myself, g_TeamNatives);
5.22 sharesys->AddNatives(myself, g_EntOutputNatives);
5.23 sharesys->AddNatives(myself, g_GameRulesNatives);
5.24 + sharesys->AddNatives(myself, g_ClientNatives);
5.25
5.26 SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers);
5.27
6.1 --- a/extensions/sdktools/msvc9/sdktools.vcproj Wed Jul 06 17:56:40 2011 -0400
6.2 +++ b/extensions/sdktools/msvc9/sdktools.vcproj Wed Jul 06 18:11:02 2011 -0400
6.3 @@ -1519,6 +1519,10 @@
6.4 >
6.5 </File>
6.6 <File
6.7 + RelativePath="..\clientnatives.cpp"
6.8 + >
6.9 + </File>
6.10 + <File
6.11 RelativePath="..\CDetour\detours.cpp"
6.12 >
6.13 </File>
6.14 @@ -1605,6 +1609,10 @@
6.15 >
6.16 </File>
6.17 <File
6.18 + RelativePath="..\clientnatives.h"
6.19 + >
6.20 + </File>
6.21 + <File
6.22 RelativePath="..\extension.h"
6.23 >
6.24 </File>
7.1 --- a/plugins/include/sdktools.inc Wed Jul 06 17:56:40 2011 -0400
7.2 +++ b/plugins/include/sdktools.inc Wed Jul 06 18:11:02 2011 -0400
7.3 @@ -50,6 +50,7 @@
7.4 #include <sdktools_entoutput>
7.5 #include <sdktools_hooks>
7.6 #include <sdktools_gamerules>
7.7 +#include <sdktools_client>
7.8
7.9 enum SDKCallType
7.10 {
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/plugins/include/sdktools_client.inc Wed Jul 06 18:11:02 2011 -0400
8.3 @@ -0,0 +1,52 @@
8.4 +/**
8.5 + * vim: set ts=4 :
8.6 + * =============================================================================
8.7 + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8.8 + * =============================================================================
8.9 + *
8.10 + * This file is part of the SourceMod/SourcePawn SDK.
8.11 + *
8.12 + * This program is free software; you can redistribute it and/or modify it under
8.13 + * the terms of the GNU General Public License, version 3.0, as published by the
8.14 + * Free Software Foundation.
8.15 + *
8.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
8.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8.18 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8.19 + * details.
8.20 + *
8.21 + * You should have received a copy of the GNU General Public License along with
8.22 + * this program. If not, see <http://www.gnu.org/licenses/>.
8.23 + *
8.24 + * As a special exception, AlliedModders LLC gives you permission to link the
8.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
8.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
8.27 + * by the Valve Corporation. You must obey the GNU General Public License in
8.28 + * all respects for all other code used. Additionally, AlliedModders LLC grants
8.29 + * this exception to all derivative works. AlliedModders LLC defines further
8.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
8.31 + * or <http://www.sourcemod.net/license.php>.
8.32 + *
8.33 + * Version: $Id$
8.34 + */
8.35 +
8.36 +#if defined _sdktools_client_included
8.37 + #endinput
8.38 +#endif
8.39 +#define _sdktools_client_included
8.40 +
8.41 +/**
8.42 + * Sets the client to an inactive state waiting for a new map
8.43 + *
8.44 + * @param client The client index
8.45 + * @noreturn
8.46 + */
8.47 +native InactivateClient(client);
8.48 +
8.49 +/**
8.50 + * Reconnect a client without dropping the netchannel
8.51 + *
8.52 + * @param client The client index
8.53 + * @noreturn
8.54 + */
8.55 +native ReconnectClient(client);