From 9decd4196aff1061f3159582493c45e81319a80f Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 9 May 2007 05:20:03 +0000 Subject: [PATCH] Whew, massive-ish reorgranization for extensions and such. I will inevitably be shot for this. (Yes, bail, it all compiles on both platforms) --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40763 --- extensions/batsupport/Makefile | 12 +- extensions/batsupport/extension.cpp | 28 +- extensions/batsupport/extension.h | 47 ++- extensions/batsupport/msvc8/batsupport.sln | 10 +- extensions/batsupport/msvc8/batsupport.vcproj | 181 +--------- extensions/batsupport/sdk/smsdk_config.h | 48 +++ .../sdk}/smsdk_ext.cpp | 27 +- .../batsupport/sdk}/smsdk_ext.h | 65 ++-- extensions/batsupport/smsdk_config.h | 33 -- extensions/bintools/CallMaker.cpp | 21 +- extensions/bintools/CallMaker.h | 21 +- extensions/bintools/CallWrapper.cpp | 21 +- extensions/bintools/CallWrapper.h | 21 +- extensions/bintools/Makefile | 10 +- extensions/bintools/extension.cpp | 27 +- extensions/bintools/extension.h | 65 +++- extensions/bintools/jit_call.cpp | 21 +- extensions/bintools/jit_call.h | 21 +- extensions/bintools/msvc8/bintools.sln | 10 +- extensions/bintools/msvc8/bintools.vcproj | 55 ++- extensions/bintools/sdk/smsdk_config.h | 48 +++ .../bintools/sdk}/smsdk_ext.cpp | 27 +- extensions/bintools/{ => sdk}/smsdk_ext.h | 65 ++-- extensions/bintools/smsdk_config.h | 33 -- extensions/geoip/Makefile | 12 +- extensions/geoip/extension.cpp | 17 +- extensions/geoip/extension.h | 55 ++- extensions/geoip/msvc8/geoip.sln | 10 +- extensions/geoip/msvc8/geoip.vcproj | 34 +- extensions/geoip/sdk/smsdk_config.h | 49 +++ extensions/geoip/sdk/smsdk_ext.cpp | 334 ++++++++++++++++++ .../{batsupport => geoip/sdk}/smsdk_ext.h | 65 ++-- extensions/geoip/smsdk_config.h | 48 --- extensions/geoip/smsdk_ext.cpp | 324 ----------------- extensions/geoip/smsdk_ext.h | 158 --------- extensions/threader/Makefile | 17 +- extensions/threader/extension.cpp | 13 +- extensions/threader/extension.h | 54 ++- extensions/threader/msvc8/threader.vcproj | 33 +- extensions/threader/sdk/smsdk_config.h | 49 +++ .../sdk}/smsdk_ext.cpp | 29 +- extensions/threader/{ => sdk}/smsdk_ext.h | 105 ++++-- extensions/threader/smsdk_config.h | 47 --- extensions/threader/thread/BaseWorker.cpp | 6 +- extensions/threader/thread/BaseWorker.h | 6 +- extensions/threader/thread/PosixThreads.cpp | 7 +- extensions/threader/thread/PosixThreads.h | 6 +- extensions/threader/thread/ThreadSupport.h | 6 +- extensions/threader/thread/ThreadWorker.cpp | 6 +- extensions/threader/thread/ThreadWorker.h | 6 +- extensions/threader/thread/WinThreads.cpp | 7 +- extensions/threader/thread/WinThreads.h | 6 +- modules.versions | 2 +- public/sample_ext/Makefile | 10 +- public/sample_ext/extension.cpp | 27 +- public/sample_ext/extension.h | 66 +++- public/sample_ext/msvc8/sdk.vcproj | 33 +- public/sample_ext/sdk/smsdk_config.h | 48 +++ .../sample_ext/sdk}/smsdk_ext.cpp | 62 ++-- public/sample_ext/sdk/smsdk_ext.h | 213 +++++++++++ public/sample_ext/smsdk_config.h | 33 -- 61 files changed, 1665 insertions(+), 1255 deletions(-) create mode 100644 extensions/batsupport/sdk/smsdk_config.h rename extensions/{bintools => batsupport/sdk}/smsdk_ext.cpp (84%) rename {public/sample_ext => extensions/batsupport/sdk}/smsdk_ext.h (73%) delete mode 100644 extensions/batsupport/smsdk_config.h create mode 100644 extensions/bintools/sdk/smsdk_config.h rename {public/sample_ext => extensions/bintools/sdk}/smsdk_ext.cpp (84%) rename extensions/bintools/{ => sdk}/smsdk_ext.h (73%) delete mode 100644 extensions/bintools/smsdk_config.h create mode 100644 extensions/geoip/sdk/smsdk_config.h create mode 100644 extensions/geoip/sdk/smsdk_ext.cpp rename extensions/{batsupport => geoip/sdk}/smsdk_ext.h (72%) delete mode 100644 extensions/geoip/smsdk_config.h delete mode 100644 extensions/geoip/smsdk_ext.cpp delete mode 100644 extensions/geoip/smsdk_ext.h create mode 100644 extensions/threader/sdk/smsdk_config.h rename extensions/{batsupport => threader/sdk}/smsdk_ext.cpp (82%) rename extensions/threader/{ => sdk}/smsdk_ext.h (56%) delete mode 100644 extensions/threader/smsdk_config.h create mode 100644 public/sample_ext/sdk/smsdk_config.h rename {extensions/threader => public/sample_ext/sdk}/smsdk_ext.cpp (68%) create mode 100644 public/sample_ext/sdk/smsdk_ext.h delete mode 100644 public/sample_ext/smsdk_config.h diff --git a/extensions/batsupport/Makefile b/extensions/batsupport/Makefile index 1e9d6a22..8ea51205 100644 --- a/extensions/batsupport/Makefile +++ b/extensions/batsupport/Makefile @@ -12,9 +12,9 @@ SOURCEMM = ../../../../sourcemm PROJECT = batsupport #Uncomment for SourceMM-enabled extensions -#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -OBJECTS = extension.cpp smsdk_ext.cpp +OBJECTS = sdk/smsdk_ext.cpp extension.cpp ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -32,7 +32,7 @@ SMM_TRUNK = $(SOURCEMM)/trunk LINK = $(LINK_HL2) -static-libgcc -INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \ -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ @@ -65,11 +65,10 @@ $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< all: - mkdir -p $(BIN_DIR) + mkdir -p $(BIN_DIR)/sdk ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so $(MAKE) extension - rm -rf $(BINARY) extension: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -81,7 +80,8 @@ default: all clean: rm -rf Release/*.o + rm -rf Release/sdk/*.o rm -rf Release/$(BINARY) rm -rf Debug/*.o + rm -rf Debug/sdk/*.o rm -rf Debug/$(BINARY) - diff --git a/extensions/batsupport/extension.cpp b/extensions/batsupport/extension.cpp index 96ef66cc..73e92c08 100644 --- a/extensions/batsupport/extension.cpp +++ b/extensions/batsupport/extension.cpp @@ -1,4 +1,26 @@ -// vim: set ts=4 : +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod BAT Support Extension + * Copyright (C) 2004-2007 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Version: $Id$ + */ + #include #include #include "extension.h" @@ -8,7 +30,7 @@ IAdminSystem *admins = NULL; IPlayerManager *players = NULL; SMEXT_LINK(&g_BatSupport); -bool BatSupport::SDK_OnLoad(char *error, size_t err_max, bool late) +bool BatSupport::SDK_OnLoad(char *error, size_t maxlength, bool late) { SM_GET_IFACE(ADMINSYS, admins); SM_GET_IFACE(PLAYERMANAGER, players); @@ -35,7 +57,7 @@ void BatSupport::SDK_OnUnload() m_hooks.clear(); } -bool BatSupport::SDK_OnMetamodLoad(char *error, size_t err_max, bool late) +bool BatSupport::SDK_OnMetamodLoad(char *error, size_t maxlength, bool late) { g_SMAPI->AddListener(this, this); diff --git a/extensions/batsupport/extension.h b/extensions/batsupport/extension.h index ce234f0a..5b946719 100644 --- a/extensions/batsupport/extension.h +++ b/extensions/batsupport/extension.h @@ -1,7 +1,34 @@ -// vim: set ts=4 : +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod BAT Support Extension + * Copyright (C) 2004-2007 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Version: $Id$ + */ + #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +/** + * @file extension.h + * @brief BAT Support extension code header. + */ + #include "smsdk_ext.h" #include "BATInterface.h" #include @@ -22,25 +49,25 @@ class BatSupport : public AdminInterface, public IClientListener { -public: //SDKExtension - bool SDK_OnLoad(char *error, size_t err_max, bool late); +public: // SDKExtension + bool SDK_OnLoad(char *error, size_t maxlength, bool late); void SDK_OnUnload(); - bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); -public: //IMetamodListener + bool SDK_OnMetamodLoad(char *error, size_t maxlength, bool late); +public: // IMetamodListener void *OnMetamodQuery(const char *iface, int *ret); -public: //AdminInterface - bool RegisterFlag(const char *Class,const char *Flag,const char *Description); +public: // AdminInterface + bool RegisterFlag(const char *Class, const char *Flag, const char *Description); bool IsClient(int id); - bool HasFlag(int id,const char *Flag); + bool HasFlag(int id, const char *Flag); int GetInterfaceVersion(); const char* GetModName(); void AddEventListner(AdminInterfaceListner *ptr); void RemoveListner(AdminInterfaceListner *ptr); -public: //IClientListener +public: // IClientListener void OnClientAuthorized(int client, const char *authstring); private: List m_hooks; List m_flags; }; -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/batsupport/msvc8/batsupport.sln b/extensions/batsupport/msvc8/batsupport.sln index 6f8ed540..cabbd260 100644 --- a/extensions/batsupport/msvc8/batsupport.sln +++ b/extensions/batsupport/msvc8/batsupport.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BatSupport", "BatSupport.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BatSupport", "BatSupport.vcproj", "{E2FDA25A-3F36-46CE-A4EB-F4AB60011386}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,10 +9,10 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 + {E2FDA25A-3F36-46CE-A4EB-F4AB60011386}.Debug|Win32.ActiveCfg = Debug|Win32 + {E2FDA25A-3F36-46CE-A4EB-F4AB60011386}.Debug|Win32.Build.0 = Debug|Win32 + {E2FDA25A-3F36-46CE-A4EB-F4AB60011386}.Release|Win32.ActiveCfg = Release|Win32 + {E2FDA25A-3F36-46CE-A4EB-F4AB60011386}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/extensions/batsupport/msvc8/batsupport.vcproj b/extensions/batsupport/msvc8/batsupport.vcproj index 43e91d83..45c21f06 100644 --- a/extensions/batsupport/msvc8/batsupport.vcproj +++ b/extensions/batsupport/msvc8/batsupport.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="BatSupport" - ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" + ProjectGUID="{E2FDA25A-3F36-46ce-A4EB-F4AB60011386}" RootNamespace="BatSupport" Keyword="Win32Proj" > @@ -40,161 +40,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/extensions/batsupport/sdk/smsdk_config.h b/extensions/batsupport/sdk/smsdk_config.h new file mode 100644 index 00000000..a2af61bd --- /dev/null +++ b/extensions/batsupport/sdk/smsdk_config.h @@ -0,0 +1,48 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ + +/** + * @file smsdk_config.h + * @brief Contains macros for configuring basic extension information. + */ + +/* Basic information exposed publicly */ +#define SMEXT_CONF_NAME "BAT Support" +#define SMEXT_CONF_DESCRIPTION "Adds support for BAT's AdminInterface" +#define SMEXT_CONF_VERSION "1.0.0.0" +#define SMEXT_CONF_AUTHOR "AlliedModders" +#define SMEXT_CONF_URL "http://www.sourcemod.net/" +#define SMEXT_CONF_LOGTAG "BATSUPPORT" +#define SMEXT_CONF_LICENSE "GPL" +#define SMEXT_CONF_DATESTRING __DATE__ + +/** + * @brief Exposes plugin's main interface. + */ +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; + +/** + * @brief Sets whether or not this plugin required Metamod. + * NOTE: Uncomment to enable, comment to disable. + */ +#define SMEXT_CONF_METAMOD + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/bintools/smsdk_ext.cpp b/extensions/batsupport/sdk/smsdk_ext.cpp similarity index 84% rename from extensions/bintools/smsdk_ext.cpp rename to extensions/batsupport/sdk/smsdk_ext.cpp index ed2de4ae..d7d3ba02 100644 --- a/extensions/bintools/smsdk_ext.cpp +++ b/extensions/batsupport/sdk/smsdk_ext.cpp @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -44,7 +46,7 @@ SDKExtension::SDKExtension() #endif } -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late) +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) { g_pShareSys = sys; myself = me; @@ -56,7 +58,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, { if (error) { - snprintf(error, err_max, "Metamod attach failed"); + snprintf(error, maxlength, "Metamod attach failed"); } return false; } @@ -66,7 +68,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, SM_GET_IFACE(SOURCEMOD, g_pSM); SM_GET_IFACE(FORWARDMANAGER, g_pForwards); - if (SDK_OnLoad(error, err_max, late)) + if (SDK_OnLoad(error, maxlength, late)) { #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; @@ -142,7 +144,7 @@ const char *SDKExtension::GetExtensionURL() return SMEXT_CONF_URL; } -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late) { return true; } @@ -287,17 +289,17 @@ const char *SDKExtension::GetVersion() return GetExtensionVerString(); } -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) { return true; } -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength) { return true; } -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength) { return true; } @@ -330,4 +332,3 @@ void operator delete[](void * ptr) free(ptr); } #endif - diff --git a/public/sample_ext/smsdk_ext.h b/extensions/batsupport/sdk/smsdk_ext.h similarity index 73% rename from public/sample_ext/smsdk_ext.h rename to extensions/batsupport/sdk/smsdk_ext.h index d763460e..808e9759 100644 --- a/public/sample_ext/smsdk_ext.h +++ b/extensions/batsupport/sdk/smsdk_ext.h @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -52,11 +54,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -78,21 +80,21 @@ public: * @brief Called when Metamod is attached, before the extension version is called. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @param late Whether or not Metamod considers this a late load. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); /** * @brief Called when Metamod is detaching, after the extension version is called. * NOTE: By default this is blocked unless sent from SourceMod. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); /** * @brief Called when Metamod's pause state is changing. @@ -100,14 +102,14 @@ public: * * @param paused Pause state being set. * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif -public: //IExtensionInterface - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late); +public: // IExtensionInterface + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late); virtual void OnExtensionUnload(); virtual void OnExtensionsAllLoaded(); @@ -136,9 +138,9 @@ public: //IExtensionInterface /** Returns date string */ virtual const char *GetExtensionDateString(); #if defined SMEXT_CONF_METAMOD -public: //ISmmPlugin +public: // ISmmPlugin /** Called when the extension is attached to Metamod. */ - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); /** Returns the author to MM */ virtual const char *GetAuthor(); /** Returns the name to MM */ @@ -185,12 +187,27 @@ extern IServerGameDLL *gamedll; /** Creates a SourceMod interface macro pair */ #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION /** Automates retrieving SourceMod interfaces */ -#define SM_GET_IFACE(prefix,addr) \ - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \ - if (error) { \ - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ - } \ - return false; \ +#define SM_GET_IFACE(prefix, addr) \ + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */ +#define SM_GET_LATE_IFACE(prefix, addr) \ + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr) +/** Validates a SourceMod interface pointer */ +#define SM_CHECK_IFACE(prefix, addr) \ + if (!addr) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ } -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/extensions/batsupport/smsdk_config.h b/extensions/batsupport/smsdk_config.h deleted file mode 100644 index 0454a055..00000000 --- a/extensions/batsupport/smsdk_config.h +++ /dev/null @@ -1,33 +0,0 @@ -// vim: set ts=4 : -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ - -/** - * @file smsdk_config.h - * @brief Contains macros for configuring basic extension information. - */ - -/* Basic information exposed publically */ -#define SMEXT_CONF_NAME "BAT Support" -#define SMEXT_CONF_DESCRIPTION "Adds support for BAT's AdminInterface" -#define SMEXT_CONF_VERSION "1.0.0.0" -#define SMEXT_CONF_AUTHOR "AlliedModders" -#define SMEXT_CONF_URL "http://www.sourcemod.net/" -#define SMEXT_CONF_LOGTAG "BATSUPPORT" -#define SMEXT_CONF_LICENSE "GPL" -#define SMEXT_CONF_DATESTRING __DATE__ - -/** - * @brief Exposes plugin's main interface. - */ -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; - -/** - * @brief Sets whether or not this plugin required Metamod. - * NOTE: Uncomment to enable, comment to disable. - * NOTE: This is enabled automatically if a Metamod build is chosen in - * the Visual Studio project. - */ -#define SMEXT_CONF_METAMOD - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/bintools/CallMaker.cpp b/extensions/bintools/CallMaker.cpp index c8941e7e..ba1a814a 100644 --- a/extensions/bintools/CallMaker.cpp +++ b/extensions/bintools/CallMaker.cpp @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/CallMaker.h b/extensions/bintools/CallMaker.h index d142a683..a7e31ca8 100644 --- a/extensions/bintools/CallMaker.h +++ b/extensions/bintools/CallMaker.h @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/CallWrapper.cpp b/extensions/bintools/CallWrapper.cpp index 15018160..8437a643 100644 --- a/extensions/bintools/CallWrapper.cpp +++ b/extensions/bintools/CallWrapper.cpp @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/CallWrapper.h b/extensions/bintools/CallWrapper.h index 3e7b2d2e..df880b23 100644 --- a/extensions/bintools/CallWrapper.h +++ b/extensions/bintools/CallWrapper.h @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/Makefile b/extensions/bintools/Makefile index f87eb55a..6272ffe0 100644 --- a/extensions/bintools/Makefile +++ b/extensions/bintools/Makefile @@ -14,7 +14,7 @@ PROJECT = bintools #Uncomment for SourceMM-enabled extensions #LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -OBJECTS = extension.cpp smsdk_ext.cpp jit_call.cpp CallWrapper.cpp CallMaker.cpp +OBJECTS = sdk/smsdk_ext.cpp extension.cpp jit_call.cpp CallWrapper.cpp CallMaker.cpp ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -32,7 +32,7 @@ SMM_TRUNK = $(SOURCEMM)/trunk LINK = $(LINK_HL2) -static-libgcc -INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \ -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions -I$(SMSDK)/public/jit \ -I$(SMSDK)/public/jit/x86 @@ -66,11 +66,10 @@ $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< all: - mkdir -p $(BIN_DIR) + mkdir -p $(BIN_DIR)/sdk ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so $(MAKE) extension - rm -rf $(BINARY) extension: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -82,7 +81,8 @@ default: all clean: rm -rf Release/*.o + rm -rf Release/sdk/*.o rm -rf Release/$(BINARY) rm -rf Debug/*.o + rm -rf Debug/sdk/*.o rm -rf Debug/$(BINARY) - diff --git a/extensions/bintools/extension.cpp b/extensions/bintools/extension.cpp index e1786feb..2bac45a0 100644 --- a/extensions/bintools/extension.cpp +++ b/extensions/bintools/extension.cpp @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ @@ -21,16 +26,16 @@ /** * @file extension.cpp - * @brief Implement extension code here. + * @brief Implements BinTools extension code. */ -BinTools g_BinTools; /**< Global singleton for your extension's main interface */ +BinTools g_BinTools; /**< Global singleton for extension's main interface */ CallMaker g_CallMaker; ISourcePawnEngine *g_SPEngine; SMEXT_LINK(&g_BinTools); -bool BinTools::SDK_OnLoad(char *error, size_t err_max, bool late) +bool BinTools::SDK_OnLoad(char *error, size_t maxlength, bool late) { g_SPEngine = g_pSM->GetScriptingEngine(); g_pShareSys->AddInterface(myself, &g_CallMaker); diff --git a/extensions/bintools/extension.h b/extensions/bintools/extension.h index 148e1e16..0b875fdc 100644 --- a/extensions/bintools/extension.h +++ b/extensions/bintools/extension.h @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ @@ -24,12 +29,11 @@ * @brief Sample extension code header. */ - #include "smsdk_ext.h" /** - * @brief Sample implementation of the SDK Extension. + * @brief Implementation of the BinTools extension. * Note: Uncomment one of the pre-defined virtual functions in order to use it. */ class BinTools : public SDKExtension @@ -39,11 +43,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -65,22 +69,45 @@ public: * @brief this is called when Core wants to know if your extension is working. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @return True if working, false otherwise. */ - //virtual void QueryRunning(char *error, size_t maxlength); + //virtual bool QueryRunning(char *error, size_t maxlength); public: #if defined SMEXT_CONF_METAMOD /** - * Read smext_base.h for documentation on these. + * @brief Called when Metamod is attached, before the extension version is called. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @param late Whether or not Metamod considers this a late load. + * @return True to succeed, false to fail. */ + //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); - //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); - //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); - //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + /** + * @brief Called when Metamod is detaching, after the extension version is called. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); + + /** + * @brief Called when Metamod's pause state is changing. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param paused Pause state being set. + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif }; extern ISourcePawnEngine *g_SPEngine; -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/bintools/jit_call.cpp b/extensions/bintools/jit_call.cpp index 28066981..00fa78e7 100644 --- a/extensions/bintools/jit_call.cpp +++ b/extensions/bintools/jit_call.cpp @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/jit_call.h b/extensions/bintools/jit_call.h index 2534600e..83bbbee4 100644 --- a/extensions/bintools/jit_call.h +++ b/extensions/bintools/jit_call.h @@ -1,17 +1,22 @@ /** * vim: set ts=4 : * =============================================================== - * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. - * All rights reserved. + * SourceMod BinTools Extension + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be - * used or modified under the Terms and Conditions of its License Agreement, - * which is found in public/licenses/LICENSE.txt. As of this notice, derivative - * works must be licensed under the GNU General Public License (version 2 or - * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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. * - * To view the latest information, see: http://www.sourcemod.net/license.php + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Version: $Id$ */ diff --git a/extensions/bintools/msvc8/bintools.sln b/extensions/bintools/msvc8/bintools.sln index 44048bb2..61d64d98 100644 --- a/extensions/bintools/msvc8/bintools.sln +++ b/extensions/bintools/msvc8/bintools.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "bintools.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bintools", "bintools.vcproj", "{E38F65D9-74B2-4373-B46A-DBB76F579F98}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,10 +9,10 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 + {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.ActiveCfg = Debug|Win32 + {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Debug|Win32.Build.0 = Debug|Win32 + {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.ActiveCfg = Release|Win32 + {E38F65D9-74B2-4373-B46A-DBB76F579F98}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/extensions/bintools/msvc8/bintools.vcproj b/extensions/bintools/msvc8/bintools.vcproj index bc4a9c58..f069e273 100644 --- a/extensions/bintools/msvc8/bintools.vcproj +++ b/extensions/bintools/msvc8/bintools.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="bintools" - ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" + ProjectGUID="{E38F65D9-74B2-4373-B46A-DBB76F579F98}" RootNamespace="bintools" Keyword="Win32Proj" > @@ -40,7 +40,7 @@ - - - - - - + + + + + + + + + + + + diff --git a/extensions/bintools/sdk/smsdk_config.h b/extensions/bintools/sdk/smsdk_config.h new file mode 100644 index 00000000..af26a061 --- /dev/null +++ b/extensions/bintools/sdk/smsdk_config.h @@ -0,0 +1,48 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ + +/** + * @file smsdk_config.h + * @brief Contains macros for configuring basic extension information. + */ + +/* Basic information exposed publicly */ +#define SMEXT_CONF_NAME "Sample Extension" +#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers" +#define SMEXT_CONF_VERSION "0.0.0.0" +#define SMEXT_CONF_AUTHOR "AlliedModders" +#define SMEXT_CONF_URL "http://www.sourcemod.net/" +#define SMEXT_CONF_LOGTAG "SAMPLE" +#define SMEXT_CONF_LICENSE "GPL" +#define SMEXT_CONF_DATESTRING __DATE__ + +/** + * @brief Exposes plugin's main interface. + */ +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; + +/** + * @brief Sets whether or not this plugin required Metamod. + * NOTE: Uncomment to enable, comment to disable. + */ +//#define SMEXT_CONF_METAMOD + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/public/sample_ext/smsdk_ext.cpp b/extensions/bintools/sdk/smsdk_ext.cpp similarity index 84% rename from public/sample_ext/smsdk_ext.cpp rename to extensions/bintools/sdk/smsdk_ext.cpp index ed2de4ae..d7d3ba02 100644 --- a/public/sample_ext/smsdk_ext.cpp +++ b/extensions/bintools/sdk/smsdk_ext.cpp @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -44,7 +46,7 @@ SDKExtension::SDKExtension() #endif } -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late) +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) { g_pShareSys = sys; myself = me; @@ -56,7 +58,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, { if (error) { - snprintf(error, err_max, "Metamod attach failed"); + snprintf(error, maxlength, "Metamod attach failed"); } return false; } @@ -66,7 +68,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, SM_GET_IFACE(SOURCEMOD, g_pSM); SM_GET_IFACE(FORWARDMANAGER, g_pForwards); - if (SDK_OnLoad(error, err_max, late)) + if (SDK_OnLoad(error, maxlength, late)) { #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; @@ -142,7 +144,7 @@ const char *SDKExtension::GetExtensionURL() return SMEXT_CONF_URL; } -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late) { return true; } @@ -287,17 +289,17 @@ const char *SDKExtension::GetVersion() return GetExtensionVerString(); } -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) { return true; } -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength) { return true; } -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength) { return true; } @@ -330,4 +332,3 @@ void operator delete[](void * ptr) free(ptr); } #endif - diff --git a/extensions/bintools/smsdk_ext.h b/extensions/bintools/sdk/smsdk_ext.h similarity index 73% rename from extensions/bintools/smsdk_ext.h rename to extensions/bintools/sdk/smsdk_ext.h index d763460e..808e9759 100644 --- a/extensions/bintools/smsdk_ext.h +++ b/extensions/bintools/sdk/smsdk_ext.h @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -52,11 +54,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -78,21 +80,21 @@ public: * @brief Called when Metamod is attached, before the extension version is called. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @param late Whether or not Metamod considers this a late load. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); /** * @brief Called when Metamod is detaching, after the extension version is called. * NOTE: By default this is blocked unless sent from SourceMod. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); /** * @brief Called when Metamod's pause state is changing. @@ -100,14 +102,14 @@ public: * * @param paused Pause state being set. * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif -public: //IExtensionInterface - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late); +public: // IExtensionInterface + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late); virtual void OnExtensionUnload(); virtual void OnExtensionsAllLoaded(); @@ -136,9 +138,9 @@ public: //IExtensionInterface /** Returns date string */ virtual const char *GetExtensionDateString(); #if defined SMEXT_CONF_METAMOD -public: //ISmmPlugin +public: // ISmmPlugin /** Called when the extension is attached to Metamod. */ - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); /** Returns the author to MM */ virtual const char *GetAuthor(); /** Returns the name to MM */ @@ -185,12 +187,27 @@ extern IServerGameDLL *gamedll; /** Creates a SourceMod interface macro pair */ #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION /** Automates retrieving SourceMod interfaces */ -#define SM_GET_IFACE(prefix,addr) \ - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \ - if (error) { \ - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ - } \ - return false; \ +#define SM_GET_IFACE(prefix, addr) \ + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */ +#define SM_GET_LATE_IFACE(prefix, addr) \ + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr) +/** Validates a SourceMod interface pointer */ +#define SM_CHECK_IFACE(prefix, addr) \ + if (!addr) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ } -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/extensions/bintools/smsdk_config.h b/extensions/bintools/smsdk_config.h deleted file mode 100644 index dfc8a925..00000000 --- a/extensions/bintools/smsdk_config.h +++ /dev/null @@ -1,33 +0,0 @@ -// vim: set ts=4 : -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ - -/** - * @file smsdk_config.h - * @brief Contains macros for configuring basic extension information. - */ - -/* Basic information exposed publically */ -#define SMEXT_CONF_NAME "Sample Extension" -#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers" -#define SMEXT_CONF_VERSION "0.0.0.0" -#define SMEXT_CONF_AUTHOR "AlliedModders" -#define SMEXT_CONF_URL "http://www.sourcemod.net/" -#define SMEXT_CONF_LOGTAG "SAMPLE" -#define SMEXT_CONF_LICENSE "GPL" -#define SMEXT_CONF_DATESTRING __DATE__ - -/** - * @brief Exposes plugin's main interface. - */ -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; - -/** - * @brief Sets whether or not this plugin required Metamod. - * NOTE: Uncomment to enable, comment to disable. - * NOTE: This is enabled automatically if a Metamod build is chosen in - * the Visual Studio project. - */ -//#define SMEXT_CONF_METAMOD - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/geoip/Makefile b/extensions/geoip/Makefile index 6323db70..b9a013f4 100644 --- a/extensions/geoip/Makefile +++ b/extensions/geoip/Makefile @@ -14,7 +14,7 @@ PROJECT = geoip #Uncomment for SourceMM-enabled extensions #LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -OBJECTS = extension.cpp smsdk_ext.cpp GeoIP.c +OBJECTS = sdk/smsdk_ext.cpp extension.cpp GeoIP.c ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -32,7 +32,7 @@ SMM_TRUNK = $(SOURCEMM)/trunk LINK = $(LINK_HL2) -static-libgcc -INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \ -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ @@ -60,7 +60,7 @@ endif BINARY = $(PROJECT).ext.so OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o) +OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< @@ -69,11 +69,10 @@ $(BIN_DIR)/%.o: %.c $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< all: - mkdir -p $(BIN_DIR) + mkdir -p $(BIN_DIR)/sdk ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so $(MAKE) extension - rm -rf $(BINARY) extension: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -85,7 +84,8 @@ default: all clean: rm -rf Release/*.o + rm -rf Release/sdk/*.o rm -rf Release/$(BINARY) rm -rf Debug/*.o + rm -rf Debug/sdk/*.o rm -rf Debug/$(BINARY) - diff --git a/extensions/geoip/extension.cpp b/extensions/geoip/extension.cpp index 0fb7b4a0..930289ca 100644 --- a/extensions/geoip/extension.cpp +++ b/extensions/geoip/extension.cpp @@ -1,5 +1,9 @@ /** - * GeoIP SourceMod Extension, (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod GeoIP Extension + * Copyright (C) 2004-2007 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 @@ -20,21 +24,25 @@ #include "extension.h" #include "GeoIP.h" +/** + * @file extension.cpp + * @brief Implement extension code here. + */ GeoIP_Extension g_GeoIP; GeoIP *gi = NULL; SMEXT_LINK(&g_GeoIP); -bool GeoIP_Extension::SDK_OnLoad(char *error, size_t err_max, bool late) +bool GeoIP_Extension::SDK_OnLoad(char *error, size_t maxlength, bool late) { - char path[PLATFORM_MAX_PATH+1]; + char path[PLATFORM_MAX_PATH]; g_pSM->BuildPath(Path_SM, path, sizeof(path), "configs/geoip/GeoIP.dat"); gi = GeoIP_open(path, GEOIP_MEMORY_CACHE); if (!gi) { - snprintf(error, err_max, "Failed to instantiate GeoIP!"); + snprintf(error, maxlength, "Failed to instantiate GeoIP!"); return false; } @@ -113,4 +121,3 @@ const sp_nativeinfo_t geoip_natives[] = {"GeoipCountry", sm_Geoip_Country}, {NULL, NULL}, }; - diff --git a/extensions/geoip/extension.h b/extensions/geoip/extension.h index 79e313d4..152c5256 100644 --- a/extensions/geoip/extension.h +++ b/extensions/geoip/extension.h @@ -1,5 +1,9 @@ /** - * GeoIP SourceMod Extension, (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod GeoIP Extension + * Copyright (C) 2004-2007 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 @@ -20,12 +24,16 @@ #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +/** + * @file extension.h + * @brief GeoIP extension code header. + */ + #include "smsdk_ext.h" -#define GEOIPDATADIR "" /** - * @brief GeoIP implementation of the SDK Extension. + * @brief Implementation of the GeoIP extension. * Note: Uncomment one of the pre-defined virtual functions in order to use it. */ class GeoIP_Extension : public SDKExtension @@ -35,11 +43,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -61,22 +69,45 @@ public: * @brief this is called when Core wants to know if your extension is working. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @return True if working, false otherwise. */ - //virtual void QueryRunning(char *error, size_t maxlength); + //virtual bool QueryRunning(char *error, size_t maxlength); public: #if defined SMEXT_CONF_METAMOD /** - * Read smext_base.h for documentation on these. + * @brief Called when Metamod is attached, before the extension version is called. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @param late Whether or not Metamod considers this a late load. + * @return True to succeed, false to fail. */ + //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); - //virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); - //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); - //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + /** + * @brief Called when Metamod is detaching, after the extension version is called. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); + + /** + * @brief Called when Metamod's pause state is changing. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param paused Pause state being set. + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif }; extern const sp_nativeinfo_t geoip_natives[]; -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/geoip/msvc8/geoip.sln b/extensions/geoip/msvc8/geoip.sln index 62e8c591..2fb7770a 100644 --- a/extensions/geoip/msvc8/geoip.sln +++ b/extensions/geoip/msvc8/geoip.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geoip", "geoip.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geoip", "geoip.vcproj", "{698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,10 +9,10 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 + {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.ActiveCfg = Debug|Win32 + {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Debug|Win32.Build.0 = Debug|Win32 + {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.ActiveCfg = Release|Win32 + {698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/extensions/geoip/msvc8/geoip.vcproj b/extensions/geoip/msvc8/geoip.vcproj index 313793a6..cac3e583 100644 --- a/extensions/geoip/msvc8/geoip.vcproj +++ b/extensions/geoip/msvc8/geoip.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="geoip" - ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}" + ProjectGUID="{698EAEE7-0EFC-4017-9B88-ECCAAF42FD5F}" RootNamespace="geoip" Keyword="Win32Proj" > @@ -40,7 +40,7 @@ - - - - - - @@ -229,6 +217,22 @@ > + + + + + + + + diff --git a/extensions/geoip/sdk/smsdk_config.h b/extensions/geoip/sdk/smsdk_config.h new file mode 100644 index 00000000..09025e28 --- /dev/null +++ b/extensions/geoip/sdk/smsdk_config.h @@ -0,0 +1,49 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#include "svn_version.h" + +/** + * @file smsdk_config.h + * @brief Contains macros for configuring basic extension information. + */ + +/* Basic information exposed publicly */ +#define SMEXT_CONF_NAME "GeoIP" +#define SMEXT_CONF_DESCRIPTION "NO IDEA WHAT THIS MODULE DOES" //:TODO: +#define SMEXT_CONF_VERSION SVN_FULL_VERSION +#define SMEXT_CONF_AUTHOR "AlliedModders" +#define SMEXT_CONF_URL "http://www.sourcemod.net/" +#define SMEXT_CONF_LOGTAG "GEOIP" +#define SMEXT_CONF_LICENSE "GPL" +#define SMEXT_CONF_DATESTRING __DATE__ + +/** + * @brief Exposes plugin's main interface. + */ +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; + +/** + * @brief Sets whether or not this plugin required Metamod. + * NOTE: Uncomment to enable, comment to disable. + */ +//#define SMEXT_CONF_METAMOD + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/geoip/sdk/smsdk_ext.cpp b/extensions/geoip/sdk/smsdk_ext.cpp new file mode 100644 index 00000000..02eb27ee --- /dev/null +++ b/extensions/geoip/sdk/smsdk_ext.cpp @@ -0,0 +1,334 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#include +#include +#include "smsdk_ext.h" + +/** + * @file smsdk_ext.cpp + * @brief Contains wrappers for making Extensions easier to write. + */ + +IShareSys *g_pShareSys = NULL; /**< Share system */ +IExtension *myself = NULL; /**< Ourself */ +IHandleSys *g_pHandleSys = NULL; /**< Handle system */ +ISourceMod *g_pSM = NULL; /**< SourceMod helpers */ +IForwardManager *g_pForwards = NULL; /**< Forward system */ + +/** Exports the main interface */ +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() +{ + return g_pExtensionIface; +} + +SDKExtension::SDKExtension() +{ +#if defined SMEXT_CONF_METAMOD + m_SourceMMLoaded = false; + m_WeAreUnloaded = false; + m_WeGotPauseChange = false; +#endif +} + +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) +{ + g_pShareSys = sys; + myself = me; + +#if defined SMEXT_CONF_METAMOD + m_WeAreUnloaded = true; + + if (!m_SourceMMLoaded) + { + if (error) + { + snprintf(error, maxlength, "Metamod attach failed"); + } + return false; + } +#endif + + SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys); + SM_GET_IFACE(SOURCEMOD, g_pSM); + SM_GET_IFACE(FORWARDMANAGER, g_pForwards); + + if (SDK_OnLoad(error, maxlength, late)) + { +#if defined SMEXT_CONF_METAMOD + m_WeAreUnloaded = true; +#endif + return true; + } + + return false; +} + +bool SDKExtension::IsMetamodExtension() +{ +#if defined SMEXT_CONF_METAMOD + return true; +#else + return false; +#endif +} + +void SDKExtension::OnExtensionPauseChange(bool state) +{ +#if defined SMEXT_CONF_METAMOD + m_WeGotPauseChange = true; +#endif + SDK_OnPauseChange(state); +} + +void SDKExtension::OnExtensionsAllLoaded() +{ + SDK_OnAllLoaded(); +} + +void SDKExtension::OnExtensionUnload() +{ +#if defined SMEXT_CONF_METAMOD + m_WeAreUnloaded = true; +#endif + SDK_OnUnload(); +} + +const char *SDKExtension::GetExtensionAuthor() +{ + return SMEXT_CONF_AUTHOR; +} + +const char *SDKExtension::GetExtensionDateString() +{ + return SMEXT_CONF_DATESTRING; +} + +const char *SDKExtension::GetExtensionDescription() +{ + return SMEXT_CONF_DESCRIPTION; +} + +const char *SDKExtension::GetExtensionVerString() +{ + return SMEXT_CONF_VERSION; +} + +const char *SDKExtension::GetExtensionName() +{ + return SMEXT_CONF_NAME; +} + +const char *SDKExtension::GetExtensionTag() +{ + return SMEXT_CONF_LOGTAG; +} + +const char *SDKExtension::GetExtensionURL() +{ + return SMEXT_CONF_URL; +} + +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late) +{ + return true; +} + +void SDKExtension::SDK_OnUnload() +{ +} + +void SDKExtension::SDK_OnPauseChange(bool paused) +{ +} + +void SDKExtension::SDK_OnAllLoaded() +{ +} + +#if defined SMEXT_CONF_METAMOD + +PluginId g_PLID = 0; /**< Metamod plugin ID */ +ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */ +SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */ +ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */ + +IVEngineServer *engine = NULL; /**< IVEngineServer pointer */ +IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ + +/** Exposes the extension to Metamod */ +SMM_API void *PL_EXPOSURE(const char *name, int *code) +{ + if (name && !strcmp(name, PLAPI_NAME)) + { + if (code) + { + *code = IFACE_OK; + } + return static_cast(g_pExtensionIface); + } + + if (code) + { + *code = IFACE_FAILED; + } + + return NULL; +} + +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) +{ + PLUGIN_SAVEVARS(); + + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); + + m_SourceMMLoaded = true; + + return SDK_OnMetamodLoad(ismm, error, maxlen, late); +} + +bool SDKExtension::Unload(char *error, size_t maxlen) +{ + if (!m_WeAreUnloaded) + { + if (error) + { + snprintf(error, maxlen, "This extension must be unloaded by SourceMod."); + } + return false; + } + + return SDK_OnMetamodUnload(error, maxlen); +} + +bool SDKExtension::Pause(char *error, size_t maxlength) +{ + if (!m_WeGotPauseChange) + { + if (error) + { + snprintf(error, maxlen, "This extension must be paused by SourceMod."); + } + return false; + } + + m_WeGotPauseChange = false; + + return SDK_OnMetamodPauseChange(true, error, maxlen); +} + +bool SDKExtension::Unpause(char *error, size_t maxlen) +{ + if (!m_WeGotPauseChange) + { + if (error) + { + snprintf(error, maxlen, "This extension must be unpaused by SourceMod."); + } + return false; + } + + m_WeGotPauseChange = false; + + return SDK_OnMetamodPauseChange(false, error, maxlen); +} + +const char *SDKExtension::GetAuthor() +{ + return GetExtensionAuthor(); +} + +const char *SDKExtension::GetDate() +{ + return GetExtensionDateString(); +} + +const char *SDKExtension::GetDescription() +{ + return GetExtensionDescription(); +} + +const char *SDKExtension::GetLicense() +{ + return SMEXT_CONF_LICENSE; +} + +const char *SDKExtension::GetLogTag() +{ + return GetExtensionTag(); +} + +const char *SDKExtension::GetName() +{ + return GetExtensionName(); +} + +const char *SDKExtension::GetURL() +{ + return GetExtensionURL(); +} + +const char *SDKExtension::GetVersion() +{ + return GetExtensionVerString(); +} + +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) +{ + return true; +} + +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength) +{ + return true; +} + +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength) +{ + return true; +} + +#endif + +/* Overload a few things to prevent libstdc++ linking */ +#if defined __linux__ +extern "C" void __cxa_pure_virtual(void) +{ +} + +void *operator new(size_t size) +{ + return malloc(size); +} + +void *operator new[](size_t size) +{ + return malloc(size); +} + +void operator delete(void *ptr) +{ + free(ptr); +} + +void operator delete[](void * ptr) +{ + free(ptr); +} +#endif diff --git a/extensions/batsupport/smsdk_ext.h b/extensions/geoip/sdk/smsdk_ext.h similarity index 72% rename from extensions/batsupport/smsdk_ext.h rename to extensions/geoip/sdk/smsdk_ext.h index 8d23c32e..808e9759 100644 --- a/extensions/batsupport/smsdk_ext.h +++ b/extensions/geoip/sdk/smsdk_ext.h @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -52,11 +54,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -78,21 +80,21 @@ public: * @brief Called when Metamod is attached, before the extension version is called. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @param late Whether or not Metamod considers this a late load. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); /** * @brief Called when Metamod is detaching, after the extension version is called. * NOTE: By default this is blocked unless sent from SourceMod. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); /** * @brief Called when Metamod's pause state is changing. @@ -100,14 +102,14 @@ public: * * @param paused Pause state being set. * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif -public: //IExtensionInterface - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late); +public: // IExtensionInterface + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late); virtual void OnExtensionUnload(); virtual void OnExtensionsAllLoaded(); @@ -136,9 +138,9 @@ public: //IExtensionInterface /** Returns date string */ virtual const char *GetExtensionDateString(); #if defined SMEXT_CONF_METAMOD -public: //ISmmPlugin +public: // ISmmPlugin /** Called when the extension is attached to Metamod. */ - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); /** Returns the author to MM */ virtual const char *GetAuthor(); /** Returns the name to MM */ @@ -185,12 +187,27 @@ extern IServerGameDLL *gamedll; /** Creates a SourceMod interface macro pair */ #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION /** Automates retrieving SourceMod interfaces */ -#define SM_GET_IFACE(prefix,addr) \ - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \ - if (error) { \ - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ - } \ - return false; \ +#define SM_GET_IFACE(prefix, addr) \ + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */ +#define SM_GET_LATE_IFACE(prefix, addr) \ + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr) +/** Validates a SourceMod interface pointer */ +#define SM_CHECK_IFACE(prefix, addr) \ + if (!addr) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ } -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/extensions/geoip/smsdk_config.h b/extensions/geoip/smsdk_config.h deleted file mode 100644 index 8e77d2ac..00000000 --- a/extensions/geoip/smsdk_config.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * GeoIP SourceMod Extension, (C)2007 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ - -#include "svn_version.h" - -/* Basic information exposed publically */ -#define SMEXT_CONF_NAME "GeoIP" -#define SMEXT_CONF_DESCRIPTION "NO IDEA WHAT THIS MODULE DOES" //:TODO: -#define SMEXT_CONF_VERSION SVN_FULL_VERSION -#define SMEXT_CONF_AUTHOR "AlliedModders" -#define SMEXT_CONF_URL "http://www.sourcemod.net/" -#define SMEXT_CONF_LOGTAG "GEOIP" -#define SMEXT_CONF_LICENSE "GPL" -#define SMEXT_CONF_DATESTRING __DATE__ - -/** - * @brief Exposes plugin's main interface. - */ -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; - -/** - * @brief Sets whether or not this plugin required Metamod. - * NOTE: Uncomment to enable, comment to disable. - * NOTE: This is enabled automatically if a Metamod build is chosen in - * the Visual Studio project. - */ -//#define SMEXT_CONF_METAMOD - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/geoip/smsdk_ext.cpp b/extensions/geoip/smsdk_ext.cpp deleted file mode 100644 index 8dfd6db6..00000000 --- a/extensions/geoip/smsdk_ext.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/** - * =============================================================== - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. - * =============================================================== - * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php - * - * Version: $Id$ - */ - -#include -#include -#include "smsdk_ext.h" - -IShareSys *g_pShareSys = NULL; -IExtension *myself = NULL; -IHandleSys *g_pHandleSys = NULL; -ISourceMod *g_pSM = NULL; -IForwardManager *g_pForwards = NULL; - -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() -{ - return g_pExtensionIface; -} - -SDKExtension::SDKExtension() -{ -#if defined SMEXT_CONF_METAMOD - m_SourceMMLoaded = false; - m_WeAreUnloaded = false; - m_WeGotPauseChange = false; -#endif -} - -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late) -{ - g_pShareSys = sys; - myself = me; - -#if defined SMEXT_CONF_METAMOD - m_WeAreUnloaded = true; - - if (!m_SourceMMLoaded) - { - if (error) - { - snprintf(error, err_max, "Metamod attach failed"); - } - return false; - } -#endif - - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys); - SM_GET_IFACE(SOURCEMOD, g_pSM); - SM_GET_IFACE(FORWARDMANAGER, g_pForwards); - - if (SDK_OnLoad(error, err_max, late)) - { -#if defined SMEXT_CONF_METAMOD - m_WeAreUnloaded = true; -#endif - return true; - } - - return false; -} - -bool SDKExtension::IsMetamodExtension() -{ -#if defined SMEXT_CONF_METAMOD - return true; -#else - return false; -#endif -} - -void SDKExtension::OnExtensionPauseChange(bool state) -{ -#if defined SMEXT_CONF_METAMOD - m_WeGotPauseChange = true; -#endif - SDK_OnPauseChange(state); -} - -void SDKExtension::OnExtensionsAllLoaded() -{ - SDK_OnAllLoaded(); -} - -void SDKExtension::OnExtensionUnload() -{ -#if defined SMEXT_CONF_METAMOD - m_WeAreUnloaded = true; -#endif - SDK_OnUnload(); -} - -const char *SDKExtension::GetExtensionAuthor() -{ - return SMEXT_CONF_AUTHOR; -} - -const char *SDKExtension::GetExtensionDateString() -{ - return SMEXT_CONF_DATESTRING; -} - -const char *SDKExtension::GetExtensionDescription() -{ - return SMEXT_CONF_DESCRIPTION; -} - -const char *SDKExtension::GetExtensionVerString() -{ - return SMEXT_CONF_VERSION; -} - -const char *SDKExtension::GetExtensionName() -{ - return SMEXT_CONF_NAME; -} - -const char *SDKExtension::GetExtensionTag() -{ - return SMEXT_CONF_LOGTAG; -} - -const char *SDKExtension::GetExtensionURL() -{ - return SMEXT_CONF_URL; -} - -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late) -{ - return true; -} - -void SDKExtension::SDK_OnUnload() -{ -} - -void SDKExtension::SDK_OnPauseChange(bool paused) -{ -} - -void SDKExtension::SDK_OnAllLoaded() -{ -} - -#if defined SMEXT_CONF_METAMOD - -PluginId g_PLID = 0; -ISmmPlugin *g_PLAPI = NULL; -SourceHook::ISourceHook *g_SHPtr = NULL; -ISmmAPI *g_SMAPI = NULL; - -IVEngineServer *engine = NULL; -IServerGameDLL *gamedll = NULL; - -SMM_API void *PL_EXPOSURE(const char *name, int *code) -{ - if (name && !strcmp(name, PLAPI_NAME)) - { - if (code) - { - *code = IFACE_OK; - } - return static_cast(g_pExtensionIface); - } - - if (code) - { - *code = IFACE_FAILED; - } - - return NULL; -} - -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) -{ - PLUGIN_SAVEVARS(); - - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); - - m_SourceMMLoaded = true; - - return SDK_OnMetamodLoad(error, maxlen, late); -} - -bool SDKExtension::Unload(char *error, size_t maxlen) -{ - if (!m_WeAreUnloaded) - { - if (error) - { - snprintf(error, maxlen, "This extension must be unloaded by SourceMod."); - } - return false; - } - - return SDK_OnMetamodUnload(error, maxlen); -} - -bool SDKExtension::Pause(char *error, size_t maxlen) -{ - if (!m_WeGotPauseChange) - { - if (error) - { - snprintf(error, maxlen, "This extension must be paused by SourceMod."); - } - return false; - } - - m_WeGotPauseChange = false; - - return SDK_OnMetamodPauseChange(true, error, maxlen); -} - -bool SDKExtension::Unpause(char *error, size_t maxlen) -{ - if (!m_WeGotPauseChange) - { - if (error) - { - snprintf(error, maxlen, "This extension must be unpaused by SourceMod."); - } - return false; - } - - m_WeGotPauseChange = false; - - return SDK_OnMetamodPauseChange(false, error, maxlen); -} - -const char *SDKExtension::GetAuthor() -{ - return GetExtensionAuthor(); -} - -const char *SDKExtension::GetDate() -{ - return GetExtensionDateString(); -} - -const char *SDKExtension::GetDescription() -{ - return GetExtensionDescription(); -} - -const char *SDKExtension::GetLicense() -{ - return SMEXT_CONF_LICENSE; -} - -const char *SDKExtension::GetLogTag() -{ - return GetExtensionTag(); -} - -const char *SDKExtension::GetName() -{ - return GetExtensionName(); -} - -const char *SDKExtension::GetURL() -{ - return GetExtensionURL(); -} - -const char *SDKExtension::GetVersion() -{ - return GetExtensionVerString(); -} - -bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late) -{ - return true; -} - -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max) -{ - return true; -} - -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max) -{ - return true; -} - -#endif - -/* Overload a few things to prevent libstdc++ linking */ -#if defined __linux__ -extern "C" void __cxa_pure_virtual(void) -{ -} - -void *operator new(size_t size) -{ - return malloc(size); -} - -void *operator new[](size_t size) -{ - return malloc(size); -} - -void operator delete(void *ptr) -{ - free(ptr); -} - -void operator delete[](void * ptr) -{ - free(ptr); -} -#endif - diff --git a/extensions/geoip/smsdk_ext.h b/extensions/geoip/smsdk_ext.h deleted file mode 100644 index ce82828a..00000000 --- a/extensions/geoip/smsdk_ext.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * =============================================================== - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. - * =============================================================== - * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ - -#include "smsdk_config.h" -#include -#include -#include -#include -#include -#include - -#if defined SMEXT_CONF_METAMOD -#include -#include -#endif - -using namespace SourceMod; -using namespace SourcePawn; - -class SDKExtension : -#if defined SMEXT_CONF_METAMOD - public ISmmPlugin, -#endif - public IExtensionInterface -{ -public: - SDKExtension(); -public: - /** - * @brief This is called after the initial loading sequence has been processed. - * - * @param error Error message buffer. - * @param err_max Size of error message buffer. - * @param late Whether or not the module was loaded after map load. - * @return True to succeed loading, false to fail. - */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); - - /** - * @brief This is called right before the extension is unloaded. - */ - virtual void SDK_OnUnload(); - - /** - * @brief This is called once all known extensions have been loaded. - */ - virtual void SDK_OnAllLoaded(); - - /** - * @brief Called when the pause state is changed. - */ - virtual void SDK_OnPauseChange(bool paused); - -#if defined SMEXT_CONF_METAMOD - /** - * @brief Called when Metamod is attached, before the extension version is called. - * - * @param error Error buffer. - * @param err_max Maximum size of error buffer. - * @param late Whether or not Metamod considers this a late load. - * @return True to succeed, false to fail. - */ - virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); - - /** - * @brief Called when Metamod is detaching, after the extension version is called. - * NOTE: By default this is blocked unless sent from SourceMod. - * - * @param error Error buffer. - * @param err_max Maximum size of error buffer. - * @return True to succeed, false to fail. - */ - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); - - /** - * @brief Called when Metamod's pause state is changing. - * NOTE: By default this is blocked unless sent from SourceMod. - * - * @param paused Pause state being set. - * @param error Error buffer. - * @param err_max Maximum size of error buffer. - * @return True to succeed, false to fail. - */ - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); -#endif - -public: //IExtensionInterface - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late); - virtual void OnExtensionUnload(); - virtual void OnExtensionsAllLoaded(); - virtual bool IsMetamodExtension(); - virtual void OnExtensionPauseChange(bool state); - virtual const char *GetExtensionName(); - virtual const char *GetExtensionURL(); - virtual const char *GetExtensionTag(); - virtual const char *GetExtensionAuthor(); - virtual const char *GetExtensionVerString(); - virtual const char *GetExtensionDescription(); - virtual const char *GetExtensionDateString(); -#if defined SMEXT_CONF_METAMOD -public: //ISmmPlugin - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); - virtual const char *GetAuthor(); - virtual const char *GetName(); - virtual const char *GetDescription(); - virtual const char *GetURL(); - virtual const char *GetLicense(); - virtual const char *GetVersion(); - virtual const char *GetDate(); - virtual const char *GetLogTag(); - virtual bool Unload(char *error, size_t maxlen); - virtual bool Pause(char *error, size_t maxlen); - virtual bool Unpause(char *error, size_t maxlen); -private: - bool m_SourceMMLoaded; - bool m_WeAreUnloaded; - bool m_WeGotPauseChange; -#endif -}; - -extern SDKExtension *g_pExtensionIface; - -extern IShareSys *g_pShareSys; -extern IExtension *myself; -extern IHandleSys *g_pHandleSys; -extern ISourceMod *g_pSM; -extern IForwardManager *g_pForwards; - -#if defined SMEXT_CONF_METAMOD -PLUGIN_GLOBALVARS(); -extern IVEngineServer *engine; -extern IServerGameDLL *gamedll; -#endif - -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION -#define SM_GET_IFACE(prefix,addr) \ - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \ - if (error) { \ - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ - } \ - return false; \ - } - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/extensions/threader/Makefile b/extensions/threader/Makefile index a02f6076..af1b4dc2 100644 --- a/extensions/threader/Makefile +++ b/extensions/threader/Makefile @@ -14,7 +14,7 @@ PROJECT = threader #Uncomment for SourceMM-enabled extensions #LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -OBJECTS = extension.cpp smsdk_ext.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp \ +OBJECTS = sdk/smsdk_ext.cpp extension.cpp thread/BaseWorker.cpp thread/PosixThreads.cpp \ thread/ThreadWorker.cpp ############################################## @@ -33,7 +33,7 @@ SMM_TRUNK = $(SOURCEMM)/trunk LINK = $(LINK_HL2) -lpthread -static-libgcc -INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ +INCLUDE = -I. -I.. -Isdk -Ithread -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \ -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ @@ -61,20 +61,16 @@ endif BINARY = $(PROJECT).ext.so OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) -OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< -$(BIN_DIR)/%.o: %.c - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - all: + mkdir -p $(BIN_DIR)/sdk mkdir -p $(BIN_DIR)/thread ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so $(MAKE) extension - rm -rf $(BINARY) extension: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -86,7 +82,10 @@ default: all clean: rm -rf Release/*.o + rm -rf Release/sdk/*.o + rm -rf Release/thread/*.o rm -rf Release/$(BINARY) rm -rf Debug/*.o - rm -rf Debug/$(BINARY) - + rm -rf Debug/sdk/*.o + rm -rf Debug/thread/*.o + rm -rf Debug/$(BINARY) \ No newline at end of file diff --git a/extensions/threader/extension.cpp b/extensions/threader/extension.cpp index b8907529..5ddbb20b 100644 --- a/extensions/threader/extension.cpp +++ b/extensions/threader/extension.cpp @@ -1,5 +1,9 @@ /** - * SourceMod Threading Extension, (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threading Extension + * Copyright (C) 2004-2007 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 @@ -20,12 +24,17 @@ #include "extension.h" #include "thread/ThreadSupport.h" +/** + * @file extension.cpp + * @brief Implements threader extension code. + */ + Sample g_Sample; MainThreader g_Threader; SMEXT_LINK(&g_Sample); -bool Sample::SDK_OnLoad(char *error, size_t err_max, bool late) +bool Sample::SDK_OnLoad(char *error, size_t maxlength, bool late) { g_pShareSys->AddInterface(myself, &g_Threader); diff --git a/extensions/threader/extension.h b/extensions/threader/extension.h index f43a8ea1..450a4369 100644 --- a/extensions/threader/extension.h +++ b/extensions/threader/extension.h @@ -1,5 +1,9 @@ /** - * SourceMod Threading Extension, (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threading Extension + * Copyright (C) 2004-2007 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 @@ -20,10 +24,15 @@ #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +/** + * @file extension.h + * @brief Threader extension code header. + */ + #include "smsdk_ext.h" /** - * @brief Sample implementation of the SDK Extension. + * @brief Implementation of the threader extension. * Note: Uncomment one of the pre-defined virtual functions in order to use it. */ class Sample : public SDKExtension @@ -33,11 +42,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -59,20 +68,43 @@ public: * @brief this is called when Core wants to know if your extension is working. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @return True if working, false otherwise. */ - //virtual void QueryRunning(char *error, size_t maxlength); + //virtual bool QueryRunning(char *error, size_t maxlength); public: #if defined SMEXT_CONF_METAMOD /** - * Read smext_base.h for documentation on these. + * @brief Called when Metamod is attached, before the extension version is called. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @param late Whether or not Metamod considers this a late load. + * @return True to succeed, false to fail. */ + //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); - //virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); - //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); - //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + /** + * @brief Called when Metamod is detaching, after the extension version is called. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); + + /** + * @brief Called when Metamod's pause state is changing. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param paused Pause state being set. + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif }; -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/threader/msvc8/threader.vcproj b/extensions/threader/msvc8/threader.vcproj index 0d33669f..18b6b35b 100644 --- a/extensions/threader/msvc8/threader.vcproj +++ b/extensions/threader/msvc8/threader.vcproj @@ -40,7 +40,7 @@ + + + + diff --git a/extensions/threader/sdk/smsdk_config.h b/extensions/threader/sdk/smsdk_config.h new file mode 100644 index 00000000..1c743e7f --- /dev/null +++ b/extensions/threader/sdk/smsdk_config.h @@ -0,0 +1,49 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#include "svn_version.h" + +/** + * @file smsdk_config.h + * @brief Contains macros for configuring basic extension information. + */ + +/* Basic information exposed publicly */ +#define SMEXT_CONF_NAME "Threader" +#define SMEXT_CONF_DESCRIPTION "Provides threading to other modules" +#define SMEXT_CONF_VERSION SVN_FULL_VERSION +#define SMEXT_CONF_AUTHOR "AlliedModders" +#define SMEXT_CONF_URL "http://www.sourcemod.net/" +#define SMEXT_CONF_LOGTAG "THREADER" +#define SMEXT_CONF_LICENSE "GPL" +#define SMEXT_CONF_DATESTRING __DATE__ + +/** + * @brief Exposes plugin's main interface. + */ +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; + +/** + * @brief Sets whether or not this plugin required Metamod. + * NOTE: Uncomment to enable, comment to disable. + */ +//#define SMEXT_CONF_METAMOD + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/batsupport/smsdk_ext.cpp b/extensions/threader/sdk/smsdk_ext.cpp similarity index 82% rename from extensions/batsupport/smsdk_ext.cpp rename to extensions/threader/sdk/smsdk_ext.cpp index 2e060a7f..d7d3ba02 100644 --- a/extensions/batsupport/smsdk_ext.cpp +++ b/extensions/threader/sdk/smsdk_ext.cpp @@ -5,11 +5,13 @@ * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -44,7 +46,7 @@ SDKExtension::SDKExtension() #endif } -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late) +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) { g_pShareSys = sys; myself = me; @@ -56,7 +58,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, { if (error) { - snprintf(error, err_max, "Metamod attach failed"); + snprintf(error, maxlength, "Metamod attach failed"); } return false; } @@ -66,7 +68,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, SM_GET_IFACE(SOURCEMOD, g_pSM); SM_GET_IFACE(FORWARDMANAGER, g_pForwards); - if (SDK_OnLoad(error, err_max, late)) + if (SDK_OnLoad(error, maxlength, late)) { #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; @@ -142,7 +144,7 @@ const char *SDKExtension::GetExtensionURL() return SMEXT_CONF_URL; } -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late) { return true; } @@ -198,7 +200,7 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, m_SourceMMLoaded = true; - return SDK_OnMetamodLoad(error, maxlen, late); + return SDK_OnMetamodLoad(ismm, error, maxlen, late); } bool SDKExtension::Unload(char *error, size_t maxlen) @@ -287,17 +289,17 @@ const char *SDKExtension::GetVersion() return GetExtensionVerString(); } -bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) { return true; } -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength) { return true; } -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength) { return true; } @@ -330,4 +332,3 @@ void operator delete[](void * ptr) free(ptr); } #endif - diff --git a/extensions/threader/smsdk_ext.h b/extensions/threader/sdk/smsdk_ext.h similarity index 56% rename from extensions/threader/smsdk_ext.h rename to extensions/threader/sdk/smsdk_ext.h index ce82828a..808e9759 100644 --- a/extensions/threader/smsdk_ext.h +++ b/extensions/threader/sdk/smsdk_ext.h @@ -1,13 +1,17 @@ /** + * vim: set ts=4 : * =============================================================== - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -15,6 +19,11 @@ #ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ #define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +/** + * @file smsdk_ext.h + * @brief Contains wrappers for making Extensions easier to write. + */ + #include "smsdk_config.h" #include #include @@ -38,17 +47,18 @@ class SDKExtension : public IExtensionInterface { public: + /** Constructor */ SDKExtension(); public: /** * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -70,21 +80,21 @@ public: * @brief Called when Metamod is attached, before the extension version is called. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @param late Whether or not Metamod considers this a late load. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late); + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); /** * @brief Called when Metamod is detaching, after the extension version is called. * NOTE: By default this is blocked unless sent from SourceMod. * * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); /** * @brief Called when Metamod's pause state is changing. @@ -92,38 +102,66 @@ public: * * @param paused Pause state being set. * @param error Error buffer. - * @param err_max Maximum size of error buffer. + * @param maxlength Maximum size of error buffer. * @return True to succeed, false to fail. */ - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif -public: //IExtensionInterface - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late); +public: // IExtensionInterface + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late); virtual void OnExtensionUnload(); virtual void OnExtensionsAllLoaded(); + + /** Returns whether or not this is a Metamod-based extension */ virtual bool IsMetamodExtension(); + + /** + * @brief Called when the pause state changes. + * + * @param state True if being paused, false if being unpaused. + */ virtual void OnExtensionPauseChange(bool state); + + /** Returns name */ virtual const char *GetExtensionName(); + /** Returns URL */ virtual const char *GetExtensionURL(); + /** Returns log tag */ virtual const char *GetExtensionTag(); + /** Returns author */ virtual const char *GetExtensionAuthor(); + /** Returns version string */ virtual const char *GetExtensionVerString(); + /** Returns description string */ virtual const char *GetExtensionDescription(); + /** Returns date string */ virtual const char *GetExtensionDateString(); #if defined SMEXT_CONF_METAMOD -public: //ISmmPlugin - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); +public: // ISmmPlugin + /** Called when the extension is attached to Metamod. */ + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); + /** Returns the author to MM */ virtual const char *GetAuthor(); + /** Returns the name to MM */ virtual const char *GetName(); + /** Returns the description to MM */ virtual const char *GetDescription(); + /** Returns the URL to MM */ virtual const char *GetURL(); + /** Returns the license to MM */ virtual const char *GetLicense(); + /** Returns the version string to MM */ virtual const char *GetVersion(); + /** Returns the date string to MM */ virtual const char *GetDate(); + /** Returns the logtag to MM */ virtual const char *GetLogTag(); + /** Called on unload */ virtual bool Unload(char *error, size_t maxlen); + /** Called on pause */ virtual bool Pause(char *error, size_t maxlen); + /** Called on unpause */ virtual bool Unpause(char *error, size_t maxlen); private: bool m_SourceMMLoaded; @@ -146,13 +184,30 @@ extern IVEngineServer *engine; extern IServerGameDLL *gamedll; #endif +/** Creates a SourceMod interface macro pair */ #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION -#define SM_GET_IFACE(prefix,addr) \ - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \ - if (error) { \ - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ - } \ - return false; \ +/** Automates retrieving SourceMod interfaces */ +#define SM_GET_IFACE(prefix, addr) \ + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */ +#define SM_GET_LATE_IFACE(prefix, addr) \ + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr) +/** Validates a SourceMod interface pointer */ +#define SM_CHECK_IFACE(prefix, addr) \ + if (!addr) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ } -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/extensions/threader/smsdk_config.h b/extensions/threader/smsdk_config.h deleted file mode 100644 index bd488494..00000000 --- a/extensions/threader/smsdk_config.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * SourceMod Threading Extension, (C)2007 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Version: $Id$ - */ -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ - -#include "svn_version.h" - -/* Basic information exposed publically */ -#define SMEXT_CONF_NAME "Threader" -#define SMEXT_CONF_DESCRIPTION "Provides threading to other modules" -#define SMEXT_CONF_VERSION SVN_FULL_VERSION -#define SMEXT_CONF_AUTHOR "AlliedModders" -#define SMEXT_CONF_URL "http://www.sourcemod.net/" -#define SMEXT_CONF_LOGTAG "THREADER" -#define SMEXT_CONF_LICENSE "GPL" -#define SMEXT_CONF_DATESTRING __DATE__ - -/** - * @brief Exposes plugin's main interface. - */ -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; - -/** - * @brief Sets whether or not this plugin required Metamod. - * NOTE: Uncomment to enable, comment to disable. - * NOTE: This is enabled automatically if a Metamod build is chosen in - * the Visual Studio project. - */ -//#define SMEXT_CONF_METAMOD - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/threader/thread/BaseWorker.cpp b/extensions/threader/thread/BaseWorker.cpp index e2881c9e..5f632875 100644 --- a/extensions/threader/thread/BaseWorker.cpp +++ b/extensions/threader/thread/BaseWorker.cpp @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/BaseWorker.h b/extensions/threader/thread/BaseWorker.h index 127e8259..65e875a2 100644 --- a/extensions/threader/thread/BaseWorker.h +++ b/extensions/threader/thread/BaseWorker.h @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/PosixThreads.cpp b/extensions/threader/thread/PosixThreads.cpp index 24e8e5ef..b2a30aca 100644 --- a/extensions/threader/thread/PosixThreads.cpp +++ b/extensions/threader/thread/PosixThreads.cpp @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 @@ -295,4 +299,3 @@ void PosixThreader::PosixEventSignal::DestroyThis() { delete this; } - diff --git a/extensions/threader/thread/PosixThreads.h b/extensions/threader/thread/PosixThreads.h index f27b4f27..efa4248a 100644 --- a/extensions/threader/thread/PosixThreads.h +++ b/extensions/threader/thread/PosixThreads.h @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/ThreadSupport.h b/extensions/threader/thread/ThreadSupport.h index f36f6e57..f87cf548 100644 --- a/extensions/threader/thread/ThreadSupport.h +++ b/extensions/threader/thread/ThreadSupport.h @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/ThreadWorker.cpp b/extensions/threader/thread/ThreadWorker.cpp index 7e745e91..32e2e757 100644 --- a/extensions/threader/thread/ThreadWorker.cpp +++ b/extensions/threader/thread/ThreadWorker.cpp @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/ThreadWorker.h b/extensions/threader/thread/ThreadWorker.h index c01a9f39..bdf2e949 100644 --- a/extensions/threader/thread/ThreadWorker.h +++ b/extensions/threader/thread/ThreadWorker.h @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/extensions/threader/thread/WinThreads.cpp b/extensions/threader/thread/WinThreads.cpp index 25c335b2..9798e6db 100644 --- a/extensions/threader/thread/WinThreads.cpp +++ b/extensions/threader/thread/WinThreads.cpp @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 @@ -321,4 +325,3 @@ void WinThreader::WinEvent::DestroyThis() { delete this; } - diff --git a/extensions/threader/thread/WinThreads.h b/extensions/threader/thread/WinThreads.h index fd11b932..a5fa4a25 100644 --- a/extensions/threader/thread/WinThreads.h +++ b/extensions/threader/thread/WinThreads.h @@ -1,5 +1,9 @@ /** - * SourceMod Threader API (C)2007 AlliedModders LLC. All rights reserved. + * vim: set ts=4 : + * =============================================================== + * SourceMod Threader API + * Copyright (C) 2004-2007 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 diff --git a/modules.versions b/modules.versions index a0d7008c..d1197ce5 100644 --- a/modules.versions +++ b/modules.versions @@ -26,4 +26,4 @@ out = svn_version.h [threader] folder = extensions/threader in = svn_version.tpl -out = svn_version.h \ No newline at end of file +out = svn_version.h diff --git a/public/sample_ext/Makefile b/public/sample_ext/Makefile index e65ffeb1..8c735d7d 100644 --- a/public/sample_ext/Makefile +++ b/public/sample_ext/Makefile @@ -14,7 +14,7 @@ PROJECT = sample #Uncomment for SourceMM-enabled extensions #LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -OBJECTS = extension.cpp smsdk_ext.cpp +OBJECTS = sdk/smsdk_ext.cpp extension.cpp ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -32,7 +32,7 @@ SMM_TRUNK = $(SOURCEMM)/trunk LINK = $(LINK_HL2) -static-libgcc -INCLUDE = -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \ -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ @@ -65,11 +65,10 @@ $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< all: - mkdir -p $(BIN_DIR) + mkdir -p $(BIN_DIR)/sdk ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so $(MAKE) extension - rm -rf $(BINARY) extension: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -81,7 +80,8 @@ default: all clean: rm -rf Release/*.o + rm -rf Release/sdk/*.o rm -rf Release/$(BINARY) rm -rf Debug/*.o + rm -rf Debug/sdk/*.o rm -rf Debug/$(BINARY) - diff --git a/public/sample_ext/extension.cpp b/public/sample_ext/extension.cpp index dd6b36b7..8c7db16c 100644 --- a/public/sample_ext/extension.cpp +++ b/public/sample_ext/extension.cpp @@ -1,4 +1,26 @@ -// vim: set ts=4 : +/** + * vim: set ts=4 : + * =============================================================== + * Sample SourceMod Extension + * Copyright (C) 2004-2007 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Version: $Id$ + */ + #include "extension.h" /** @@ -6,7 +28,6 @@ * @brief Implement extension code here. */ -Sample g_Sample; /**< Global singleton for your extension's main interface */ +Sample g_Sample; /**< Global singleton for extension's main interface */ SMEXT_LINK(&g_Sample); - diff --git a/public/sample_ext/extension.h b/public/sample_ext/extension.h index e88b3494..a1f11ebb 100644 --- a/public/sample_ext/extension.h +++ b/public/sample_ext/extension.h @@ -1,4 +1,26 @@ -// vim: set ts=4 : +/** + * vim: set ts=4 : + * =============================================================== + * Sample SourceMod Extension + * Copyright (C) 2004-2007 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Version: $Id$ + */ + #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ @@ -7,7 +29,6 @@ * @brief Sample extension code header. */ - #include "smsdk_ext.h" @@ -22,11 +43,11 @@ public: * @brief This is called after the initial loading sequence has been processed. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @param late Whether or not the module was loaded after map load. * @return True to succeed loading, false to fail. */ - //virtual bool SDK_OnLoad(char *error, size_t err_max, bool late); + //virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); /** * @brief This is called right before the extension is unloaded. @@ -48,20 +69,43 @@ public: * @brief this is called when Core wants to know if your extension is working. * * @param error Error message buffer. - * @param err_max Size of error message buffer. + * @param maxlength Size of error message buffer. * @return True if working, false otherwise. */ - //virtual void QueryRunning(char *error, size_t maxlength); + //virtual bool QueryRunning(char *error, size_t maxlength); public: #if defined SMEXT_CONF_METAMOD /** - * Read smext_base.h for documentation on these. + * @brief Called when Metamod is attached, before the extension version is called. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @param late Whether or not Metamod considers this a late load. + * @return True to succeed, false to fail. */ + //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); - //virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); - //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max); - //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max); + /** + * @brief Called when Metamod is detaching, after the extension version is called. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); + + /** + * @brief Called when Metamod's pause state is changing. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param paused Pause state being set. + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); #endif }; -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/public/sample_ext/msvc8/sdk.vcproj b/public/sample_ext/msvc8/sdk.vcproj index cb06fd34..444323ad 100644 --- a/public/sample_ext/msvc8/sdk.vcproj +++ b/public/sample_ext/msvc8/sdk.vcproj @@ -40,7 +40,7 @@ - - - - - - + + + + + + + + diff --git a/public/sample_ext/sdk/smsdk_config.h b/public/sample_ext/sdk/smsdk_config.h new file mode 100644 index 00000000..af26a061 --- /dev/null +++ b/public/sample_ext/sdk/smsdk_config.h @@ -0,0 +1,48 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ + +/** + * @file smsdk_config.h + * @brief Contains macros for configuring basic extension information. + */ + +/* Basic information exposed publicly */ +#define SMEXT_CONF_NAME "Sample Extension" +#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers" +#define SMEXT_CONF_VERSION "0.0.0.0" +#define SMEXT_CONF_AUTHOR "AlliedModders" +#define SMEXT_CONF_URL "http://www.sourcemod.net/" +#define SMEXT_CONF_LOGTAG "SAMPLE" +#define SMEXT_CONF_LICENSE "GPL" +#define SMEXT_CONF_DATESTRING __DATE__ + +/** + * @brief Exposes plugin's main interface. + */ +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; + +/** + * @brief Sets whether or not this plugin required Metamod. + * NOTE: Uncomment to enable, comment to disable. + */ +//#define SMEXT_CONF_METAMOD + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ diff --git a/extensions/threader/smsdk_ext.cpp b/public/sample_ext/sdk/smsdk_ext.cpp similarity index 68% rename from extensions/threader/smsdk_ext.cpp rename to public/sample_ext/sdk/smsdk_ext.cpp index 8dfd6db6..d7d3ba02 100644 --- a/extensions/threader/smsdk_ext.cpp +++ b/public/sample_ext/sdk/smsdk_ext.cpp @@ -1,13 +1,17 @@ /** + * vim: set ts=4 : * =============================================================== - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. * =============================================================== * - * This file is part of the SourceMod/SourcePawn SDK. This file may only be used - * or modified under the Terms and Conditions of its License Agreement, which is found - * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins - * may change at any time. To view the latest information, see: - * http://www.sourcemod.net/license.php + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php * * Version: $Id$ */ @@ -16,12 +20,18 @@ #include #include "smsdk_ext.h" -IShareSys *g_pShareSys = NULL; -IExtension *myself = NULL; -IHandleSys *g_pHandleSys = NULL; -ISourceMod *g_pSM = NULL; -IForwardManager *g_pForwards = NULL; +/** + * @file smsdk_ext.cpp + * @brief Contains wrappers for making Extensions easier to write. + */ +IShareSys *g_pShareSys = NULL; /**< Share system */ +IExtension *myself = NULL; /**< Ourself */ +IHandleSys *g_pHandleSys = NULL; /**< Handle system */ +ISourceMod *g_pSM = NULL; /**< SourceMod helpers */ +IForwardManager *g_pForwards = NULL; /**< Forward system */ + +/** Exports the main interface */ PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() { return g_pExtensionIface; @@ -36,7 +46,7 @@ SDKExtension::SDKExtension() #endif } -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late) +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) { g_pShareSys = sys; myself = me; @@ -48,7 +58,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, { if (error) { - snprintf(error, err_max, "Metamod attach failed"); + snprintf(error, maxlength, "Metamod attach failed"); } return false; } @@ -58,7 +68,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, SM_GET_IFACE(SOURCEMOD, g_pSM); SM_GET_IFACE(FORWARDMANAGER, g_pForwards); - if (SDK_OnLoad(error, err_max, late)) + if (SDK_OnLoad(error, maxlength, late)) { #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; @@ -134,7 +144,7 @@ const char *SDKExtension::GetExtensionURL() return SMEXT_CONF_URL; } -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late) { return true; } @@ -153,14 +163,15 @@ void SDKExtension::SDK_OnAllLoaded() #if defined SMEXT_CONF_METAMOD -PluginId g_PLID = 0; -ISmmPlugin *g_PLAPI = NULL; -SourceHook::ISourceHook *g_SHPtr = NULL; -ISmmAPI *g_SMAPI = NULL; +PluginId g_PLID = 0; /**< Metamod plugin ID */ +ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */ +SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */ +ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */ -IVEngineServer *engine = NULL; -IServerGameDLL *gamedll = NULL; +IVEngineServer *engine = NULL; /**< IVEngineServer pointer */ +IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ +/** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) { if (name && !strcmp(name, PLAPI_NAME)) @@ -189,7 +200,7 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, m_SourceMMLoaded = true; - return SDK_OnMetamodLoad(error, maxlen, late); + return SDK_OnMetamodLoad(ismm, error, maxlen, late); } bool SDKExtension::Unload(char *error, size_t maxlen) @@ -278,17 +289,17 @@ const char *SDKExtension::GetVersion() return GetExtensionVerString(); } -bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late) +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) { return true; } -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength) { return true; } -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max) +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength) { return true; } @@ -321,4 +332,3 @@ void operator delete[](void * ptr) free(ptr); } #endif - diff --git a/public/sample_ext/sdk/smsdk_ext.h b/public/sample_ext/sdk/smsdk_ext.h new file mode 100644 index 00000000..24647206 --- /dev/null +++ b/public/sample_ext/sdk/smsdk_ext.h @@ -0,0 +1,213 @@ +/** + * vim: set ts=4 : + * =============================================================== + * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. + * All rights reserved. + * =============================================================== + * + * This file is part of the SourceMod/SourcePawn SDK. This file may only be + * used or modified under the Terms and Conditions of its License Agreement, + * which is found in public/licenses/LICENSE.txt. As of this notice, derivative + * works must be licensed under the GNU General Public License (version 2 or + * greater). A copy of the GPL is included under public/licenses/GPL.txt. + * + * To view the latest information, see: http://www.sourcemod.net/license.php + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ + +/** + * @file smsdk_ext.h + * @brief Contains wrappers for making Extensions easier to write. + */ + +#include "smsdk_config.h" +#include +#include +#include +#include +#include +#include + +#if defined SMEXT_CONF_METAMOD +#include +#include +#endif + +using namespace SourceMod; +using namespace SourcePawn; + +class SDKExtension : +#if defined SMEXT_CONF_METAMOD + public ISmmPlugin, +#endif + public IExtensionInterface +{ +public: + /** Constructor */ + SDKExtension(); +public: + /** + * @brief This is called after the initial loading sequence has been processed. + * + * @param error Error message buffer. + * @param maxlength Size of error message buffer. + * @param late Whether or not the module was loaded after map load. + * @return True to succeed loading, false to fail. + */ + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late); + + /** + * @brief This is called right before the extension is unloaded. + */ + virtual void SDK_OnUnload(); + + /** + * @brief This is called once all known extensions have been loaded. + */ + virtual void SDK_OnAllLoaded(); + + /** + * @brief Called when the pause state is changed. + */ + virtual void SDK_OnPauseChange(bool paused); + +#if defined SMEXT_CONF_METAMOD + /** + * @brief Called when Metamod is attached, before the extension version is called. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @param late Whether or not Metamod considers this a late load. + * @return True to succeed, false to fail. + */ + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); + + /** + * @brief Called when Metamod is detaching, after the extension version is called. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength); + + /** + * @brief Called when Metamod's pause state is changing. + * NOTE: By default this is blocked unless sent from SourceMod. + * + * @param paused Pause state being set. + * @param error Error buffer. + * @param maxlength Maximum size of error buffer. + * @return True to succeed, false to fail. + */ + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength); +#endif + +public: //IExtensionInterface + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late); + virtual void OnExtensionUnload(); + virtual void OnExtensionsAllLoaded(); + + /** Returns whether or not this is a Metamod-based extension */ + virtual bool IsMetamodExtension(); + + /** + * @brief Called when the pause state changes. + * + * @param state True if being paused, false if being unpaused. + */ + virtual void OnExtensionPauseChange(bool state); + + /** Returns name */ + virtual const char *GetExtensionName(); + /** Returns URL */ + virtual const char *GetExtensionURL(); + /** Returns log tag */ + virtual const char *GetExtensionTag(); + /** Returns author */ + virtual const char *GetExtensionAuthor(); + /** Returns version string */ + virtual const char *GetExtensionVerString(); + /** Returns description string */ + virtual const char *GetExtensionDescription(); + /** Returns date string */ + virtual const char *GetExtensionDateString(); +#if defined SMEXT_CONF_METAMOD +public: //ISmmPlugin + /** Called when the extension is attached to Metamod. */ + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late); + /** Returns the author to MM */ + virtual const char *GetAuthor(); + /** Returns the name to MM */ + virtual const char *GetName(); + /** Returns the description to MM */ + virtual const char *GetDescription(); + /** Returns the URL to MM */ + virtual const char *GetURL(); + /** Returns the license to MM */ + virtual const char *GetLicense(); + /** Returns the version string to MM */ + virtual const char *GetVersion(); + /** Returns the date string to MM */ + virtual const char *GetDate(); + /** Returns the logtag to MM */ + virtual const char *GetLogTag(); + /** Called on unload */ + virtual bool Unload(char *error, size_t maxlength); + /** Called on pause */ + virtual bool Pause(char *error, size_t maxlength); + /** Called on unpause */ + virtual bool Unpause(char *error, size_t maxlength); +private: + bool m_SourceMMLoaded; + bool m_WeAreUnloaded; + bool m_WeGotPauseChange; +#endif +}; + +extern SDKExtension *g_pExtensionIface; + +extern IShareSys *g_pShareSys; +extern IExtension *myself; +extern IHandleSys *g_pHandleSys; +extern ISourceMod *g_pSM; +extern IForwardManager *g_pForwards; + +#if defined SMEXT_CONF_METAMOD +PLUGIN_GLOBALVARS(); +extern IVEngineServer *engine; +extern IServerGameDLL *gamedll; +#endif + +/** Creates a SourceMod interface macro pair */ +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION +/** Automates retrieving SourceMod interfaces */ +#define SM_GET_IFACE(prefix, addr) \ + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */ +#define SM_GET_LATE_IFACE(prefix, addr) \ + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr) +/** Validates a SourceMod interface pointer */ +#define SM_CHECK_IFACE(prefix, addr) \ + if (!addr) \ + { \ + if (error) \ + { \ + snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ + return false; \ + } \ + } + +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_ diff --git a/public/sample_ext/smsdk_config.h b/public/sample_ext/smsdk_config.h deleted file mode 100644 index dfc8a925..00000000 --- a/public/sample_ext/smsdk_config.h +++ /dev/null @@ -1,33 +0,0 @@ -// vim: set ts=4 : -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ - -/** - * @file smsdk_config.h - * @brief Contains macros for configuring basic extension information. - */ - -/* Basic information exposed publically */ -#define SMEXT_CONF_NAME "Sample Extension" -#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers" -#define SMEXT_CONF_VERSION "0.0.0.0" -#define SMEXT_CONF_AUTHOR "AlliedModders" -#define SMEXT_CONF_URL "http://www.sourcemod.net/" -#define SMEXT_CONF_LOGTAG "SAMPLE" -#define SMEXT_CONF_LICENSE "GPL" -#define SMEXT_CONF_DATESTRING __DATE__ - -/** - * @brief Exposes plugin's main interface. - */ -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; - -/** - * @brief Sets whether or not this plugin required Metamod. - * NOTE: Uncomment to enable, comment to disable. - * NOTE: This is enabled automatically if a Metamod build is chosen in - * the Visual Studio project. - */ -//#define SMEXT_CONF_METAMOD - -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_