implemented wrapper around BAT's AdminInterface
authorDavid Anderson <dvander@alliedmods.net>
Tue Feb 27 08:21:01 2007 +0000 (2007-02-27)
changeset 5424a7c23cfa070
parent 541 43e600fc2aa7
child 543 191d60152a7b
implemented wrapper around BAT's AdminInterface
extensions/batsupport/BATInterface.h
extensions/batsupport/Makefile
extensions/batsupport/extension.cpp
extensions/batsupport/extension.h
extensions/batsupport/msvc8/batsupport.sln
extensions/batsupport/msvc8/batsupport.vcproj
extensions/batsupport/smsdk_config.h
extensions/batsupport/smsdk_ext.cpp
extensions/batsupport/smsdk_ext.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/batsupport/BATInterface.h	Tue Feb 27 08:21:01 2007 +0000
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* ======== Basic Admin tool ========
     1.5 +* Copyright (C) 2004-2006 Erling K. S�terdal
     1.6 +* No warranties of any kind
     1.7 +*
     1.8 +* License: zlib/libpng
     1.9 +*
    1.10 +* Author(s): Erling K. S�terdal ( EKS )
    1.11 +* Credits:
    1.12 +*	Menu code based on code from CSDM ( http://www.tcwonline.org/~dvander/cssdm ) Created by BAILOPAN
    1.13 +*	Helping on misc errors/functions: BAILOPAN,LDuke,sslice,devicenull,PMOnoTo,cybermind ( most who idle in #sourcemod on GameSurge realy )
    1.14 +* ============================ */
    1.15 +
    1.16 +#ifndef _INCLUDE_BATINTERFACE
    1.17 +#define _INCLUDE_BATINTERFACE
    1.18 +#include "ismmplugin.h"
    1.19 +
    1.20 +#define ADMININTERFACE_VERSION 0
    1.21 +#define ADMININTERFACE_MAXACCESSLENGTHTEXT 50		// This is the maximum length of a "flag" access text.
    1.22 +
    1.23 +//#include "BATMenu.h"
    1.24 +
    1.25 +//extern menuId g_AdminMenu;
    1.26 +class AdminInterfaceListner
    1.27 +{
    1.28 +public:
    1.29 +	virtual void OnAdminInterfaceUnload()=0;
    1.30 +	virtual void Client_Authorized(int id)=0;
    1.31 +};
    1.32 +
    1.33 +class AdminInterface
    1.34 +{
    1.35 +public:
    1.36 +	virtual bool RegisterFlag(const char *Class,const char *Flag,const char *Description) = 0; // Registers a new admin access
    1.37 +	virtual bool IsClient(int id) = 0;				// returns false if client is bot, or NOT connected
    1.38 +	virtual bool HasFlag(int id,const char *Flag) = 0;	// returns true if the player has this access flag, lower case only
    1.39 +	virtual int GetInterfaceVersion() = 0 ;		// Returns the interface version of the admin mod
    1.40 +	virtual const char* GetModName() = 0;			// Returns the name of the current admin mod
    1.41 +	virtual void AddEventListner(AdminInterfaceListner *ptr) = 0; // You should ALLWAYS set this, so you know when the "server"  plugin gets unloaded
    1.42 +	virtual void RemoveListner(AdminInterfaceListner *ptr) = 0;   // You MUST CALL this function in your plugin unloads function, or the admin plugin will crash on next client connect.
    1.43 +};
    1.44 +
    1.45 +class BATAdminInterface : public AdminInterface
    1.46 +{
    1.47 +public:
    1.48 +	bool RegisterFlag(const char *Class,const char *Flag,const char *Description); // Max 1 admin access at the time, returns true if done successfully
    1.49 +	bool IsClient(int id);		// returns false if client is bot, or NOT connected
    1.50 +	bool HasFlag(int id,const char *Flag);	// returns true if the player has this access flag
    1.51 +	int GetInterfaceVersion() { return ADMININTERFACE_VERSION; } // Returns the interface version of the admin mod
    1.52 +	const char* GetModName() { return "BAT"; }		// Returns the name of the current admin mod
    1.53 +	void AddEventListner(AdminInterfaceListner *ptr); // You should ALLWAYS set this, so you know when the "server"  plugin gets unloaded
    1.54 +	void RemoveListner(AdminInterfaceListner *ptr);
    1.55 +private:
    1.56 +	char GetFlagFromInt(int CharIndex);
    1.57 +	bool CustomAccessExistence(const char *Flag);
    1.58 +};
    1.59 +class MyListener : public IMetamodListener
    1.60 +{
    1.61 +public:
    1.62 +	virtual void *OnMetamodQuery(const char *iface, int *ret);
    1.63 +};
    1.64 +#endif
    1.65 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/extensions/batsupport/Makefile	Tue Feb 27 08:21:01 2007 +0000
     2.3 @@ -0,0 +1,91 @@
     2.4 +#(C)2004-2006 SourceMM Development Team
     2.5 +# Makefile written by David "BAILOPAN" Anderson
     2.6 +
     2.7 +SMSDK = ../..
     2.8 +SRCDS = ~/srcds
     2.9 +SOURCEMM = ../../../../sourcemm
    2.10 +
    2.11 +#####################################
    2.12 +### EDIT BELOW FOR OTHER PROJECTS ###
    2.13 +#####################################
    2.14 +
    2.15 +PROJECT = sample
    2.16 +
    2.17 +#Uncomment for SourceMM-enabled extensions
    2.18 +#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
    2.19 +
    2.20 +OBJECTS = extension.cpp smsdk_ext.cpp
    2.21 +
    2.22 +##############################################
    2.23 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    2.24 +##############################################
    2.25 +
    2.26 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
    2.27 +C_DEBUG_FLAGS = -g -ggdb3
    2.28 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
    2.29 +CPP = gcc-4.1
    2.30 +
    2.31 +HL2PUB = $(HL2SDK)/public
    2.32 +HL2LIB = $(HL2SDK)/linux_sdk
    2.33 +HL2SDK = $(SOURCEMM)/hl2sdk
    2.34 +SMM_TRUNK = $(SOURCEMM)/trunk
    2.35 +
    2.36 +LINK = $(LINK_HL2) -static-libgcc
    2.37 +
    2.38 +INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
    2.39 +          -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \
    2.40 +	  -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
    2.41 +
    2.42 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -fPIC -msse -DSOURCEMOD_BUILD
    2.43 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
    2.44 +
    2.45 +################################################
    2.46 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
    2.47 +################################################
    2.48 +
    2.49 +ifeq "$(DEBUG)" "true"
    2.50 +	BIN_DIR = Debug
    2.51 +	CFLAGS += $(C_DEBUG_FLAGS)
    2.52 +else
    2.53 +	BIN_DIR = Release
    2.54 +	CFLAGS += $(C_OPT_FLAGS)
    2.55 +endif
    2.56 +
    2.57 +
    2.58 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
    2.59 +ifeq "$(GCC_VERSION)" "4"
    2.60 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
    2.61 +endif
    2.62 +
    2.63 +BINARY = $(PROJECT).ext.so
    2.64 +
    2.65 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
    2.66 +OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
    2.67 +
    2.68 +$(BIN_DIR)/%.o: %.cpp
    2.69 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
    2.70 +
    2.71 +$(BIN_DIR)/%.o: %.c
    2.72 +	$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
    2.73 +
    2.74 +all:
    2.75 +	mkdir -p $(BIN_DIR)
    2.76 +	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
    2.77 +	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
    2.78 +	$(MAKE) extension
    2.79 +	rm -rf $(BINARY)
    2.80 +
    2.81 +extension: $(OBJ_LINUX)
    2.82 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
    2.83 +
    2.84 +debug:	
    2.85 +	$(MAKE) all DEBUG=true
    2.86 +
    2.87 +default: all
    2.88 +
    2.89 +clean:
    2.90 +	rm -rf Release/*.o
    2.91 +	rm -rf Release/$(BINARY)
    2.92 +	rm -rf Debug/*.o
    2.93 +	rm -rf Debug/$(BINARY)
    2.94 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/extensions/batsupport/extension.cpp	Tue Feb 27 08:21:01 2007 +0000
     3.3 @@ -0,0 +1,235 @@
     3.4 +// vim: set ts=4 :
     3.5 +#include <IAdminSystem.h>
     3.6 +#include <IPlayerHelpers.h>
     3.7 +#include "extension.h"
     3.8 +
     3.9 +BatSupport g_BatSupport;		/**< Global singleton for your extension's main interface */
    3.10 +IAdminSystem *admins = NULL;
    3.11 +IPlayerManager *players = NULL;
    3.12 +SMEXT_LINK(&g_BatSupport);
    3.13 +
    3.14 +bool BatSupport::SDK_OnLoad(char *error, size_t err_max, bool late)
    3.15 +{
    3.16 +	SM_GET_IFACE(ADMINSYS, admins);
    3.17 +	SM_GET_IFACE(PLAYERMANAGER, players);
    3.18 +
    3.19 +	players->AddClientListener(this);
    3.20 +
    3.21 +	return true;
    3.22 +}
    3.23 +
    3.24 +void BatSupport::SDK_OnUnload()
    3.25 +{
    3.26 +	players->RemoveClientListener(this);
    3.27 +
    3.28 +	List<AdminInterfaceListner *>::iterator iter;
    3.29 +	AdminInterfaceListner *hook;
    3.30 +
    3.31 +	for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
    3.32 +	{
    3.33 +		hook = (*iter);
    3.34 +		hook->OnAdminInterfaceUnload();
    3.35 +	}
    3.36 +
    3.37 +	/* In case plugins don't do this */
    3.38 +	m_hooks.clear();
    3.39 +}
    3.40 +
    3.41 +bool BatSupport::SDK_OnMetamodLoad(char *error, size_t err_max, bool late)
    3.42 +{
    3.43 +	g_SMAPI->AddListener(this, this);
    3.44 +
    3.45 +	return true;
    3.46 +}
    3.47 +
    3.48 +void BatSupport::OnClientAuthorized(int client, const char *authstring)
    3.49 +{
    3.50 +	List<AdminInterfaceListner *>::iterator iter;
    3.51 +	AdminInterfaceListner *hook;
    3.52 +
    3.53 +	for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
    3.54 +	{
    3.55 +		hook = (*iter);
    3.56 +		hook->Client_Authorized(client);
    3.57 +	}
    3.58 +}
    3.59 +
    3.60 +const char *BatSupport::GetModName()
    3.61 +{
    3.62 +	return "SourceMod";
    3.63 +}
    3.64 +
    3.65 +int BatSupport::GetInterfaceVersion()
    3.66 +{
    3.67 +	return ADMININTERFACE_VERSION;
    3.68 +}
    3.69 +
    3.70 +void *BatSupport::OnMetamodQuery(const char *iface, int *ret)
    3.71 +{
    3.72 +	if (strcmp(iface, "AdminInterface") == 0)
    3.73 +	{
    3.74 +		AdminInterface *pThis = this;
    3.75 +		if (ret)
    3.76 +		{
    3.77 +			*ret = IFACE_OK;
    3.78 +		}
    3.79 +		return pThis;
    3.80 +	}
    3.81 +
    3.82 +	if (ret)
    3.83 +	{
    3.84 +		*ret = IFACE_FAILED;
    3.85 +	}
    3.86 +	
    3.87 +	return NULL;
    3.88 +}
    3.89 +
    3.90 +bool BatSupport::RegisterFlag(const char *Class,const char *Flag,const char *Description)
    3.91 +{
    3.92 +	/* No empty flags */
    3.93 +	if (Flag[0] == '\0')
    3.94 +	{
    3.95 +		g_pSM->LogError(myself, "BAT AdminInterface support tried to register a blank flag");
    3.96 +		return false;
    3.97 +	}
    3.98 +
    3.99 +	/* We only support up to 6 custom flags for SourceMod */
   3.100 +	if (m_flags.size() >= 6)
   3.101 +	{
   3.102 +		g_pSM->LogError(myself, "BAT AdminInterface support reached maximum number of custom flags");
   3.103 +		return false;
   3.104 +	}
   3.105 +
   3.106 +	List<CustomFlag>::iterator iter;
   3.107 +	for (iter=m_flags.begin(); iter!=m_flags.end(); iter++)
   3.108 +	{
   3.109 +		CustomFlag &cf = (*iter);
   3.110 +		/* Ignore already registered, in case plugin is reloading */
   3.111 +		if (cf.name.compare(Flag) == 0)
   3.112 +		{
   3.113 +			return true;
   3.114 +		}
   3.115 +	}
   3.116 +
   3.117 +	g_pSM->LogMessage(myself, 
   3.118 +		"BAT AdminInterface support registered Admin_Custom%d (class \"%s\") (flag \"%s\") (descr \"%s\")",
   3.119 +		m_flags.size() + 1,
   3.120 +		Class,
   3.121 +		Flag,
   3.122 +		Description);
   3.123 +
   3.124 +	unsigned int f = (unsigned int)Admin_Custom1;
   3.125 +	f += m_flags.size();
   3.126 +
   3.127 +	CustomFlag cf;
   3.128 +	cf.bit = (1<<f);
   3.129 +	cf.flag = (AdminFlag)f;
   3.130 +	cf.name.assign(Flag);
   3.131 +
   3.132 +	m_flags.push_back(cf);
   3.133 +
   3.134 +	return true;
   3.135 +}
   3.136 +
   3.137 +bool BatSupport::IsClient(int id)
   3.138 +{
   3.139 +	IGamePlayer *pPlayer = players->GetGamePlayer(id);
   3.140 +	
   3.141 +	if (!pPlayer)
   3.142 +	{
   3.143 +		return false;
   3.144 +	}
   3.145 +
   3.146 +	if (!pPlayer->IsConnected())
   3.147 +	{
   3.148 +		return false;
   3.149 +	}
   3.150 +
   3.151 +	if (pPlayer->IsFakeClient())
   3.152 +	{
   3.153 +		return false;
   3.154 +	}
   3.155 +
   3.156 +	return true;
   3.157 +}
   3.158 +
   3.159 +void BatSupport::AddEventListner(AdminInterfaceListner *ptr)
   3.160 +{
   3.161 +	m_hooks.push_back(ptr);
   3.162 +}
   3.163 +
   3.164 +void BatSupport::RemoveListner(AdminInterfaceListner *ptr)
   3.165 +{
   3.166 +	m_hooks.remove(ptr);
   3.167 +}
   3.168 +
   3.169 +bool BatSupport::HasFlag(int id,const char *Flag)
   3.170 +{
   3.171 +	IGamePlayer *pPlayer = players->GetGamePlayer(id);
   3.172 +
   3.173 +	if (!pPlayer || !pPlayer->IsConnected())
   3.174 +	{
   3.175 +		return false;
   3.176 +	}
   3.177 +
   3.178 +	AdminId admin = pPlayer->GetAdminId();
   3.179 +	if (admin == INVALID_ADMIN_ID)
   3.180 +	{
   3.181 +		return false;
   3.182 +	}
   3.183 +
   3.184 +	FlagBits bits = admins->GetAdminFlags(admin, Access_Effective);
   3.185 +
   3.186 +	/* Root has it all... except for immunity */
   3.187 +	if ((strcmp(Flag, "immunity") != 0)
   3.188 +	    && ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT))
   3.189 +	{
   3.190 +		return true;
   3.191 +	}
   3.192 +
   3.193 +	if (!strcmp(Flag, "any"))
   3.194 +	{
   3.195 +		return ((bits & ~ADMFLAG_RESERVATION) != 0);
   3.196 +	} else if (!strcmp(Flag, "kick")) {
   3.197 +		return ((bits & ADMFLAG_KICK) == ADMFLAG_KICK);
   3.198 +	} else if (!strcmp(Flag, "slap")) {
   3.199 +		return ((bits & ADMFLAG_SLAY) == ADMFLAG_SLAY);
   3.200 +	} else if (!strcmp(Flag, "slay")) {
   3.201 +		return ((bits & ADMFLAG_SLAY) == ADMFLAG_SLAY);
   3.202 +	} else if (!strcmp(Flag, "ban")) {
   3.203 +		return ((bits & ADMFLAG_BAN) == ADMFLAG_BAN);
   3.204 +	} else if (!strcmp(Flag, "chat")) {
   3.205 +		return ((bits & ADMFLAG_CHAT) == ADMFLAG_CHAT);
   3.206 +	} else if (!strcmp(Flag, "rcon")) {
   3.207 +		return ((bits & ADMFLAG_RCON) == ADMFLAG_RCON);
   3.208 +	} else if (!strcmp(Flag, "map")) {
   3.209 +		return ((bits & ADMFLAG_CHANGEMAP) == ADMFLAG_CHANGEMAP);
   3.210 +	} else if (!strcmp(Flag, "reservedslots")) {
   3.211 +		return ((bits & ADMFLAG_RESERVATION) == ADMFLAG_RESERVATION);
   3.212 +	} else if (!strcmp(Flag, "immunuty")) {
   3.213 +		/* This is a bit different... */
   3.214 +		unsigned int count = admins->GetAdminGroupCount(admin);
   3.215 +		for (unsigned int i=0; i<count; i++)
   3.216 +		{
   3.217 +			GroupId gid = admins->GetAdminGroup(admin, i, NULL);
   3.218 +			if (admins->GetGroupGenericImmunity(gid, Immunity_Default)
   3.219 +				|| admins->GetGroupGenericImmunity(gid, Immunity_Global))
   3.220 +			{
   3.221 +				return true;
   3.222 +			}
   3.223 +		}
   3.224 +		return false;
   3.225 +	}
   3.226 +
   3.227 +	List<CustomFlag>::iterator iter;
   3.228 +	for (iter=m_flags.begin(); iter!=m_flags.end(); iter++)
   3.229 +	{
   3.230 +		CustomFlag &cf = (*iter);
   3.231 +		if (cf.name.compare(Flag) == 0)
   3.232 +		{
   3.233 +			return ((bits & cf.bit) == cf.bit);
   3.234 +		}
   3.235 +	}
   3.236 +
   3.237 +	return false;
   3.238 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/extensions/batsupport/extension.h	Tue Feb 27 08:21:01 2007 +0000
     4.3 @@ -0,0 +1,46 @@
     4.4 +// vim: set ts=4 :
     4.5 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     4.6 +#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     4.7 +
     4.8 +#include "smsdk_ext.h"
     4.9 +#include "BATInterface.h"
    4.10 +#include <sh_list.h>
    4.11 +#include <sh_string.h>
    4.12 +
    4.13 +using namespace SourceHook;
    4.14 +
    4.15 +struct CustomFlag
    4.16 +{
    4.17 +	String name;
    4.18 +	AdminFlag flag;
    4.19 +	FlagBits bit;
    4.20 +};
    4.21 +
    4.22 +class BatSupport : 
    4.23 +	public SDKExtension,
    4.24 +	public IMetamodListener,
    4.25 +	public AdminInterface,
    4.26 +	public IClientListener
    4.27 +{
    4.28 +public: //SDKExtension
    4.29 +	bool SDK_OnLoad(char *error, size_t err_max, bool late);
    4.30 +	void SDK_OnUnload();
    4.31 +	bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
    4.32 +public: //IMetamodListener
    4.33 +	void *OnMetamodQuery(const char *iface, int *ret);
    4.34 +public: //AdminInterface
    4.35 +	bool RegisterFlag(const char *Class,const char *Flag,const char *Description);
    4.36 +	bool IsClient(int id);
    4.37 +	bool HasFlag(int id,const char *Flag);
    4.38 +	int GetInterfaceVersion();
    4.39 +	const char* GetModName();
    4.40 +	void AddEventListner(AdminInterfaceListner *ptr);
    4.41 +	void RemoveListner(AdminInterfaceListner *ptr);
    4.42 +public: //IClientListener
    4.43 +	void OnClientAuthorized(int client, const char *authstring);
    4.44 +private:
    4.45 +	List<AdminInterfaceListner *> m_hooks;
    4.46 +	List<CustomFlag> m_flags;
    4.47 +};
    4.48 +
    4.49 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/extensions/batsupport/msvc8/batsupport.sln	Tue Feb 27 08:21:01 2007 +0000
     5.3 @@ -0,0 +1,20 @@
     5.4 +
     5.5 +Microsoft Visual Studio Solution File, Format Version 9.00
     5.6 +# Visual Studio 2005
     5.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BatSupport", "BatSupport.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
     5.8 +EndProject
     5.9 +Global
    5.10 +	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    5.11 +		Debug|Win32 = Debug|Win32
    5.12 +		Release|Win32 = Release|Win32
    5.13 +	EndGlobalSection
    5.14 +	GlobalSection(ProjectConfigurationPlatforms) = postSolution
    5.15 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32
    5.16 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32
    5.17 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32
    5.18 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32
    5.19 +	EndGlobalSection
    5.20 +	GlobalSection(SolutionProperties) = preSolution
    5.21 +		HideSolutionNode = FALSE
    5.22 +	EndGlobalSection
    5.23 +EndGlobal
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/extensions/batsupport/msvc8/batsupport.vcproj	Tue Feb 27 08:21:01 2007 +0000
     6.3 @@ -0,0 +1,380 @@
     6.4 +<?xml version="1.0" encoding="Windows-1252"?>
     6.5 +<VisualStudioProject
     6.6 +	ProjectType="Visual C++"
     6.7 +	Version="8.00"
     6.8 +	Name="BatSupport"
     6.9 +	ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
    6.10 +	RootNamespace="BatSupport"
    6.11 +	Keyword="Win32Proj"
    6.12 +	>
    6.13 +	<Platforms>
    6.14 +		<Platform
    6.15 +			Name="Win32"
    6.16 +		/>
    6.17 +	</Platforms>
    6.18 +	<ToolFiles>
    6.19 +	</ToolFiles>
    6.20 +	<Configurations>
    6.21 +		<Configuration
    6.22 +			Name="Debug|Win32"
    6.23 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    6.24 +			IntermediateDirectory="$(ConfigurationName)"
    6.25 +			ConfigurationType="2"
    6.26 +			CharacterSet="2"
    6.27 +			>
    6.28 +			<Tool
    6.29 +				Name="VCPreBuildEventTool"
    6.30 +			/>
    6.31 +			<Tool
    6.32 +				Name="VCCustomBuildTool"
    6.33 +			/>
    6.34 +			<Tool
    6.35 +				Name="VCXMLDataGeneratorTool"
    6.36 +			/>
    6.37 +			<Tool
    6.38 +				Name="VCWebServiceProxyGeneratorTool"
    6.39 +			/>
    6.40 +			<Tool
    6.41 +				Name="VCMIDLTool"
    6.42 +			/>
    6.43 +			<Tool
    6.44 +				Name="VCCLCompilerTool"
    6.45 +				Optimization="0"
    6.46 +				AdditionalIncludeDirectories="..\..\..\public;..\..\..\public\sourcepawn"
    6.47 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
    6.48 +				MinimalRebuild="true"
    6.49 +				BasicRuntimeChecks="3"
    6.50 +				RuntimeLibrary="1"
    6.51 +				UsePrecompiledHeader="0"
    6.52 +				WarningLevel="3"
    6.53 +				Detect64BitPortabilityProblems="false"
    6.54 +				DebugInformationFormat="4"
    6.55 +			/>
    6.56 +			<Tool
    6.57 +				Name="VCManagedResourceCompilerTool"
    6.58 +			/>
    6.59 +			<Tool
    6.60 +				Name="VCResourceCompilerTool"
    6.61 +			/>
    6.62 +			<Tool
    6.63 +				Name="VCPreLinkEventTool"
    6.64 +			/>
    6.65 +			<Tool
    6.66 +				Name="VCLinkerTool"
    6.67 +				OutputFile="$(OutDir)\sample.ext.dll"
    6.68 +				LinkIncremental="2"
    6.69 +				GenerateDebugInformation="true"
    6.70 +				SubSystem="2"
    6.71 +				TargetMachine="1"
    6.72 +			/>
    6.73 +			<Tool
    6.74 +				Name="VCALinkTool"
    6.75 +			/>
    6.76 +			<Tool
    6.77 +				Name="VCManifestTool"
    6.78 +			/>
    6.79 +			<Tool
    6.80 +				Name="VCXDCMakeTool"
    6.81 +			/>
    6.82 +			<Tool
    6.83 +				Name="VCBscMakeTool"
    6.84 +			/>
    6.85 +			<Tool
    6.86 +				Name="VCFxCopTool"
    6.87 +			/>
    6.88 +			<Tool
    6.89 +				Name="VCAppVerifierTool"
    6.90 +			/>
    6.91 +			<Tool
    6.92 +				Name="VCWebDeploymentTool"
    6.93 +			/>
    6.94 +			<Tool
    6.95 +				Name="VCPostBuildEventTool"
    6.96 +			/>
    6.97 +		</Configuration>
    6.98 +		<Configuration
    6.99 +			Name="Release|Win32"
   6.100 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   6.101 +			IntermediateDirectory="$(ConfigurationName)"
   6.102 +			ConfigurationType="2"
   6.103 +			CharacterSet="2"
   6.104 +			WholeProgramOptimization="1"
   6.105 +			>
   6.106 +			<Tool
   6.107 +				Name="VCPreBuildEventTool"
   6.108 +			/>
   6.109 +			<Tool
   6.110 +				Name="VCCustomBuildTool"
   6.111 +			/>
   6.112 +			<Tool
   6.113 +				Name="VCXMLDataGeneratorTool"
   6.114 +			/>
   6.115 +			<Tool
   6.116 +				Name="VCWebServiceProxyGeneratorTool"
   6.117 +			/>
   6.118 +			<Tool
   6.119 +				Name="VCMIDLTool"
   6.120 +			/>
   6.121 +			<Tool
   6.122 +				Name="VCCLCompilerTool"
   6.123 +				AdditionalIncludeDirectories="..\..\..\public;..\..\..\public\sourcepawn"
   6.124 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
   6.125 +				RuntimeLibrary="0"
   6.126 +				UsePrecompiledHeader="0"
   6.127 +				WarningLevel="3"
   6.128 +				Detect64BitPortabilityProblems="false"
   6.129 +				DebugInformationFormat="3"
   6.130 +			/>
   6.131 +			<Tool
   6.132 +				Name="VCManagedResourceCompilerTool"
   6.133 +			/>
   6.134 +			<Tool
   6.135 +				Name="VCResourceCompilerTool"
   6.136 +			/>
   6.137 +			<Tool
   6.138 +				Name="VCPreLinkEventTool"
   6.139 +			/>
   6.140 +			<Tool
   6.141 +				Name="VCLinkerTool"
   6.142 +				OutputFile="$(OutDir)\sample.ext.dll"
   6.143 +				LinkIncremental="1"
   6.144 +				GenerateDebugInformation="true"
   6.145 +				SubSystem="2"
   6.146 +				OptimizeReferences="2"
   6.147 +				EnableCOMDATFolding="2"
   6.148 +				TargetMachine="1"
   6.149 +			/>
   6.150 +			<Tool
   6.151 +				Name="VCALinkTool"
   6.152 +			/>
   6.153 +			<Tool
   6.154 +				Name="VCManifestTool"
   6.155 +			/>
   6.156 +			<Tool
   6.157 +				Name="VCXDCMakeTool"
   6.158 +			/>
   6.159 +			<Tool
   6.160 +				Name="VCBscMakeTool"
   6.161 +			/>
   6.162 +			<Tool
   6.163 +				Name="VCFxCopTool"
   6.164 +			/>
   6.165 +			<Tool
   6.166 +				Name="VCAppVerifierTool"
   6.167 +			/>
   6.168 +			<Tool
   6.169 +				Name="VCWebDeploymentTool"
   6.170 +			/>
   6.171 +			<Tool
   6.172 +				Name="VCPostBuildEventTool"
   6.173 +			/>
   6.174 +		</Configuration>
   6.175 +		<Configuration
   6.176 +			Name="Debug|Win32"
   6.177 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   6.178 +			IntermediateDirectory="$(ConfigurationName)"
   6.179 +			ConfigurationType="2"
   6.180 +			CharacterSet="2"
   6.181 +			>
   6.182 +			<Tool
   6.183 +				Name="VCPreBuildEventTool"
   6.184 +			/>
   6.185 +			<Tool
   6.186 +				Name="VCCustomBuildTool"
   6.187 +			/>
   6.188 +			<Tool
   6.189 +				Name="VCXMLDataGeneratorTool"
   6.190 +			/>
   6.191 +			<Tool
   6.192 +				Name="VCWebServiceProxyGeneratorTool"
   6.193 +			/>
   6.194 +			<Tool
   6.195 +				Name="VCMIDLTool"
   6.196 +			/>
   6.197 +			<Tool
   6.198 +				Name="VCCLCompilerTool"
   6.199 +				Optimization="0"
   6.200 +				AdditionalIncludeDirectories="..\..\..\public;..\..\..\public\sourcepawn"
   6.201 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
   6.202 +				MinimalRebuild="true"
   6.203 +				BasicRuntimeChecks="3"
   6.204 +				RuntimeLibrary="1"
   6.205 +				UsePrecompiledHeader="0"
   6.206 +				WarningLevel="3"
   6.207 +				Detect64BitPortabilityProblems="false"
   6.208 +				DebugInformationFormat="4"
   6.209 +			/>
   6.210 +			<Tool
   6.211 +				Name="VCManagedResourceCompilerTool"
   6.212 +			/>
   6.213 +			<Tool
   6.214 +				Name="VCResourceCompilerTool"
   6.215 +			/>
   6.216 +			<Tool
   6.217 +				Name="VCPreLinkEventTool"
   6.218 +			/>
   6.219 +			<Tool
   6.220 +				Name="VCLinkerTool"
   6.221 +				AdditionalDependencies="tier0.lib"
   6.222 +				OutputFile="$(OutDir)\batsupport.ext.dll"
   6.223 +				LinkIncremental="2"
   6.224 +				GenerateDebugInformation="true"
   6.225 +				SubSystem="2"
   6.226 +				TargetMachine="1"
   6.227 +			/>
   6.228 +			<Tool
   6.229 +				Name="VCALinkTool"
   6.230 +			/>
   6.231 +			<Tool
   6.232 +				Name="VCManifestTool"
   6.233 +			/>
   6.234 +			<Tool
   6.235 +				Name="VCXDCMakeTool"
   6.236 +			/>
   6.237 +			<Tool
   6.238 +				Name="VCBscMakeTool"
   6.239 +			/>
   6.240 +			<Tool
   6.241 +				Name="VCFxCopTool"
   6.242 +			/>
   6.243 +			<Tool
   6.244 +				Name="VCAppVerifierTool"
   6.245 +			/>
   6.246 +			<Tool
   6.247 +				Name="VCWebDeploymentTool"
   6.248 +			/>
   6.249 +			<Tool
   6.250 +				Name="VCPostBuildEventTool"
   6.251 +			/>
   6.252 +		</Configuration>
   6.253 +		<Configuration
   6.254 +			Name="Release|Win32"
   6.255 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   6.256 +			IntermediateDirectory="$(ConfigurationName)"
   6.257 +			ConfigurationType="2"
   6.258 +			CharacterSet="2"
   6.259 +			WholeProgramOptimization="1"
   6.260 +			>
   6.261 +			<Tool
   6.262 +				Name="VCPreBuildEventTool"
   6.263 +			/>
   6.264 +			<Tool
   6.265 +				Name="VCCustomBuildTool"
   6.266 +			/>
   6.267 +			<Tool
   6.268 +				Name="VCXMLDataGeneratorTool"
   6.269 +			/>
   6.270 +			<Tool
   6.271 +				Name="VCWebServiceProxyGeneratorTool"
   6.272 +			/>
   6.273 +			<Tool
   6.274 +				Name="VCMIDLTool"
   6.275 +			/>
   6.276 +			<Tool
   6.277 +				Name="VCCLCompilerTool"
   6.278 +				AdditionalIncludeDirectories="..\..\..\public;..\..\..\public\sourcepawn"
   6.279 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
   6.280 +				RuntimeLibrary="0"
   6.281 +				UsePrecompiledHeader="0"
   6.282 +				WarningLevel="3"
   6.283 +				Detect64BitPortabilityProblems="false"
   6.284 +				DebugInformationFormat="3"
   6.285 +			/>
   6.286 +			<Tool
   6.287 +				Name="VCManagedResourceCompilerTool"
   6.288 +			/>
   6.289 +			<Tool
   6.290 +				Name="VCResourceCompilerTool"
   6.291 +			/>
   6.292 +			<Tool
   6.293 +				Name="VCPreLinkEventTool"
   6.294 +			/>
   6.295 +			<Tool
   6.296 +				Name="VCLinkerTool"
   6.297 +				OutputFile="$(OutDir)\sample.ext.dll"
   6.298 +				LinkIncremental="1"
   6.299 +				GenerateDebugInformation="true"
   6.300 +				SubSystem="2"
   6.301 +				OptimizeReferences="2"
   6.302 +				EnableCOMDATFolding="2"
   6.303 +				TargetMachine="1"
   6.304 +			/>
   6.305 +			<Tool
   6.306 +				Name="VCALinkTool"
   6.307 +			/>
   6.308 +			<Tool
   6.309 +				Name="VCManifestTool"
   6.310 +			/>
   6.311 +			<Tool
   6.312 +				Name="VCXDCMakeTool"
   6.313 +			/>
   6.314 +			<Tool
   6.315 +				Name="VCBscMakeTool"
   6.316 +			/>
   6.317 +			<Tool
   6.318 +				Name="VCFxCopTool"
   6.319 +			/>
   6.320 +			<Tool
   6.321 +				Name="VCAppVerifierTool"
   6.322 +			/>
   6.323 +			<Tool
   6.324 +				Name="VCWebDeploymentTool"
   6.325 +			/>
   6.326 +			<Tool
   6.327 +				Name="VCPostBuildEventTool"
   6.328 +			/>
   6.329 +		</Configuration>
   6.330 +	</Configurations>
   6.331 +	<References>
   6.332 +	</References>
   6.333 +	<Files>
   6.334 +		<Filter
   6.335 +			Name="Source Files"
   6.336 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
   6.337 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
   6.338 +			>
   6.339 +			<File
   6.340 +				RelativePath="..\extension.cpp"
   6.341 +				>
   6.342 +			</File>
   6.343 +		</Filter>
   6.344 +		<Filter
   6.345 +			Name="Header Files"
   6.346 +			Filter="h;hpp;hxx;hm;inl;inc;xsd"
   6.347 +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
   6.348 +			>
   6.349 +			<File
   6.350 +				RelativePath="..\BATInterface.h"
   6.351 +				>
   6.352 +			</File>
   6.353 +			<File
   6.354 +				RelativePath="..\extension.h"
   6.355 +				>
   6.356 +			</File>
   6.357 +			<File
   6.358 +				RelativePath="..\smsdk_config.h"
   6.359 +				>
   6.360 +			</File>
   6.361 +		</Filter>
   6.362 +		<Filter
   6.363 +			Name="Resource Files"
   6.364 +			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
   6.365 +			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
   6.366 +			>
   6.367 +		</Filter>
   6.368 +		<Filter
   6.369 +			Name="SDK"
   6.370 +			>
   6.371 +			<File
   6.372 +				RelativePath="..\smsdk_ext.cpp"
   6.373 +				>
   6.374 +			</File>
   6.375 +			<File
   6.376 +				RelativePath="..\smsdk_ext.h"
   6.377 +				>
   6.378 +			</File>
   6.379 +		</Filter>
   6.380 +	</Files>
   6.381 +	<Globals>
   6.382 +	</Globals>
   6.383 +</VisualStudioProject>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/extensions/batsupport/smsdk_config.h	Tue Feb 27 08:21:01 2007 +0000
     7.3 @@ -0,0 +1,33 @@
     7.4 +// vim: set ts=4 :
     7.5 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
     7.6 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
     7.7 +
     7.8 +/**
     7.9 + * @file smsdk_config.h
    7.10 + * @brief Contains macros for configuring basic extension information.
    7.11 + */
    7.12 +
    7.13 +/* Basic information exposed publically */
    7.14 +#define SMEXT_CONF_NAME			"BAT Support"
    7.15 +#define SMEXT_CONF_DESCRIPTION	"Adds support for BAT's AdminInterface"
    7.16 +#define SMEXT_CONF_VERSION		"1.0.0.0"
    7.17 +#define SMEXT_CONF_AUTHOR		"AlliedModders"
    7.18 +#define SMEXT_CONF_URL			"http://www.sourcemod.net/"
    7.19 +#define SMEXT_CONF_LOGTAG		"BATSUPPORT"
    7.20 +#define SMEXT_CONF_LICENSE		"GPL"
    7.21 +#define SMEXT_CONF_DATESTRING	__DATE__
    7.22 +
    7.23 +/** 
    7.24 + * @brief Exposes plugin's main interface.
    7.25 + */
    7.26 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
    7.27 +
    7.28 +/**
    7.29 + * @brief Sets whether or not this plugin required Metamod.
    7.30 + * NOTE: Uncomment to enable, comment to disable.
    7.31 + * NOTE: This is enabled automatically if a Metamod build is chosen in 
    7.32 + *		 the Visual Studio project.
    7.33 + */
    7.34 +#define SMEXT_CONF_METAMOD		
    7.35 +
    7.36 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/extensions/batsupport/smsdk_ext.cpp	Tue Feb 27 08:21:01 2007 +0000
     8.3 @@ -0,0 +1,333 @@
     8.4 +/**
     8.5 + * vim: set ts=4 :
     8.6 + * ===============================================================
     8.7 + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. 
     8.8 + * All rights reserved.
     8.9 + * ===============================================================
    8.10 + *
    8.11 + *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
    8.12 + * or modified under the Terms and Conditions of its License Agreement, which is found 
    8.13 + * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    8.14 + * may change at any time.  To view the latest information, see:
    8.15 + *   http://www.sourcemod.net/license.php
    8.16 + *
    8.17 + * Version: $Id$
    8.18 + */
    8.19 +
    8.20 +#include <stdio.h>
    8.21 +#include <malloc.h>
    8.22 +#include "smsdk_ext.h"
    8.23 +
    8.24 +/**
    8.25 + * @file smsdk_ext.cpp
    8.26 + * @brief Contains wrappers for making Extensions easier to write.
    8.27 + */
    8.28 +
    8.29 +IShareSys *g_pShareSys = NULL;			/**< Share system */
    8.30 +IExtension *myself = NULL;				/**< Ourself */
    8.31 +IHandleSys *g_pHandleSys = NULL;		/**< Handle system */
    8.32 +ISourceMod *g_pSM = NULL;				/**< SourceMod helpers */
    8.33 +IForwardManager *g_pForwards = NULL;	/**< Forward system */
    8.34 +
    8.35 +/** Exports the main interface */
    8.36 +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
    8.37 +{
    8.38 +	return g_pExtensionIface;
    8.39 +}
    8.40 +
    8.41 +SDKExtension::SDKExtension()
    8.42 +{
    8.43 +#if defined SMEXT_CONF_METAMOD
    8.44 +	m_SourceMMLoaded = false;
    8.45 +	m_WeAreUnloaded = false;
    8.46 +	m_WeGotPauseChange = false;
    8.47 +#endif
    8.48 +}
    8.49 +
    8.50 +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late)
    8.51 +{
    8.52 +	g_pShareSys = sys;
    8.53 +	myself = me;
    8.54 +
    8.55 +#if defined SMEXT_CONF_METAMOD
    8.56 +	m_WeAreUnloaded = true;
    8.57 +
    8.58 +	if (!m_SourceMMLoaded)
    8.59 +	{
    8.60 +		if (error)
    8.61 +		{
    8.62 +			snprintf(error, err_max, "Metamod attach failed");
    8.63 +		}
    8.64 +		return false;
    8.65 +	}
    8.66 +#endif
    8.67 +
    8.68 +	SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
    8.69 +	SM_GET_IFACE(SOURCEMOD, g_pSM);
    8.70 +	SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
    8.71 +
    8.72 +	if (SDK_OnLoad(error, err_max, late))
    8.73 +	{
    8.74 +#if defined SMEXT_CONF_METAMOD
    8.75 +		m_WeAreUnloaded = true;
    8.76 +#endif
    8.77 +		return true;
    8.78 +	}
    8.79 +
    8.80 +	return false;
    8.81 +}
    8.82 +
    8.83 +bool SDKExtension::IsMetamodExtension()
    8.84 +{
    8.85 +#if defined SMEXT_CONF_METAMOD
    8.86 +	return true;
    8.87 +#else
    8.88 +	return false;
    8.89 +#endif
    8.90 +}
    8.91 +
    8.92 +void SDKExtension::OnExtensionPauseChange(bool state)
    8.93 +{
    8.94 +#if defined SMEXT_CONF_METAMOD
    8.95 +	m_WeGotPauseChange = true;
    8.96 +#endif
    8.97 +	SDK_OnPauseChange(state);
    8.98 +}
    8.99 +
   8.100 +void SDKExtension::OnExtensionsAllLoaded()
   8.101 +{
   8.102 +	SDK_OnAllLoaded();
   8.103 +}
   8.104 +
   8.105 +void SDKExtension::OnExtensionUnload()
   8.106 +{
   8.107 +#if defined SMEXT_CONF_METAMOD
   8.108 +	m_WeAreUnloaded = true;
   8.109 +#endif
   8.110 +	SDK_OnUnload();
   8.111 +}
   8.112 +
   8.113 +const char *SDKExtension::GetExtensionAuthor()
   8.114 +{
   8.115 +	return SMEXT_CONF_AUTHOR;
   8.116 +}
   8.117 +
   8.118 +const char *SDKExtension::GetExtensionDateString()
   8.119 +{
   8.120 +	return SMEXT_CONF_DATESTRING;
   8.121 +}
   8.122 +
   8.123 +const char *SDKExtension::GetExtensionDescription()
   8.124 +{
   8.125 +	return SMEXT_CONF_DESCRIPTION;
   8.126 +}
   8.127 +
   8.128 +const char *SDKExtension::GetExtensionVerString()
   8.129 +{
   8.130 +	return SMEXT_CONF_VERSION;
   8.131 +}
   8.132 +
   8.133 +const char *SDKExtension::GetExtensionName()
   8.134 +{
   8.135 +	return SMEXT_CONF_NAME;
   8.136 +}
   8.137 +
   8.138 +const char *SDKExtension::GetExtensionTag()
   8.139 +{
   8.140 +	return SMEXT_CONF_LOGTAG;
   8.141 +}
   8.142 +
   8.143 +const char *SDKExtension::GetExtensionURL()
   8.144 +{
   8.145 +	return SMEXT_CONF_URL;
   8.146 +}
   8.147 +
   8.148 +bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
   8.149 +{
   8.150 +	return true;
   8.151 +}
   8.152 +
   8.153 +void SDKExtension::SDK_OnUnload()
   8.154 +{
   8.155 +}
   8.156 +
   8.157 +void SDKExtension::SDK_OnPauseChange(bool paused)
   8.158 +{
   8.159 +}
   8.160 +
   8.161 +void SDKExtension::SDK_OnAllLoaded()
   8.162 +{
   8.163 +}
   8.164 +
   8.165 +#if defined SMEXT_CONF_METAMOD
   8.166 +
   8.167 +PluginId g_PLID = 0;						/**< Metamod plugin ID */
   8.168 +ISmmPlugin *g_PLAPI = NULL;					/**< Metamod plugin API */
   8.169 +SourceHook::ISourceHook *g_SHPtr = NULL;	/**< SourceHook pointer */
   8.170 +ISmmAPI *g_SMAPI = NULL;					/**< SourceMM API pointer */
   8.171 +
   8.172 +IVEngineServer *engine = NULL;				/**< IVEngineServer pointer */
   8.173 +IServerGameDLL *gamedll = NULL;				/**< IServerGameDLL pointer */
   8.174 +
   8.175 +/** Exposes the extension to Metamod */
   8.176 +SMM_API void *PL_EXPOSURE(const char *name, int *code)
   8.177 +{
   8.178 +	if (name && !strcmp(name, PLAPI_NAME))
   8.179 +	{
   8.180 +		if (code)
   8.181 +		{
   8.182 +			*code = IFACE_OK;
   8.183 +		}
   8.184 +		return static_cast<void *>(g_pExtensionIface);
   8.185 +	}
   8.186 +
   8.187 +	if (code)
   8.188 +	{
   8.189 +		*code = IFACE_FAILED;
   8.190 +	}
   8.191 +
   8.192 +	return NULL;
   8.193 +}
   8.194 +
   8.195 +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
   8.196 +{
   8.197 +	PLUGIN_SAVEVARS();
   8.198 +
   8.199 +	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
   8.200 +	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
   8.201 +
   8.202 +	m_SourceMMLoaded = true;
   8.203 +
   8.204 +	return SDK_OnMetamodLoad(error, maxlen, late);
   8.205 +}
   8.206 +
   8.207 +bool SDKExtension::Unload(char *error, size_t maxlen)
   8.208 +{
   8.209 +	if (!m_WeAreUnloaded)
   8.210 +	{
   8.211 +		if (error)
   8.212 +		{
   8.213 +			snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
   8.214 +		}
   8.215 +		return false;
   8.216 +	}
   8.217 +
   8.218 +	return SDK_OnMetamodUnload(error, maxlen);
   8.219 +}
   8.220 +
   8.221 +bool SDKExtension::Pause(char *error, size_t maxlen)
   8.222 +{
   8.223 +	if (!m_WeGotPauseChange)
   8.224 +	{
   8.225 +		if (error)
   8.226 +		{
   8.227 +			snprintf(error, maxlen, "This extension must be paused by SourceMod.");
   8.228 +		}
   8.229 +		return false;
   8.230 +	}
   8.231 +
   8.232 +	m_WeGotPauseChange = false;
   8.233 +
   8.234 +	return SDK_OnMetamodPauseChange(true, error, maxlen);
   8.235 +}
   8.236 +
   8.237 +bool SDKExtension::Unpause(char *error, size_t maxlen)
   8.238 +{
   8.239 +	if (!m_WeGotPauseChange)
   8.240 +	{
   8.241 +		if (error)
   8.242 +		{
   8.243 +			snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
   8.244 +		}
   8.245 +		return false;
   8.246 +	}
   8.247 +
   8.248 +	m_WeGotPauseChange = false;
   8.249 +
   8.250 +	return SDK_OnMetamodPauseChange(false, error, maxlen);
   8.251 +}
   8.252 +
   8.253 +const char *SDKExtension::GetAuthor()
   8.254 +{
   8.255 +	return GetExtensionAuthor();
   8.256 +}
   8.257 +
   8.258 +const char *SDKExtension::GetDate()
   8.259 +{
   8.260 +	return GetExtensionDateString();
   8.261 +}
   8.262 +
   8.263 +const char *SDKExtension::GetDescription()
   8.264 +{
   8.265 +	return GetExtensionDescription();
   8.266 +}
   8.267 +
   8.268 +const char *SDKExtension::GetLicense()
   8.269 +{
   8.270 +	return SMEXT_CONF_LICENSE;
   8.271 +}
   8.272 +
   8.273 +const char *SDKExtension::GetLogTag()
   8.274 +{
   8.275 +	return GetExtensionTag();
   8.276 +}
   8.277 +
   8.278 +const char *SDKExtension::GetName()
   8.279 +{
   8.280 +	return GetExtensionName();
   8.281 +}
   8.282 +
   8.283 +const char *SDKExtension::GetURL()
   8.284 +{
   8.285 +	return GetExtensionURL();
   8.286 +}
   8.287 +
   8.288 +const char *SDKExtension::GetVersion()
   8.289 +{
   8.290 +	return GetExtensionVerString();
   8.291 +}
   8.292 +
   8.293 +bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late)
   8.294 +{
   8.295 +	return true;
   8.296 +}
   8.297 +
   8.298 +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max)
   8.299 +{
   8.300 +	return true;
   8.301 +}
   8.302 +
   8.303 +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max)
   8.304 +{
   8.305 +	return true;
   8.306 +}
   8.307 +
   8.308 +#endif
   8.309 +
   8.310 +/* Overload a few things to prevent libstdc++ linking */
   8.311 +#if defined __linux__
   8.312 +extern "C" void __cxa_pure_virtual(void)
   8.313 +{
   8.314 +}
   8.315 +
   8.316 +void *operator new(size_t size)
   8.317 +{
   8.318 +	return malloc(size);
   8.319 +}
   8.320 +
   8.321 +void *operator new[](size_t size) 
   8.322 +{
   8.323 +	return malloc(size);
   8.324 +}
   8.325 +
   8.326 +void operator delete(void *ptr) 
   8.327 +{
   8.328 +	free(ptr);
   8.329 +}
   8.330 +
   8.331 +void operator delete[](void * ptr)
   8.332 +{
   8.333 +	free(ptr);
   8.334 +}
   8.335 +#endif
   8.336 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/extensions/batsupport/smsdk_ext.h	Tue Feb 27 08:21:01 2007 +0000
     9.3 @@ -0,0 +1,196 @@
     9.4 +/**
     9.5 + * vim: set ts=4 :
     9.6 + * ===============================================================
     9.7 + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. 
     9.8 + * All rights reserved.
     9.9 + * ===============================================================
    9.10 + *
    9.11 + *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
    9.12 + * or modified under the Terms and Conditions of its License Agreement, which is found 
    9.13 + * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    9.14 + * may change at any time.  To view the latest information, see:
    9.15 + *   http://www.sourcemod.net/license.php
    9.16 + *
    9.17 + * Version: $Id$
    9.18 + */
    9.19 +
    9.20 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    9.21 +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    9.22 +
    9.23 +/**
    9.24 + * @file smsdk_ext.h
    9.25 + * @brief Contains wrappers for making Extensions easier to write.
    9.26 + */
    9.27 +
    9.28 +#include "smsdk_config.h"
    9.29 +#include <IExtensionSys.h>
    9.30 +#include <IHandleSys.h>
    9.31 +#include <sp_vm_api.h>
    9.32 +#include <sm_platform.h>
    9.33 +#include <ISourceMod.h>
    9.34 +#include <IForwardSys.h>
    9.35 +
    9.36 +#if defined SMEXT_CONF_METAMOD
    9.37 +#include <ISmmPlugin.h>
    9.38 +#include <eiface.h>
    9.39 +#endif
    9.40 +
    9.41 +using namespace SourceMod;
    9.42 +using namespace SourcePawn;
    9.43 +
    9.44 +class SDKExtension : 
    9.45 +#if defined SMEXT_CONF_METAMOD
    9.46 +	public ISmmPlugin,
    9.47 +#endif
    9.48 +	public IExtensionInterface
    9.49 +{
    9.50 +public:
    9.51 +	/** Constructor */
    9.52 +	SDKExtension();
    9.53 +public:
    9.54 +	/**
    9.55 +	 * @brief This is called after the initial loading sequence has been processed.
    9.56 +	 *
    9.57 +	 * @param error		Error message buffer.
    9.58 +	 * @param err_max	Size of error message buffer.
    9.59 +	 * @param late		Whether or not the module was loaded after map load.
    9.60 +	 * @return			True to succeed loading, false to fail.
    9.61 +	 */
    9.62 +	virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
    9.63 +	
    9.64 +	/**
    9.65 +	 * @brief This is called right before the extension is unloaded.
    9.66 +	 */
    9.67 +	virtual void SDK_OnUnload();
    9.68 +
    9.69 +	/**
    9.70 +	 * @brief This is called once all known extensions have been loaded.
    9.71 +	 */
    9.72 +	virtual void SDK_OnAllLoaded();
    9.73 +
    9.74 +	/**
    9.75 +	 * @brief Called when the pause state is changed.
    9.76 +	 */
    9.77 +	virtual void SDK_OnPauseChange(bool paused);
    9.78 +
    9.79 +#if defined SMEXT_CONF_METAMOD
    9.80 +	/**
    9.81 +	 * @brief Called when Metamod is attached, before the extension version is called.
    9.82 +	 *
    9.83 +	 * @param error			Error buffer.
    9.84 +	 * @param err_max		Maximum size of error buffer.
    9.85 +	 * @param late			Whether or not Metamod considers this a late load.
    9.86 +	 * @return				True to succeed, false to fail.
    9.87 +	 */
    9.88 +	virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
    9.89 +
    9.90 +	/**
    9.91 +	 * @brief Called when Metamod is detaching, after the extension version is called.
    9.92 +	 * NOTE: By default this is blocked unless sent from SourceMod.
    9.93 +	 *
    9.94 +	 * @param error			Error buffer.
    9.95 +	 * @param err_max		Maximum size of error buffer.
    9.96 +	 * @return				True to succeed, false to fail.
    9.97 +	 */
    9.98 +	virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
    9.99 +
   9.100 +	/**
   9.101 +	 * @brief Called when Metamod's pause state is changing.
   9.102 +	 * NOTE: By default this is blocked unless sent from SourceMod.
   9.103 +	 *
   9.104 +	 * @param paused		Pause state being set.
   9.105 +	 * @param error			Error buffer.
   9.106 +	 * @param err_max		Maximum size of error buffer.
   9.107 +	 * @return				True to succeed, false to fail.
   9.108 +	 */
   9.109 +	virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
   9.110 +#endif
   9.111 +
   9.112 +public: //IExtensionInterface
   9.113 +	virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late);
   9.114 +	virtual void OnExtensionUnload();
   9.115 +	virtual void OnExtensionsAllLoaded();
   9.116 +
   9.117 +	/** Returns whether or not this is a Metamod-based extension */
   9.118 +	virtual bool IsMetamodExtension();
   9.119 +
   9.120 +	/**
   9.121 +	 * @brief Called when the pause state changes.
   9.122 +	 * 
   9.123 +	 * @param state			True if being paused, false if being unpaused.
   9.124 +	 */
   9.125 +	virtual void OnExtensionPauseChange(bool state);
   9.126 +
   9.127 +	/** Returns name */
   9.128 +	virtual const char *GetExtensionName();
   9.129 +	/** Returns URL */
   9.130 +	virtual const char *GetExtensionURL();
   9.131 +	/** Returns log tag */
   9.132 +	virtual const char *GetExtensionTag();
   9.133 +	/** Returns author */
   9.134 +	virtual const char *GetExtensionAuthor();
   9.135 +	/** Returns version string */
   9.136 +	virtual const char *GetExtensionVerString();
   9.137 +	/** Returns description string */
   9.138 +	virtual const char *GetExtensionDescription();
   9.139 +	/** Returns date string */
   9.140 +	virtual const char *GetExtensionDateString();
   9.141 +#if defined SMEXT_CONF_METAMOD
   9.142 +public: //ISmmPlugin
   9.143 +	/** Called when the extension is attached to Metamod. */
   9.144 +	virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
   9.145 +	/** Returns the author to MM */
   9.146 +	virtual const char *GetAuthor();
   9.147 +	/** Returns the name to MM */
   9.148 +	virtual const char *GetName();
   9.149 +	/** Returns the description to MM */
   9.150 +	virtual const char *GetDescription();
   9.151 +	/** Returns the URL to MM */
   9.152 +	virtual const char *GetURL();
   9.153 +	/** Returns the license to MM */
   9.154 +	virtual const char *GetLicense();
   9.155 +	/** Returns the version string to MM */
   9.156 +	virtual const char *GetVersion();
   9.157 +	/** Returns the date string to MM */
   9.158 +	virtual const char *GetDate();
   9.159 +	/** Returns the logtag to MM */
   9.160 +	virtual const char *GetLogTag();
   9.161 +	/** Called on unload */
   9.162 +	virtual bool Unload(char *error, size_t maxlen);
   9.163 +	/** Called on pause */
   9.164 +	virtual bool Pause(char *error, size_t maxlen);
   9.165 +	/** Called on unpause */
   9.166 +	virtual bool Unpause(char *error, size_t maxlen);
   9.167 +private:
   9.168 +	bool m_SourceMMLoaded;
   9.169 +	bool m_WeAreUnloaded;
   9.170 +	bool m_WeGotPauseChange;
   9.171 +#endif
   9.172 +};
   9.173 +
   9.174 +extern SDKExtension *g_pExtensionIface;
   9.175 +
   9.176 +extern IShareSys *g_pShareSys;
   9.177 +extern IExtension *myself;
   9.178 +extern IHandleSys *g_pHandleSys;
   9.179 +extern ISourceMod *g_pSM;
   9.180 +extern IForwardManager *g_pForwards;
   9.181 +
   9.182 +#if defined SMEXT_CONF_METAMOD
   9.183 +PLUGIN_GLOBALVARS();
   9.184 +extern IVEngineServer *engine;
   9.185 +extern IServerGameDLL *gamedll;
   9.186 +#endif
   9.187 +
   9.188 +/** Creates a SourceMod interface macro pair */
   9.189 +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
   9.190 +/** Automates retrieving SourceMod interfaces */
   9.191 +#define SM_GET_IFACE(prefix,addr) \
   9.192 +	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \
   9.193 +	 if (error) { \
   9.194 +		snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
   9.195 +	 } \
   9.196 +	 return false; \
   9.197 +	}
   9.198 +
   9.199 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_