Deduplicate a number of files used by extensions by moving them to the public directory (bug 5341, r=psychonic).
1.1 --- a/core/logic/sm_memtable.h Wed Apr 23 21:40:50 2014 -0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,170 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 sw=4 tw=99 noet :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
1.36 -#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
1.37 -
1.38 -#include <stdlib.h>
1.39 -#include <string.h>
1.40 -
1.41 -class BaseMemTable
1.42 -{
1.43 -public:
1.44 - BaseMemTable(unsigned int init_size)
1.45 - {
1.46 - membase = (unsigned char *)malloc(init_size);
1.47 - size = init_size;
1.48 - tail = 0;
1.49 - }
1.50 - ~BaseMemTable()
1.51 - {
1.52 - free(membase);
1.53 - membase = NULL;
1.54 - }
1.55 -public:
1.56 - /**
1.57 - * Allocates 'size' bytes of memory.
1.58 - * Optionally outputs the address through 'addr'.
1.59 - * Returns an index >= 0 on success, < 0 on failure.
1.60 - */
1.61 - int CreateMem(unsigned int addsize, void **addr)
1.62 - {
1.63 - int idx = (int)tail;
1.64 -
1.65 - while (tail + addsize >= size) {
1.66 - size *= 2;
1.67 - membase = (unsigned char *)realloc(membase, size);
1.68 - }
1.69 -
1.70 - tail += addsize;
1.71 - if (addr)
1.72 - *addr = (void *)&membase[idx];
1.73 -
1.74 - return idx;
1.75 - }
1.76 -
1.77 - /**
1.78 - * Given an index into the memory table, returns its address.
1.79 - * Returns NULL if invalid.
1.80 - */
1.81 - void *GetAddress(int index)
1.82 - {
1.83 - if (index < 0 || (unsigned int)index >= tail)
1.84 - return NULL;
1.85 - return &membase[index];
1.86 - }
1.87 -
1.88 - /**
1.89 - * Scraps the memory table. For caching purposes, the memory
1.90 - * is not freed, however subsequent calls to CreateMem() will
1.91 - * begin at the first index again.
1.92 - */
1.93 - void Reset()
1.94 - {
1.95 - tail = 0;
1.96 - }
1.97 -
1.98 - inline unsigned int GetMemUsage()
1.99 - {
1.100 - return size;
1.101 - }
1.102 -
1.103 - inline unsigned int GetActualMemUsed()
1.104 - {
1.105 - return tail;
1.106 - }
1.107 -
1.108 -private:
1.109 - unsigned char *membase;
1.110 - unsigned int size;
1.111 - unsigned int tail;
1.112 -};
1.113 -
1.114 -class BaseStringTable
1.115 -{
1.116 -public:
1.117 - BaseStringTable(unsigned int init_size) : m_table(init_size)
1.118 - {
1.119 - }
1.120 -public:
1.121 - /**
1.122 - * Adds a string to the string table and returns its index.
1.123 - */
1.124 - int AddString(const char *string)
1.125 - {
1.126 - return AddString(string, strlen(string));
1.127 - }
1.128 -
1.129 - /**
1.130 - * Adds a string to the string table and returns its index.
1.131 - */
1.132 - int AddString(const char *string, size_t length)
1.133 - {
1.134 - size_t len = length + 1;
1.135 - int idx;
1.136 - char *addr;
1.137 -
1.138 - idx = m_table.CreateMem(len, (void **)&addr);
1.139 - memcpy(addr, string, length + 1);
1.140 - return idx;
1.141 - }
1.142 -
1.143 - /**
1.144 - * Given an index into the string table, returns the associated string.
1.145 - */
1.146 - inline const char *GetString(int str)
1.147 - {
1.148 - return (const char *)m_table.GetAddress(str);
1.149 - }
1.150 -
1.151 - /**
1.152 - * Scraps the string table. For caching purposes, the memory
1.153 - * is not freed, however subsequent calls to AddString() will
1.154 - * begin at the first index again.
1.155 - */
1.156 - void Reset()
1.157 - {
1.158 - m_table.Reset();
1.159 - }
1.160 -
1.161 - /**
1.162 - * Returns the parent BaseMemTable that this string table uses.
1.163 - */
1.164 - inline BaseMemTable *GetMemTable()
1.165 - {
1.166 - return &m_table;
1.167 - }
1.168 -private:
1.169 - BaseMemTable m_table;
1.170 -};
1.171 -
1.172 -#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
1.173 -
2.1 --- a/extensions/bintools/AMBuilder Wed Apr 23 21:40:50 2014 -0400
2.2 +++ b/extensions/bintools/AMBuilder Wed Apr 23 21:19:28 2014 -0500
2.3 @@ -16,7 +16,7 @@
2.4 'HookWrapper.cpp',
2.5 'jit_call.cpp',
2.6 'jit_hook.cpp',
2.7 - 'sdk/smsdk_ext.cpp'
2.8 + '../../public/smsdk_ext.cpp'
2.9 ]
2.10
2.11 SM.extensions += [builder.Add(binary)]
3.1 --- a/extensions/bintools/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,80 +0,0 @@
3.4 -/**
3.5 - * vim: set ts=4 :
3.6 - * =============================================================================
3.7 - * SourceMod BinTools Extension
3.8 - * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
3.9 - * =============================================================================
3.10 - *
3.11 - * This program is free software; you can redistribute it and/or modify it under
3.12 - * the terms of the GNU General Public License, version 3.0, as published by the
3.13 - * Free Software Foundation.
3.14 - *
3.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
3.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3.18 - * details.
3.19 - *
3.20 - * You should have received a copy of the GNU General Public License along with
3.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
3.22 - *
3.23 - * As a special exception, AlliedModders LLC gives you permission to link the
3.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
3.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
3.26 - * by the Valve Corporation. You must obey the GNU General Public License in
3.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
3.28 - * this exception to all derivative works. AlliedModders LLC defines further
3.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
3.30 - * or <http://www.sourcemod.net/license.php>.
3.31 - *
3.32 - * Version: $Id$
3.33 - */
3.34 -
3.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
3.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
3.37 -
3.38 -/**
3.39 - * @file smsdk_config.h
3.40 - * @brief Contains macros for configuring basic extension information.
3.41 - */
3.42 -
3.43 -/* Basic information exposed publicly */
3.44 -#define SMEXT_CONF_NAME "BinTools"
3.45 -#define SMEXT_CONF_DESCRIPTION "Low-level C/C++ Calling API"
3.46 -#define SMEXT_CONF_VERSION ""
3.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
3.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
3.49 -#define SMEXT_CONF_LOGTAG "SAMPLE"
3.50 -#define SMEXT_CONF_LICENSE "GPL"
3.51 -#define SMEXT_CONF_DATESTRING ""
3.52 -
3.53 -/**
3.54 - * @brief Exposes plugin's main interface.
3.55 - */
3.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
3.57 -
3.58 -/**
3.59 - * @brief Sets whether or not this plugin required Metamod.
3.60 - * NOTE: Uncomment to enable, comment to disable.
3.61 - */
3.62 -//#define SMEXT_CONF_METAMOD
3.63 -
3.64 -/** Enable interfaces you want to use here by uncommenting lines */
3.65 -//#define SMEXT_ENABLE_FORWARDSYS
3.66 -//#define SMEXT_ENABLE_HANDLESYS
3.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
3.68 -//#define SMEXT_ENABLE_DBMANAGER
3.69 -//#define SMEXT_ENABLE_GAMECONF
3.70 -//#define SMEXT_ENABLE_MEMUTILS
3.71 -//#define SMEXT_ENABLE_GAMEHELPERS
3.72 -//#define SMEXT_ENABLE_TIMERSYS
3.73 -//#define SMEXT_ENABLE_THREADER
3.74 -//#define SMEXT_ENABLE_LIBSYS
3.75 -//#define SMEXT_ENABLE_MENUS
3.76 -//#define SMEXT_ENABLE_ADTFACTORY
3.77 -//#define SMEXT_ENABLE_PLUGINSYS
3.78 -//#define SMEXT_ENABLE_ADMINSYS
3.79 -//#define SMEXT_ENABLE_TEXTPARSERS
3.80 -//#define SMEXT_ENABLE_USERMSGS
3.81 -//#define SMEXT_ENABLE_TRANSLATOR
3.82 -
3.83 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
4.1 --- a/extensions/bintools/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,498 +0,0 @@
4.4 -/**
4.5 - * vim: set ts=4 :
4.6 - * =============================================================================
4.7 - * SourceMod Base Extension Code
4.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
4.9 - * =============================================================================
4.10 - *
4.11 - * This program is free software; you can redistribute it and/or modify it under
4.12 - * the terms of the GNU General Public License, version 3.0, as published by the
4.13 - * Free Software Foundation.
4.14 - *
4.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
4.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4.18 - * details.
4.19 - *
4.20 - * You should have received a copy of the GNU General Public License along with
4.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
4.22 - *
4.23 - * As a special exception, AlliedModders LLC gives you permission to link the
4.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
4.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
4.26 - * by the Valve Corporation. You must obey the GNU General Public License in
4.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
4.28 - * this exception to all derivative works. AlliedModders LLC defines further
4.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
4.30 - * or <http://www.sourcemod.net/license.php>.
4.31 - *
4.32 - * Version: $Id$
4.33 - */
4.34 -
4.35 -#include <stdio.h>
4.36 -#include <stdlib.h>
4.37 -#include "smsdk_ext.h"
4.38 -
4.39 -/**
4.40 - * @file smsdk_ext.cpp
4.41 - * @brief Contains wrappers for making Extensions easier to write.
4.42 - */
4.43 -
4.44 -IExtension *myself = NULL; /**< Ourself */
4.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
4.46 -IShareSys *sharesys = NULL; /**< Share system */
4.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
4.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
4.49 -
4.50 -#if defined SMEXT_ENABLE_FORWARDSYS
4.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
4.52 -IForwardManager *forwards = NULL; /**< Forward system */
4.53 -#endif
4.54 -#if defined SMEXT_ENABLE_HANDLESYS
4.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
4.56 -IHandleSys *handlesys = NULL; /**< Handle system */
4.57 -#endif
4.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
4.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
4.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
4.61 -#if defined SMEXT_ENABLE_DBMANAGER
4.62 -IDBManager *dbi = NULL; /**< DB Manager */
4.63 -#endif //SMEXT_ENABLE_DBMANAGER
4.64 -#if defined SMEXT_ENABLE_GAMECONF
4.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
4.66 -#endif //SMEXT_ENABLE_DBMANAGER
4.67 -#if defined SMEXT_ENABLE_MEMUTILS
4.68 -IMemoryUtils *memutils = NULL;
4.69 -#endif //SMEXT_ENABLE_DBMANAGER
4.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
4.71 -IGameHelpers *gamehelpers = NULL;
4.72 -#endif
4.73 -#if defined SMEXT_ENABLE_TIMERSYS
4.74 -ITimerSystem *timersys = NULL;
4.75 -#endif
4.76 -#if defined SMEXT_ENABLE_ADTFACTORY
4.77 -IADTFactory *adtfactory = NULL;
4.78 -#endif
4.79 -#if defined SMEXT_ENABLE_THREADER
4.80 -IThreader *threader = NULL;
4.81 -#endif
4.82 -#if defined SMEXT_ENABLE_LIBSYS
4.83 -ILibrarySys *libsys = NULL;
4.84 -#endif
4.85 -#if defined SMEXT_ENABLE_PLUGINSYS
4.86 -SourceMod::IPluginManager *plsys;
4.87 -#endif
4.88 -#if defined SMEXT_ENABLE_MENUS
4.89 -IMenuManager *menus = NULL;
4.90 -#endif
4.91 -#if defined SMEXT_ENABLE_ADMINSYS
4.92 -IAdminSystem *adminsys = NULL;
4.93 -#endif
4.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
4.95 -ITextParsers *textparsers = NULL;
4.96 -#endif
4.97 -#if defined SMEXT_ENABLE_USERMSGS
4.98 -IUserMessages *usermsgs = NULL;
4.99 -#endif
4.100 -#if defined SMEXT_ENABLE_TRANSLATOR
4.101 -ITranslator *translator = NULL;
4.102 -#endif
4.103 -#if defined SMEXT_ENABLE_PLUGINSYS
4.104 -SourceMod::IPluginManager *plsys;
4.105 -#endif
4.106 -#if defined SMEXT_ENABLE_MENUS
4.107 -IMenuManager *menus = NULL;
4.108 -#endif
4.109 -#if defined SMEXT_ENABLE_ADMINSYS
4.110 -IAdminSystem *adminsys = NULL;
4.111 -#endif
4.112 -#if defined SMEXT_ENABLE_TEXTPARSERS
4.113 -ITextParsers *textparsers = NULL;
4.114 -#endif
4.115 -#if defined SMEXT_ENABLE_USERMSGS
4.116 -IUserMessages *usermsgs = NULL;
4.117 -#endif
4.118 -#if defined SMEXT_ENABLE_TRANSLATOR
4.119 -ITranslator *translator = NULL;
4.120 -#endif
4.121 -
4.122 -/** Exports the main interface */
4.123 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
4.124 -{
4.125 - return g_pExtensionIface;
4.126 -}
4.127 -
4.128 -SDKExtension::SDKExtension()
4.129 -{
4.130 -#if defined SMEXT_CONF_METAMOD
4.131 - m_SourceMMLoaded = false;
4.132 - m_WeAreUnloaded = false;
4.133 - m_WeGotPauseChange = false;
4.134 -#endif
4.135 -}
4.136 -
4.137 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
4.138 -{
4.139 - g_pShareSys = sharesys = sys;
4.140 - myself = me;
4.141 -
4.142 -#if defined SMEXT_CONF_METAMOD
4.143 - m_WeAreUnloaded = true;
4.144 -
4.145 - if (!m_SourceMMLoaded)
4.146 - {
4.147 - if (error)
4.148 - {
4.149 - snprintf(error, maxlength, "Metamod attach failed");
4.150 - }
4.151 - return false;
4.152 - }
4.153 -#endif
4.154 - SM_GET_IFACE(SOURCEMOD, g_pSM);
4.155 - smutils = g_pSM;
4.156 -#if defined SMEXT_ENABLE_HANDLESYS
4.157 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
4.158 - handlesys = g_pHandleSys;
4.159 -#endif
4.160 -#if defined SMEXT_ENABLE_FORWARDSYS
4.161 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
4.162 - forwards = g_pForwards;
4.163 -#endif
4.164 -#if defined SMEXT_ENABLE_PLAYERHELPERS
4.165 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
4.166 -#endif
4.167 -#if defined SMEXT_ENABLE_DBMANAGER
4.168 - SM_GET_IFACE(DBI, dbi);
4.169 -#endif
4.170 -#if defined SMEXT_ENABLE_GAMECONF
4.171 - SM_GET_IFACE(GAMECONFIG, gameconfs);
4.172 -#endif
4.173 -#if defined SMEXT_ENABLE_MEMUTILS
4.174 - SM_GET_IFACE(MEMORYUTILS, memutils);
4.175 -#endif
4.176 -#if defined SMEXT_ENABLE_GAMEHELPERS
4.177 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
4.178 -#endif
4.179 -#if defined SMEXT_ENABLE_TIMERSYS
4.180 - SM_GET_IFACE(TIMERSYS, timersys);
4.181 -#endif
4.182 -#if defined SMEXT_ENABLE_ADTFACTORY
4.183 - SM_GET_IFACE(ADTFACTORY, adtfactory);
4.184 -#endif
4.185 -#if defined SMEXT_ENABLE_THREADER
4.186 - SM_GET_IFACE(THREADER, threader);
4.187 -#endif
4.188 -#if defined SMEXT_ENABLE_LIBSYS
4.189 - SM_GET_IFACE(LIBRARYSYS, libsys);
4.190 -#endif
4.191 -#if defined SMEXT_ENABLE_PLUGINSYS
4.192 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
4.193 -#endif
4.194 -#if defined SMEXT_ENABLE_MENUS
4.195 - SM_GET_IFACE(MENUMANAGER, menus);
4.196 -#endif
4.197 -#if defined SMEXT_ENABLE_ADMINSYS
4.198 - SM_GET_IFACE(ADMINSYS, adminsys);
4.199 -#endif
4.200 -#if defined SMEXT_ENABLE_TEXTPARSERS
4.201 - SM_GET_IFACE(TEXTPARSERS, textparsers);
4.202 -#endif
4.203 -#if defined SMEXT_ENABLE_USERMSGS
4.204 - SM_GET_IFACE(USERMSGS, usermsgs);
4.205 -#endif
4.206 -#if defined SMEXT_ENABLE_TRANSLATOR
4.207 - SM_GET_IFACE(TRANSLATOR, translator);
4.208 -#endif
4.209 -#if defined SMEXT_ENABLE_PLUGINSYS
4.210 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
4.211 -#endif
4.212 -#if defined SMEXT_ENABLE_MENUS
4.213 - SM_GET_IFACE(MENUMANAGER, menus);
4.214 -#endif
4.215 -#if defined SMEXT_ENABLE_ADMINSYS
4.216 - SM_GET_IFACE(ADMINSYS, adminsys);
4.217 -#endif
4.218 -#if defined SMEXT_ENABLE_TEXTPARSERS
4.219 - SM_GET_IFACE(TEXTPARSERS, textparsers);
4.220 -#endif
4.221 -#if defined SMEXT_ENABLE_USERMSGS
4.222 - SM_GET_IFACE(USERMSGS, usermsgs);
4.223 -#endif
4.224 -#if defined SMEXT_ENABLE_TRANSLATOR
4.225 - SM_GET_IFACE(TRANSLATOR, translator);
4.226 -#endif
4.227 -
4.228 - if (SDK_OnLoad(error, maxlength, late))
4.229 - {
4.230 -#if defined SMEXT_CONF_METAMOD
4.231 - m_WeAreUnloaded = true;
4.232 -#endif
4.233 - return true;
4.234 - }
4.235 -
4.236 - return false;
4.237 -}
4.238 -
4.239 -bool SDKExtension::IsMetamodExtension()
4.240 -{
4.241 -#if defined SMEXT_CONF_METAMOD
4.242 - return true;
4.243 -#else
4.244 - return false;
4.245 -#endif
4.246 -}
4.247 -
4.248 -void SDKExtension::OnExtensionPauseChange(bool state)
4.249 -{
4.250 -#if defined SMEXT_CONF_METAMOD
4.251 - m_WeGotPauseChange = true;
4.252 -#endif
4.253 - SDK_OnPauseChange(state);
4.254 -}
4.255 -
4.256 -void SDKExtension::OnExtensionsAllLoaded()
4.257 -{
4.258 - SDK_OnAllLoaded();
4.259 -}
4.260 -
4.261 -void SDKExtension::OnExtensionUnload()
4.262 -{
4.263 -#if defined SMEXT_CONF_METAMOD
4.264 - m_WeAreUnloaded = true;
4.265 -#endif
4.266 - SDK_OnUnload();
4.267 -}
4.268 -
4.269 -const char *SDKExtension::GetExtensionAuthor()
4.270 -{
4.271 - return SMEXT_CONF_AUTHOR;
4.272 -}
4.273 -
4.274 -const char *SDKExtension::GetExtensionDateString()
4.275 -{
4.276 - return SMEXT_CONF_DATESTRING;
4.277 -}
4.278 -
4.279 -const char *SDKExtension::GetExtensionDescription()
4.280 -{
4.281 - return SMEXT_CONF_DESCRIPTION;
4.282 -}
4.283 -
4.284 -const char *SDKExtension::GetExtensionVerString()
4.285 -{
4.286 - return SMEXT_CONF_VERSION;
4.287 -}
4.288 -
4.289 -const char *SDKExtension::GetExtensionName()
4.290 -{
4.291 - return SMEXT_CONF_NAME;
4.292 -}
4.293 -
4.294 -const char *SDKExtension::GetExtensionTag()
4.295 -{
4.296 - return SMEXT_CONF_LOGTAG;
4.297 -}
4.298 -
4.299 -const char *SDKExtension::GetExtensionURL()
4.300 -{
4.301 - return SMEXT_CONF_URL;
4.302 -}
4.303 -
4.304 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
4.305 -{
4.306 - return true;
4.307 -}
4.308 -
4.309 -void SDKExtension::SDK_OnUnload()
4.310 -{
4.311 -}
4.312 -
4.313 -void SDKExtension::SDK_OnPauseChange(bool paused)
4.314 -{
4.315 -}
4.316 -
4.317 -void SDKExtension::SDK_OnAllLoaded()
4.318 -{
4.319 -}
4.320 -
4.321 -#if defined SMEXT_CONF_METAMOD
4.322 -
4.323 -PluginId g_PLID = 0; /**< Metamod plugin ID */
4.324 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
4.325 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
4.326 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
4.327 -
4.328 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
4.329 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
4.330 -
4.331 -/** Exposes the extension to Metamod */
4.332 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
4.333 -{
4.334 -#if defined METAMOD_PLAPI_VERSION
4.335 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
4.336 -#else
4.337 - if (name && !strcmp(name, PLAPI_NAME))
4.338 -#endif
4.339 - {
4.340 - if (code)
4.341 - {
4.342 - *code = IFACE_OK;
4.343 - }
4.344 - return static_cast<void *>(g_pExtensionIface);
4.345 - }
4.346 -
4.347 - if (code)
4.348 - {
4.349 - *code = IFACE_FAILED;
4.350 - }
4.351 -
4.352 - return NULL;
4.353 -}
4.354 -
4.355 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
4.356 -{
4.357 - PLUGIN_SAVEVARS();
4.358 -
4.359 -#if !defined METAMOD_PLAPI_VERSION
4.360 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
4.361 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
4.362 -#else
4.363 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
4.364 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
4.365 -#endif
4.366 -
4.367 - m_SourceMMLoaded = true;
4.368 -
4.369 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
4.370 -}
4.371 -
4.372 -bool SDKExtension::Unload(char *error, size_t maxlen)
4.373 -{
4.374 - if (!m_WeAreUnloaded)
4.375 - {
4.376 - if (error)
4.377 - {
4.378 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
4.379 - }
4.380 - return false;
4.381 - }
4.382 -
4.383 - return SDK_OnMetamodUnload(error, maxlen);
4.384 -}
4.385 -
4.386 -bool SDKExtension::Pause(char *error, size_t maxlen)
4.387 -{
4.388 - if (!m_WeGotPauseChange)
4.389 - {
4.390 - if (error)
4.391 - {
4.392 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
4.393 - }
4.394 - return false;
4.395 - }
4.396 -
4.397 - m_WeGotPauseChange = false;
4.398 -
4.399 - return SDK_OnMetamodPauseChange(true, error, maxlen);
4.400 -}
4.401 -
4.402 -bool SDKExtension::Unpause(char *error, size_t maxlen)
4.403 -{
4.404 - if (!m_WeGotPauseChange)
4.405 - {
4.406 - if (error)
4.407 - {
4.408 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
4.409 - }
4.410 - return false;
4.411 - }
4.412 -
4.413 - m_WeGotPauseChange = false;
4.414 -
4.415 - return SDK_OnMetamodPauseChange(false, error, maxlen);
4.416 -}
4.417 -
4.418 -const char *SDKExtension::GetAuthor()
4.419 -{
4.420 - return GetExtensionAuthor();
4.421 -}
4.422 -
4.423 -const char *SDKExtension::GetDate()
4.424 -{
4.425 - return GetExtensionDateString();
4.426 -}
4.427 -
4.428 -const char *SDKExtension::GetDescription()
4.429 -{
4.430 - return GetExtensionDescription();
4.431 -}
4.432 -
4.433 -const char *SDKExtension::GetLicense()
4.434 -{
4.435 - return SMEXT_CONF_LICENSE;
4.436 -}
4.437 -
4.438 -const char *SDKExtension::GetLogTag()
4.439 -{
4.440 - return GetExtensionTag();
4.441 -}
4.442 -
4.443 -const char *SDKExtension::GetName()
4.444 -{
4.445 - return GetExtensionName();
4.446 -}
4.447 -
4.448 -const char *SDKExtension::GetURL()
4.449 -{
4.450 - return GetExtensionURL();
4.451 -}
4.452 -
4.453 -const char *SDKExtension::GetVersion()
4.454 -{
4.455 - return GetExtensionVerString();
4.456 -}
4.457 -
4.458 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
4.459 -{
4.460 - return true;
4.461 -}
4.462 -
4.463 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
4.464 -{
4.465 - return true;
4.466 -}
4.467 -
4.468 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
4.469 -{
4.470 - return true;
4.471 -}
4.472 -
4.473 -#endif
4.474 -
4.475 -/* Overload a few things to prevent libstdc++ linking */
4.476 -#if defined __linux__ || defined __APPLE__
4.477 -extern "C" void __cxa_pure_virtual(void)
4.478 -{
4.479 -}
4.480 -
4.481 -void *operator new(size_t size)
4.482 -{
4.483 - return malloc(size);
4.484 -}
4.485 -
4.486 -void *operator new[](size_t size)
4.487 -{
4.488 - return malloc(size);
4.489 -}
4.490 -
4.491 -void operator delete(void *ptr)
4.492 -{
4.493 - free(ptr);
4.494 -}
4.495 -
4.496 -void operator delete[](void * ptr)
4.497 -{
4.498 - free(ptr);
4.499 -}
4.500 -#endif
4.501 -
5.1 --- a/extensions/bintools/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,333 +0,0 @@
5.4 -/**
5.5 - * vim: set ts=4 :
5.6 - * =============================================================================
5.7 - * SourceMod Base Extension Code
5.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
5.9 - * =============================================================================
5.10 - *
5.11 - * This program is free software; you can redistribute it and/or modify it under
5.12 - * the terms of the GNU General Public License, version 3.0, as published by the
5.13 - * Free Software Foundation.
5.14 - *
5.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
5.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
5.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
5.18 - * details.
5.19 - *
5.20 - * You should have received a copy of the GNU General Public License along with
5.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
5.22 - *
5.23 - * As a special exception, AlliedModders LLC gives you permission to link the
5.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
5.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
5.26 - * by the Valve Corporation. You must obey the GNU General Public License in
5.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
5.28 - * this exception to all derivative works. AlliedModders LLC defines further
5.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
5.30 - * or <http://www.sourcemod.net/license.php>.
5.31 - *
5.32 - * Version: $Id$
5.33 - */
5.34 -
5.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
5.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
5.37 -
5.38 -/**
5.39 - * @file smsdk_ext.h
5.40 - * @brief Contains wrappers for making Extensions easier to write.
5.41 - */
5.42 -
5.43 -#include "smsdk_config.h"
5.44 -#include <IExtensionSys.h>
5.45 -#include <IHandleSys.h>
5.46 -#include <sp_vm_api.h>
5.47 -#include <sm_platform.h>
5.48 -#include <ISourceMod.h>
5.49 -#if defined SMEXT_ENABLE_FORWARDSYS
5.50 -#include <IForwardSys.h>
5.51 -#endif //SMEXT_ENABLE_FORWARDSYS
5.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
5.53 -#include <IPlayerHelpers.h>
5.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
5.55 -#if defined SMEXT_ENABLE_DBMANAGER
5.56 -#include <IDBDriver.h>
5.57 -#endif //SMEXT_ENABLE_DBMANAGER
5.58 -#if defined SMEXT_ENABLE_GAMECONF
5.59 -#include <IGameConfigs.h>
5.60 -#endif
5.61 -#if defined SMEXT_ENABLE_MEMUTILS
5.62 -#include <IMemoryUtils.h>
5.63 -#endif
5.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
5.65 -#include <IGameHelpers.h>
5.66 -#endif
5.67 -#if defined SMEXT_ENABLE_TIMERSYS
5.68 -#include <ITimerSystem.h>
5.69 -#endif
5.70 -#if defined SMEXT_ENABLE_ADTFACTORY
5.71 -#include <IADTFactory.h>
5.72 -#endif
5.73 -#if defined SMEXT_ENABLE_THREADER
5.74 -#include <IThreader.h>
5.75 -#endif
5.76 -#if defined SMEXT_ENABLE_LIBSYS
5.77 -#include <ILibrarySys.h>
5.78 -#endif
5.79 -#if defined SMEXT_ENABLE_PLUGINSYS
5.80 -#include <IPluginSys.h>
5.81 -#endif
5.82 -#if defined SMEXT_ENABLE_MENUS
5.83 -#include <IMenuManager.h>
5.84 -#endif
5.85 -#if defined SMEXT_ENABLE_ADMINSYS
5.86 -#include <IAdminSystem.h>
5.87 -#endif
5.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
5.89 -#include <ITextParsers.h>
5.90 -#endif
5.91 -#if defined SMEXT_ENABLE_USERMSGS
5.92 -#include <IUserMessages.h>
5.93 -#endif
5.94 -#if defined SMEXT_ENABLE_TRANSLATOR
5.95 -#include <ITranslator.h>
5.96 -#endif
5.97 -
5.98 -#if defined SMEXT_CONF_METAMOD
5.99 -#include <ISmmPlugin.h>
5.100 -#include <eiface.h>
5.101 -#endif
5.102 -
5.103 -using namespace SourceMod;
5.104 -using namespace SourcePawn;
5.105 -
5.106 -class SDKExtension :
5.107 -#if defined SMEXT_CONF_METAMOD
5.108 - public ISmmPlugin,
5.109 -#endif
5.110 - public IExtensionInterface
5.111 -{
5.112 -public:
5.113 - /** Constructor */
5.114 - SDKExtension();
5.115 -public:
5.116 - /**
5.117 - * @brief This is called after the initial loading sequence has been processed.
5.118 - *
5.119 - * @param error Error message buffer.
5.120 - * @param maxlength Size of error message buffer.
5.121 - * @param late Whether or not the module was loaded after map load.
5.122 - * @return True to succeed loading, false to fail.
5.123 - */
5.124 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
5.125 -
5.126 - /**
5.127 - * @brief This is called right before the extension is unloaded.
5.128 - */
5.129 - virtual void SDK_OnUnload();
5.130 -
5.131 - /**
5.132 - * @brief This is called once all known extensions have been loaded.
5.133 - */
5.134 - virtual void SDK_OnAllLoaded();
5.135 -
5.136 - /**
5.137 - * @brief Called when the pause state is changed.
5.138 - */
5.139 - virtual void SDK_OnPauseChange(bool paused);
5.140 -
5.141 -#if defined SMEXT_CONF_METAMOD
5.142 - /**
5.143 - * @brief Called when Metamod is attached, before the extension version is called.
5.144 - *
5.145 - * @param error Error buffer.
5.146 - * @param maxlength Maximum size of error buffer.
5.147 - * @param late Whether or not Metamod considers this a late load.
5.148 - * @return True to succeed, false to fail.
5.149 - */
5.150 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
5.151 -
5.152 - /**
5.153 - * @brief Called when Metamod is detaching, after the extension version is called.
5.154 - * NOTE: By default this is blocked unless sent from SourceMod.
5.155 - *
5.156 - * @param error Error buffer.
5.157 - * @param maxlength Maximum size of error buffer.
5.158 - * @return True to succeed, false to fail.
5.159 - */
5.160 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
5.161 -
5.162 - /**
5.163 - * @brief Called when Metamod's pause state is changing.
5.164 - * NOTE: By default this is blocked unless sent from SourceMod.
5.165 - *
5.166 - * @param paused Pause state being set.
5.167 - * @param error Error buffer.
5.168 - * @param maxlength Maximum size of error buffer.
5.169 - * @return True to succeed, false to fail.
5.170 - */
5.171 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
5.172 -#endif
5.173 -
5.174 -public: //IExtensionInterface
5.175 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
5.176 - virtual void OnExtensionUnload();
5.177 - virtual void OnExtensionsAllLoaded();
5.178 -
5.179 - /** Returns whether or not this is a Metamod-based extension */
5.180 - virtual bool IsMetamodExtension();
5.181 -
5.182 - /**
5.183 - * @brief Called when the pause state changes.
5.184 - *
5.185 - * @param state True if being paused, false if being unpaused.
5.186 - */
5.187 - virtual void OnExtensionPauseChange(bool state);
5.188 -
5.189 - /** Returns name */
5.190 - virtual const char *GetExtensionName();
5.191 - /** Returns URL */
5.192 - virtual const char *GetExtensionURL();
5.193 - /** Returns log tag */
5.194 - virtual const char *GetExtensionTag();
5.195 - /** Returns author */
5.196 - virtual const char *GetExtensionAuthor();
5.197 - /** Returns version string */
5.198 - virtual const char *GetExtensionVerString();
5.199 - /** Returns description string */
5.200 - virtual const char *GetExtensionDescription();
5.201 - /** Returns date string */
5.202 - virtual const char *GetExtensionDateString();
5.203 -#if defined SMEXT_CONF_METAMOD
5.204 -public: //ISmmPlugin
5.205 - /** Called when the extension is attached to Metamod. */
5.206 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
5.207 - /** Returns the author to MM */
5.208 - virtual const char *GetAuthor();
5.209 - /** Returns the name to MM */
5.210 - virtual const char *GetName();
5.211 - /** Returns the description to MM */
5.212 - virtual const char *GetDescription();
5.213 - /** Returns the URL to MM */
5.214 - virtual const char *GetURL();
5.215 - /** Returns the license to MM */
5.216 - virtual const char *GetLicense();
5.217 - /** Returns the version string to MM */
5.218 - virtual const char *GetVersion();
5.219 - /** Returns the date string to MM */
5.220 - virtual const char *GetDate();
5.221 - /** Returns the logtag to MM */
5.222 - virtual const char *GetLogTag();
5.223 - /** Called on unload */
5.224 - virtual bool Unload(char *error, size_t maxlength);
5.225 - /** Called on pause */
5.226 - virtual bool Pause(char *error, size_t maxlength);
5.227 - /** Called on unpause */
5.228 - virtual bool Unpause(char *error, size_t maxlength);
5.229 -private:
5.230 - bool m_SourceMMLoaded;
5.231 - bool m_WeAreUnloaded;
5.232 - bool m_WeGotPauseChange;
5.233 -#endif
5.234 -};
5.235 -
5.236 -extern SDKExtension *g_pExtensionIface;
5.237 -extern IExtension *myself;
5.238 -
5.239 -extern IShareSys *g_pShareSys;
5.240 -extern IShareSys *sharesys; /* Note: Newer name */
5.241 -extern ISourceMod *g_pSM;
5.242 -extern ISourceMod *smutils; /* Note: Newer name */
5.243 -
5.244 -/* Optional interfaces are below */
5.245 -#if defined SMEXT_ENABLE_FORWARDSYS
5.246 -extern IForwardManager *g_pForwards;
5.247 -extern IForwardManager *forwards; /* Note: Newer name */
5.248 -#endif //SMEXT_ENABLE_FORWARDSYS
5.249 -#if defined SMEXT_ENABLE_HANDLESYS
5.250 -extern IHandleSys *g_pHandleSys;
5.251 -extern IHandleSys *handlesys; /* Note: Newer name */
5.252 -#endif //SMEXT_ENABLE_HANDLESYS
5.253 -#if defined SMEXT_ENABLE_PLAYERHELPERS
5.254 -extern IPlayerManager *playerhelpers;
5.255 -#endif //SMEXT_ENABLE_PLAYERHELPERS
5.256 -#if defined SMEXT_ENABLE_DBMANAGER
5.257 -extern IDBManager *dbi;
5.258 -#endif //SMEXT_ENABLE_DBMANAGER
5.259 -#if defined SMEXT_ENABLE_GAMECONF
5.260 -extern IGameConfigManager *gameconfs;
5.261 -#endif //SMEXT_ENABLE_DBMANAGER
5.262 -#if defined SMEXT_ENABLE_MEMUTILS
5.263 -extern IMemoryUtils *memutils;
5.264 -#endif
5.265 -#if defined SMEXT_ENABLE_GAMEHELPERS
5.266 -extern IGameHelpers *gamehelpers;
5.267 -#endif
5.268 -#if defined SMEXT_ENABLE_TIMERSYS
5.269 -extern ITimerSystem *timersys;
5.270 -#endif
5.271 -#if defined SMEXT_ENABLE_ADTFACTORY
5.272 -extern IADTFactory *adtfactory;
5.273 -#endif
5.274 -#if defined SMEXT_ENABLE_THREADER
5.275 -extern IThreader *threader;
5.276 -#endif
5.277 -#if defined SMEXT_ENABLE_LIBSYS
5.278 -extern ILibrarySys *libsys;
5.279 -#endif
5.280 -#if defined SMEXT_ENABLE_PLUGINSYS
5.281 -extern SourceMod::IPluginManager *plsys;
5.282 -#endif
5.283 -#if defined SMEXT_ENABLE_MENUS
5.284 -extern IMenuManager *menus;
5.285 -#endif
5.286 -#if defined SMEXT_ENABLE_ADMINSYS
5.287 -extern IAdminSystem *adminsys;
5.288 -#endif
5.289 -#if defined SMEXT_ENABLE_USERMSGS
5.290 -extern IUserMessages *usermsgs;
5.291 -#endif
5.292 -#if defined SMEXT_ENABLE_TRANSLATOR
5.293 -extern ITranslator *translator;
5.294 -#endif
5.295 -
5.296 -#if defined SMEXT_CONF_METAMOD
5.297 -PLUGIN_GLOBALVARS();
5.298 -extern IVEngineServer *engine;
5.299 -extern IServerGameDLL *gamedll;
5.300 -#endif
5.301 -
5.302 -/** Creates a SourceMod interface macro pair */
5.303 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
5.304 -/** Automates retrieving SourceMod interfaces */
5.305 -#define SM_GET_IFACE(prefix, addr) \
5.306 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
5.307 - { \
5.308 - if (error != NULL && maxlength) \
5.309 - { \
5.310 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
5.311 - if (len >= maxlength) \
5.312 - { \
5.313 - error[maxlength - 1] = '\0'; \
5.314 - } \
5.315 - } \
5.316 - return false; \
5.317 - }
5.318 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
5.319 -#define SM_GET_LATE_IFACE(prefix, addr) \
5.320 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
5.321 -/** Validates a SourceMod interface pointer */
5.322 -#define SM_CHECK_IFACE(prefix, addr) \
5.323 - if (!addr) \
5.324 - { \
5.325 - if (error != NULL && maxlength) \
5.326 - { \
5.327 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
5.328 - if (len >= maxlength) \
5.329 - { \
5.330 - error[maxlength - 1] = '\0'; \
5.331 - } \
5.332 - } \
5.333 - return false; \
5.334 - }
5.335 -
5.336 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/extensions/bintools/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
6.3 @@ -0,0 +1,80 @@
6.4 +/**
6.5 + * vim: set ts=4 :
6.6 + * =============================================================================
6.7 + * SourceMod BinTools Extension
6.8 + * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
6.9 + * =============================================================================
6.10 + *
6.11 + * This program is free software; you can redistribute it and/or modify it under
6.12 + * the terms of the GNU General Public License, version 3.0, as published by the
6.13 + * Free Software Foundation.
6.14 + *
6.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
6.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
6.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
6.18 + * details.
6.19 + *
6.20 + * You should have received a copy of the GNU General Public License along with
6.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
6.22 + *
6.23 + * As a special exception, AlliedModders LLC gives you permission to link the
6.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
6.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
6.26 + * by the Valve Corporation. You must obey the GNU General Public License in
6.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
6.28 + * this exception to all derivative works. AlliedModders LLC defines further
6.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
6.30 + * or <http://www.sourcemod.net/license.php>.
6.31 + *
6.32 + * Version: $Id$
6.33 + */
6.34 +
6.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
6.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
6.37 +
6.38 +/**
6.39 + * @file smsdk_config.h
6.40 + * @brief Contains macros for configuring basic extension information.
6.41 + */
6.42 +
6.43 +/* Basic information exposed publicly */
6.44 +#define SMEXT_CONF_NAME "BinTools"
6.45 +#define SMEXT_CONF_DESCRIPTION "Low-level C/C++ Calling API"
6.46 +#define SMEXT_CONF_VERSION ""
6.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
6.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
6.49 +#define SMEXT_CONF_LOGTAG "SAMPLE"
6.50 +#define SMEXT_CONF_LICENSE "GPL"
6.51 +#define SMEXT_CONF_DATESTRING ""
6.52 +
6.53 +/**
6.54 + * @brief Exposes plugin's main interface.
6.55 + */
6.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
6.57 +
6.58 +/**
6.59 + * @brief Sets whether or not this plugin required Metamod.
6.60 + * NOTE: Uncomment to enable, comment to disable.
6.61 + */
6.62 +//#define SMEXT_CONF_METAMOD
6.63 +
6.64 +/** Enable interfaces you want to use here by uncommenting lines */
6.65 +//#define SMEXT_ENABLE_FORWARDSYS
6.66 +//#define SMEXT_ENABLE_HANDLESYS
6.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
6.68 +//#define SMEXT_ENABLE_DBMANAGER
6.69 +//#define SMEXT_ENABLE_GAMECONF
6.70 +//#define SMEXT_ENABLE_MEMUTILS
6.71 +//#define SMEXT_ENABLE_GAMEHELPERS
6.72 +//#define SMEXT_ENABLE_TIMERSYS
6.73 +//#define SMEXT_ENABLE_THREADER
6.74 +//#define SMEXT_ENABLE_LIBSYS
6.75 +//#define SMEXT_ENABLE_MENUS
6.76 +//#define SMEXT_ENABLE_ADTFACTORY
6.77 +//#define SMEXT_ENABLE_PLUGINSYS
6.78 +//#define SMEXT_ENABLE_ADMINSYS
6.79 +//#define SMEXT_ENABLE_TEXTPARSERS
6.80 +//#define SMEXT_ENABLE_USERMSGS
6.81 +//#define SMEXT_ENABLE_TRANSLATOR
6.82 +
6.83 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
7.1 --- a/extensions/clientprefs/AMBuilder Wed Apr 23 21:40:50 2014 -0400
7.2 +++ b/extensions/clientprefs/AMBuilder Wed Apr 23 21:19:28 2014 -0500
7.3 @@ -12,7 +12,7 @@
7.4 'menus.cpp',
7.5 'natives.cpp',
7.6 'query.cpp',
7.7 - 'sdk/smsdk_ext.cpp'
7.8 + '../../public/smsdk_ext.cpp'
7.9 ]
7.10
7.11 SM.extensions += [builder.Add(binary)]
8.1 --- a/extensions/clientprefs/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,80 +0,0 @@
8.4 -/**
8.5 - * vim: set ts=4 :
8.6 - * =============================================================================
8.7 - * SourceMod Client Preferences Extension
8.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
8.9 - * =============================================================================
8.10 - *
8.11 - * This program is free software; you can redistribute it and/or modify it under
8.12 - * the terms of the GNU General Public License, version 3.0, as published by the
8.13 - * Free Software Foundation.
8.14 - *
8.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
8.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8.18 - * details.
8.19 - *
8.20 - * You should have received a copy of the GNU General Public License along with
8.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
8.22 - *
8.23 - * As a special exception, AlliedModders LLC gives you permission to link the
8.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
8.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
8.26 - * by the Valve Corporation. You must obey the GNU General Public License in
8.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
8.28 - * this exception to all derivative works. AlliedModders LLC defines further
8.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
8.30 - * or <http://www.sourcemod.net/license.php>.
8.31 - *
8.32 - * Version: $Id$
8.33 - */
8.34 -
8.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
8.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
8.37 -
8.38 -/**
8.39 - * @file smsdk_config.h
8.40 - * @brief Contains macros for configuring basic extension information.
8.41 - */
8.42 -
8.43 -/* Basic information exposed publicly */
8.44 -#define SMEXT_CONF_NAME "Client Preferences"
8.45 -#define SMEXT_CONF_DESCRIPTION "Saves client preference settings"
8.46 -#define SMEXT_CONF_VERSION ""
8.47 -#define SMEXT_CONF_AUTHOR "AlliedModders"
8.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
8.49 -#define SMEXT_CONF_LOGTAG "CLIENTPREFS"
8.50 -#define SMEXT_CONF_LICENSE "GPL"
8.51 -#define SMEXT_CONF_DATESTRING ""
8.52 -
8.53 -/**
8.54 - * @brief Exposes plugin's main interface.
8.55 - */
8.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
8.57 -
8.58 -/**
8.59 - * @brief Sets whether or not this plugin required Metamod.
8.60 - * NOTE: Uncomment to enable, comment to disable.
8.61 - */
8.62 -//#define SMEXT_CONF_METAMOD
8.63 -
8.64 -/** Enable interfaces you want to use here by uncommenting lines */
8.65 -#define SMEXT_ENABLE_FORWARDSYS
8.66 -#define SMEXT_ENABLE_HANDLESYS
8.67 -#define SMEXT_ENABLE_PLAYERHELPERS
8.68 -#define SMEXT_ENABLE_DBMANAGER
8.69 -//#define SMEXT_ENABLE_GAMECONF
8.70 -//#define SMEXT_ENABLE_MEMUTILS
8.71 -#define SMEXT_ENABLE_GAMEHELPERS
8.72 -//#define SMEXT_ENABLE_TIMERSYS
8.73 -//#define SMEXT_ENABLE_THREADER
8.74 -//#define SMEXT_ENABLE_LIBSYS
8.75 -#define SMEXT_ENABLE_MENUS
8.76 -//#define SMEXT_ENABLE_ADTFACTORY
8.77 -#define SMEXT_ENABLE_PLUGINSYS
8.78 -//#define SMEXT_ENABLE_ADMINSYS
8.79 -//#define SMEXT_ENABLE_TEXTPARSERS
8.80 -//#define SMEXT_ENABLE_USERMSGS
8.81 -#define SMEXT_ENABLE_TRANSLATOR
8.82 -
8.83 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
9.1 --- a/extensions/clientprefs/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,483 +0,0 @@
9.4 -/**
9.5 - * vim: set ts=4 sw=4 tw=99 noet:
9.6 - * =============================================================================
9.7 - * SourceMod Base Extension Code
9.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
9.9 - * =============================================================================
9.10 - *
9.11 - * This program is free software; you can redistribute it and/or modify it under
9.12 - * the terms of the GNU General Public License, version 3.0, as published by the
9.13 - * Free Software Foundation.
9.14 - *
9.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
9.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
9.18 - * details.
9.19 - *
9.20 - * You should have received a copy of the GNU General Public License along with
9.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
9.22 - *
9.23 - * As a special exception, AlliedModders LLC gives you permission to link the
9.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
9.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
9.26 - * by the Valve Corporation. You must obey the GNU General Public License in
9.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
9.28 - * this exception to all derivative works. AlliedModders LLC defines further
9.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
9.30 - * or <http://www.sourcemod.net/license.php>.
9.31 - *
9.32 - * Version: $Id$
9.33 - */
9.34 -
9.35 -#include <stdio.h>
9.36 -#include <stdlib.h>
9.37 -#include "smsdk_ext.h"
9.38 -
9.39 -/**
9.40 - * @file smsdk_ext.cpp
9.41 - * @brief Contains wrappers for making Extensions easier to write.
9.42 - */
9.43 -
9.44 -IExtension *myself = NULL; /**< Ourself */
9.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
9.46 -IShareSys *sharesys = NULL; /**< Share system */
9.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
9.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
9.49 -
9.50 -#if defined SMEXT_ENABLE_FORWARDSYS
9.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
9.52 -IForwardManager *forwards = NULL; /**< Forward system */
9.53 -#endif
9.54 -#if defined SMEXT_ENABLE_HANDLESYS
9.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
9.56 -IHandleSys *handlesys = NULL; /**< Handle system */
9.57 -#endif
9.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
9.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
9.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
9.61 -#if defined SMEXT_ENABLE_DBMANAGER
9.62 -IDBManager *dbi = NULL; /**< DB Manager */
9.63 -#endif //SMEXT_ENABLE_DBMANAGER
9.64 -#if defined SMEXT_ENABLE_GAMECONF
9.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
9.66 -#endif //SMEXT_ENABLE_DBMANAGER
9.67 -#if defined SMEXT_ENABLE_MEMUTILS
9.68 -IMemoryUtils *memutils = NULL;
9.69 -#endif //SMEXT_ENABLE_DBMANAGER
9.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
9.71 -IGameHelpers *gamehelpers = NULL;
9.72 -#endif
9.73 -#if defined SMEXT_ENABLE_TIMERSYS
9.74 -ITimerSystem *timersys = NULL;
9.75 -#endif
9.76 -#if defined SMEXT_ENABLE_ADTFACTORY
9.77 -IADTFactory *adtfactory = NULL;
9.78 -#endif
9.79 -#if defined SMEXT_ENABLE_THREADER
9.80 -IThreader *threader = NULL;
9.81 -#endif
9.82 -#if defined SMEXT_ENABLE_LIBSYS
9.83 -ILibrarySys *libsys = NULL;
9.84 -#endif
9.85 -#if defined SMEXT_ENABLE_PLUGINSYS
9.86 -SourceMod::IPluginManager *plsys;
9.87 -#endif
9.88 -#if defined SMEXT_ENABLE_MENUS
9.89 -IMenuManager *menus = NULL;
9.90 -#endif
9.91 -#if defined SMEXT_ENABLE_ADMINSYS
9.92 -IAdminSystem *adminsys = NULL;
9.93 -#endif
9.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
9.95 -ITextParsers *textparsers = NULL;
9.96 -#endif
9.97 -#if defined SMEXT_ENABLE_USERMSGS
9.98 -IUserMessages *usermsgs = NULL;
9.99 -#endif
9.100 -#if defined SMEXT_ENABLE_TRANSLATOR
9.101 -ITranslator *translator = NULL;
9.102 -#endif
9.103 -#if defined SMEXT_ENABLE_NINVOKE
9.104 -INativeInterface *ninvoke = NULL;
9.105 -#endif
9.106 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
9.107 -IRootConsole *rootconsole = NULL;
9.108 -#endif
9.109 -
9.110 -/** Exports the main interface */
9.111 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
9.112 -{
9.113 - return g_pExtensionIface;
9.114 -}
9.115 -
9.116 -SDKExtension::SDKExtension()
9.117 -{
9.118 -#if defined SMEXT_CONF_METAMOD
9.119 - m_SourceMMLoaded = false;
9.120 - m_WeAreUnloaded = false;
9.121 - m_WeGotPauseChange = false;
9.122 -#endif
9.123 -}
9.124 -
9.125 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
9.126 -{
9.127 - g_pShareSys = sharesys = sys;
9.128 - myself = me;
9.129 -
9.130 -#if defined SMEXT_CONF_METAMOD
9.131 - m_WeAreUnloaded = true;
9.132 -
9.133 - if (!m_SourceMMLoaded)
9.134 - {
9.135 - if (error)
9.136 - {
9.137 - snprintf(error, maxlength, "Metamod attach failed");
9.138 - }
9.139 - return false;
9.140 - }
9.141 -#endif
9.142 - SM_GET_IFACE(SOURCEMOD, g_pSM);
9.143 - smutils = g_pSM;
9.144 -#if defined SMEXT_ENABLE_HANDLESYS
9.145 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
9.146 - handlesys = g_pHandleSys;
9.147 -#endif
9.148 -#if defined SMEXT_ENABLE_FORWARDSYS
9.149 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
9.150 - forwards = g_pForwards;
9.151 -#endif
9.152 -#if defined SMEXT_ENABLE_PLAYERHELPERS
9.153 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
9.154 -#endif
9.155 -#if defined SMEXT_ENABLE_DBMANAGER
9.156 - SM_GET_IFACE(DBI, dbi);
9.157 -#endif
9.158 -#if defined SMEXT_ENABLE_GAMECONF
9.159 - SM_GET_IFACE(GAMECONFIG, gameconfs);
9.160 -#endif
9.161 -#if defined SMEXT_ENABLE_MEMUTILS
9.162 - SM_GET_IFACE(MEMORYUTILS, memutils);
9.163 -#endif
9.164 -#if defined SMEXT_ENABLE_GAMEHELPERS
9.165 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
9.166 -#endif
9.167 -#if defined SMEXT_ENABLE_TIMERSYS
9.168 - SM_GET_IFACE(TIMERSYS, timersys);
9.169 -#endif
9.170 -#if defined SMEXT_ENABLE_ADTFACTORY
9.171 - SM_GET_IFACE(ADTFACTORY, adtfactory);
9.172 -#endif
9.173 -#if defined SMEXT_ENABLE_THREADER
9.174 - SM_GET_IFACE(THREADER, threader);
9.175 -#endif
9.176 -#if defined SMEXT_ENABLE_LIBSYS
9.177 - SM_GET_IFACE(LIBRARYSYS, libsys);
9.178 -#endif
9.179 -#if defined SMEXT_ENABLE_PLUGINSYS
9.180 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
9.181 -#endif
9.182 -#if defined SMEXT_ENABLE_MENUS
9.183 - SM_GET_IFACE(MENUMANAGER, menus);
9.184 -#endif
9.185 -#if defined SMEXT_ENABLE_ADMINSYS
9.186 - SM_GET_IFACE(ADMINSYS, adminsys);
9.187 -#endif
9.188 -#if defined SMEXT_ENABLE_TEXTPARSERS
9.189 - SM_GET_IFACE(TEXTPARSERS, textparsers);
9.190 -#endif
9.191 -#if defined SMEXT_ENABLE_USERMSGS
9.192 - SM_GET_IFACE(USERMSGS, usermsgs);
9.193 -#endif
9.194 -#if defined SMEXT_ENABLE_TRANSLATOR
9.195 - SM_GET_IFACE(TRANSLATOR, translator);
9.196 -#endif
9.197 -#if defined SMEXT_ENABLE_NINVOKE
9.198 - SM_GET_IFACE(NINVOKE, ninvoke);
9.199 -#endif
9.200 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
9.201 - SM_GET_IFACE(ROOTCONSOLE, rootconsole);
9.202 -#endif
9.203 -
9.204 - if (SDK_OnLoad(error, maxlength, late))
9.205 - {
9.206 -#if defined SMEXT_CONF_METAMOD
9.207 - m_WeAreUnloaded = true;
9.208 -#endif
9.209 - return true;
9.210 - }
9.211 -
9.212 - return false;
9.213 -}
9.214 -
9.215 -bool SDKExtension::IsMetamodExtension()
9.216 -{
9.217 -#if defined SMEXT_CONF_METAMOD
9.218 - return true;
9.219 -#else
9.220 - return false;
9.221 -#endif
9.222 -}
9.223 -
9.224 -void SDKExtension::OnExtensionPauseChange(bool state)
9.225 -{
9.226 -#if defined SMEXT_CONF_METAMOD
9.227 - m_WeGotPauseChange = true;
9.228 -#endif
9.229 - SDK_OnPauseChange(state);
9.230 -}
9.231 -
9.232 -void SDKExtension::OnExtensionsAllLoaded()
9.233 -{
9.234 - SDK_OnAllLoaded();
9.235 -}
9.236 -
9.237 -void SDKExtension::OnExtensionUnload()
9.238 -{
9.239 -#if defined SMEXT_CONF_METAMOD
9.240 - m_WeAreUnloaded = true;
9.241 -#endif
9.242 - SDK_OnUnload();
9.243 -}
9.244 -
9.245 -void SDKExtension::OnDependenciesDropped()
9.246 -{
9.247 - SDK_OnDependenciesDropped();
9.248 -}
9.249 -
9.250 -const char *SDKExtension::GetExtensionAuthor()
9.251 -{
9.252 - return SMEXT_CONF_AUTHOR;
9.253 -}
9.254 -
9.255 -const char *SDKExtension::GetExtensionDateString()
9.256 -{
9.257 - return SMEXT_CONF_DATESTRING;
9.258 -}
9.259 -
9.260 -const char *SDKExtension::GetExtensionDescription()
9.261 -{
9.262 - return SMEXT_CONF_DESCRIPTION;
9.263 -}
9.264 -
9.265 -const char *SDKExtension::GetExtensionVerString()
9.266 -{
9.267 - return SMEXT_CONF_VERSION;
9.268 -}
9.269 -
9.270 -const char *SDKExtension::GetExtensionName()
9.271 -{
9.272 - return SMEXT_CONF_NAME;
9.273 -}
9.274 -
9.275 -const char *SDKExtension::GetExtensionTag()
9.276 -{
9.277 - return SMEXT_CONF_LOGTAG;
9.278 -}
9.279 -
9.280 -const char *SDKExtension::GetExtensionURL()
9.281 -{
9.282 - return SMEXT_CONF_URL;
9.283 -}
9.284 -
9.285 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
9.286 -{
9.287 - return true;
9.288 -}
9.289 -
9.290 -void SDKExtension::SDK_OnUnload()
9.291 -{
9.292 -}
9.293 -
9.294 -void SDKExtension::SDK_OnPauseChange(bool paused)
9.295 -{
9.296 -}
9.297 -
9.298 -void SDKExtension::SDK_OnAllLoaded()
9.299 -{
9.300 -}
9.301 -
9.302 -void SDKExtension::SDK_OnDependenciesDropped()
9.303 -{
9.304 -}
9.305 -
9.306 -#if defined SMEXT_CONF_METAMOD
9.307 -
9.308 -PluginId g_PLID = 0; /**< Metamod plugin ID */
9.309 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
9.310 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
9.311 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
9.312 -
9.313 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
9.314 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
9.315 -
9.316 -/** Exposes the extension to Metamod */
9.317 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
9.318 -{
9.319 -#if defined METAMOD_PLAPI_VERSION
9.320 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
9.321 -#else
9.322 - if (name && !strcmp(name, PLAPI_NAME))
9.323 -#endif
9.324 - {
9.325 - if (code)
9.326 - {
9.327 - *code = IFACE_OK;
9.328 - }
9.329 - return static_cast<void *>(g_pExtensionIface);
9.330 - }
9.331 -
9.332 - if (code)
9.333 - {
9.334 - *code = IFACE_FAILED;
9.335 - }
9.336 -
9.337 - return NULL;
9.338 -}
9.339 -
9.340 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
9.341 -{
9.342 - PLUGIN_SAVEVARS();
9.343 -
9.344 -#if !defined METAMOD_PLAPI_VERSION
9.345 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
9.346 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
9.347 -#else
9.348 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
9.349 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
9.350 -#endif
9.351 -
9.352 - m_SourceMMLoaded = true;
9.353 -
9.354 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
9.355 -}
9.356 -
9.357 -bool SDKExtension::Unload(char *error, size_t maxlen)
9.358 -{
9.359 - if (!m_WeAreUnloaded)
9.360 - {
9.361 - if (error)
9.362 - {
9.363 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
9.364 - }
9.365 - return false;
9.366 - }
9.367 -
9.368 - return SDK_OnMetamodUnload(error, maxlen);
9.369 -}
9.370 -
9.371 -bool SDKExtension::Pause(char *error, size_t maxlen)
9.372 -{
9.373 - if (!m_WeGotPauseChange)
9.374 - {
9.375 - if (error)
9.376 - {
9.377 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
9.378 - }
9.379 - return false;
9.380 - }
9.381 -
9.382 - m_WeGotPauseChange = false;
9.383 -
9.384 - return SDK_OnMetamodPauseChange(true, error, maxlen);
9.385 -}
9.386 -
9.387 -bool SDKExtension::Unpause(char *error, size_t maxlen)
9.388 -{
9.389 - if (!m_WeGotPauseChange)
9.390 - {
9.391 - if (error)
9.392 - {
9.393 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
9.394 - }
9.395 - return false;
9.396 - }
9.397 -
9.398 - m_WeGotPauseChange = false;
9.399 -
9.400 - return SDK_OnMetamodPauseChange(false, error, maxlen);
9.401 -}
9.402 -
9.403 -const char *SDKExtension::GetAuthor()
9.404 -{
9.405 - return GetExtensionAuthor();
9.406 -}
9.407 -
9.408 -const char *SDKExtension::GetDate()
9.409 -{
9.410 - return GetExtensionDateString();
9.411 -}
9.412 -
9.413 -const char *SDKExtension::GetDescription()
9.414 -{
9.415 - return GetExtensionDescription();
9.416 -}
9.417 -
9.418 -const char *SDKExtension::GetLicense()
9.419 -{
9.420 - return SMEXT_CONF_LICENSE;
9.421 -}
9.422 -
9.423 -const char *SDKExtension::GetLogTag()
9.424 -{
9.425 - return GetExtensionTag();
9.426 -}
9.427 -
9.428 -const char *SDKExtension::GetName()
9.429 -{
9.430 - return GetExtensionName();
9.431 -}
9.432 -
9.433 -const char *SDKExtension::GetURL()
9.434 -{
9.435 - return GetExtensionURL();
9.436 -}
9.437 -
9.438 -const char *SDKExtension::GetVersion()
9.439 -{
9.440 - return GetExtensionVerString();
9.441 -}
9.442 -
9.443 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
9.444 -{
9.445 - return true;
9.446 -}
9.447 -
9.448 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
9.449 -{
9.450 - return true;
9.451 -}
9.452 -
9.453 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
9.454 -{
9.455 - return true;
9.456 -}
9.457 -
9.458 -#endif
9.459 -
9.460 -/* Overload a few things to prevent libstdc++ linking */
9.461 -#if defined __linux__ || defined __APPLE__
9.462 -extern "C" void __cxa_pure_virtual(void)
9.463 -{
9.464 -}
9.465 -
9.466 -void *operator new(size_t size)
9.467 -{
9.468 - return malloc(size);
9.469 -}
9.470 -
9.471 -void *operator new[](size_t size)
9.472 -{
9.473 - return malloc(size);
9.474 -}
9.475 -
9.476 -void operator delete(void *ptr)
9.477 -{
9.478 - free(ptr);
9.479 -}
9.480 -
9.481 -void operator delete[](void * ptr)
9.482 -{
9.483 - free(ptr);
9.484 -}
9.485 -#endif
9.486 -
10.1 --- a/extensions/clientprefs/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,354 +0,0 @@
10.4 -/**
10.5 - * vim: set ts=4 sw=4 tw=99 noet:
10.6 - * =============================================================================
10.7 - * SourceMod Base Extension Code
10.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
10.9 - * =============================================================================
10.10 - *
10.11 - * This program is free software; you can redistribute it and/or modify it under
10.12 - * the terms of the GNU General Public License, version 3.0, as published by the
10.13 - * Free Software Foundation.
10.14 - *
10.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
10.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10.18 - * details.
10.19 - *
10.20 - * You should have received a copy of the GNU General Public License along with
10.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
10.22 - *
10.23 - * As a special exception, AlliedModders LLC gives you permission to link the
10.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
10.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
10.26 - * by the Valve Corporation. You must obey the GNU General Public License in
10.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
10.28 - * this exception to all derivative works. AlliedModders LLC defines further
10.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
10.30 - * or <http://www.sourcemod.net/license.php>.
10.31 - *
10.32 - * Version: $Id$
10.33 - */
10.34 -
10.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
10.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
10.37 -
10.38 -/**
10.39 - * @file smsdk_ext.h
10.40 - * @brief Contains wrappers for making Extensions easier to write.
10.41 - */
10.42 -
10.43 -#include "smsdk_config.h"
10.44 -#include <IExtensionSys.h>
10.45 -#include <IHandleSys.h>
10.46 -#include <sp_vm_api.h>
10.47 -#include <sm_platform.h>
10.48 -#include <ISourceMod.h>
10.49 -#if defined SMEXT_ENABLE_FORWARDSYS
10.50 -#include <IForwardSys.h>
10.51 -#endif //SMEXT_ENABLE_FORWARDSYS
10.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
10.53 -#include <IPlayerHelpers.h>
10.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
10.55 -#if defined SMEXT_ENABLE_DBMANAGER
10.56 -#include <IDBDriver.h>
10.57 -#endif //SMEXT_ENABLE_DBMANAGER
10.58 -#if defined SMEXT_ENABLE_GAMECONF
10.59 -#include <IGameConfigs.h>
10.60 -#endif
10.61 -#if defined SMEXT_ENABLE_MEMUTILS
10.62 -#include <IMemoryUtils.h>
10.63 -#endif
10.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
10.65 -#include <IGameHelpers.h>
10.66 -#endif
10.67 -#if defined SMEXT_ENABLE_TIMERSYS
10.68 -#include <ITimerSystem.h>
10.69 -#endif
10.70 -#if defined SMEXT_ENABLE_ADTFACTORY
10.71 -#include <IADTFactory.h>
10.72 -#endif
10.73 -#if defined SMEXT_ENABLE_THREADER
10.74 -#include <IThreader.h>
10.75 -#endif
10.76 -#if defined SMEXT_ENABLE_LIBSYS
10.77 -#include <ILibrarySys.h>
10.78 -#endif
10.79 -#if defined SMEXT_ENABLE_PLUGINSYS
10.80 -#include <IPluginSys.h>
10.81 -#endif
10.82 -#if defined SMEXT_ENABLE_MENUS
10.83 -#include <IMenuManager.h>
10.84 -#endif
10.85 -#if defined SMEXT_ENABLE_ADMINSYS
10.86 -#include <IAdminSystem.h>
10.87 -#endif
10.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
10.89 -#include <ITextParsers.h>
10.90 -#endif
10.91 -#if defined SMEXT_ENABLE_USERMSGS
10.92 -#include <IUserMessages.h>
10.93 -#endif
10.94 -#if defined SMEXT_ENABLE_TRANSLATOR
10.95 -#include <ITranslator.h>
10.96 -#endif
10.97 -#if defined SMEXT_ENABLE_NINVOKE
10.98 -#include <INativeInvoker.h>
10.99 -#endif
10.100 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
10.101 -#include <IRootConsoleMenu.h>
10.102 -#endif
10.103 -
10.104 -#if defined SMEXT_CONF_METAMOD
10.105 -#include <ISmmPlugin.h>
10.106 -#include <eiface.h>
10.107 -#endif
10.108 -
10.109 -using namespace SourceMod;
10.110 -using namespace SourcePawn;
10.111 -
10.112 -class SDKExtension :
10.113 -#if defined SMEXT_CONF_METAMOD
10.114 - public ISmmPlugin,
10.115 -#endif
10.116 - public IExtensionInterface
10.117 -{
10.118 -public:
10.119 - /** Constructor */
10.120 - SDKExtension();
10.121 -public:
10.122 - /**
10.123 - * @brief This is called after the initial loading sequence has been processed.
10.124 - *
10.125 - * @param error Error message buffer.
10.126 - * @param maxlength Size of error message buffer.
10.127 - * @param late Whether or not the module was loaded after map load.
10.128 - * @return True to succeed loading, false to fail.
10.129 - */
10.130 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
10.131 -
10.132 - /**
10.133 - * @brief This is called once the extension unloading process begins.
10.134 - */
10.135 - virtual void SDK_OnUnload();
10.136 -
10.137 - /**
10.138 - * @brief This is called once all known extensions have been loaded.
10.139 - */
10.140 - virtual void SDK_OnAllLoaded();
10.141 -
10.142 - /**
10.143 - * @brief Called when the pause state is changed.
10.144 - */
10.145 - virtual void SDK_OnPauseChange(bool paused);
10.146 -
10.147 - /**
10.148 - * @brief Called after SDK_OnUnload, once all dependencies have been
10.149 - * removed, and the extension is about to be removed from memory.
10.150 - */
10.151 - virtual void SDK_OnDependenciesDropped();
10.152 -
10.153 -#if defined SMEXT_CONF_METAMOD
10.154 - /**
10.155 - * @brief Called when Metamod is attached, before the extension version is called.
10.156 - *
10.157 - * @param error Error buffer.
10.158 - * @param maxlength Maximum size of error buffer.
10.159 - * @param late Whether or not Metamod considers this a late load.
10.160 - * @return True to succeed, false to fail.
10.161 - */
10.162 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
10.163 -
10.164 - /**
10.165 - * @brief Called when Metamod is detaching, after the extension version is called.
10.166 - * NOTE: By default this is blocked unless sent from SourceMod.
10.167 - *
10.168 - * @param error Error buffer.
10.169 - * @param maxlength Maximum size of error buffer.
10.170 - * @return True to succeed, false to fail.
10.171 - */
10.172 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
10.173 -
10.174 - /**
10.175 - * @brief Called when Metamod's pause state is changing.
10.176 - * NOTE: By default this is blocked unless sent from SourceMod.
10.177 - *
10.178 - * @param paused Pause state being set.
10.179 - * @param error Error buffer.
10.180 - * @param maxlength Maximum size of error buffer.
10.181 - * @return True to succeed, false to fail.
10.182 - */
10.183 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
10.184 -#endif
10.185 -
10.186 -public: //IExtensionInterface
10.187 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
10.188 - virtual void OnExtensionUnload();
10.189 - virtual void OnExtensionsAllLoaded();
10.190 -
10.191 - /** Returns whether or not this is a Metamod-based extension */
10.192 - virtual bool IsMetamodExtension();
10.193 -
10.194 - /**
10.195 - * @brief Called when the pause state changes.
10.196 - *
10.197 - * @param state True if being paused, false if being unpaused.
10.198 - */
10.199 - virtual void OnExtensionPauseChange(bool state);
10.200 -
10.201 - /** Returns name */
10.202 - virtual const char *GetExtensionName();
10.203 - /** Returns URL */
10.204 - virtual const char *GetExtensionURL();
10.205 - /** Returns log tag */
10.206 - virtual const char *GetExtensionTag();
10.207 - /** Returns author */
10.208 - virtual const char *GetExtensionAuthor();
10.209 - /** Returns version string */
10.210 - virtual const char *GetExtensionVerString();
10.211 - /** Returns description string */
10.212 - virtual const char *GetExtensionDescription();
10.213 - /** Returns date string */
10.214 - virtual const char *GetExtensionDateString();
10.215 -
10.216 - /** Called after OnExtensionUnload, once dependencies have been dropped. */
10.217 - virtual void OnDependenciesDropped();
10.218 -#if defined SMEXT_CONF_METAMOD
10.219 -public: //ISmmPlugin
10.220 - /** Called when the extension is attached to Metamod. */
10.221 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
10.222 - /** Returns the author to MM */
10.223 - virtual const char *GetAuthor();
10.224 - /** Returns the name to MM */
10.225 - virtual const char *GetName();
10.226 - /** Returns the description to MM */
10.227 - virtual const char *GetDescription();
10.228 - /** Returns the URL to MM */
10.229 - virtual const char *GetURL();
10.230 - /** Returns the license to MM */
10.231 - virtual const char *GetLicense();
10.232 - /** Returns the version string to MM */
10.233 - virtual const char *GetVersion();
10.234 - /** Returns the date string to MM */
10.235 - virtual const char *GetDate();
10.236 - /** Returns the logtag to MM */
10.237 - virtual const char *GetLogTag();
10.238 - /** Called on unload */
10.239 - virtual bool Unload(char *error, size_t maxlength);
10.240 - /** Called on pause */
10.241 - virtual bool Pause(char *error, size_t maxlength);
10.242 - /** Called on unpause */
10.243 - virtual bool Unpause(char *error, size_t maxlength);
10.244 -private:
10.245 - bool m_SourceMMLoaded;
10.246 - bool m_WeAreUnloaded;
10.247 - bool m_WeGotPauseChange;
10.248 -#endif
10.249 -};
10.250 -
10.251 -extern SDKExtension *g_pExtensionIface;
10.252 -extern IExtension *myself;
10.253 -
10.254 -extern IShareSys *g_pShareSys;
10.255 -extern IShareSys *sharesys; /* Note: Newer name */
10.256 -extern ISourceMod *g_pSM;
10.257 -extern ISourceMod *smutils; /* Note: Newer name */
10.258 -
10.259 -/* Optional interfaces are below */
10.260 -#if defined SMEXT_ENABLE_FORWARDSYS
10.261 -extern IForwardManager *g_pForwards;
10.262 -extern IForwardManager *forwards; /* Note: Newer name */
10.263 -#endif //SMEXT_ENABLE_FORWARDSYS
10.264 -#if defined SMEXT_ENABLE_HANDLESYS
10.265 -extern IHandleSys *g_pHandleSys;
10.266 -extern IHandleSys *handlesys; /* Note: Newer name */
10.267 -#endif //SMEXT_ENABLE_HANDLESYS
10.268 -#if defined SMEXT_ENABLE_PLAYERHELPERS
10.269 -extern IPlayerManager *playerhelpers;
10.270 -#endif //SMEXT_ENABLE_PLAYERHELPERS
10.271 -#if defined SMEXT_ENABLE_DBMANAGER
10.272 -extern IDBManager *dbi;
10.273 -#endif //SMEXT_ENABLE_DBMANAGER
10.274 -#if defined SMEXT_ENABLE_GAMECONF
10.275 -extern IGameConfigManager *gameconfs;
10.276 -#endif //SMEXT_ENABLE_DBMANAGER
10.277 -#if defined SMEXT_ENABLE_MEMUTILS
10.278 -extern IMemoryUtils *memutils;
10.279 -#endif
10.280 -#if defined SMEXT_ENABLE_GAMEHELPERS
10.281 -extern IGameHelpers *gamehelpers;
10.282 -#endif
10.283 -#if defined SMEXT_ENABLE_TIMERSYS
10.284 -extern ITimerSystem *timersys;
10.285 -#endif
10.286 -#if defined SMEXT_ENABLE_ADTFACTORY
10.287 -extern IADTFactory *adtfactory;
10.288 -#endif
10.289 -#if defined SMEXT_ENABLE_THREADER
10.290 -extern IThreader *threader;
10.291 -#endif
10.292 -#if defined SMEXT_ENABLE_LIBSYS
10.293 -extern ILibrarySys *libsys;
10.294 -#endif
10.295 -#if defined SMEXT_ENABLE_PLUGINSYS
10.296 -extern SourceMod::IPluginManager *plsys;
10.297 -#endif
10.298 -#if defined SMEXT_ENABLE_MENUS
10.299 -extern IMenuManager *menus;
10.300 -#endif
10.301 -#if defined SMEXT_ENABLE_ADMINSYS
10.302 -extern IAdminSystem *adminsys;
10.303 -#endif
10.304 -#if defined SMEXT_ENABLE_USERMSGS
10.305 -extern IUserMessages *usermsgs;
10.306 -#endif
10.307 -#if defined SMEXT_ENABLE_TRANSLATOR
10.308 -extern ITranslator *translator;
10.309 -#endif
10.310 -#if defined SMEXT_ENABLE_NINVOKE
10.311 -extern INativeInterface *ninvoke;
10.312 -#endif
10.313 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
10.314 -extern IRootConsole *rootconsole;
10.315 -#endif
10.316 -
10.317 -#if defined SMEXT_CONF_METAMOD
10.318 -PLUGIN_GLOBALVARS();
10.319 -extern IVEngineServer *engine;
10.320 -extern IServerGameDLL *gamedll;
10.321 -#endif
10.322 -
10.323 -/** Creates a SourceMod interface macro pair */
10.324 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
10.325 -/** Automates retrieving SourceMod interfaces */
10.326 -#define SM_GET_IFACE(prefix, addr) \
10.327 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
10.328 - { \
10.329 - if (error != NULL && maxlength) \
10.330 - { \
10.331 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
10.332 - if (len >= maxlength) \
10.333 - { \
10.334 - error[maxlength - 1] = '\0'; \
10.335 - } \
10.336 - } \
10.337 - return false; \
10.338 - }
10.339 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
10.340 -#define SM_GET_LATE_IFACE(prefix, addr) \
10.341 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
10.342 -/** Validates a SourceMod interface pointer */
10.343 -#define SM_CHECK_IFACE(prefix, addr) \
10.344 - if (!addr) \
10.345 - { \
10.346 - if (error != NULL && maxlength) \
10.347 - { \
10.348 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
10.349 - if (len >= maxlength) \
10.350 - { \
10.351 - error[maxlength - 1] = '\0'; \
10.352 - } \
10.353 - } \
10.354 - return false; \
10.355 - }
10.356 -
10.357 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/extensions/clientprefs/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
11.3 @@ -0,0 +1,80 @@
11.4 +/**
11.5 + * vim: set ts=4 :
11.6 + * =============================================================================
11.7 + * SourceMod Client Preferences Extension
11.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
11.9 + * =============================================================================
11.10 + *
11.11 + * This program is free software; you can redistribute it and/or modify it under
11.12 + * the terms of the GNU General Public License, version 3.0, as published by the
11.13 + * Free Software Foundation.
11.14 + *
11.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
11.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11.18 + * details.
11.19 + *
11.20 + * You should have received a copy of the GNU General Public License along with
11.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
11.22 + *
11.23 + * As a special exception, AlliedModders LLC gives you permission to link the
11.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
11.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
11.26 + * by the Valve Corporation. You must obey the GNU General Public License in
11.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
11.28 + * this exception to all derivative works. AlliedModders LLC defines further
11.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
11.30 + * or <http://www.sourcemod.net/license.php>.
11.31 + *
11.32 + * Version: $Id$
11.33 + */
11.34 +
11.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
11.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
11.37 +
11.38 +/**
11.39 + * @file smsdk_config.h
11.40 + * @brief Contains macros for configuring basic extension information.
11.41 + */
11.42 +
11.43 +/* Basic information exposed publicly */
11.44 +#define SMEXT_CONF_NAME "Client Preferences"
11.45 +#define SMEXT_CONF_DESCRIPTION "Saves client preference settings"
11.46 +#define SMEXT_CONF_VERSION ""
11.47 +#define SMEXT_CONF_AUTHOR "AlliedModders"
11.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
11.49 +#define SMEXT_CONF_LOGTAG "CLIENTPREFS"
11.50 +#define SMEXT_CONF_LICENSE "GPL"
11.51 +#define SMEXT_CONF_DATESTRING ""
11.52 +
11.53 +/**
11.54 + * @brief Exposes plugin's main interface.
11.55 + */
11.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
11.57 +
11.58 +/**
11.59 + * @brief Sets whether or not this plugin required Metamod.
11.60 + * NOTE: Uncomment to enable, comment to disable.
11.61 + */
11.62 +//#define SMEXT_CONF_METAMOD
11.63 +
11.64 +/** Enable interfaces you want to use here by uncommenting lines */
11.65 +#define SMEXT_ENABLE_FORWARDSYS
11.66 +#define SMEXT_ENABLE_HANDLESYS
11.67 +#define SMEXT_ENABLE_PLAYERHELPERS
11.68 +#define SMEXT_ENABLE_DBMANAGER
11.69 +//#define SMEXT_ENABLE_GAMECONF
11.70 +//#define SMEXT_ENABLE_MEMUTILS
11.71 +#define SMEXT_ENABLE_GAMEHELPERS
11.72 +//#define SMEXT_ENABLE_TIMERSYS
11.73 +//#define SMEXT_ENABLE_THREADER
11.74 +//#define SMEXT_ENABLE_LIBSYS
11.75 +#define SMEXT_ENABLE_MENUS
11.76 +//#define SMEXT_ENABLE_ADTFACTORY
11.77 +#define SMEXT_ENABLE_PLUGINSYS
11.78 +//#define SMEXT_ENABLE_ADMINSYS
11.79 +//#define SMEXT_ENABLE_TEXTPARSERS
11.80 +//#define SMEXT_ENABLE_USERMSGS
11.81 +#define SMEXT_ENABLE_TRANSLATOR
11.82 +
11.83 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
12.1 --- a/extensions/cstrike/AMBuilder Wed Apr 23 21:40:50 2014 -0400
12.2 +++ b/extensions/cstrike/AMBuilder Wed Apr 23 21:19:28 2014 -0500
12.3 @@ -14,8 +14,8 @@
12.4 'timeleft.cpp',
12.5 'forwards.cpp',
12.6 'util_cstrike.cpp',
12.7 - 'sdk/smsdk_ext.cpp',
12.8 - 'CDetour/detours.cpp',
12.9 - 'asm/asm.c'
12.10 + '../../public/smsdk_ext.cpp',
12.11 + '../../public/CDetour/detours.cpp',
12.12 + '../../public/asm/asm.c'
12.13 ]
12.14 SM.extensions += [builder.Add(binary)]
13.1 --- a/extensions/cstrike/CDetour/detourhelpers.h Wed Apr 23 21:40:50 2014 -0400
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,100 +0,0 @@
13.4 -/**
13.5 - * vim: set ts=4 :
13.6 - * =============================================================================
13.7 - * SourceMod
13.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
13.9 - * =============================================================================
13.10 - *
13.11 - * This program is free software; you can redistribute it and/or modify it under
13.12 - * the terms of the GNU General Public License, version 3.0, as published by the
13.13 - * Free Software Foundation.
13.14 - *
13.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
13.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13.18 - * details.
13.19 - *
13.20 - * You should have received a copy of the GNU General Public License along with
13.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
13.22 - *
13.23 - * As a special exception, AlliedModders LLC gives you permission to link the
13.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
13.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
13.26 - * by the Valve Corporation. You must obey the GNU General Public License in
13.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
13.28 - * this exception to all derivative works. AlliedModders LLC defines further
13.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
13.30 - * or <http://www.sourcemod.net/license.php>.
13.31 - *
13.32 - * Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $
13.33 - */
13.34 -
13.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
13.36 -#define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
13.37 -
13.38 -#if defined PLATFORM_POSIX
13.39 -#include <sys/mman.h>
13.40 -#ifndef PAGE_SIZE
13.41 -#define PAGE_SIZE 4096
13.42 -#endif
13.43 -#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
13.44 -#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
13.45 -#endif
13.46 -
13.47 -struct patch_t
13.48 -{
13.49 - patch_t()
13.50 - {
13.51 - patch[0] = 0;
13.52 - bytes = 0;
13.53 - }
13.54 - unsigned char patch[20];
13.55 - size_t bytes;
13.56 -};
13.57 -
13.58 -inline void ProtectMemory(void *addr, int length, int prot)
13.59 -{
13.60 -#if defined PLATFORM_POSIX
13.61 - void *addr2 = (void *)ALIGN(addr);
13.62 - mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
13.63 -#elif defined PLATFORM_WINDOWS
13.64 - DWORD old_prot;
13.65 - VirtualProtect(addr, length, prot, &old_prot);
13.66 -#endif
13.67 -}
13.68 -
13.69 -inline void SetMemPatchable(void *address, size_t size)
13.70 -{
13.71 - ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
13.72 -}
13.73 -
13.74 -inline void DoGatePatch(unsigned char *target, void *callback)
13.75 -{
13.76 - SetMemPatchable(target, 20);
13.77 -
13.78 - target[0] = 0xFF; /* JMP */
13.79 - target[1] = 0x25; /* MEM32 */
13.80 - *(void **)(&target[2]) = callback;
13.81 -}
13.82 -
13.83 -inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
13.84 -{
13.85 - ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
13.86 -
13.87 - unsigned char *addr = (unsigned char *)address + offset;
13.88 - if (restore)
13.89 - {
13.90 - for (size_t i=0; i<patch->bytes; i++)
13.91 - {
13.92 - restore->patch[i] = addr[i];
13.93 - }
13.94 - restore->bytes = patch->bytes;
13.95 - }
13.96 -
13.97 - for (size_t i=0; i<patch->bytes; i++)
13.98 - {
13.99 - addr[i] = patch->patch[i];
13.100 - }
13.101 -}
13.102 -
13.103 -#endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_
14.1 --- a/extensions/cstrike/CDetour/detours.cpp Wed Apr 23 21:40:50 2014 -0400
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,192 +0,0 @@
14.4 -/**
14.5 -* vim: set ts=4 :
14.6 -* =============================================================================
14.7 -* SourceMod
14.8 -* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
14.9 -* =============================================================================
14.10 -*
14.11 -* This program is free software; you can redistribute it and/or modify it under
14.12 -* the terms of the GNU General Public License, version 3.0, as published by the
14.13 -* Free Software Foundation.
14.14 -*
14.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
14.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14.18 -* details.
14.19 -*
14.20 -* You should have received a copy of the GNU General Public License along with
14.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
14.22 -*
14.23 -* As a special exception, AlliedModders LLC gives you permission to link the
14.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
14.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
14.26 -* by the Valve Corporation. You must obey the GNU General Public License in
14.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
14.28 -* this exception to all derivative works. AlliedModders LLC defines further
14.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
14.30 -* or <http://www.sourcemod.net/license.php>.
14.31 -*
14.32 -* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
14.33 -*/
14.34 -
14.35 -#include "detours.h"
14.36 -#include <asm/asm.h>
14.37 -
14.38 -ISourcePawnEngine *CDetourManager::spengine = NULL;
14.39 -IGameConfig *CDetourManager::gameconf = NULL;
14.40 -
14.41 -void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
14.42 -{
14.43 - CDetourManager::spengine = spengine;
14.44 - CDetourManager::gameconf = gameconf;
14.45 -}
14.46 -
14.47 -CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
14.48 -{
14.49 - CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
14.50 - if (detour)
14.51 - {
14.52 - if (!detour->Init(spengine, gameconf))
14.53 - {
14.54 - delete detour;
14.55 - return NULL;
14.56 - }
14.57 -
14.58 - return detour;
14.59 - }
14.60 -
14.61 - return NULL;
14.62 -}
14.63 -
14.64 -CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
14.65 -{
14.66 - enabled = false;
14.67 - detoured = false;
14.68 - detour_address = NULL;
14.69 - detour_trampoline = NULL;
14.70 - this->signame = signame;
14.71 - this->detour_callback = callbackfunction;
14.72 - spengine = NULL;
14.73 - gameconf = NULL;
14.74 - this->trampoline = trampoline;
14.75 -}
14.76 -
14.77 -bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
14.78 -{
14.79 - this->spengine = spengine;
14.80 - this->gameconf = gameconf;
14.81 -
14.82 - if (!CreateDetour())
14.83 - {
14.84 - enabled = false;
14.85 - return enabled;
14.86 - }
14.87 -
14.88 - enabled = true;
14.89 -
14.90 - return enabled;
14.91 -}
14.92 -
14.93 -void CDetour::Destroy()
14.94 -{
14.95 - DeleteDetour();
14.96 - delete this;
14.97 -}
14.98 -
14.99 -bool CDetour::IsEnabled()
14.100 -{
14.101 - return enabled;
14.102 -}
14.103 -
14.104 -bool CDetour::CreateDetour()
14.105 -{
14.106 - if (!gameconf->GetMemSig(signame, &detour_address))
14.107 - {
14.108 - g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame);
14.109 - return false;
14.110 - }
14.111 -
14.112 - if (!detour_address)
14.113 - {
14.114 - g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame);
14.115 - return false;
14.116 - }
14.117 -
14.118 - detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE+1);
14.119 -
14.120 - /* First, save restore bits */
14.121 - for (size_t i=0; i<detour_restore.bytes; i++)
14.122 - {
14.123 - detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
14.124 - }
14.125 -
14.126 - JitWriter wr;
14.127 - JitWriter *jit = ≀
14.128 - jit_uint32_t CodeSize = 0;
14.129 -
14.130 - wr.outbase = NULL;
14.131 - wr.outptr = NULL;
14.132 -
14.133 -jit_rewind:
14.134 -
14.135 - /* Patch old bytes in */
14.136 - if (wr.outbase != NULL)
14.137 - {
14.138 - copy_bytes((unsigned char *)detour_address, (unsigned char*)wr.outptr, detour_restore.bytes);
14.139 - }
14.140 - wr.outptr += detour_restore.bytes;
14.141 -
14.142 - /* Return to the original function */
14.143 - jitoffs_t call = IA32_Jump_Imm32(jit, 0);
14.144 - IA32_Write_Jump32_Abs(jit, call, (unsigned char *)detour_address + detour_restore.bytes);
14.145 -
14.146 - if (wr.outbase == NULL)
14.147 - {
14.148 - CodeSize = wr.get_outputpos();
14.149 - wr.outbase = (jitcode_t)spengine->AllocatePageMemory(CodeSize);
14.150 - spengine->SetReadWrite(wr.outbase);
14.151 - wr.outptr = wr.outbase;
14.152 - detour_trampoline = wr.outbase;
14.153 - goto jit_rewind;
14.154 - }
14.155 -
14.156 - spengine->SetReadExecute(wr.outbase);
14.157 -
14.158 - *trampoline = detour_trampoline;
14.159 -
14.160 - return true;
14.161 -}
14.162 -
14.163 -void CDetour::DeleteDetour()
14.164 -{
14.165 - if (detoured)
14.166 - {
14.167 - DisableDetour();
14.168 - }
14.169 -
14.170 - if (detour_trampoline)
14.171 - {
14.172 - /* Free the allocated trampoline memory */
14.173 - spengine->FreePageMemory(detour_trampoline);
14.174 - detour_trampoline = NULL;
14.175 - }
14.176 -}
14.177 -
14.178 -void CDetour::EnableDetour()
14.179 -{
14.180 - if (!detoured)
14.181 - {
14.182 - DoGatePatch((unsigned char *)detour_address, &detour_callback);
14.183 - detoured = true;
14.184 - }
14.185 -}
14.186 -
14.187 -void CDetour::DisableDetour()
14.188 -{
14.189 - if (detoured)
14.190 - {
14.191 - /* Remove the patch */
14.192 - ApplyPatch(detour_address, 0, &detour_restore, NULL);
14.193 - detoured = false;
14.194 - }
14.195 -}
15.1 --- a/extensions/cstrike/CDetour/detours.h Wed Apr 23 21:40:50 2014 -0400
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,241 +0,0 @@
15.4 -/**
15.5 -* vim: set ts=4 :
15.6 -* =============================================================================
15.7 -* SourceMod
15.8 -* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
15.9 -* =============================================================================
15.10 -*
15.11 -* This program is free software; you can redistribute it and/or modify it under
15.12 -* the terms of the GNU General Public License, version 3.0, as published by the
15.13 -* Free Software Foundation.
15.14 -*
15.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
15.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15.18 -* details.
15.19 -*
15.20 -* You should have received a copy of the GNU General Public License along with
15.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
15.22 -*
15.23 -* As a special exception, AlliedModders LLC gives you permission to link the
15.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
15.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
15.26 -* by the Valve Corporation. You must obey the GNU General Public License in
15.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
15.28 -* this exception to all derivative works. AlliedModders LLC defines further
15.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
15.30 -* or <http://www.sourcemod.net/license.php>.
15.31 -*
15.32 -* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
15.33 -*/
15.34 -
15.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
15.36 -#define _INCLUDE_SOURCEMOD_DETOURS_H_
15.37 -
15.38 -#include "extension.h"
15.39 -#include <jit/jit_helpers.h>
15.40 -#include <jit/x86/x86_macros.h>
15.41 -#include "detourhelpers.h"
15.42 -
15.43 -/**
15.44 - * CDetours class for SourceMod Extensions by pRED*
15.45 - * detourhelpers.h entirely stolen from CSS:DM and were written by BAILOPAN (I assume).
15.46 - * asm.h/c from devmaster.net (thanks cybermind) edited by pRED* to handle gcc -fPIC thunks correctly
15.47 - * Concept by Nephyrin Zey (http://www.doublezen.net/) and Windows Detour Library (http://research.microsoft.com/sn/detours/)
15.48 - * Member function pointer ideas by Don Clugston (http://www.codeproject.com/cpp/FastDelegate.asp)
15.49 - */
15.50 -
15.51 -#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
15.52 -#define DETOUR_STATIC_CALL(name) (name##_Actual)
15.53 -
15.54 -#define DETOUR_DECL_STATIC0(name, ret) \
15.55 -ret (*name##_Actual)(void) = NULL; \
15.56 -ret name(void)
15.57 -
15.58 -#define DETOUR_DECL_STATIC1(name, ret, p1type, p1name) \
15.59 -ret (*name##_Actual)(p1type) = NULL; \
15.60 -ret name(p1type p1name)
15.61 -
15.62 -#define DETOUR_DECL_STATIC4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
15.63 -ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
15.64 -ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
15.65 -
15.66 -#define DETOUR_DECL_MEMBER0(name, ret) \
15.67 -class name##Class \
15.68 -{ \
15.69 -public: \
15.70 - ret name(); \
15.71 - static ret (name##Class::* name##_Actual)(void); \
15.72 -}; \
15.73 -ret (name##Class::* name##Class::name##_Actual)(void) = NULL; \
15.74 -ret name##Class::name()
15.75 -
15.76 -#define DETOUR_DECL_MEMBER1(name, ret, p1type, p1name) \
15.77 -class name##Class \
15.78 -{ \
15.79 -public: \
15.80 - ret name(p1type p1name); \
15.81 - static ret (name##Class::* name##_Actual)(p1type); \
15.82 -}; \
15.83 -ret (name##Class::* name##Class::name##_Actual)(p1type) = NULL; \
15.84 -ret name##Class::name(p1type p1name)
15.85 -
15.86 -#define DETOUR_DECL_MEMBER2(name, ret, p1type, p1name, p2type, p2name) \
15.87 -class name##Class \
15.88 -{ \
15.89 -public: \
15.90 - ret name(p1type p1name, p2type p2name); \
15.91 - static ret (name##Class::* name##_Actual)(p1type, p2type); \
15.92 -}; \
15.93 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type) = NULL; \
15.94 -ret name##Class::name(p1type p1name, p2type p2name)
15.95 -
15.96 -#define DETOUR_DECL_MEMBER3(name, ret, p1type, p1name, p2type, p2name, p3type, p3name) \
15.97 -class name##Class \
15.98 -{ \
15.99 -public: \
15.100 - ret name(p1type p1name, p2type p2name, p3type p3name); \
15.101 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type); \
15.102 -}; \
15.103 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type) = NULL; \
15.104 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name)
15.105 -
15.106 -#define DETOUR_DECL_MEMBER4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
15.107 -class name##Class \
15.108 -{ \
15.109 -public: \
15.110 - ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name); \
15.111 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type); \
15.112 -}; \
15.113 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
15.114 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
15.115 -
15.116 -
15.117 -#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
15.118 -#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
15.119 -
15.120 -#define GET_STATIC_CALLBACK(name) (void *)&name
15.121 -#define GET_STATIC_TRAMPOLINE(name) (void **)&name##_Actual
15.122 -
15.123 -#define DETOUR_CREATE_MEMBER(name, gamedata) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), gamedata);
15.124 -#define DETOUR_CREATE_STATIC(name, gamedata) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), gamedata);
15.125 -
15.126 -
15.127 -class GenericClass {};
15.128 -typedef void (GenericClass::*VoidFunc)();
15.129 -
15.130 -inline void *GetCodeAddr(VoidFunc mfp)
15.131 -{
15.132 - return *(void **)&mfp;
15.133 -}
15.134 -
15.135 -/**
15.136 - * Converts a member function pointer to a void pointer.
15.137 - * This relies on the assumption that the code address lies at mfp+0
15.138 - * This is the case for both g++ and later MSVC versions on non virtual functions but may be different for other compilers
15.139 - * Based on research by Don Clugston : http://www.codeproject.com/cpp/FastDelegate.asp
15.140 - */
15.141 -#define GetCodeAddress(mfp) GetCodeAddr(reinterpret_cast<VoidFunc>(mfp))
15.142 -
15.143 -class CDetourManager;
15.144 -
15.145 -class CDetour
15.146 -{
15.147 -public:
15.148 -
15.149 - bool IsEnabled();
15.150 -
15.151 - /**
15.152 - * These would be somewhat self-explanatory I hope
15.153 - */
15.154 - void EnableDetour();
15.155 - void DisableDetour();
15.156 -
15.157 - void Destroy();
15.158 -
15.159 - friend class CDetourManager;
15.160 -
15.161 -protected:
15.162 - CDetour(void *callbackfunction, void **trampoline, const char *signame);
15.163 -
15.164 - bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
15.165 -private:
15.166 -
15.167 - /* These create/delete the allocated memory */
15.168 - bool CreateDetour();
15.169 - void DeleteDetour();
15.170 -
15.171 - bool enabled;
15.172 - bool detoured;
15.173 -
15.174 - patch_t detour_restore;
15.175 - /* Address of the detoured function */
15.176 - void *detour_address;
15.177 - /* Address of the allocated trampoline function */
15.178 - void *detour_trampoline;
15.179 - /* Address of the callback handler */
15.180 - void *detour_callback;
15.181 - /* The function pointer used to call our trampoline */
15.182 - void **trampoline;
15.183 -
15.184 - const char *signame;
15.185 - ISourcePawnEngine *spengine;
15.186 - IGameConfig *gameconf;
15.187 -};
15.188 -
15.189 -class CDetourManager
15.190 -{
15.191 -public:
15.192 -
15.193 - static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
15.194 -
15.195 - /**
15.196 - * Creates a new detour
15.197 - *
15.198 - * @param callbackfunction Void pointer to your detour callback function.
15.199 - * @param trampoline Address of the trampoline pointer
15.200 - * @param signame Section name containing a signature to fetch from the gamedata file.
15.201 - * @return A new CDetour pointer to control your detour.
15.202 - *
15.203 - * Example:
15.204 - *
15.205 - * CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
15.206 - *
15.207 - * Define a new class with the required function and a member function pointer to the same type:
15.208 - *
15.209 - * class CBaseServerDetour
15.210 - * {
15.211 - * public:
15.212 - * bool ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
15.213 - * static bool (CBaseServerDetour::* ConnectClient_Actual)(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
15.214 - * }
15.215 - *
15.216 - * void *callbackfunc = GetCodeAddress(&CBaseServerDetour::ConnectClient);
15.217 - * void **trampoline = (void **)(&CBaseServerDetour::ConnectClient_Actual);
15.218 - *
15.219 - * Creation:
15.220 - * CDetourManager::CreateDetour(callbackfunc, trampoline, "ConnectClient");
15.221 - *
15.222 - * Usage:
15.223 - *
15.224 - * CBaseServerDetour::ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int)
15.225 - * {
15.226 - * //pre hook code
15.227 - * bool result = (this->*ConnectClient_Actual)(netaddr_s, rest of params);
15.228 - * //post hook code
15.229 - * return result;
15.230 - * }
15.231 - *
15.232 - * Note we changed the netadr_s reference into a void* to avoid needing to define the type
15.233 - */
15.234 - static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
15.235 -
15.236 - friend class CBlocker;
15.237 - friend class CDetour;
15.238 -
15.239 -private:
15.240 - static ISourcePawnEngine *spengine;
15.241 - static IGameConfig *gameconf;
15.242 -};
15.243 -
15.244 -#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
16.1 --- a/extensions/cstrike/asm/asm.c Wed Apr 23 21:40:50 2014 -0400
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,421 +0,0 @@
16.4 -#include "asm.h"
16.5 -
16.6 -#ifndef WIN32
16.7 -#define _GNU_SOURCE
16.8 -#include <dlfcn.h>
16.9 -#include <string.h>
16.10 -
16.11 -#define REG_EAX 0
16.12 -#define REG_ECX 1
16.13 -#define REG_EDX 2
16.14 -#define REG_EBX 3
16.15 -
16.16 -#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
16.17 -#endif
16.18 -
16.19 -extern void Msg( const char *, ... );
16.20 -
16.21 -/**
16.22 -* Checks if a call to a fpic thunk has just been written into dest.
16.23 -* If found replaces it with a direct mov that sets the required register to the value of pc.
16.24 -*
16.25 -* @param dest Destination buffer where a call opcode + addr (5 bytes) has just been written.
16.26 -* @param pc The program counter value that needs to be set (usually the next address from the source).
16.27 -* @noreturn
16.28 -*/
16.29 -void check_thunks(unsigned char *dest, unsigned char *pc)
16.30 -{
16.31 -#if defined WIN32
16.32 - return;
16.33 -#else
16.34 - /* Step write address back 4 to the start of the function address */
16.35 - unsigned char *writeaddr = dest - 4;
16.36 - unsigned char *calloffset = *(unsigned char **)writeaddr;
16.37 - unsigned char *calladdr = (unsigned char *)(dest + (unsigned int)calloffset);
16.38 -
16.39 - /* Lookup name of function being called */
16.40 - if ((*calladdr == 0x8B) && (*(calladdr+2) == 0x24) && (*(calladdr+3) == 0xC3))
16.41 - {
16.42 - //a thunk maybe?
16.43 - char movByte = IA32_MOV_REG_IMM;
16.44 -
16.45 - /* Calculate the correct mov opcode */
16.46 - switch (*(calladdr+1))
16.47 - {
16.48 - case 0x04:
16.49 - {
16.50 - movByte += REG_EAX;
16.51 - break;
16.52 - }
16.53 - case 0x1C:
16.54 - {
16.55 - movByte += REG_EBX;
16.56 - break;
16.57 - }
16.58 - case 0x0C:
16.59 - {
16.60 - movByte += REG_ECX;
16.61 - break;
16.62 - }
16.63 - case 0x14:
16.64 - {
16.65 - movByte += REG_EDX;
16.66 - break;
16.67 - }
16.68 - default:
16.69 - {
16.70 - Msg("Unknown thunk: %c\n", *(calladdr+1));
16.71 - break;
16.72 - }
16.73 - }
16.74 -
16.75 - /* Move our write address back one to where the call opcode was */
16.76 - writeaddr--;
16.77 -
16.78 -
16.79 - /* Write our mov */
16.80 - *writeaddr = movByte;
16.81 - writeaddr++;
16.82 -
16.83 - /* Write the value - The provided program counter value */
16.84 - *(void **)writeaddr = (void *)pc;
16.85 - writeaddr += 4;
16.86 - }
16.87 -
16.88 - return;
16.89 -#endif
16.90 -}
16.91 -
16.92 -//if dest is NULL, returns minimum number of bytes needed to be copied
16.93 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
16.94 -//http://www.devmaster.net/forums/showthread.php?t=2311
16.95 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
16.96 - int bytecount = 0;
16.97 -
16.98 - while(bytecount < required_len && *func != 0xCC)
16.99 - {
16.100 - // prefixes F0h, F2h, F3h, 66h, 67h, D8h-DFh, 2Eh, 36h, 3Eh, 26h, 64h and 65h
16.101 - int operandSize = 4;
16.102 - int FPU = 0;
16.103 - int twoByte = 0;
16.104 - unsigned char opcode = 0x90;
16.105 - unsigned char modRM = 0xFF;
16.106 - while(*func == 0xF0 ||
16.107 - *func == 0xF2 ||
16.108 - *func == 0xF3 ||
16.109 - (*func & 0xFC) == 0x64 ||
16.110 - (*func & 0xF8) == 0xD8 ||
16.111 - (*func & 0x7E) == 0x62)
16.112 - {
16.113 - if(*func == 0x66)
16.114 - {
16.115 - operandSize = 2;
16.116 - }
16.117 - else if((*func & 0xF8) == 0xD8)
16.118 - {
16.119 - FPU = *func;
16.120 - if (dest)
16.121 - *dest++ = *func++;
16.122 - else
16.123 - func++;
16.124 - bytecount++;
16.125 - break;
16.126 - }
16.127 -
16.128 - if (dest)
16.129 - *dest++ = *func++;
16.130 - else
16.131 - func++;
16.132 - bytecount++;
16.133 - }
16.134 -
16.135 - // two-byte opcode byte
16.136 - if(*func == 0x0F)
16.137 - {
16.138 - twoByte = 1;
16.139 - if (dest)
16.140 - *dest++ = *func++;
16.141 - else
16.142 - func++;
16.143 - bytecount++;
16.144 - }
16.145 -
16.146 - // opcode byte
16.147 - opcode = *func++;
16.148 - if (dest) *dest++ = opcode;
16.149 - bytecount++;
16.150 -
16.151 - // mod R/M byte
16.152 - modRM = 0xFF;
16.153 - if(FPU)
16.154 - {
16.155 - if((opcode & 0xC0) != 0xC0)
16.156 - {
16.157 - modRM = opcode;
16.158 - }
16.159 - }
16.160 - else if(!twoByte)
16.161 - {
16.162 - if((opcode & 0xC4) == 0x00 ||
16.163 - ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) ||
16.164 - (opcode & 0xF0) == 0x80 ||
16.165 - ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) ||
16.166 - (opcode & 0xFC) == 0xD0 ||
16.167 - (opcode & 0xF6) == 0xF6)
16.168 - {
16.169 - modRM = *func++;
16.170 - if (dest) *dest++ = modRM;
16.171 - bytecount++;
16.172 - }
16.173 - }
16.174 - else
16.175 - {
16.176 - if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) ||
16.177 - (opcode & 0xF0) == 0x30 ||
16.178 - opcode == 0x77 ||
16.179 - (opcode & 0xF0) == 0x80 ||
16.180 - ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) ||
16.181 - (opcode & 0xF8) == 0xC8)
16.182 - {
16.183 - // No mod R/M byte
16.184 - }
16.185 - else
16.186 - {
16.187 - modRM = *func++;
16.188 - if (dest) *dest++ = modRM;
16.189 - bytecount++;
16.190 - }
16.191 - }
16.192 -
16.193 - // SIB
16.194 - if((modRM & 0x07) == 0x04 &&
16.195 - (modRM & 0xC0) != 0xC0)
16.196 - {
16.197 - if (dest)
16.198 - *dest++ = *func++; //SIB
16.199 - else
16.200 - func++;
16.201 - bytecount++;
16.202 - }
16.203 -
16.204 - // mod R/M displacement
16.205 -
16.206 - // Dword displacement, no base
16.207 - if((modRM & 0xC5) == 0x05) {
16.208 - if (dest) {
16.209 - *(unsigned int*)dest = *(unsigned int*)func;
16.210 - dest += 4;
16.211 - }
16.212 - func += 4;
16.213 - bytecount += 4;
16.214 - }
16.215 -
16.216 - // Byte displacement
16.217 - if((modRM & 0xC0) == 0x40) {
16.218 - if (dest)
16.219 - *dest++ = *func++;
16.220 - else
16.221 - func++;
16.222 - bytecount++;
16.223 - }
16.224 -
16.225 - // Dword displacement
16.226 - if((modRM & 0xC0) == 0x80) {
16.227 - if (dest) {
16.228 - *(unsigned int*)dest = *(unsigned int*)func;
16.229 - dest += 4;
16.230 - }
16.231 - func += 4;
16.232 - bytecount += 4;
16.233 - }
16.234 -
16.235 - // immediate
16.236 - if(FPU)
16.237 - {
16.238 - // Can't have immediate operand
16.239 - }
16.240 - else if(!twoByte)
16.241 - {
16.242 - if((opcode & 0xC7) == 0x04 ||
16.243 - (opcode & 0xFE) == 0x6A || // PUSH/POP/IMUL
16.244 - (opcode & 0xF0) == 0x70 || // Jcc
16.245 - opcode == 0x80 ||
16.246 - opcode == 0x83 ||
16.247 - (opcode & 0xFD) == 0xA0 || // MOV
16.248 - opcode == 0xA8 || // TEST
16.249 - (opcode & 0xF8) == 0xB0 || // MOV
16.250 - (opcode & 0xFE) == 0xC0 || // RCL
16.251 - opcode == 0xC6 || // MOV
16.252 - opcode == 0xCD || // INT
16.253 - (opcode & 0xFE) == 0xD4 || // AAD/AAM
16.254 - (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ
16.255 - opcode == 0xEB ||
16.256 - (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST
16.257 - {
16.258 - if (dest)
16.259 - *dest++ = *func++;
16.260 - else
16.261 - func++;
16.262 - bytecount++;
16.263 - }
16.264 - else if((opcode & 0xF7) == 0xC2) // RET
16.265 - {
16.266 - if (dest) {
16.267 - *(unsigned short*)dest = *(unsigned short*)func;
16.268 - dest += 2;
16.269 - }
16.270 - func += 2;
16.271 - bytecount += 2;
16.272 - }
16.273 - else if((opcode & 0xFC) == 0x80 ||
16.274 - (opcode & 0xC7) == 0x05 ||
16.275 - (opcode & 0xF8) == 0xB8 ||
16.276 - (opcode & 0xFE) == 0xE8 || // CALL/Jcc
16.277 - (opcode & 0xFE) == 0x68 ||
16.278 - (opcode & 0xFC) == 0xA0 ||
16.279 - (opcode & 0xEE) == 0xA8 ||
16.280 - opcode == 0xC7 ||
16.281 - (opcode == 0xF7 && (modRM & 0x30) == 0x00))
16.282 - {
16.283 - if (dest) {
16.284 - //Fix CALL/JMP offset
16.285 - if ((opcode & 0xFE) == 0xE8) {
16.286 - if (operandSize == 4)
16.287 - {
16.288 - *(long*)dest = ((func + *(long*)func) - dest);
16.289 -
16.290 - //pRED* edit. func is the current address of the call address, +4 is the next instruction, so the value of $pc
16.291 - check_thunks(dest+4, func+4);
16.292 - }
16.293 - else
16.294 - *(short*)dest = ((func + *(short*)func) - dest);
16.295 -
16.296 - } else {
16.297 - if (operandSize == 4)
16.298 - *(unsigned long*)dest = *(unsigned long*)func;
16.299 - else
16.300 - *(unsigned short*)dest = *(unsigned short*)func;
16.301 - }
16.302 - dest += operandSize;
16.303 - }
16.304 - func += operandSize;
16.305 - bytecount += operandSize;
16.306 -
16.307 - }
16.308 - }
16.309 - else
16.310 - {
16.311 - if(opcode == 0xBA || // BT
16.312 - opcode == 0x0F || // 3DNow!
16.313 - (opcode & 0xFC) == 0x70 || // PSLLW
16.314 - (opcode & 0xF7) == 0xA4 || // SHLD
16.315 - opcode == 0xC2 ||
16.316 - opcode == 0xC4 ||
16.317 - opcode == 0xC5 ||
16.318 - opcode == 0xC6)
16.319 - {
16.320 - if (dest)
16.321 - *dest++ = *func++;
16.322 - else
16.323 - func++;
16.324 - }
16.325 - else if((opcode & 0xF0) == 0x80) // Jcc -i
16.326 - {
16.327 - if (dest) {
16.328 - if (operandSize == 4)
16.329 - *(unsigned long*)dest = *(unsigned long*)func;
16.330 - else
16.331 - *(unsigned short*)dest = *(unsigned short*)func;
16.332 -
16.333 - dest += operandSize;
16.334 - }
16.335 - func += operandSize;
16.336 - bytecount += operandSize;
16.337 - }
16.338 - }
16.339 - }
16.340 -
16.341 - return bytecount;
16.342 -}
16.343 -
16.344 -//insert a specific JMP instruction at the given location
16.345 -void inject_jmp(void* src, void* dest) {
16.346 - *(unsigned char*)src = OP_JMP;
16.347 - *(long*)((unsigned char*)src+1) = (long)((unsigned char*)dest - ((unsigned char*)src + OP_JMP_SIZE));
16.348 -}
16.349 -
16.350 -//fill a given block with NOPs
16.351 -void fill_nop(void* src, unsigned int len) {
16.352 - unsigned char* src2 = (unsigned char*)src;
16.353 - while (len) {
16.354 - *src2++ = OP_NOP;
16.355 - --len;
16.356 - }
16.357 -}
16.358 -
16.359 -void* eval_jump(void* src) {
16.360 - unsigned char* addr = (unsigned char*)src;
16.361 -
16.362 - if (!addr) return 0;
16.363 -
16.364 - //import table jump
16.365 - if (addr[0] == OP_PREFIX && addr[1] == OP_JMP_SEG) {
16.366 - addr += 2;
16.367 - addr = *(unsigned char**)addr;
16.368 - //TODO: if addr points into the IAT
16.369 - return *(void**)addr;
16.370 - }
16.371 -
16.372 - //8bit offset
16.373 - else if (addr[0] == OP_JMP_BYTE) {
16.374 - addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1];
16.375 - //mangled 32bit jump?
16.376 - if (addr[0] == OP_JMP) {
16.377 - addr = addr + *(int*)&addr[1];
16.378 - }
16.379 - return addr;
16.380 - }
16.381 - /*
16.382 - //32bit offset
16.383 - else if (addr[0] == OP_JMP) {
16.384 - addr = &addr[OP_JMP_SIZE] + *(int*)&addr[1];
16.385 - }
16.386 - */
16.387 -
16.388 - return addr;
16.389 -}
16.390 -/*
16.391 -from ms detours package
16.392 -static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress)
16.393 -{
16.394 - MEMORY_BASIC_INFORMATION mbi;
16.395 - VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi));
16.396 - __try {
16.397 - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase;
16.398 - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
16.399 - return false;
16.400 - }
16.401 -
16.402 - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader +
16.403 - pDosHeader->e_lfanew);
16.404 - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
16.405 - return false;
16.406 - }
16.407 -
16.408 - if (pbAddress >= ((PBYTE)pDosHeader +
16.409 - pNtHeader->OptionalHeader
16.410 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) &&
16.411 - pbAddress < ((PBYTE)pDosHeader +
16.412 - pNtHeader->OptionalHeader
16.413 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress +
16.414 - pNtHeader->OptionalHeader
16.415 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) {
16.416 - return true;
16.417 - }
16.418 - return false;
16.419 - }
16.420 - __except(EXCEPTION_EXECUTE_HANDLER) {
16.421 - return false;
16.422 - }
16.423 -}
16.424 -*/
17.1 --- a/extensions/cstrike/asm/asm.h Wed Apr 23 21:40:50 2014 -0400
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,40 +0,0 @@
17.4 -#ifndef __ASM_H__
17.5 -#define __ASM_H__
17.6 -
17.7 -#define OP_JMP 0xE9
17.8 -#define OP_JMP_SIZE 5
17.9 -
17.10 -#define OP_NOP 0x90
17.11 -#define OP_NOP_SIZE 1
17.12 -
17.13 -#define OP_PREFIX 0xFF
17.14 -#define OP_JMP_SEG 0x25
17.15 -
17.16 -#define OP_JMP_BYTE 0xEB
17.17 -#define OP_JMP_BYTE_SIZE 2
17.18 -
17.19 -#ifdef __cplusplus
17.20 -extern "C" {
17.21 -#endif
17.22 -
17.23 -void check_thunks(unsigned char *dest, unsigned char *pc);
17.24 -
17.25 -//if dest is NULL, returns minimum number of bytes needed to be copied
17.26 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
17.27 -//http://www.devmaster.net/forums/showthread.php?t=2311
17.28 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
17.29 -
17.30 -//insert a specific JMP instruction at the given location
17.31 -void inject_jmp(void* src, void* dest);
17.32 -
17.33 -//fill a given block with NOPs
17.34 -void fill_nop(void* src, unsigned int len);
17.35 -
17.36 -//evaluate a JMP at the target
17.37 -void* eval_jump(void* src);
17.38 -
17.39 -#ifdef __cplusplus
17.40 -}
17.41 -#endif
17.42 -
17.43 -#endif //__ASM_H__
18.1 --- a/extensions/cstrike/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,75 +0,0 @@
18.4 -/**
18.5 - * vim: set ts=4 :
18.6 - * =============================================================================
18.7 - * SourceMod Counter-Strike:Source Extension
18.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
18.9 - * =============================================================================
18.10 - *
18.11 - * This program is free software; you can redistribute it and/or modify it under
18.12 - * the terms of the GNU General Public License, version 3.0, as published by the
18.13 - * Free Software Foundation.
18.14 - *
18.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
18.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18.18 - * details.
18.19 - *
18.20 - * You should have received a copy of the GNU General Public License along with
18.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
18.22 - *
18.23 - * As a special exception, AlliedModders LLC gives you permission to link the
18.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
18.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
18.26 - * by the Valve Corporation. You must obey the GNU General Public License in
18.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
18.28 - * this exception to all derivative works. AlliedModders LLC defines further
18.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
18.30 - * or <http://www.sourcemod.net/license.php>.
18.31 - *
18.32 - * Version: $Id$
18.33 - */
18.34 -
18.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
18.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
18.37 -
18.38 -/**
18.39 - * @file smsdk_config.h
18.40 - * @brief Contains macros for configuring basic extension information.
18.41 - */
18.42 -
18.43 -/* Basic information exposed publicly */
18.44 -#define SMEXT_CONF_NAME "CS Tools"
18.45 -#define SMEXT_CONF_DESCRIPTION "CS extended functionality"
18.46 -#define SMEXT_CONF_VERSION ""
18.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
18.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
18.49 -#define SMEXT_CONF_LOGTAG "CSTRIKE"
18.50 -#define SMEXT_CONF_LICENSE "GPL"
18.51 -#define SMEXT_CONF_DATESTRING ""
18.52 -
18.53 -/**
18.54 - * @brief Exposes plugin's main interface.
18.55 - */
18.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
18.57 -
18.58 -/**
18.59 - * @brief Sets whether or not this plugin required Metamod.
18.60 - * NOTE: Uncomment to enable, comment to disable.
18.61 - */
18.62 -#define SMEXT_CONF_METAMOD
18.63 -
18.64 -/** Enable interfaces you want to use here by uncommenting lines */
18.65 -#define SMEXT_ENABLE_FORWARDSYS
18.66 -//#define SMEXT_ENABLE_HANDLESYS
18.67 -#define SMEXT_ENABLE_PLAYERHELPERS
18.68 -//#define SMEXT_ENABLE_DBMANAGER
18.69 -#define SMEXT_ENABLE_GAMECONF
18.70 -//#define SMEXT_ENABLE_MEMUTILS
18.71 -#define SMEXT_ENABLE_GAMEHELPERS
18.72 -#define SMEXT_ENABLE_TIMERSYS
18.73 -//#define SMEXT_ENABLE_THREADER
18.74 -//#define SMEXT_ENABLE_LIBSYS
18.75 -#define SMEXT_ENABLE_USERMSGS
18.76 -#define SMEXT_ENABLE_PLUGINSYS
18.77 -
18.78 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
19.1 --- a/extensions/cstrike/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,462 +0,0 @@
19.4 -/**
19.5 - * vim: set ts=4 :
19.6 - * =============================================================================
19.7 - * SourceMod Base Extension Code
19.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
19.9 - * =============================================================================
19.10 - *
19.11 - * This program is free software; you can redistribute it and/or modify it under
19.12 - * the terms of the GNU General Public License, version 3.0, as published by the
19.13 - * Free Software Foundation.
19.14 - *
19.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
19.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19.18 - * details.
19.19 - *
19.20 - * You should have received a copy of the GNU General Public License along with
19.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
19.22 - *
19.23 - * As a special exception, AlliedModders LLC gives you permission to link the
19.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
19.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
19.26 - * by the Valve Corporation. You must obey the GNU General Public License in
19.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
19.28 - * this exception to all derivative works. AlliedModders LLC defines further
19.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
19.30 - * or <http://www.sourcemod.net/license.php>.
19.31 - *
19.32 - * Version: $Id$
19.33 - */
19.34 -
19.35 -#include <stdio.h>
19.36 -#include <stdlib.h>
19.37 -#include "smsdk_ext.h"
19.38 -
19.39 -/**
19.40 - * @file smsdk_ext.cpp
19.41 - * @brief Contains wrappers for making Extensions easier to write.
19.42 - */
19.43 -
19.44 -IExtension *myself = NULL; /**< Ourself */
19.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
19.46 -IShareSys *sharesys = NULL; /**< Share system */
19.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
19.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
19.49 -
19.50 -#if defined SMEXT_ENABLE_FORWARDSYS
19.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
19.52 -IForwardManager *forwards = NULL; /**< Forward system */
19.53 -#endif
19.54 -#if defined SMEXT_ENABLE_HANDLESYS
19.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
19.56 -IHandleSys *handlesys = NULL; /**< Handle system */
19.57 -#endif
19.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
19.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
19.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
19.61 -#if defined SMEXT_ENABLE_DBMANAGER
19.62 -IDBManager *dbi = NULL; /**< DB Manager */
19.63 -#endif //SMEXT_ENABLE_DBMANAGER
19.64 -#if defined SMEXT_ENABLE_GAMECONF
19.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
19.66 -#endif //SMEXT_ENABLE_DBMANAGER
19.67 -#if defined SMEXT_ENABLE_MEMUTILS
19.68 -IMemoryUtils *memutils = NULL;
19.69 -#endif //SMEXT_ENABLE_DBMANAGER
19.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
19.71 -IGameHelpers *gamehelpers = NULL;
19.72 -#endif
19.73 -#if defined SMEXT_ENABLE_TIMERSYS
19.74 -ITimerSystem *timersys = NULL;
19.75 -#endif
19.76 -#if defined SMEXT_ENABLE_ADTFACTORY
19.77 -IADTFactory *adtfactory = NULL;
19.78 -#endif
19.79 -#if defined SMEXT_ENABLE_THREADER
19.80 -IThreader *threader = NULL;
19.81 -#endif
19.82 -#if defined SMEXT_ENABLE_LIBSYS
19.83 -ILibrarySys *libsys = NULL;
19.84 -#endif
19.85 -#if defined SMEXT_ENABLE_PLUGINSYS
19.86 -SourceMod::IPluginManager *plsys;
19.87 -#endif
19.88 -#if defined SMEXT_ENABLE_MENUS
19.89 -IMenuManager *menus = NULL;
19.90 -#endif
19.91 -#if defined SMEXT_ENABLE_ADMINSYS
19.92 -IAdminSystem *adminsys = NULL;
19.93 -#endif
19.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
19.95 -ITextParsers *textparsers = NULL;
19.96 -#endif
19.97 -#if defined SMEXT_ENABLE_USERMSGS
19.98 -IUserMessages *usermsgs = NULL;
19.99 -#endif
19.100 -#if defined SMEXT_ENABLE_TRANSLATOR
19.101 -ITranslator *translator = NULL;
19.102 -#endif
19.103 -
19.104 -/** Exports the main interface */
19.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
19.106 -{
19.107 - return g_pExtensionIface;
19.108 -}
19.109 -
19.110 -SDKExtension::SDKExtension()
19.111 -{
19.112 -#if defined SMEXT_CONF_METAMOD
19.113 - m_SourceMMLoaded = false;
19.114 - m_WeAreUnloaded = false;
19.115 - m_WeGotPauseChange = false;
19.116 -#endif
19.117 -}
19.118 -
19.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
19.120 -{
19.121 - g_pShareSys = sharesys = sys;
19.122 - myself = me;
19.123 -
19.124 -#if defined SMEXT_CONF_METAMOD
19.125 - m_WeAreUnloaded = true;
19.126 -
19.127 - if (!m_SourceMMLoaded)
19.128 - {
19.129 - if (error)
19.130 - {
19.131 - snprintf(error, maxlength, "Metamod attach failed");
19.132 - }
19.133 - return false;
19.134 - }
19.135 -#endif
19.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
19.137 - smutils = g_pSM;
19.138 -#if defined SMEXT_ENABLE_HANDLESYS
19.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
19.140 - handlesys = g_pHandleSys;
19.141 -#endif
19.142 -#if defined SMEXT_ENABLE_FORWARDSYS
19.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
19.144 - forwards = g_pForwards;
19.145 -#endif
19.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
19.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
19.148 -#endif
19.149 -#if defined SMEXT_ENABLE_DBMANAGER
19.150 - SM_GET_IFACE(DBI, dbi);
19.151 -#endif
19.152 -#if defined SMEXT_ENABLE_GAMECONF
19.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
19.154 -#endif
19.155 -#if defined SMEXT_ENABLE_MEMUTILS
19.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
19.157 -#endif
19.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
19.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
19.160 -#endif
19.161 -#if defined SMEXT_ENABLE_TIMERSYS
19.162 - SM_GET_IFACE(TIMERSYS, timersys);
19.163 -#endif
19.164 -#if defined SMEXT_ENABLE_ADTFACTORY
19.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
19.166 -#endif
19.167 -#if defined SMEXT_ENABLE_THREADER
19.168 - SM_GET_IFACE(THREADER, threader);
19.169 -#endif
19.170 -#if defined SMEXT_ENABLE_LIBSYS
19.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
19.172 -#endif
19.173 -#if defined SMEXT_ENABLE_PLUGINSYS
19.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
19.175 -#endif
19.176 -#if defined SMEXT_ENABLE_MENUS
19.177 - SM_GET_IFACE(MENUMANAGER, menus);
19.178 -#endif
19.179 -#if defined SMEXT_ENABLE_ADMINSYS
19.180 - SM_GET_IFACE(ADMINSYS, adminsys);
19.181 -#endif
19.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
19.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
19.184 -#endif
19.185 -#if defined SMEXT_ENABLE_USERMSGS
19.186 - SM_GET_IFACE(USERMSGS, usermsgs);
19.187 -#endif
19.188 -#if defined SMEXT_ENABLE_TRANSLATOR
19.189 - SM_GET_IFACE(TRANSLATOR, translator);
19.190 -#endif
19.191 -
19.192 - if (SDK_OnLoad(error, maxlength, late))
19.193 - {
19.194 -#if defined SMEXT_CONF_METAMOD
19.195 - m_WeAreUnloaded = true;
19.196 -#endif
19.197 - return true;
19.198 - }
19.199 -
19.200 - return false;
19.201 -}
19.202 -
19.203 -bool SDKExtension::IsMetamodExtension()
19.204 -{
19.205 -#if defined SMEXT_CONF_METAMOD
19.206 - return true;
19.207 -#else
19.208 - return false;
19.209 -#endif
19.210 -}
19.211 -
19.212 -void SDKExtension::OnExtensionPauseChange(bool state)
19.213 -{
19.214 -#if defined SMEXT_CONF_METAMOD
19.215 - m_WeGotPauseChange = true;
19.216 -#endif
19.217 - SDK_OnPauseChange(state);
19.218 -}
19.219 -
19.220 -void SDKExtension::OnExtensionsAllLoaded()
19.221 -{
19.222 - SDK_OnAllLoaded();
19.223 -}
19.224 -
19.225 -void SDKExtension::OnExtensionUnload()
19.226 -{
19.227 -#if defined SMEXT_CONF_METAMOD
19.228 - m_WeAreUnloaded = true;
19.229 -#endif
19.230 - SDK_OnUnload();
19.231 -}
19.232 -
19.233 -const char *SDKExtension::GetExtensionAuthor()
19.234 -{
19.235 - return SMEXT_CONF_AUTHOR;
19.236 -}
19.237 -
19.238 -const char *SDKExtension::GetExtensionDateString()
19.239 -{
19.240 - return SMEXT_CONF_DATESTRING;
19.241 -}
19.242 -
19.243 -const char *SDKExtension::GetExtensionDescription()
19.244 -{
19.245 - return SMEXT_CONF_DESCRIPTION;
19.246 -}
19.247 -
19.248 -const char *SDKExtension::GetExtensionVerString()
19.249 -{
19.250 - return SMEXT_CONF_VERSION;
19.251 -}
19.252 -
19.253 -const char *SDKExtension::GetExtensionName()
19.254 -{
19.255 - return SMEXT_CONF_NAME;
19.256 -}
19.257 -
19.258 -const char *SDKExtension::GetExtensionTag()
19.259 -{
19.260 - return SMEXT_CONF_LOGTAG;
19.261 -}
19.262 -
19.263 -const char *SDKExtension::GetExtensionURL()
19.264 -{
19.265 - return SMEXT_CONF_URL;
19.266 -}
19.267 -
19.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
19.269 -{
19.270 - return true;
19.271 -}
19.272 -
19.273 -void SDKExtension::SDK_OnUnload()
19.274 -{
19.275 -}
19.276 -
19.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
19.278 -{
19.279 -}
19.280 -
19.281 -void SDKExtension::SDK_OnAllLoaded()
19.282 -{
19.283 -}
19.284 -
19.285 -#if defined SMEXT_CONF_METAMOD
19.286 -
19.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
19.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
19.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
19.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
19.291 -
19.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
19.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
19.294 -
19.295 -/** Exposes the extension to Metamod */
19.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
19.297 -{
19.298 -#if defined METAMOD_PLAPI_VERSION
19.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
19.300 -#else
19.301 - if (name && !strcmp(name, PLAPI_NAME))
19.302 -#endif
19.303 - {
19.304 - if (code)
19.305 - {
19.306 - *code = IFACE_OK;
19.307 - }
19.308 - return static_cast<void *>(g_pExtensionIface);
19.309 - }
19.310 -
19.311 - if (code)
19.312 - {
19.313 - *code = IFACE_FAILED;
19.314 - }
19.315 -
19.316 - return NULL;
19.317 -}
19.318 -
19.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
19.320 -{
19.321 - PLUGIN_SAVEVARS();
19.322 -
19.323 -#if !defined METAMOD_PLAPI_VERSION
19.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
19.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
19.326 -#else
19.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
19.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
19.329 -#endif
19.330 -
19.331 - m_SourceMMLoaded = true;
19.332 -
19.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
19.334 -}
19.335 -
19.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
19.337 -{
19.338 - if (!m_WeAreUnloaded)
19.339 - {
19.340 - if (error)
19.341 - {
19.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
19.343 - }
19.344 - return false;
19.345 - }
19.346 -
19.347 - return SDK_OnMetamodUnload(error, maxlen);
19.348 -}
19.349 -
19.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
19.351 -{
19.352 - if (!m_WeGotPauseChange)
19.353 - {
19.354 - if (error)
19.355 - {
19.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
19.357 - }
19.358 - return false;
19.359 - }
19.360 -
19.361 - m_WeGotPauseChange = false;
19.362 -
19.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
19.364 -}
19.365 -
19.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
19.367 -{
19.368 - if (!m_WeGotPauseChange)
19.369 - {
19.370 - if (error)
19.371 - {
19.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
19.373 - }
19.374 - return false;
19.375 - }
19.376 -
19.377 - m_WeGotPauseChange = false;
19.378 -
19.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
19.380 -}
19.381 -
19.382 -const char *SDKExtension::GetAuthor()
19.383 -{
19.384 - return GetExtensionAuthor();
19.385 -}
19.386 -
19.387 -const char *SDKExtension::GetDate()
19.388 -{
19.389 - return GetExtensionDateString();
19.390 -}
19.391 -
19.392 -const char *SDKExtension::GetDescription()
19.393 -{
19.394 - return GetExtensionDescription();
19.395 -}
19.396 -
19.397 -const char *SDKExtension::GetLicense()
19.398 -{
19.399 - return SMEXT_CONF_LICENSE;
19.400 -}
19.401 -
19.402 -const char *SDKExtension::GetLogTag()
19.403 -{
19.404 - return GetExtensionTag();
19.405 -}
19.406 -
19.407 -const char *SDKExtension::GetName()
19.408 -{
19.409 - return GetExtensionName();
19.410 -}
19.411 -
19.412 -const char *SDKExtension::GetURL()
19.413 -{
19.414 - return GetExtensionURL();
19.415 -}
19.416 -
19.417 -const char *SDKExtension::GetVersion()
19.418 -{
19.419 - return GetExtensionVerString();
19.420 -}
19.421 -
19.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
19.423 -{
19.424 - return true;
19.425 -}
19.426 -
19.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
19.428 -{
19.429 - return true;
19.430 -}
19.431 -
19.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
19.433 -{
19.434 - return true;
19.435 -}
19.436 -
19.437 -#endif
19.438 -
19.439 -/* Overload a few things to prevent libstdc++ linking */
19.440 -#if defined __linux__ || defined __APPLE__
19.441 -extern "C" void __cxa_pure_virtual(void)
19.442 -{
19.443 -}
19.444 -
19.445 -void *operator new(size_t size)
19.446 -{
19.447 - return malloc(size);
19.448 -}
19.449 -
19.450 -void *operator new[](size_t size)
19.451 -{
19.452 - return malloc(size);
19.453 -}
19.454 -
19.455 -void operator delete(void *ptr)
19.456 -{
19.457 - free(ptr);
19.458 -}
19.459 -
19.460 -void operator delete[](void * ptr)
19.461 -{
19.462 - free(ptr);
19.463 -}
19.464 -#endif
19.465 -
20.1 --- a/extensions/cstrike/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,317 +0,0 @@
20.4 -/**
20.5 - * vim: set ts=4 :
20.6 - * =============================================================================
20.7 - * SourceMod Base Extension Code
20.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
20.9 - * =============================================================================
20.10 - *
20.11 - * This program is free software; you can redistribute it and/or modify it under
20.12 - * the terms of the GNU General Public License, version 3.0, as published by the
20.13 - * Free Software Foundation.
20.14 - *
20.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
20.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20.18 - * details.
20.19 - *
20.20 - * You should have received a copy of the GNU General Public License along with
20.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
20.22 - *
20.23 - * As a special exception, AlliedModders LLC gives you permission to link the
20.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
20.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
20.26 - * by the Valve Corporation. You must obey the GNU General Public License in
20.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
20.28 - * this exception to all derivative works. AlliedModders LLC defines further
20.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
20.30 - * or <http://www.sourcemod.net/license.php>.
20.31 - *
20.32 - * Version: $Id$
20.33 - */
20.34 -
20.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
20.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
20.37 -
20.38 -/**
20.39 - * @file smsdk_ext.h
20.40 - * @brief Contains wrappers for making Extensions easier to write.
20.41 - */
20.42 -
20.43 -#include "smsdk_config.h"
20.44 -#include <IExtensionSys.h>
20.45 -#include <IHandleSys.h>
20.46 -#include <sp_vm_api.h>
20.47 -#include <sm_platform.h>
20.48 -#include <ISourceMod.h>
20.49 -#if defined SMEXT_ENABLE_FORWARDSYS
20.50 -#include <IForwardSys.h>
20.51 -#endif //SMEXT_ENABLE_FORWARDSYS
20.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
20.53 -#include <IPlayerHelpers.h>
20.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
20.55 -#if defined SMEXT_ENABLE_DBMANAGER
20.56 -#include <IDBDriver.h>
20.57 -#endif //SMEXT_ENABLE_DBMANAGER
20.58 -#if defined SMEXT_ENABLE_GAMECONF
20.59 -#include <IGameConfigs.h>
20.60 -#endif
20.61 -#if defined SMEXT_ENABLE_MEMUTILS
20.62 -#include <IMemoryUtils.h>
20.63 -#endif
20.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
20.65 -#include <IGameHelpers.h>
20.66 -#endif
20.67 -#if defined SMEXT_ENABLE_TIMERSYS
20.68 -#include <ITimerSystem.h>
20.69 -#endif
20.70 -#if defined SMEXT_ENABLE_ADTFACTORY
20.71 -#include <IADTFactory.h>
20.72 -#endif
20.73 -#if defined SMEXT_ENABLE_THREADER
20.74 -#include <IThreader.h>
20.75 -#endif
20.76 -#if defined SMEXT_ENABLE_LIBSYS
20.77 -#include <ILibrarySys.h>
20.78 -#endif
20.79 -#if defined SMEXT_ENABLE_USERMSGS
20.80 -#include <IUserMessages.h>
20.81 -#endif
20.82 -#if defined SMEXT_ENABLE_PLUGINSYS
20.83 -#include <IPluginSys.h>
20.84 -#endif
20.85 -
20.86 -#if defined SMEXT_CONF_METAMOD
20.87 -#include <ISmmPlugin.h>
20.88 -#include <eiface.h>
20.89 -#endif
20.90 -
20.91 -#if !defined METAMOD_PLAPI_VERSION
20.92 - #include <metamod_wrappers.h>
20.93 -#endif
20.94 -
20.95 -using namespace SourceMod;
20.96 -using namespace SourcePawn;
20.97 -
20.98 -class SDKExtension :
20.99 -#if defined SMEXT_CONF_METAMOD
20.100 - public ISmmPlugin,
20.101 -#endif
20.102 - public IExtensionInterface
20.103 -{
20.104 -public:
20.105 - /** Constructor */
20.106 - SDKExtension();
20.107 -public:
20.108 - /**
20.109 - * @brief This is called after the initial loading sequence has been processed.
20.110 - *
20.111 - * @param error Error message buffer.
20.112 - * @param maxlength Size of error message buffer.
20.113 - * @param late Whether or not the module was loaded after map load.
20.114 - * @return True to succeed loading, false to fail.
20.115 - */
20.116 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
20.117 -
20.118 - /**
20.119 - * @brief This is called right before the extension is unloaded.
20.120 - */
20.121 - virtual void SDK_OnUnload();
20.122 -
20.123 - /**
20.124 - * @brief This is called once all known extensions have been loaded.
20.125 - */
20.126 - virtual void SDK_OnAllLoaded();
20.127 -
20.128 - /**
20.129 - * @brief Called when the pause state is changed.
20.130 - */
20.131 - virtual void SDK_OnPauseChange(bool paused);
20.132 -
20.133 -#if defined SMEXT_CONF_METAMOD
20.134 - /**
20.135 - * @brief Called when Metamod is attached, before the extension version is called.
20.136 - *
20.137 - * @param error Error buffer.
20.138 - * @param maxlength Maximum size of error buffer.
20.139 - * @param late Whether or not Metamod considers this a late load.
20.140 - * @return True to succeed, false to fail.
20.141 - */
20.142 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
20.143 -
20.144 - /**
20.145 - * @brief Called when Metamod is detaching, after the extension version is called.
20.146 - * NOTE: By default this is blocked unless sent from SourceMod.
20.147 - *
20.148 - * @param error Error buffer.
20.149 - * @param maxlength Maximum size of error buffer.
20.150 - * @return True to succeed, false to fail.
20.151 - */
20.152 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
20.153 -
20.154 - /**
20.155 - * @brief Called when Metamod's pause state is changing.
20.156 - * NOTE: By default this is blocked unless sent from SourceMod.
20.157 - *
20.158 - * @param paused Pause state being set.
20.159 - * @param error Error buffer.
20.160 - * @param maxlength Maximum size of error buffer.
20.161 - * @return True to succeed, false to fail.
20.162 - */
20.163 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
20.164 -#endif
20.165 -
20.166 -public: //IExtensionInterface
20.167 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
20.168 - virtual void OnExtensionUnload();
20.169 - virtual void OnExtensionsAllLoaded();
20.170 -
20.171 - /** Returns whether or not this is a Metamod-based extension */
20.172 - virtual bool IsMetamodExtension();
20.173 -
20.174 - /**
20.175 - * @brief Called when the pause state changes.
20.176 - *
20.177 - * @param state True if being paused, false if being unpaused.
20.178 - */
20.179 - virtual void OnExtensionPauseChange(bool state);
20.180 -
20.181 - /** Returns name */
20.182 - virtual const char *GetExtensionName();
20.183 - /** Returns URL */
20.184 - virtual const char *GetExtensionURL();
20.185 - /** Returns log tag */
20.186 - virtual const char *GetExtensionTag();
20.187 - /** Returns author */
20.188 - virtual const char *GetExtensionAuthor();
20.189 - /** Returns version string */
20.190 - virtual const char *GetExtensionVerString();
20.191 - /** Returns description string */
20.192 - virtual const char *GetExtensionDescription();
20.193 - /** Returns date string */
20.194 - virtual const char *GetExtensionDateString();
20.195 -#if defined SMEXT_CONF_METAMOD
20.196 -public: //ISmmPlugin
20.197 - /** Called when the extension is attached to Metamod. */
20.198 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
20.199 - /** Returns the author to MM */
20.200 - virtual const char *GetAuthor();
20.201 - /** Returns the name to MM */
20.202 - virtual const char *GetName();
20.203 - /** Returns the description to MM */
20.204 - virtual const char *GetDescription();
20.205 - /** Returns the URL to MM */
20.206 - virtual const char *GetURL();
20.207 - /** Returns the license to MM */
20.208 - virtual const char *GetLicense();
20.209 - /** Returns the version string to MM */
20.210 - virtual const char *GetVersion();
20.211 - /** Returns the date string to MM */
20.212 - virtual const char *GetDate();
20.213 - /** Returns the logtag to MM */
20.214 - virtual const char *GetLogTag();
20.215 - /** Called on unload */
20.216 - virtual bool Unload(char *error, size_t maxlength);
20.217 - /** Called on pause */
20.218 - virtual bool Pause(char *error, size_t maxlength);
20.219 - /** Called on unpause */
20.220 - virtual bool Unpause(char *error, size_t maxlength);
20.221 -private:
20.222 - bool m_SourceMMLoaded;
20.223 - bool m_WeAreUnloaded;
20.224 - bool m_WeGotPauseChange;
20.225 -#endif
20.226 -};
20.227 -
20.228 -extern SDKExtension *g_pExtensionIface;
20.229 -extern IExtension *myself;
20.230 -
20.231 -extern IShareSys *g_pShareSys;
20.232 -extern IShareSys *sharesys; /* Note: Newer name */
20.233 -extern ISourceMod *g_pSM;
20.234 -extern ISourceMod *smutils; /* Note: Newer name */
20.235 -
20.236 -/* Optional interfaces are below */
20.237 -#if defined SMEXT_ENABLE_FORWARDSYS
20.238 -extern IForwardManager *g_pForwards;
20.239 -extern IForwardManager *forwards; /* Note: Newer name */
20.240 -#endif //SMEXT_ENABLE_FORWARDSYS
20.241 -#if defined SMEXT_ENABLE_HANDLESYS
20.242 -extern IHandleSys *g_pHandleSys;
20.243 -extern IHandleSys *handlesys; /* Note: Newer name */
20.244 -#endif //SMEXT_ENABLE_HANDLESYS
20.245 -#if defined SMEXT_ENABLE_PLAYERHELPERS
20.246 -extern IPlayerManager *playerhelpers;
20.247 -#endif //SMEXT_ENABLE_PLAYERHELPERS
20.248 -#if defined SMEXT_ENABLE_DBMANAGER
20.249 -extern IDBManager *dbi;
20.250 -#endif //SMEXT_ENABLE_DBMANAGER
20.251 -#if defined SMEXT_ENABLE_GAMECONF
20.252 -extern IGameConfigManager *gameconfs;
20.253 -#endif //SMEXT_ENABLE_DBMANAGER
20.254 -#if defined SMEXT_ENABLE_MEMUTILS
20.255 -extern IMemoryUtils *memutils;
20.256 -#endif
20.257 -#if defined SMEXT_ENABLE_GAMEHELPERS
20.258 -extern IGameHelpers *gamehelpers;
20.259 -#endif
20.260 -#if defined SMEXT_ENABLE_TIMERSYS
20.261 -extern ITimerSystem *timersys;
20.262 -#endif
20.263 -#if defined SMEXT_ENABLE_ADTFACTORY
20.264 -extern IADTFactory *adtfactory;
20.265 -#endif
20.266 -#if defined SMEXT_ENABLE_THREADER
20.267 -extern IThreader *threader;
20.268 -#endif
20.269 -#if defined SMEXT_ENABLE_LIBSYS
20.270 -extern ILibrarySys *libsys;
20.271 -#endif
20.272 -#if defined SMEXT_ENABLE_USERMSGS
20.273 -extern IUserMessages *usermsgs;
20.274 -#endif
20.275 -#if defined SMEXT_ENABLE_PLUGINSYS
20.276 -extern IPluginManager *plsys;
20.277 -#endif
20.278 -
20.279 -
20.280 -#if defined SMEXT_CONF_METAMOD
20.281 -PLUGIN_GLOBALVARS();
20.282 -extern IVEngineServer *engine;
20.283 -extern IServerGameDLL *gamedll;
20.284 -#endif
20.285 -
20.286 -/** Creates a SourceMod interface macro pair */
20.287 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
20.288 -/** Automates retrieving SourceMod interfaces */
20.289 -#define SM_GET_IFACE(prefix, addr) \
20.290 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
20.291 - { \
20.292 - if (error != NULL && maxlength) \
20.293 - { \
20.294 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
20.295 - if (len >= maxlength) \
20.296 - { \
20.297 - error[maxlength - 1] = '\0'; \
20.298 - } \
20.299 - } \
20.300 - return false; \
20.301 - }
20.302 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
20.303 -#define SM_GET_LATE_IFACE(prefix, addr) \
20.304 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
20.305 -/** Validates a SourceMod interface pointer */
20.306 -#define SM_CHECK_IFACE(prefix, addr) \
20.307 - if (!addr) \
20.308 - { \
20.309 - if (error != NULL && maxlength) \
20.310 - { \
20.311 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
20.312 - if (len >= maxlength) \
20.313 - { \
20.314 - error[maxlength - 1] = '\0'; \
20.315 - } \
20.316 - } \
20.317 - return false; \
20.318 - }
20.319 -
20.320 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/extensions/cstrike/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
21.3 @@ -0,0 +1,75 @@
21.4 +/**
21.5 + * vim: set ts=4 :
21.6 + * =============================================================================
21.7 + * SourceMod Counter-Strike:Source Extension
21.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
21.9 + * =============================================================================
21.10 + *
21.11 + * This program is free software; you can redistribute it and/or modify it under
21.12 + * the terms of the GNU General Public License, version 3.0, as published by the
21.13 + * Free Software Foundation.
21.14 + *
21.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
21.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21.18 + * details.
21.19 + *
21.20 + * You should have received a copy of the GNU General Public License along with
21.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
21.22 + *
21.23 + * As a special exception, AlliedModders LLC gives you permission to link the
21.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
21.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
21.26 + * by the Valve Corporation. You must obey the GNU General Public License in
21.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
21.28 + * this exception to all derivative works. AlliedModders LLC defines further
21.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
21.30 + * or <http://www.sourcemod.net/license.php>.
21.31 + *
21.32 + * Version: $Id$
21.33 + */
21.34 +
21.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
21.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
21.37 +
21.38 +/**
21.39 + * @file smsdk_config.h
21.40 + * @brief Contains macros for configuring basic extension information.
21.41 + */
21.42 +
21.43 +/* Basic information exposed publicly */
21.44 +#define SMEXT_CONF_NAME "CS Tools"
21.45 +#define SMEXT_CONF_DESCRIPTION "CS extended functionality"
21.46 +#define SMEXT_CONF_VERSION ""
21.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
21.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
21.49 +#define SMEXT_CONF_LOGTAG "CSTRIKE"
21.50 +#define SMEXT_CONF_LICENSE "GPL"
21.51 +#define SMEXT_CONF_DATESTRING ""
21.52 +
21.53 +/**
21.54 + * @brief Exposes plugin's main interface.
21.55 + */
21.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
21.57 +
21.58 +/**
21.59 + * @brief Sets whether or not this plugin required Metamod.
21.60 + * NOTE: Uncomment to enable, comment to disable.
21.61 + */
21.62 +#define SMEXT_CONF_METAMOD
21.63 +
21.64 +/** Enable interfaces you want to use here by uncommenting lines */
21.65 +#define SMEXT_ENABLE_FORWARDSYS
21.66 +//#define SMEXT_ENABLE_HANDLESYS
21.67 +#define SMEXT_ENABLE_PLAYERHELPERS
21.68 +//#define SMEXT_ENABLE_DBMANAGER
21.69 +#define SMEXT_ENABLE_GAMECONF
21.70 +//#define SMEXT_ENABLE_MEMUTILS
21.71 +#define SMEXT_ENABLE_GAMEHELPERS
21.72 +#define SMEXT_ENABLE_TIMERSYS
21.73 +//#define SMEXT_ENABLE_THREADER
21.74 +//#define SMEXT_ENABLE_LIBSYS
21.75 +#define SMEXT_ENABLE_USERMSGS
21.76 +#define SMEXT_ENABLE_PLUGINSYS
21.77 +
21.78 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
22.1 --- a/extensions/curl/AMBuilder Wed Apr 23 21:40:50 2014 -0400
22.2 +++ b/extensions/curl/AMBuilder Wed Apr 23 21:19:28 2014 -0500
22.3 @@ -17,7 +17,7 @@
22.4 binary.sources += [
22.5 'extension.cpp',
22.6 'curlapi.cpp',
22.7 - 'sdk/smsdk_ext.cpp',
22.8 + '../../public/smsdk_ext.cpp'
22.9 ]
22.10
22.11 SM.extensions += [builder.Add(binary)]
23.1 --- a/extensions/curl/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,80 +0,0 @@
23.4 -/**
23.5 - * vim: set ts=4 :
23.6 - * =============================================================================
23.7 - * SourceMod Sample Extension
23.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
23.9 - * =============================================================================
23.10 - *
23.11 - * This program is free software; you can redistribute it and/or modify it under
23.12 - * the terms of the GNU General Public License, version 3.0, as published by the
23.13 - * Free Software Foundation.
23.14 - *
23.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
23.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23.18 - * details.
23.19 - *
23.20 - * You should have received a copy of the GNU General Public License along with
23.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
23.22 - *
23.23 - * As a special exception, AlliedModders LLC gives you permission to link the
23.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
23.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23.26 - * by the Valve Corporation. You must obey the GNU General Public License in
23.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
23.28 - * this exception to all derivative works. AlliedModders LLC defines further
23.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
23.30 - * or <http://www.sourcemod.net/license.php>.
23.31 - *
23.32 - * Version: $Id$
23.33 - */
23.34 -
23.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
23.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
23.37 -
23.38 -/**
23.39 - * @file smsdk_config.h
23.40 - * @brief Contains macros for configuring basic extension information.
23.41 - */
23.42 -
23.43 -/* Basic information exposed publicly */
23.44 -#define SMEXT_CONF_NAME "Webternet"
23.45 -#define SMEXT_CONF_DESCRIPTION "Extension for interacting with URLs"
23.46 -#define SMEXT_CONF_VERSION ""
23.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
23.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
23.49 -#define SMEXT_CONF_LOGTAG "WEB"
23.50 -#define SMEXT_CONF_LICENSE "GPL"
23.51 -#define SMEXT_CONF_DATESTRING ""
23.52 -
23.53 -/**
23.54 - * @brief Exposes plugin's main interface.
23.55 - */
23.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
23.57 -
23.58 -/**
23.59 - * @brief Sets whether or not this plugin required Metamod.
23.60 - * NOTE: Uncomment to enable, comment to disable.
23.61 - */
23.62 -//#define SMEXT_CONF_METAMOD
23.63 -
23.64 -/** Enable interfaces you want to use here by uncommenting lines */
23.65 -//#define SMEXT_ENABLE_FORWARDSYS
23.66 -//#define SMEXT_ENABLE_HANDLESYS
23.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
23.68 -//#define SMEXT_ENABLE_DBMANAGER
23.69 -//#define SMEXT_ENABLE_GAMECONF
23.70 -//#define SMEXT_ENABLE_MEMUTILS
23.71 -//#define SMEXT_ENABLE_GAMEHELPERS
23.72 -//#define SMEXT_ENABLE_TIMERSYS
23.73 -//#define SMEXT_ENABLE_THREADER
23.74 -//#define SMEXT_ENABLE_LIBSYS
23.75 -//#define SMEXT_ENABLE_MENUS
23.76 -//#define SMEXT_ENABLE_ADTFACTORY
23.77 -//#define SMEXT_ENABLE_PLUGINSYS
23.78 -//#define SMEXT_ENABLE_ADMINSYS
23.79 -//#define SMEXT_ENABLE_TEXTPARSERS
23.80 -//#define SMEXT_ENABLE_USERMSGS
23.81 -//#define SMEXT_ENABLE_TRANSLATOR
23.82 -
23.83 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
24.1 --- a/extensions/curl/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,462 +0,0 @@
24.4 -/**
24.5 - * vim: set ts=4 :
24.6 - * =============================================================================
24.7 - * SourceMod Base Extension Code
24.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
24.9 - * =============================================================================
24.10 - *
24.11 - * This program is free software; you can redistribute it and/or modify it under
24.12 - * the terms of the GNU General Public License, version 3.0, as published by the
24.13 - * Free Software Foundation.
24.14 - *
24.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
24.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24.18 - * details.
24.19 - *
24.20 - * You should have received a copy of the GNU General Public License along with
24.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
24.22 - *
24.23 - * As a special exception, AlliedModders LLC gives you permission to link the
24.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
24.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24.26 - * by the Valve Corporation. You must obey the GNU General Public License in
24.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
24.28 - * this exception to all derivative works. AlliedModders LLC defines further
24.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
24.30 - * or <http://www.sourcemod.net/license.php>.
24.31 - *
24.32 - * Version: $Id$
24.33 - */
24.34 -
24.35 -#include <stdio.h>
24.36 -#include <stdlib.h>
24.37 -#include "smsdk_ext.h"
24.38 -
24.39 -/**
24.40 - * @file smsdk_ext.cpp
24.41 - * @brief Contains wrappers for making Extensions easier to write.
24.42 - */
24.43 -
24.44 -IExtension *myself = NULL; /**< Ourself */
24.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
24.46 -IShareSys *sharesys = NULL; /**< Share system */
24.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
24.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
24.49 -
24.50 -#if defined SMEXT_ENABLE_FORWARDSYS
24.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
24.52 -IForwardManager *forwards = NULL; /**< Forward system */
24.53 -#endif
24.54 -#if defined SMEXT_ENABLE_HANDLESYS
24.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
24.56 -IHandleSys *handlesys = NULL; /**< Handle system */
24.57 -#endif
24.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
24.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
24.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
24.61 -#if defined SMEXT_ENABLE_DBMANAGER
24.62 -IDBManager *dbi = NULL; /**< DB Manager */
24.63 -#endif //SMEXT_ENABLE_DBMANAGER
24.64 -#if defined SMEXT_ENABLE_GAMECONF
24.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
24.66 -#endif //SMEXT_ENABLE_DBMANAGER
24.67 -#if defined SMEXT_ENABLE_MEMUTILS
24.68 -IMemoryUtils *memutils = NULL;
24.69 -#endif //SMEXT_ENABLE_DBMANAGER
24.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
24.71 -IGameHelpers *gamehelpers = NULL;
24.72 -#endif
24.73 -#if defined SMEXT_ENABLE_TIMERSYS
24.74 -ITimerSystem *timersys = NULL;
24.75 -#endif
24.76 -#if defined SMEXT_ENABLE_ADTFACTORY
24.77 -IADTFactory *adtfactory = NULL;
24.78 -#endif
24.79 -#if defined SMEXT_ENABLE_THREADER
24.80 -IThreader *threader = NULL;
24.81 -#endif
24.82 -#if defined SMEXT_ENABLE_LIBSYS
24.83 -ILibrarySys *libsys = NULL;
24.84 -#endif
24.85 -#if defined SMEXT_ENABLE_PLUGINSYS
24.86 -SourceMod::IPluginManager *plsys;
24.87 -#endif
24.88 -#if defined SMEXT_ENABLE_MENUS
24.89 -IMenuManager *menus = NULL;
24.90 -#endif
24.91 -#if defined SMEXT_ENABLE_ADMINSYS
24.92 -IAdminSystem *adminsys = NULL;
24.93 -#endif
24.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
24.95 -ITextParsers *textparsers = NULL;
24.96 -#endif
24.97 -#if defined SMEXT_ENABLE_USERMSGS
24.98 -IUserMessages *usermsgs = NULL;
24.99 -#endif
24.100 -#if defined SMEXT_ENABLE_TRANSLATOR
24.101 -ITranslator *translator = NULL;
24.102 -#endif
24.103 -
24.104 -/** Exports the main interface */
24.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
24.106 -{
24.107 - return g_pExtensionIface;
24.108 -}
24.109 -
24.110 -SDKExtension::SDKExtension()
24.111 -{
24.112 -#if defined SMEXT_CONF_METAMOD
24.113 - m_SourceMMLoaded = false;
24.114 - m_WeAreUnloaded = false;
24.115 - m_WeGotPauseChange = false;
24.116 -#endif
24.117 -}
24.118 -
24.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
24.120 -{
24.121 - g_pShareSys = sharesys = sys;
24.122 - myself = me;
24.123 -
24.124 -#if defined SMEXT_CONF_METAMOD
24.125 - m_WeAreUnloaded = true;
24.126 -
24.127 - if (!m_SourceMMLoaded)
24.128 - {
24.129 - if (error)
24.130 - {
24.131 - snprintf(error, maxlength, "Metamod attach failed");
24.132 - }
24.133 - return false;
24.134 - }
24.135 -#endif
24.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
24.137 - smutils = g_pSM;
24.138 -#if defined SMEXT_ENABLE_HANDLESYS
24.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
24.140 - handlesys = g_pHandleSys;
24.141 -#endif
24.142 -#if defined SMEXT_ENABLE_FORWARDSYS
24.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
24.144 - forwards = g_pForwards;
24.145 -#endif
24.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
24.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
24.148 -#endif
24.149 -#if defined SMEXT_ENABLE_DBMANAGER
24.150 - SM_GET_IFACE(DBI, dbi);
24.151 -#endif
24.152 -#if defined SMEXT_ENABLE_GAMECONF
24.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
24.154 -#endif
24.155 -#if defined SMEXT_ENABLE_MEMUTILS
24.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
24.157 -#endif
24.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
24.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
24.160 -#endif
24.161 -#if defined SMEXT_ENABLE_TIMERSYS
24.162 - SM_GET_IFACE(TIMERSYS, timersys);
24.163 -#endif
24.164 -#if defined SMEXT_ENABLE_ADTFACTORY
24.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
24.166 -#endif
24.167 -#if defined SMEXT_ENABLE_THREADER
24.168 - SM_GET_IFACE(THREADER, threader);
24.169 -#endif
24.170 -#if defined SMEXT_ENABLE_LIBSYS
24.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
24.172 -#endif
24.173 -#if defined SMEXT_ENABLE_PLUGINSYS
24.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
24.175 -#endif
24.176 -#if defined SMEXT_ENABLE_MENUS
24.177 - SM_GET_IFACE(MENUMANAGER, menus);
24.178 -#endif
24.179 -#if defined SMEXT_ENABLE_ADMINSYS
24.180 - SM_GET_IFACE(ADMINSYS, adminsys);
24.181 -#endif
24.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
24.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
24.184 -#endif
24.185 -#if defined SMEXT_ENABLE_USERMSGS
24.186 - SM_GET_IFACE(USERMSGS, usermsgs);
24.187 -#endif
24.188 -#if defined SMEXT_ENABLE_TRANSLATOR
24.189 - SM_GET_IFACE(TRANSLATOR, translator);
24.190 -#endif
24.191 -
24.192 - if (SDK_OnLoad(error, maxlength, late))
24.193 - {
24.194 -#if defined SMEXT_CONF_METAMOD
24.195 - m_WeAreUnloaded = true;
24.196 -#endif
24.197 - return true;
24.198 - }
24.199 -
24.200 - return false;
24.201 -}
24.202 -
24.203 -bool SDKExtension::IsMetamodExtension()
24.204 -{
24.205 -#if defined SMEXT_CONF_METAMOD
24.206 - return true;
24.207 -#else
24.208 - return false;
24.209 -#endif
24.210 -}
24.211 -
24.212 -void SDKExtension::OnExtensionPauseChange(bool state)
24.213 -{
24.214 -#if defined SMEXT_CONF_METAMOD
24.215 - m_WeGotPauseChange = true;
24.216 -#endif
24.217 - SDK_OnPauseChange(state);
24.218 -}
24.219 -
24.220 -void SDKExtension::OnExtensionsAllLoaded()
24.221 -{
24.222 - SDK_OnAllLoaded();
24.223 -}
24.224 -
24.225 -void SDKExtension::OnExtensionUnload()
24.226 -{
24.227 -#if defined SMEXT_CONF_METAMOD
24.228 - m_WeAreUnloaded = true;
24.229 -#endif
24.230 - SDK_OnUnload();
24.231 -}
24.232 -
24.233 -const char *SDKExtension::GetExtensionAuthor()
24.234 -{
24.235 - return SMEXT_CONF_AUTHOR;
24.236 -}
24.237 -
24.238 -const char *SDKExtension::GetExtensionDateString()
24.239 -{
24.240 - return SMEXT_CONF_DATESTRING;
24.241 -}
24.242 -
24.243 -const char *SDKExtension::GetExtensionDescription()
24.244 -{
24.245 - return SMEXT_CONF_DESCRIPTION;
24.246 -}
24.247 -
24.248 -const char *SDKExtension::GetExtensionVerString()
24.249 -{
24.250 - return SMEXT_CONF_VERSION;
24.251 -}
24.252 -
24.253 -const char *SDKExtension::GetExtensionName()
24.254 -{
24.255 - return SMEXT_CONF_NAME;
24.256 -}
24.257 -
24.258 -const char *SDKExtension::GetExtensionTag()
24.259 -{
24.260 - return SMEXT_CONF_LOGTAG;
24.261 -}
24.262 -
24.263 -const char *SDKExtension::GetExtensionURL()
24.264 -{
24.265 - return SMEXT_CONF_URL;
24.266 -}
24.267 -
24.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
24.269 -{
24.270 - return true;
24.271 -}
24.272 -
24.273 -void SDKExtension::SDK_OnUnload()
24.274 -{
24.275 -}
24.276 -
24.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
24.278 -{
24.279 -}
24.280 -
24.281 -void SDKExtension::SDK_OnAllLoaded()
24.282 -{
24.283 -}
24.284 -
24.285 -#if defined SMEXT_CONF_METAMOD
24.286 -
24.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
24.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
24.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
24.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
24.291 -
24.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
24.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
24.294 -
24.295 -/** Exposes the extension to Metamod */
24.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
24.297 -{
24.298 -#if defined METAMOD_PLAPI_VERSION
24.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
24.300 -#else
24.301 - if (name && !strcmp(name, PLAPI_NAME))
24.302 -#endif
24.303 - {
24.304 - if (code)
24.305 - {
24.306 - *code = IFACE_OK;
24.307 - }
24.308 - return static_cast<void *>(g_pExtensionIface);
24.309 - }
24.310 -
24.311 - if (code)
24.312 - {
24.313 - *code = IFACE_FAILED;
24.314 - }
24.315 -
24.316 - return NULL;
24.317 -}
24.318 -
24.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
24.320 -{
24.321 - PLUGIN_SAVEVARS();
24.322 -
24.323 -#if !defined METAMOD_PLAPI_VERSION
24.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
24.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
24.326 -#else
24.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
24.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
24.329 -#endif
24.330 -
24.331 - m_SourceMMLoaded = true;
24.332 -
24.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
24.334 -}
24.335 -
24.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
24.337 -{
24.338 - if (!m_WeAreUnloaded)
24.339 - {
24.340 - if (error)
24.341 - {
24.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
24.343 - }
24.344 - return false;
24.345 - }
24.346 -
24.347 - return SDK_OnMetamodUnload(error, maxlen);
24.348 -}
24.349 -
24.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
24.351 -{
24.352 - if (!m_WeGotPauseChange)
24.353 - {
24.354 - if (error)
24.355 - {
24.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
24.357 - }
24.358 - return false;
24.359 - }
24.360 -
24.361 - m_WeGotPauseChange = false;
24.362 -
24.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
24.364 -}
24.365 -
24.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
24.367 -{
24.368 - if (!m_WeGotPauseChange)
24.369 - {
24.370 - if (error)
24.371 - {
24.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
24.373 - }
24.374 - return false;
24.375 - }
24.376 -
24.377 - m_WeGotPauseChange = false;
24.378 -
24.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
24.380 -}
24.381 -
24.382 -const char *SDKExtension::GetAuthor()
24.383 -{
24.384 - return GetExtensionAuthor();
24.385 -}
24.386 -
24.387 -const char *SDKExtension::GetDate()
24.388 -{
24.389 - return GetExtensionDateString();
24.390 -}
24.391 -
24.392 -const char *SDKExtension::GetDescription()
24.393 -{
24.394 - return GetExtensionDescription();
24.395 -}
24.396 -
24.397 -const char *SDKExtension::GetLicense()
24.398 -{
24.399 - return SMEXT_CONF_LICENSE;
24.400 -}
24.401 -
24.402 -const char *SDKExtension::GetLogTag()
24.403 -{
24.404 - return GetExtensionTag();
24.405 -}
24.406 -
24.407 -const char *SDKExtension::GetName()
24.408 -{
24.409 - return GetExtensionName();
24.410 -}
24.411 -
24.412 -const char *SDKExtension::GetURL()
24.413 -{
24.414 - return GetExtensionURL();
24.415 -}
24.416 -
24.417 -const char *SDKExtension::GetVersion()
24.418 -{
24.419 - return GetExtensionVerString();
24.420 -}
24.421 -
24.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
24.423 -{
24.424 - return true;
24.425 -}
24.426 -
24.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
24.428 -{
24.429 - return true;
24.430 -}
24.431 -
24.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
24.433 -{
24.434 - return true;
24.435 -}
24.436 -
24.437 -#endif
24.438 -
24.439 -/* Overload a few things to prevent libstdc++ linking */
24.440 -#if defined __linux__ || defined __APPLE__
24.441 -extern "C" void __cxa_pure_virtual(void)
24.442 -{
24.443 -}
24.444 -
24.445 -void *operator new(size_t size)
24.446 -{
24.447 - return malloc(size);
24.448 -}
24.449 -
24.450 -void *operator new[](size_t size)
24.451 -{
24.452 - return malloc(size);
24.453 -}
24.454 -
24.455 -void operator delete(void *ptr)
24.456 -{
24.457 - free(ptr);
24.458 -}
24.459 -
24.460 -void operator delete[](void * ptr)
24.461 -{
24.462 - free(ptr);
24.463 -}
24.464 -#endif
24.465 -
25.1 --- a/extensions/curl/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,333 +0,0 @@
25.4 -/**
25.5 - * vim: set ts=4 :
25.6 - * =============================================================================
25.7 - * SourceMod Base Extension Code
25.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
25.9 - * =============================================================================
25.10 - *
25.11 - * This program is free software; you can redistribute it and/or modify it under
25.12 - * the terms of the GNU General Public License, version 3.0, as published by the
25.13 - * Free Software Foundation.
25.14 - *
25.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
25.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
25.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
25.18 - * details.
25.19 - *
25.20 - * You should have received a copy of the GNU General Public License along with
25.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
25.22 - *
25.23 - * As a special exception, AlliedModders LLC gives you permission to link the
25.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
25.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25.26 - * by the Valve Corporation. You must obey the GNU General Public License in
25.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
25.28 - * this exception to all derivative works. AlliedModders LLC defines further
25.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
25.30 - * or <http://www.sourcemod.net/license.php>.
25.31 - *
25.32 - * Version: $Id$
25.33 - */
25.34 -
25.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
25.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
25.37 -
25.38 -/**
25.39 - * @file smsdk_ext.h
25.40 - * @brief Contains wrappers for making Extensions easier to write.
25.41 - */
25.42 -
25.43 -#include "smsdk_config.h"
25.44 -#include <IExtensionSys.h>
25.45 -#include <IHandleSys.h>
25.46 -#include <sp_vm_api.h>
25.47 -#include <sm_platform.h>
25.48 -#include <ISourceMod.h>
25.49 -#if defined SMEXT_ENABLE_FORWARDSYS
25.50 -#include <IForwardSys.h>
25.51 -#endif //SMEXT_ENABLE_FORWARDSYS
25.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
25.53 -#include <IPlayerHelpers.h>
25.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
25.55 -#if defined SMEXT_ENABLE_DBMANAGER
25.56 -#include <IDBDriver.h>
25.57 -#endif //SMEXT_ENABLE_DBMANAGER
25.58 -#if defined SMEXT_ENABLE_GAMECONF
25.59 -#include <IGameConfigs.h>
25.60 -#endif
25.61 -#if defined SMEXT_ENABLE_MEMUTILS
25.62 -#include <IMemoryUtils.h>
25.63 -#endif
25.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
25.65 -#include <IGameHelpers.h>
25.66 -#endif
25.67 -#if defined SMEXT_ENABLE_TIMERSYS
25.68 -#include <ITimerSystem.h>
25.69 -#endif
25.70 -#if defined SMEXT_ENABLE_ADTFACTORY
25.71 -#include <IADTFactory.h>
25.72 -#endif
25.73 -#if defined SMEXT_ENABLE_THREADER
25.74 -#include <IThreader.h>
25.75 -#endif
25.76 -#if defined SMEXT_ENABLE_LIBSYS
25.77 -#include <ILibrarySys.h>
25.78 -#endif
25.79 -#if defined SMEXT_ENABLE_PLUGINSYS
25.80 -#include <IPluginSys.h>
25.81 -#endif
25.82 -#if defined SMEXT_ENABLE_MENUS
25.83 -#include <IMenuManager.h>
25.84 -#endif
25.85 -#if defined SMEXT_ENABLE_ADMINSYS
25.86 -#include <IAdminSystem.h>
25.87 -#endif
25.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
25.89 -#include <ITextParsers.h>
25.90 -#endif
25.91 -#if defined SMEXT_ENABLE_USERMSGS
25.92 -#include <IUserMessages.h>
25.93 -#endif
25.94 -#if defined SMEXT_ENABLE_TRANSLATOR
25.95 -#include <ITranslator.h>
25.96 -#endif
25.97 -
25.98 -#if defined SMEXT_CONF_METAMOD
25.99 -#include <ISmmPlugin.h>
25.100 -#include <eiface.h>
25.101 -#endif
25.102 -
25.103 -using namespace SourceMod;
25.104 -using namespace SourcePawn;
25.105 -
25.106 -class SDKExtension :
25.107 -#if defined SMEXT_CONF_METAMOD
25.108 - public ISmmPlugin,
25.109 -#endif
25.110 - public IExtensionInterface
25.111 -{
25.112 -public:
25.113 - /** Constructor */
25.114 - SDKExtension();
25.115 -public:
25.116 - /**
25.117 - * @brief This is called after the initial loading sequence has been processed.
25.118 - *
25.119 - * @param error Error message buffer.
25.120 - * @param maxlength Size of error message buffer.
25.121 - * @param late Whether or not the module was loaded after map load.
25.122 - * @return True to succeed loading, false to fail.
25.123 - */
25.124 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
25.125 -
25.126 - /**
25.127 - * @brief This is called right before the extension is unloaded.
25.128 - */
25.129 - virtual void SDK_OnUnload();
25.130 -
25.131 - /**
25.132 - * @brief This is called once all known extensions have been loaded.
25.133 - */
25.134 - virtual void SDK_OnAllLoaded();
25.135 -
25.136 - /**
25.137 - * @brief Called when the pause state is changed.
25.138 - */
25.139 - virtual void SDK_OnPauseChange(bool paused);
25.140 -
25.141 -#if defined SMEXT_CONF_METAMOD
25.142 - /**
25.143 - * @brief Called when Metamod is attached, before the extension version is called.
25.144 - *
25.145 - * @param error Error buffer.
25.146 - * @param maxlength Maximum size of error buffer.
25.147 - * @param late Whether or not Metamod considers this a late load.
25.148 - * @return True to succeed, false to fail.
25.149 - */
25.150 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
25.151 -
25.152 - /**
25.153 - * @brief Called when Metamod is detaching, after the extension version is called.
25.154 - * NOTE: By default this is blocked unless sent from SourceMod.
25.155 - *
25.156 - * @param error Error buffer.
25.157 - * @param maxlength Maximum size of error buffer.
25.158 - * @return True to succeed, false to fail.
25.159 - */
25.160 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
25.161 -
25.162 - /**
25.163 - * @brief Called when Metamod's pause state is changing.
25.164 - * NOTE: By default this is blocked unless sent from SourceMod.
25.165 - *
25.166 - * @param paused Pause state being set.
25.167 - * @param error Error buffer.
25.168 - * @param maxlength Maximum size of error buffer.
25.169 - * @return True to succeed, false to fail.
25.170 - */
25.171 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
25.172 -#endif
25.173 -
25.174 -public: //IExtensionInterface
25.175 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
25.176 - virtual void OnExtensionUnload();
25.177 - virtual void OnExtensionsAllLoaded();
25.178 -
25.179 - /** Returns whether or not this is a Metamod-based extension */
25.180 - virtual bool IsMetamodExtension();
25.181 -
25.182 - /**
25.183 - * @brief Called when the pause state changes.
25.184 - *
25.185 - * @param state True if being paused, false if being unpaused.
25.186 - */
25.187 - virtual void OnExtensionPauseChange(bool state);
25.188 -
25.189 - /** Returns name */
25.190 - virtual const char *GetExtensionName();
25.191 - /** Returns URL */
25.192 - virtual const char *GetExtensionURL();
25.193 - /** Returns log tag */
25.194 - virtual const char *GetExtensionTag();
25.195 - /** Returns author */
25.196 - virtual const char *GetExtensionAuthor();
25.197 - /** Returns version string */
25.198 - virtual const char *GetExtensionVerString();
25.199 - /** Returns description string */
25.200 - virtual const char *GetExtensionDescription();
25.201 - /** Returns date string */
25.202 - virtual const char *GetExtensionDateString();
25.203 -#if defined SMEXT_CONF_METAMOD
25.204 -public: //ISmmPlugin
25.205 - /** Called when the extension is attached to Metamod. */
25.206 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
25.207 - /** Returns the author to MM */
25.208 - virtual const char *GetAuthor();
25.209 - /** Returns the name to MM */
25.210 - virtual const char *GetName();
25.211 - /** Returns the description to MM */
25.212 - virtual const char *GetDescription();
25.213 - /** Returns the URL to MM */
25.214 - virtual const char *GetURL();
25.215 - /** Returns the license to MM */
25.216 - virtual const char *GetLicense();
25.217 - /** Returns the version string to MM */
25.218 - virtual const char *GetVersion();
25.219 - /** Returns the date string to MM */
25.220 - virtual const char *GetDate();
25.221 - /** Returns the logtag to MM */
25.222 - virtual const char *GetLogTag();
25.223 - /** Called on unload */
25.224 - virtual bool Unload(char *error, size_t maxlength);
25.225 - /** Called on pause */
25.226 - virtual bool Pause(char *error, size_t maxlength);
25.227 - /** Called on unpause */
25.228 - virtual bool Unpause(char *error, size_t maxlength);
25.229 -private:
25.230 - bool m_SourceMMLoaded;
25.231 - bool m_WeAreUnloaded;
25.232 - bool m_WeGotPauseChange;
25.233 -#endif
25.234 -};
25.235 -
25.236 -extern SDKExtension *g_pExtensionIface;
25.237 -extern IExtension *myself;
25.238 -
25.239 -extern IShareSys *g_pShareSys;
25.240 -extern IShareSys *sharesys; /* Note: Newer name */
25.241 -extern ISourceMod *g_pSM;
25.242 -extern ISourceMod *smutils; /* Note: Newer name */
25.243 -
25.244 -/* Optional interfaces are below */
25.245 -#if defined SMEXT_ENABLE_FORWARDSYS
25.246 -extern IForwardManager *g_pForwards;
25.247 -extern IForwardManager *forwards; /* Note: Newer name */
25.248 -#endif //SMEXT_ENABLE_FORWARDSYS
25.249 -#if defined SMEXT_ENABLE_HANDLESYS
25.250 -extern IHandleSys *g_pHandleSys;
25.251 -extern IHandleSys *handlesys; /* Note: Newer name */
25.252 -#endif //SMEXT_ENABLE_HANDLESYS
25.253 -#if defined SMEXT_ENABLE_PLAYERHELPERS
25.254 -extern IPlayerManager *playerhelpers;
25.255 -#endif //SMEXT_ENABLE_PLAYERHELPERS
25.256 -#if defined SMEXT_ENABLE_DBMANAGER
25.257 -extern IDBManager *dbi;
25.258 -#endif //SMEXT_ENABLE_DBMANAGER
25.259 -#if defined SMEXT_ENABLE_GAMECONF
25.260 -extern IGameConfigManager *gameconfs;
25.261 -#endif //SMEXT_ENABLE_DBMANAGER
25.262 -#if defined SMEXT_ENABLE_MEMUTILS
25.263 -extern IMemoryUtils *memutils;
25.264 -#endif
25.265 -#if defined SMEXT_ENABLE_GAMEHELPERS
25.266 -extern IGameHelpers *gamehelpers;
25.267 -#endif
25.268 -#if defined SMEXT_ENABLE_TIMERSYS
25.269 -extern ITimerSystem *timersys;
25.270 -#endif
25.271 -#if defined SMEXT_ENABLE_ADTFACTORY
25.272 -extern IADTFactory *adtfactory;
25.273 -#endif
25.274 -#if defined SMEXT_ENABLE_THREADER
25.275 -extern IThreader *threader;
25.276 -#endif
25.277 -#if defined SMEXT_ENABLE_LIBSYS
25.278 -extern ILibrarySys *libsys;
25.279 -#endif
25.280 -#if defined SMEXT_ENABLE_PLUGINSYS
25.281 -extern SourceMod::IPluginManager *plsys;
25.282 -#endif
25.283 -#if defined SMEXT_ENABLE_MENUS
25.284 -extern IMenuManager *menus;
25.285 -#endif
25.286 -#if defined SMEXT_ENABLE_ADMINSYS
25.287 -extern IAdminSystem *adminsys;
25.288 -#endif
25.289 -#if defined SMEXT_ENABLE_USERMSGS
25.290 -extern IUserMessages *usermsgs;
25.291 -#endif
25.292 -#if defined SMEXT_ENABLE_TRANSLATOR
25.293 -extern ITranslator *translator;
25.294 -#endif
25.295 -
25.296 -#if defined SMEXT_CONF_METAMOD
25.297 -PLUGIN_GLOBALVARS();
25.298 -extern IVEngineServer *engine;
25.299 -extern IServerGameDLL *gamedll;
25.300 -#endif
25.301 -
25.302 -/** Creates a SourceMod interface macro pair */
25.303 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
25.304 -/** Automates retrieving SourceMod interfaces */
25.305 -#define SM_GET_IFACE(prefix, addr) \
25.306 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
25.307 - { \
25.308 - if (error != NULL && maxlength) \
25.309 - { \
25.310 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
25.311 - if (len >= maxlength) \
25.312 - { \
25.313 - error[maxlength - 1] = '\0'; \
25.314 - } \
25.315 - } \
25.316 - return false; \
25.317 - }
25.318 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
25.319 -#define SM_GET_LATE_IFACE(prefix, addr) \
25.320 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
25.321 -/** Validates a SourceMod interface pointer */
25.322 -#define SM_CHECK_IFACE(prefix, addr) \
25.323 - if (!addr) \
25.324 - { \
25.325 - if (error != NULL && maxlength) \
25.326 - { \
25.327 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
25.328 - if (len >= maxlength) \
25.329 - { \
25.330 - error[maxlength - 1] = '\0'; \
25.331 - } \
25.332 - } \
25.333 - return false; \
25.334 - }
25.335 -
25.336 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/extensions/curl/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
26.3 @@ -0,0 +1,80 @@
26.4 +/**
26.5 + * vim: set ts=4 :
26.6 + * =============================================================================
26.7 + * SourceMod Sample Extension
26.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
26.9 + * =============================================================================
26.10 + *
26.11 + * This program is free software; you can redistribute it and/or modify it under
26.12 + * the terms of the GNU General Public License, version 3.0, as published by the
26.13 + * Free Software Foundation.
26.14 + *
26.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
26.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
26.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
26.18 + * details.
26.19 + *
26.20 + * You should have received a copy of the GNU General Public License along with
26.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
26.22 + *
26.23 + * As a special exception, AlliedModders LLC gives you permission to link the
26.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
26.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
26.26 + * by the Valve Corporation. You must obey the GNU General Public License in
26.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
26.28 + * this exception to all derivative works. AlliedModders LLC defines further
26.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
26.30 + * or <http://www.sourcemod.net/license.php>.
26.31 + *
26.32 + * Version: $Id$
26.33 + */
26.34 +
26.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
26.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
26.37 +
26.38 +/**
26.39 + * @file smsdk_config.h
26.40 + * @brief Contains macros for configuring basic extension information.
26.41 + */
26.42 +
26.43 +/* Basic information exposed publicly */
26.44 +#define SMEXT_CONF_NAME "Webternet"
26.45 +#define SMEXT_CONF_DESCRIPTION "Extension for interacting with URLs"
26.46 +#define SMEXT_CONF_VERSION ""
26.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
26.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
26.49 +#define SMEXT_CONF_LOGTAG "WEB"
26.50 +#define SMEXT_CONF_LICENSE "GPL"
26.51 +#define SMEXT_CONF_DATESTRING ""
26.52 +
26.53 +/**
26.54 + * @brief Exposes plugin's main interface.
26.55 + */
26.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
26.57 +
26.58 +/**
26.59 + * @brief Sets whether or not this plugin required Metamod.
26.60 + * NOTE: Uncomment to enable, comment to disable.
26.61 + */
26.62 +//#define SMEXT_CONF_METAMOD
26.63 +
26.64 +/** Enable interfaces you want to use here by uncommenting lines */
26.65 +//#define SMEXT_ENABLE_FORWARDSYS
26.66 +//#define SMEXT_ENABLE_HANDLESYS
26.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
26.68 +//#define SMEXT_ENABLE_DBMANAGER
26.69 +//#define SMEXT_ENABLE_GAMECONF
26.70 +//#define SMEXT_ENABLE_MEMUTILS
26.71 +//#define SMEXT_ENABLE_GAMEHELPERS
26.72 +//#define SMEXT_ENABLE_TIMERSYS
26.73 +//#define SMEXT_ENABLE_THREADER
26.74 +//#define SMEXT_ENABLE_LIBSYS
26.75 +//#define SMEXT_ENABLE_MENUS
26.76 +//#define SMEXT_ENABLE_ADTFACTORY
26.77 +//#define SMEXT_ENABLE_PLUGINSYS
26.78 +//#define SMEXT_ENABLE_ADMINSYS
26.79 +//#define SMEXT_ENABLE_TEXTPARSERS
26.80 +//#define SMEXT_ENABLE_USERMSGS
26.81 +//#define SMEXT_ENABLE_TRANSLATOR
26.82 +
26.83 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
27.1 --- a/extensions/geoip/AMBuilder Wed Apr 23 21:40:50 2014 -0400
27.2 +++ b/extensions/geoip/AMBuilder Wed Apr 23 21:19:28 2014 -0500
27.3 @@ -8,7 +8,7 @@
27.4 binary.sources += [
27.5 'extension.cpp',
27.6 'GeoIP.c',
27.7 - 'sdk/smsdk_ext.cpp'
27.8 + '../../public/smsdk_ext.cpp'
27.9 ]
27.10
27.11 SM.extensions += [builder.Add(binary)]
28.1 --- a/extensions/geoip/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,68 +0,0 @@
28.4 -/**
28.5 - * vim: set ts=4 :
28.6 - * =============================================================================
28.7 - * SourceMod GeoIP Extension
28.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
28.9 - * =============================================================================
28.10 - *
28.11 - * This program is free software; you can redistribute it and/or modify it under
28.12 - * the terms of the GNU General Public License, version 3.0, as published by the
28.13 - * Free Software Foundation.
28.14 - *
28.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
28.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
28.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
28.18 - * details.
28.19 - *
28.20 - * You should have received a copy of the GNU General Public License along with
28.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
28.22 - *
28.23 - * As a special exception, AlliedModders LLC gives you permission to link the
28.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
28.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
28.26 - * by the Valve Corporation. You must obey the GNU General Public License in
28.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
28.28 - * this exception to all derivative works. AlliedModders LLC defines further
28.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28.30 - * or <http://www.sourcemod.net/license.php>.
28.31 - *
28.32 - * Version: $Id$
28.33 - */
28.34 -
28.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
28.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
28.37 -
28.38 -/**
28.39 - * @file smsdk_config.h
28.40 - * @brief Contains macros for configuring basic extension information.
28.41 - */
28.42 -
28.43 -/* Basic information exposed publicly */
28.44 -#define SMEXT_CONF_NAME "GeoIP"
28.45 -#define SMEXT_CONF_DESCRIPTION "Geographical IP information"
28.46 -#define SMEXT_CONF_VERSION ""
28.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
28.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
28.49 -#define SMEXT_CONF_LOGTAG "GEOIP"
28.50 -#define SMEXT_CONF_LICENSE "GPL"
28.51 -#define SMEXT_CONF_DATESTRING ""
28.52 -
28.53 -/**
28.54 - * @brief Exposes plugin's main interface.
28.55 - */
28.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
28.57 -
28.58 -/**
28.59 - * @brief Sets whether or not this plugin required Metamod.
28.60 - * NOTE: Uncomment to enable, comment to disable.
28.61 - */
28.62 -//#define SMEXT_CONF_METAMOD
28.63 -
28.64 -/** Enable interfaces you want to use here by uncommenting lines */
28.65 -//#define SMEXT_ENABLE_FORWARDSYS
28.66 -//#define SMEXT_ENABLE_HANDLESYS
28.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
28.68 -//#define SMEXT_ENABLE_DBMANAGER
28.69 -//#define SMEXT_ENABLE_GAMECONF
28.70 -
28.71 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
29.1 --- a/extensions/geoip/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,462 +0,0 @@
29.4 -/**
29.5 - * vim: set ts=4 :
29.6 - * =============================================================================
29.7 - * SourceMod Base Extension Code
29.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
29.9 - * =============================================================================
29.10 - *
29.11 - * This program is free software; you can redistribute it and/or modify it under
29.12 - * the terms of the GNU General Public License, version 3.0, as published by the
29.13 - * Free Software Foundation.
29.14 - *
29.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
29.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
29.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
29.18 - * details.
29.19 - *
29.20 - * You should have received a copy of the GNU General Public License along with
29.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
29.22 - *
29.23 - * As a special exception, AlliedModders LLC gives you permission to link the
29.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
29.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
29.26 - * by the Valve Corporation. You must obey the GNU General Public License in
29.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
29.28 - * this exception to all derivative works. AlliedModders LLC defines further
29.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29.30 - * or <http://www.sourcemod.net/license.php>.
29.31 - *
29.32 - * Version: $Id$
29.33 - */
29.34 -
29.35 -#include <stdio.h>
29.36 -#include <stdlib.h>
29.37 -#include "smsdk_ext.h"
29.38 -
29.39 -/**
29.40 - * @file smsdk_ext.cpp
29.41 - * @brief Contains wrappers for making Extensions easier to write.
29.42 - */
29.43 -
29.44 -IExtension *myself = NULL; /**< Ourself */
29.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
29.46 -IShareSys *sharesys = NULL; /**< Share system */
29.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
29.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
29.49 -
29.50 -#if defined SMEXT_ENABLE_FORWARDSYS
29.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
29.52 -IForwardManager *forwards = NULL; /**< Forward system */
29.53 -#endif
29.54 -#if defined SMEXT_ENABLE_HANDLESYS
29.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
29.56 -IHandleSys *handlesys = NULL; /**< Handle system */
29.57 -#endif
29.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
29.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
29.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
29.61 -#if defined SMEXT_ENABLE_DBMANAGER
29.62 -IDBManager *dbi = NULL; /**< DB Manager */
29.63 -#endif //SMEXT_ENABLE_DBMANAGER
29.64 -#if defined SMEXT_ENABLE_GAMECONF
29.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
29.66 -#endif //SMEXT_ENABLE_DBMANAGER
29.67 -#if defined SMEXT_ENABLE_MEMUTILS
29.68 -IMemoryUtils *memutils = NULL;
29.69 -#endif //SMEXT_ENABLE_DBMANAGER
29.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
29.71 -IGameHelpers *gamehelpers = NULL;
29.72 -#endif
29.73 -#if defined SMEXT_ENABLE_TIMERSYS
29.74 -ITimerSystem *timersys = NULL;
29.75 -#endif
29.76 -#if defined SMEXT_ENABLE_ADTFACTORY
29.77 -IADTFactory *adtfactory = NULL;
29.78 -#endif
29.79 -#if defined SMEXT_ENABLE_THREADER
29.80 -IThreader *threader = NULL;
29.81 -#endif
29.82 -#if defined SMEXT_ENABLE_LIBSYS
29.83 -ILibrarySys *libsys = NULL;
29.84 -#endif
29.85 -#if defined SMEXT_ENABLE_PLUGINSYS
29.86 -SourceMod::IPluginManager *plsys;
29.87 -#endif
29.88 -#if defined SMEXT_ENABLE_MENUS
29.89 -IMenuManager *menus = NULL;
29.90 -#endif
29.91 -#if defined SMEXT_ENABLE_ADMINSYS
29.92 -IAdminSystem *adminsys = NULL;
29.93 -#endif
29.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
29.95 -ITextParsers *textparsers = NULL;
29.96 -#endif
29.97 -#if defined SMEXT_ENABLE_USERMSGS
29.98 -IUserMessages *usermsgs = NULL;
29.99 -#endif
29.100 -#if defined SMEXT_ENABLE_TRANSLATOR
29.101 -ITranslator *translator = NULL;
29.102 -#endif
29.103 -
29.104 -/** Exports the main interface */
29.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
29.106 -{
29.107 - return g_pExtensionIface;
29.108 -}
29.109 -
29.110 -SDKExtension::SDKExtension()
29.111 -{
29.112 -#if defined SMEXT_CONF_METAMOD
29.113 - m_SourceMMLoaded = false;
29.114 - m_WeAreUnloaded = false;
29.115 - m_WeGotPauseChange = false;
29.116 -#endif
29.117 -}
29.118 -
29.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
29.120 -{
29.121 - g_pShareSys = sharesys = sys;
29.122 - myself = me;
29.123 -
29.124 -#if defined SMEXT_CONF_METAMOD
29.125 - m_WeAreUnloaded = true;
29.126 -
29.127 - if (!m_SourceMMLoaded)
29.128 - {
29.129 - if (error)
29.130 - {
29.131 - snprintf(error, maxlength, "Metamod attach failed");
29.132 - }
29.133 - return false;
29.134 - }
29.135 -#endif
29.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
29.137 - smutils = g_pSM;
29.138 -#if defined SMEXT_ENABLE_HANDLESYS
29.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
29.140 - handlesys = g_pHandleSys;
29.141 -#endif
29.142 -#if defined SMEXT_ENABLE_FORWARDSYS
29.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
29.144 - forwards = g_pForwards;
29.145 -#endif
29.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
29.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
29.148 -#endif
29.149 -#if defined SMEXT_ENABLE_DBMANAGER
29.150 - SM_GET_IFACE(DBI, dbi);
29.151 -#endif
29.152 -#if defined SMEXT_ENABLE_GAMECONF
29.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
29.154 -#endif
29.155 -#if defined SMEXT_ENABLE_MEMUTILS
29.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
29.157 -#endif
29.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
29.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
29.160 -#endif
29.161 -#if defined SMEXT_ENABLE_TIMERSYS
29.162 - SM_GET_IFACE(TIMERSYS, timersys);
29.163 -#endif
29.164 -#if defined SMEXT_ENABLE_ADTFACTORY
29.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
29.166 -#endif
29.167 -#if defined SMEXT_ENABLE_THREADER
29.168 - SM_GET_IFACE(THREADER, threader);
29.169 -#endif
29.170 -#if defined SMEXT_ENABLE_LIBSYS
29.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
29.172 -#endif
29.173 -#if defined SMEXT_ENABLE_PLUGINSYS
29.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
29.175 -#endif
29.176 -#if defined SMEXT_ENABLE_MENUS
29.177 - SM_GET_IFACE(MENUMANAGER, menus);
29.178 -#endif
29.179 -#if defined SMEXT_ENABLE_ADMINSYS
29.180 - SM_GET_IFACE(ADMINSYS, adminsys);
29.181 -#endif
29.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
29.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
29.184 -#endif
29.185 -#if defined SMEXT_ENABLE_USERMSGS
29.186 - SM_GET_IFACE(USERMSGS, usermsgs);
29.187 -#endif
29.188 -#if defined SMEXT_ENABLE_TRANSLATOR
29.189 - SM_GET_IFACE(TRANSLATOR, translator);
29.190 -#endif
29.191 -
29.192 - if (SDK_OnLoad(error, maxlength, late))
29.193 - {
29.194 -#if defined SMEXT_CONF_METAMOD
29.195 - m_WeAreUnloaded = true;
29.196 -#endif
29.197 - return true;
29.198 - }
29.199 -
29.200 - return false;
29.201 -}
29.202 -
29.203 -bool SDKExtension::IsMetamodExtension()
29.204 -{
29.205 -#if defined SMEXT_CONF_METAMOD
29.206 - return true;
29.207 -#else
29.208 - return false;
29.209 -#endif
29.210 -}
29.211 -
29.212 -void SDKExtension::OnExtensionPauseChange(bool state)
29.213 -{
29.214 -#if defined SMEXT_CONF_METAMOD
29.215 - m_WeGotPauseChange = true;
29.216 -#endif
29.217 - SDK_OnPauseChange(state);
29.218 -}
29.219 -
29.220 -void SDKExtension::OnExtensionsAllLoaded()
29.221 -{
29.222 - SDK_OnAllLoaded();
29.223 -}
29.224 -
29.225 -void SDKExtension::OnExtensionUnload()
29.226 -{
29.227 -#if defined SMEXT_CONF_METAMOD
29.228 - m_WeAreUnloaded = true;
29.229 -#endif
29.230 - SDK_OnUnload();
29.231 -}
29.232 -
29.233 -const char *SDKExtension::GetExtensionAuthor()
29.234 -{
29.235 - return SMEXT_CONF_AUTHOR;
29.236 -}
29.237 -
29.238 -const char *SDKExtension::GetExtensionDateString()
29.239 -{
29.240 - return SMEXT_CONF_DATESTRING;
29.241 -}
29.242 -
29.243 -const char *SDKExtension::GetExtensionDescription()
29.244 -{
29.245 - return SMEXT_CONF_DESCRIPTION;
29.246 -}
29.247 -
29.248 -const char *SDKExtension::GetExtensionVerString()
29.249 -{
29.250 - return SMEXT_CONF_VERSION;
29.251 -}
29.252 -
29.253 -const char *SDKExtension::GetExtensionName()
29.254 -{
29.255 - return SMEXT_CONF_NAME;
29.256 -}
29.257 -
29.258 -const char *SDKExtension::GetExtensionTag()
29.259 -{
29.260 - return SMEXT_CONF_LOGTAG;
29.261 -}
29.262 -
29.263 -const char *SDKExtension::GetExtensionURL()
29.264 -{
29.265 - return SMEXT_CONF_URL;
29.266 -}
29.267 -
29.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
29.269 -{
29.270 - return true;
29.271 -}
29.272 -
29.273 -void SDKExtension::SDK_OnUnload()
29.274 -{
29.275 -}
29.276 -
29.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
29.278 -{
29.279 -}
29.280 -
29.281 -void SDKExtension::SDK_OnAllLoaded()
29.282 -{
29.283 -}
29.284 -
29.285 -#if defined SMEXT_CONF_METAMOD
29.286 -
29.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
29.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
29.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
29.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
29.291 -
29.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
29.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
29.294 -
29.295 -/** Exposes the extension to Metamod */
29.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
29.297 -{
29.298 -#if defined METAMOD_PLAPI_VERSION
29.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
29.300 -#else
29.301 - if (name && !strcmp(name, PLAPI_NAME))
29.302 -#endif
29.303 - {
29.304 - if (code)
29.305 - {
29.306 - *code = IFACE_OK;
29.307 - }
29.308 - return static_cast<void *>(g_pExtensionIface);
29.309 - }
29.310 -
29.311 - if (code)
29.312 - {
29.313 - *code = IFACE_FAILED;
29.314 - }
29.315 -
29.316 - return NULL;
29.317 -}
29.318 -
29.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
29.320 -{
29.321 - PLUGIN_SAVEVARS();
29.322 -
29.323 -#if !defined METAMOD_PLAPI_VERSION
29.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
29.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
29.326 -#else
29.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
29.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
29.329 -#endif
29.330 -
29.331 - m_SourceMMLoaded = true;
29.332 -
29.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
29.334 -}
29.335 -
29.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
29.337 -{
29.338 - if (!m_WeAreUnloaded)
29.339 - {
29.340 - if (error)
29.341 - {
29.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
29.343 - }
29.344 - return false;
29.345 - }
29.346 -
29.347 - return SDK_OnMetamodUnload(error, maxlen);
29.348 -}
29.349 -
29.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
29.351 -{
29.352 - if (!m_WeGotPauseChange)
29.353 - {
29.354 - if (error)
29.355 - {
29.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
29.357 - }
29.358 - return false;
29.359 - }
29.360 -
29.361 - m_WeGotPauseChange = false;
29.362 -
29.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
29.364 -}
29.365 -
29.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
29.367 -{
29.368 - if (!m_WeGotPauseChange)
29.369 - {
29.370 - if (error)
29.371 - {
29.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
29.373 - }
29.374 - return false;
29.375 - }
29.376 -
29.377 - m_WeGotPauseChange = false;
29.378 -
29.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
29.380 -}
29.381 -
29.382 -const char *SDKExtension::GetAuthor()
29.383 -{
29.384 - return GetExtensionAuthor();
29.385 -}
29.386 -
29.387 -const char *SDKExtension::GetDate()
29.388 -{
29.389 - return GetExtensionDateString();
29.390 -}
29.391 -
29.392 -const char *SDKExtension::GetDescription()
29.393 -{
29.394 - return GetExtensionDescription();
29.395 -}
29.396 -
29.397 -const char *SDKExtension::GetLicense()
29.398 -{
29.399 - return SMEXT_CONF_LICENSE;
29.400 -}
29.401 -
29.402 -const char *SDKExtension::GetLogTag()
29.403 -{
29.404 - return GetExtensionTag();
29.405 -}
29.406 -
29.407 -const char *SDKExtension::GetName()
29.408 -{
29.409 - return GetExtensionName();
29.410 -}
29.411 -
29.412 -const char *SDKExtension::GetURL()
29.413 -{
29.414 - return GetExtensionURL();
29.415 -}
29.416 -
29.417 -const char *SDKExtension::GetVersion()
29.418 -{
29.419 - return GetExtensionVerString();
29.420 -}
29.421 -
29.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
29.423 -{
29.424 - return true;
29.425 -}
29.426 -
29.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
29.428 -{
29.429 - return true;
29.430 -}
29.431 -
29.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
29.433 -{
29.434 - return true;
29.435 -}
29.436 -
29.437 -#endif
29.438 -
29.439 -/* Overload a few things to prevent libstdc++ linking */
29.440 -#if defined __linux__ || defined __APPLE__
29.441 -extern "C" void __cxa_pure_virtual(void)
29.442 -{
29.443 -}
29.444 -
29.445 -void *operator new(size_t size)
29.446 -{
29.447 - return malloc(size);
29.448 -}
29.449 -
29.450 -void *operator new[](size_t size)
29.451 -{
29.452 - return malloc(size);
29.453 -}
29.454 -
29.455 -void operator delete(void *ptr)
29.456 -{
29.457 - free(ptr);
29.458 -}
29.459 -
29.460 -void operator delete[](void * ptr)
29.461 -{
29.462 - free(ptr);
29.463 -}
29.464 -#endif
29.465 -
30.1 --- a/extensions/geoip/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,300 +0,0 @@
30.4 -/**
30.5 - * vim: set ts=4 :
30.6 - * =============================================================================
30.7 - * SourceMod Base Extension Code
30.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
30.9 - * =============================================================================
30.10 - *
30.11 - * This program is free software; you can redistribute it and/or modify it under
30.12 - * the terms of the GNU General Public License, version 3.0, as published by the
30.13 - * Free Software Foundation.
30.14 - *
30.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
30.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
30.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
30.18 - * details.
30.19 - *
30.20 - * You should have received a copy of the GNU General Public License along with
30.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
30.22 - *
30.23 - * As a special exception, AlliedModders LLC gives you permission to link the
30.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
30.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
30.26 - * by the Valve Corporation. You must obey the GNU General Public License in
30.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
30.28 - * this exception to all derivative works. AlliedModders LLC defines further
30.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
30.30 - * or <http://www.sourcemod.net/license.php>.
30.31 - *
30.32 - * Version: $Id$
30.33 - */
30.34 -
30.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
30.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
30.37 -
30.38 -/**
30.39 - * @file smsdk_ext.h
30.40 - * @brief Contains wrappers for making Extensions easier to write.
30.41 - */
30.42 -
30.43 -#include "smsdk_config.h"
30.44 -#include <IExtensionSys.h>
30.45 -#include <IHandleSys.h>
30.46 -#include <sp_vm_api.h>
30.47 -#include <sm_platform.h>
30.48 -#include <ISourceMod.h>
30.49 -#if defined SMEXT_ENABLE_FORWARDSYS
30.50 -#include <IForwardSys.h>
30.51 -#endif //SMEXT_ENABLE_FORWARDSYS
30.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
30.53 -#include <IPlayerHelpers.h>
30.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
30.55 -#if defined SMEXT_ENABLE_DBMANAGER
30.56 -#include <IDBDriver.h>
30.57 -#endif //SMEXT_ENABLE_DBMANAGER
30.58 -#if defined SMEXT_ENABLE_GAMECONF
30.59 -#include <IGameConfigs.h>
30.60 -#endif
30.61 -#if defined SMEXT_ENABLE_MEMUTILS
30.62 -#include <IMemoryUtils.h>
30.63 -#endif
30.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
30.65 -#include <IGameHelpers.h>
30.66 -#endif
30.67 -#if defined SMEXT_ENABLE_TIMERSYS
30.68 -#include <ITimerSystem.h>
30.69 -#endif
30.70 -#if defined SMEXT_ENABLE_ADTFACTORY
30.71 -#include <IADTFactory.h>
30.72 -#endif
30.73 -#if defined SMEXT_ENABLE_THREADER
30.74 -#include <IThreader.h>
30.75 -#endif
30.76 -#if defined SMEXT_ENABLE_LIBSYS
30.77 -#include <ILibrarySys.h>
30.78 -#endif
30.79 -
30.80 -#if defined SMEXT_CONF_METAMOD
30.81 -#include <ISmmPlugin.h>
30.82 -#include <eiface.h>
30.83 -#endif
30.84 -
30.85 -using namespace SourceMod;
30.86 -using namespace SourcePawn;
30.87 -
30.88 -class SDKExtension :
30.89 -#if defined SMEXT_CONF_METAMOD
30.90 - public ISmmPlugin,
30.91 -#endif
30.92 - public IExtensionInterface
30.93 -{
30.94 -public:
30.95 - /** Constructor */
30.96 - SDKExtension();
30.97 -public:
30.98 - /**
30.99 - * @brief This is called after the initial loading sequence has been processed.
30.100 - *
30.101 - * @param error Error message buffer.
30.102 - * @param maxlength Size of error message buffer.
30.103 - * @param late Whether or not the module was loaded after map load.
30.104 - * @return True to succeed loading, false to fail.
30.105 - */
30.106 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
30.107 -
30.108 - /**
30.109 - * @brief This is called right before the extension is unloaded.
30.110 - */
30.111 - virtual void SDK_OnUnload();
30.112 -
30.113 - /**
30.114 - * @brief This is called once all known extensions have been loaded.
30.115 - */
30.116 - virtual void SDK_OnAllLoaded();
30.117 -
30.118 - /**
30.119 - * @brief Called when the pause state is changed.
30.120 - */
30.121 - virtual void SDK_OnPauseChange(bool paused);
30.122 -
30.123 -#if defined SMEXT_CONF_METAMOD
30.124 - /**
30.125 - * @brief Called when Metamod is attached, before the extension version is called.
30.126 - *
30.127 - * @param error Error buffer.
30.128 - * @param maxlength Maximum size of error buffer.
30.129 - * @param late Whether or not Metamod considers this a late load.
30.130 - * @return True to succeed, false to fail.
30.131 - */
30.132 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
30.133 -
30.134 - /**
30.135 - * @brief Called when Metamod is detaching, after the extension version is called.
30.136 - * NOTE: By default this is blocked unless sent from SourceMod.
30.137 - *
30.138 - * @param error Error buffer.
30.139 - * @param maxlength Maximum size of error buffer.
30.140 - * @return True to succeed, false to fail.
30.141 - */
30.142 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
30.143 -
30.144 - /**
30.145 - * @brief Called when Metamod's pause state is changing.
30.146 - * NOTE: By default this is blocked unless sent from SourceMod.
30.147 - *
30.148 - * @param paused Pause state being set.
30.149 - * @param error Error buffer.
30.150 - * @param maxlength Maximum size of error buffer.
30.151 - * @return True to succeed, false to fail.
30.152 - */
30.153 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
30.154 -#endif
30.155 -
30.156 -public: //IExtensionInterface
30.157 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
30.158 - virtual void OnExtensionUnload();
30.159 - virtual void OnExtensionsAllLoaded();
30.160 -
30.161 - /** Returns whether or not this is a Metamod-based extension */
30.162 - virtual bool IsMetamodExtension();
30.163 -
30.164 - /**
30.165 - * @brief Called when the pause state changes.
30.166 - *
30.167 - * @param state True if being paused, false if being unpaused.
30.168 - */
30.169 - virtual void OnExtensionPauseChange(bool state);
30.170 -
30.171 - /** Returns name */
30.172 - virtual const char *GetExtensionName();
30.173 - /** Returns URL */
30.174 - virtual const char *GetExtensionURL();
30.175 - /** Returns log tag */
30.176 - virtual const char *GetExtensionTag();
30.177 - /** Returns author */
30.178 - virtual const char *GetExtensionAuthor();
30.179 - /** Returns version string */
30.180 - virtual const char *GetExtensionVerString();
30.181 - /** Returns description string */
30.182 - virtual const char *GetExtensionDescription();
30.183 - /** Returns date string */
30.184 - virtual const char *GetExtensionDateString();
30.185 -#if defined SMEXT_CONF_METAMOD
30.186 -public: //ISmmPlugin
30.187 - /** Called when the extension is attached to Metamod. */
30.188 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
30.189 - /** Returns the author to MM */
30.190 - virtual const char *GetAuthor();
30.191 - /** Returns the name to MM */
30.192 - virtual const char *GetName();
30.193 - /** Returns the description to MM */
30.194 - virtual const char *GetDescription();
30.195 - /** Returns the URL to MM */
30.196 - virtual const char *GetURL();
30.197 - /** Returns the license to MM */
30.198 - virtual const char *GetLicense();
30.199 - /** Returns the version string to MM */
30.200 - virtual const char *GetVersion();
30.201 - /** Returns the date string to MM */
30.202 - virtual const char *GetDate();
30.203 - /** Returns the logtag to MM */
30.204 - virtual const char *GetLogTag();
30.205 - /** Called on unload */
30.206 - virtual bool Unload(char *error, size_t maxlength);
30.207 - /** Called on pause */
30.208 - virtual bool Pause(char *error, size_t maxlength);
30.209 - /** Called on unpause */
30.210 - virtual bool Unpause(char *error, size_t maxlength);
30.211 -private:
30.212 - bool m_SourceMMLoaded;
30.213 - bool m_WeAreUnloaded;
30.214 - bool m_WeGotPauseChange;
30.215 -#endif
30.216 -};
30.217 -
30.218 -extern SDKExtension *g_pExtensionIface;
30.219 -extern IExtension *myself;
30.220 -
30.221 -extern IShareSys *g_pShareSys;
30.222 -extern IShareSys *sharesys; /* Note: Newer name */
30.223 -extern ISourceMod *g_pSM;
30.224 -extern ISourceMod *smutils; /* Note: Newer name */
30.225 -
30.226 -/* Optional interfaces are below */
30.227 -#if defined SMEXT_ENABLE_FORWARDSYS
30.228 -extern IForwardManager *g_pForwards;
30.229 -extern IForwardManager *forwards; /* Note: Newer name */
30.230 -#endif //SMEXT_ENABLE_FORWARDSYS
30.231 -#if defined SMEXT_ENABLE_HANDLESYS
30.232 -extern IHandleSys *g_pHandleSys;
30.233 -extern IHandleSys *handlesys; /* Note: Newer name */
30.234 -#endif //SMEXT_ENABLE_HANDLESYS
30.235 -#if defined SMEXT_ENABLE_PLAYERHELPERS
30.236 -extern IPlayerManager *playerhelpers;
30.237 -#endif //SMEXT_ENABLE_PLAYERHELPERS
30.238 -#if defined SMEXT_ENABLE_DBMANAGER
30.239 -extern IDBManager *dbi;
30.240 -#endif //SMEXT_ENABLE_DBMANAGER
30.241 -#if defined SMEXT_ENABLE_GAMECONF
30.242 -extern IGameConfigManager *gameconfs;
30.243 -#endif //SMEXT_ENABLE_DBMANAGER
30.244 -#if defined SMEXT_ENABLE_MEMUTILS
30.245 -extern IMemoryUtils *memutils;
30.246 -#endif
30.247 -#if defined SMEXT_ENABLE_GAMEHELPERS
30.248 -extern IGameHelpers *gamehelpers;
30.249 -#endif
30.250 -#if defined SMEXT_ENABLE_TIMERSYS
30.251 -extern ITimerSystem *timersys;
30.252 -#endif
30.253 -#if defined SMEXT_ENABLE_ADTFACTORY
30.254 -extern IADTFactory *adtfactory;
30.255 -#endif
30.256 -#if defined SMEXT_ENABLE_THREADER
30.257 -extern IThreader *threader;
30.258 -#endif
30.259 -#if defined SMEXT_ENABLE_LIBSYS
30.260 -extern ILibrarySys *libsys;
30.261 -#endif
30.262 -
30.263 -#if defined SMEXT_CONF_METAMOD
30.264 -PLUGIN_GLOBALVARS();
30.265 -extern IVEngineServer *engine;
30.266 -extern IServerGameDLL *gamedll;
30.267 -#endif
30.268 -
30.269 -/** Creates a SourceMod interface macro pair */
30.270 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
30.271 -/** Automates retrieving SourceMod interfaces */
30.272 -#define SM_GET_IFACE(prefix, addr) \
30.273 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
30.274 - { \
30.275 - if (error != NULL && maxlength) \
30.276 - { \
30.277 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
30.278 - if (len >= maxlength) \
30.279 - { \
30.280 - error[maxlength - 1] = '\0'; \
30.281 - } \
30.282 - } \
30.283 - return false; \
30.284 - }
30.285 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
30.286 -#define SM_GET_LATE_IFACE(prefix, addr) \
30.287 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
30.288 -/** Validates a SourceMod interface pointer */
30.289 -#define SM_CHECK_IFACE(prefix, addr) \
30.290 - if (!addr) \
30.291 - { \
30.292 - if (error != NULL && maxlength) \
30.293 - { \
30.294 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
30.295 - if (len >= maxlength) \
30.296 - { \
30.297 - error[maxlength - 1] = '\0'; \
30.298 - } \
30.299 - } \
30.300 - return false; \
30.301 - }
30.302 -
30.303 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/extensions/geoip/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
31.3 @@ -0,0 +1,68 @@
31.4 +/**
31.5 + * vim: set ts=4 :
31.6 + * =============================================================================
31.7 + * SourceMod GeoIP Extension
31.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
31.9 + * =============================================================================
31.10 + *
31.11 + * This program is free software; you can redistribute it and/or modify it under
31.12 + * the terms of the GNU General Public License, version 3.0, as published by the
31.13 + * Free Software Foundation.
31.14 + *
31.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
31.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
31.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
31.18 + * details.
31.19 + *
31.20 + * You should have received a copy of the GNU General Public License along with
31.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
31.22 + *
31.23 + * As a special exception, AlliedModders LLC gives you permission to link the
31.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
31.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
31.26 + * by the Valve Corporation. You must obey the GNU General Public License in
31.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
31.28 + * this exception to all derivative works. AlliedModders LLC defines further
31.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
31.30 + * or <http://www.sourcemod.net/license.php>.
31.31 + *
31.32 + * Version: $Id$
31.33 + */
31.34 +
31.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
31.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
31.37 +
31.38 +/**
31.39 + * @file smsdk_config.h
31.40 + * @brief Contains macros for configuring basic extension information.
31.41 + */
31.42 +
31.43 +/* Basic information exposed publicly */
31.44 +#define SMEXT_CONF_NAME "GeoIP"
31.45 +#define SMEXT_CONF_DESCRIPTION "Geographical IP information"
31.46 +#define SMEXT_CONF_VERSION ""
31.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
31.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
31.49 +#define SMEXT_CONF_LOGTAG "GEOIP"
31.50 +#define SMEXT_CONF_LICENSE "GPL"
31.51 +#define SMEXT_CONF_DATESTRING ""
31.52 +
31.53 +/**
31.54 + * @brief Exposes plugin's main interface.
31.55 + */
31.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
31.57 +
31.58 +/**
31.59 + * @brief Sets whether or not this plugin required Metamod.
31.60 + * NOTE: Uncomment to enable, comment to disable.
31.61 + */
31.62 +//#define SMEXT_CONF_METAMOD
31.63 +
31.64 +/** Enable interfaces you want to use here by uncommenting lines */
31.65 +//#define SMEXT_ENABLE_FORWARDSYS
31.66 +//#define SMEXT_ENABLE_HANDLESYS
31.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
31.68 +//#define SMEXT_ENABLE_DBMANAGER
31.69 +//#define SMEXT_ENABLE_GAMECONF
31.70 +
31.71 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
32.1 --- a/extensions/mysql/AMBuilder Wed Apr 23 21:40:50 2014 -0400
32.2 +++ b/extensions/mysql/AMBuilder Wed Apr 23 21:19:28 2014 -0500
32.3 @@ -23,7 +23,7 @@
32.4 ]
32.5
32.6 binary.sources += [
32.7 - 'sdk/smsdk_ext.cpp',
32.8 + '../../public/smsdk_ext.cpp',
32.9 'mysql/MyBasicResults.cpp',
32.10 'mysql/MyBoundResults.cpp',
32.11 'mysql/MyDatabase.cpp',
33.1 --- a/extensions/mysql/mysql/MyDriver.cpp Wed Apr 23 21:40:50 2014 -0400
33.2 +++ b/extensions/mysql/mysql/MyDriver.cpp Wed Apr 23 21:19:28 2014 -0500
33.3 @@ -31,7 +31,7 @@
33.4
33.5 #include "MyDriver.h"
33.6 #include "MyDatabase.h"
33.7 -#include "sdk/smsdk_ext.h"
33.8 +#include "smsdk_ext.h"
33.9
33.10 MyDriver g_MyDriver;
33.11
34.1 --- a/extensions/mysql/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,72 +0,0 @@
34.4 -/**
34.5 - * vim: set ts=4 :
34.6 - * =============================================================================
34.7 - * SourceMod MySQL Extension
34.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
34.9 - * =============================================================================
34.10 - *
34.11 - * This program is free software; you can redistribute it and/or modify it under
34.12 - * the terms of the GNU General Public License, version 3.0, as published by the
34.13 - * Free Software Foundation.
34.14 - *
34.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
34.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
34.18 - * details.
34.19 - *
34.20 - * You should have received a copy of the GNU General Public License along with
34.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
34.22 - *
34.23 - * As a special exception, AlliedModders LLC gives you permission to link the
34.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
34.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
34.26 - * by the Valve Corporation. You must obey the GNU General Public License in
34.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
34.28 - * this exception to all derivative works. AlliedModders LLC defines further
34.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
34.30 - * or <http://www.sourcemod.net/license.php>.
34.31 - *
34.32 - * Version: $Id$
34.33 - */
34.34 -
34.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
34.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
34.37 -
34.38 -/**
34.39 - * @file smsdk_config.h
34.40 - * @brief Contains macros for configuring basic extension information.
34.41 - */
34.42 -
34.43 -/* Basic information exposed publicly */
34.44 -#define SMEXT_CONF_NAME "MySQL-DBI"
34.45 -#define SMEXT_CONF_DESCRIPTION "MySQL driver implementation for DBI"
34.46 -#define SMEXT_CONF_VERSION ""
34.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
34.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
34.49 -#define SMEXT_CONF_LOGTAG "MYSQL"
34.50 -#define SMEXT_CONF_LICENSE "GPL"
34.51 -#define SMEXT_CONF_DATESTRING ""
34.52 -
34.53 -/**
34.54 - * @brief Exposes plugin's main interface.
34.55 - */
34.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
34.57 -
34.58 -/**
34.59 - * @brief Sets whether or not this plugin required Metamod.
34.60 - * NOTE: Uncomment to enable, comment to disable.
34.61 - */
34.62 -//#define SMEXT_CONF_METAMOD
34.63 -
34.64 -/** Enable interfaces you want to use here by uncommenting lines */
34.65 -//#define SMEXT_ENABLE_FORWARDSYS
34.66 -//#define SMEXT_ENABLE_HANDLESYS
34.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
34.68 -#define SMEXT_ENABLE_DBMANAGER
34.69 -//#define SMEXT_ENABLE_GAMECONF
34.70 -//#define SMEXT_ENABLE_MEMUTILS
34.71 -//#define SMEXT_ENABLE_GAMEHELPERS
34.72 -//#define SMEXT_ENABLE_TIMERSYS
34.73 -//#define SMEXT_ENABLE_THREADER
34.74 -
34.75 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
35.1 --- a/extensions/mysql/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,462 +0,0 @@
35.4 -/**
35.5 - * vim: set ts=4 :
35.6 - * =============================================================================
35.7 - * SourceMod Base Extension Code
35.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
35.9 - * =============================================================================
35.10 - *
35.11 - * This program is free software; you can redistribute it and/or modify it under
35.12 - * the terms of the GNU General Public License, version 3.0, as published by the
35.13 - * Free Software Foundation.
35.14 - *
35.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
35.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
35.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
35.18 - * details.
35.19 - *
35.20 - * You should have received a copy of the GNU General Public License along with
35.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
35.22 - *
35.23 - * As a special exception, AlliedModders LLC gives you permission to link the
35.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
35.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
35.26 - * by the Valve Corporation. You must obey the GNU General Public License in
35.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
35.28 - * this exception to all derivative works. AlliedModders LLC defines further
35.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
35.30 - * or <http://www.sourcemod.net/license.php>.
35.31 - *
35.32 - * Version: $Id$
35.33 - */
35.34 -
35.35 -#include <stdio.h>
35.36 -#include <stdlib.h>
35.37 -#include "smsdk_ext.h"
35.38 -
35.39 -/**
35.40 - * @file smsdk_ext.cpp
35.41 - * @brief Contains wrappers for making Extensions easier to write.
35.42 - */
35.43 -
35.44 -IExtension *myself = NULL; /**< Ourself */
35.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
35.46 -IShareSys *sharesys = NULL; /**< Share system */
35.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
35.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
35.49 -
35.50 -#if defined SMEXT_ENABLE_FORWARDSYS
35.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
35.52 -IForwardManager *forwards = NULL; /**< Forward system */
35.53 -#endif
35.54 -#if defined SMEXT_ENABLE_HANDLESYS
35.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
35.56 -IHandleSys *handlesys = NULL; /**< Handle system */
35.57 -#endif
35.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
35.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
35.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
35.61 -#if defined SMEXT_ENABLE_DBMANAGER
35.62 -IDBManager *dbi = NULL; /**< DB Manager */
35.63 -#endif //SMEXT_ENABLE_DBMANAGER
35.64 -#if defined SMEXT_ENABLE_GAMECONF
35.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
35.66 -#endif //SMEXT_ENABLE_DBMANAGER
35.67 -#if defined SMEXT_ENABLE_MEMUTILS
35.68 -IMemoryUtils *memutils = NULL;
35.69 -#endif //SMEXT_ENABLE_DBMANAGER
35.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
35.71 -IGameHelpers *gamehelpers = NULL;
35.72 -#endif
35.73 -#if defined SMEXT_ENABLE_TIMERSYS
35.74 -ITimerSystem *timersys = NULL;
35.75 -#endif
35.76 -#if defined SMEXT_ENABLE_ADTFACTORY
35.77 -IADTFactory *adtfactory = NULL;
35.78 -#endif
35.79 -#if defined SMEXT_ENABLE_THREADER
35.80 -IThreader *threader = NULL;
35.81 -#endif
35.82 -#if defined SMEXT_ENABLE_LIBSYS
35.83 -ILibrarySys *libsys = NULL;
35.84 -#endif
35.85 -#if defined SMEXT_ENABLE_PLUGINSYS
35.86 -SourceMod::IPluginManager *plsys;
35.87 -#endif
35.88 -#if defined SMEXT_ENABLE_MENUS
35.89 -IMenuManager *menus = NULL;
35.90 -#endif
35.91 -#if defined SMEXT_ENABLE_ADMINSYS
35.92 -IAdminSystem *adminsys = NULL;
35.93 -#endif
35.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
35.95 -ITextParsers *textparsers = NULL;
35.96 -#endif
35.97 -#if defined SMEXT_ENABLE_USERMSGS
35.98 -IUserMessages *usermsgs = NULL;
35.99 -#endif
35.100 -#if defined SMEXT_ENABLE_TRANSLATOR
35.101 -ITranslator *translator = NULL;
35.102 -#endif
35.103 -
35.104 -/** Exports the main interface */
35.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
35.106 -{
35.107 - return g_pExtensionIface;
35.108 -}
35.109 -
35.110 -SDKExtension::SDKExtension()
35.111 -{
35.112 -#if defined SMEXT_CONF_METAMOD
35.113 - m_SourceMMLoaded = false;
35.114 - m_WeAreUnloaded = false;
35.115 - m_WeGotPauseChange = false;
35.116 -#endif
35.117 -}
35.118 -
35.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
35.120 -{
35.121 - g_pShareSys = sharesys = sys;
35.122 - myself = me;
35.123 -
35.124 -#if defined SMEXT_CONF_METAMOD
35.125 - m_WeAreUnloaded = true;
35.126 -
35.127 - if (!m_SourceMMLoaded)
35.128 - {
35.129 - if (error)
35.130 - {
35.131 - snprintf(error, maxlength, "Metamod attach failed");
35.132 - }
35.133 - return false;
35.134 - }
35.135 -#endif
35.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
35.137 - smutils = g_pSM;
35.138 -#if defined SMEXT_ENABLE_HANDLESYS
35.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
35.140 - handlesys = g_pHandleSys;
35.141 -#endif
35.142 -#if defined SMEXT_ENABLE_FORWARDSYS
35.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
35.144 - forwards = g_pForwards;
35.145 -#endif
35.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
35.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
35.148 -#endif
35.149 -#if defined SMEXT_ENABLE_DBMANAGER
35.150 - SM_GET_IFACE(DBI, dbi);
35.151 -#endif
35.152 -#if defined SMEXT_ENABLE_GAMECONF
35.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
35.154 -#endif
35.155 -#if defined SMEXT_ENABLE_MEMUTILS
35.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
35.157 -#endif
35.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
35.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
35.160 -#endif
35.161 -#if defined SMEXT_ENABLE_TIMERSYS
35.162 - SM_GET_IFACE(TIMERSYS, timersys);
35.163 -#endif
35.164 -#if defined SMEXT_ENABLE_ADTFACTORY
35.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
35.166 -#endif
35.167 -#if defined SMEXT_ENABLE_THREADER
35.168 - SM_GET_IFACE(THREADER, threader);
35.169 -#endif
35.170 -#if defined SMEXT_ENABLE_LIBSYS
35.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
35.172 -#endif
35.173 -#if defined SMEXT_ENABLE_PLUGINSYS
35.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
35.175 -#endif
35.176 -#if defined SMEXT_ENABLE_MENUS
35.177 - SM_GET_IFACE(MENUMANAGER, menus);
35.178 -#endif
35.179 -#if defined SMEXT_ENABLE_ADMINSYS
35.180 - SM_GET_IFACE(ADMINSYS, adminsys);
35.181 -#endif
35.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
35.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
35.184 -#endif
35.185 -#if defined SMEXT_ENABLE_USERMSGS
35.186 - SM_GET_IFACE(USERMSGS, usermsgs);
35.187 -#endif
35.188 -#if defined SMEXT_ENABLE_TRANSLATOR
35.189 - SM_GET_IFACE(TRANSLATOR, translator);
35.190 -#endif
35.191 -
35.192 - if (SDK_OnLoad(error, maxlength, late))
35.193 - {
35.194 -#if defined SMEXT_CONF_METAMOD
35.195 - m_WeAreUnloaded = true;
35.196 -#endif
35.197 - return true;
35.198 - }
35.199 -
35.200 - return false;
35.201 -}
35.202 -
35.203 -bool SDKExtension::IsMetamodExtension()
35.204 -{
35.205 -#if defined SMEXT_CONF_METAMOD
35.206 - return true;
35.207 -#else
35.208 - return false;
35.209 -#endif
35.210 -}
35.211 -
35.212 -void SDKExtension::OnExtensionPauseChange(bool state)
35.213 -{
35.214 -#if defined SMEXT_CONF_METAMOD
35.215 - m_WeGotPauseChange = true;
35.216 -#endif
35.217 - SDK_OnPauseChange(state);
35.218 -}
35.219 -
35.220 -void SDKExtension::OnExtensionsAllLoaded()
35.221 -{
35.222 - SDK_OnAllLoaded();
35.223 -}
35.224 -
35.225 -void SDKExtension::OnExtensionUnload()
35.226 -{
35.227 -#if defined SMEXT_CONF_METAMOD
35.228 - m_WeAreUnloaded = true;
35.229 -#endif
35.230 - SDK_OnUnload();
35.231 -}
35.232 -
35.233 -const char *SDKExtension::GetExtensionAuthor()
35.234 -{
35.235 - return SMEXT_CONF_AUTHOR;
35.236 -}
35.237 -
35.238 -const char *SDKExtension::GetExtensionDateString()
35.239 -{
35.240 - return SMEXT_CONF_DATESTRING;
35.241 -}
35.242 -
35.243 -const char *SDKExtension::GetExtensionDescription()
35.244 -{
35.245 - return SMEXT_CONF_DESCRIPTION;
35.246 -}
35.247 -
35.248 -const char *SDKExtension::GetExtensionVerString()
35.249 -{
35.250 - return SMEXT_CONF_VERSION;
35.251 -}
35.252 -
35.253 -const char *SDKExtension::GetExtensionName()
35.254 -{
35.255 - return SMEXT_CONF_NAME;
35.256 -}
35.257 -
35.258 -const char *SDKExtension::GetExtensionTag()
35.259 -{
35.260 - return SMEXT_CONF_LOGTAG;
35.261 -}
35.262 -
35.263 -const char *SDKExtension::GetExtensionURL()
35.264 -{
35.265 - return SMEXT_CONF_URL;
35.266 -}
35.267 -
35.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
35.269 -{
35.270 - return true;
35.271 -}
35.272 -
35.273 -void SDKExtension::SDK_OnUnload()
35.274 -{
35.275 -}
35.276 -
35.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
35.278 -{
35.279 -}
35.280 -
35.281 -void SDKExtension::SDK_OnAllLoaded()
35.282 -{
35.283 -}
35.284 -
35.285 -#if defined SMEXT_CONF_METAMOD
35.286 -
35.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
35.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
35.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
35.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
35.291 -
35.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
35.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
35.294 -
35.295 -/** Exposes the extension to Metamod */
35.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
35.297 -{
35.298 -#if defined METAMOD_PLAPI_VERSION
35.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
35.300 -#else
35.301 - if (name && !strcmp(name, PLAPI_NAME))
35.302 -#endif
35.303 - {
35.304 - if (code)
35.305 - {
35.306 - *code = IFACE_OK;
35.307 - }
35.308 - return static_cast<void *>(g_pExtensionIface);
35.309 - }
35.310 -
35.311 - if (code)
35.312 - {
35.313 - *code = IFACE_FAILED;
35.314 - }
35.315 -
35.316 - return NULL;
35.317 -}
35.318 -
35.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
35.320 -{
35.321 - PLUGIN_SAVEVARS();
35.322 -
35.323 -#if !defined METAMOD_PLAPI_VERSION
35.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
35.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
35.326 -#else
35.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
35.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
35.329 -#endif
35.330 -
35.331 - m_SourceMMLoaded = true;
35.332 -
35.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
35.334 -}
35.335 -
35.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
35.337 -{
35.338 - if (!m_WeAreUnloaded)
35.339 - {
35.340 - if (error)
35.341 - {
35.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
35.343 - }
35.344 - return false;
35.345 - }
35.346 -
35.347 - return SDK_OnMetamodUnload(error, maxlen);
35.348 -}
35.349 -
35.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
35.351 -{
35.352 - if (!m_WeGotPauseChange)
35.353 - {
35.354 - if (error)
35.355 - {
35.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
35.357 - }
35.358 - return false;
35.359 - }
35.360 -
35.361 - m_WeGotPauseChange = false;
35.362 -
35.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
35.364 -}
35.365 -
35.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
35.367 -{
35.368 - if (!m_WeGotPauseChange)
35.369 - {
35.370 - if (error)
35.371 - {
35.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
35.373 - }
35.374 - return false;
35.375 - }
35.376 -
35.377 - m_WeGotPauseChange = false;
35.378 -
35.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
35.380 -}
35.381 -
35.382 -const char *SDKExtension::GetAuthor()
35.383 -{
35.384 - return GetExtensionAuthor();
35.385 -}
35.386 -
35.387 -const char *SDKExtension::GetDate()
35.388 -{
35.389 - return GetExtensionDateString();
35.390 -}
35.391 -
35.392 -const char *SDKExtension::GetDescription()
35.393 -{
35.394 - return GetExtensionDescription();
35.395 -}
35.396 -
35.397 -const char *SDKExtension::GetLicense()
35.398 -{
35.399 - return SMEXT_CONF_LICENSE;
35.400 -}
35.401 -
35.402 -const char *SDKExtension::GetLogTag()
35.403 -{
35.404 - return GetExtensionTag();
35.405 -}
35.406 -
35.407 -const char *SDKExtension::GetName()
35.408 -{
35.409 - return GetExtensionName();
35.410 -}
35.411 -
35.412 -const char *SDKExtension::GetURL()
35.413 -{
35.414 - return GetExtensionURL();
35.415 -}
35.416 -
35.417 -const char *SDKExtension::GetVersion()
35.418 -{
35.419 - return GetExtensionVerString();
35.420 -}
35.421 -
35.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
35.423 -{
35.424 - return true;
35.425 -}
35.426 -
35.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
35.428 -{
35.429 - return true;
35.430 -}
35.431 -
35.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
35.433 -{
35.434 - return true;
35.435 -}
35.436 -
35.437 -#endif
35.438 -
35.439 -/* Overload a few things to prevent libstdc++ linking */
35.440 -#if defined __linux__ || defined __APPLE__
35.441 -extern "C" void __cxa_pure_virtual(void)
35.442 -{
35.443 -}
35.444 -
35.445 -void *operator new(size_t size)
35.446 -{
35.447 - return malloc(size);
35.448 -}
35.449 -
35.450 -void *operator new[](size_t size)
35.451 -{
35.452 - return malloc(size);
35.453 -}
35.454 -
35.455 -void operator delete(void *ptr)
35.456 -{
35.457 - free(ptr);
35.458 -}
35.459 -
35.460 -void operator delete[](void * ptr)
35.461 -{
35.462 - free(ptr);
35.463 -}
35.464 -#endif
35.465 -
36.1 --- a/extensions/mysql/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,300 +0,0 @@
36.4 -/**
36.5 - * vim: set ts=4 :
36.6 - * =============================================================================
36.7 - * SourceMod Base Extension Code
36.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
36.9 - * =============================================================================
36.10 - *
36.11 - * This program is free software; you can redistribute it and/or modify it under
36.12 - * the terms of the GNU General Public License, version 3.0, as published by the
36.13 - * Free Software Foundation.
36.14 - *
36.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
36.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
36.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
36.18 - * details.
36.19 - *
36.20 - * You should have received a copy of the GNU General Public License along with
36.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
36.22 - *
36.23 - * As a special exception, AlliedModders LLC gives you permission to link the
36.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
36.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
36.26 - * by the Valve Corporation. You must obey the GNU General Public License in
36.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
36.28 - * this exception to all derivative works. AlliedModders LLC defines further
36.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
36.30 - * or <http://www.sourcemod.net/license.php>.
36.31 - *
36.32 - * Version: $Id$
36.33 - */
36.34 -
36.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
36.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
36.37 -
36.38 -/**
36.39 - * @file smsdk_ext.h
36.40 - * @brief Contains wrappers for making Extensions easier to write.
36.41 - */
36.42 -
36.43 -#include "smsdk_config.h"
36.44 -#include <IExtensionSys.h>
36.45 -#include <IHandleSys.h>
36.46 -#include <sp_vm_api.h>
36.47 -#include <sm_platform.h>
36.48 -#include <ISourceMod.h>
36.49 -#if defined SMEXT_ENABLE_FORWARDSYS
36.50 -#include <IForwardSys.h>
36.51 -#endif //SMEXT_ENABLE_FORWARDSYS
36.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
36.53 -#include <IPlayerHelpers.h>
36.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
36.55 -#if defined SMEXT_ENABLE_DBMANAGER
36.56 -#include <IDBDriver.h>
36.57 -#endif //SMEXT_ENABLE_DBMANAGER
36.58 -#if defined SMEXT_ENABLE_GAMECONF
36.59 -#include <IGameConfigs.h>
36.60 -#endif
36.61 -#if defined SMEXT_ENABLE_MEMUTILS
36.62 -#include <IMemoryUtils.h>
36.63 -#endif
36.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
36.65 -#include <IGameHelpers.h>
36.66 -#endif
36.67 -#if defined SMEXT_ENABLE_TIMERSYS
36.68 -#include <ITimerSystem.h>
36.69 -#endif
36.70 -#if defined SMEXT_ENABLE_ADTFACTORY
36.71 -#include <IADTFactory.h>
36.72 -#endif
36.73 -#if defined SMEXT_ENABLE_THREADER
36.74 -#include <IThreader.h>
36.75 -#endif
36.76 -#if defined SMEXT_ENABLE_LIBSYS
36.77 -#include <ILibrarySys.h>
36.78 -#endif
36.79 -
36.80 -#if defined SMEXT_CONF_METAMOD
36.81 -#include <ISmmPlugin.h>
36.82 -#include <eiface.h>
36.83 -#endif
36.84 -
36.85 -using namespace SourceMod;
36.86 -using namespace SourcePawn;
36.87 -
36.88 -class SDKExtension :
36.89 -#if defined SMEXT_CONF_METAMOD
36.90 - public ISmmPlugin,
36.91 -#endif
36.92 - public IExtensionInterface
36.93 -{
36.94 -public:
36.95 - /** Constructor */
36.96 - SDKExtension();
36.97 -public:
36.98 - /**
36.99 - * @brief This is called after the initial loading sequence has been processed.
36.100 - *
36.101 - * @param error Error message buffer.
36.102 - * @param maxlength Size of error message buffer.
36.103 - * @param late Whether or not the module was loaded after map load.
36.104 - * @return True to succeed loading, false to fail.
36.105 - */
36.106 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
36.107 -
36.108 - /**
36.109 - * @brief This is called right before the extension is unloaded.
36.110 - */
36.111 - virtual void SDK_OnUnload();
36.112 -
36.113 - /**
36.114 - * @brief This is called once all known extensions have been loaded.
36.115 - */
36.116 - virtual void SDK_OnAllLoaded();
36.117 -
36.118 - /**
36.119 - * @brief Called when the pause state is changed.
36.120 - */
36.121 - virtual void SDK_OnPauseChange(bool paused);
36.122 -
36.123 -#if defined SMEXT_CONF_METAMOD
36.124 - /**
36.125 - * @brief Called when Metamod is attached, before the extension version is called.
36.126 - *
36.127 - * @param error Error buffer.
36.128 - * @param maxlength Maximum size of error buffer.
36.129 - * @param late Whether or not Metamod considers this a late load.
36.130 - * @return True to succeed, false to fail.
36.131 - */
36.132 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
36.133 -
36.134 - /**
36.135 - * @brief Called when Metamod is detaching, after the extension version is called.
36.136 - * NOTE: By default this is blocked unless sent from SourceMod.
36.137 - *
36.138 - * @param error Error buffer.
36.139 - * @param maxlength Maximum size of error buffer.
36.140 - * @return True to succeed, false to fail.
36.141 - */
36.142 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
36.143 -
36.144 - /**
36.145 - * @brief Called when Metamod's pause state is changing.
36.146 - * NOTE: By default this is blocked unless sent from SourceMod.
36.147 - *
36.148 - * @param paused Pause state being set.
36.149 - * @param error Error buffer.
36.150 - * @param maxlength Maximum size of error buffer.
36.151 - * @return True to succeed, false to fail.
36.152 - */
36.153 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
36.154 -#endif
36.155 -
36.156 -public: //IExtensionInterface
36.157 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
36.158 - virtual void OnExtensionUnload();
36.159 - virtual void OnExtensionsAllLoaded();
36.160 -
36.161 - /** Returns whether or not this is a Metamod-based extension */
36.162 - virtual bool IsMetamodExtension();
36.163 -
36.164 - /**
36.165 - * @brief Called when the pause state changes.
36.166 - *
36.167 - * @param state True if being paused, false if being unpaused.
36.168 - */
36.169 - virtual void OnExtensionPauseChange(bool state);
36.170 -
36.171 - /** Returns name */
36.172 - virtual const char *GetExtensionName();
36.173 - /** Returns URL */
36.174 - virtual const char *GetExtensionURL();
36.175 - /** Returns log tag */
36.176 - virtual const char *GetExtensionTag();
36.177 - /** Returns author */
36.178 - virtual const char *GetExtensionAuthor();
36.179 - /** Returns version string */
36.180 - virtual const char *GetExtensionVerString();
36.181 - /** Returns description string */
36.182 - virtual const char *GetExtensionDescription();
36.183 - /** Returns date string */
36.184 - virtual const char *GetExtensionDateString();
36.185 -#if defined SMEXT_CONF_METAMOD
36.186 -public: //ISmmPlugin
36.187 - /** Called when the extension is attached to Metamod. */
36.188 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
36.189 - /** Returns the author to MM */
36.190 - virtual const char *GetAuthor();
36.191 - /** Returns the name to MM */
36.192 - virtual const char *GetName();
36.193 - /** Returns the description to MM */
36.194 - virtual const char *GetDescription();
36.195 - /** Returns the URL to MM */
36.196 - virtual const char *GetURL();
36.197 - /** Returns the license to MM */
36.198 - virtual const char *GetLicense();
36.199 - /** Returns the version string to MM */
36.200 - virtual const char *GetVersion();
36.201 - /** Returns the date string to MM */
36.202 - virtual const char *GetDate();
36.203 - /** Returns the logtag to MM */
36.204 - virtual const char *GetLogTag();
36.205 - /** Called on unload */
36.206 - virtual bool Unload(char *error, size_t maxlength);
36.207 - /** Called on pause */
36.208 - virtual bool Pause(char *error, size_t maxlength);
36.209 - /** Called on unpause */
36.210 - virtual bool Unpause(char *error, size_t maxlength);
36.211 -private:
36.212 - bool m_SourceMMLoaded;
36.213 - bool m_WeAreUnloaded;
36.214 - bool m_WeGotPauseChange;
36.215 -#endif
36.216 -};
36.217 -
36.218 -extern SDKExtension *g_pExtensionIface;
36.219 -extern IExtension *myself;
36.220 -
36.221 -extern IShareSys *g_pShareSys;
36.222 -extern IShareSys *sharesys; /* Note: Newer name */
36.223 -extern ISourceMod *g_pSM;
36.224 -extern ISourceMod *smutils; /* Note: Newer name */
36.225 -
36.226 -/* Optional interfaces are below */
36.227 -#if defined SMEXT_ENABLE_FORWARDSYS
36.228 -extern IForwardManager *g_pForwards;
36.229 -extern IForwardManager *forwards; /* Note: Newer name */
36.230 -#endif //SMEXT_ENABLE_FORWARDSYS
36.231 -#if defined SMEXT_ENABLE_HANDLESYS
36.232 -extern IHandleSys *g_pHandleSys;
36.233 -extern IHandleSys *handlesys; /* Note: Newer name */
36.234 -#endif //SMEXT_ENABLE_HANDLESYS
36.235 -#if defined SMEXT_ENABLE_PLAYERHELPERS
36.236 -extern IPlayerManager *playerhelpers;
36.237 -#endif //SMEXT_ENABLE_PLAYERHELPERS
36.238 -#if defined SMEXT_ENABLE_DBMANAGER
36.239 -extern IDBManager *dbi;
36.240 -#endif //SMEXT_ENABLE_DBMANAGER
36.241 -#if defined SMEXT_ENABLE_GAMECONF
36.242 -extern IGameConfigManager *gameconfs;
36.243 -#endif //SMEXT_ENABLE_DBMANAGER
36.244 -#if defined SMEXT_ENABLE_MEMUTILS
36.245 -extern IMemoryUtils *memutils;
36.246 -#endif
36.247 -#if defined SMEXT_ENABLE_GAMEHELPERS
36.248 -extern IGameHelpers *gamehelpers;
36.249 -#endif
36.250 -#if defined SMEXT_ENABLE_TIMERSYS
36.251 -extern ITimerSystem *timersys;
36.252 -#endif
36.253 -#if defined SMEXT_ENABLE_ADTFACTORY
36.254 -extern IADTFactory *adtfactory;
36.255 -#endif
36.256 -#if defined SMEXT_ENABLE_THREADER
36.257 -extern IThreader *threader;
36.258 -#endif
36.259 -#if defined SMEXT_ENABLE_LIBSYS
36.260 -extern ILibrarySys *libsys;
36.261 -#endif
36.262 -
36.263 -#if defined SMEXT_CONF_METAMOD
36.264 -PLUGIN_GLOBALVARS();
36.265 -extern IVEngineServer *engine;
36.266 -extern IServerGameDLL *gamedll;
36.267 -#endif
36.268 -
36.269 -/** Creates a SourceMod interface macro pair */
36.270 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
36.271 -/** Automates retrieving SourceMod interfaces */
36.272 -#define SM_GET_IFACE(prefix, addr) \
36.273 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
36.274 - { \
36.275 - if (error != NULL && maxlength) \
36.276 - { \
36.277 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
36.278 - if (len >= maxlength) \
36.279 - { \
36.280 - error[maxlength - 1] = '\0'; \
36.281 - } \
36.282 - } \
36.283 - return false; \
36.284 - }
36.285 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
36.286 -#define SM_GET_LATE_IFACE(prefix, addr) \
36.287 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
36.288 -/** Validates a SourceMod interface pointer */
36.289 -#define SM_CHECK_IFACE(prefix, addr) \
36.290 - if (!addr) \
36.291 - { \
36.292 - if (error != NULL && maxlength) \
36.293 - { \
36.294 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
36.295 - if (len >= maxlength) \
36.296 - { \
36.297 - error[maxlength - 1] = '\0'; \
36.298 - } \
36.299 - } \
36.300 - return false; \
36.301 - }
36.302 -
36.303 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/extensions/mysql/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
37.3 @@ -0,0 +1,72 @@
37.4 +/**
37.5 + * vim: set ts=4 :
37.6 + * =============================================================================
37.7 + * SourceMod MySQL Extension
37.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
37.9 + * =============================================================================
37.10 + *
37.11 + * This program is free software; you can redistribute it and/or modify it under
37.12 + * the terms of the GNU General Public License, version 3.0, as published by the
37.13 + * Free Software Foundation.
37.14 + *
37.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
37.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
37.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
37.18 + * details.
37.19 + *
37.20 + * You should have received a copy of the GNU General Public License along with
37.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
37.22 + *
37.23 + * As a special exception, AlliedModders LLC gives you permission to link the
37.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
37.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
37.26 + * by the Valve Corporation. You must obey the GNU General Public License in
37.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
37.28 + * this exception to all derivative works. AlliedModders LLC defines further
37.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
37.30 + * or <http://www.sourcemod.net/license.php>.
37.31 + *
37.32 + * Version: $Id$
37.33 + */
37.34 +
37.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
37.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
37.37 +
37.38 +/**
37.39 + * @file smsdk_config.h
37.40 + * @brief Contains macros for configuring basic extension information.
37.41 + */
37.42 +
37.43 +/* Basic information exposed publicly */
37.44 +#define SMEXT_CONF_NAME "MySQL-DBI"
37.45 +#define SMEXT_CONF_DESCRIPTION "MySQL driver implementation for DBI"
37.46 +#define SMEXT_CONF_VERSION ""
37.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
37.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
37.49 +#define SMEXT_CONF_LOGTAG "MYSQL"
37.50 +#define SMEXT_CONF_LICENSE "GPL"
37.51 +#define SMEXT_CONF_DATESTRING ""
37.52 +
37.53 +/**
37.54 + * @brief Exposes plugin's main interface.
37.55 + */
37.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
37.57 +
37.58 +/**
37.59 + * @brief Sets whether or not this plugin required Metamod.
37.60 + * NOTE: Uncomment to enable, comment to disable.
37.61 + */
37.62 +//#define SMEXT_CONF_METAMOD
37.63 +
37.64 +/** Enable interfaces you want to use here by uncommenting lines */
37.65 +//#define SMEXT_ENABLE_FORWARDSYS
37.66 +//#define SMEXT_ENABLE_HANDLESYS
37.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
37.68 +#define SMEXT_ENABLE_DBMANAGER
37.69 +//#define SMEXT_ENABLE_GAMECONF
37.70 +//#define SMEXT_ENABLE_MEMUTILS
37.71 +//#define SMEXT_ENABLE_GAMEHELPERS
37.72 +//#define SMEXT_ENABLE_TIMERSYS
37.73 +//#define SMEXT_ENABLE_THREADER
37.74 +
37.75 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
38.1 --- a/extensions/regex/AMBuilder Wed Apr 23 21:40:50 2014 -0400
38.2 +++ b/extensions/regex/AMBuilder Wed Apr 23 21:19:28 2014 -0500
38.3 @@ -17,7 +17,7 @@
38.4 binary.sources += [
38.5 'extension.cpp',
38.6 'CRegEx.cpp',
38.7 - 'sdk/smsdk_ext.cpp',
38.8 + '../../public/smsdk_ext.cpp'
38.9 ]
38.10
38.11 SM.extensions += [builder.Add(binary)]
39.1 --- a/extensions/regex/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,79 +0,0 @@
39.4 -/**
39.5 - * vim: set ts=4 :
39.6 - * =============================================================================
39.7 - * SourceMod Regular Expressions Extension
39.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
39.9 - * =============================================================================
39.10 - *
39.11 - * This program is free software; you can redistribute it and/or modify it under
39.12 - * the terms of the GNU General Public License, version 3.0, as published by the
39.13 - * Free Software Foundation.
39.14 - *
39.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
39.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
39.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
39.18 - * details.
39.19 - *
39.20 - * You should have received a copy of the GNU General Public License along with
39.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
39.22 - *
39.23 - * As a special exception, AlliedModders LLC gives you permission to link the
39.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
39.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
39.26 - * by the Valve Corporation. You must obey the GNU General Public License in
39.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
39.28 - * this exception to all derivative works. AlliedModders LLC defines further
39.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
39.30 - * or <http://www.sourcemod.net/license.php>.
39.31 - *
39.32 - * Version: $Id$
39.33 - */
39.34 -
39.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
39.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
39.37 -
39.38 -/**
39.39 - * @file smsdk_config.h
39.40 - * @brief Contains macros for configuring basic extension information.
39.41 - */
39.42 -
39.43 -/* Basic information exposed publicly */
39.44 -#define SMEXT_CONF_NAME "Regex"
39.45 -#define SMEXT_CONF_DESCRIPTION "Provides regex natives for plugins"
39.46 -#define SMEXT_CONF_VERSION ""
39.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
39.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
39.49 -#define SMEXT_CONF_LOGTAG "REGEX"
39.50 -#define SMEXT_CONF_LICENSE "GPL"
39.51 -#define SMEXT_CONF_DATESTRING ""
39.52 -
39.53 -/**
39.54 - * @brief Exposes plugin's main interface.
39.55 - */
39.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
39.57 -
39.58 -/**
39.59 - * @brief Sets whether or not this plugin required Metamod.
39.60 - * NOTE: Uncomment to enable, comment to disable.
39.61 - */
39.62 -//#define SMEXT_CONF_METAMOD
39.63 -
39.64 -/** Enable interfaces you want to use here by uncommenting lines */
39.65 -//#define SMEXT_ENABLE_FORWARDSYS
39.66 -#define SMEXT_ENABLE_HANDLESYS
39.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
39.68 -//#define SMEXT_ENABLE_DBMANAGER
39.69 -//#define SMEXT_ENABLE_GAMECONF
39.70 -//#define SMEXT_ENABLE_MEMUTILS
39.71 -//#define SMEXT_ENABLE_GAMEHELPERS
39.72 -//#define SMEXT_ENABLE_TIMERSYS
39.73 -//#define SMEXT_ENABLE_THREADER
39.74 -//#define SMEXT_ENABLE_LIBSYS
39.75 -//#define SMEXT_ENABLE_MENUS
39.76 -//#define SMEXT_ENABLE_ADTFACTORY
39.77 -//#define SMEXT_ENABLE_PLUGINSYS
39.78 -//#define SMEXT_ENABLE_ADMINSYS
39.79 -//#define SMEXT_ENABLE_TEXTPARSERS
39.80 -//#define SMEXT_ENABLE_USERMSGS
39.81 -
39.82 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
40.1 --- a/extensions/regex/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,462 +0,0 @@
40.4 -/**
40.5 - * vim: set ts=4 :
40.6 - * =============================================================================
40.7 - * SourceMod Base Extension Code
40.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
40.9 - * =============================================================================
40.10 - *
40.11 - * This program is free software; you can redistribute it and/or modify it under
40.12 - * the terms of the GNU General Public License, version 3.0, as published by the
40.13 - * Free Software Foundation.
40.14 - *
40.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
40.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
40.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
40.18 - * details.
40.19 - *
40.20 - * You should have received a copy of the GNU General Public License along with
40.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
40.22 - *
40.23 - * As a special exception, AlliedModders LLC gives you permission to link the
40.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
40.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
40.26 - * by the Valve Corporation. You must obey the GNU General Public License in
40.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
40.28 - * this exception to all derivative works. AlliedModders LLC defines further
40.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
40.30 - * or <http://www.sourcemod.net/license.php>.
40.31 - *
40.32 - * Version: $Id$
40.33 - */
40.34 -
40.35 -#include <stdio.h>
40.36 -#include <stdlib.h>
40.37 -#include "smsdk_ext.h"
40.38 -
40.39 -/**
40.40 - * @file smsdk_ext.cpp
40.41 - * @brief Contains wrappers for making Extensions easier to write.
40.42 - */
40.43 -
40.44 -IExtension *myself = NULL; /**< Ourself */
40.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
40.46 -IShareSys *sharesys = NULL; /**< Share system */
40.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
40.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
40.49 -
40.50 -#if defined SMEXT_ENABLE_FORWARDSYS
40.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
40.52 -IForwardManager *forwards = NULL; /**< Forward system */
40.53 -#endif
40.54 -#if defined SMEXT_ENABLE_HANDLESYS
40.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
40.56 -IHandleSys *handlesys = NULL; /**< Handle system */
40.57 -#endif
40.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
40.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
40.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
40.61 -#if defined SMEXT_ENABLE_DBMANAGER
40.62 -IDBManager *dbi = NULL; /**< DB Manager */
40.63 -#endif //SMEXT_ENABLE_DBMANAGER
40.64 -#if defined SMEXT_ENABLE_GAMECONF
40.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
40.66 -#endif //SMEXT_ENABLE_DBMANAGER
40.67 -#if defined SMEXT_ENABLE_MEMUTILS
40.68 -IMemoryUtils *memutils = NULL;
40.69 -#endif //SMEXT_ENABLE_DBMANAGER
40.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
40.71 -IGameHelpers *gamehelpers = NULL;
40.72 -#endif
40.73 -#if defined SMEXT_ENABLE_TIMERSYS
40.74 -ITimerSystem *timersys = NULL;
40.75 -#endif
40.76 -#if defined SMEXT_ENABLE_ADTFACTORY
40.77 -IADTFactory *adtfactory = NULL;
40.78 -#endif
40.79 -#if defined SMEXT_ENABLE_THREADER
40.80 -IThreader *threader = NULL;
40.81 -#endif
40.82 -#if defined SMEXT_ENABLE_LIBSYS
40.83 -ILibrarySys *libsys = NULL;
40.84 -#endif
40.85 -#if defined SMEXT_ENABLE_PLUGINSYS
40.86 -SourceMod::IPluginManager *plsys;
40.87 -#endif
40.88 -#if defined SMEXT_ENABLE_MENUS
40.89 -IMenuManager *menus = NULL;
40.90 -#endif
40.91 -#if defined SMEXT_ENABLE_ADMINSYS
40.92 -IAdminSystem *adminsys = NULL;
40.93 -#endif
40.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
40.95 -ITextParsers *textparsers = NULL;
40.96 -#endif
40.97 -#if defined SMEXT_ENABLE_USERMSGS
40.98 -IUserMessages *usermsgs = NULL;
40.99 -#endif
40.100 -#if defined SMEXT_ENABLE_TRANSLATOR
40.101 -ITranslator *translator = NULL;
40.102 -#endif
40.103 -
40.104 -/** Exports the main interface */
40.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
40.106 -{
40.107 - return g_pExtensionIface;
40.108 -}
40.109 -
40.110 -SDKExtension::SDKExtension()
40.111 -{
40.112 -#if defined SMEXT_CONF_METAMOD
40.113 - m_SourceMMLoaded = false;
40.114 - m_WeAreUnloaded = false;
40.115 - m_WeGotPauseChange = false;
40.116 -#endif
40.117 -}
40.118 -
40.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
40.120 -{
40.121 - g_pShareSys = sharesys = sys;
40.122 - myself = me;
40.123 -
40.124 -#if defined SMEXT_CONF_METAMOD
40.125 - m_WeAreUnloaded = true;
40.126 -
40.127 - if (!m_SourceMMLoaded)
40.128 - {
40.129 - if (error)
40.130 - {
40.131 - snprintf(error, maxlength, "Metamod attach failed");
40.132 - }
40.133 - return false;
40.134 - }
40.135 -#endif
40.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
40.137 - smutils = g_pSM;
40.138 -#if defined SMEXT_ENABLE_HANDLESYS
40.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
40.140 - handlesys = g_pHandleSys;
40.141 -#endif
40.142 -#if defined SMEXT_ENABLE_FORWARDSYS
40.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
40.144 - forwards = g_pForwards;
40.145 -#endif
40.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
40.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
40.148 -#endif
40.149 -#if defined SMEXT_ENABLE_DBMANAGER
40.150 - SM_GET_IFACE(DBI, dbi);
40.151 -#endif
40.152 -#if defined SMEXT_ENABLE_GAMECONF
40.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
40.154 -#endif
40.155 -#if defined SMEXT_ENABLE_MEMUTILS
40.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
40.157 -#endif
40.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
40.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
40.160 -#endif
40.161 -#if defined SMEXT_ENABLE_TIMERSYS
40.162 - SM_GET_IFACE(TIMERSYS, timersys);
40.163 -#endif
40.164 -#if defined SMEXT_ENABLE_ADTFACTORY
40.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
40.166 -#endif
40.167 -#if defined SMEXT_ENABLE_THREADER
40.168 - SM_GET_IFACE(THREADER, threader);
40.169 -#endif
40.170 -#if defined SMEXT_ENABLE_LIBSYS
40.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
40.172 -#endif
40.173 -#if defined SMEXT_ENABLE_PLUGINSYS
40.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
40.175 -#endif
40.176 -#if defined SMEXT_ENABLE_MENUS
40.177 - SM_GET_IFACE(MENUMANAGER, menus);
40.178 -#endif
40.179 -#if defined SMEXT_ENABLE_ADMINSYS
40.180 - SM_GET_IFACE(ADMINSYS, adminsys);
40.181 -#endif
40.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
40.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
40.184 -#endif
40.185 -#if defined SMEXT_ENABLE_USERMSGS
40.186 - SM_GET_IFACE(USERMSGS, usermsgs);
40.187 -#endif
40.188 -#if defined SMEXT_ENABLE_TRANSLATOR
40.189 - SM_GET_IFACE(TRANSLATOR, translator);
40.190 -#endif
40.191 -
40.192 - if (SDK_OnLoad(error, maxlength, late))
40.193 - {
40.194 -#if defined SMEXT_CONF_METAMOD
40.195 - m_WeAreUnloaded = true;
40.196 -#endif
40.197 - return true;
40.198 - }
40.199 -
40.200 - return false;
40.201 -}
40.202 -
40.203 -bool SDKExtension::IsMetamodExtension()
40.204 -{
40.205 -#if defined SMEXT_CONF_METAMOD
40.206 - return true;
40.207 -#else
40.208 - return false;
40.209 -#endif
40.210 -}
40.211 -
40.212 -void SDKExtension::OnExtensionPauseChange(bool state)
40.213 -{
40.214 -#if defined SMEXT_CONF_METAMOD
40.215 - m_WeGotPauseChange = true;
40.216 -#endif
40.217 - SDK_OnPauseChange(state);
40.218 -}
40.219 -
40.220 -void SDKExtension::OnExtensionsAllLoaded()
40.221 -{
40.222 - SDK_OnAllLoaded();
40.223 -}
40.224 -
40.225 -void SDKExtension::OnExtensionUnload()
40.226 -{
40.227 -#if defined SMEXT_CONF_METAMOD
40.228 - m_WeAreUnloaded = true;
40.229 -#endif
40.230 - SDK_OnUnload();
40.231 -}
40.232 -
40.233 -const char *SDKExtension::GetExtensionAuthor()
40.234 -{
40.235 - return SMEXT_CONF_AUTHOR;
40.236 -}
40.237 -
40.238 -const char *SDKExtension::GetExtensionDateString()
40.239 -{
40.240 - return SMEXT_CONF_DATESTRING;
40.241 -}
40.242 -
40.243 -const char *SDKExtension::GetExtensionDescription()
40.244 -{
40.245 - return SMEXT_CONF_DESCRIPTION;
40.246 -}
40.247 -
40.248 -const char *SDKExtension::GetExtensionVerString()
40.249 -{
40.250 - return SMEXT_CONF_VERSION;
40.251 -}
40.252 -
40.253 -const char *SDKExtension::GetExtensionName()
40.254 -{
40.255 - return SMEXT_CONF_NAME;
40.256 -}
40.257 -
40.258 -const char *SDKExtension::GetExtensionTag()
40.259 -{
40.260 - return SMEXT_CONF_LOGTAG;
40.261 -}
40.262 -
40.263 -const char *SDKExtension::GetExtensionURL()
40.264 -{
40.265 - return SMEXT_CONF_URL;
40.266 -}
40.267 -
40.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
40.269 -{
40.270 - return true;
40.271 -}
40.272 -
40.273 -void SDKExtension::SDK_OnUnload()
40.274 -{
40.275 -}
40.276 -
40.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
40.278 -{
40.279 -}
40.280 -
40.281 -void SDKExtension::SDK_OnAllLoaded()
40.282 -{
40.283 -}
40.284 -
40.285 -#if defined SMEXT_CONF_METAMOD
40.286 -
40.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
40.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
40.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
40.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
40.291 -
40.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
40.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
40.294 -
40.295 -/** Exposes the extension to Metamod */
40.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
40.297 -{
40.298 -#if defined METAMOD_PLAPI_VERSION
40.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
40.300 -#else
40.301 - if (name && !strcmp(name, PLAPI_NAME))
40.302 -#endif
40.303 - {
40.304 - if (code)
40.305 - {
40.306 - *code = IFACE_OK;
40.307 - }
40.308 - return static_cast<void *>(g_pExtensionIface);
40.309 - }
40.310 -
40.311 - if (code)
40.312 - {
40.313 - *code = IFACE_FAILED;
40.314 - }
40.315 -
40.316 - return NULL;
40.317 -}
40.318 -
40.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
40.320 -{
40.321 - PLUGIN_SAVEVARS();
40.322 -
40.323 -#if !defined METAMOD_PLAPI_VERSION
40.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
40.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
40.326 -#else
40.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
40.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
40.329 -#endif
40.330 -
40.331 - m_SourceMMLoaded = true;
40.332 -
40.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
40.334 -}
40.335 -
40.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
40.337 -{
40.338 - if (!m_WeAreUnloaded)
40.339 - {
40.340 - if (error)
40.341 - {
40.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
40.343 - }
40.344 - return false;
40.345 - }
40.346 -
40.347 - return SDK_OnMetamodUnload(error, maxlen);
40.348 -}
40.349 -
40.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
40.351 -{
40.352 - if (!m_WeGotPauseChange)
40.353 - {
40.354 - if (error)
40.355 - {
40.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
40.357 - }
40.358 - return false;
40.359 - }
40.360 -
40.361 - m_WeGotPauseChange = false;
40.362 -
40.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
40.364 -}
40.365 -
40.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
40.367 -{
40.368 - if (!m_WeGotPauseChange)
40.369 - {
40.370 - if (error)
40.371 - {
40.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
40.373 - }
40.374 - return false;
40.375 - }
40.376 -
40.377 - m_WeGotPauseChange = false;
40.378 -
40.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
40.380 -}
40.381 -
40.382 -const char *SDKExtension::GetAuthor()
40.383 -{
40.384 - return GetExtensionAuthor();
40.385 -}
40.386 -
40.387 -const char *SDKExtension::GetDate()
40.388 -{
40.389 - return GetExtensionDateString();
40.390 -}
40.391 -
40.392 -const char *SDKExtension::GetDescription()
40.393 -{
40.394 - return GetExtensionDescription();
40.395 -}
40.396 -
40.397 -const char *SDKExtension::GetLicense()
40.398 -{
40.399 - return SMEXT_CONF_LICENSE;
40.400 -}
40.401 -
40.402 -const char *SDKExtension::GetLogTag()
40.403 -{
40.404 - return GetExtensionTag();
40.405 -}
40.406 -
40.407 -const char *SDKExtension::GetName()
40.408 -{
40.409 - return GetExtensionName();
40.410 -}
40.411 -
40.412 -const char *SDKExtension::GetURL()
40.413 -{
40.414 - return GetExtensionURL();
40.415 -}
40.416 -
40.417 -const char *SDKExtension::GetVersion()
40.418 -{
40.419 - return GetExtensionVerString();
40.420 -}
40.421 -
40.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
40.423 -{
40.424 - return true;
40.425 -}
40.426 -
40.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
40.428 -{
40.429 - return true;
40.430 -}
40.431 -
40.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
40.433 -{
40.434 - return true;
40.435 -}
40.436 -
40.437 -#endif
40.438 -
40.439 -/* Overload a few things to prevent libstdc++ linking */
40.440 -#if defined __linux__ || defined __APPLE__
40.441 -extern "C" void __cxa_pure_virtual(void)
40.442 -{
40.443 -}
40.444 -
40.445 -void *operator new(size_t size)
40.446 -{
40.447 - return malloc(size);
40.448 -}
40.449 -
40.450 -void *operator new[](size_t size)
40.451 -{
40.452 - return malloc(size);
40.453 -}
40.454 -
40.455 -void operator delete(void *ptr)
40.456 -{
40.457 - free(ptr);
40.458 -}
40.459 -
40.460 -void operator delete[](void * ptr)
40.461 -{
40.462 - free(ptr);
40.463 -}
40.464 -#endif
40.465 -
41.1 --- a/extensions/regex/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,327 +0,0 @@
41.4 -/**
41.5 - * vim: set ts=4 :
41.6 - * =============================================================================
41.7 - * SourceMod Base Extension Code
41.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
41.9 - * =============================================================================
41.10 - *
41.11 - * This program is free software; you can redistribute it and/or modify it under
41.12 - * the terms of the GNU General Public License, version 3.0, as published by the
41.13 - * Free Software Foundation.
41.14 - *
41.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
41.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
41.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
41.18 - * details.
41.19 - *
41.20 - * You should have received a copy of the GNU General Public License along with
41.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
41.22 - *
41.23 - * As a special exception, AlliedModders LLC gives you permission to link the
41.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
41.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
41.26 - * by the Valve Corporation. You must obey the GNU General Public License in
41.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
41.28 - * this exception to all derivative works. AlliedModders LLC defines further
41.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
41.30 - * or <http://www.sourcemod.net/license.php>.
41.31 - *
41.32 - * Version: $Id$
41.33 - */
41.34 -
41.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
41.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
41.37 -
41.38 -/**
41.39 - * @file smsdk_ext.h
41.40 - * @brief Contains wrappers for making Extensions easier to write.
41.41 - */
41.42 -
41.43 -#include "smsdk_config.h"
41.44 -#include <IExtensionSys.h>
41.45 -#include <IHandleSys.h>
41.46 -#include <sp_vm_api.h>
41.47 -#include <sm_platform.h>
41.48 -#include <ISourceMod.h>
41.49 -#if defined SMEXT_ENABLE_FORWARDSYS
41.50 -#include <IForwardSys.h>
41.51 -#endif //SMEXT_ENABLE_FORWARDSYS
41.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
41.53 -#include <IPlayerHelpers.h>
41.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
41.55 -#if defined SMEXT_ENABLE_DBMANAGER
41.56 -#include <IDBDriver.h>
41.57 -#endif //SMEXT_ENABLE_DBMANAGER
41.58 -#if defined SMEXT_ENABLE_GAMECONF
41.59 -#include <IGameConfigs.h>
41.60 -#endif
41.61 -#if defined SMEXT_ENABLE_MEMUTILS
41.62 -#include <IMemoryUtils.h>
41.63 -#endif
41.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
41.65 -#include <IGameHelpers.h>
41.66 -#endif
41.67 -#if defined SMEXT_ENABLE_TIMERSYS
41.68 -#include <ITimerSystem.h>
41.69 -#endif
41.70 -#if defined SMEXT_ENABLE_ADTFACTORY
41.71 -#include <IADTFactory.h>
41.72 -#endif
41.73 -#if defined SMEXT_ENABLE_THREADER
41.74 -#include <IThreader.h>
41.75 -#endif
41.76 -#if defined SMEXT_ENABLE_LIBSYS
41.77 -#include <ILibrarySys.h>
41.78 -#endif
41.79 -#if defined SMEXT_ENABLE_PLUGINSYS
41.80 -#include <IPluginSys.h>
41.81 -#endif
41.82 -#if defined SMEXT_ENABLE_MENUS
41.83 -#include <IMenuManager.h>
41.84 -#endif
41.85 -#if defined SMEXT_ENABLE_ADMINSYS
41.86 -#include <IAdminSystem.h>
41.87 -#endif
41.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
41.89 -#include <ITextParsers.h>
41.90 -#endif
41.91 -#if defined SMEXT_ENABLE_USERMSGS
41.92 -#include <IUserMessages.h>
41.93 -#endif
41.94 -
41.95 -#if defined SMEXT_CONF_METAMOD
41.96 -#include <ISmmPlugin.h>
41.97 -#include <eiface.h>
41.98 -#endif
41.99 -
41.100 -using namespace SourceMod;
41.101 -using namespace SourcePawn;
41.102 -
41.103 -class SDKExtension :
41.104 -#if defined SMEXT_CONF_METAMOD
41.105 - public ISmmPlugin,
41.106 -#endif
41.107 - public IExtensionInterface
41.108 -{
41.109 -public:
41.110 - /** Constructor */
41.111 - SDKExtension();
41.112 -public:
41.113 - /**
41.114 - * @brief This is called after the initial loading sequence has been processed.
41.115 - *
41.116 - * @param error Error message buffer.
41.117 - * @param maxlength Size of error message buffer.
41.118 - * @param late Whether or not the module was loaded after map load.
41.119 - * @return True to succeed loading, false to fail.
41.120 - */
41.121 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
41.122 -
41.123 - /**
41.124 - * @brief This is called right before the extension is unloaded.
41.125 - */
41.126 - virtual void SDK_OnUnload();
41.127 -
41.128 - /**
41.129 - * @brief This is called once all known extensions have been loaded.
41.130 - */
41.131 - virtual void SDK_OnAllLoaded();
41.132 -
41.133 - /**
41.134 - * @brief Called when the pause state is changed.
41.135 - */
41.136 - virtual void SDK_OnPauseChange(bool paused);
41.137 -
41.138 -#if defined SMEXT_CONF_METAMOD
41.139 - /**
41.140 - * @brief Called when Metamod is attached, before the extension version is called.
41.141 - *
41.142 - * @param error Error buffer.
41.143 - * @param maxlength Maximum size of error buffer.
41.144 - * @param late Whether or not Metamod considers this a late load.
41.145 - * @return True to succeed, false to fail.
41.146 - */
41.147 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
41.148 -
41.149 - /**
41.150 - * @brief Called when Metamod is detaching, after the extension version is called.
41.151 - * NOTE: By default this is blocked unless sent from SourceMod.
41.152 - *
41.153 - * @param error Error buffer.
41.154 - * @param maxlength Maximum size of error buffer.
41.155 - * @return True to succeed, false to fail.
41.156 - */
41.157 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
41.158 -
41.159 - /**
41.160 - * @brief Called when Metamod's pause state is changing.
41.161 - * NOTE: By default this is blocked unless sent from SourceMod.
41.162 - *
41.163 - * @param paused Pause state being set.
41.164 - * @param error Error buffer.
41.165 - * @param maxlength Maximum size of error buffer.
41.166 - * @return True to succeed, false to fail.
41.167 - */
41.168 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
41.169 -#endif
41.170 -
41.171 -public: //IExtensionInterface
41.172 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
41.173 - virtual void OnExtensionUnload();
41.174 - virtual void OnExtensionsAllLoaded();
41.175 -
41.176 - /** Returns whether or not this is a Metamod-based extension */
41.177 - virtual bool IsMetamodExtension();
41.178 -
41.179 - /**
41.180 - * @brief Called when the pause state changes.
41.181 - *
41.182 - * @param state True if being paused, false if being unpaused.
41.183 - */
41.184 - virtual void OnExtensionPauseChange(bool state);
41.185 -
41.186 - /** Returns name */
41.187 - virtual const char *GetExtensionName();
41.188 - /** Returns URL */
41.189 - virtual const char *GetExtensionURL();
41.190 - /** Returns log tag */
41.191 - virtual const char *GetExtensionTag();
41.192 - /** Returns author */
41.193 - virtual const char *GetExtensionAuthor();
41.194 - /** Returns version string */
41.195 - virtual const char *GetExtensionVerString();
41.196 - /** Returns description string */
41.197 - virtual const char *GetExtensionDescription();
41.198 - /** Returns date string */
41.199 - virtual const char *GetExtensionDateString();
41.200 -#if defined SMEXT_CONF_METAMOD
41.201 -public: //ISmmPlugin
41.202 - /** Called when the extension is attached to Metamod. */
41.203 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
41.204 - /** Returns the author to MM */
41.205 - virtual const char *GetAuthor();
41.206 - /** Returns the name to MM */
41.207 - virtual const char *GetName();
41.208 - /** Returns the description to MM */
41.209 - virtual const char *GetDescription();
41.210 - /** Returns the URL to MM */
41.211 - virtual const char *GetURL();
41.212 - /** Returns the license to MM */
41.213 - virtual const char *GetLicense();
41.214 - /** Returns the version string to MM */
41.215 - virtual const char *GetVersion();
41.216 - /** Returns the date string to MM */
41.217 - virtual const char *GetDate();
41.218 - /** Returns the logtag to MM */
41.219 - virtual const char *GetLogTag();
41.220 - /** Called on unload */
41.221 - virtual bool Unload(char *error, size_t maxlength);
41.222 - /** Called on pause */
41.223 - virtual bool Pause(char *error, size_t maxlength);
41.224 - /** Called on unpause */
41.225 - virtual bool Unpause(char *error, size_t maxlength);
41.226 -private:
41.227 - bool m_SourceMMLoaded;
41.228 - bool m_WeAreUnloaded;
41.229 - bool m_WeGotPauseChange;
41.230 -#endif
41.231 -};
41.232 -
41.233 -extern SDKExtension *g_pExtensionIface;
41.234 -extern IExtension *myself;
41.235 -
41.236 -extern IShareSys *g_pShareSys;
41.237 -extern IShareSys *sharesys; /* Note: Newer name */
41.238 -extern ISourceMod *g_pSM;
41.239 -extern ISourceMod *smutils; /* Note: Newer name */
41.240 -
41.241 -/* Optional interfaces are below */
41.242 -#if defined SMEXT_ENABLE_FORWARDSYS
41.243 -extern IForwardManager *g_pForwards;
41.244 -extern IForwardManager *forwards; /* Note: Newer name */
41.245 -#endif //SMEXT_ENABLE_FORWARDSYS
41.246 -#if defined SMEXT_ENABLE_HANDLESYS
41.247 -extern IHandleSys *g_pHandleSys;
41.248 -extern IHandleSys *handlesys; /* Note: Newer name */
41.249 -#endif //SMEXT_ENABLE_HANDLESYS
41.250 -#if defined SMEXT_ENABLE_PLAYERHELPERS
41.251 -extern IPlayerManager *playerhelpers;
41.252 -#endif //SMEXT_ENABLE_PLAYERHELPERS
41.253 -#if defined SMEXT_ENABLE_DBMANAGER
41.254 -extern IDBManager *dbi;
41.255 -#endif //SMEXT_ENABLE_DBMANAGER
41.256 -#if defined SMEXT_ENABLE_GAMECONF
41.257 -extern IGameConfigManager *gameconfs;
41.258 -#endif //SMEXT_ENABLE_DBMANAGER
41.259 -#if defined SMEXT_ENABLE_MEMUTILS
41.260 -extern IMemoryUtils *memutils;
41.261 -#endif
41.262 -#if defined SMEXT_ENABLE_GAMEHELPERS
41.263 -extern IGameHelpers *gamehelpers;
41.264 -#endif
41.265 -#if defined SMEXT_ENABLE_TIMERSYS
41.266 -extern ITimerSystem *timersys;
41.267 -#endif
41.268 -#if defined SMEXT_ENABLE_ADTFACTORY
41.269 -extern IADTFactory *adtfactory;
41.270 -#endif
41.271 -#if defined SMEXT_ENABLE_THREADER
41.272 -extern IThreader *threader;
41.273 -#endif
41.274 -#if defined SMEXT_ENABLE_LIBSYS
41.275 -extern ILibrarySys *libsys;
41.276 -#endif
41.277 -#if defined SMEXT_ENABLE_PLUGINSYS
41.278 -extern SourceMod::IPluginManager *plsys;
41.279 -#endif
41.280 -#if defined SMEXT_ENABLE_MENUS
41.281 -extern IMenuManager *menus;
41.282 -#endif
41.283 -#if defined SMEXT_ENABLE_ADMINSYS
41.284 -extern IAdminSystem *adminsys;
41.285 -#endif
41.286 -#if defined SMEXT_ENABLE_USERMSGS
41.287 -extern IUserMessages *usermsgs;
41.288 -#endif
41.289 -
41.290 -#if defined SMEXT_CONF_METAMOD
41.291 -PLUGIN_GLOBALVARS();
41.292 -extern IVEngineServer *engine;
41.293 -extern IServerGameDLL *gamedll;
41.294 -#endif
41.295 -
41.296 -/** Creates a SourceMod interface macro pair */
41.297 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
41.298 -/** Automates retrieving SourceMod interfaces */
41.299 -#define SM_GET_IFACE(prefix, addr) \
41.300 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
41.301 - { \
41.302 - if (error != NULL && maxlength) \
41.303 - { \
41.304 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
41.305 - if (len >= maxlength) \
41.306 - { \
41.307 - error[maxlength - 1] = '\0'; \
41.308 - } \
41.309 - } \
41.310 - return false; \
41.311 - }
41.312 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
41.313 -#define SM_GET_LATE_IFACE(prefix, addr) \
41.314 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
41.315 -/** Validates a SourceMod interface pointer */
41.316 -#define SM_CHECK_IFACE(prefix, addr) \
41.317 - if (!addr) \
41.318 - { \
41.319 - if (error != NULL && maxlength) \
41.320 - { \
41.321 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
41.322 - if (len >= maxlength) \
41.323 - { \
41.324 - error[maxlength - 1] = '\0'; \
41.325 - } \
41.326 - } \
41.327 - return false; \
41.328 - }
41.329 -
41.330 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/extensions/regex/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
42.3 @@ -0,0 +1,79 @@
42.4 +/**
42.5 + * vim: set ts=4 :
42.6 + * =============================================================================
42.7 + * SourceMod Regular Expressions Extension
42.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
42.9 + * =============================================================================
42.10 + *
42.11 + * This program is free software; you can redistribute it and/or modify it under
42.12 + * the terms of the GNU General Public License, version 3.0, as published by the
42.13 + * Free Software Foundation.
42.14 + *
42.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
42.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
42.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
42.18 + * details.
42.19 + *
42.20 + * You should have received a copy of the GNU General Public License along with
42.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
42.22 + *
42.23 + * As a special exception, AlliedModders LLC gives you permission to link the
42.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
42.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
42.26 + * by the Valve Corporation. You must obey the GNU General Public License in
42.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
42.28 + * this exception to all derivative works. AlliedModders LLC defines further
42.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
42.30 + * or <http://www.sourcemod.net/license.php>.
42.31 + *
42.32 + * Version: $Id$
42.33 + */
42.34 +
42.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
42.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
42.37 +
42.38 +/**
42.39 + * @file smsdk_config.h
42.40 + * @brief Contains macros for configuring basic extension information.
42.41 + */
42.42 +
42.43 +/* Basic information exposed publicly */
42.44 +#define SMEXT_CONF_NAME "Regex"
42.45 +#define SMEXT_CONF_DESCRIPTION "Provides regex natives for plugins"
42.46 +#define SMEXT_CONF_VERSION ""
42.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
42.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
42.49 +#define SMEXT_CONF_LOGTAG "REGEX"
42.50 +#define SMEXT_CONF_LICENSE "GPL"
42.51 +#define SMEXT_CONF_DATESTRING ""
42.52 +
42.53 +/**
42.54 + * @brief Exposes plugin's main interface.
42.55 + */
42.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
42.57 +
42.58 +/**
42.59 + * @brief Sets whether or not this plugin required Metamod.
42.60 + * NOTE: Uncomment to enable, comment to disable.
42.61 + */
42.62 +//#define SMEXT_CONF_METAMOD
42.63 +
42.64 +/** Enable interfaces you want to use here by uncommenting lines */
42.65 +//#define SMEXT_ENABLE_FORWARDSYS
42.66 +#define SMEXT_ENABLE_HANDLESYS
42.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
42.68 +//#define SMEXT_ENABLE_DBMANAGER
42.69 +//#define SMEXT_ENABLE_GAMECONF
42.70 +//#define SMEXT_ENABLE_MEMUTILS
42.71 +//#define SMEXT_ENABLE_GAMEHELPERS
42.72 +//#define SMEXT_ENABLE_TIMERSYS
42.73 +//#define SMEXT_ENABLE_THREADER
42.74 +//#define SMEXT_ENABLE_LIBSYS
42.75 +//#define SMEXT_ENABLE_MENUS
42.76 +//#define SMEXT_ENABLE_ADTFACTORY
42.77 +//#define SMEXT_ENABLE_PLUGINSYS
42.78 +//#define SMEXT_ENABLE_ADMINSYS
42.79 +//#define SMEXT_ENABLE_TEXTPARSERS
42.80 +//#define SMEXT_ENABLE_USERMSGS
42.81 +
42.82 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
43.1 --- a/extensions/sdkhooks/AMBuilder Wed Apr 23 21:40:50 2014 -0400
43.2 +++ b/extensions/sdkhooks/AMBuilder Wed Apr 23 21:19:28 2014 -0500
43.3 @@ -16,6 +16,6 @@
43.4 'natives.cpp',
43.5 'takedamageinfohack.cpp',
43.6 'util.cpp',
43.7 - 'sdk/smsdk_ext.cpp',
43.8 + '../../public/smsdk_ext.cpp'
43.9 ]
43.10 SM.extensions += [builder.Add(binary)]
44.1 --- a/extensions/sdkhooks/extension.cpp Wed Apr 23 21:40:50 2014 -0400
44.2 +++ b/extensions/sdkhooks/extension.cpp Wed Apr 23 21:19:28 2014 -0500
44.3 @@ -101,6 +101,10 @@
44.4 IBinTools *g_pBinTools = NULL;
44.5 ICvar *icvar = NULL;
44.6
44.7 +#if SOURCE_ENGINE >= SE_ORANGEBOX
44.8 +IServerTools *servertools = NULL;
44.9 +#endif
44.10 +
44.11 // global hooks and forwards
44.12 IForward *g_pOnEntityCreated = NULL;
44.13 IForward *g_pOnEntityDestroyed = NULL;
44.14 @@ -349,6 +353,7 @@
44.15 GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
44.16
44.17 #if SOURCE_ENGINE >= SE_ORANGEBOX
44.18 + GET_V_IFACE_ANY(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
44.19 g_pCVar = icvar;
44.20 #endif
44.21 CONVAR_REGISTER(this);
45.1 --- a/extensions/sdkhooks/extension.h Wed Apr 23 21:40:50 2014 -0400
45.2 +++ b/extensions/sdkhooks/extension.h Wed Apr 23 21:19:28 2014 -0500
45.3 @@ -12,6 +12,10 @@
45.4 #include <iplayerinfo.h>
45.5 #include <shareddefs.h>
45.6
45.7 +#if SOURCE_ENGINE >= SE_ORANGEBOX
45.8 +#include <itoolentity.h>
45.9 +#endif
45.10 +
45.11 #include "takedamageinfohack.h"
45.12
45.13 #ifndef METAMOD_PLAPI_VERSION
45.14 @@ -334,4 +338,9 @@
45.15 extern ke::Vector<CVTableList *> g_HookList[SDKHook_MAXHOOKS];
45.16
45.17 extern ICvar *icvar;
45.18 +
45.19 +#if SOURCE_ENGINE >= SE_ORANGEBOX
45.20 +extern IServerTools *servertools;
45.21 +#endif
45.22 +
45.23 #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
46.1 --- a/extensions/sdkhooks/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,81 +0,0 @@
46.4 -/**
46.5 - * vim: set ts=4 :
46.6 - * =============================================================================
46.7 - * SourceMod SDK Hooks Extension
46.8 - * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
46.9 - * =============================================================================
46.10 - *
46.11 - * This program is free software; you can redistribute it and/or modify it under
46.12 - * the terms of the GNU General Public License, version 3.0, as published by the
46.13 - * Free Software Foundation.
46.14 - *
46.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
46.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
46.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
46.18 - * details.
46.19 - *
46.20 - * You should have received a copy of the GNU General Public License along with
46.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
46.22 - *
46.23 - * As a special exception, AlliedModders LLC gives you permission to link the
46.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
46.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
46.26 - * by the Valve Corporation. You must obey the GNU General Public License in
46.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
46.28 - * this exception to all derivative works. AlliedModders LLC defines further
46.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
46.30 - * or <http://www.sourcemod.net/license.php>.
46.31 - *
46.32 - * Version: $Id$
46.33 - */
46.34 -
46.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
46.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
46.37 -
46.38 -/**
46.39 - * @file smsdk_config.h
46.40 - * @brief Contains macros for configuring basic extension information.
46.41 - */
46.42 -
46.43 -/* Basic information exposed publicly */
46.44 -#define SMEXT_CONF_NAME "SDK Hooks"
46.45 -#define SMEXT_CONF_DESCRIPTION "Source SDK Hooks"
46.46 -#define SMEXT_CONF_VERSION ""
46.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
46.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
46.49 -#define SMEXT_CONF_LOGTAG "SDKHOOKS"
46.50 -#define SMEXT_CONF_LICENSE "GPL"
46.51 -#define SMEXT_CONF_DATESTRING ""
46.52 -
46.53 -/**
46.54 - * @brief Exposes plugin's main interface.
46.55 - */
46.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
46.57 -
46.58 -/**
46.59 - * @brief Sets whether or not this plugin required Metamod.
46.60 - * NOTE: Uncomment to enable, comment to disable.
46.61 - */
46.62 -#define SMEXT_CONF_METAMOD
46.63 -
46.64 -/** Enable interfaces you want to use here by uncommenting lines */
46.65 -#define SMEXT_ENABLE_FORWARDSYS
46.66 -//#define SMEXT_ENABLE_HANDLESYS
46.67 -#define SMEXT_ENABLE_PLAYERHELPERS
46.68 -//#define SMEXT_ENABLE_DBMANAGER
46.69 -#define SMEXT_ENABLE_GAMECONF
46.70 -//#define SMEXT_ENABLE_MEMUTILS
46.71 -#define SMEXT_ENABLE_GAMEHELPERS
46.72 -//#define SMEXT_ENABLE_TIMERSYS
46.73 -//#define SMEXT_ENABLE_THREADER
46.74 -#define SMEXT_ENABLE_LIBSYS
46.75 -//#define SMEXT_ENABLE_MENUS
46.76 -//#define SMEXT_ENABLE_ADTFACTORY
46.77 -#define SMEXT_ENABLE_PLUGINSYS
46.78 -//#define SMEXT_ENABLE_ADMINSYS
46.79 -//#define SMEXT_ENABLE_TEXTPARSERS
46.80 -//#define SMEXT_ENABLE_USERMSGS
46.81 -//#define SMEXT_ENABLE_TRANSLATOR
46.82 -//#define SMEXT_ENABLE_NINVOKE
46.83 -
46.84 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
47.1 --- a/extensions/sdkhooks/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,473 +0,0 @@
47.4 -/**
47.5 - * vim: set ts=4 :
47.6 - * =============================================================================
47.7 - * SourceMod Base Extension Code
47.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
47.9 - * =============================================================================
47.10 - *
47.11 - * This program is free software; you can redistribute it and/or modify it under
47.12 - * the terms of the GNU General Public License, version 3.0, as published by the
47.13 - * Free Software Foundation.
47.14 - *
47.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
47.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
47.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
47.18 - * details.
47.19 - *
47.20 - * You should have received a copy of the GNU General Public License along with
47.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
47.22 - *
47.23 - * As a special exception, AlliedModders LLC gives you permission to link the
47.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
47.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
47.26 - * by the Valve Corporation. You must obey the GNU General Public License in
47.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
47.28 - * this exception to all derivative works. AlliedModders LLC defines further
47.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
47.30 - * or <http://www.sourcemod.net/license.php>.
47.31 - *
47.32 - * Version: $Id$
47.33 - */
47.34 -
47.35 -#include <stdio.h>
47.36 -#include <stdlib.h>
47.37 -#include "smsdk_ext.h"
47.38 -
47.39 -/**
47.40 - * @file smsdk_ext.cpp
47.41 - * @brief Contains wrappers for making Extensions easier to write.
47.42 - */
47.43 -
47.44 -IExtension *myself = NULL; /**< Ourself */
47.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
47.46 -IShareSys *sharesys = NULL; /**< Share system */
47.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
47.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
47.49 -
47.50 -#if defined SMEXT_ENABLE_FORWARDSYS
47.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
47.52 -IForwardManager *forwards = NULL; /**< Forward system */
47.53 -#endif
47.54 -#if defined SMEXT_ENABLE_HANDLESYS
47.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
47.56 -IHandleSys *handlesys = NULL; /**< Handle system */
47.57 -#endif
47.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
47.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
47.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
47.61 -#if defined SMEXT_ENABLE_DBMANAGER
47.62 -IDBManager *dbi = NULL; /**< DB Manager */
47.63 -#endif //SMEXT_ENABLE_DBMANAGER
47.64 -#if defined SMEXT_ENABLE_GAMECONF
47.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
47.66 -#endif //SMEXT_ENABLE_DBMANAGER
47.67 -#if defined SMEXT_ENABLE_MEMUTILS
47.68 -IMemoryUtils *memutils = NULL;
47.69 -#endif //SMEXT_ENABLE_DBMANAGER
47.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
47.71 -IGameHelpers *gamehelpers = NULL;
47.72 -#endif
47.73 -#if defined SMEXT_ENABLE_TIMERSYS
47.74 -ITimerSystem *timersys = NULL;
47.75 -#endif
47.76 -#if defined SMEXT_ENABLE_ADTFACTORY
47.77 -IADTFactory *adtfactory = NULL;
47.78 -#endif
47.79 -#if defined SMEXT_ENABLE_THREADER
47.80 -IThreader *threader = NULL;
47.81 -#endif
47.82 -#if defined SMEXT_ENABLE_LIBSYS
47.83 -ILibrarySys *libsys = NULL;
47.84 -#endif
47.85 -#if defined SMEXT_ENABLE_PLUGINSYS
47.86 -SourceMod::IPluginManager *plsys;
47.87 -#endif
47.88 -#if defined SMEXT_ENABLE_MENUS
47.89 -IMenuManager *menus = NULL;
47.90 -#endif
47.91 -#if defined SMEXT_ENABLE_ADMINSYS
47.92 -IAdminSystem *adminsys = NULL;
47.93 -#endif
47.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
47.95 -ITextParsers *textparsers = NULL;
47.96 -#endif
47.97 -#if defined SMEXT_ENABLE_USERMSGS
47.98 -IUserMessages *usermsgs = NULL;
47.99 -#endif
47.100 -#if defined SMEXT_ENABLE_TRANSLATOR
47.101 -ITranslator *translator = NULL;
47.102 -#endif
47.103 -#if defined SMEXT_ENABLE_NINVOKE
47.104 -INativeInterface *ninvoke = NULL;
47.105 -#endif
47.106 -
47.107 -/** Exports the main interface */
47.108 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
47.109 -{
47.110 - return g_pExtensionIface;
47.111 -}
47.112 -
47.113 -SDKExtension::SDKExtension()
47.114 -{
47.115 -#if defined SMEXT_CONF_METAMOD
47.116 - m_SourceMMLoaded = false;
47.117 - m_WeAreUnloaded = false;
47.118 - m_WeGotPauseChange = false;
47.119 -#endif
47.120 -}
47.121 -
47.122 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
47.123 -{
47.124 - g_pShareSys = sharesys = sys;
47.125 - myself = me;
47.126 -
47.127 -#if defined SMEXT_CONF_METAMOD
47.128 - m_WeAreUnloaded = true;
47.129 -
47.130 - if (!m_SourceMMLoaded)
47.131 - {
47.132 - if (error)
47.133 - {
47.134 - snprintf(error, maxlength, "Metamod attach failed");
47.135 - }
47.136 - return false;
47.137 - }
47.138 -#endif
47.139 - SM_GET_IFACE(SOURCEMOD, g_pSM);
47.140 - smutils = g_pSM;
47.141 -#if defined SMEXT_ENABLE_HANDLESYS
47.142 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
47.143 - handlesys = g_pHandleSys;
47.144 -#endif
47.145 -#if defined SMEXT_ENABLE_FORWARDSYS
47.146 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
47.147 - forwards = g_pForwards;
47.148 -#endif
47.149 -#if defined SMEXT_ENABLE_PLAYERHELPERS
47.150 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
47.151 -#endif
47.152 -#if defined SMEXT_ENABLE_DBMANAGER
47.153 - SM_GET_IFACE(DBI, dbi);
47.154 -#endif
47.155 -#if defined SMEXT_ENABLE_GAMECONF
47.156 - SM_GET_IFACE(GAMECONFIG, gameconfs);
47.157 -#endif
47.158 -#if defined SMEXT_ENABLE_MEMUTILS
47.159 - SM_GET_IFACE(MEMORYUTILS, memutils);
47.160 -#endif
47.161 -#if defined SMEXT_ENABLE_GAMEHELPERS
47.162 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
47.163 -#endif
47.164 -#if defined SMEXT_ENABLE_TIMERSYS
47.165 - SM_GET_IFACE(TIMERSYS, timersys);
47.166 -#endif
47.167 -#if defined SMEXT_ENABLE_ADTFACTORY
47.168 - SM_GET_IFACE(ADTFACTORY, adtfactory);
47.169 -#endif
47.170 -#if defined SMEXT_ENABLE_THREADER
47.171 - SM_GET_IFACE(THREADER, threader);
47.172 -#endif
47.173 -#if defined SMEXT_ENABLE_LIBSYS
47.174 - SM_GET_IFACE(LIBRARYSYS, libsys);
47.175 -#endif
47.176 -#if defined SMEXT_ENABLE_PLUGINSYS
47.177 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
47.178 -#endif
47.179 -#if defined SMEXT_ENABLE_MENUS
47.180 - SM_GET_IFACE(MENUMANAGER, menus);
47.181 -#endif
47.182 -#if defined SMEXT_ENABLE_ADMINSYS
47.183 - SM_GET_IFACE(ADMINSYS, adminsys);
47.184 -#endif
47.185 -#if defined SMEXT_ENABLE_TEXTPARSERS
47.186 - SM_GET_IFACE(TEXTPARSERS, textparsers);
47.187 -#endif
47.188 -#if defined SMEXT_ENABLE_USERMSGS
47.189 - SM_GET_IFACE(USERMSGS, usermsgs);
47.190 -#endif
47.191 -#if defined SMEXT_ENABLE_TRANSLATOR
47.192 - SM_GET_IFACE(TRANSLATOR, translator);
47.193 -#endif
47.194 -
47.195 - if (SDK_OnLoad(error, maxlength, late))
47.196 - {
47.197 -#if defined SMEXT_CONF_METAMOD
47.198 - m_WeAreUnloaded = true;
47.199 -#endif
47.200 - return true;
47.201 - }
47.202 -
47.203 - return false;
47.204 -}
47.205 -
47.206 -bool SDKExtension::IsMetamodExtension()
47.207 -{
47.208 -#if defined SMEXT_CONF_METAMOD
47.209 - return true;
47.210 -#else
47.211 - return false;
47.212 -#endif
47.213 -}
47.214 -
47.215 -void SDKExtension::OnExtensionPauseChange(bool state)
47.216 -{
47.217 -#if defined SMEXT_CONF_METAMOD
47.218 - m_WeGotPauseChange = true;
47.219 -#endif
47.220 - SDK_OnPauseChange(state);
47.221 -}
47.222 -
47.223 -void SDKExtension::OnExtensionsAllLoaded()
47.224 -{
47.225 - SDK_OnAllLoaded();
47.226 -}
47.227 -
47.228 -void SDKExtension::OnExtensionUnload()
47.229 -{
47.230 -#if defined SMEXT_CONF_METAMOD
47.231 - m_WeAreUnloaded = true;
47.232 -#endif
47.233 - SDK_OnUnload();
47.234 -}
47.235 -
47.236 -const char *SDKExtension::GetExtensionAuthor()
47.237 -{
47.238 - return SMEXT_CONF_AUTHOR;
47.239 -}
47.240 -
47.241 -const char *SDKExtension::GetExtensionDateString()
47.242 -{
47.243 - return SMEXT_CONF_DATESTRING;
47.244 -}
47.245 -
47.246 -const char *SDKExtension::GetExtensionDescription()
47.247 -{
47.248 - return SMEXT_CONF_DESCRIPTION;
47.249 -}
47.250 -
47.251 -const char *SDKExtension::GetExtensionVerString()
47.252 -{
47.253 - return SMEXT_CONF_VERSION;
47.254 -}
47.255 -
47.256 -const char *SDKExtension::GetExtensionName()
47.257 -{
47.258 - return SMEXT_CONF_NAME;
47.259 -}
47.260 -
47.261 -const char *SDKExtension::GetExtensionTag()
47.262 -{
47.263 - return SMEXT_CONF_LOGTAG;
47.264 -}
47.265 -
47.266 -const char *SDKExtension::GetExtensionURL()
47.267 -{
47.268 - return SMEXT_CONF_URL;
47.269 -}
47.270 -
47.271 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
47.272 -{
47.273 - return true;
47.274 -}
47.275 -
47.276 -void SDKExtension::SDK_OnUnload()
47.277 -{
47.278 -}
47.279 -
47.280 -void SDKExtension::SDK_OnPauseChange(bool paused)
47.281 -{
47.282 -}
47.283 -
47.284 -void SDKExtension::SDK_OnAllLoaded()
47.285 -{
47.286 -}
47.287 -
47.288 -#if defined SMEXT_CONF_METAMOD
47.289 -
47.290 -PluginId g_PLID = 0; /**< Metamod plugin ID */
47.291 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
47.292 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
47.293 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
47.294 -
47.295 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
47.296 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
47.297 -
47.298 -#if SOURCE_ENGINE >= SE_ORANGEBOX
47.299 -IServerTools *servertools = NULL; /**< IServerTools pointer */
47.300 -#endif
47.301 -
47.302 -/** Exposes the extension to Metamod */
47.303 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
47.304 -{
47.305 -#if defined METAMOD_PLAPI_VERSION
47.306 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
47.307 -#else
47.308 - if (name && !strcmp(name, PLAPI_NAME))
47.309 -#endif
47.310 - {
47.311 - if (code)
47.312 - {
47.313 - *code = IFACE_OK;
47.314 - }
47.315 - return static_cast<void *>(g_pExtensionIface);
47.316 - }
47.317 -
47.318 - if (code)
47.319 - {
47.320 - *code = IFACE_FAILED;
47.321 - }
47.322 -
47.323 - return NULL;
47.324 -}
47.325 -
47.326 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
47.327 -{
47.328 - PLUGIN_SAVEVARS();
47.329 -
47.330 -#if !defined METAMOD_PLAPI_VERSION
47.331 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
47.332 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
47.333 -#else
47.334 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
47.335 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
47.336 -#endif
47.337 -
47.338 -#if SOURCE_ENGINE >= SE_ORANGEBOX
47.339 - GET_V_IFACE_CURRENT(GetServerFactory, servertools, IServerTools, VSERVERTOOLS_INTERFACE_VERSION);
47.340 -#endif
47.341 -
47.342 - m_SourceMMLoaded = true;
47.343 -
47.344 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
47.345 -}
47.346 -
47.347 -bool SDKExtension::Unload(char *error, size_t maxlen)
47.348 -{
47.349 - if (!m_WeAreUnloaded)
47.350 - {
47.351 - if (error)
47.352 - {
47.353 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
47.354 - }
47.355 - return false;
47.356 - }
47.357 -
47.358 - return SDK_OnMetamodUnload(error, maxlen);
47.359 -}
47.360 -
47.361 -bool SDKExtension::Pause(char *error, size_t maxlen)
47.362 -{
47.363 - if (!m_WeGotPauseChange)
47.364 - {
47.365 - if (error)
47.366 - {
47.367 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
47.368 - }
47.369 - return false;
47.370 - }
47.371 -
47.372 - m_WeGotPauseChange = false;
47.373 -
47.374 - return SDK_OnMetamodPauseChange(true, error, maxlen);
47.375 -}
47.376 -
47.377 -bool SDKExtension::Unpause(char *error, size_t maxlen)
47.378 -{
47.379 - if (!m_WeGotPauseChange)
47.380 - {
47.381 - if (error)
47.382 - {
47.383 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
47.384 - }
47.385 - return false;
47.386 - }
47.387 -
47.388 - m_WeGotPauseChange = false;
47.389 -
47.390 - return SDK_OnMetamodPauseChange(false, error, maxlen);
47.391 -}
47.392 -
47.393 -const char *SDKExtension::GetAuthor()
47.394 -{
47.395 - return GetExtensionAuthor();
47.396 -}
47.397 -
47.398 -const char *SDKExtension::GetDate()
47.399 -{
47.400 - return GetExtensionDateString();
47.401 -}
47.402 -
47.403 -const char *SDKExtension::GetDescription()
47.404 -{
47.405 - return GetExtensionDescription();
47.406 -}
47.407 -
47.408 -const char *SDKExtension::GetLicense()
47.409 -{
47.410 - return SMEXT_CONF_LICENSE;
47.411 -}
47.412 -
47.413 -const char *SDKExtension::GetLogTag()
47.414 -{
47.415 - return GetExtensionTag();
47.416 -}
47.417 -
47.418 -const char *SDKExtension::GetName()
47.419 -{
47.420 - return GetExtensionName();
47.421 -}
47.422 -
47.423 -const char *SDKExtension::GetURL()
47.424 -{
47.425 - return GetExtensionURL();
47.426 -}
47.427 -
47.428 -const char *SDKExtension::GetVersion()
47.429 -{
47.430 - return GetExtensionVerString();
47.431 -}
47.432 -
47.433 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
47.434 -{
47.435 - return true;
47.436 -}
47.437 -
47.438 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
47.439 -{
47.440 - return true;
47.441 -}
47.442 -
47.443 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
47.444 -{
47.445 - return true;
47.446 -}
47.447 -
47.448 -#endif
47.449 -
47.450 -/* Overload a few things to prevent libstdc++ linking */
47.451 -#if defined __linux__ || defined __APPLE__
47.452 -extern "C" void __cxa_pure_virtual(void)
47.453 -{
47.454 -}
47.455 -
47.456 -void *operator new(size_t size)
47.457 -{
47.458 - return malloc(size);
47.459 -}
47.460 -
47.461 -void *operator new[](size_t size)
47.462 -{
47.463 - return malloc(size);
47.464 -}
47.465 -
47.466 -void operator delete(void *ptr)
47.467 -{
47.468 - free(ptr);
47.469 -}
47.470 -
47.471 -void operator delete[](void * ptr)
47.472 -{
47.473 - free(ptr);
47.474 -}
47.475 -#endif
47.476 -
48.1 --- a/extensions/sdkhooks/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,343 +0,0 @@
48.4 -/**
48.5 - * vim: set ts=4 :
48.6 - * =============================================================================
48.7 - * SourceMod Base Extension Code
48.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
48.9 - * =============================================================================
48.10 - *
48.11 - * This program is free software; you can redistribute it and/or modify it under
48.12 - * the terms of the GNU General Public License, version 3.0, as published by the
48.13 - * Free Software Foundation.
48.14 - *
48.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
48.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
48.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
48.18 - * details.
48.19 - *
48.20 - * You should have received a copy of the GNU General Public License along with
48.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
48.22 - *
48.23 - * As a special exception, AlliedModders LLC gives you permission to link the
48.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
48.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
48.26 - * by the Valve Corporation. You must obey the GNU General Public License in
48.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
48.28 - * this exception to all derivative works. AlliedModders LLC defines further
48.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
48.30 - * or <http://www.sourcemod.net/license.php>.
48.31 - *
48.32 - * Version: $Id$
48.33 - */
48.34 -
48.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
48.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
48.37 -
48.38 -/**
48.39 - * @file smsdk_ext.h
48.40 - * @brief Contains wrappers for making Extensions easier to write.
48.41 - */
48.42 -
48.43 -#include "smsdk_config.h"
48.44 -#include <IExtensionSys.h>
48.45 -#include <IHandleSys.h>
48.46 -#include <sp_vm_api.h>
48.47 -#include <sm_platform.h>
48.48 -#include <ISourceMod.h>
48.49 -#if defined SMEXT_ENABLE_FORWARDSYS
48.50 -#include <IForwardSys.h>
48.51 -#endif //SMEXT_ENABLE_FORWARDSYS
48.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
48.53 -#include <IPlayerHelpers.h>
48.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
48.55 -#if defined SMEXT_ENABLE_DBMANAGER
48.56 -#include <IDBDriver.h>
48.57 -#endif //SMEXT_ENABLE_DBMANAGER
48.58 -#if defined SMEXT_ENABLE_GAMECONF
48.59 -#include <IGameConfigs.h>
48.60 -#endif
48.61 -#if defined SMEXT_ENABLE_MEMUTILS
48.62 -#include <IMemoryUtils.h>
48.63 -#endif
48.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
48.65 -#include <IGameHelpers.h>
48.66 -#endif
48.67 -#if defined SMEXT_ENABLE_TIMERSYS
48.68 -#include <ITimerSystem.h>
48.69 -#endif
48.70 -#if defined SMEXT_ENABLE_ADTFACTORY
48.71 -#include <IADTFactory.h>
48.72 -#endif
48.73 -#if defined SMEXT_ENABLE_THREADER
48.74 -#include <IThreader.h>
48.75 -#endif
48.76 -#if defined SMEXT_ENABLE_LIBSYS
48.77 -#include <ILibrarySys.h>
48.78 -#endif
48.79 -#if defined SMEXT_ENABLE_PLUGINSYS
48.80 -#include <IPluginSys.h>
48.81 -#endif
48.82 -#if defined SMEXT_ENABLE_MENUS
48.83 -#include <IMenuManager.h>
48.84 -#endif
48.85 -#if defined SMEXT_ENABLE_ADMINSYS
48.86 -#include <IAdminSystem.h>
48.87 -#endif
48.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
48.89 -#include <ITextParsers.h>
48.90 -#endif
48.91 -#if defined SMEXT_ENABLE_USERMSGS
48.92 -#include <IUserMessages.h>
48.93 -#endif
48.94 -#if defined SMEXT_ENABLE_TRANSLATOR
48.95 -#include <ITranslator.h>
48.96 -#endif
48.97 -#if defined SMEXT_ENABLE_NINVOKE
48.98 -#include <INativeInvoker.h>
48.99 -#endif
48.100 -
48.101 -#if defined SMEXT_CONF_METAMOD
48.102 -#include <ISmmPlugin.h>
48.103 -#include <eiface.h>
48.104 -#include <toolframework/itoolentity.h>
48.105 -#endif
48.106 -
48.107 -using namespace SourceMod;
48.108 -using namespace SourcePawn;
48.109 -
48.110 -class SDKExtension :
48.111 -#if defined SMEXT_CONF_METAMOD
48.112 - public ISmmPlugin,
48.113 -#endif
48.114 - public IExtensionInterface
48.115 -{
48.116 -public:
48.117 - /** Constructor */
48.118 - SDKExtension();
48.119 -public:
48.120 - /**
48.121 - * @brief This is called after the initial loading sequence has been processed.
48.122 - *
48.123 - * @param error Error message buffer.
48.124 - * @param maxlength Size of error message buffer.
48.125 - * @param late Whether or not the module was loaded after map load.
48.126 - * @return True to succeed loading, false to fail.
48.127 - */
48.128 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
48.129 -
48.130 - /**
48.131 - * @brief This is called right before the extension is unloaded.
48.132 - */
48.133 - virtual void SDK_OnUnload();
48.134 -
48.135 - /**
48.136 - * @brief This is called once all known extensions have been loaded.
48.137 - */
48.138 - virtual void SDK_OnAllLoaded();
48.139 -
48.140 - /**
48.141 - * @brief Called when the pause state is changed.
48.142 - */
48.143 - virtual void SDK_OnPauseChange(bool paused);
48.144 -
48.145 -#if defined SMEXT_CONF_METAMOD
48.146 - /**
48.147 - * @brief Called when Metamod is attached, before the extension version is called.
48.148 - *
48.149 - * @param error Error buffer.
48.150 - * @param maxlength Maximum size of error buffer.
48.151 - * @param late Whether or not Metamod considers this a late load.
48.152 - * @return True to succeed, false to fail.
48.153 - */
48.154 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
48.155 -
48.156 - /**
48.157 - * @brief Called when Metamod is detaching, after the extension version is called.
48.158 - * NOTE: By default this is blocked unless sent from SourceMod.
48.159 - *
48.160 - * @param error Error buffer.
48.161 - * @param maxlength Maximum size of error buffer.
48.162 - * @return True to succeed, false to fail.
48.163 - */
48.164 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
48.165 -
48.166 - /**
48.167 - * @brief Called when Metamod's pause state is changing.
48.168 - * NOTE: By default this is blocked unless sent from SourceMod.
48.169 - *
48.170 - * @param paused Pause state being set.
48.171 - * @param error Error buffer.
48.172 - * @param maxlength Maximum size of error buffer.
48.173 - * @return True to succeed, false to fail.
48.174 - */
48.175 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
48.176 -#endif
48.177 -
48.178 -public: //IExtensionInterface
48.179 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
48.180 - virtual void OnExtensionUnload();
48.181 - virtual void OnExtensionsAllLoaded();
48.182 -
48.183 - /** Returns whether or not this is a Metamod-based extension */
48.184 - virtual bool IsMetamodExtension();
48.185 -
48.186 - /**
48.187 - * @brief Called when the pause state changes.
48.188 - *
48.189 - * @param state True if being paused, false if being unpaused.
48.190 - */
48.191 - virtual void OnExtensionPauseChange(bool state);
48.192 -
48.193 - /** Returns name */
48.194 - virtual const char *GetExtensionName();
48.195 - /** Returns URL */
48.196 - virtual const char *GetExtensionURL();
48.197 - /** Returns log tag */
48.198 - virtual const char *GetExtensionTag();
48.199 - /** Returns author */
48.200 - virtual const char *GetExtensionAuthor();
48.201 - /** Returns version string */
48.202 - virtual const char *GetExtensionVerString();
48.203 - /** Returns description string */
48.204 - virtual const char *GetExtensionDescription();
48.205 - /** Returns date string */
48.206 - virtual const char *GetExtensionDateString();
48.207 -#if defined SMEXT_CONF_METAMOD
48.208 -public: //ISmmPlugin
48.209 - /** Called when the extension is attached to Metamod. */
48.210 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
48.211 - /** Returns the author to MM */
48.212 - virtual const char *GetAuthor();
48.213 - /** Returns the name to MM */
48.214 - virtual const char *GetName();
48.215 - /** Returns the description to MM */
48.216 - virtual const char *GetDescription();
48.217 - /** Returns the URL to MM */
48.218 - virtual const char *GetURL();
48.219 - /** Returns the license to MM */
48.220 - virtual const char *GetLicense();
48.221 - /** Returns the version string to MM */
48.222 - virtual const char *GetVersion();
48.223 - /** Returns the date string to MM */
48.224 - virtual const char *GetDate();
48.225 - /** Returns the logtag to MM */
48.226 - virtual const char *GetLogTag();
48.227 - /** Called on unload */
48.228 - virtual bool Unload(char *error, size_t maxlength);
48.229 - /** Called on pause */
48.230 - virtual bool Pause(char *error, size_t maxlength);
48.231 - /** Called on unpause */
48.232 - virtual bool Unpause(char *error, size_t maxlength);
48.233 -private:
48.234 - bool m_SourceMMLoaded;
48.235 - bool m_WeAreUnloaded;
48.236 - bool m_WeGotPauseChange;
48.237 -#endif
48.238 -};
48.239 -
48.240 -extern SDKExtension *g_pExtensionIface;
48.241 -extern IExtension *myself;
48.242 -
48.243 -extern IShareSys *g_pShareSys;
48.244 -extern IShareSys *sharesys; /* Note: Newer name */
48.245 -extern ISourceMod *g_pSM;
48.246 -extern ISourceMod *smutils; /* Note: Newer name */
48.247 -
48.248 -/* Optional interfaces are below */
48.249 -#if defined SMEXT_ENABLE_FORWARDSYS
48.250 -extern IForwardManager *g_pForwards;
48.251 -extern IForwardManager *forwards; /* Note: Newer name */
48.252 -#endif //SMEXT_ENABLE_FORWARDSYS
48.253 -#if defined SMEXT_ENABLE_HANDLESYS
48.254 -extern IHandleSys *g_pHandleSys;
48.255 -extern IHandleSys *handlesys; /* Note: Newer name */
48.256 -#endif //SMEXT_ENABLE_HANDLESYS
48.257 -#if defined SMEXT_ENABLE_PLAYERHELPERS
48.258 -extern IPlayerManager *playerhelpers;
48.259 -#endif //SMEXT_ENABLE_PLAYERHELPERS
48.260 -#if defined SMEXT_ENABLE_DBMANAGER
48.261 -extern IDBManager *dbi;
48.262 -#endif //SMEXT_ENABLE_DBMANAGER
48.263 -#if defined SMEXT_ENABLE_GAMECONF
48.264 -extern IGameConfigManager *gameconfs;
48.265 -#endif //SMEXT_ENABLE_DBMANAGER
48.266 -#if defined SMEXT_ENABLE_MEMUTILS
48.267 -extern IMemoryUtils *memutils;
48.268 -#endif
48.269 -#if defined SMEXT_ENABLE_GAMEHELPERS
48.270 -extern IGameHelpers *gamehelpers;
48.271 -#endif
48.272 -#if defined SMEXT_ENABLE_TIMERSYS
48.273 -extern ITimerSystem *timersys;
48.274 -#endif
48.275 -#if defined SMEXT_ENABLE_ADTFACTORY
48.276 -extern IADTFactory *adtfactory;
48.277 -#endif
48.278 -#if defined SMEXT_ENABLE_THREADER
48.279 -extern IThreader *threader;
48.280 -#endif
48.281 -#if defined SMEXT_ENABLE_LIBSYS
48.282 -extern ILibrarySys *libsys;
48.283 -#endif
48.284 -#if defined SMEXT_ENABLE_PLUGINSYS
48.285 -extern SourceMod::IPluginManager *plsys;
48.286 -#endif
48.287 -#if defined SMEXT_ENABLE_MENUS
48.288 -extern IMenuManager *menus;
48.289 -#endif
48.290 -#if defined SMEXT_ENABLE_ADMINSYS
48.291 -extern IAdminSystem *adminsys;
48.292 -#endif
48.293 -#if defined SMEXT_ENABLE_USERMSGS
48.294 -extern IUserMessages *usermsgs;
48.295 -#endif
48.296 -#if defined SMEXT_ENABLE_TRANSLATOR
48.297 -extern ITranslator *translator;
48.298 -#endif
48.299 -#if defined SMEXT_ENABLE_NINVOKE
48.300 -extern INativeInterface *ninvoke;
48.301 -#endif
48.302 -
48.303 -#if defined SMEXT_CONF_METAMOD
48.304 -PLUGIN_GLOBALVARS();
48.305 -extern IVEngineServer *engine;
48.306 -extern IServerGameDLL *gamedll;
48.307 -#if SOURCE_ENGINE >= SE_ORANGEBOX
48.308 -extern IServerTools *servertools;
48.309 -#endif
48.310 -#endif
48.311 -
48.312 -/** Creates a SourceMod interface macro pair */
48.313 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
48.314 -/** Automates retrieving SourceMod interfaces */
48.315 -#define SM_GET_IFACE(prefix, addr) \
48.316 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
48.317 - { \
48.318 - if (error != NULL && maxlength) \
48.319 - { \
48.320 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
48.321 - if (len >= maxlength) \
48.322 - { \
48.323 - error[maxlength - 1] = '\0'; \
48.324 - } \
48.325 - } \
48.326 - return false; \
48.327 - }
48.328 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
48.329 -#define SM_GET_LATE_IFACE(prefix, addr) \
48.330 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
48.331 -/** Validates a SourceMod interface pointer */
48.332 -#define SM_CHECK_IFACE(prefix, addr) \
48.333 - if (!addr) \
48.334 - { \
48.335 - if (error != NULL && maxlength) \
48.336 - { \
48.337 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
48.338 - if (len >= maxlength) \
48.339 - { \
48.340 - error[maxlength - 1] = '\0'; \
48.341 - } \
48.342 - } \
48.343 - return false; \
48.344 - }
48.345 -
48.346 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/extensions/sdkhooks/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
49.3 @@ -0,0 +1,81 @@
49.4 +/**
49.5 + * vim: set ts=4 :
49.6 + * =============================================================================
49.7 + * SourceMod SDK Hooks Extension
49.8 + * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
49.9 + * =============================================================================
49.10 + *
49.11 + * This program is free software; you can redistribute it and/or modify it under
49.12 + * the terms of the GNU General Public License, version 3.0, as published by the
49.13 + * Free Software Foundation.
49.14 + *
49.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
49.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
49.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
49.18 + * details.
49.19 + *
49.20 + * You should have received a copy of the GNU General Public License along with
49.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
49.22 + *
49.23 + * As a special exception, AlliedModders LLC gives you permission to link the
49.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
49.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
49.26 + * by the Valve Corporation. You must obey the GNU General Public License in
49.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
49.28 + * this exception to all derivative works. AlliedModders LLC defines further
49.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
49.30 + * or <http://www.sourcemod.net/license.php>.
49.31 + *
49.32 + * Version: $Id$
49.33 + */
49.34 +
49.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
49.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
49.37 +
49.38 +/**
49.39 + * @file smsdk_config.h
49.40 + * @brief Contains macros for configuring basic extension information.
49.41 + */
49.42 +
49.43 +/* Basic information exposed publicly */
49.44 +#define SMEXT_CONF_NAME "SDK Hooks"
49.45 +#define SMEXT_CONF_DESCRIPTION "Source SDK Hooks"
49.46 +#define SMEXT_CONF_VERSION ""
49.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
49.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
49.49 +#define SMEXT_CONF_LOGTAG "SDKHOOKS"
49.50 +#define SMEXT_CONF_LICENSE "GPL"
49.51 +#define SMEXT_CONF_DATESTRING ""
49.52 +
49.53 +/**
49.54 + * @brief Exposes plugin's main interface.
49.55 + */
49.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
49.57 +
49.58 +/**
49.59 + * @brief Sets whether or not this plugin required Metamod.
49.60 + * NOTE: Uncomment to enable, comment to disable.
49.61 + */
49.62 +#define SMEXT_CONF_METAMOD
49.63 +
49.64 +/** Enable interfaces you want to use here by uncommenting lines */
49.65 +#define SMEXT_ENABLE_FORWARDSYS
49.66 +//#define SMEXT_ENABLE_HANDLESYS
49.67 +#define SMEXT_ENABLE_PLAYERHELPERS
49.68 +//#define SMEXT_ENABLE_DBMANAGER
49.69 +#define SMEXT_ENABLE_GAMECONF
49.70 +//#define SMEXT_ENABLE_MEMUTILS
49.71 +#define SMEXT_ENABLE_GAMEHELPERS
49.72 +//#define SMEXT_ENABLE_TIMERSYS
49.73 +//#define SMEXT_ENABLE_THREADER
49.74 +#define SMEXT_ENABLE_LIBSYS
49.75 +//#define SMEXT_ENABLE_MENUS
49.76 +//#define SMEXT_ENABLE_ADTFACTORY
49.77 +#define SMEXT_ENABLE_PLUGINSYS
49.78 +//#define SMEXT_ENABLE_ADMINSYS
49.79 +//#define SMEXT_ENABLE_TEXTPARSERS
49.80 +//#define SMEXT_ENABLE_USERMSGS
49.81 +//#define SMEXT_ENABLE_TRANSLATOR
49.82 +//#define SMEXT_ENABLE_NINVOKE
49.83 +
49.84 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
50.1 --- a/extensions/sdktools/AMBuilder Wed Apr 23 21:40:50 2014 -0400
50.2 +++ b/extensions/sdktools/AMBuilder Wed Apr 23 21:19:28 2014 -0500
50.3 @@ -38,8 +38,8 @@
50.4 'hooks.cpp',
50.5 'gamerulesnatives.cpp',
50.6 'vstringtable.cpp',
50.7 - 'CDetour/detours.cpp',
50.8 - 'sdk/smsdk_ext.cpp',
50.9 - 'asm/asm.c'
50.10 + '../../public/smsdk_ext.cpp',
50.11 + '../../public/CDetour/detours.cpp',
50.12 + '../../public/asm/asm.c'
50.13 ]
50.14 SM.extensions += [builder.Add(binary)]
51.1 --- a/extensions/sdktools/CDetour/detourhelpers.h Wed Apr 23 21:40:50 2014 -0400
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,100 +0,0 @@
51.4 -/**
51.5 - * vim: set ts=4 :
51.6 - * =============================================================================
51.7 - * SourceMod
51.8 - * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
51.9 - * =============================================================================
51.10 - *
51.11 - * This program is free software; you can redistribute it and/or modify it under
51.12 - * the terms of the GNU General Public License, version 3.0, as published by the
51.13 - * Free Software Foundation.
51.14 - *
51.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
51.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
51.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
51.18 - * details.
51.19 - *
51.20 - * You should have received a copy of the GNU General Public License along with
51.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
51.22 - *
51.23 - * As a special exception, AlliedModders LLC gives you permission to link the
51.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
51.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
51.26 - * by the Valve Corporation. You must obey the GNU General Public License in
51.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
51.28 - * this exception to all derivative works. AlliedModders LLC defines further
51.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
51.30 - * or <http://www.sourcemod.net/license.php>.
51.31 - *
51.32 - * Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $
51.33 - */
51.34 -
51.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
51.36 -#define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
51.37 -
51.38 -#if defined PLATFORM_POSIX
51.39 -#include <sys/mman.h>
51.40 -#ifndef PAGE_SIZE
51.41 -#define PAGE_SIZE 4096
51.42 -#endif
51.43 -#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
51.44 -#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
51.45 -#endif
51.46 -
51.47 -struct patch_t
51.48 -{
51.49 - patch_t()
51.50 - {
51.51 - patch[0] = 0;
51.52 - bytes = 0;
51.53 - }
51.54 - unsigned char patch[20];
51.55 - size_t bytes;
51.56 -};
51.57 -
51.58 -inline void ProtectMemory(void *addr, int length, int prot)
51.59 -{
51.60 -#if defined PLATFORM_POSIX
51.61 - void *addr2 = (void *)ALIGN(addr);
51.62 - mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
51.63 -#elif defined PLATFORM_WINDOWS
51.64 - DWORD old_prot;
51.65 - VirtualProtect(addr, length, prot, &old_prot);
51.66 -#endif
51.67 -}
51.68 -
51.69 -inline void SetMemPatchable(void *address, size_t size)
51.70 -{
51.71 - ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
51.72 -}
51.73 -
51.74 -inline void DoGatePatch(unsigned char *target, void *callback)
51.75 -{
51.76 - SetMemPatchable(target, 20);
51.77 -
51.78 - target[0] = 0xFF; /* JMP */
51.79 - target[1] = 0x25; /* MEM32 */
51.80 - *(void **)(&target[2]) = callback;
51.81 -}
51.82 -
51.83 -inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
51.84 -{
51.85 - ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
51.86 -
51.87 - unsigned char *addr = (unsigned char *)address + offset;
51.88 - if (restore)
51.89 - {
51.90 - for (size_t i=0; i<patch->bytes; i++)
51.91 - {
51.92 - restore->patch[i] = addr[i];
51.93 - }
51.94 - restore->bytes = patch->bytes;
51.95 - }
51.96 -
51.97 - for (size_t i=0; i<patch->bytes; i++)
51.98 - {
51.99 - addr[i] = patch->patch[i];
51.100 - }
51.101 -}
51.102 -
51.103 -#endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_
52.1 --- a/extensions/sdktools/CDetour/detours.cpp Wed Apr 23 21:40:50 2014 -0400
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,192 +0,0 @@
52.4 -/**
52.5 -* vim: set ts=4 :
52.6 -* =============================================================================
52.7 -* SourceMod
52.8 -* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
52.9 -* =============================================================================
52.10 -*
52.11 -* This program is free software; you can redistribute it and/or modify it under
52.12 -* the terms of the GNU General Public License, version 3.0, as published by the
52.13 -* Free Software Foundation.
52.14 -*
52.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
52.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
52.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
52.18 -* details.
52.19 -*
52.20 -* You should have received a copy of the GNU General Public License along with
52.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
52.22 -*
52.23 -* As a special exception, AlliedModders LLC gives you permission to link the
52.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
52.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
52.26 -* by the Valve Corporation. You must obey the GNU General Public License in
52.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
52.28 -* this exception to all derivative works. AlliedModders LLC defines further
52.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
52.30 -* or <http://www.sourcemod.net/license.php>.
52.31 -*
52.32 -* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
52.33 -*/
52.34 -
52.35 -#include "detours.h"
52.36 -#include <asm/asm.h>
52.37 -
52.38 -ISourcePawnEngine *CDetourManager::spengine = NULL;
52.39 -IGameConfig *CDetourManager::gameconf = NULL;
52.40 -
52.41 -void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
52.42 -{
52.43 - CDetourManager::spengine = spengine;
52.44 - CDetourManager::gameconf = gameconf;
52.45 -}
52.46 -
52.47 -CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
52.48 -{
52.49 - CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
52.50 - if (detour)
52.51 - {
52.52 - if (!detour->Init(spengine, gameconf))
52.53 - {
52.54 - delete detour;
52.55 - return NULL;
52.56 - }
52.57 -
52.58 - return detour;
52.59 - }
52.60 -
52.61 - return NULL;
52.62 -}
52.63 -
52.64 -CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
52.65 -{
52.66 - enabled = false;
52.67 - detoured = false;
52.68 - detour_address = NULL;
52.69 - detour_trampoline = NULL;
52.70 - this->signame = signame;
52.71 - this->detour_callback = callbackfunction;
52.72 - spengine = NULL;
52.73 - gameconf = NULL;
52.74 - this->trampoline = trampoline;
52.75 -}
52.76 -
52.77 -bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
52.78 -{
52.79 - this->spengine = spengine;
52.80 - this->gameconf = gameconf;
52.81 -
52.82 - if (!CreateDetour())
52.83 - {
52.84 - enabled = false;
52.85 - return enabled;
52.86 - }
52.87 -
52.88 - enabled = true;
52.89 -
52.90 - return enabled;
52.91 -}
52.92 -
52.93 -void CDetour::Destroy()
52.94 -{
52.95 - DeleteDetour();
52.96 - delete this;
52.97 -}
52.98 -
52.99 -bool CDetour::IsEnabled()
52.100 -{
52.101 - return enabled;
52.102 -}
52.103 -
52.104 -bool CDetour::CreateDetour()
52.105 -{
52.106 - if (!gameconf->GetMemSig(signame, &detour_address))
52.107 - {
52.108 - g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame);
52.109 - return false;
52.110 - }
52.111 -
52.112 - if (!detour_address)
52.113 - {
52.114 - g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame);
52.115 - return false;
52.116 - }
52.117 -
52.118 - detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE+1);
52.119 -
52.120 - /* First, save restore bits */
52.121 - for (size_t i=0; i<detour_restore.bytes; i++)
52.122 - {
52.123 - detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
52.124 - }
52.125 -
52.126 - JitWriter wr;
52.127 - JitWriter *jit = ≀
52.128 - jit_uint32_t CodeSize = 0;
52.129 -
52.130 - wr.outbase = NULL;
52.131 - wr.outptr = NULL;
52.132 -
52.133 -jit_rewind:
52.134 -
52.135 - /* Patch old bytes in */
52.136 - if (wr.outbase != NULL)
52.137 - {
52.138 - copy_bytes((unsigned char *)detour_address, (unsigned char*)wr.outptr, detour_restore.bytes);
52.139 - }
52.140 - wr.outptr += detour_restore.bytes;
52.141 -
52.142 - /* Return to the original function */
52.143 - jitoffs_t call = IA32_Jump_Imm32(jit, 0);
52.144 - IA32_Write_Jump32_Abs(jit, call, (unsigned char *)detour_address + detour_restore.bytes);
52.145 -
52.146 - if (wr.outbase == NULL)
52.147 - {
52.148 - CodeSize = wr.get_outputpos();
52.149 - wr.outbase = (jitcode_t)spengine->AllocatePageMemory(CodeSize);
52.150 - spengine->SetReadWrite(wr.outbase);
52.151 - wr.outptr = wr.outbase;
52.152 - detour_trampoline = wr.outbase;
52.153 - goto jit_rewind;
52.154 - }
52.155 -
52.156 - spengine->SetReadExecute(wr.outbase);
52.157 -
52.158 - *trampoline = detour_trampoline;
52.159 -
52.160 - return true;
52.161 -}
52.162 -
52.163 -void CDetour::DeleteDetour()
52.164 -{
52.165 - if (detoured)
52.166 - {
52.167 - DisableDetour();
52.168 - }
52.169 -
52.170 - if (detour_trampoline)
52.171 - {
52.172 - /* Free the allocated trampoline memory */
52.173 - spengine->FreePageMemory(detour_trampoline);
52.174 - detour_trampoline = NULL;
52.175 - }
52.176 -}
52.177 -
52.178 -void CDetour::EnableDetour()
52.179 -{
52.180 - if (!detoured)
52.181 - {
52.182 - DoGatePatch((unsigned char *)detour_address, &detour_callback);
52.183 - detoured = true;
52.184 - }
52.185 -}
52.186 -
52.187 -void CDetour::DisableDetour()
52.188 -{
52.189 - if (detoured)
52.190 - {
52.191 - /* Remove the patch */
52.192 - ApplyPatch(detour_address, 0, &detour_restore, NULL);
52.193 - detoured = false;
52.194 - }
52.195 -}
53.1 --- a/extensions/sdktools/CDetour/detours.h Wed Apr 23 21:40:50 2014 -0400
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,251 +0,0 @@
53.4 -/**
53.5 -* vim: set ts=4 :
53.6 -* =============================================================================
53.7 -* SourceMod
53.8 -* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
53.9 -* =============================================================================
53.10 -*
53.11 -* This program is free software; you can redistribute it and/or modify it under
53.12 -* the terms of the GNU General Public License, version 3.0, as published by the
53.13 -* Free Software Foundation.
53.14 -*
53.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
53.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
53.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
53.18 -* details.
53.19 -*
53.20 -* You should have received a copy of the GNU General Public License along with
53.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
53.22 -*
53.23 -* As a special exception, AlliedModders LLC gives you permission to link the
53.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
53.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
53.26 -* by the Valve Corporation. You must obey the GNU General Public License in
53.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
53.28 -* this exception to all derivative works. AlliedModders LLC defines further
53.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
53.30 -* or <http://www.sourcemod.net/license.php>.
53.31 -*
53.32 -* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
53.33 -*/
53.34 -
53.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
53.36 -#define _INCLUDE_SOURCEMOD_DETOURS_H_
53.37 -
53.38 -#include "extension.h"
53.39 -#include <jit/jit_helpers.h>
53.40 -#include <jit/x86/x86_macros.h>
53.41 -#include "detourhelpers.h"
53.42 -
53.43 -/**
53.44 - * CDetours class for SourceMod Extensions by pRED*
53.45 - * detourhelpers.h entirely stolen from CSS:DM and were written by BAILOPAN (I assume).
53.46 - * asm.h/c from devmaster.net (thanks cybermind) edited by pRED* to handle gcc -fPIC thunks correctly
53.47 - * Concept by Nephyrin Zey (http://www.doublezen.net/) and Windows Detour Library (http://research.microsoft.com/sn/detours/)
53.48 - * Member function pointer ideas by Don Clugston (http://www.codeproject.com/cpp/FastDelegate.asp)
53.49 - */
53.50 -
53.51 -#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
53.52 -#define DETOUR_STATIC_CALL(name) (name##_Actual)
53.53 -
53.54 -#define DETOUR_DECL_STATIC0(name, ret) \
53.55 -ret (*name##_Actual)(void) = NULL; \
53.56 -ret name(void)
53.57 -
53.58 -#define DETOUR_DECL_STATIC1(name, ret, p1type, p1name) \
53.59 -ret (*name##_Actual)(p1type) = NULL; \
53.60 -ret name(p1type p1name)
53.61 -
53.62 -#define DETOUR_DECL_STATIC4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
53.63 -ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
53.64 -ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
53.65 -
53.66 -#define DETOUR_DECL_MEMBER0(name, ret) \
53.67 -class name##Class \
53.68 -{ \
53.69 -public: \
53.70 - ret name(); \
53.71 - static ret (name##Class::* name##_Actual)(void); \
53.72 -}; \
53.73 -ret (name##Class::* name##Class::name##_Actual)(void) = NULL; \
53.74 -ret name##Class::name()
53.75 -
53.76 -#define DETOUR_DECL_MEMBER1(name, ret, p1type, p1name) \
53.77 -class name##Class \
53.78 -{ \
53.79 -public: \
53.80 - ret name(p1type p1name); \
53.81 - static ret (name##Class::* name##_Actual)(p1type); \
53.82 -}; \
53.83 -ret (name##Class::* name##Class::name##_Actual)(p1type) = NULL; \
53.84 -ret name##Class::name(p1type p1name)
53.85 -
53.86 -#define DETOUR_DECL_MEMBER2(name, ret, p1type, p1name, p2type, p2name) \
53.87 -class name##Class \
53.88 -{ \
53.89 -public: \
53.90 - ret name(p1type p1name, p2type p2name); \
53.91 - static ret (name##Class::* name##_Actual)(p1type, p2type); \
53.92 -}; \
53.93 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type) = NULL; \
53.94 -ret name##Class::name(p1type p1name, p2type p2name)
53.95 -
53.96 -#define DETOUR_DECL_MEMBER3(name, ret, p1type, p1name, p2type, p2name, p3type, p3name) \
53.97 -class name##Class \
53.98 -{ \
53.99 -public: \
53.100 - ret name(p1type p1name, p2type p2name, p3type p3name); \
53.101 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type); \
53.102 -}; \
53.103 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type) = NULL; \
53.104 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name)
53.105 -
53.106 -#define DETOUR_DECL_MEMBER4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
53.107 -class name##Class \
53.108 -{ \
53.109 -public: \
53.110 - ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name); \
53.111 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type); \
53.112 -}; \
53.113 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
53.114 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
53.115 -
53.116 -#define DETOUR_DECL_MEMBER8(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name) \
53.117 -class name##Class \
53.118 -{ \
53.119 -public: \
53.120 - ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name); \
53.121 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type); \
53.122 -}; \
53.123 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
53.124 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
53.125 -
53.126 -
53.127 -#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
53.128 -#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
53.129 -
53.130 -#define GET_STATIC_CALLBACK(name) (void *)&name
53.131 -#define GET_STATIC_TRAMPOLINE(name) (void **)&name##_Actual
53.132 -
53.133 -#define DETOUR_CREATE_MEMBER(name, gamedata) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), gamedata);
53.134 -#define DETOUR_CREATE_STATIC(name, gamedata) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), gamedata);
53.135 -
53.136 -
53.137 -class GenericClass {};
53.138 -typedef void (GenericClass::*VoidFunc)();
53.139 -
53.140 -inline void *GetCodeAddr(VoidFunc mfp)
53.141 -{
53.142 - return *(void **)&mfp;
53.143 -}
53.144 -
53.145 -/**
53.146 - * Converts a member function pointer to a void pointer.
53.147 - * This relies on the assumption that the code address lies at mfp+0
53.148 - * This is the case for both g++ and later MSVC versions on non virtual functions but may be different for other compilers
53.149 - * Based on research by Don Clugston : http://www.codeproject.com/cpp/FastDelegate.asp
53.150 - */
53.151 -#define GetCodeAddress(mfp) GetCodeAddr(reinterpret_cast<VoidFunc>(mfp))
53.152 -
53.153 -class CDetourManager;
53.154 -
53.155 -class CDetour
53.156 -{
53.157 -public:
53.158 -
53.159 - bool IsEnabled();
53.160 -
53.161 - /**
53.162 - * These would be somewhat self-explanatory I hope
53.163 - */
53.164 - void EnableDetour();
53.165 - void DisableDetour();
53.166 -
53.167 - void Destroy();
53.168 -
53.169 - friend class CDetourManager;
53.170 -
53.171 -protected:
53.172 - CDetour(void *callbackfunction, void **trampoline, const char *signame);
53.173 -
53.174 - bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
53.175 -private:
53.176 -
53.177 - /* These create/delete the allocated memory */
53.178 - bool CreateDetour();
53.179 - void DeleteDetour();
53.180 -
53.181 - bool enabled;
53.182 - bool detoured;
53.183 -
53.184 - patch_t detour_restore;
53.185 - /* Address of the detoured function */
53.186 - void *detour_address;
53.187 - /* Address of the allocated trampoline function */
53.188 - void *detour_trampoline;
53.189 - /* Address of the callback handler */
53.190 - void *detour_callback;
53.191 - /* The function pointer used to call our trampoline */
53.192 - void **trampoline;
53.193 -
53.194 - const char *signame;
53.195 - ISourcePawnEngine *spengine;
53.196 - IGameConfig *gameconf;
53.197 -};
53.198 -
53.199 -class CDetourManager
53.200 -{
53.201 -public:
53.202 -
53.203 - static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
53.204 -
53.205 - /**
53.206 - * Creates a new detour
53.207 - *
53.208 - * @param callbackfunction Void pointer to your detour callback function.
53.209 - * @param trampoline Address of the trampoline pointer
53.210 - * @param signame Section name containing a signature to fetch from the gamedata file.
53.211 - * @return A new CDetour pointer to control your detour.
53.212 - *
53.213 - * Example:
53.214 - *
53.215 - * CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
53.216 - *
53.217 - * Define a new class with the required function and a member function pointer to the same type:
53.218 - *
53.219 - * class CBaseServerDetour
53.220 - * {
53.221 - * public:
53.222 - * bool ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
53.223 - * static bool (CBaseServerDetour::* ConnectClient_Actual)(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
53.224 - * }
53.225 - *
53.226 - * void *callbackfunc = GetCodeAddress(&CBaseServerDetour::ConnectClient);
53.227 - * void **trampoline = (void **)(&CBaseServerDetour::ConnectClient_Actual);
53.228 - *
53.229 - * Creation:
53.230 - * CDetourManager::CreateDetour(callbackfunc, trampoline, "ConnectClient");
53.231 - *
53.232 - * Usage:
53.233 - *
53.234 - * CBaseServerDetour::ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int)
53.235 - * {
53.236 - * //pre hook code
53.237 - * bool result = (this->*ConnectClient_Actual)(netaddr_s, rest of params);
53.238 - * //post hook code
53.239 - * return result;
53.240 - * }
53.241 - *
53.242 - * Note we changed the netadr_s reference into a void* to avoid needing to define the type
53.243 - */
53.244 - static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
53.245 -
53.246 - friend class CBlocker;
53.247 - friend class CDetour;
53.248 -
53.249 -private:
53.250 - static ISourcePawnEngine *spengine;
53.251 - static IGameConfig *gameconf;
53.252 -};
53.253 -
53.254 -#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
54.1 --- a/extensions/sdktools/asm/asm.c Wed Apr 23 21:40:50 2014 -0400
54.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
54.3 @@ -1,421 +0,0 @@
54.4 -#include "asm.h"
54.5 -
54.6 -#ifndef WIN32
54.7 -#define _GNU_SOURCE
54.8 -#include <dlfcn.h>
54.9 -#include <string.h>
54.10 -
54.11 -#define REG_EAX 0
54.12 -#define REG_ECX 1
54.13 -#define REG_EDX 2
54.14 -#define REG_EBX 3
54.15 -
54.16 -#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
54.17 -#endif
54.18 -
54.19 -extern void Msg( const char *, ... );
54.20 -
54.21 -/**
54.22 -* Checks if a call to a fpic thunk has just been written into dest.
54.23 -* If found replaces it with a direct mov that sets the required register to the value of pc.
54.24 -*
54.25 -* @param dest Destination buffer where a call opcode + addr (5 bytes) has just been written.
54.26 -* @param pc The program counter value that needs to be set (usually the next address from the source).
54.27 -* @noreturn
54.28 -*/
54.29 -void check_thunks(unsigned char *dest, unsigned char *pc)
54.30 -{
54.31 -#if defined WIN32
54.32 - return;
54.33 -#else
54.34 - /* Step write address back 4 to the start of the function address */
54.35 - unsigned char *writeaddr = dest - 4;
54.36 - unsigned char *calloffset = *(unsigned char **)writeaddr;
54.37 - unsigned char *calladdr = (unsigned char *)(dest + (unsigned int)calloffset);
54.38 -
54.39 - /* Lookup name of function being called */
54.40 - if ((*calladdr == 0x8B) && (*(calladdr+2) == 0x24) && (*(calladdr+3) == 0xC3))
54.41 - {
54.42 - //a thunk maybe?
54.43 - char movByte = IA32_MOV_REG_IMM;
54.44 -
54.45 - /* Calculate the correct mov opcode */
54.46 - switch (*(calladdr+1))
54.47 - {
54.48 - case 0x04:
54.49 - {
54.50 - movByte += REG_EAX;
54.51 - break;
54.52 - }
54.53 - case 0x1C:
54.54 - {
54.55 - movByte += REG_EBX;
54.56 - break;
54.57 - }
54.58 - case 0x0C:
54.59 - {
54.60 - movByte += REG_ECX;
54.61 - break;
54.62 - }
54.63 - case 0x14:
54.64 - {
54.65 - movByte += REG_EDX;
54.66 - break;
54.67 - }
54.68 - default:
54.69 - {
54.70 - Msg("Unknown thunk: %c\n", *(calladdr+1));
54.71 - break;
54.72 - }
54.73 - }
54.74 -
54.75 - /* Move our write address back one to where the call opcode was */
54.76 - writeaddr--;
54.77 -
54.78 -
54.79 - /* Write our mov */
54.80 - *writeaddr = movByte;
54.81 - writeaddr++;
54.82 -
54.83 - /* Write the value - The provided program counter value */
54.84 - *(void **)writeaddr = (void *)pc;
54.85 - writeaddr += 4;
54.86 - }
54.87 -
54.88 - return;
54.89 -#endif
54.90 -}
54.91 -
54.92 -//if dest is NULL, returns minimum number of bytes needed to be copied
54.93 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
54.94 -//http://www.devmaster.net/forums/showthread.php?t=2311
54.95 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
54.96 - int bytecount = 0;
54.97 -
54.98 - while(bytecount < required_len && *func != 0xCC)
54.99 - {
54.100 - // prefixes F0h, F2h, F3h, 66h, 67h, D8h-DFh, 2Eh, 36h, 3Eh, 26h, 64h and 65h
54.101 - int operandSize = 4;
54.102 - int FPU = 0;
54.103 - int twoByte = 0;
54.104 - unsigned char opcode = 0x90;
54.105 - unsigned char modRM = 0xFF;
54.106 - while(*func == 0xF0 ||
54.107 - *func == 0xF2 ||
54.108 - *func == 0xF3 ||
54.109 - (*func & 0xFC) == 0x64 ||
54.110 - (*func & 0xF8) == 0xD8 ||
54.111 - (*func & 0x7E) == 0x62)
54.112 - {
54.113 - if(*func == 0x66)
54.114 - {
54.115 - operandSize = 2;
54.116 - }
54.117 - else if((*func & 0xF8) == 0xD8)
54.118 - {
54.119 - FPU = *func;
54.120 - if (dest)
54.121 - *dest++ = *func++;
54.122 - else
54.123 - func++;
54.124 - bytecount++;
54.125 - break;
54.126 - }
54.127 -
54.128 - if (dest)
54.129 - *dest++ = *func++;
54.130 - else
54.131 - func++;
54.132 - bytecount++;
54.133 - }
54.134 -
54.135 - // two-byte opcode byte
54.136 - if(*func == 0x0F)
54.137 - {
54.138 - twoByte = 1;
54.139 - if (dest)
54.140 - *dest++ = *func++;
54.141 - else
54.142 - func++;
54.143 - bytecount++;
54.144 - }
54.145 -
54.146 - // opcode byte
54.147 - opcode = *func++;
54.148 - if (dest) *dest++ = opcode;
54.149 - bytecount++;
54.150 -
54.151 - // mod R/M byte
54.152 - modRM = 0xFF;
54.153 - if(FPU)
54.154 - {
54.155 - if((opcode & 0xC0) != 0xC0)
54.156 - {
54.157 - modRM = opcode;
54.158 - }
54.159 - }
54.160 - else if(!twoByte)
54.161 - {
54.162 - if((opcode & 0xC4) == 0x00 ||
54.163 - ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) ||
54.164 - (opcode & 0xF0) == 0x80 ||
54.165 - ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) ||
54.166 - (opcode & 0xFC) == 0xD0 ||
54.167 - (opcode & 0xF6) == 0xF6)
54.168 - {
54.169 - modRM = *func++;
54.170 - if (dest) *dest++ = modRM;
54.171 - bytecount++;
54.172 - }
54.173 - }
54.174 - else
54.175 - {
54.176 - if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) ||
54.177 - (opcode & 0xF0) == 0x30 ||
54.178 - opcode == 0x77 ||
54.179 - (opcode & 0xF0) == 0x80 ||
54.180 - ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) ||
54.181 - (opcode & 0xF8) == 0xC8)
54.182 - {
54.183 - // No mod R/M byte
54.184 - }
54.185 - else
54.186 - {
54.187 - modRM = *func++;
54.188 - if (dest) *dest++ = modRM;
54.189 - bytecount++;
54.190 - }
54.191 - }
54.192 -
54.193 - // SIB
54.194 - if((modRM & 0x07) == 0x04 &&
54.195 - (modRM & 0xC0) != 0xC0)
54.196 - {
54.197 - if (dest)
54.198 - *dest++ = *func++; //SIB
54.199 - else
54.200 - func++;
54.201 - bytecount++;
54.202 - }
54.203 -
54.204 - // mod R/M displacement
54.205 -
54.206 - // Dword displacement, no base
54.207 - if((modRM & 0xC5) == 0x05) {
54.208 - if (dest) {
54.209 - *(unsigned int*)dest = *(unsigned int*)func;
54.210 - dest += 4;
54.211 - }
54.212 - func += 4;
54.213 - bytecount += 4;
54.214 - }
54.215 -
54.216 - // Byte displacement
54.217 - if((modRM & 0xC0) == 0x40) {
54.218 - if (dest)
54.219 - *dest++ = *func++;
54.220 - else
54.221 - func++;
54.222 - bytecount++;
54.223 - }
54.224 -
54.225 - // Dword displacement
54.226 - if((modRM & 0xC0) == 0x80) {
54.227 - if (dest) {
54.228 - *(unsigned int*)dest = *(unsigned int*)func;
54.229 - dest += 4;
54.230 - }
54.231 - func += 4;
54.232 - bytecount += 4;
54.233 - }
54.234 -
54.235 - // immediate
54.236 - if(FPU)
54.237 - {
54.238 - // Can't have immediate operand
54.239 - }
54.240 - else if(!twoByte)
54.241 - {
54.242 - if((opcode & 0xC7) == 0x04 ||
54.243 - (opcode & 0xFE) == 0x6A || // PUSH/POP/IMUL
54.244 - (opcode & 0xF0) == 0x70 || // Jcc
54.245 - opcode == 0x80 ||
54.246 - opcode == 0x83 ||
54.247 - (opcode & 0xFD) == 0xA0 || // MOV
54.248 - opcode == 0xA8 || // TEST
54.249 - (opcode & 0xF8) == 0xB0 || // MOV
54.250 - (opcode & 0xFE) == 0xC0 || // RCL
54.251 - opcode == 0xC6 || // MOV
54.252 - opcode == 0xCD || // INT
54.253 - (opcode & 0xFE) == 0xD4 || // AAD/AAM
54.254 - (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ
54.255 - opcode == 0xEB ||
54.256 - (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST
54.257 - {
54.258 - if (dest)
54.259 - *dest++ = *func++;
54.260 - else
54.261 - func++;
54.262 - bytecount++;
54.263 - }
54.264 - else if((opcode & 0xF7) == 0xC2) // RET
54.265 - {
54.266 - if (dest) {
54.267 - *(unsigned short*)dest = *(unsigned short*)func;
54.268 - dest += 2;
54.269 - }
54.270 - func += 2;
54.271 - bytecount += 2;
54.272 - }
54.273 - else if((opcode & 0xFC) == 0x80 ||
54.274 - (opcode & 0xC7) == 0x05 ||
54.275 - (opcode & 0xF8) == 0xB8 ||
54.276 - (opcode & 0xFE) == 0xE8 || // CALL/Jcc
54.277 - (opcode & 0xFE) == 0x68 ||
54.278 - (opcode & 0xFC) == 0xA0 ||
54.279 - (opcode & 0xEE) == 0xA8 ||
54.280 - opcode == 0xC7 ||
54.281 - (opcode == 0xF7 && (modRM & 0x30) == 0x00))
54.282 - {
54.283 - if (dest) {
54.284 - //Fix CALL/JMP offset
54.285 - if ((opcode & 0xFE) == 0xE8) {
54.286 - if (operandSize == 4)
54.287 - {
54.288 - *(long*)dest = ((func + *(long*)func) - dest);
54.289 -
54.290 - //pRED* edit. func is the current address of the call address, +4 is the next instruction, so the value of $pc
54.291 - check_thunks(dest+4, func+4);
54.292 - }
54.293 - else
54.294 - *(short*)dest = ((func + *(short*)func) - dest);
54.295 -
54.296 - } else {
54.297 - if (operandSize == 4)
54.298 - *(unsigned long*)dest = *(unsigned long*)func;
54.299 - else
54.300 - *(unsigned short*)dest = *(unsigned short*)func;
54.301 - }
54.302 - dest += operandSize;
54.303 - }
54.304 - func += operandSize;
54.305 - bytecount += operandSize;
54.306 -
54.307 - }
54.308 - }
54.309 - else
54.310 - {
54.311 - if(opcode == 0xBA || // BT
54.312 - opcode == 0x0F || // 3DNow!
54.313 - (opcode & 0xFC) == 0x70 || // PSLLW
54.314 - (opcode & 0xF7) == 0xA4 || // SHLD
54.315 - opcode == 0xC2 ||
54.316 - opcode == 0xC4 ||
54.317 - opcode == 0xC5 ||
54.318 - opcode == 0xC6)
54.319 - {
54.320 - if (dest)
54.321 - *dest++ = *func++;
54.322 - else
54.323 - func++;
54.324 - }
54.325 - else if((opcode & 0xF0) == 0x80) // Jcc -i
54.326 - {
54.327 - if (dest) {
54.328 - if (operandSize == 4)
54.329 - *(unsigned long*)dest = *(unsigned long*)func;
54.330 - else
54.331 - *(unsigned short*)dest = *(unsigned short*)func;
54.332 -
54.333 - dest += operandSize;
54.334 - }
54.335 - func += operandSize;
54.336 - bytecount += operandSize;
54.337 - }
54.338 - }
54.339 - }
54.340 -
54.341 - return bytecount;
54.342 -}
54.343 -
54.344 -//insert a specific JMP instruction at the given location
54.345 -void inject_jmp(void* src, void* dest) {
54.346 - *(unsigned char*)src = OP_JMP;
54.347 - *(long*)((unsigned char*)src+1) = (long)((unsigned char*)dest - ((unsigned char*)src + OP_JMP_SIZE));
54.348 -}
54.349 -
54.350 -//fill a given block with NOPs
54.351 -void fill_nop(void* src, unsigned int len) {
54.352 - unsigned char* src2 = (unsigned char*)src;
54.353 - while (len) {
54.354 - *src2++ = OP_NOP;
54.355 - --len;
54.356 - }
54.357 -}
54.358 -
54.359 -void* eval_jump(void* src) {
54.360 - unsigned char* addr = (unsigned char*)src;
54.361 -
54.362 - if (!addr) return 0;
54.363 -
54.364 - //import table jump
54.365 - if (addr[0] == OP_PREFIX && addr[1] == OP_JMP_SEG) {
54.366 - addr += 2;
54.367 - addr = *(unsigned char**)addr;
54.368 - //TODO: if addr points into the IAT
54.369 - return *(void**)addr;
54.370 - }
54.371 -
54.372 - //8bit offset
54.373 - else if (addr[0] == OP_JMP_BYTE) {
54.374 - addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1];
54.375 - //mangled 32bit jump?
54.376 - if (addr[0] == OP_JMP) {
54.377 - addr = addr + *(int*)&addr[1];
54.378 - }
54.379 - return addr;
54.380 - }
54.381 - /*
54.382 - //32bit offset
54.383 - else if (addr[0] == OP_JMP) {
54.384 - addr = &addr[OP_JMP_SIZE] + *(int*)&addr[1];
54.385 - }
54.386 - */
54.387 -
54.388 - return addr;
54.389 -}
54.390 -/*
54.391 -from ms detours package
54.392 -static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress)
54.393 -{
54.394 - MEMORY_BASIC_INFORMATION mbi;
54.395 - VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi));
54.396 - __try {
54.397 - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase;
54.398 - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
54.399 - return false;
54.400 - }
54.401 -
54.402 - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader +
54.403 - pDosHeader->e_lfanew);
54.404 - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
54.405 - return false;
54.406 - }
54.407 -
54.408 - if (pbAddress >= ((PBYTE)pDosHeader +
54.409 - pNtHeader->OptionalHeader
54.410 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) &&
54.411 - pbAddress < ((PBYTE)pDosHeader +
54.412 - pNtHeader->OptionalHeader
54.413 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress +
54.414 - pNtHeader->OptionalHeader
54.415 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) {
54.416 - return true;
54.417 - }
54.418 - return false;
54.419 - }
54.420 - __except(EXCEPTION_EXECUTE_HANDLER) {
54.421 - return false;
54.422 - }
54.423 -}
54.424 -*/
55.1 --- a/extensions/sdktools/asm/asm.h Wed Apr 23 21:40:50 2014 -0400
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,40 +0,0 @@
55.4 -#ifndef __ASM_H__
55.5 -#define __ASM_H__
55.6 -
55.7 -#define OP_JMP 0xE9
55.8 -#define OP_JMP_SIZE 5
55.9 -
55.10 -#define OP_NOP 0x90
55.11 -#define OP_NOP_SIZE 1
55.12 -
55.13 -#define OP_PREFIX 0xFF
55.14 -#define OP_JMP_SEG 0x25
55.15 -
55.16 -#define OP_JMP_BYTE 0xEB
55.17 -#define OP_JMP_BYTE_SIZE 2
55.18 -
55.19 -#ifdef __cplusplus
55.20 -extern "C" {
55.21 -#endif
55.22 -
55.23 -void check_thunks(unsigned char *dest, unsigned char *pc);
55.24 -
55.25 -//if dest is NULL, returns minimum number of bytes needed to be copied
55.26 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
55.27 -//http://www.devmaster.net/forums/showthread.php?t=2311
55.28 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
55.29 -
55.30 -//insert a specific JMP instruction at the given location
55.31 -void inject_jmp(void* src, void* dest);
55.32 -
55.33 -//fill a given block with NOPs
55.34 -void fill_nop(void* src, unsigned int len);
55.35 -
55.36 -//evaluate a JMP at the target
55.37 -void* eval_jump(void* src);
55.38 -
55.39 -#ifdef __cplusplus
55.40 -}
55.41 -#endif
55.42 -
55.43 -#endif //__ASM_H__
56.1 --- a/extensions/sdktools/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,73 +0,0 @@
56.4 -/**
56.5 - * vim: set ts=4 :
56.6 - * =============================================================================
56.7 - * SourceMod SDKTools Extension
56.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
56.9 - * =============================================================================
56.10 - *
56.11 - * This program is free software; you can redistribute it and/or modify it under
56.12 - * the terms of the GNU General Public License, version 3.0, as published by the
56.13 - * Free Software Foundation.
56.14 - *
56.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
56.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
56.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
56.18 - * details.
56.19 - *
56.20 - * You should have received a copy of the GNU General Public License along with
56.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
56.22 - *
56.23 - * As a special exception, AlliedModders LLC gives you permission to link the
56.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
56.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
56.26 - * by the Valve Corporation. You must obey the GNU General Public License in
56.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
56.28 - * this exception to all derivative works. AlliedModders LLC defines further
56.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
56.30 - * or <http://www.sourcemod.net/license.php>.
56.31 - *
56.32 - * Version: $Id$
56.33 - */
56.34 -
56.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
56.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
56.37 -
56.38 -/**
56.39 - * @file smsdk_config.h
56.40 - * @brief Contains macros for configuring basic extension information.
56.41 - */
56.42 -
56.43 -/* Basic information exposed publicly */
56.44 -#define SMEXT_CONF_NAME "SDK Tools"
56.45 -#define SMEXT_CONF_DESCRIPTION "Source SDK Tools"
56.46 -#define SMEXT_CONF_VERSION ""
56.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
56.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
56.49 -#define SMEXT_CONF_LOGTAG "SDKTOOLS"
56.50 -#define SMEXT_CONF_LICENSE "GPL"
56.51 -#define SMEXT_CONF_DATESTRING ""
56.52 -
56.53 -/**
56.54 - * @brief Exposes plugin's main interface.
56.55 - */
56.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
56.57 -
56.58 -/**
56.59 - * @brief Sets whether or not this plugin required Metamod.
56.60 - * NOTE: Uncomment to enable, comment to disable.
56.61 - */
56.62 -#define SMEXT_CONF_METAMOD
56.63 -
56.64 -/** Enable interfaces you want to use here by uncommenting lines */
56.65 -#define SMEXT_ENABLE_FORWARDSYS
56.66 -#define SMEXT_ENABLE_HANDLESYS
56.67 -#define SMEXT_ENABLE_PLAYERHELPERS
56.68 -//#define SMEXT_ENABLE_DBMANAGER
56.69 -#define SMEXT_ENABLE_GAMECONF
56.70 -#define SMEXT_ENABLE_MEMUTILS
56.71 -#define SMEXT_ENABLE_GAMEHELPERS
56.72 -//#define SMEXT_ENABLE_TIMERSYS
56.73 -#define SMEXT_ENABLE_ADTFACTORY
56.74 -#define SMEXT_ENABLE_PLUGINSYS
56.75 -
56.76 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
57.1 --- a/extensions/sdktools/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,462 +0,0 @@
57.4 -/**
57.5 - * vim: set ts=4 :
57.6 - * =============================================================================
57.7 - * SourceMod Base Extension Code
57.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
57.9 - * =============================================================================
57.10 - *
57.11 - * This program is free software; you can redistribute it and/or modify it under
57.12 - * the terms of the GNU General Public License, version 3.0, as published by the
57.13 - * Free Software Foundation.
57.14 - *
57.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
57.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
57.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
57.18 - * details.
57.19 - *
57.20 - * You should have received a copy of the GNU General Public License along with
57.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
57.22 - *
57.23 - * As a special exception, AlliedModders LLC gives you permission to link the
57.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
57.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
57.26 - * by the Valve Corporation. You must obey the GNU General Public License in
57.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
57.28 - * this exception to all derivative works. AlliedModders LLC defines further
57.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
57.30 - * or <http://www.sourcemod.net/license.php>.
57.31 - *
57.32 - * Version: $Id$
57.33 - */
57.34 -
57.35 -#include <stdio.h>
57.36 -#include <stdlib.h>
57.37 -#include "smsdk_ext.h"
57.38 -
57.39 -/**
57.40 - * @file smsdk_ext.cpp
57.41 - * @brief Contains wrappers for making Extensions easier to write.
57.42 - */
57.43 -
57.44 -IExtension *myself = NULL; /**< Ourself */
57.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
57.46 -IShareSys *sharesys = NULL; /**< Share system */
57.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
57.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
57.49 -
57.50 -#if defined SMEXT_ENABLE_FORWARDSYS
57.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
57.52 -IForwardManager *forwards = NULL; /**< Forward system */
57.53 -#endif
57.54 -#if defined SMEXT_ENABLE_HANDLESYS
57.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
57.56 -IHandleSys *handlesys = NULL; /**< Handle system */
57.57 -#endif
57.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
57.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
57.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
57.61 -#if defined SMEXT_ENABLE_DBMANAGER
57.62 -IDBManager *dbi = NULL; /**< DB Manager */
57.63 -#endif //SMEXT_ENABLE_DBMANAGER
57.64 -#if defined SMEXT_ENABLE_GAMECONF
57.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
57.66 -#endif //SMEXT_ENABLE_DBMANAGER
57.67 -#if defined SMEXT_ENABLE_MEMUTILS
57.68 -IMemoryUtils *memutils = NULL;
57.69 -#endif //SMEXT_ENABLE_DBMANAGER
57.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
57.71 -IGameHelpers *gamehelpers = NULL;
57.72 -#endif
57.73 -#if defined SMEXT_ENABLE_TIMERSYS
57.74 -ITimerSystem *timersys = NULL;
57.75 -#endif
57.76 -#if defined SMEXT_ENABLE_ADTFACTORY
57.77 -IADTFactory *adtfactory = NULL;
57.78 -#endif
57.79 -#if defined SMEXT_ENABLE_THREADER
57.80 -IThreader *threader = NULL;
57.81 -#endif
57.82 -#if defined SMEXT_ENABLE_LIBSYS
57.83 -ILibrarySys *libsys = NULL;
57.84 -#endif
57.85 -#if defined SMEXT_ENABLE_PLUGINSYS
57.86 -SourceMod::IPluginManager *plsys;
57.87 -#endif
57.88 -#if defined SMEXT_ENABLE_MENUS
57.89 -IMenuManager *menus = NULL;
57.90 -#endif
57.91 -#if defined SMEXT_ENABLE_ADMINSYS
57.92 -IAdminSystem *adminsys = NULL;
57.93 -#endif
57.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
57.95 -ITextParsers *textparsers = NULL;
57.96 -#endif
57.97 -#if defined SMEXT_ENABLE_USERMSGS
57.98 -IUserMessages *usermsgs = NULL;
57.99 -#endif
57.100 -#if defined SMEXT_ENABLE_TRANSLATOR
57.101 -ITranslator *translator = NULL;
57.102 -#endif
57.103 -
57.104 -/** Exports the main interface */
57.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
57.106 -{
57.107 - return g_pExtensionIface;
57.108 -}
57.109 -
57.110 -SDKExtension::SDKExtension()
57.111 -{
57.112 -#if defined SMEXT_CONF_METAMOD
57.113 - m_SourceMMLoaded = false;
57.114 - m_WeAreUnloaded = false;
57.115 - m_WeGotPauseChange = false;
57.116 -#endif
57.117 -}
57.118 -
57.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
57.120 -{
57.121 - g_pShareSys = sharesys = sys;
57.122 - myself = me;
57.123 -
57.124 -#if defined SMEXT_CONF_METAMOD
57.125 - m_WeAreUnloaded = true;
57.126 -
57.127 - if (!m_SourceMMLoaded)
57.128 - {
57.129 - if (error)
57.130 - {
57.131 - snprintf(error, maxlength, "Metamod attach failed");
57.132 - }
57.133 - return false;
57.134 - }
57.135 -#endif
57.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
57.137 - smutils = g_pSM;
57.138 -#if defined SMEXT_ENABLE_HANDLESYS
57.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
57.140 - handlesys = g_pHandleSys;
57.141 -#endif
57.142 -#if defined SMEXT_ENABLE_FORWARDSYS
57.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
57.144 - forwards = g_pForwards;
57.145 -#endif
57.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
57.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
57.148 -#endif
57.149 -#if defined SMEXT_ENABLE_DBMANAGER
57.150 - SM_GET_IFACE(DBI, dbi);
57.151 -#endif
57.152 -#if defined SMEXT_ENABLE_GAMECONF
57.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
57.154 -#endif
57.155 -#if defined SMEXT_ENABLE_MEMUTILS
57.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
57.157 -#endif
57.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
57.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
57.160 -#endif
57.161 -#if defined SMEXT_ENABLE_TIMERSYS
57.162 - SM_GET_IFACE(TIMERSYS, timersys);
57.163 -#endif
57.164 -#if defined SMEXT_ENABLE_ADTFACTORY
57.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
57.166 -#endif
57.167 -#if defined SMEXT_ENABLE_THREADER
57.168 - SM_GET_IFACE(THREADER, threader);
57.169 -#endif
57.170 -#if defined SMEXT_ENABLE_LIBSYS
57.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
57.172 -#endif
57.173 -#if defined SMEXT_ENABLE_PLUGINSYS
57.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
57.175 -#endif
57.176 -#if defined SMEXT_ENABLE_MENUS
57.177 - SM_GET_IFACE(MENUMANAGER, menus);
57.178 -#endif
57.179 -#if defined SMEXT_ENABLE_ADMINSYS
57.180 - SM_GET_IFACE(ADMINSYS, adminsys);
57.181 -#endif
57.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
57.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
57.184 -#endif
57.185 -#if defined SMEXT_ENABLE_USERMSGS
57.186 - SM_GET_IFACE(USERMSGS, usermsgs);
57.187 -#endif
57.188 -#if defined SMEXT_ENABLE_TRANSLATOR
57.189 - SM_GET_IFACE(TRANSLATOR, translator);
57.190 -#endif
57.191 -
57.192 - if (SDK_OnLoad(error, maxlength, late))
57.193 - {
57.194 -#if defined SMEXT_CONF_METAMOD
57.195 - m_WeAreUnloaded = true;
57.196 -#endif
57.197 - return true;
57.198 - }
57.199 -
57.200 - return false;
57.201 -}
57.202 -
57.203 -bool SDKExtension::IsMetamodExtension()
57.204 -{
57.205 -#if defined SMEXT_CONF_METAMOD
57.206 - return true;
57.207 -#else
57.208 - return false;
57.209 -#endif
57.210 -}
57.211 -
57.212 -void SDKExtension::OnExtensionPauseChange(bool state)
57.213 -{
57.214 -#if defined SMEXT_CONF_METAMOD
57.215 - m_WeGotPauseChange = true;
57.216 -#endif
57.217 - SDK_OnPauseChange(state);
57.218 -}
57.219 -
57.220 -void SDKExtension::OnExtensionsAllLoaded()
57.221 -{
57.222 - SDK_OnAllLoaded();
57.223 -}
57.224 -
57.225 -void SDKExtension::OnExtensionUnload()
57.226 -{
57.227 -#if defined SMEXT_CONF_METAMOD
57.228 - m_WeAreUnloaded = true;
57.229 -#endif
57.230 - SDK_OnUnload();
57.231 -}
57.232 -
57.233 -const char *SDKExtension::GetExtensionAuthor()
57.234 -{
57.235 - return SMEXT_CONF_AUTHOR;
57.236 -}
57.237 -
57.238 -const char *SDKExtension::GetExtensionDateString()
57.239 -{
57.240 - return SMEXT_CONF_DATESTRING;
57.241 -}
57.242 -
57.243 -const char *SDKExtension::GetExtensionDescription()
57.244 -{
57.245 - return SMEXT_CONF_DESCRIPTION;
57.246 -}
57.247 -
57.248 -const char *SDKExtension::GetExtensionVerString()
57.249 -{
57.250 - return SMEXT_CONF_VERSION;
57.251 -}
57.252 -
57.253 -const char *SDKExtension::GetExtensionName()
57.254 -{
57.255 - return SMEXT_CONF_NAME;
57.256 -}
57.257 -
57.258 -const char *SDKExtension::GetExtensionTag()
57.259 -{
57.260 - return SMEXT_CONF_LOGTAG;
57.261 -}
57.262 -
57.263 -const char *SDKExtension::GetExtensionURL()
57.264 -{
57.265 - return SMEXT_CONF_URL;
57.266 -}
57.267 -
57.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
57.269 -{
57.270 - return true;
57.271 -}
57.272 -
57.273 -void SDKExtension::SDK_OnUnload()
57.274 -{
57.275 -}
57.276 -
57.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
57.278 -{
57.279 -}
57.280 -
57.281 -void SDKExtension::SDK_OnAllLoaded()
57.282 -{
57.283 -}
57.284 -
57.285 -#if defined SMEXT_CONF_METAMOD
57.286 -
57.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
57.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
57.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
57.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
57.291 -
57.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
57.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
57.294 -
57.295 -/** Exposes the extension to Metamod */
57.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
57.297 -{
57.298 -#if defined METAMOD_PLAPI_VERSION
57.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
57.300 -#else
57.301 - if (name && !strcmp(name, PLAPI_NAME))
57.302 -#endif
57.303 - {
57.304 - if (code)
57.305 - {
57.306 - *code = IFACE_OK;
57.307 - }
57.308 - return static_cast<void *>(g_pExtensionIface);
57.309 - }
57.310 -
57.311 - if (code)
57.312 - {
57.313 - *code = IFACE_FAILED;
57.314 - }
57.315 -
57.316 - return NULL;
57.317 -}
57.318 -
57.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
57.320 -{
57.321 - PLUGIN_SAVEVARS();
57.322 -
57.323 -#if !defined METAMOD_PLAPI_VERSION
57.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
57.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
57.326 -#else
57.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
57.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
57.329 -#endif
57.330 -
57.331 - m_SourceMMLoaded = true;
57.332 -
57.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
57.334 -}
57.335 -
57.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
57.337 -{
57.338 - if (!m_WeAreUnloaded)
57.339 - {
57.340 - if (error)
57.341 - {
57.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
57.343 - }
57.344 - return false;
57.345 - }
57.346 -
57.347 - return SDK_OnMetamodUnload(error, maxlen);
57.348 -}
57.349 -
57.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
57.351 -{
57.352 - if (!m_WeGotPauseChange)
57.353 - {
57.354 - if (error)
57.355 - {
57.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
57.357 - }
57.358 - return false;
57.359 - }
57.360 -
57.361 - m_WeGotPauseChange = false;
57.362 -
57.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
57.364 -}
57.365 -
57.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
57.367 -{
57.368 - if (!m_WeGotPauseChange)
57.369 - {
57.370 - if (error)
57.371 - {
57.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
57.373 - }
57.374 - return false;
57.375 - }
57.376 -
57.377 - m_WeGotPauseChange = false;
57.378 -
57.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
57.380 -}
57.381 -
57.382 -const char *SDKExtension::GetAuthor()
57.383 -{
57.384 - return GetExtensionAuthor();
57.385 -}
57.386 -
57.387 -const char *SDKExtension::GetDate()
57.388 -{
57.389 - return GetExtensionDateString();
57.390 -}
57.391 -
57.392 -const char *SDKExtension::GetDescription()
57.393 -{
57.394 - return GetExtensionDescription();
57.395 -}
57.396 -
57.397 -const char *SDKExtension::GetLicense()
57.398 -{
57.399 - return SMEXT_CONF_LICENSE;
57.400 -}
57.401 -
57.402 -const char *SDKExtension::GetLogTag()
57.403 -{
57.404 - return GetExtensionTag();
57.405 -}
57.406 -
57.407 -const char *SDKExtension::GetName()
57.408 -{
57.409 - return GetExtensionName();
57.410 -}
57.411 -
57.412 -const char *SDKExtension::GetURL()
57.413 -{
57.414 - return GetExtensionURL();
57.415 -}
57.416 -
57.417 -const char *SDKExtension::GetVersion()
57.418 -{
57.419 - return GetExtensionVerString();
57.420 -}
57.421 -
57.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
57.423 -{
57.424 - return true;
57.425 -}
57.426 -
57.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
57.428 -{
57.429 - return true;
57.430 -}
57.431 -
57.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
57.433 -{
57.434 - return true;
57.435 -}
57.436 -
57.437 -#endif
57.438 -
57.439 -/* Overload a few things to prevent libstdc++ linking */
57.440 -#if defined __linux__ || defined __APPLE__
57.441 -extern "C" void __cxa_pure_virtual(void)
57.442 -{
57.443 -}
57.444 -
57.445 -void *operator new(size_t size)
57.446 -{
57.447 - return malloc(size);
57.448 -}
57.449 -
57.450 -void *operator new[](size_t size)
57.451 -{
57.452 - return malloc(size);
57.453 -}
57.454 -
57.455 -void operator delete(void *ptr)
57.456 -{
57.457 - free(ptr);
57.458 -}
57.459 -
57.460 -void operator delete[](void * ptr)
57.461 -{
57.462 - free(ptr);
57.463 -}
57.464 -#endif
57.465 -
58.1 --- a/extensions/sdktools/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,310 +0,0 @@
58.4 -/**
58.5 - * vim: set ts=4 :
58.6 - * =============================================================================
58.7 - * SourceMod Base Extension Code
58.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
58.9 - * =============================================================================
58.10 - *
58.11 - * This program is free software; you can redistribute it and/or modify it under
58.12 - * the terms of the GNU General Public License, version 3.0, as published by the
58.13 - * Free Software Foundation.
58.14 - *
58.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
58.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
58.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
58.18 - * details.
58.19 - *
58.20 - * You should have received a copy of the GNU General Public License along with
58.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
58.22 - *
58.23 - * As a special exception, AlliedModders LLC gives you permission to link the
58.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
58.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
58.26 - * by the Valve Corporation. You must obey the GNU General Public License in
58.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
58.28 - * this exception to all derivative works. AlliedModders LLC defines further
58.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
58.30 - * or <http://www.sourcemod.net/license.php>.
58.31 - *
58.32 - * Version: $Id$
58.33 - */
58.34 -
58.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
58.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
58.37 -
58.38 -/**
58.39 - * @file smsdk_ext.h
58.40 - * @brief Contains wrappers for making Extensions easier to write.
58.41 - */
58.42 -
58.43 -#include "smsdk_config.h"
58.44 -#include <IExtensionSys.h>
58.45 -#include <IHandleSys.h>
58.46 -#include <sp_vm_api.h>
58.47 -#include <sm_platform.h>
58.48 -#include <ISourceMod.h>
58.49 -#if defined SMEXT_ENABLE_FORWARDSYS
58.50 -#include <IForwardSys.h>
58.51 -#endif //SMEXT_ENABLE_FORWARDSYS
58.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
58.53 -#include <IPlayerHelpers.h>
58.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
58.55 -#if defined SMEXT_ENABLE_DBMANAGER
58.56 -#include <IDBDriver.h>
58.57 -#endif //SMEXT_ENABLE_DBMANAGER
58.58 -#if defined SMEXT_ENABLE_GAMECONF
58.59 -#include <IGameConfigs.h>
58.60 -#endif
58.61 -#if defined SMEXT_ENABLE_MEMUTILS
58.62 -#include <IMemoryUtils.h>
58.63 -#endif
58.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
58.65 -#include <IGameHelpers.h>
58.66 -#endif
58.67 -#if defined SMEXT_ENABLE_TIMERSYS
58.68 -#include <ITimerSystem.h>
58.69 -#endif
58.70 -#if defined SMEXT_ENABLE_ADTFACTORY
58.71 -#include <IADTFactory.h>
58.72 -#endif
58.73 -#if defined SMEXT_ENABLE_THREADER
58.74 -#include <IThreader.h>
58.75 -#endif
58.76 -#if defined SMEXT_ENABLE_LIBSYS
58.77 -#include <ILibrarySys.h>
58.78 -#endif
58.79 -#if defined SMEXT_ENABLE_PLUGINSYS
58.80 -#include <IPluginSys.h>
58.81 -#endif
58.82 -
58.83 -#if defined SMEXT_CONF_METAMOD
58.84 -#include <ISmmPlugin.h>
58.85 -#include <eiface.h>
58.86 -#endif
58.87 -
58.88 -#if !defined METAMOD_PLAPI_VERSION
58.89 -#include <metamod_wrappers.h>
58.90 -#endif
58.91 -
58.92 -using namespace SourceMod;
58.93 -using namespace SourcePawn;
58.94 -
58.95 -class SDKExtension :
58.96 -#if defined SMEXT_CONF_METAMOD
58.97 - public ISmmPlugin,
58.98 -#endif
58.99 - public IExtensionInterface
58.100 -{
58.101 -public:
58.102 - /** Constructor */
58.103 - SDKExtension();
58.104 -public:
58.105 - /**
58.106 - * @brief This is called after the initial loading sequence has been processed.
58.107 - *
58.108 - * @param error Error message buffer.
58.109 - * @param maxlength Size of error message buffer.
58.110 - * @param late Whether or not the module was loaded after map load.
58.111 - * @return True to succeed loading, false to fail.
58.112 - */
58.113 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
58.114 -
58.115 - /**
58.116 - * @brief This is called right before the extension is unloaded.
58.117 - */
58.118 - virtual void SDK_OnUnload();
58.119 -
58.120 - /**
58.121 - * @brief This is called once all known extensions have been loaded.
58.122 - */
58.123 - virtual void SDK_OnAllLoaded();
58.124 -
58.125 - /**
58.126 - * @brief Called when the pause state is changed.
58.127 - */
58.128 - virtual void SDK_OnPauseChange(bool paused);
58.129 -
58.130 -#if defined SMEXT_CONF_METAMOD
58.131 - /**
58.132 - * @brief Called when Metamod is attached, before the extension version is called.
58.133 - *
58.134 - * @param error Error buffer.
58.135 - * @param maxlength Maximum size of error buffer.
58.136 - * @param late Whether or not Metamod considers this a late load.
58.137 - * @return True to succeed, false to fail.
58.138 - */
58.139 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
58.140 -
58.141 - /**
58.142 - * @brief Called when Metamod is detaching, after the extension version is called.
58.143 - * NOTE: By default this is blocked unless sent from SourceMod.
58.144 - *
58.145 - * @param error Error buffer.
58.146 - * @param maxlength Maximum size of error buffer.
58.147 - * @return True to succeed, false to fail.
58.148 - */
58.149 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
58.150 -
58.151 - /**
58.152 - * @brief Called when Metamod's pause state is changing.
58.153 - * NOTE: By default this is blocked unless sent from SourceMod.
58.154 - *
58.155 - * @param paused Pause state being set.
58.156 - * @param error Error buffer.
58.157 - * @param maxlength Maximum size of error buffer.
58.158 - * @return True to succeed, false to fail.
58.159 - */
58.160 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
58.161 -#endif
58.162 -
58.163 -public: //IExtensionInterface
58.164 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
58.165 - virtual void OnExtensionUnload();
58.166 - virtual void OnExtensionsAllLoaded();
58.167 -
58.168 - /** Returns whether or not this is a Metamod-based extension */
58.169 - virtual bool IsMetamodExtension();
58.170 -
58.171 - /**
58.172 - * @brief Called when the pause state changes.
58.173 - *
58.174 - * @param state True if being paused, false if being unpaused.
58.175 - */
58.176 - virtual void OnExtensionPauseChange(bool state);
58.177 -
58.178 - /** Returns name */
58.179 - virtual const char *GetExtensionName();
58.180 - /** Returns URL */
58.181 - virtual const char *GetExtensionURL();
58.182 - /** Returns log tag */
58.183 - virtual const char *GetExtensionTag();
58.184 - /** Returns author */
58.185 - virtual const char *GetExtensionAuthor();
58.186 - /** Returns version string */
58.187 - virtual const char *GetExtensionVerString();
58.188 - /** Returns description string */
58.189 - virtual const char *GetExtensionDescription();
58.190 - /** Returns date string */
58.191 - virtual const char *GetExtensionDateString();
58.192 -#if defined SMEXT_CONF_METAMOD
58.193 -public: //ISmmPlugin
58.194 - /** Called when the extension is attached to Metamod. */
58.195 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
58.196 - /** Returns the author to MM */
58.197 - virtual const char *GetAuthor();
58.198 - /** Returns the name to MM */
58.199 - virtual const char *GetName();
58.200 - /** Returns the description to MM */
58.201 - virtual const char *GetDescription();
58.202 - /** Returns the URL to MM */
58.203 - virtual const char *GetURL();
58.204 - /** Returns the license to MM */
58.205 - virtual const char *GetLicense();
58.206 - /** Returns the version string to MM */
58.207 - virtual const char *GetVersion();
58.208 - /** Returns the date string to MM */
58.209 - virtual const char *GetDate();
58.210 - /** Returns the logtag to MM */
58.211 - virtual const char *GetLogTag();
58.212 - /** Called on unload */
58.213 - virtual bool Unload(char *error, size_t maxlength);
58.214 - /** Called on pause */
58.215 - virtual bool Pause(char *error, size_t maxlength);
58.216 - /** Called on unpause */
58.217 - virtual bool Unpause(char *error, size_t maxlength);
58.218 -private:
58.219 - bool m_SourceMMLoaded;
58.220 - bool m_WeAreUnloaded;
58.221 - bool m_WeGotPauseChange;
58.222 -#endif
58.223 -};
58.224 -
58.225 -extern SDKExtension *g_pExtensionIface;
58.226 -extern IExtension *myself;
58.227 -
58.228 -extern IShareSys *g_pShareSys;
58.229 -extern IShareSys *sharesys; /* Note: Newer name */
58.230 -extern ISourceMod *g_pSM;
58.231 -extern ISourceMod *smutils; /* Note: Newer name */
58.232 -
58.233 -/* Optional interfaces are below */
58.234 -#if defined SMEXT_ENABLE_FORWARDSYS
58.235 -extern IForwardManager *g_pForwards;
58.236 -extern IForwardManager *forwards; /* Note: Newer name */
58.237 -#endif //SMEXT_ENABLE_FORWARDSYS
58.238 -#if defined SMEXT_ENABLE_HANDLESYS
58.239 -extern IHandleSys *g_pHandleSys;
58.240 -extern IHandleSys *handlesys; /* Note: Newer name */
58.241 -#endif //SMEXT_ENABLE_HANDLESYS
58.242 -#if defined SMEXT_ENABLE_PLAYERHELPERS
58.243 -extern IPlayerManager *playerhelpers;
58.244 -#endif //SMEXT_ENABLE_PLAYERHELPERS
58.245 -#if defined SMEXT_ENABLE_DBMANAGER
58.246 -extern IDBManager *dbi;
58.247 -#endif //SMEXT_ENABLE_DBMANAGER
58.248 -#if defined SMEXT_ENABLE_GAMECONF
58.249 -extern IGameConfigManager *gameconfs;
58.250 -#endif //SMEXT_ENABLE_DBMANAGER
58.251 -#if defined SMEXT_ENABLE_MEMUTILS
58.252 -extern IMemoryUtils *memutils;
58.253 -#endif
58.254 -#if defined SMEXT_ENABLE_GAMEHELPERS
58.255 -extern IGameHelpers *gamehelpers;
58.256 -#endif
58.257 -#if defined SMEXT_ENABLE_TIMERSYS
58.258 -extern ITimerSystem *timersys;
58.259 -#endif
58.260 -#if defined SMEXT_ENABLE_ADTFACTORY
58.261 -extern IADTFactory *adtfactory;
58.262 -#endif
58.263 -#if defined SMEXT_ENABLE_THREADER
58.264 -extern IThreader *threader;
58.265 -#endif
58.266 -#if defined SMEXT_ENABLE_LIBSYS
58.267 -extern ILibrarySys *libsys;
58.268 -#endif
58.269 -#if defined SMEXT_ENABLE_PLUGINSYS
58.270 -extern SourceMod::IPluginManager *plsys;
58.271 -#endif
58.272 -
58.273 -#if defined SMEXT_CONF_METAMOD
58.274 -PLUGIN_GLOBALVARS();
58.275 -extern IVEngineServer *engine;
58.276 -extern IServerGameDLL *gamedll;
58.277 -#endif
58.278 -
58.279 -/** Creates a SourceMod interface macro pair */
58.280 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
58.281 -/** Automates retrieving SourceMod interfaces */
58.282 -#define SM_GET_IFACE(prefix, addr) \
58.283 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
58.284 - { \
58.285 - if (error != NULL && maxlength) \
58.286 - { \
58.287 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
58.288 - if (len >= maxlength) \
58.289 - { \
58.290 - error[maxlength - 1] = '\0'; \
58.291 - } \
58.292 - } \
58.293 - return false; \
58.294 - }
58.295 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
58.296 -#define SM_GET_LATE_IFACE(prefix, addr) \
58.297 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
58.298 -/** Validates a SourceMod interface pointer */
58.299 -#define SM_CHECK_IFACE(prefix, addr) \
58.300 - if (!addr) \
58.301 - { \
58.302 - if (error != NULL && maxlength) \
58.303 - { \
58.304 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
58.305 - if (len >= maxlength) \
58.306 - { \
58.307 - error[maxlength - 1] = '\0'; \
58.308 - } \
58.309 - } \
58.310 - return false; \
58.311 - }
58.312 -
58.313 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/extensions/sdktools/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
59.3 @@ -0,0 +1,73 @@
59.4 +/**
59.5 + * vim: set ts=4 :
59.6 + * =============================================================================
59.7 + * SourceMod SDKTools Extension
59.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
59.9 + * =============================================================================
59.10 + *
59.11 + * This program is free software; you can redistribute it and/or modify it under
59.12 + * the terms of the GNU General Public License, version 3.0, as published by the
59.13 + * Free Software Foundation.
59.14 + *
59.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
59.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
59.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
59.18 + * details.
59.19 + *
59.20 + * You should have received a copy of the GNU General Public License along with
59.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
59.22 + *
59.23 + * As a special exception, AlliedModders LLC gives you permission to link the
59.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
59.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
59.26 + * by the Valve Corporation. You must obey the GNU General Public License in
59.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
59.28 + * this exception to all derivative works. AlliedModders LLC defines further
59.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
59.30 + * or <http://www.sourcemod.net/license.php>.
59.31 + *
59.32 + * Version: $Id$
59.33 + */
59.34 +
59.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
59.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
59.37 +
59.38 +/**
59.39 + * @file smsdk_config.h
59.40 + * @brief Contains macros for configuring basic extension information.
59.41 + */
59.42 +
59.43 +/* Basic information exposed publicly */
59.44 +#define SMEXT_CONF_NAME "SDK Tools"
59.45 +#define SMEXT_CONF_DESCRIPTION "Source SDK Tools"
59.46 +#define SMEXT_CONF_VERSION ""
59.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
59.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
59.49 +#define SMEXT_CONF_LOGTAG "SDKTOOLS"
59.50 +#define SMEXT_CONF_LICENSE "GPL"
59.51 +#define SMEXT_CONF_DATESTRING ""
59.52 +
59.53 +/**
59.54 + * @brief Exposes plugin's main interface.
59.55 + */
59.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
59.57 +
59.58 +/**
59.59 + * @brief Sets whether or not this plugin required Metamod.
59.60 + * NOTE: Uncomment to enable, comment to disable.
59.61 + */
59.62 +#define SMEXT_CONF_METAMOD
59.63 +
59.64 +/** Enable interfaces you want to use here by uncommenting lines */
59.65 +#define SMEXT_ENABLE_FORWARDSYS
59.66 +#define SMEXT_ENABLE_HANDLESYS
59.67 +#define SMEXT_ENABLE_PLAYERHELPERS
59.68 +//#define SMEXT_ENABLE_DBMANAGER
59.69 +#define SMEXT_ENABLE_GAMECONF
59.70 +#define SMEXT_ENABLE_MEMUTILS
59.71 +#define SMEXT_ENABLE_GAMEHELPERS
59.72 +//#define SMEXT_ENABLE_TIMERSYS
59.73 +#define SMEXT_ENABLE_ADTFACTORY
59.74 +#define SMEXT_ENABLE_PLUGINSYS
59.75 +
59.76 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
60.1 --- a/extensions/sqlite/AMBuilder Wed Apr 23 21:40:50 2014 -0400
60.2 +++ b/extensions/sqlite/AMBuilder Wed Apr 23 21:19:28 2014 -0500
60.3 @@ -14,8 +14,7 @@
60.4 binary.compiler.postlink += ['-ldl', '-lpthread']
60.5
60.6 binary.sources += [
60.7 - 'sdk/smsdk_ext.cpp',
60.8 - 'sdk/sm_memtable.cpp',
60.9 + '../../public/smsdk_ext.cpp',
60.10 'extension.cpp',
60.11 'driver/SqDatabase.cpp',
60.12 'driver/SqDriver.cpp',
61.1 --- a/extensions/sqlite/sdk/sm_memtable.cpp Wed Apr 23 21:40:50 2014 -0400
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,112 +0,0 @@
61.4 -/**
61.5 - * vim: set ts=4 :
61.6 - * =============================================================================
61.7 - * SourceMod
61.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
61.9 - * =============================================================================
61.10 - *
61.11 - * This program is free software; you can redistribute it and/or modify it under
61.12 - * the terms of the GNU General Public License, version 3.0, as published by the
61.13 - * Free Software Foundation.
61.14 - *
61.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
61.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
61.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
61.18 - * details.
61.19 - *
61.20 - * You should have received a copy of the GNU General Public License along with
61.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
61.22 - *
61.23 - * As a special exception, AlliedModders LLC gives you permission to link the
61.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
61.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
61.26 - * by the Valve Corporation. You must obey the GNU General Public License in
61.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
61.28 - * this exception to all derivative works. AlliedModders LLC defines further
61.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
61.30 - * or <http://www.sourcemod.net/license.php>.
61.31 - *
61.32 - * Version: $Id$
61.33 - */
61.34 -
61.35 -#include <string.h>
61.36 -#include <stdlib.h>
61.37 -#include "sm_memtable.h"
61.38 -
61.39 -BaseMemTable::BaseMemTable(unsigned int init_size)
61.40 -{
61.41 - membase = (unsigned char *)malloc(init_size);
61.42 - size = init_size;
61.43 - tail = 0;
61.44 -}
61.45 -
61.46 -BaseMemTable::~BaseMemTable()
61.47 -{
61.48 - free(membase);
61.49 - membase = NULL;
61.50 -}
61.51 -
61.52 -int BaseMemTable::CreateMem(unsigned int addsize, void **addr)
61.53 -{
61.54 - int idx = (int)tail;
61.55 -
61.56 - while (tail + addsize >= size)
61.57 - {
61.58 - size *= 2;
61.59 - membase = (unsigned char *)realloc(membase, size);
61.60 - }
61.61 -
61.62 - tail += addsize;
61.63 -
61.64 - if (addr)
61.65 - {
61.66 - *addr = (void *)&membase[idx];
61.67 - }
61.68 -
61.69 - return idx;
61.70 -}
61.71 -
61.72 -void *BaseMemTable::GetAddress(int index)
61.73 -{
61.74 - if (index < 0 || (unsigned int)index >= tail)
61.75 - {
61.76 - return NULL;
61.77 - }
61.78 -
61.79 - return &membase[index];
61.80 -}
61.81 -
61.82 -void BaseMemTable::Reset()
61.83 -{
61.84 - tail = 0;
61.85 -}
61.86 -
61.87 -BaseStringTable::BaseStringTable(unsigned int init_size) : m_table(init_size)
61.88 -{
61.89 -}
61.90 -
61.91 -BaseStringTable::~BaseStringTable()
61.92 -{
61.93 -}
61.94 -
61.95 -int BaseStringTable::AddString(const char *string)
61.96 -{
61.97 - size_t len = strlen(string) + 1;
61.98 - int idx;
61.99 - char *addr;
61.100 -
61.101 - idx = m_table.CreateMem(len, (void **)&addr);
61.102 - strcpy(addr, string);
61.103 -
61.104 - return idx;
61.105 -}
61.106 -
61.107 -/*const char *BaseStringTable::GetString(int str)
61.108 -{
61.109 - return (const char *)m_table.GetAddress(str);
61.110 -}*/
61.111 -
61.112 -void BaseStringTable::Reset()
61.113 -{
61.114 - m_table.Reset();
61.115 -}
62.1 --- a/extensions/sqlite/sdk/sm_memtable.h Wed Apr 23 21:40:50 2014 -0400
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,105 +0,0 @@
62.4 -/**
62.5 - * vim: set ts=4 :
62.6 - * =============================================================================
62.7 - * SourceMod
62.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
62.9 - * =============================================================================
62.10 - *
62.11 - * This program is free software; you can redistribute it and/or modify it under
62.12 - * the terms of the GNU General Public License, version 3.0, as published by the
62.13 - * Free Software Foundation.
62.14 - *
62.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
62.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
62.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
62.18 - * details.
62.19 - *
62.20 - * You should have received a copy of the GNU General Public License along with
62.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
62.22 - *
62.23 - * As a special exception, AlliedModders LLC gives you permission to link the
62.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
62.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
62.26 - * by the Valve Corporation. You must obey the GNU General Public License in
62.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
62.28 - * this exception to all derivative works. AlliedModders LLC defines further
62.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
62.30 - * or <http://www.sourcemod.net/license.php>.
62.31 - *
62.32 - * Version: $Id$
62.33 - */
62.34 -
62.35 -#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
62.36 -#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
62.37 -
62.38 -class BaseMemTable
62.39 -{
62.40 -public:
62.41 - BaseMemTable(unsigned int init_size);
62.42 - ~BaseMemTable();
62.43 -public:
62.44 - /**
62.45 - * Allocates 'size' bytes of memory.
62.46 - * Optionally outputs the address through 'addr'.
62.47 - * Returns an index >= 0 on success, < 0 on failure.
62.48 - */
62.49 - int CreateMem(unsigned int size, void **addr);
62.50 -
62.51 - /**
62.52 - * Given an index into the memory table, returns its address.
62.53 - * Returns NULL if invalid.
62.54 - */
62.55 - void *GetAddress(int index);
62.56 -
62.57 - /**
62.58 - * Scraps the memory table. For caching purposes, the memory
62.59 - * is not freed, however subsequent calls to CreateMem() will
62.60 - * begin at the first index again.
62.61 - */
62.62 - void Reset();
62.63 -
62.64 -
62.65 -private:
62.66 - unsigned char *membase;
62.67 - unsigned int size;
62.68 - unsigned int tail;
62.69 -};
62.70 -
62.71 -class BaseStringTable
62.72 -{
62.73 -public:
62.74 - BaseStringTable(unsigned int init_size);
62.75 - ~BaseStringTable();
62.76 -public:
62.77 - /**
62.78 - * Adds a string to the string table and returns its index.
62.79 - */
62.80 - int AddString(const char *string);
62.81 -
62.82 - /**
62.83 - * Given an index into the string table, returns the associated string.
62.84 - */
62.85 - inline const char *GetString(int str)
62.86 - {
62.87 - return (const char *)m_table.GetAddress(str);
62.88 - }
62.89 -
62.90 - /**
62.91 - * Scraps the string table. For caching purposes, the memory
62.92 - * is not freed, however subsequent calls to AddString() will
62.93 - * begin at the first index again.
62.94 - */
62.95 - void Reset();
62.96 -
62.97 - /**
62.98 - * Returns the parent BaseMemTable that this string table uses.
62.99 - */
62.100 - inline BaseMemTable *GetMemTable()
62.101 - {
62.102 - return &m_table;
62.103 - }
62.104 -private:
62.105 - BaseMemTable m_table;
62.106 -};
62.107 -
62.108 -#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
63.1 --- a/extensions/sqlite/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,73 +0,0 @@
63.4 -/**
63.5 - * vim: set ts=4 :
63.6 - * =============================================================================
63.7 - * SourceMod SQLite Extension
63.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
63.9 - * =============================================================================
63.10 - *
63.11 - * This program is free software; you can redistribute it and/or modify it under
63.12 - * the terms of the GNU General Public License, version 3.0, as published by the
63.13 - * Free Software Foundation.
63.14 - *
63.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
63.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
63.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
63.18 - * details.
63.19 - *
63.20 - * You should have received a copy of the GNU General Public License along with
63.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
63.22 - *
63.23 - * As a special exception, AlliedModders LLC gives you permission to link the
63.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
63.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
63.26 - * by the Valve Corporation. You must obey the GNU General Public License in
63.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
63.28 - * this exception to all derivative works. AlliedModders LLC defines further
63.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
63.30 - * or <http://www.sourcemod.net/license.php>.
63.31 - *
63.32 - * Version: $Id$
63.33 - */
63.34 -
63.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
63.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
63.37 -
63.38 -/**
63.39 - * @file smsdk_config.h
63.40 - * @brief Contains macros for configuring basic extension information.
63.41 - */
63.42 -
63.43 -/* Basic information exposed publicly */
63.44 -#define SMEXT_CONF_NAME "SQLite"
63.45 -#define SMEXT_CONF_DESCRIPTION "SQLite Driver"
63.46 -#define SMEXT_CONF_VERSION ""
63.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
63.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
63.49 -#define SMEXT_CONF_LOGTAG "SQLITE"
63.50 -#define SMEXT_CONF_LICENSE "GPL"
63.51 -#define SMEXT_CONF_DATESTRING ""
63.52 -
63.53 -/**
63.54 - * @brief Exposes plugin's main interface.
63.55 - */
63.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
63.57 -
63.58 -/**
63.59 - * @brief Sets whether or not this plugin required Metamod.
63.60 - * NOTE: Uncomment to enable, comment to disable.
63.61 - */
63.62 -//#define SMEXT_CONF_METAMOD
63.63 -
63.64 -/** Enable interfaces you want to use here by uncommenting lines */
63.65 -//#define SMEXT_ENABLE_FORWARDSYS
63.66 -//#define SMEXT_ENABLE_HANDLESYS
63.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
63.68 -#define SMEXT_ENABLE_DBMANAGER
63.69 -//#define SMEXT_ENABLE_GAMECONF
63.70 -//#define SMEXT_ENABLE_MEMUTILS
63.71 -//#define SMEXT_ENABLE_GAMEHELPERS
63.72 -//#define SMEXT_ENABLE_TIMERSYS
63.73 -//#define SMEXT_ENABLE_THREADER
63.74 -#define SMEXT_ENABLE_LIBSYS
63.75 -
63.76 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
64.1 --- a/extensions/sqlite/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,462 +0,0 @@
64.4 -/**
64.5 - * vim: set ts=4 :
64.6 - * =============================================================================
64.7 - * SourceMod Base Extension Code
64.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
64.9 - * =============================================================================
64.10 - *
64.11 - * This program is free software; you can redistribute it and/or modify it under
64.12 - * the terms of the GNU General Public License, version 3.0, as published by the
64.13 - * Free Software Foundation.
64.14 - *
64.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
64.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
64.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
64.18 - * details.
64.19 - *
64.20 - * You should have received a copy of the GNU General Public License along with
64.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
64.22 - *
64.23 - * As a special exception, AlliedModders LLC gives you permission to link the
64.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
64.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
64.26 - * by the Valve Corporation. You must obey the GNU General Public License in
64.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
64.28 - * this exception to all derivative works. AlliedModders LLC defines further
64.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
64.30 - * or <http://www.sourcemod.net/license.php>.
64.31 - *
64.32 - * Version: $Id$
64.33 - */
64.34 -
64.35 -#include <stdio.h>
64.36 -#include <stdlib.h>
64.37 -#include "smsdk_ext.h"
64.38 -
64.39 -/**
64.40 - * @file smsdk_ext.cpp
64.41 - * @brief Contains wrappers for making Extensions easier to write.
64.42 - */
64.43 -
64.44 -IExtension *myself = NULL; /**< Ourself */
64.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
64.46 -IShareSys *sharesys = NULL; /**< Share system */
64.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
64.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
64.49 -
64.50 -#if defined SMEXT_ENABLE_FORWARDSYS
64.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
64.52 -IForwardManager *forwards = NULL; /**< Forward system */
64.53 -#endif
64.54 -#if defined SMEXT_ENABLE_HANDLESYS
64.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
64.56 -IHandleSys *handlesys = NULL; /**< Handle system */
64.57 -#endif
64.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
64.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
64.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
64.61 -#if defined SMEXT_ENABLE_DBMANAGER
64.62 -IDBManager *dbi = NULL; /**< DB Manager */
64.63 -#endif //SMEXT_ENABLE_DBMANAGER
64.64 -#if defined SMEXT_ENABLE_GAMECONF
64.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
64.66 -#endif //SMEXT_ENABLE_DBMANAGER
64.67 -#if defined SMEXT_ENABLE_MEMUTILS
64.68 -IMemoryUtils *memutils = NULL;
64.69 -#endif //SMEXT_ENABLE_DBMANAGER
64.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
64.71 -IGameHelpers *gamehelpers = NULL;
64.72 -#endif
64.73 -#if defined SMEXT_ENABLE_TIMERSYS
64.74 -ITimerSystem *timersys = NULL;
64.75 -#endif
64.76 -#if defined SMEXT_ENABLE_ADTFACTORY
64.77 -IADTFactory *adtfactory = NULL;
64.78 -#endif
64.79 -#if defined SMEXT_ENABLE_THREADER
64.80 -IThreader *threader = NULL;
64.81 -#endif
64.82 -#if defined SMEXT_ENABLE_LIBSYS
64.83 -ILibrarySys *libsys = NULL;
64.84 -#endif
64.85 -#if defined SMEXT_ENABLE_PLUGINSYS
64.86 -SourceMod::IPluginManager *plsys;
64.87 -#endif
64.88 -#if defined SMEXT_ENABLE_MENUS
64.89 -IMenuManager *menus = NULL;
64.90 -#endif
64.91 -#if defined SMEXT_ENABLE_ADMINSYS
64.92 -IAdminSystem *adminsys = NULL;
64.93 -#endif
64.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
64.95 -ITextParsers *textparsers = NULL;
64.96 -#endif
64.97 -#if defined SMEXT_ENABLE_USERMSGS
64.98 -IUserMessages *usermsgs = NULL;
64.99 -#endif
64.100 -#if defined SMEXT_ENABLE_TRANSLATOR
64.101 -ITranslator *translator = NULL;
64.102 -#endif
64.103 -
64.104 -/** Exports the main interface */
64.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
64.106 -{
64.107 - return g_pExtensionIface;
64.108 -}
64.109 -
64.110 -SDKExtension::SDKExtension()
64.111 -{
64.112 -#if defined SMEXT_CONF_METAMOD
64.113 - m_SourceMMLoaded = false;
64.114 - m_WeAreUnloaded = false;
64.115 - m_WeGotPauseChange = false;
64.116 -#endif
64.117 -}
64.118 -
64.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
64.120 -{
64.121 - g_pShareSys = sharesys = sys;
64.122 - myself = me;
64.123 -
64.124 -#if defined SMEXT_CONF_METAMOD
64.125 - m_WeAreUnloaded = true;
64.126 -
64.127 - if (!m_SourceMMLoaded)
64.128 - {
64.129 - if (error)
64.130 - {
64.131 - snprintf(error, maxlength, "Metamod attach failed");
64.132 - }
64.133 - return false;
64.134 - }
64.135 -#endif
64.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
64.137 - smutils = g_pSM;
64.138 -#if defined SMEXT_ENABLE_HANDLESYS
64.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
64.140 - handlesys = g_pHandleSys;
64.141 -#endif
64.142 -#if defined SMEXT_ENABLE_FORWARDSYS
64.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
64.144 - forwards = g_pForwards;
64.145 -#endif
64.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
64.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
64.148 -#endif
64.149 -#if defined SMEXT_ENABLE_DBMANAGER
64.150 - SM_GET_IFACE(DBI, dbi);
64.151 -#endif
64.152 -#if defined SMEXT_ENABLE_GAMECONF
64.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
64.154 -#endif
64.155 -#if defined SMEXT_ENABLE_MEMUTILS
64.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
64.157 -#endif
64.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
64.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
64.160 -#endif
64.161 -#if defined SMEXT_ENABLE_TIMERSYS
64.162 - SM_GET_IFACE(TIMERSYS, timersys);
64.163 -#endif
64.164 -#if defined SMEXT_ENABLE_ADTFACTORY
64.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
64.166 -#endif
64.167 -#if defined SMEXT_ENABLE_THREADER
64.168 - SM_GET_IFACE(THREADER, threader);
64.169 -#endif
64.170 -#if defined SMEXT_ENABLE_LIBSYS
64.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
64.172 -#endif
64.173 -#if defined SMEXT_ENABLE_PLUGINSYS
64.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
64.175 -#endif
64.176 -#if defined SMEXT_ENABLE_MENUS
64.177 - SM_GET_IFACE(MENUMANAGER, menus);
64.178 -#endif
64.179 -#if defined SMEXT_ENABLE_ADMINSYS
64.180 - SM_GET_IFACE(ADMINSYS, adminsys);
64.181 -#endif
64.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
64.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
64.184 -#endif
64.185 -#if defined SMEXT_ENABLE_USERMSGS
64.186 - SM_GET_IFACE(USERMSGS, usermsgs);
64.187 -#endif
64.188 -#if defined SMEXT_ENABLE_TRANSLATOR
64.189 - SM_GET_IFACE(TRANSLATOR, translator);
64.190 -#endif
64.191 -
64.192 - if (SDK_OnLoad(error, maxlength, late))
64.193 - {
64.194 -#if defined SMEXT_CONF_METAMOD
64.195 - m_WeAreUnloaded = true;
64.196 -#endif
64.197 - return true;
64.198 - }
64.199 -
64.200 - return false;
64.201 -}
64.202 -
64.203 -bool SDKExtension::IsMetamodExtension()
64.204 -{
64.205 -#if defined SMEXT_CONF_METAMOD
64.206 - return true;
64.207 -#else
64.208 - return false;
64.209 -#endif
64.210 -}
64.211 -
64.212 -void SDKExtension::OnExtensionPauseChange(bool state)
64.213 -{
64.214 -#if defined SMEXT_CONF_METAMOD
64.215 - m_WeGotPauseChange = true;
64.216 -#endif
64.217 - SDK_OnPauseChange(state);
64.218 -}
64.219 -
64.220 -void SDKExtension::OnExtensionsAllLoaded()
64.221 -{
64.222 - SDK_OnAllLoaded();
64.223 -}
64.224 -
64.225 -void SDKExtension::OnExtensionUnload()
64.226 -{
64.227 -#if defined SMEXT_CONF_METAMOD
64.228 - m_WeAreUnloaded = true;
64.229 -#endif
64.230 - SDK_OnUnload();
64.231 -}
64.232 -
64.233 -const char *SDKExtension::GetExtensionAuthor()
64.234 -{
64.235 - return SMEXT_CONF_AUTHOR;
64.236 -}
64.237 -
64.238 -const char *SDKExtension::GetExtensionDateString()
64.239 -{
64.240 - return SMEXT_CONF_DATESTRING;
64.241 -}
64.242 -
64.243 -const char *SDKExtension::GetExtensionDescription()
64.244 -{
64.245 - return SMEXT_CONF_DESCRIPTION;
64.246 -}
64.247 -
64.248 -const char *SDKExtension::GetExtensionVerString()
64.249 -{
64.250 - return SMEXT_CONF_VERSION;
64.251 -}
64.252 -
64.253 -const char *SDKExtension::GetExtensionName()
64.254 -{
64.255 - return SMEXT_CONF_NAME;
64.256 -}
64.257 -
64.258 -const char *SDKExtension::GetExtensionTag()
64.259 -{
64.260 - return SMEXT_CONF_LOGTAG;
64.261 -}
64.262 -
64.263 -const char *SDKExtension::GetExtensionURL()
64.264 -{
64.265 - return SMEXT_CONF_URL;
64.266 -}
64.267 -
64.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
64.269 -{
64.270 - return true;
64.271 -}
64.272 -
64.273 -void SDKExtension::SDK_OnUnload()
64.274 -{
64.275 -}
64.276 -
64.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
64.278 -{
64.279 -}
64.280 -
64.281 -void SDKExtension::SDK_OnAllLoaded()
64.282 -{
64.283 -}
64.284 -
64.285 -#if defined SMEXT_CONF_METAMOD
64.286 -
64.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
64.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
64.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
64.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
64.291 -
64.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
64.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
64.294 -
64.295 -/** Exposes the extension to Metamod */
64.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
64.297 -{
64.298 -#if defined METAMOD_PLAPI_VERSION
64.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
64.300 -#else
64.301 - if (name && !strcmp(name, PLAPI_NAME))
64.302 -#endif
64.303 - {
64.304 - if (code)
64.305 - {
64.306 - *code = IFACE_OK;
64.307 - }
64.308 - return static_cast<void *>(g_pExtensionIface);
64.309 - }
64.310 -
64.311 - if (code)
64.312 - {
64.313 - *code = IFACE_FAILED;
64.314 - }
64.315 -
64.316 - return NULL;
64.317 -}
64.318 -
64.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
64.320 -{
64.321 - PLUGIN_SAVEVARS();
64.322 -
64.323 -#if !defined METAMOD_PLAPI_VERSION
64.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
64.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
64.326 -#else
64.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
64.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
64.329 -#endif
64.330 -
64.331 - m_SourceMMLoaded = true;
64.332 -
64.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
64.334 -}
64.335 -
64.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
64.337 -{
64.338 - if (!m_WeAreUnloaded)
64.339 - {
64.340 - if (error)
64.341 - {
64.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
64.343 - }
64.344 - return false;
64.345 - }
64.346 -
64.347 - return SDK_OnMetamodUnload(error, maxlen);
64.348 -}
64.349 -
64.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
64.351 -{
64.352 - if (!m_WeGotPauseChange)
64.353 - {
64.354 - if (error)
64.355 - {
64.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
64.357 - }
64.358 - return false;
64.359 - }
64.360 -
64.361 - m_WeGotPauseChange = false;
64.362 -
64.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
64.364 -}
64.365 -
64.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
64.367 -{
64.368 - if (!m_WeGotPauseChange)
64.369 - {
64.370 - if (error)
64.371 - {
64.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
64.373 - }
64.374 - return false;
64.375 - }
64.376 -
64.377 - m_WeGotPauseChange = false;
64.378 -
64.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
64.380 -}
64.381 -
64.382 -const char *SDKExtension::GetAuthor()
64.383 -{
64.384 - return GetExtensionAuthor();
64.385 -}
64.386 -
64.387 -const char *SDKExtension::GetDate()
64.388 -{
64.389 - return GetExtensionDateString();
64.390 -}
64.391 -
64.392 -const char *SDKExtension::GetDescription()
64.393 -{
64.394 - return GetExtensionDescription();
64.395 -}
64.396 -
64.397 -const char *SDKExtension::GetLicense()
64.398 -{
64.399 - return SMEXT_CONF_LICENSE;
64.400 -}
64.401 -
64.402 -const char *SDKExtension::GetLogTag()
64.403 -{
64.404 - return GetExtensionTag();
64.405 -}
64.406 -
64.407 -const char *SDKExtension::GetName()
64.408 -{
64.409 - return GetExtensionName();
64.410 -}
64.411 -
64.412 -const char *SDKExtension::GetURL()
64.413 -{
64.414 - return GetExtensionURL();
64.415 -}
64.416 -
64.417 -const char *SDKExtension::GetVersion()
64.418 -{
64.419 - return GetExtensionVerString();
64.420 -}
64.421 -
64.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
64.423 -{
64.424 - return true;
64.425 -}
64.426 -
64.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
64.428 -{
64.429 - return true;
64.430 -}
64.431 -
64.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
64.433 -{
64.434 - return true;
64.435 -}
64.436 -
64.437 -#endif
64.438 -
64.439 -/* Overload a few things to prevent libstdc++ linking */
64.440 -#if defined __linux__ || defined __APPLE__
64.441 -extern "C" void __cxa_pure_virtual(void)
64.442 -{
64.443 -}
64.444 -
64.445 -void *operator new(size_t size)
64.446 -{
64.447 - return malloc(size);
64.448 -}
64.449 -
64.450 -void *operator new[](size_t size)
64.451 -{
64.452 - return malloc(size);
64.453 -}
64.454 -
64.455 -void operator delete(void *ptr)
64.456 -{
64.457 - free(ptr);
64.458 -}
64.459 -
64.460 -void operator delete[](void * ptr)
64.461 -{
64.462 - free(ptr);
64.463 -}
64.464 -#endif
64.465 -
65.1 --- a/extensions/sqlite/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
65.3 @@ -1,300 +0,0 @@
65.4 -/**
65.5 - * vim: set ts=4 :
65.6 - * =============================================================================
65.7 - * SourceMod Base Extension Code
65.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
65.9 - * =============================================================================
65.10 - *
65.11 - * This program is free software; you can redistribute it and/or modify it under
65.12 - * the terms of the GNU General Public License, version 3.0, as published by the
65.13 - * Free Software Foundation.
65.14 - *
65.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
65.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
65.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
65.18 - * details.
65.19 - *
65.20 - * You should have received a copy of the GNU General Public License along with
65.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
65.22 - *
65.23 - * As a special exception, AlliedModders LLC gives you permission to link the
65.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
65.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
65.26 - * by the Valve Corporation. You must obey the GNU General Public License in
65.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
65.28 - * this exception to all derivative works. AlliedModders LLC defines further
65.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
65.30 - * or <http://www.sourcemod.net/license.php>.
65.31 - *
65.32 - * Version: $Id$
65.33 - */
65.34 -
65.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
65.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
65.37 -
65.38 -/**
65.39 - * @file smsdk_ext.h
65.40 - * @brief Contains wrappers for making Extensions easier to write.
65.41 - */
65.42 -
65.43 -#include "smsdk_config.h"
65.44 -#include <IExtensionSys.h>
65.45 -#include <IHandleSys.h>
65.46 -#include <sp_vm_api.h>
65.47 -#include <sm_platform.h>
65.48 -#include <ISourceMod.h>
65.49 -#if defined SMEXT_ENABLE_FORWARDSYS
65.50 -#include <IForwardSys.h>
65.51 -#endif //SMEXT_ENABLE_FORWARDSYS
65.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
65.53 -#include <IPlayerHelpers.h>
65.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
65.55 -#if defined SMEXT_ENABLE_DBMANAGER
65.56 -#include <IDBDriver.h>
65.57 -#endif //SMEXT_ENABLE_DBMANAGER
65.58 -#if defined SMEXT_ENABLE_GAMECONF
65.59 -#include <IGameConfigs.h>
65.60 -#endif
65.61 -#if defined SMEXT_ENABLE_MEMUTILS
65.62 -#include <IMemoryUtils.h>
65.63 -#endif
65.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
65.65 -#include <IGameHelpers.h>
65.66 -#endif
65.67 -#if defined SMEXT_ENABLE_TIMERSYS
65.68 -#include <ITimerSystem.h>
65.69 -#endif
65.70 -#if defined SMEXT_ENABLE_ADTFACTORY
65.71 -#include <IADTFactory.h>
65.72 -#endif
65.73 -#if defined SMEXT_ENABLE_THREADER
65.74 -#include <IThreader.h>
65.75 -#endif
65.76 -#if defined SMEXT_ENABLE_LIBSYS
65.77 -#include <ILibrarySys.h>
65.78 -#endif
65.79 -
65.80 -#if defined SMEXT_CONF_METAMOD
65.81 -#include <ISmmPlugin.h>
65.82 -#include <eiface.h>
65.83 -#endif
65.84 -
65.85 -using namespace SourceMod;
65.86 -using namespace SourcePawn;
65.87 -
65.88 -class SDKExtension :
65.89 -#if defined SMEXT_CONF_METAMOD
65.90 - public ISmmPlugin,
65.91 -#endif
65.92 - public IExtensionInterface
65.93 -{
65.94 -public:
65.95 - /** Constructor */
65.96 - SDKExtension();
65.97 -public:
65.98 - /**
65.99 - * @brief This is called after the initial loading sequence has been processed.
65.100 - *
65.101 - * @param error Error message buffer.
65.102 - * @param maxlength Size of error message buffer.
65.103 - * @param late Whether or not the module was loaded after map load.
65.104 - * @return True to succeed loading, false to fail.
65.105 - */
65.106 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
65.107 -
65.108 - /**
65.109 - * @brief This is called right before the extension is unloaded.
65.110 - */
65.111 - virtual void SDK_OnUnload();
65.112 -
65.113 - /**
65.114 - * @brief This is called once all known extensions have been loaded.
65.115 - */
65.116 - virtual void SDK_OnAllLoaded();
65.117 -
65.118 - /**
65.119 - * @brief Called when the pause state is changed.
65.120 - */
65.121 - virtual void SDK_OnPauseChange(bool paused);
65.122 -
65.123 -#if defined SMEXT_CONF_METAMOD
65.124 - /**
65.125 - * @brief Called when Metamod is attached, before the extension version is called.
65.126 - *
65.127 - * @param error Error buffer.
65.128 - * @param maxlength Maximum size of error buffer.
65.129 - * @param late Whether or not Metamod considers this a late load.
65.130 - * @return True to succeed, false to fail.
65.131 - */
65.132 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
65.133 -
65.134 - /**
65.135 - * @brief Called when Metamod is detaching, after the extension version is called.
65.136 - * NOTE: By default this is blocked unless sent from SourceMod.
65.137 - *
65.138 - * @param error Error buffer.
65.139 - * @param maxlength Maximum size of error buffer.
65.140 - * @return True to succeed, false to fail.
65.141 - */
65.142 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
65.143 -
65.144 - /**
65.145 - * @brief Called when Metamod's pause state is changing.
65.146 - * NOTE: By default this is blocked unless sent from SourceMod.
65.147 - *
65.148 - * @param paused Pause state being set.
65.149 - * @param error Error buffer.
65.150 - * @param maxlength Maximum size of error buffer.
65.151 - * @return True to succeed, false to fail.
65.152 - */
65.153 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
65.154 -#endif
65.155 -
65.156 -public: //IExtensionInterface
65.157 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
65.158 - virtual void OnExtensionUnload();
65.159 - virtual void OnExtensionsAllLoaded();
65.160 -
65.161 - /** Returns whether or not this is a Metamod-based extension */
65.162 - virtual bool IsMetamodExtension();
65.163 -
65.164 - /**
65.165 - * @brief Called when the pause state changes.
65.166 - *
65.167 - * @param state True if being paused, false if being unpaused.
65.168 - */
65.169 - virtual void OnExtensionPauseChange(bool state);
65.170 -
65.171 - /** Returns name */
65.172 - virtual const char *GetExtensionName();
65.173 - /** Returns URL */
65.174 - virtual const char *GetExtensionURL();
65.175 - /** Returns log tag */
65.176 - virtual const char *GetExtensionTag();
65.177 - /** Returns author */
65.178 - virtual const char *GetExtensionAuthor();
65.179 - /** Returns version string */
65.180 - virtual const char *GetExtensionVerString();
65.181 - /** Returns description string */
65.182 - virtual const char *GetExtensionDescription();
65.183 - /** Returns date string */
65.184 - virtual const char *GetExtensionDateString();
65.185 -#if defined SMEXT_CONF_METAMOD
65.186 -public: //ISmmPlugin
65.187 - /** Called when the extension is attached to Metamod. */
65.188 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
65.189 - /** Returns the author to MM */
65.190 - virtual const char *GetAuthor();
65.191 - /** Returns the name to MM */
65.192 - virtual const char *GetName();
65.193 - /** Returns the description to MM */
65.194 - virtual const char *GetDescription();
65.195 - /** Returns the URL to MM */
65.196 - virtual const char *GetURL();
65.197 - /** Returns the license to MM */
65.198 - virtual const char *GetLicense();
65.199 - /** Returns the version string to MM */
65.200 - virtual const char *GetVersion();
65.201 - /** Returns the date string to MM */
65.202 - virtual const char *GetDate();
65.203 - /** Returns the logtag to MM */
65.204 - virtual const char *GetLogTag();
65.205 - /** Called on unload */
65.206 - virtual bool Unload(char *error, size_t maxlength);
65.207 - /** Called on pause */
65.208 - virtual bool Pause(char *error, size_t maxlength);
65.209 - /** Called on unpause */
65.210 - virtual bool Unpause(char *error, size_t maxlength);
65.211 -private:
65.212 - bool m_SourceMMLoaded;
65.213 - bool m_WeAreUnloaded;
65.214 - bool m_WeGotPauseChange;
65.215 -#endif
65.216 -};
65.217 -
65.218 -extern SDKExtension *g_pExtensionIface;
65.219 -extern IExtension *myself;
65.220 -
65.221 -extern IShareSys *g_pShareSys;
65.222 -extern IShareSys *sharesys; /* Note: Newer name */
65.223 -extern ISourceMod *g_pSM;
65.224 -extern ISourceMod *smutils; /* Note: Newer name */
65.225 -
65.226 -/* Optional interfaces are below */
65.227 -#if defined SMEXT_ENABLE_FORWARDSYS
65.228 -extern IForwardManager *g_pForwards;
65.229 -extern IForwardManager *forwards; /* Note: Newer name */
65.230 -#endif //SMEXT_ENABLE_FORWARDSYS
65.231 -#if defined SMEXT_ENABLE_HANDLESYS
65.232 -extern IHandleSys *g_pHandleSys;
65.233 -extern IHandleSys *handlesys; /* Note: Newer name */
65.234 -#endif //SMEXT_ENABLE_HANDLESYS
65.235 -#if defined SMEXT_ENABLE_PLAYERHELPERS
65.236 -extern IPlayerManager *playerhelpers;
65.237 -#endif //SMEXT_ENABLE_PLAYERHELPERS
65.238 -#if defined SMEXT_ENABLE_DBMANAGER
65.239 -extern IDBManager *dbi;
65.240 -#endif //SMEXT_ENABLE_DBMANAGER
65.241 -#if defined SMEXT_ENABLE_GAMECONF
65.242 -extern IGameConfigManager *gameconfs;
65.243 -#endif //SMEXT_ENABLE_DBMANAGER
65.244 -#if defined SMEXT_ENABLE_MEMUTILS
65.245 -extern IMemoryUtils *memutils;
65.246 -#endif
65.247 -#if defined SMEXT_ENABLE_GAMEHELPERS
65.248 -extern IGameHelpers *gamehelpers;
65.249 -#endif
65.250 -#if defined SMEXT_ENABLE_TIMERSYS
65.251 -extern ITimerSystem *timersys;
65.252 -#endif
65.253 -#if defined SMEXT_ENABLE_ADTFACTORY
65.254 -extern IADTFactory *adtfactory;
65.255 -#endif
65.256 -#if defined SMEXT_ENABLE_THREADER
65.257 -extern IThreader *threader;
65.258 -#endif
65.259 -#if defined SMEXT_ENABLE_LIBSYS
65.260 -extern ILibrarySys *libsys;
65.261 -#endif
65.262 -
65.263 -#if defined SMEXT_CONF_METAMOD
65.264 -PLUGIN_GLOBALVARS();
65.265 -extern IVEngineServer *engine;
65.266 -extern IServerGameDLL *gamedll;
65.267 -#endif
65.268 -
65.269 -/** Creates a SourceMod interface macro pair */
65.270 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
65.271 -/** Automates retrieving SourceMod interfaces */
65.272 -#define SM_GET_IFACE(prefix, addr) \
65.273 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
65.274 - { \
65.275 - if (error != NULL && maxlength) \
65.276 - { \
65.277 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
65.278 - if (len >= maxlength) \
65.279 - { \
65.280 - error[maxlength - 1] = '\0'; \
65.281 - } \
65.282 - } \
65.283 - return false; \
65.284 - }
65.285 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
65.286 -#define SM_GET_LATE_IFACE(prefix, addr) \
65.287 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
65.288 -/** Validates a SourceMod interface pointer */
65.289 -#define SM_CHECK_IFACE(prefix, addr) \
65.290 - if (!addr) \
65.291 - { \
65.292 - if (error != NULL && maxlength) \
65.293 - { \
65.294 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
65.295 - if (len >= maxlength) \
65.296 - { \
65.297 - error[maxlength - 1] = '\0'; \
65.298 - } \
65.299 - } \
65.300 - return false; \
65.301 - }
65.302 -
65.303 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/extensions/sqlite/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
66.3 @@ -0,0 +1,73 @@
66.4 +/**
66.5 + * vim: set ts=4 :
66.6 + * =============================================================================
66.7 + * SourceMod SQLite Extension
66.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
66.9 + * =============================================================================
66.10 + *
66.11 + * This program is free software; you can redistribute it and/or modify it under
66.12 + * the terms of the GNU General Public License, version 3.0, as published by the
66.13 + * Free Software Foundation.
66.14 + *
66.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
66.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
66.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
66.18 + * details.
66.19 + *
66.20 + * You should have received a copy of the GNU General Public License along with
66.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
66.22 + *
66.23 + * As a special exception, AlliedModders LLC gives you permission to link the
66.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
66.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
66.26 + * by the Valve Corporation. You must obey the GNU General Public License in
66.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
66.28 + * this exception to all derivative works. AlliedModders LLC defines further
66.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
66.30 + * or <http://www.sourcemod.net/license.php>.
66.31 + *
66.32 + * Version: $Id$
66.33 + */
66.34 +
66.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
66.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
66.37 +
66.38 +/**
66.39 + * @file smsdk_config.h
66.40 + * @brief Contains macros for configuring basic extension information.
66.41 + */
66.42 +
66.43 +/* Basic information exposed publicly */
66.44 +#define SMEXT_CONF_NAME "SQLite"
66.45 +#define SMEXT_CONF_DESCRIPTION "SQLite Driver"
66.46 +#define SMEXT_CONF_VERSION ""
66.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
66.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
66.49 +#define SMEXT_CONF_LOGTAG "SQLITE"
66.50 +#define SMEXT_CONF_LICENSE "GPL"
66.51 +#define SMEXT_CONF_DATESTRING ""
66.52 +
66.53 +/**
66.54 + * @brief Exposes plugin's main interface.
66.55 + */
66.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
66.57 +
66.58 +/**
66.59 + * @brief Sets whether or not this plugin required Metamod.
66.60 + * NOTE: Uncomment to enable, comment to disable.
66.61 + */
66.62 +//#define SMEXT_CONF_METAMOD
66.63 +
66.64 +/** Enable interfaces you want to use here by uncommenting lines */
66.65 +//#define SMEXT_ENABLE_FORWARDSYS
66.66 +//#define SMEXT_ENABLE_HANDLESYS
66.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
66.68 +#define SMEXT_ENABLE_DBMANAGER
66.69 +//#define SMEXT_ENABLE_GAMECONF
66.70 +//#define SMEXT_ENABLE_MEMUTILS
66.71 +//#define SMEXT_ENABLE_GAMEHELPERS
66.72 +//#define SMEXT_ENABLE_TIMERSYS
66.73 +//#define SMEXT_ENABLE_THREADER
66.74 +#define SMEXT_ENABLE_LIBSYS
66.75 +
66.76 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
67.1 --- a/extensions/structs/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
67.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
67.3 @@ -1,80 +0,0 @@
67.4 -/**
67.5 - * vim: set ts=4 :
67.6 - * =============================================================================
67.7 - * SourceMod Sample Extension
67.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
67.9 - * =============================================================================
67.10 - *
67.11 - * This program is free software; you can redistribute it and/or modify it under
67.12 - * the terms of the GNU General Public License, version 3.0, as published by the
67.13 - * Free Software Foundation.
67.14 - *
67.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
67.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
67.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
67.18 - * details.
67.19 - *
67.20 - * You should have received a copy of the GNU General Public License along with
67.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
67.22 - *
67.23 - * As a special exception, AlliedModders LLC gives you permission to link the
67.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
67.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
67.26 - * by the Valve Corporation. You must obey the GNU General Public License in
67.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
67.28 - * this exception to all derivative works. AlliedModders LLC defines further
67.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
67.30 - * or <http://www.sourcemod.net/license.php>.
67.31 - *
67.32 - * Version: $Id$
67.33 - */
67.34 -
67.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
67.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
67.37 -
67.38 -/**
67.39 - * @file smsdk_config.h
67.40 - * @brief Contains macros for configuring basic extension information.
67.41 - */
67.42 -
67.43 -/* Basic information exposed publicly */
67.44 -#define SMEXT_CONF_NAME "Struct Abstraction Extension"
67.45 -#define SMEXT_CONF_DESCRIPTION "Makes complex structs available in SourcePawn"
67.46 -#define SMEXT_CONF_VERSION "1.0.0.0"
67.47 -#define SMEXT_CONF_AUTHOR "AlliedModders"
67.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
67.49 -#define SMEXT_CONF_LOGTAG "STRUCTS"
67.50 -#define SMEXT_CONF_LICENSE "GPL"
67.51 -#define SMEXT_CONF_DATESTRING __DATE__
67.52 -
67.53 -/**
67.54 - * @brief Exposes plugin's main interface.
67.55 - */
67.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
67.57 -
67.58 -/**
67.59 - * @brief Sets whether or not this plugin required Metamod.
67.60 - * NOTE: Uncomment to enable, comment to disable.
67.61 - */
67.62 -#define SMEXT_CONF_METAMOD
67.63 -
67.64 -/** Enable interfaces you want to use here by uncommenting lines */
67.65 -//#define SMEXT_ENABLE_FORWARDSYS
67.66 -#define SMEXT_ENABLE_HANDLESYS
67.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
67.68 -//#define SMEXT_ENABLE_DBMANAGER
67.69 -#define SMEXT_ENABLE_GAMECONF
67.70 -//#define SMEXT_ENABLE_MEMUTILS
67.71 -//#define SMEXT_ENABLE_GAMEHELPERS
67.72 -//#define SMEXT_ENABLE_TIMERSYS
67.73 -//#define SMEXT_ENABLE_THREADER
67.74 -//#define SMEXT_ENABLE_LIBSYS
67.75 -//#define SMEXT_ENABLE_MENUS
67.76 -//#define SMEXT_ENABLE_ADTFACTORY
67.77 -//#define SMEXT_ENABLE_PLUGINSYS
67.78 -//#define SMEXT_ENABLE_ADMINSYS
67.79 -#define SMEXT_ENABLE_TEXTPARSERS
67.80 -//#define SMEXT_ENABLE_USERMSGS
67.81 -//#define SMEXT_ENABLE_TRANSLATOR
67.82 -
67.83 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
68.1 --- a/extensions/structs/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
68.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
68.3 @@ -1,461 +0,0 @@
68.4 -/**
68.5 - * vim: set ts=4 :
68.6 - * =============================================================================
68.7 - * SourceMod Base Extension Code
68.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
68.9 - * =============================================================================
68.10 - *
68.11 - * This program is free software; you can redistribute it and/or modify it under
68.12 - * the terms of the GNU General Public License, version 3.0, as published by the
68.13 - * Free Software Foundation.
68.14 - *
68.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
68.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
68.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
68.18 - * details.
68.19 - *
68.20 - * You should have received a copy of the GNU General Public License along with
68.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
68.22 - *
68.23 - * As a special exception, AlliedModders LLC gives you permission to link the
68.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
68.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
68.26 - * by the Valve Corporation. You must obey the GNU General Public License in
68.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
68.28 - * this exception to all derivative works. AlliedModders LLC defines further
68.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
68.30 - * or <http://www.sourcemod.net/license.php>.
68.31 - *
68.32 - * Version: $Id$
68.33 - */
68.34 -
68.35 -#include <stdio.h>
68.36 -#include <malloc.h>
68.37 -#include "smsdk_ext.h"
68.38 -
68.39 -/**
68.40 - * @file smsdk_ext.cpp
68.41 - * @brief Contains wrappers for making Extensions easier to write.
68.42 - */
68.43 -
68.44 -IExtension *myself = NULL; /**< Ourself */
68.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
68.46 -IShareSys *sharesys = NULL; /**< Share system */
68.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
68.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
68.49 -
68.50 -#if defined SMEXT_ENABLE_FORWARDSYS
68.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
68.52 -IForwardManager *forwards = NULL; /**< Forward system */
68.53 -#endif
68.54 -#if defined SMEXT_ENABLE_HANDLESYS
68.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
68.56 -IHandleSys *handlesys = NULL; /**< Handle system */
68.57 -#endif
68.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
68.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
68.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
68.61 -#if defined SMEXT_ENABLE_DBMANAGER
68.62 -IDBManager *dbi = NULL; /**< DB Manager */
68.63 -#endif //SMEXT_ENABLE_DBMANAGER
68.64 -#if defined SMEXT_ENABLE_GAMECONF
68.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
68.66 -#endif //SMEXT_ENABLE_DBMANAGER
68.67 -#if defined SMEXT_ENABLE_MEMUTILS
68.68 -IMemoryUtils *memutils = NULL;
68.69 -#endif //SMEXT_ENABLE_DBMANAGER
68.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
68.71 -IGameHelpers *gamehelpers = NULL;
68.72 -#endif
68.73 -#if defined SMEXT_ENABLE_TIMERSYS
68.74 -ITimerSystem *timersys = NULL;
68.75 -#endif
68.76 -#if defined SMEXT_ENABLE_ADTFACTORY
68.77 -IADTFactory *adtfactory = NULL;
68.78 -#endif
68.79 -#if defined SMEXT_ENABLE_THREADER
68.80 -IThreader *threader = NULL;
68.81 -#endif
68.82 -#if defined SMEXT_ENABLE_LIBSYS
68.83 -ILibrarySys *libsys = NULL;
68.84 -#endif
68.85 -#if defined SMEXT_ENABLE_PLUGINSYS
68.86 -SourceMod::IPluginManager *plsys;
68.87 -#endif
68.88 -#if defined SMEXT_ENABLE_MENUS
68.89 -IMenuManager *menus = NULL;
68.90 -#endif
68.91 -#if defined SMEXT_ENABLE_ADMINSYS
68.92 -IAdminSystem *adminsys = NULL;
68.93 -#endif
68.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
68.95 -ITextParsers *textparsers = NULL;
68.96 -#endif
68.97 -#if defined SMEXT_ENABLE_USERMSGS
68.98 -IUserMessages *usermsgs = NULL;
68.99 -#endif
68.100 -#if defined SMEXT_ENABLE_TRANSLATOR
68.101 -ITranslator *translator = NULL;
68.102 -#endif
68.103 -
68.104 -/** Exports the main interface */
68.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
68.106 -{
68.107 - return g_pExtensionIface;
68.108 -}
68.109 -
68.110 -SDKExtension::SDKExtension()
68.111 -{
68.112 -#if defined SMEXT_CONF_METAMOD
68.113 - m_SourceMMLoaded = false;
68.114 - m_WeAreUnloaded = false;
68.115 - m_WeGotPauseChange = false;
68.116 -#endif
68.117 -}
68.118 -
68.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
68.120 -{
68.121 - g_pShareSys = sharesys = sys;
68.122 - myself = me;
68.123 -
68.124 -#if defined SMEXT_CONF_METAMOD
68.125 - m_WeAreUnloaded = true;
68.126 -
68.127 - if (!m_SourceMMLoaded)
68.128 - {
68.129 - if (error)
68.130 - {
68.131 - snprintf(error, maxlength, "Metamod attach failed");
68.132 - }
68.133 - return false;
68.134 - }
68.135 -#endif
68.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
68.137 - smutils = g_pSM;
68.138 -#if defined SMEXT_ENABLE_HANDLESYS
68.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
68.140 - handlesys = g_pHandleSys;
68.141 -#endif
68.142 -#if defined SMEXT_ENABLE_FORWARDSYS
68.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
68.144 - forwards = g_pForwards;
68.145 -#endif
68.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
68.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
68.148 -#endif
68.149 -#if defined SMEXT_ENABLE_DBMANAGER
68.150 - SM_GET_IFACE(DBI, dbi);
68.151 -#endif
68.152 -#if defined SMEXT_ENABLE_GAMECONF
68.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
68.154 -#endif
68.155 -#if defined SMEXT_ENABLE_MEMUTILS
68.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
68.157 -#endif
68.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
68.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
68.160 -#endif
68.161 -#if defined SMEXT_ENABLE_TIMERSYS
68.162 - SM_GET_IFACE(TIMERSYS, timersys);
68.163 -#endif
68.164 -#if defined SMEXT_ENABLE_ADTFACTORY
68.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
68.166 -#endif
68.167 -#if defined SMEXT_ENABLE_THREADER
68.168 - SM_GET_IFACE(THREADER, threader);
68.169 -#endif
68.170 -#if defined SMEXT_ENABLE_LIBSYS
68.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
68.172 -#endif
68.173 -#if defined SMEXT_ENABLE_PLUGINSYS
68.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
68.175 -#endif
68.176 -#if defined SMEXT_ENABLE_MENUS
68.177 - SM_GET_IFACE(MENUMANAGER, menus);
68.178 -#endif
68.179 -#if defined SMEXT_ENABLE_ADMINSYS
68.180 - SM_GET_IFACE(ADMINSYS, adminsys);
68.181 -#endif
68.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
68.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
68.184 -#endif
68.185 -#if defined SMEXT_ENABLE_USERMSGS
68.186 - SM_GET_IFACE(USERMSGS, usermsgs);
68.187 -#endif
68.188 -#if defined SMEXT_ENABLE_TRANSLATOR
68.189 - SM_GET_IFACE(TRANSLATOR, translator);
68.190 -#endif
68.191 -
68.192 - if (SDK_OnLoad(error, maxlength, late))
68.193 - {
68.194 -#if defined SMEXT_CONF_METAMOD
68.195 - m_WeAreUnloaded = true;
68.196 -#endif
68.197 - return true;
68.198 - }
68.199 -
68.200 - return false;
68.201 -}
68.202 -
68.203 -bool SDKExtension::IsMetamodExtension()
68.204 -{
68.205 -#if defined SMEXT_CONF_METAMOD
68.206 - return true;
68.207 -#else
68.208 - return false;
68.209 -#endif
68.210 -}
68.211 -
68.212 -void SDKExtension::OnExtensionPauseChange(bool state)
68.213 -{
68.214 -#if defined SMEXT_CONF_METAMOD
68.215 - m_WeGotPauseChange = true;
68.216 -#endif
68.217 - SDK_OnPauseChange(state);
68.218 -}
68.219 -
68.220 -void SDKExtension::OnExtensionsAllLoaded()
68.221 -{
68.222 - SDK_OnAllLoaded();
68.223 -}
68.224 -
68.225 -void SDKExtension::OnExtensionUnload()
68.226 -{
68.227 -#if defined SMEXT_CONF_METAMOD
68.228 - m_WeAreUnloaded = true;
68.229 -#endif
68.230 - SDK_OnUnload();
68.231 -}
68.232 -
68.233 -const char *SDKExtension::GetExtensionAuthor()
68.234 -{
68.235 - return SMEXT_CONF_AUTHOR;
68.236 -}
68.237 -
68.238 -const char *SDKExtension::GetExtensionDateString()
68.239 -{
68.240 - return SMEXT_CONF_DATESTRING;
68.241 -}
68.242 -
68.243 -const char *SDKExtension::GetExtensionDescription()
68.244 -{
68.245 - return SMEXT_CONF_DESCRIPTION;
68.246 -}
68.247 -
68.248 -const char *SDKExtension::GetExtensionVerString()
68.249 -{
68.250 - return SMEXT_CONF_VERSION;
68.251 -}
68.252 -
68.253 -const char *SDKExtension::GetExtensionName()
68.254 -{
68.255 - return SMEXT_CONF_NAME;
68.256 -}
68.257 -
68.258 -const char *SDKExtension::GetExtensionTag()
68.259 -{
68.260 - return SMEXT_CONF_LOGTAG;
68.261 -}
68.262 -
68.263 -const char *SDKExtension::GetExtensionURL()
68.264 -{
68.265 - return SMEXT_CONF_URL;
68.266 -}
68.267 -
68.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
68.269 -{
68.270 - return true;
68.271 -}
68.272 -
68.273 -void SDKExtension::SDK_OnUnload()
68.274 -{
68.275 -}
68.276 -
68.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
68.278 -{
68.279 -}
68.280 -
68.281 -void SDKExtension::SDK_OnAllLoaded()
68.282 -{
68.283 -}
68.284 -
68.285 -#if defined SMEXT_CONF_METAMOD
68.286 -
68.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
68.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
68.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
68.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
68.291 -
68.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
68.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
68.294 -
68.295 -/** Exposes the extension to Metamod */
68.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
68.297 -{
68.298 -#if defined METAMOD_PLAPI_VERSION
68.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
68.300 -#else
68.301 - if (name && !strcmp(name, PLAPI_NAME))
68.302 -#endif
68.303 - {
68.304 - if (code)
68.305 - {
68.306 - *code = IFACE_OK;
68.307 - }
68.308 - return static_cast<void *>(g_pExtensionIface);
68.309 - }
68.310 -
68.311 - if (code)
68.312 - {
68.313 - *code = IFACE_FAILED;
68.314 - }
68.315 -
68.316 - return NULL;
68.317 -}
68.318 -
68.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
68.320 -{
68.321 - PLUGIN_SAVEVARS();
68.322 -
68.323 -#if !defined METAMOD_PLAPI_VERSION
68.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
68.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
68.326 -#else
68.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
68.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
68.329 -#endif
68.330 -
68.331 - m_SourceMMLoaded = true;
68.332 -
68.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
68.334 -}
68.335 -
68.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
68.337 -{
68.338 - if (!m_WeAreUnloaded)
68.339 - {
68.340 - if (error)
68.341 - {
68.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
68.343 - }
68.344 - return false;
68.345 - }
68.346 -
68.347 - return SDK_OnMetamodUnload(error, maxlen);
68.348 -}
68.349 -
68.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
68.351 -{
68.352 - if (!m_WeGotPauseChange)
68.353 - {
68.354 - if (error)
68.355 - {
68.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
68.357 - }
68.358 - return false;
68.359 - }
68.360 -
68.361 - m_WeGotPauseChange = false;
68.362 -
68.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
68.364 -}
68.365 -
68.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
68.367 -{
68.368 - if (!m_WeGotPauseChange)
68.369 - {
68.370 - if (error)
68.371 - {
68.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
68.373 - }
68.374 - return false;
68.375 - }
68.376 -
68.377 - m_WeGotPauseChange = false;
68.378 -
68.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
68.380 -}
68.381 -
68.382 -const char *SDKExtension::GetAuthor()
68.383 -{
68.384 - return GetExtensionAuthor();
68.385 -}
68.386 -
68.387 -const char *SDKExtension::GetDate()
68.388 -{
68.389 - return GetExtensionDateString();
68.390 -}
68.391 -
68.392 -const char *SDKExtension::GetDescription()
68.393 -{
68.394 - return GetExtensionDescription();
68.395 -}
68.396 -
68.397 -const char *SDKExtension::GetLicense()
68.398 -{
68.399 - return SMEXT_CONF_LICENSE;
68.400 -}
68.401 -
68.402 -const char *SDKExtension::GetLogTag()
68.403 -{
68.404 - return GetExtensionTag();
68.405 -}
68.406 -
68.407 -const char *SDKExtension::GetName()
68.408 -{
68.409 - return GetExtensionName();
68.410 -}
68.411 -
68.412 -const char *SDKExtension::GetURL()
68.413 -{
68.414 - return GetExtensionURL();
68.415 -}
68.416 -
68.417 -const char *SDKExtension::GetVersion()
68.418 -{
68.419 - return GetExtensionVerString();
68.420 -}
68.421 -
68.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
68.423 -{
68.424 - return true;
68.425 -}
68.426 -
68.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
68.428 -{
68.429 - return true;
68.430 -}
68.431 -
68.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
68.433 -{
68.434 - return true;
68.435 -}
68.436 -
68.437 -#endif
68.438 -
68.439 -/* Overload a few things to prevent libstdc++ linking */
68.440 -#if defined __linux__
68.441 -extern "C" void __cxa_pure_virtual(void)
68.442 -{
68.443 -}
68.444 -
68.445 -void *operator new(size_t size)
68.446 -{
68.447 - return malloc(size);
68.448 -}
68.449 -
68.450 -void *operator new[](size_t size)
68.451 -{
68.452 - return malloc(size);
68.453 -}
68.454 -
68.455 -void operator delete(void *ptr)
68.456 -{
68.457 - free(ptr);
68.458 -}
68.459 -
68.460 -void operator delete[](void * ptr)
68.461 -{
68.462 - free(ptr);
68.463 -}
68.464 -#endif
69.1 --- a/extensions/structs/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
69.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
69.3 @@ -1,333 +0,0 @@
69.4 -/**
69.5 - * vim: set ts=4 :
69.6 - * =============================================================================
69.7 - * SourceMod Base Extension Code
69.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
69.9 - * =============================================================================
69.10 - *
69.11 - * This program is free software; you can redistribute it and/or modify it under
69.12 - * the terms of the GNU General Public License, version 3.0, as published by the
69.13 - * Free Software Foundation.
69.14 - *
69.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
69.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
69.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
69.18 - * details.
69.19 - *
69.20 - * You should have received a copy of the GNU General Public License along with
69.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
69.22 - *
69.23 - * As a special exception, AlliedModders LLC gives you permission to link the
69.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
69.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
69.26 - * by the Valve Corporation. You must obey the GNU General Public License in
69.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
69.28 - * this exception to all derivative works. AlliedModders LLC defines further
69.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
69.30 - * or <http://www.sourcemod.net/license.php>.
69.31 - *
69.32 - * Version: $Id$
69.33 - */
69.34 -
69.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
69.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
69.37 -
69.38 -/**
69.39 - * @file smsdk_ext.h
69.40 - * @brief Contains wrappers for making Extensions easier to write.
69.41 - */
69.42 -
69.43 -#include "smsdk_config.h"
69.44 -#include <IExtensionSys.h>
69.45 -#include <IHandleSys.h>
69.46 -#include <sp_vm_api.h>
69.47 -#include <sm_platform.h>
69.48 -#include <ISourceMod.h>
69.49 -#if defined SMEXT_ENABLE_FORWARDSYS
69.50 -#include <IForwardSys.h>
69.51 -#endif //SMEXT_ENABLE_FORWARDSYS
69.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
69.53 -#include <IPlayerHelpers.h>
69.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
69.55 -#if defined SMEXT_ENABLE_DBMANAGER
69.56 -#include <IDBDriver.h>
69.57 -#endif //SMEXT_ENABLE_DBMANAGER
69.58 -#if defined SMEXT_ENABLE_GAMECONF
69.59 -#include <IGameConfigs.h>
69.60 -#endif
69.61 -#if defined SMEXT_ENABLE_MEMUTILS
69.62 -#include <IMemoryUtils.h>
69.63 -#endif
69.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
69.65 -#include <IGameHelpers.h>
69.66 -#endif
69.67 -#if defined SMEXT_ENABLE_TIMERSYS
69.68 -#include <ITimerSystem.h>
69.69 -#endif
69.70 -#if defined SMEXT_ENABLE_ADTFACTORY
69.71 -#include <IADTFactory.h>
69.72 -#endif
69.73 -#if defined SMEXT_ENABLE_THREADER
69.74 -#include <IThreader.h>
69.75 -#endif
69.76 -#if defined SMEXT_ENABLE_LIBSYS
69.77 -#include <ILibrarySys.h>
69.78 -#endif
69.79 -#if defined SMEXT_ENABLE_PLUGINSYS
69.80 -#include <IPluginSys.h>
69.81 -#endif
69.82 -#if defined SMEXT_ENABLE_MENUS
69.83 -#include <IMenuManager.h>
69.84 -#endif
69.85 -#if defined SMEXT_ENABLE_ADMINSYS
69.86 -#include <IAdminSystem.h>
69.87 -#endif
69.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
69.89 -#include <ITextParsers.h>
69.90 -#endif
69.91 -#if defined SMEXT_ENABLE_USERMSGS
69.92 -#include <IUserMessages.h>
69.93 -#endif
69.94 -#if defined SMEXT_ENABLE_TRANSLATOR
69.95 -#include <ITranslator.h>
69.96 -#endif
69.97 -
69.98 -#if defined SMEXT_CONF_METAMOD
69.99 -#include <ISmmPlugin.h>
69.100 -#include <eiface.h>
69.101 -#endif
69.102 -
69.103 -using namespace SourceMod;
69.104 -using namespace SourcePawn;
69.105 -
69.106 -class SDKExtension :
69.107 -#if defined SMEXT_CONF_METAMOD
69.108 - public ISmmPlugin,
69.109 -#endif
69.110 - public IExtensionInterface
69.111 -{
69.112 -public:
69.113 - /** Constructor */
69.114 - SDKExtension();
69.115 -public:
69.116 - /**
69.117 - * @brief This is called after the initial loading sequence has been processed.
69.118 - *
69.119 - * @param error Error message buffer.
69.120 - * @param maxlength Size of error message buffer.
69.121 - * @param late Whether or not the module was loaded after map load.
69.122 - * @return True to succeed loading, false to fail.
69.123 - */
69.124 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
69.125 -
69.126 - /**
69.127 - * @brief This is called right before the extension is unloaded.
69.128 - */
69.129 - virtual void SDK_OnUnload();
69.130 -
69.131 - /**
69.132 - * @brief This is called once all known extensions have been loaded.
69.133 - */
69.134 - virtual void SDK_OnAllLoaded();
69.135 -
69.136 - /**
69.137 - * @brief Called when the pause state is changed.
69.138 - */
69.139 - virtual void SDK_OnPauseChange(bool paused);
69.140 -
69.141 -#if defined SMEXT_CONF_METAMOD
69.142 - /**
69.143 - * @brief Called when Metamod is attached, before the extension version is called.
69.144 - *
69.145 - * @param error Error buffer.
69.146 - * @param maxlength Maximum size of error buffer.
69.147 - * @param late Whether or not Metamod considers this a late load.
69.148 - * @return True to succeed, false to fail.
69.149 - */
69.150 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
69.151 -
69.152 - /**
69.153 - * @brief Called when Metamod is detaching, after the extension version is called.
69.154 - * NOTE: By default this is blocked unless sent from SourceMod.
69.155 - *
69.156 - * @param error Error buffer.
69.157 - * @param maxlength Maximum size of error buffer.
69.158 - * @return True to succeed, false to fail.
69.159 - */
69.160 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
69.161 -
69.162 - /**
69.163 - * @brief Called when Metamod's pause state is changing.
69.164 - * NOTE: By default this is blocked unless sent from SourceMod.
69.165 - *
69.166 - * @param paused Pause state being set.
69.167 - * @param error Error buffer.
69.168 - * @param maxlength Maximum size of error buffer.
69.169 - * @return True to succeed, false to fail.
69.170 - */
69.171 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
69.172 -#endif
69.173 -
69.174 -public: //IExtensionInterface
69.175 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
69.176 - virtual void OnExtensionUnload();
69.177 - virtual void OnExtensionsAllLoaded();
69.178 -
69.179 - /** Returns whether or not this is a Metamod-based extension */
69.180 - virtual bool IsMetamodExtension();
69.181 -
69.182 - /**
69.183 - * @brief Called when the pause state changes.
69.184 - *
69.185 - * @param state True if being paused, false if being unpaused.
69.186 - */
69.187 - virtual void OnExtensionPauseChange(bool state);
69.188 -
69.189 - /** Returns name */
69.190 - virtual const char *GetExtensionName();
69.191 - /** Returns URL */
69.192 - virtual const char *GetExtensionURL();
69.193 - /** Returns log tag */
69.194 - virtual const char *GetExtensionTag();
69.195 - /** Returns author */
69.196 - virtual const char *GetExtensionAuthor();
69.197 - /** Returns version string */
69.198 - virtual const char *GetExtensionVerString();
69.199 - /** Returns description string */
69.200 - virtual const char *GetExtensionDescription();
69.201 - /** Returns date string */
69.202 - virtual const char *GetExtensionDateString();
69.203 -#if defined SMEXT_CONF_METAMOD
69.204 -public: //ISmmPlugin
69.205 - /** Called when the extension is attached to Metamod. */
69.206 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
69.207 - /** Returns the author to MM */
69.208 - virtual const char *GetAuthor();
69.209 - /** Returns the name to MM */
69.210 - virtual const char *GetName();
69.211 - /** Returns the description to MM */
69.212 - virtual const char *GetDescription();
69.213 - /** Returns the URL to MM */
69.214 - virtual const char *GetURL();
69.215 - /** Returns the license to MM */
69.216 - virtual const char *GetLicense();
69.217 - /** Returns the version string to MM */
69.218 - virtual const char *GetVersion();
69.219 - /** Returns the date string to MM */
69.220 - virtual const char *GetDate();
69.221 - /** Returns the logtag to MM */
69.222 - virtual const char *GetLogTag();
69.223 - /** Called on unload */
69.224 - virtual bool Unload(char *error, size_t maxlength);
69.225 - /** Called on pause */
69.226 - virtual bool Pause(char *error, size_t maxlength);
69.227 - /** Called on unpause */
69.228 - virtual bool Unpause(char *error, size_t maxlength);
69.229 -private:
69.230 - bool m_SourceMMLoaded;
69.231 - bool m_WeAreUnloaded;
69.232 - bool m_WeGotPauseChange;
69.233 -#endif
69.234 -};
69.235 -
69.236 -extern SDKExtension *g_pExtensionIface;
69.237 -extern IExtension *myself;
69.238 -
69.239 -extern IShareSys *g_pShareSys;
69.240 -extern IShareSys *sharesys; /* Note: Newer name */
69.241 -extern ISourceMod *g_pSM;
69.242 -extern ISourceMod *smutils; /* Note: Newer name */
69.243 -
69.244 -/* Optional interfaces are below */
69.245 -#if defined SMEXT_ENABLE_FORWARDSYS
69.246 -extern IForwardManager *g_pForwards;
69.247 -extern IForwardManager *forwards; /* Note: Newer name */
69.248 -#endif //SMEXT_ENABLE_FORWARDSYS
69.249 -#if defined SMEXT_ENABLE_HANDLESYS
69.250 -extern IHandleSys *g_pHandleSys;
69.251 -extern IHandleSys *handlesys; /* Note: Newer name */
69.252 -#endif //SMEXT_ENABLE_HANDLESYS
69.253 -#if defined SMEXT_ENABLE_PLAYERHELPERS
69.254 -extern IPlayerManager *playerhelpers;
69.255 -#endif //SMEXT_ENABLE_PLAYERHELPERS
69.256 -#if defined SMEXT_ENABLE_DBMANAGER
69.257 -extern IDBManager *dbi;
69.258 -#endif //SMEXT_ENABLE_DBMANAGER
69.259 -#if defined SMEXT_ENABLE_GAMECONF
69.260 -extern IGameConfigManager *gameconfs;
69.261 -#endif //SMEXT_ENABLE_DBMANAGER
69.262 -#if defined SMEXT_ENABLE_MEMUTILS
69.263 -extern IMemoryUtils *memutils;
69.264 -#endif
69.265 -#if defined SMEXT_ENABLE_GAMEHELPERS
69.266 -extern IGameHelpers *gamehelpers;
69.267 -#endif
69.268 -#if defined SMEXT_ENABLE_TIMERSYS
69.269 -extern ITimerSystem *timersys;
69.270 -#endif
69.271 -#if defined SMEXT_ENABLE_ADTFACTORY
69.272 -extern IADTFactory *adtfactory;
69.273 -#endif
69.274 -#if defined SMEXT_ENABLE_THREADER
69.275 -extern IThreader *threader;
69.276 -#endif
69.277 -#if defined SMEXT_ENABLE_LIBSYS
69.278 -extern ILibrarySys *libsys;
69.279 -#endif
69.280 -#if defined SMEXT_ENABLE_PLUGINSYS
69.281 -extern SourceMod::IPluginManager *plsys;
69.282 -#endif
69.283 -#if defined SMEXT_ENABLE_MENUS
69.284 -extern IMenuManager *menus;
69.285 -#endif
69.286 -#if defined SMEXT_ENABLE_ADMINSYS
69.287 -extern IAdminSystem *adminsys;
69.288 -#endif
69.289 -#if defined SMEXT_ENABLE_USERMSGS
69.290 -extern IUserMessages *usermsgs;
69.291 -#endif
69.292 -#if defined SMEXT_ENABLE_TRANSLATOR
69.293 -extern ITranslator *translator;
69.294 -#endif
69.295 -
69.296 -#if defined SMEXT_CONF_METAMOD
69.297 -PLUGIN_GLOBALVARS();
69.298 -extern IVEngineServer *engine;
69.299 -extern IServerGameDLL *gamedll;
69.300 -#endif
69.301 -
69.302 -/** Creates a SourceMod interface macro pair */
69.303 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
69.304 -/** Automates retrieving SourceMod interfaces */
69.305 -#define SM_GET_IFACE(prefix, addr) \
69.306 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
69.307 - { \
69.308 - if (error != NULL && maxlength) \
69.309 - { \
69.310 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
69.311 - if (len >= maxlength) \
69.312 - { \
69.313 - error[maxlength - 1] = '\0'; \
69.314 - } \
69.315 - } \
69.316 - return false; \
69.317 - }
69.318 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
69.319 -#define SM_GET_LATE_IFACE(prefix, addr) \
69.320 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
69.321 -/** Validates a SourceMod interface pointer */
69.322 -#define SM_CHECK_IFACE(prefix, addr) \
69.323 - if (!addr) \
69.324 - { \
69.325 - if (error != NULL && maxlength) \
69.326 - { \
69.327 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
69.328 - if (len >= maxlength) \
69.329 - { \
69.330 - error[maxlength - 1] = '\0'; \
69.331 - } \
69.332 - } \
69.333 - return false; \
69.334 - }
69.335 -
69.336 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/extensions/structs/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
70.3 @@ -0,0 +1,80 @@
70.4 +/**
70.5 + * vim: set ts=4 :
70.6 + * =============================================================================
70.7 + * SourceMod Sample Extension
70.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
70.9 + * =============================================================================
70.10 + *
70.11 + * This program is free software; you can redistribute it and/or modify it under
70.12 + * the terms of the GNU General Public License, version 3.0, as published by the
70.13 + * Free Software Foundation.
70.14 + *
70.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
70.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
70.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
70.18 + * details.
70.19 + *
70.20 + * You should have received a copy of the GNU General Public License along with
70.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
70.22 + *
70.23 + * As a special exception, AlliedModders LLC gives you permission to link the
70.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
70.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
70.26 + * by the Valve Corporation. You must obey the GNU General Public License in
70.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
70.28 + * this exception to all derivative works. AlliedModders LLC defines further
70.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
70.30 + * or <http://www.sourcemod.net/license.php>.
70.31 + *
70.32 + * Version: $Id$
70.33 + */
70.34 +
70.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
70.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
70.37 +
70.38 +/**
70.39 + * @file smsdk_config.h
70.40 + * @brief Contains macros for configuring basic extension information.
70.41 + */
70.42 +
70.43 +/* Basic information exposed publicly */
70.44 +#define SMEXT_CONF_NAME "Struct Abstraction Extension"
70.45 +#define SMEXT_CONF_DESCRIPTION "Makes complex structs available in SourcePawn"
70.46 +#define SMEXT_CONF_VERSION "1.0.0.0"
70.47 +#define SMEXT_CONF_AUTHOR "AlliedModders"
70.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
70.49 +#define SMEXT_CONF_LOGTAG "STRUCTS"
70.50 +#define SMEXT_CONF_LICENSE "GPL"
70.51 +#define SMEXT_CONF_DATESTRING __DATE__
70.52 +
70.53 +/**
70.54 + * @brief Exposes plugin's main interface.
70.55 + */
70.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
70.57 +
70.58 +/**
70.59 + * @brief Sets whether or not this plugin required Metamod.
70.60 + * NOTE: Uncomment to enable, comment to disable.
70.61 + */
70.62 +#define SMEXT_CONF_METAMOD
70.63 +
70.64 +/** Enable interfaces you want to use here by uncommenting lines */
70.65 +//#define SMEXT_ENABLE_FORWARDSYS
70.66 +#define SMEXT_ENABLE_HANDLESYS
70.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
70.68 +//#define SMEXT_ENABLE_DBMANAGER
70.69 +#define SMEXT_ENABLE_GAMECONF
70.70 +//#define SMEXT_ENABLE_MEMUTILS
70.71 +//#define SMEXT_ENABLE_GAMEHELPERS
70.72 +//#define SMEXT_ENABLE_TIMERSYS
70.73 +//#define SMEXT_ENABLE_THREADER
70.74 +//#define SMEXT_ENABLE_LIBSYS
70.75 +//#define SMEXT_ENABLE_MENUS
70.76 +//#define SMEXT_ENABLE_ADTFACTORY
70.77 +//#define SMEXT_ENABLE_PLUGINSYS
70.78 +//#define SMEXT_ENABLE_ADMINSYS
70.79 +#define SMEXT_ENABLE_TEXTPARSERS
70.80 +//#define SMEXT_ENABLE_USERMSGS
70.81 +//#define SMEXT_ENABLE_TRANSLATOR
70.82 +
70.83 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
71.1 --- a/extensions/tf2/AMBuilder Wed Apr 23 21:40:50 2014 -0400
71.2 +++ b/extensions/tf2/AMBuilder Wed Apr 23 21:19:28 2014 -0500
71.3 @@ -15,8 +15,8 @@
71.4 'teleporter.cpp',
71.5 'gameplayrules.cpp',
71.6 'conditions.cpp',
71.7 - 'CDetour/detours.cpp',
71.8 - 'sdk/smsdk_ext.cpp',
71.9 - 'asm/asm.c'
71.10 + '../../public/smsdk_ext.cpp',
71.11 + '../../public/CDetour/detours.cpp',
71.12 + '../../public/asm/asm.c'
71.13 ]
71.14 SM.extensions += [builder.Add(binary)]
72.1 --- a/extensions/tf2/CDetour/detourhelpers.h Wed Apr 23 21:40:50 2014 -0400
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,98 +0,0 @@
72.4 -/**
72.5 - * vim: set ts=4 :
72.6 - * =============================================================================
72.7 - * SourceMod
72.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
72.9 - * =============================================================================
72.10 - *
72.11 - * This program is free software; you can redistribute it and/or modify it under
72.12 - * the terms of the GNU General Public License, version 3.0, as published by the
72.13 - * Free Software Foundation.
72.14 - *
72.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
72.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
72.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
72.18 - * details.
72.19 - *
72.20 - * You should have received a copy of the GNU General Public License along with
72.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
72.22 - *
72.23 - * As a special exception, AlliedModders LLC gives you permission to link the
72.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
72.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
72.26 - * by the Valve Corporation. You must obey the GNU General Public License in
72.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
72.28 - * this exception to all derivative works. AlliedModders LLC defines further
72.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
72.30 - * or <http://www.sourcemod.net/license.php>.
72.31 - *
72.32 - * Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $
72.33 - */
72.34 -
72.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
72.36 -#define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
72.37 -
72.38 -#if defined PLATFORM_POSIX
72.39 -#include <sys/mman.h>
72.40 -#define PAGE_SIZE 4096
72.41 -#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
72.42 -#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
72.43 -#endif
72.44 -
72.45 -struct patch_t
72.46 -{
72.47 - patch_t()
72.48 - {
72.49 - patch[0] = 0;
72.50 - bytes = 0;
72.51 - }
72.52 - unsigned char patch[20];
72.53 - size_t bytes;
72.54 -};
72.55 -
72.56 -inline void ProtectMemory(void *addr, int length, int prot)
72.57 -{
72.58 -#if defined PLATFORM_POSIX
72.59 - void *addr2 = (void *)ALIGN(addr);
72.60 - mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
72.61 -#elif defined PLATFORM_WINDOWS
72.62 - DWORD old_prot;
72.63 - VirtualProtect(addr, length, prot, &old_prot);
72.64 -#endif
72.65 -}
72.66 -
72.67 -inline void SetMemPatchable(void *address, size_t size)
72.68 -{
72.69 - ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
72.70 -}
72.71 -
72.72 -inline void DoGatePatch(unsigned char *target, void *callback)
72.73 -{
72.74 - SetMemPatchable(target, 20);
72.75 -
72.76 - target[0] = 0xFF; /* JMP */
72.77 - target[1] = 0x25; /* MEM32 */
72.78 - *(void **)(&target[2]) = callback;
72.79 -}
72.80 -
72.81 -inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
72.82 -{
72.83 - ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
72.84 -
72.85 - unsigned char *addr = (unsigned char *)address + offset;
72.86 - if (restore)
72.87 - {
72.88 - for (size_t i=0; i<patch->bytes; i++)
72.89 - {
72.90 - restore->patch[i] = addr[i];
72.91 - }
72.92 - restore->bytes = patch->bytes;
72.93 - }
72.94 -
72.95 - for (size_t i=0; i<patch->bytes; i++)
72.96 - {
72.97 - addr[i] = patch->patch[i];
72.98 - }
72.99 -}
72.100 -
72.101 -#endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_
73.1 --- a/extensions/tf2/CDetour/detours.cpp Wed Apr 23 21:40:50 2014 -0400
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,192 +0,0 @@
73.4 -/**
73.5 -* vim: set ts=4 :
73.6 -* =============================================================================
73.7 -* SourceMod
73.8 -* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
73.9 -* =============================================================================
73.10 -*
73.11 -* This program is free software; you can redistribute it and/or modify it under
73.12 -* the terms of the GNU General Public License, version 3.0, as published by the
73.13 -* Free Software Foundation.
73.14 -*
73.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
73.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
73.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
73.18 -* details.
73.19 -*
73.20 -* You should have received a copy of the GNU General Public License along with
73.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
73.22 -*
73.23 -* As a special exception, AlliedModders LLC gives you permission to link the
73.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
73.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
73.26 -* by the Valve Corporation. You must obey the GNU General Public License in
73.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
73.28 -* this exception to all derivative works. AlliedModders LLC defines further
73.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
73.30 -* or <http://www.sourcemod.net/license.php>.
73.31 -*
73.32 -* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
73.33 -*/
73.34 -
73.35 -#include "detours.h"
73.36 -#include <asm/asm.h>
73.37 -
73.38 -ISourcePawnEngine *CDetourManager::spengine = NULL;
73.39 -IGameConfig *CDetourManager::gameconf = NULL;
73.40 -
73.41 -void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
73.42 -{
73.43 - CDetourManager::spengine = spengine;
73.44 - CDetourManager::gameconf = gameconf;
73.45 -}
73.46 -
73.47 -CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
73.48 -{
73.49 - CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
73.50 - if (detour)
73.51 - {
73.52 - if (!detour->Init(spengine, gameconf))
73.53 - {
73.54 - delete detour;
73.55 - return NULL;
73.56 - }
73.57 -
73.58 - return detour;
73.59 - }
73.60 -
73.61 - return NULL;
73.62 -}
73.63 -
73.64 -CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
73.65 -{
73.66 - enabled = false;
73.67 - detoured = false;
73.68 - detour_address = NULL;
73.69 - detour_trampoline = NULL;
73.70 - this->signame = signame;
73.71 - this->detour_callback = callbackfunction;
73.72 - spengine = NULL;
73.73 - gameconf = NULL;
73.74 - this->trampoline = trampoline;
73.75 -}
73.76 -
73.77 -bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
73.78 -{
73.79 - this->spengine = spengine;
73.80 - this->gameconf = gameconf;
73.81 -
73.82 - if (!CreateDetour())
73.83 - {
73.84 - enabled = false;
73.85 - return enabled;
73.86 - }
73.87 -
73.88 - enabled = true;
73.89 -
73.90 - return enabled;
73.91 -}
73.92 -
73.93 -void CDetour::Destroy()
73.94 -{
73.95 - DeleteDetour();
73.96 - delete this;
73.97 -}
73.98 -
73.99 -bool CDetour::IsEnabled()
73.100 -{
73.101 - return enabled;
73.102 -}
73.103 -
73.104 -bool CDetour::CreateDetour()
73.105 -{
73.106 - if (!gameconf->GetMemSig(signame, &detour_address))
73.107 - {
73.108 - g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame);
73.109 - return false;
73.110 - }
73.111 -
73.112 - if (!detour_address)
73.113 - {
73.114 - g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame);
73.115 - return false;
73.116 - }
73.117 -
73.118 - detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE+1);
73.119 -
73.120 - /* First, save restore bits */
73.121 - for (size_t i=0; i<detour_restore.bytes; i++)
73.122 - {
73.123 - detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
73.124 - }
73.125 -
73.126 - JitWriter wr;
73.127 - JitWriter *jit = ≀
73.128 - jit_uint32_t CodeSize = 0;
73.129 -
73.130 - wr.outbase = NULL;
73.131 - wr.outptr = NULL;
73.132 -
73.133 -jit_rewind:
73.134 -
73.135 - /* Patch old bytes in */
73.136 - if (wr.outbase != NULL)
73.137 - {
73.138 - copy_bytes((unsigned char *)detour_address, (unsigned char*)wr.outptr, detour_restore.bytes);
73.139 - }
73.140 - wr.outptr += detour_restore.bytes;
73.141 -
73.142 - /* Return to the original function */
73.143 - jitoffs_t call = IA32_Jump_Imm32(jit, 0);
73.144 - IA32_Write_Jump32_Abs(jit, call, (unsigned char *)detour_address + detour_restore.bytes);
73.145 -
73.146 - if (wr.outbase == NULL)
73.147 - {
73.148 - CodeSize = wr.get_outputpos();
73.149 - wr.outbase = (jitcode_t)spengine->AllocatePageMemory(CodeSize);
73.150 - spengine->SetReadWrite(wr.outbase);
73.151 - wr.outptr = wr.outbase;
73.152 - detour_trampoline = wr.outbase;
73.153 - goto jit_rewind;
73.154 - }
73.155 -
73.156 - spengine->SetReadExecute(wr.outbase);
73.157 -
73.158 - *trampoline = detour_trampoline;
73.159 -
73.160 - return true;
73.161 -}
73.162 -
73.163 -void CDetour::DeleteDetour()
73.164 -{
73.165 - if (detoured)
73.166 - {
73.167 - DisableDetour();
73.168 - }
73.169 -
73.170 - if (detour_trampoline)
73.171 - {
73.172 - /* Free the allocated trampoline memory */
73.173 - spengine->FreePageMemory(detour_trampoline);
73.174 - detour_trampoline = NULL;
73.175 - }
73.176 -}
73.177 -
73.178 -void CDetour::EnableDetour()
73.179 -{
73.180 - if (!detoured)
73.181 - {
73.182 - DoGatePatch((unsigned char *)detour_address, &detour_callback);
73.183 - detoured = true;
73.184 - }
73.185 -}
73.186 -
73.187 -void CDetour::DisableDetour()
73.188 -{
73.189 - if (detoured)
73.190 - {
73.191 - /* Remove the patch */
73.192 - ApplyPatch(detour_address, 0, &detour_restore, NULL);
73.193 - detoured = false;
73.194 - }
73.195 -}
74.1 --- a/extensions/tf2/CDetour/detours.h Wed Apr 23 21:40:50 2014 -0400
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,241 +0,0 @@
74.4 -/**
74.5 -* vim: set ts=4 :
74.6 -* =============================================================================
74.7 -* SourceMod
74.8 -* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
74.9 -* =============================================================================
74.10 -*
74.11 -* This program is free software; you can redistribute it and/or modify it under
74.12 -* the terms of the GNU General Public License, version 3.0, as published by the
74.13 -* Free Software Foundation.
74.14 -*
74.15 -* This program is distributed in the hope that it will be useful, but WITHOUT
74.16 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
74.17 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
74.18 -* details.
74.19 -*
74.20 -* You should have received a copy of the GNU General Public License along with
74.21 -* this program. If not, see <http://www.gnu.org/licenses/>.
74.22 -*
74.23 -* As a special exception, AlliedModders LLC gives you permission to link the
74.24 -* code of this program (as well as its derivative works) to "Half-Life 2," the
74.25 -* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
74.26 -* by the Valve Corporation. You must obey the GNU General Public License in
74.27 -* all respects for all other code used. Additionally, AlliedModders LLC grants
74.28 -* this exception to all derivative works. AlliedModders LLC defines further
74.29 -* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
74.30 -* or <http://www.sourcemod.net/license.php>.
74.31 -*
74.32 -* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
74.33 -*/
74.34 -
74.35 -#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
74.36 -#define _INCLUDE_SOURCEMOD_DETOURS_H_
74.37 -
74.38 -#include "extension.h"
74.39 -#include <jit/jit_helpers.h>
74.40 -#include <jit/x86/x86_macros.h>
74.41 -#include "detourhelpers.h"
74.42 -
74.43 -/**
74.44 - * CDetours class for SourceMod Extensions by pRED*
74.45 - * detourhelpers.h entirely stolen from CSS:DM and were written by BAILOPAN (I assume).
74.46 - * asm.h/c from devmaster.net (thanks cybermind) edited by pRED* to handle gcc -fPIC thunks correctly
74.47 - * Concept by Nephyrin Zey (http://www.doublezen.net/) and Windows Detour Library (http://research.microsoft.com/sn/detours/)
74.48 - * Member function pointer ideas by Don Clugston (http://www.codeproject.com/cpp/FastDelegate.asp)
74.49 - */
74.50 -
74.51 -#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
74.52 -#define DETOUR_STATIC_CALL(name) (name##_Actual)
74.53 -
74.54 -#define DETOUR_DECL_STATIC0(name, ret) \
74.55 -ret (*name##_Actual)(void) = NULL; \
74.56 -ret name(void)
74.57 -
74.58 -#define DETOUR_DECL_STATIC1(name, ret, p1type, p1name) \
74.59 -ret (*name##_Actual)(p1type) = NULL; \
74.60 -ret name(p1type p1name)
74.61 -
74.62 -#define DETOUR_DECL_STATIC4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
74.63 -ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
74.64 -ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
74.65 -
74.66 -#define DETOUR_DECL_MEMBER0(name, ret) \
74.67 -class name##Class \
74.68 -{ \
74.69 -public: \
74.70 - ret name(); \
74.71 - static ret (name##Class::* name##_Actual)(void); \
74.72 -}; \
74.73 -ret (name##Class::* name##Class::name##_Actual)(void) = NULL; \
74.74 -ret name##Class::name()
74.75 -
74.76 -#define DETOUR_DECL_MEMBER1(name, ret, p1type, p1name) \
74.77 -class name##Class \
74.78 -{ \
74.79 -public: \
74.80 - ret name(p1type p1name); \
74.81 - static ret (name##Class::* name##_Actual)(p1type); \
74.82 -}; \
74.83 -ret (name##Class::* name##Class::name##_Actual)(p1type) = NULL; \
74.84 -ret name##Class::name(p1type p1name)
74.85 -
74.86 -#define DETOUR_DECL_MEMBER2(name, ret, p1type, p1name, p2type, p2name) \
74.87 -class name##Class \
74.88 -{ \
74.89 -public: \
74.90 - ret name(p1type p1name, p2type p2name); \
74.91 - static ret (name##Class::* name##_Actual)(p1type, p2type); \
74.92 -}; \
74.93 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type) = NULL; \
74.94 -ret name##Class::name(p1type p1name, p2type p2name)
74.95 -
74.96 -#define DETOUR_DECL_MEMBER3(name, ret, p1type, p1name, p2type, p2name, p3type, p3name) \
74.97 -class name##Class \
74.98 -{ \
74.99 -public: \
74.100 - ret name(p1type p1name, p2type p2name, p3type p3name); \
74.101 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type); \
74.102 -}; \
74.103 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type) = NULL; \
74.104 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name)
74.105 -
74.106 -#define DETOUR_DECL_MEMBER4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
74.107 -class name##Class \
74.108 -{ \
74.109 -public: \
74.110 - ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name); \
74.111 - static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type); \
74.112 -}; \
74.113 -ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
74.114 -ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
74.115 -
74.116 -
74.117 -#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
74.118 -#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
74.119 -
74.120 -#define GET_STATIC_CALLBACK(name) (void *)&name
74.121 -#define GET_STATIC_TRAMPOLINE(name) (void **)&name##_Actual
74.122 -
74.123 -#define DETOUR_CREATE_MEMBER(name, gamedata) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), gamedata);
74.124 -#define DETOUR_CREATE_STATIC(name, gamedata) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), gamedata);
74.125 -
74.126 -
74.127 -class GenericClass {};
74.128 -typedef void (GenericClass::*VoidFunc)();
74.129 -
74.130 -inline void *GetCodeAddr(VoidFunc mfp)
74.131 -{
74.132 - return *(void **)&mfp;
74.133 -}
74.134 -
74.135 -/**
74.136 - * Converts a member function pointer to a void pointer.
74.137 - * This relies on the assumption that the code address lies at mfp+0
74.138 - * This is the case for both g++ and later MSVC versions on non virtual functions but may be different for other compilers
74.139 - * Based on research by Don Clugston : http://www.codeproject.com/cpp/FastDelegate.asp
74.140 - */
74.141 -#define GetCodeAddress(mfp) GetCodeAddr(reinterpret_cast<VoidFunc>(mfp))
74.142 -
74.143 -class CDetourManager;
74.144 -
74.145 -class CDetour
74.146 -{
74.147 -public:
74.148 -
74.149 - bool IsEnabled();
74.150 -
74.151 - /**
74.152 - * These would be somewhat self-explanatory I hope
74.153 - */
74.154 - void EnableDetour();
74.155 - void DisableDetour();
74.156 -
74.157 - void Destroy();
74.158 -
74.159 - friend class CDetourManager;
74.160 -
74.161 -protected:
74.162 - CDetour(void *callbackfunction, void **trampoline, const char *signame);
74.163 -
74.164 - bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
74.165 -private:
74.166 -
74.167 - /* These create/delete the allocated memory */
74.168 - bool CreateDetour();
74.169 - void DeleteDetour();
74.170 -
74.171 - bool enabled;
74.172 - bool detoured;
74.173 -
74.174 - patch_t detour_restore;
74.175 - /* Address of the detoured function */
74.176 - void *detour_address;
74.177 - /* Address of the allocated trampoline function */
74.178 - void *detour_trampoline;
74.179 - /* Address of the callback handler */
74.180 - void *detour_callback;
74.181 - /* The function pointer used to call our trampoline */
74.182 - void **trampoline;
74.183 -
74.184 - const char *signame;
74.185 - ISourcePawnEngine *spengine;
74.186 - IGameConfig *gameconf;
74.187 -};
74.188 -
74.189 -class CDetourManager
74.190 -{
74.191 -public:
74.192 -
74.193 - static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
74.194 -
74.195 - /**
74.196 - * Creates a new detour
74.197 - *
74.198 - * @param callbackfunction Void pointer to your detour callback function.
74.199 - * @param trampoline Address of the trampoline pointer
74.200 - * @param signame Section name containing a signature to fetch from the gamedata file.
74.201 - * @return A new CDetour pointer to control your detour.
74.202 - *
74.203 - * Example:
74.204 - *
74.205 - * CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
74.206 - *
74.207 - * Define a new class with the required function and a member function pointer to the same type:
74.208 - *
74.209 - * class CBaseServerDetour
74.210 - * {
74.211 - * public:
74.212 - * bool ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
74.213 - * static bool (CBaseServerDetour::* ConnectClient_Actual)(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
74.214 - * }
74.215 - *
74.216 - * void *callbackfunc = GetCodeAddress(&CBaseServerDetour::ConnectClient);
74.217 - * void **trampoline = (void **)(&CBaseServerDetour::ConnectClient_Actual);
74.218 - *
74.219 - * Creation:
74.220 - * CDetourManager::CreateDetour(callbackfunc, trampoline, "ConnectClient");
74.221 - *
74.222 - * Usage:
74.223 - *
74.224 - * CBaseServerDetour::ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int)
74.225 - * {
74.226 - * //pre hook code
74.227 - * bool result = (this->*ConnectClient_Actual)(netaddr_s, rest of params);
74.228 - * //post hook code
74.229 - * return result;
74.230 - * }
74.231 - *
74.232 - * Note we changed the netadr_s reference into a void* to avoid needing to define the type
74.233 - */
74.234 - static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
74.235 -
74.236 - friend class CBlocker;
74.237 - friend class CDetour;
74.238 -
74.239 -private:
74.240 - static ISourcePawnEngine *spengine;
74.241 - static IGameConfig *gameconf;
74.242 -};
74.243 -
74.244 -#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
75.1 --- a/extensions/tf2/asm/asm.c Wed Apr 23 21:40:50 2014 -0400
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,421 +0,0 @@
75.4 -#include "asm.h"
75.5 -
75.6 -#ifndef WIN32
75.7 -#define _GNU_SOURCE
75.8 -#include <dlfcn.h>
75.9 -#include <string.h>
75.10 -
75.11 -#define REG_EAX 0
75.12 -#define REG_ECX 1
75.13 -#define REG_EDX 2
75.14 -#define REG_EBX 3
75.15 -
75.16 -#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
75.17 -#endif
75.18 -
75.19 -extern void Msg( const char *, ... );
75.20 -
75.21 -/**
75.22 -* Checks if a call to a fpic thunk has just been written into dest.
75.23 -* If found replaces it with a direct mov that sets the required register to the value of pc.
75.24 -*
75.25 -* @param dest Destination buffer where a call opcode + addr (5 bytes) has just been written.
75.26 -* @param pc The program counter value that needs to be set (usually the next address from the source).
75.27 -* @noreturn
75.28 -*/
75.29 -void check_thunks(unsigned char *dest, unsigned char *pc)
75.30 -{
75.31 -#if defined WIN32
75.32 - return;
75.33 -#else
75.34 - /* Step write address back 4 to the start of the function address */
75.35 - unsigned char *writeaddr = dest - 4;
75.36 - unsigned char *calloffset = *(unsigned char **)writeaddr;
75.37 - unsigned char *calladdr = (unsigned char *)(dest + (unsigned int)calloffset);
75.38 -
75.39 - /* Lookup name of function being called */
75.40 - if ((*calladdr == 0x8B) && (*(calladdr+2) == 0x24) && (*(calladdr+3) == 0xC3))
75.41 - {
75.42 - //a thunk maybe?
75.43 - char movByte = IA32_MOV_REG_IMM;
75.44 -
75.45 - /* Calculate the correct mov opcode */
75.46 - switch (*(calladdr+1))
75.47 - {
75.48 - case 0x04:
75.49 - {
75.50 - movByte += REG_EAX;
75.51 - break;
75.52 - }
75.53 - case 0x1C:
75.54 - {
75.55 - movByte += REG_EBX;
75.56 - break;
75.57 - }
75.58 - case 0x0C:
75.59 - {
75.60 - movByte += REG_ECX;
75.61 - break;
75.62 - }
75.63 - case 0x14:
75.64 - {
75.65 - movByte += REG_EDX;
75.66 - break;
75.67 - }
75.68 - default:
75.69 - {
75.70 - Msg("Unknown thunk: %c\n", *(calladdr+1));
75.71 - break;
75.72 - }
75.73 - }
75.74 -
75.75 - /* Move our write address back one to where the call opcode was */
75.76 - writeaddr--;
75.77 -
75.78 -
75.79 - /* Write our mov */
75.80 - *writeaddr = movByte;
75.81 - writeaddr++;
75.82 -
75.83 - /* Write the value - The provided program counter value */
75.84 - *(void **)writeaddr = (void *)pc;
75.85 - writeaddr += 4;
75.86 - }
75.87 -
75.88 - return;
75.89 -#endif
75.90 -}
75.91 -
75.92 -//if dest is NULL, returns minimum number of bytes needed to be copied
75.93 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
75.94 -//http://www.devmaster.net/forums/showthread.php?t=2311
75.95 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
75.96 - int bytecount = 0;
75.97 -
75.98 - while(bytecount < required_len && *func != 0xCC)
75.99 - {
75.100 - // prefixes F0h, F2h, F3h, 66h, 67h, D8h-DFh, 2Eh, 36h, 3Eh, 26h, 64h and 65h
75.101 - int operandSize = 4;
75.102 - int FPU = 0;
75.103 - int twoByte = 0;
75.104 - unsigned char opcode = 0x90;
75.105 - unsigned char modRM = 0xFF;
75.106 - while(*func == 0xF0 ||
75.107 - *func == 0xF2 ||
75.108 - *func == 0xF3 ||
75.109 - (*func & 0xFC) == 0x64 ||
75.110 - (*func & 0xF8) == 0xD8 ||
75.111 - (*func & 0x7E) == 0x62)
75.112 - {
75.113 - if(*func == 0x66)
75.114 - {
75.115 - operandSize = 2;
75.116 - }
75.117 - else if((*func & 0xF8) == 0xD8)
75.118 - {
75.119 - FPU = *func;
75.120 - if (dest)
75.121 - *dest++ = *func++;
75.122 - else
75.123 - func++;
75.124 - bytecount++;
75.125 - break;
75.126 - }
75.127 -
75.128 - if (dest)
75.129 - *dest++ = *func++;
75.130 - else
75.131 - func++;
75.132 - bytecount++;
75.133 - }
75.134 -
75.135 - // two-byte opcode byte
75.136 - if(*func == 0x0F)
75.137 - {
75.138 - twoByte = 1;
75.139 - if (dest)
75.140 - *dest++ = *func++;
75.141 - else
75.142 - func++;
75.143 - bytecount++;
75.144 - }
75.145 -
75.146 - // opcode byte
75.147 - opcode = *func++;
75.148 - if (dest) *dest++ = opcode;
75.149 - bytecount++;
75.150 -
75.151 - // mod R/M byte
75.152 - modRM = 0xFF;
75.153 - if(FPU)
75.154 - {
75.155 - if((opcode & 0xC0) != 0xC0)
75.156 - {
75.157 - modRM = opcode;
75.158 - }
75.159 - }
75.160 - else if(!twoByte)
75.161 - {
75.162 - if((opcode & 0xC4) == 0x00 ||
75.163 - ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) ||
75.164 - (opcode & 0xF0) == 0x80 ||
75.165 - ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) ||
75.166 - (opcode & 0xFC) == 0xD0 ||
75.167 - (opcode & 0xF6) == 0xF6)
75.168 - {
75.169 - modRM = *func++;
75.170 - if (dest) *dest++ = modRM;
75.171 - bytecount++;
75.172 - }
75.173 - }
75.174 - else
75.175 - {
75.176 - if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) ||
75.177 - (opcode & 0xF0) == 0x30 ||
75.178 - opcode == 0x77 ||
75.179 - (opcode & 0xF0) == 0x80 ||
75.180 - ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) ||
75.181 - (opcode & 0xF8) == 0xC8)
75.182 - {
75.183 - // No mod R/M byte
75.184 - }
75.185 - else
75.186 - {
75.187 - modRM = *func++;
75.188 - if (dest) *dest++ = modRM;
75.189 - bytecount++;
75.190 - }
75.191 - }
75.192 -
75.193 - // SIB
75.194 - if((modRM & 0x07) == 0x04 &&
75.195 - (modRM & 0xC0) != 0xC0)
75.196 - {
75.197 - if (dest)
75.198 - *dest++ = *func++; //SIB
75.199 - else
75.200 - func++;
75.201 - bytecount++;
75.202 - }
75.203 -
75.204 - // mod R/M displacement
75.205 -
75.206 - // Dword displacement, no base
75.207 - if((modRM & 0xC5) == 0x05) {
75.208 - if (dest) {
75.209 - *(unsigned int*)dest = *(unsigned int*)func;
75.210 - dest += 4;
75.211 - }
75.212 - func += 4;
75.213 - bytecount += 4;
75.214 - }
75.215 -
75.216 - // Byte displacement
75.217 - if((modRM & 0xC0) == 0x40) {
75.218 - if (dest)
75.219 - *dest++ = *func++;
75.220 - else
75.221 - func++;
75.222 - bytecount++;
75.223 - }
75.224 -
75.225 - // Dword displacement
75.226 - if((modRM & 0xC0) == 0x80) {
75.227 - if (dest) {
75.228 - *(unsigned int*)dest = *(unsigned int*)func;
75.229 - dest += 4;
75.230 - }
75.231 - func += 4;
75.232 - bytecount += 4;
75.233 - }
75.234 -
75.235 - // immediate
75.236 - if(FPU)
75.237 - {
75.238 - // Can't have immediate operand
75.239 - }
75.240 - else if(!twoByte)
75.241 - {
75.242 - if((opcode & 0xC7) == 0x04 ||
75.243 - (opcode & 0xFE) == 0x6A || // PUSH/POP/IMUL
75.244 - (opcode & 0xF0) == 0x70 || // Jcc
75.245 - opcode == 0x80 ||
75.246 - opcode == 0x83 ||
75.247 - (opcode & 0xFD) == 0xA0 || // MOV
75.248 - opcode == 0xA8 || // TEST
75.249 - (opcode & 0xF8) == 0xB0 || // MOV
75.250 - (opcode & 0xFE) == 0xC0 || // RCL
75.251 - opcode == 0xC6 || // MOV
75.252 - opcode == 0xCD || // INT
75.253 - (opcode & 0xFE) == 0xD4 || // AAD/AAM
75.254 - (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ
75.255 - opcode == 0xEB ||
75.256 - (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST
75.257 - {
75.258 - if (dest)
75.259 - *dest++ = *func++;
75.260 - else
75.261 - func++;
75.262 - bytecount++;
75.263 - }
75.264 - else if((opcode & 0xF7) == 0xC2) // RET
75.265 - {
75.266 - if (dest) {
75.267 - *(unsigned short*)dest = *(unsigned short*)func;
75.268 - dest += 2;
75.269 - }
75.270 - func += 2;
75.271 - bytecount += 2;
75.272 - }
75.273 - else if((opcode & 0xFC) == 0x80 ||
75.274 - (opcode & 0xC7) == 0x05 ||
75.275 - (opcode & 0xF8) == 0xB8 ||
75.276 - (opcode & 0xFE) == 0xE8 || // CALL/Jcc
75.277 - (opcode & 0xFE) == 0x68 ||
75.278 - (opcode & 0xFC) == 0xA0 ||
75.279 - (opcode & 0xEE) == 0xA8 ||
75.280 - opcode == 0xC7 ||
75.281 - (opcode == 0xF7 && (modRM & 0x30) == 0x00))
75.282 - {
75.283 - if (dest) {
75.284 - //Fix CALL/JMP offset
75.285 - if ((opcode & 0xFE) == 0xE8) {
75.286 - if (operandSize == 4)
75.287 - {
75.288 - *(long*)dest = ((func + *(long*)func) - dest);
75.289 -
75.290 - //pRED* edit. func is the current address of the call address, +4 is the next instruction, so the value of $pc
75.291 - check_thunks(dest+4, func+4);
75.292 - }
75.293 - else
75.294 - *(short*)dest = ((func + *(short*)func) - dest);
75.295 -
75.296 - } else {
75.297 - if (operandSize == 4)
75.298 - *(unsigned long*)dest = *(unsigned long*)func;
75.299 - else
75.300 - *(unsigned short*)dest = *(unsigned short*)func;
75.301 - }
75.302 - dest += operandSize;
75.303 - }
75.304 - func += operandSize;
75.305 - bytecount += operandSize;
75.306 -
75.307 - }
75.308 - }
75.309 - else
75.310 - {
75.311 - if(opcode == 0xBA || // BT
75.312 - opcode == 0x0F || // 3DNow!
75.313 - (opcode & 0xFC) == 0x70 || // PSLLW
75.314 - (opcode & 0xF7) == 0xA4 || // SHLD
75.315 - opcode == 0xC2 ||
75.316 - opcode == 0xC4 ||
75.317 - opcode == 0xC5 ||
75.318 - opcode == 0xC6)
75.319 - {
75.320 - if (dest)
75.321 - *dest++ = *func++;
75.322 - else
75.323 - func++;
75.324 - }
75.325 - else if((opcode & 0xF0) == 0x80) // Jcc -i
75.326 - {
75.327 - if (dest) {
75.328 - if (operandSize == 4)
75.329 - *(unsigned long*)dest = *(unsigned long*)func;
75.330 - else
75.331 - *(unsigned short*)dest = *(unsigned short*)func;
75.332 -
75.333 - dest += operandSize;
75.334 - }
75.335 - func += operandSize;
75.336 - bytecount += operandSize;
75.337 - }
75.338 - }
75.339 - }
75.340 -
75.341 - return bytecount;
75.342 -}
75.343 -
75.344 -//insert a specific JMP instruction at the given location
75.345 -void inject_jmp(void* src, void* dest) {
75.346 - *(unsigned char*)src = OP_JMP;
75.347 - *(long*)((unsigned char*)src+1) = (long)((unsigned char*)dest - ((unsigned char*)src + OP_JMP_SIZE));
75.348 -}
75.349 -
75.350 -//fill a given block with NOPs
75.351 -void fill_nop(void* src, unsigned int len) {
75.352 - unsigned char* src2 = (unsigned char*)src;
75.353 - while (len) {
75.354 - *src2++ = OP_NOP;
75.355 - --len;
75.356 - }
75.357 -}
75.358 -
75.359 -void* eval_jump(void* src) {
75.360 - unsigned char* addr = (unsigned char*)src;
75.361 -
75.362 - if (!addr) return 0;
75.363 -
75.364 - //import table jump
75.365 - if (addr[0] == OP_PREFIX && addr[1] == OP_JMP_SEG) {
75.366 - addr += 2;
75.367 - addr = *(unsigned char**)addr;
75.368 - //TODO: if addr points into the IAT
75.369 - return *(void**)addr;
75.370 - }
75.371 -
75.372 - //8bit offset
75.373 - else if (addr[0] == OP_JMP_BYTE) {
75.374 - addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1];
75.375 - //mangled 32bit jump?
75.376 - if (addr[0] == OP_JMP) {
75.377 - addr = addr + *(int*)&addr[1];
75.378 - }
75.379 - return addr;
75.380 - }
75.381 - /*
75.382 - //32bit offset
75.383 - else if (addr[0] == OP_JMP) {
75.384 - addr = &addr[OP_JMP_SIZE] + *(int*)&addr[1];
75.385 - }
75.386 - */
75.387 -
75.388 - return addr;
75.389 -}
75.390 -/*
75.391 -from ms detours package
75.392 -static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress)
75.393 -{
75.394 - MEMORY_BASIC_INFORMATION mbi;
75.395 - VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi));
75.396 - __try {
75.397 - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase;
75.398 - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
75.399 - return false;
75.400 - }
75.401 -
75.402 - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader +
75.403 - pDosHeader->e_lfanew);
75.404 - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
75.405 - return false;
75.406 - }
75.407 -
75.408 - if (pbAddress >= ((PBYTE)pDosHeader +
75.409 - pNtHeader->OptionalHeader
75.410 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) &&
75.411 - pbAddress < ((PBYTE)pDosHeader +
75.412 - pNtHeader->OptionalHeader
75.413 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress +
75.414 - pNtHeader->OptionalHeader
75.415 - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) {
75.416 - return true;
75.417 - }
75.418 - return false;
75.419 - }
75.420 - __except(EXCEPTION_EXECUTE_HANDLER) {
75.421 - return false;
75.422 - }
75.423 -}
75.424 -*/
76.1 --- a/extensions/tf2/asm/asm.h Wed Apr 23 21:40:50 2014 -0400
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,40 +0,0 @@
76.4 -#ifndef __ASM_H__
76.5 -#define __ASM_H__
76.6 -
76.7 -#define OP_JMP 0xE9
76.8 -#define OP_JMP_SIZE 5
76.9 -
76.10 -#define OP_NOP 0x90
76.11 -#define OP_NOP_SIZE 1
76.12 -
76.13 -#define OP_PREFIX 0xFF
76.14 -#define OP_JMP_SEG 0x25
76.15 -
76.16 -#define OP_JMP_BYTE 0xEB
76.17 -#define OP_JMP_BYTE_SIZE 2
76.18 -
76.19 -#ifdef __cplusplus
76.20 -extern "C" {
76.21 -#endif
76.22 -
76.23 -void check_thunks(unsigned char *dest, unsigned char *pc);
76.24 -
76.25 -//if dest is NULL, returns minimum number of bytes needed to be copied
76.26 -//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
76.27 -//http://www.devmaster.net/forums/showthread.php?t=2311
76.28 -int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
76.29 -
76.30 -//insert a specific JMP instruction at the given location
76.31 -void inject_jmp(void* src, void* dest);
76.32 -
76.33 -//fill a given block with NOPs
76.34 -void fill_nop(void* src, unsigned int len);
76.35 -
76.36 -//evaluate a JMP at the target
76.37 -void* eval_jump(void* src);
76.38 -
76.39 -#ifdef __cplusplus
76.40 -}
76.41 -#endif
76.42 -
76.43 -#endif //__ASM_H__
77.1 --- a/extensions/tf2/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,75 +0,0 @@
77.4 -/**
77.5 - * vim: set ts=4 :
77.6 - * =============================================================================
77.7 - * SourceMod Team Fortress 2 Extension
77.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
77.9 - * =============================================================================
77.10 - *
77.11 - * This program is free software; you can redistribute it and/or modify it under
77.12 - * the terms of the GNU General Public License, version 3.0, as published by the
77.13 - * Free Software Foundation.
77.14 - *
77.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
77.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
77.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
77.18 - * details.
77.19 - *
77.20 - * You should have received a copy of the GNU General Public License along with
77.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
77.22 - *
77.23 - * As a special exception, AlliedModders LLC gives you permission to link the
77.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
77.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
77.26 - * by the Valve Corporation. You must obey the GNU General Public License in
77.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
77.28 - * this exception to all derivative works. AlliedModders LLC defines further
77.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
77.30 - * or <http://www.sourcemod.net/license.php>.
77.31 - *
77.32 - * Version: $Id$
77.33 - */
77.34 -
77.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
77.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
77.37 -
77.38 -/**
77.39 - * @file smsdk_config.h
77.40 - * @brief Contains macros for configuring basic extension information.
77.41 - */
77.42 -
77.43 -/* Basic information exposed publicly */
77.44 -#define SMEXT_CONF_NAME "TF2 Tools"
77.45 -#define SMEXT_CONF_DESCRIPTION "TF2 extended functionality"
77.46 -#define SMEXT_CONF_VERSION ""
77.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
77.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
77.49 -#define SMEXT_CONF_LOGTAG "TF2"
77.50 -#define SMEXT_CONF_LICENSE "GPL"
77.51 -#define SMEXT_CONF_DATESTRING ""
77.52 -
77.53 -/**
77.54 - * @brief Exposes plugin's main interface.
77.55 - */
77.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
77.57 -
77.58 -/**
77.59 - * @brief Sets whether or not this plugin required Metamod.
77.60 - * NOTE: Uncomment to enable, comment to disable.
77.61 - */
77.62 -#define SMEXT_CONF_METAMOD
77.63 -
77.64 -/** Enable interfaces you want to use here by uncommenting lines */
77.65 -#define SMEXT_ENABLE_FORWARDSYS
77.66 -//#define SMEXT_ENABLE_HANDLESYS
77.67 -#define SMEXT_ENABLE_PLAYERHELPERS
77.68 -//#define SMEXT_ENABLE_DBMANAGER
77.69 -#define SMEXT_ENABLE_GAMECONF
77.70 -//#define SMEXT_ENABLE_MEMUTILS
77.71 -#define SMEXT_ENABLE_GAMEHELPERS
77.72 -#define SMEXT_ENABLE_TIMERSYS
77.73 -//#define SMEXT_ENABLE_THREADER
77.74 -//#define SMEXT_ENABLE_LIBSYS
77.75 -//#define SMEXT_ENABLE_USERMSGS
77.76 -#define SMEXT_ENABLE_PLUGINSYS
77.77 -
77.78 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
78.1 --- a/extensions/tf2/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,462 +0,0 @@
78.4 -/**
78.5 - * vim: set ts=4 :
78.6 - * =============================================================================
78.7 - * SourceMod Base Extension Code
78.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
78.9 - * =============================================================================
78.10 - *
78.11 - * This program is free software; you can redistribute it and/or modify it under
78.12 - * the terms of the GNU General Public License, version 3.0, as published by the
78.13 - * Free Software Foundation.
78.14 - *
78.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
78.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
78.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
78.18 - * details.
78.19 - *
78.20 - * You should have received a copy of the GNU General Public License along with
78.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
78.22 - *
78.23 - * As a special exception, AlliedModders LLC gives you permission to link the
78.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
78.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
78.26 - * by the Valve Corporation. You must obey the GNU General Public License in
78.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
78.28 - * this exception to all derivative works. AlliedModders LLC defines further
78.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
78.30 - * or <http://www.sourcemod.net/license.php>.
78.31 - *
78.32 - * Version: $Id$
78.33 - */
78.34 -
78.35 -#include <stdio.h>
78.36 -#include <stdlib.h>
78.37 -#include "smsdk_ext.h"
78.38 -
78.39 -/**
78.40 - * @file smsdk_ext.cpp
78.41 - * @brief Contains wrappers for making Extensions easier to write.
78.42 - */
78.43 -
78.44 -IExtension *myself = NULL; /**< Ourself */
78.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
78.46 -IShareSys *sharesys = NULL; /**< Share system */
78.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
78.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
78.49 -
78.50 -#if defined SMEXT_ENABLE_FORWARDSYS
78.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
78.52 -IForwardManager *forwards = NULL; /**< Forward system */
78.53 -#endif
78.54 -#if defined SMEXT_ENABLE_HANDLESYS
78.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
78.56 -IHandleSys *handlesys = NULL; /**< Handle system */
78.57 -#endif
78.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
78.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
78.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
78.61 -#if defined SMEXT_ENABLE_DBMANAGER
78.62 -IDBManager *dbi = NULL; /**< DB Manager */
78.63 -#endif //SMEXT_ENABLE_DBMANAGER
78.64 -#if defined SMEXT_ENABLE_GAMECONF
78.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
78.66 -#endif //SMEXT_ENABLE_DBMANAGER
78.67 -#if defined SMEXT_ENABLE_MEMUTILS
78.68 -IMemoryUtils *memutils = NULL;
78.69 -#endif //SMEXT_ENABLE_DBMANAGER
78.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
78.71 -IGameHelpers *gamehelpers = NULL;
78.72 -#endif
78.73 -#if defined SMEXT_ENABLE_TIMERSYS
78.74 -ITimerSystem *timersys = NULL;
78.75 -#endif
78.76 -#if defined SMEXT_ENABLE_ADTFACTORY
78.77 -IADTFactory *adtfactory = NULL;
78.78 -#endif
78.79 -#if defined SMEXT_ENABLE_THREADER
78.80 -IThreader *threader = NULL;
78.81 -#endif
78.82 -#if defined SMEXT_ENABLE_LIBSYS
78.83 -ILibrarySys *libsys = NULL;
78.84 -#endif
78.85 -#if defined SMEXT_ENABLE_PLUGINSYS
78.86 -SourceMod::IPluginManager *plsys;
78.87 -#endif
78.88 -#if defined SMEXT_ENABLE_MENUS
78.89 -IMenuManager *menus = NULL;
78.90 -#endif
78.91 -#if defined SMEXT_ENABLE_ADMINSYS
78.92 -IAdminSystem *adminsys = NULL;
78.93 -#endif
78.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
78.95 -ITextParsers *textparsers = NULL;
78.96 -#endif
78.97 -#if defined SMEXT_ENABLE_USERMSGS
78.98 -IUserMessages *usermsgs = NULL;
78.99 -#endif
78.100 -#if defined SMEXT_ENABLE_TRANSLATOR
78.101 -ITranslator *translator = NULL;
78.102 -#endif
78.103 -
78.104 -/** Exports the main interface */
78.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
78.106 -{
78.107 - return g_pExtensionIface;
78.108 -}
78.109 -
78.110 -SDKExtension::SDKExtension()
78.111 -{
78.112 -#if defined SMEXT_CONF_METAMOD
78.113 - m_SourceMMLoaded = false;
78.114 - m_WeAreUnloaded = false;
78.115 - m_WeGotPauseChange = false;
78.116 -#endif
78.117 -}
78.118 -
78.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
78.120 -{
78.121 - g_pShareSys = sharesys = sys;
78.122 - myself = me;
78.123 -
78.124 -#if defined SMEXT_CONF_METAMOD
78.125 - m_WeAreUnloaded = true;
78.126 -
78.127 - if (!m_SourceMMLoaded)
78.128 - {
78.129 - if (error)
78.130 - {
78.131 - snprintf(error, maxlength, "Metamod attach failed");
78.132 - }
78.133 - return false;
78.134 - }
78.135 -#endif
78.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
78.137 - smutils = g_pSM;
78.138 -#if defined SMEXT_ENABLE_HANDLESYS
78.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
78.140 - handlesys = g_pHandleSys;
78.141 -#endif
78.142 -#if defined SMEXT_ENABLE_FORWARDSYS
78.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
78.144 - forwards = g_pForwards;
78.145 -#endif
78.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
78.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
78.148 -#endif
78.149 -#if defined SMEXT_ENABLE_DBMANAGER
78.150 - SM_GET_IFACE(DBI, dbi);
78.151 -#endif
78.152 -#if defined SMEXT_ENABLE_GAMECONF
78.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
78.154 -#endif
78.155 -#if defined SMEXT_ENABLE_MEMUTILS
78.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
78.157 -#endif
78.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
78.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
78.160 -#endif
78.161 -#if defined SMEXT_ENABLE_TIMERSYS
78.162 - SM_GET_IFACE(TIMERSYS, timersys);
78.163 -#endif
78.164 -#if defined SMEXT_ENABLE_ADTFACTORY
78.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
78.166 -#endif
78.167 -#if defined SMEXT_ENABLE_THREADER
78.168 - SM_GET_IFACE(THREADER, threader);
78.169 -#endif
78.170 -#if defined SMEXT_ENABLE_LIBSYS
78.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
78.172 -#endif
78.173 -#if defined SMEXT_ENABLE_PLUGINSYS
78.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
78.175 -#endif
78.176 -#if defined SMEXT_ENABLE_MENUS
78.177 - SM_GET_IFACE(MENUMANAGER, menus);
78.178 -#endif
78.179 -#if defined SMEXT_ENABLE_ADMINSYS
78.180 - SM_GET_IFACE(ADMINSYS, adminsys);
78.181 -#endif
78.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
78.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
78.184 -#endif
78.185 -#if defined SMEXT_ENABLE_USERMSGS
78.186 - SM_GET_IFACE(USERMSGS, usermsgs);
78.187 -#endif
78.188 -#if defined SMEXT_ENABLE_TRANSLATOR
78.189 - SM_GET_IFACE(TRANSLATOR, translator);
78.190 -#endif
78.191 -
78.192 - if (SDK_OnLoad(error, maxlength, late))
78.193 - {
78.194 -#if defined SMEXT_CONF_METAMOD
78.195 - m_WeAreUnloaded = true;
78.196 -#endif
78.197 - return true;
78.198 - }
78.199 -
78.200 - return false;
78.201 -}
78.202 -
78.203 -bool SDKExtension::IsMetamodExtension()
78.204 -{
78.205 -#if defined SMEXT_CONF_METAMOD
78.206 - return true;
78.207 -#else
78.208 - return false;
78.209 -#endif
78.210 -}
78.211 -
78.212 -void SDKExtension::OnExtensionPauseChange(bool state)
78.213 -{
78.214 -#if defined SMEXT_CONF_METAMOD
78.215 - m_WeGotPauseChange = true;
78.216 -#endif
78.217 - SDK_OnPauseChange(state);
78.218 -}
78.219 -
78.220 -void SDKExtension::OnExtensionsAllLoaded()
78.221 -{
78.222 - SDK_OnAllLoaded();
78.223 -}
78.224 -
78.225 -void SDKExtension::OnExtensionUnload()
78.226 -{
78.227 -#if defined SMEXT_CONF_METAMOD
78.228 - m_WeAreUnloaded = true;
78.229 -#endif
78.230 - SDK_OnUnload();
78.231 -}
78.232 -
78.233 -const char *SDKExtension::GetExtensionAuthor()
78.234 -{
78.235 - return SMEXT_CONF_AUTHOR;
78.236 -}
78.237 -
78.238 -const char *SDKExtension::GetExtensionDateString()
78.239 -{
78.240 - return SMEXT_CONF_DATESTRING;
78.241 -}
78.242 -
78.243 -const char *SDKExtension::GetExtensionDescription()
78.244 -{
78.245 - return SMEXT_CONF_DESCRIPTION;
78.246 -}
78.247 -
78.248 -const char *SDKExtension::GetExtensionVerString()
78.249 -{
78.250 - return SMEXT_CONF_VERSION;
78.251 -}
78.252 -
78.253 -const char *SDKExtension::GetExtensionName()
78.254 -{
78.255 - return SMEXT_CONF_NAME;
78.256 -}
78.257 -
78.258 -const char *SDKExtension::GetExtensionTag()
78.259 -{
78.260 - return SMEXT_CONF_LOGTAG;
78.261 -}
78.262 -
78.263 -const char *SDKExtension::GetExtensionURL()
78.264 -{
78.265 - return SMEXT_CONF_URL;
78.266 -}
78.267 -
78.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
78.269 -{
78.270 - return true;
78.271 -}
78.272 -
78.273 -void SDKExtension::SDK_OnUnload()
78.274 -{
78.275 -}
78.276 -
78.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
78.278 -{
78.279 -}
78.280 -
78.281 -void SDKExtension::SDK_OnAllLoaded()
78.282 -{
78.283 -}
78.284 -
78.285 -#if defined SMEXT_CONF_METAMOD
78.286 -
78.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
78.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
78.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
78.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
78.291 -
78.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
78.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
78.294 -
78.295 -/** Exposes the extension to Metamod */
78.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
78.297 -{
78.298 -#if defined METAMOD_PLAPI_VERSION
78.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
78.300 -#else
78.301 - if (name && !strcmp(name, PLAPI_NAME))
78.302 -#endif
78.303 - {
78.304 - if (code)
78.305 - {
78.306 - *code = IFACE_OK;
78.307 - }
78.308 - return static_cast<void *>(g_pExtensionIface);
78.309 - }
78.310 -
78.311 - if (code)
78.312 - {
78.313 - *code = IFACE_FAILED;
78.314 - }
78.315 -
78.316 - return NULL;
78.317 -}
78.318 -
78.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
78.320 -{
78.321 - PLUGIN_SAVEVARS();
78.322 -
78.323 -#if !defined METAMOD_PLAPI_VERSION
78.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
78.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
78.326 -#else
78.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
78.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
78.329 -#endif
78.330 -
78.331 - m_SourceMMLoaded = true;
78.332 -
78.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
78.334 -}
78.335 -
78.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
78.337 -{
78.338 - if (!m_WeAreUnloaded)
78.339 - {
78.340 - if (error)
78.341 - {
78.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
78.343 - }
78.344 - return false;
78.345 - }
78.346 -
78.347 - return SDK_OnMetamodUnload(error, maxlen);
78.348 -}
78.349 -
78.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
78.351 -{
78.352 - if (!m_WeGotPauseChange)
78.353 - {
78.354 - if (error)
78.355 - {
78.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
78.357 - }
78.358 - return false;
78.359 - }
78.360 -
78.361 - m_WeGotPauseChange = false;
78.362 -
78.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
78.364 -}
78.365 -
78.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
78.367 -{
78.368 - if (!m_WeGotPauseChange)
78.369 - {
78.370 - if (error)
78.371 - {
78.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
78.373 - }
78.374 - return false;
78.375 - }
78.376 -
78.377 - m_WeGotPauseChange = false;
78.378 -
78.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
78.380 -}
78.381 -
78.382 -const char *SDKExtension::GetAuthor()
78.383 -{
78.384 - return GetExtensionAuthor();
78.385 -}
78.386 -
78.387 -const char *SDKExtension::GetDate()
78.388 -{
78.389 - return GetExtensionDateString();
78.390 -}
78.391 -
78.392 -const char *SDKExtension::GetDescription()
78.393 -{
78.394 - return GetExtensionDescription();
78.395 -}
78.396 -
78.397 -const char *SDKExtension::GetLicense()
78.398 -{
78.399 - return SMEXT_CONF_LICENSE;
78.400 -}
78.401 -
78.402 -const char *SDKExtension::GetLogTag()
78.403 -{
78.404 - return GetExtensionTag();
78.405 -}
78.406 -
78.407 -const char *SDKExtension::GetName()
78.408 -{
78.409 - return GetExtensionName();
78.410 -}
78.411 -
78.412 -const char *SDKExtension::GetURL()
78.413 -{
78.414 - return GetExtensionURL();
78.415 -}
78.416 -
78.417 -const char *SDKExtension::GetVersion()
78.418 -{
78.419 - return GetExtensionVerString();
78.420 -}
78.421 -
78.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
78.423 -{
78.424 - return true;
78.425 -}
78.426 -
78.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
78.428 -{
78.429 - return true;
78.430 -}
78.431 -
78.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
78.433 -{
78.434 - return true;
78.435 -}
78.436 -
78.437 -#endif
78.438 -
78.439 -/* Overload a few things to prevent libstdc++ linking */
78.440 -#if defined __linux__ || defined __APPLE__
78.441 -extern "C" void __cxa_pure_virtual(void)
78.442 -{
78.443 -}
78.444 -
78.445 -void *operator new(size_t size)
78.446 -{
78.447 - return malloc(size);
78.448 -}
78.449 -
78.450 -void *operator new[](size_t size)
78.451 -{
78.452 - return malloc(size);
78.453 -}
78.454 -
78.455 -void operator delete(void *ptr)
78.456 -{
78.457 - free(ptr);
78.458 -}
78.459 -
78.460 -void operator delete[](void * ptr)
78.461 -{
78.462 - free(ptr);
78.463 -}
78.464 -#endif
78.465 -
79.1 --- a/extensions/tf2/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,316 +0,0 @@
79.4 -/**
79.5 - * vim: set ts=4 :
79.6 - * =============================================================================
79.7 - * SourceMod Base Extension Code
79.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
79.9 - * =============================================================================
79.10 - *
79.11 - * This program is free software; you can redistribute it and/or modify it under
79.12 - * the terms of the GNU General Public License, version 3.0, as published by the
79.13 - * Free Software Foundation.
79.14 - *
79.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
79.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
79.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
79.18 - * details.
79.19 - *
79.20 - * You should have received a copy of the GNU General Public License along with
79.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
79.22 - *
79.23 - * As a special exception, AlliedModders LLC gives you permission to link the
79.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
79.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
79.26 - * by the Valve Corporation. You must obey the GNU General Public License in
79.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
79.28 - * this exception to all derivative works. AlliedModders LLC defines further
79.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
79.30 - * or <http://www.sourcemod.net/license.php>.
79.31 - *
79.32 - * Version: $Id$
79.33 - */
79.34 -
79.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
79.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
79.37 -
79.38 -/**
79.39 - * @file smsdk_ext.h
79.40 - * @brief Contains wrappers for making Extensions easier to write.
79.41 - */
79.42 -
79.43 -#include "smsdk_config.h"
79.44 -#include <IExtensionSys.h>
79.45 -#include <IHandleSys.h>
79.46 -#include <sp_vm_api.h>
79.47 -#include <sm_platform.h>
79.48 -#include <ISourceMod.h>
79.49 -#if defined SMEXT_ENABLE_FORWARDSYS
79.50 -#include <IForwardSys.h>
79.51 -#endif //SMEXT_ENABLE_FORWARDSYS
79.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
79.53 -#include <IPlayerHelpers.h>
79.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
79.55 -#if defined SMEXT_ENABLE_DBMANAGER
79.56 -#include <IDBDriver.h>
79.57 -#endif //SMEXT_ENABLE_DBMANAGER
79.58 -#if defined SMEXT_ENABLE_GAMECONF
79.59 -#include <IGameConfigs.h>
79.60 -#endif
79.61 -#if defined SMEXT_ENABLE_MEMUTILS
79.62 -#include <IMemoryUtils.h>
79.63 -#endif
79.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
79.65 -#include <IGameHelpers.h>
79.66 -#endif
79.67 -#if defined SMEXT_ENABLE_TIMERSYS
79.68 -#include <ITimerSystem.h>
79.69 -#endif
79.70 -#if defined SMEXT_ENABLE_ADTFACTORY
79.71 -#include <IADTFactory.h>
79.72 -#endif
79.73 -#if defined SMEXT_ENABLE_THREADER
79.74 -#include <IThreader.h>
79.75 -#endif
79.76 -#if defined SMEXT_ENABLE_LIBSYS
79.77 -#include <ILibrarySys.h>
79.78 -#endif
79.79 -#if defined SMEXT_ENABLE_USERMSGS
79.80 -#include <IUserMessages.h>
79.81 -#endif
79.82 -#if defined SMEXT_ENABLE_PLUGINSYS
79.83 -#include <IPluginSys.h>
79.84 -#endif
79.85 -
79.86 -#if defined SMEXT_CONF_METAMOD
79.87 -#include <ISmmPlugin.h>
79.88 -#include <eiface.h>
79.89 -#endif
79.90 -
79.91 -#if !defined METAMOD_PLAPI_VERSION
79.92 - #include <metamod_wrappers.h>
79.93 -#endif
79.94 -
79.95 -using namespace SourceMod;
79.96 -using namespace SourcePawn;
79.97 -
79.98 -class SDKExtension :
79.99 -#if defined SMEXT_CONF_METAMOD
79.100 - public ISmmPlugin,
79.101 -#endif
79.102 - public IExtensionInterface
79.103 -{
79.104 -public:
79.105 - /** Constructor */
79.106 - SDKExtension();
79.107 -public:
79.108 - /**
79.109 - * @brief This is called after the initial loading sequence has been processed.
79.110 - *
79.111 - * @param error Error message buffer.
79.112 - * @param maxlength Size of error message buffer.
79.113 - * @param late Whether or not the module was loaded after map load.
79.114 - * @return True to succeed loading, false to fail.
79.115 - */
79.116 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
79.117 -
79.118 - /**
79.119 - * @brief This is called right before the extension is unloaded.
79.120 - */
79.121 - virtual void SDK_OnUnload();
79.122 -
79.123 - /**
79.124 - * @brief This is called once all known extensions have been loaded.
79.125 - */
79.126 - virtual void SDK_OnAllLoaded();
79.127 -
79.128 - /**
79.129 - * @brief Called when the pause state is changed.
79.130 - */
79.131 - virtual void SDK_OnPauseChange(bool paused);
79.132 -
79.133 -#if defined SMEXT_CONF_METAMOD
79.134 - /**
79.135 - * @brief Called when Metamod is attached, before the extension version is called.
79.136 - *
79.137 - * @param error Error buffer.
79.138 - * @param maxlength Maximum size of error buffer.
79.139 - * @param late Whether or not Metamod considers this a late load.
79.140 - * @return True to succeed, false to fail.
79.141 - */
79.142 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
79.143 -
79.144 - /**
79.145 - * @brief Called when Metamod is detaching, after the extension version is called.
79.146 - * NOTE: By default this is blocked unless sent from SourceMod.
79.147 - *
79.148 - * @param error Error buffer.
79.149 - * @param maxlength Maximum size of error buffer.
79.150 - * @return True to succeed, false to fail.
79.151 - */
79.152 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
79.153 -
79.154 - /**
79.155 - * @brief Called when Metamod's pause state is changing.
79.156 - * NOTE: By default this is blocked unless sent from SourceMod.
79.157 - *
79.158 - * @param paused Pause state being set.
79.159 - * @param error Error buffer.
79.160 - * @param maxlength Maximum size of error buffer.
79.161 - * @return True to succeed, false to fail.
79.162 - */
79.163 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
79.164 -#endif
79.165 -
79.166 -public: //IExtensionInterface
79.167 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
79.168 - virtual void OnExtensionUnload();
79.169 - virtual void OnExtensionsAllLoaded();
79.170 -
79.171 - /** Returns whether or not this is a Metamod-based extension */
79.172 - virtual bool IsMetamodExtension();
79.173 -
79.174 - /**
79.175 - * @brief Called when the pause state changes.
79.176 - *
79.177 - * @param state True if being paused, false if being unpaused.
79.178 - */
79.179 - virtual void OnExtensionPauseChange(bool state);
79.180 -
79.181 - /** Returns name */
79.182 - virtual const char *GetExtensionName();
79.183 - /** Returns URL */
79.184 - virtual const char *GetExtensionURL();
79.185 - /** Returns log tag */
79.186 - virtual const char *GetExtensionTag();
79.187 - /** Returns author */
79.188 - virtual const char *GetExtensionAuthor();
79.189 - /** Returns version string */
79.190 - virtual const char *GetExtensionVerString();
79.191 - /** Returns description string */
79.192 - virtual const char *GetExtensionDescription();
79.193 - /** Returns date string */
79.194 - virtual const char *GetExtensionDateString();
79.195 -#if defined SMEXT_CONF_METAMOD
79.196 -public: //ISmmPlugin
79.197 - /** Called when the extension is attached to Metamod. */
79.198 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
79.199 - /** Returns the author to MM */
79.200 - virtual const char *GetAuthor();
79.201 - /** Returns the name to MM */
79.202 - virtual const char *GetName();
79.203 - /** Returns the description to MM */
79.204 - virtual const char *GetDescription();
79.205 - /** Returns the URL to MM */
79.206 - virtual const char *GetURL();
79.207 - /** Returns the license to MM */
79.208 - virtual const char *GetLicense();
79.209 - /** Returns the version string to MM */
79.210 - virtual const char *GetVersion();
79.211 - /** Returns the date string to MM */
79.212 - virtual const char *GetDate();
79.213 - /** Returns the logtag to MM */
79.214 - virtual const char *GetLogTag();
79.215 - /** Called on unload */
79.216 - virtual bool Unload(char *error, size_t maxlength);
79.217 - /** Called on pause */
79.218 - virtual bool Pause(char *error, size_t maxlength);
79.219 - /** Called on unpause */
79.220 - virtual bool Unpause(char *error, size_t maxlength);
79.221 -private:
79.222 - bool m_SourceMMLoaded;
79.223 - bool m_WeAreUnloaded;
79.224 - bool m_WeGotPauseChange;
79.225 -#endif
79.226 -};
79.227 -
79.228 -extern SDKExtension *g_pExtensionIface;
79.229 -extern IExtension *myself;
79.230 -
79.231 -extern IShareSys *g_pShareSys;
79.232 -extern IShareSys *sharesys; /* Note: Newer name */
79.233 -extern ISourceMod *g_pSM;
79.234 -extern ISourceMod *smutils; /* Note: Newer name */
79.235 -
79.236 -/* Optional interfaces are below */
79.237 -#if defined SMEXT_ENABLE_FORWARDSYS
79.238 -extern IForwardManager *g_pForwards;
79.239 -extern IForwardManager *forwards; /* Note: Newer name */
79.240 -#endif //SMEXT_ENABLE_FORWARDSYS
79.241 -#if defined SMEXT_ENABLE_HANDLESYS
79.242 -extern IHandleSys *g_pHandleSys;
79.243 -extern IHandleSys *handlesys; /* Note: Newer name */
79.244 -#endif //SMEXT_ENABLE_HANDLESYS
79.245 -#if defined SMEXT_ENABLE_PLAYERHELPERS
79.246 -extern IPlayerManager *playerhelpers;
79.247 -#endif //SMEXT_ENABLE_PLAYERHELPERS
79.248 -#if defined SMEXT_ENABLE_DBMANAGER
79.249 -extern IDBManager *dbi;
79.250 -#endif //SMEXT_ENABLE_DBMANAGER
79.251 -#if defined SMEXT_ENABLE_GAMECONF
79.252 -extern IGameConfigManager *gameconfs;
79.253 -#endif //SMEXT_ENABLE_DBMANAGER
79.254 -#if defined SMEXT_ENABLE_MEMUTILS
79.255 -extern IMemoryUtils *memutils;
79.256 -#endif
79.257 -#if defined SMEXT_ENABLE_GAMEHELPERS
79.258 -extern IGameHelpers *gamehelpers;
79.259 -#endif
79.260 -#if defined SMEXT_ENABLE_TIMERSYS
79.261 -extern ITimerSystem *timersys;
79.262 -#endif
79.263 -#if defined SMEXT_ENABLE_ADTFACTORY
79.264 -extern IADTFactory *adtfactory;
79.265 -#endif
79.266 -#if defined SMEXT_ENABLE_THREADER
79.267 -extern IThreader *threader;
79.268 -#endif
79.269 -#if defined SMEXT_ENABLE_LIBSYS
79.270 -extern ILibrarySys *libsys;
79.271 -#endif
79.272 -#if defined SMEXT_ENABLE_USERMSGS
79.273 -extern IUserMessages *usermsgs;
79.274 -#endif
79.275 -#if defined SMEXT_ENABLE_PLUGINSYS
79.276 -extern IPluginManager *plsys;
79.277 -#endif
79.278 -
79.279 -#if defined SMEXT_CONF_METAMOD
79.280 -PLUGIN_GLOBALVARS();
79.281 -extern IVEngineServer *engine;
79.282 -extern IServerGameDLL *gamedll;
79.283 -#endif
79.284 -
79.285 -/** Creates a SourceMod interface macro pair */
79.286 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
79.287 -/** Automates retrieving SourceMod interfaces */
79.288 -#define SM_GET_IFACE(prefix, addr) \
79.289 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
79.290 - { \
79.291 - if (error != NULL && maxlength) \
79.292 - { \
79.293 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
79.294 - if (len >= maxlength) \
79.295 - { \
79.296 - error[maxlength - 1] = '\0'; \
79.297 - } \
79.298 - } \
79.299 - return false; \
79.300 - }
79.301 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
79.302 -#define SM_GET_LATE_IFACE(prefix, addr) \
79.303 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
79.304 -/** Validates a SourceMod interface pointer */
79.305 -#define SM_CHECK_IFACE(prefix, addr) \
79.306 - if (!addr) \
79.307 - { \
79.308 - if (error != NULL && maxlength) \
79.309 - { \
79.310 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
79.311 - if (len >= maxlength) \
79.312 - { \
79.313 - error[maxlength - 1] = '\0'; \
79.314 - } \
79.315 - } \
79.316 - return false; \
79.317 - }
79.318 -
79.319 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/extensions/tf2/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
80.3 @@ -0,0 +1,75 @@
80.4 +/**
80.5 + * vim: set ts=4 :
80.6 + * =============================================================================
80.7 + * SourceMod Team Fortress 2 Extension
80.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
80.9 + * =============================================================================
80.10 + *
80.11 + * This program is free software; you can redistribute it and/or modify it under
80.12 + * the terms of the GNU General Public License, version 3.0, as published by the
80.13 + * Free Software Foundation.
80.14 + *
80.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
80.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
80.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
80.18 + * details.
80.19 + *
80.20 + * You should have received a copy of the GNU General Public License along with
80.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
80.22 + *
80.23 + * As a special exception, AlliedModders LLC gives you permission to link the
80.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
80.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
80.26 + * by the Valve Corporation. You must obey the GNU General Public License in
80.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
80.28 + * this exception to all derivative works. AlliedModders LLC defines further
80.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
80.30 + * or <http://www.sourcemod.net/license.php>.
80.31 + *
80.32 + * Version: $Id$
80.33 + */
80.34 +
80.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
80.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
80.37 +
80.38 +/**
80.39 + * @file smsdk_config.h
80.40 + * @brief Contains macros for configuring basic extension information.
80.41 + */
80.42 +
80.43 +/* Basic information exposed publicly */
80.44 +#define SMEXT_CONF_NAME "TF2 Tools"
80.45 +#define SMEXT_CONF_DESCRIPTION "TF2 extended functionality"
80.46 +#define SMEXT_CONF_VERSION ""
80.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
80.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
80.49 +#define SMEXT_CONF_LOGTAG "TF2"
80.50 +#define SMEXT_CONF_LICENSE "GPL"
80.51 +#define SMEXT_CONF_DATESTRING ""
80.52 +
80.53 +/**
80.54 + * @brief Exposes plugin's main interface.
80.55 + */
80.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
80.57 +
80.58 +/**
80.59 + * @brief Sets whether or not this plugin required Metamod.
80.60 + * NOTE: Uncomment to enable, comment to disable.
80.61 + */
80.62 +#define SMEXT_CONF_METAMOD
80.63 +
80.64 +/** Enable interfaces you want to use here by uncommenting lines */
80.65 +#define SMEXT_ENABLE_FORWARDSYS
80.66 +//#define SMEXT_ENABLE_HANDLESYS
80.67 +#define SMEXT_ENABLE_PLAYERHELPERS
80.68 +//#define SMEXT_ENABLE_DBMANAGER
80.69 +#define SMEXT_ENABLE_GAMECONF
80.70 +//#define SMEXT_ENABLE_MEMUTILS
80.71 +#define SMEXT_ENABLE_GAMEHELPERS
80.72 +#define SMEXT_ENABLE_TIMERSYS
80.73 +//#define SMEXT_ENABLE_THREADER
80.74 +//#define SMEXT_ENABLE_LIBSYS
80.75 +//#define SMEXT_ENABLE_USERMSGS
80.76 +#define SMEXT_ENABLE_PLUGINSYS
80.77 +
80.78 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
81.1 --- a/extensions/topmenus/AMBuilder Wed Apr 23 21:40:50 2014 -0400
81.2 +++ b/extensions/topmenus/AMBuilder Wed Apr 23 21:19:28 2014 -0500
81.3 @@ -11,8 +11,7 @@
81.4 'smn_topmenus.cpp',
81.5 'TopMenu.cpp',
81.6 'TopMenuManager.cpp',
81.7 - 'sdk/smsdk_ext.cpp',
81.8 - 'sdk/sm_memtable.cpp'
81.9 + '../../public/smsdk_ext.cpp',
81.10 ]
81.11
81.12 SM.extensions += [builder.Add(binary)]
82.1 --- a/extensions/topmenus/TopMenu.cpp Wed Apr 23 21:40:50 2014 -0400
82.2 +++ b/extensions/topmenus/TopMenu.cpp Wed Apr 23 21:19:28 2014 -0500
82.3 @@ -91,7 +91,7 @@
82.4 {
82.5 unsigned int size = sizeof(TopMenu);
82.6
82.7 - size += m_Config.strings.GetMemTable()->MemUsage();
82.8 + size += m_Config.strings.GetMemTable()->GetMemUsage();
82.9 size += (m_Config.cats.size() * sizeof(int));
82.10 size += (sizeof(topmenu_player_t) * (ABSOLUTE_PLAYER_LIMIT + 1));
82.11 size += (m_SortedCats.size() * sizeof(unsigned int));
83.1 --- a/extensions/topmenus/sdk/sm_memtable.cpp Wed Apr 23 21:40:50 2014 -0400
83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
83.3 @@ -1,112 +0,0 @@
83.4 -/**
83.5 - * vim: set ts=4 :
83.6 - * =============================================================================
83.7 - * SourceMod
83.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
83.9 - * =============================================================================
83.10 - *
83.11 - * This program is free software; you can redistribute it and/or modify it under
83.12 - * the terms of the GNU General Public License, version 3.0, as published by the
83.13 - * Free Software Foundation.
83.14 - *
83.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
83.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
83.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
83.18 - * details.
83.19 - *
83.20 - * You should have received a copy of the GNU General Public License along with
83.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
83.22 - *
83.23 - * As a special exception, AlliedModders LLC gives you permission to link the
83.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
83.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
83.26 - * by the Valve Corporation. You must obey the GNU General Public License in
83.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
83.28 - * this exception to all derivative works. AlliedModders LLC defines further
83.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
83.30 - * or <http://www.sourcemod.net/license.php>.
83.31 - *
83.32 - * Version: $Id$
83.33 - */
83.34 -
83.35 -#include <string.h>
83.36 -#include <stdlib.h>
83.37 -#include "sm_memtable.h"
83.38 -
83.39 -BaseMemTable::BaseMemTable(unsigned int init_size)
83.40 -{
83.41 - membase = (unsigned char *)malloc(init_size);
83.42 - size = init_size;
83.43 - tail = 0;
83.44 -}
83.45 -
83.46 -BaseMemTable::~BaseMemTable()
83.47 -{
83.48 - free(membase);
83.49 - membase = NULL;
83.50 -}
83.51 -
83.52 -int BaseMemTable::CreateMem(unsigned int addsize, void **addr)
83.53 -{
83.54 - int idx = (int)tail;
83.55 -
83.56 - while (tail + addsize >= size)
83.57 - {
83.58 - size *= 2;
83.59 - membase = (unsigned char *)realloc(membase, size);
83.60 - }
83.61 -
83.62 - tail += addsize;
83.63 -
83.64 - if (addr)
83.65 - {
83.66 - *addr = (void *)&membase[idx];
83.67 - }
83.68 -
83.69 - return idx;
83.70 -}
83.71 -
83.72 -void *BaseMemTable::GetAddress(int index)
83.73 -{
83.74 - if (index < 0 || (unsigned int)index >= tail)
83.75 - {
83.76 - return NULL;
83.77 - }
83.78 -
83.79 - return &membase[index];
83.80 -}
83.81 -
83.82 -void BaseMemTable::Reset()
83.83 -{
83.84 - tail = 0;
83.85 -}
83.86 -
83.87 -BaseStringTable::BaseStringTable(unsigned int init_size) : m_table(init_size)
83.88 -{
83.89 -}
83.90 -
83.91 -BaseStringTable::~BaseStringTable()
83.92 -{
83.93 -}
83.94 -
83.95 -int BaseStringTable::AddString(const char *string)
83.96 -{
83.97 - size_t len = strlen(string) + 1;
83.98 - int idx;
83.99 - char *addr;
83.100 -
83.101 - idx = m_table.CreateMem(len, (void **)&addr);
83.102 - strcpy(addr, string);
83.103 -
83.104 - return idx;
83.105 -}
83.106 -
83.107 -/*const char *BaseStringTable::GetString(int str)
83.108 -{
83.109 - return (const char *)m_table.GetAddress(str);
83.110 -}*/
83.111 -
83.112 -void BaseStringTable::Reset()
83.113 -{
83.114 - m_table.Reset();
83.115 -}
84.1 --- a/extensions/topmenus/sdk/sm_memtable.h Wed Apr 23 21:40:50 2014 -0400
84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
84.3 @@ -1,109 +0,0 @@
84.4 -/**
84.5 - * vim: set ts=4 :
84.6 - * =============================================================================
84.7 - * SourceMod
84.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
84.9 - * =============================================================================
84.10 - *
84.11 - * This program is free software; you can redistribute it and/or modify it under
84.12 - * the terms of the GNU General Public License, version 3.0, as published by the
84.13 - * Free Software Foundation.
84.14 - *
84.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
84.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
84.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
84.18 - * details.
84.19 - *
84.20 - * You should have received a copy of the GNU General Public License along with
84.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
84.22 - *
84.23 - * As a special exception, AlliedModders LLC gives you permission to link the
84.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
84.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
84.26 - * by the Valve Corporation. You must obey the GNU General Public License in
84.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
84.28 - * this exception to all derivative works. AlliedModders LLC defines further
84.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
84.30 - * or <http://www.sourcemod.net/license.php>.
84.31 - *
84.32 - * Version: $Id$
84.33 - */
84.34 -
84.35 -#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
84.36 -#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
84.37 -
84.38 -class BaseMemTable
84.39 -{
84.40 -public:
84.41 - BaseMemTable(unsigned int init_size);
84.42 - ~BaseMemTable();
84.43 -public:
84.44 - /**
84.45 - * Allocates 'size' bytes of memory.
84.46 - * Optionally outputs the address through 'addr'.
84.47 - * Returns an index >= 0 on success, < 0 on failure.
84.48 - */
84.49 - int CreateMem(unsigned int size, void **addr);
84.50 -
84.51 - /**
84.52 - * Given an index into the memory table, returns its address.
84.53 - * Returns NULL if invalid.
84.54 - */
84.55 - void *GetAddress(int index);
84.56 -
84.57 - /**
84.58 - * Scraps the memory table. For caching purposes, the memory
84.59 - * is not freed, however subsequent calls to CreateMem() will
84.60 - * begin at the first index again.
84.61 - */
84.62 - void Reset();
84.63 -
84.64 - inline unsigned int MemUsage()
84.65 - {
84.66 - return size;
84.67 - }
84.68 -
84.69 -private:
84.70 - unsigned char *membase;
84.71 - unsigned int size;
84.72 - unsigned int tail;
84.73 -};
84.74 -
84.75 -class BaseStringTable
84.76 -{
84.77 -public:
84.78 - BaseStringTable(unsigned int init_size);
84.79 - ~BaseStringTable();
84.80 -public:
84.81 - /**
84.82 - * Adds a string to the string table and returns its index.
84.83 - */
84.84 - int AddString(const char *string);
84.85 -
84.86 - /**
84.87 - * Given an index into the string table, returns the associated string.
84.88 - */
84.89 - inline const char *GetString(int str)
84.90 - {
84.91 - return (const char *)m_table.GetAddress(str);
84.92 - }
84.93 -
84.94 - /**
84.95 - * Scraps the string table. For caching purposes, the memory
84.96 - * is not freed, however subsequent calls to AddString() will
84.97 - * begin at the first index again.
84.98 - */
84.99 - void Reset();
84.100 -
84.101 - /**
84.102 - * Returns the parent BaseMemTable that this string table uses.
84.103 - */
84.104 - inline BaseMemTable *GetMemTable()
84.105 - {
84.106 - return &m_table;
84.107 - }
84.108 -private:
84.109 - BaseMemTable m_table;
84.110 -};
84.111 -
84.112 -#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
85.1 --- a/extensions/topmenus/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
85.3 @@ -1,78 +0,0 @@
85.4 -/**
85.5 - * vim: set ts=4 :
85.6 - * =============================================================================
85.7 - * SourceMod TopMenus Extension
85.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
85.9 - * =============================================================================
85.10 - *
85.11 - * This program is free software; you can redistribute it and/or modify it under
85.12 - * the terms of the GNU General Public License, version 3.0, as published by the
85.13 - * Free Software Foundation.
85.14 - *
85.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
85.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
85.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
85.18 - * details.
85.19 - *
85.20 - * You should have received a copy of the GNU General Public License along with
85.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
85.22 - *
85.23 - * As a special exception, AlliedModders LLC gives you permission to link the
85.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
85.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
85.26 - * by the Valve Corporation. You must obey the GNU General Public License in
85.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
85.28 - * this exception to all derivative works. AlliedModders LLC defines further
85.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
85.30 - * or <http://www.sourcemod.net/license.php>.
85.31 - *
85.32 - * Version: $Id$
85.33 - */
85.34 -
85.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
85.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
85.37 -
85.38 -/**
85.39 - * @file smsdk_config.h
85.40 - * @brief Contains macros for configuring basic extension information.
85.41 - */
85.42 -
85.43 -/* Basic information exposed publicly */
85.44 -#define SMEXT_CONF_NAME "Top Menus"
85.45 -#define SMEXT_CONF_DESCRIPTION "Creates sorted nested menus"
85.46 -#define SMEXT_CONF_VERSION ""
85.47 -#define SMEXT_CONF_AUTHOR "AlliedModders"
85.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
85.49 -#define SMEXT_CONF_LOGTAG "TOPMENUS"
85.50 -#define SMEXT_CONF_LICENSE "GPLv3"
85.51 -#define SMEXT_CONF_DATESTRING ""
85.52 -
85.53 -/**
85.54 - * @brief Exposes plugin's main interface.
85.55 - */
85.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
85.57 -
85.58 -/**
85.59 - * @brief Sets whether or not this plugin required Metamod.
85.60 - * NOTE: Uncomment to enable, comment to disable.
85.61 - */
85.62 -//#define SMEXT_CONF_METAMOD
85.63 -
85.64 -/** Enable interfaces you want to use here by uncommenting lines */
85.65 -//#define SMEXT_ENABLE_FORWARDSYS
85.66 -#define SMEXT_ENABLE_HANDLESYS
85.67 -#define SMEXT_ENABLE_PLAYERHELPERS
85.68 -//#define SMEXT_ENABLE_DBMANAGER
85.69 -//#define SMEXT_ENABLE_GAMECONF
85.70 -//#define SMEXT_ENABLE_MEMUTILS
85.71 -//#define SMEXT_ENABLE_GAMEHELPERS
85.72 -//#define SMEXT_ENABLE_TIMERSYS
85.73 -//#define SMEXT_ENABLE_THREADER
85.74 -//#define SMEXT_ENABLE_LIBSYS
85.75 -#define SMEXT_ENABLE_MENUS
85.76 -//#define SMEXT_ENABLE_ADTFACTORY
85.77 -#define SMEXT_ENABLE_PLUGINSYS
85.78 -#define SMEXT_ENABLE_ADMINSYS
85.79 -#define SMEXT_ENABLE_TEXTPARSERS
85.80 -
85.81 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
86.1 --- a/extensions/topmenus/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
86.3 @@ -1,462 +0,0 @@
86.4 -/**
86.5 - * vim: set ts=4 :
86.6 - * =============================================================================
86.7 - * SourceMod Base Extension Code
86.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
86.9 - * =============================================================================
86.10 - *
86.11 - * This program is free software; you can redistribute it and/or modify it under
86.12 - * the terms of the GNU General Public License, version 3.0, as published by the
86.13 - * Free Software Foundation.
86.14 - *
86.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
86.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
86.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
86.18 - * details.
86.19 - *
86.20 - * You should have received a copy of the GNU General Public License along with
86.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
86.22 - *
86.23 - * As a special exception, AlliedModders LLC gives you permission to link the
86.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
86.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
86.26 - * by the Valve Corporation. You must obey the GNU General Public License in
86.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
86.28 - * this exception to all derivative works. AlliedModders LLC defines further
86.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
86.30 - * or <http://www.sourcemod.net/license.php>.
86.31 - *
86.32 - * Version: $Id$
86.33 - */
86.34 -
86.35 -#include <stdio.h>
86.36 -#include <stdlib.h>
86.37 -#include "smsdk_ext.h"
86.38 -
86.39 -/**
86.40 - * @file smsdk_ext.cpp
86.41 - * @brief Contains wrappers for making Extensions easier to write.
86.42 - */
86.43 -
86.44 -IExtension *myself = NULL; /**< Ourself */
86.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
86.46 -IShareSys *sharesys = NULL; /**< Share system */
86.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
86.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
86.49 -
86.50 -#if defined SMEXT_ENABLE_FORWARDSYS
86.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
86.52 -IForwardManager *forwards = NULL; /**< Forward system */
86.53 -#endif
86.54 -#if defined SMEXT_ENABLE_HANDLESYS
86.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
86.56 -IHandleSys *handlesys = NULL; /**< Handle system */
86.57 -#endif
86.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
86.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
86.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
86.61 -#if defined SMEXT_ENABLE_DBMANAGER
86.62 -IDBManager *dbi = NULL; /**< DB Manager */
86.63 -#endif //SMEXT_ENABLE_DBMANAGER
86.64 -#if defined SMEXT_ENABLE_GAMECONF
86.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
86.66 -#endif //SMEXT_ENABLE_DBMANAGER
86.67 -#if defined SMEXT_ENABLE_MEMUTILS
86.68 -IMemoryUtils *memutils = NULL;
86.69 -#endif //SMEXT_ENABLE_DBMANAGER
86.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
86.71 -IGameHelpers *gamehelpers = NULL;
86.72 -#endif
86.73 -#if defined SMEXT_ENABLE_TIMERSYS
86.74 -ITimerSystem *timersys = NULL;
86.75 -#endif
86.76 -#if defined SMEXT_ENABLE_ADTFACTORY
86.77 -IADTFactory *adtfactory = NULL;
86.78 -#endif
86.79 -#if defined SMEXT_ENABLE_THREADER
86.80 -IThreader *threader = NULL;
86.81 -#endif
86.82 -#if defined SMEXT_ENABLE_LIBSYS
86.83 -ILibrarySys *libsys = NULL;
86.84 -#endif
86.85 -#if defined SMEXT_ENABLE_PLUGINSYS
86.86 -SourceMod::IPluginManager *plsys;
86.87 -#endif
86.88 -#if defined SMEXT_ENABLE_MENUS
86.89 -IMenuManager *menus = NULL;
86.90 -#endif
86.91 -#if defined SMEXT_ENABLE_ADMINSYS
86.92 -IAdminSystem *adminsys = NULL;
86.93 -#endif
86.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
86.95 -ITextParsers *textparsers = NULL;
86.96 -#endif
86.97 -#if defined SMEXT_ENABLE_USERMSGS
86.98 -IUserMessages *usermsgs = NULL;
86.99 -#endif
86.100 -#if defined SMEXT_ENABLE_TRANSLATOR
86.101 -ITranslator *translator = NULL;
86.102 -#endif
86.103 -
86.104 -/** Exports the main interface */
86.105 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
86.106 -{
86.107 - return g_pExtensionIface;
86.108 -}
86.109 -
86.110 -SDKExtension::SDKExtension()
86.111 -{
86.112 -#if defined SMEXT_CONF_METAMOD
86.113 - m_SourceMMLoaded = false;
86.114 - m_WeAreUnloaded = false;
86.115 - m_WeGotPauseChange = false;
86.116 -#endif
86.117 -}
86.118 -
86.119 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
86.120 -{
86.121 - g_pShareSys = sharesys = sys;
86.122 - myself = me;
86.123 -
86.124 -#if defined SMEXT_CONF_METAMOD
86.125 - m_WeAreUnloaded = true;
86.126 -
86.127 - if (!m_SourceMMLoaded)
86.128 - {
86.129 - if (error)
86.130 - {
86.131 - snprintf(error, maxlength, "Metamod attach failed");
86.132 - }
86.133 - return false;
86.134 - }
86.135 -#endif
86.136 - SM_GET_IFACE(SOURCEMOD, g_pSM);
86.137 - smutils = g_pSM;
86.138 -#if defined SMEXT_ENABLE_HANDLESYS
86.139 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
86.140 - handlesys = g_pHandleSys;
86.141 -#endif
86.142 -#if defined SMEXT_ENABLE_FORWARDSYS
86.143 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
86.144 - forwards = g_pForwards;
86.145 -#endif
86.146 -#if defined SMEXT_ENABLE_PLAYERHELPERS
86.147 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
86.148 -#endif
86.149 -#if defined SMEXT_ENABLE_DBMANAGER
86.150 - SM_GET_IFACE(DBI, dbi);
86.151 -#endif
86.152 -#if defined SMEXT_ENABLE_GAMECONF
86.153 - SM_GET_IFACE(GAMECONFIG, gameconfs);
86.154 -#endif
86.155 -#if defined SMEXT_ENABLE_MEMUTILS
86.156 - SM_GET_IFACE(MEMORYUTILS, memutils);
86.157 -#endif
86.158 -#if defined SMEXT_ENABLE_GAMEHELPERS
86.159 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
86.160 -#endif
86.161 -#if defined SMEXT_ENABLE_TIMERSYS
86.162 - SM_GET_IFACE(TIMERSYS, timersys);
86.163 -#endif
86.164 -#if defined SMEXT_ENABLE_ADTFACTORY
86.165 - SM_GET_IFACE(ADTFACTORY, adtfactory);
86.166 -#endif
86.167 -#if defined SMEXT_ENABLE_THREADER
86.168 - SM_GET_IFACE(THREADER, threader);
86.169 -#endif
86.170 -#if defined SMEXT_ENABLE_LIBSYS
86.171 - SM_GET_IFACE(LIBRARYSYS, libsys);
86.172 -#endif
86.173 -#if defined SMEXT_ENABLE_PLUGINSYS
86.174 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
86.175 -#endif
86.176 -#if defined SMEXT_ENABLE_MENUS
86.177 - SM_GET_IFACE(MENUMANAGER, menus);
86.178 -#endif
86.179 -#if defined SMEXT_ENABLE_ADMINSYS
86.180 - SM_GET_IFACE(ADMINSYS, adminsys);
86.181 -#endif
86.182 -#if defined SMEXT_ENABLE_TEXTPARSERS
86.183 - SM_GET_IFACE(TEXTPARSERS, textparsers);
86.184 -#endif
86.185 -#if defined SMEXT_ENABLE_USERMSGS
86.186 - SM_GET_IFACE(USERMSGS, usermsgs);
86.187 -#endif
86.188 -#if defined SMEXT_ENABLE_TRANSLATOR
86.189 - SM_GET_IFACE(TRANSLATOR, translator);
86.190 -#endif
86.191 -
86.192 - if (SDK_OnLoad(error, maxlength, late))
86.193 - {
86.194 -#if defined SMEXT_CONF_METAMOD
86.195 - m_WeAreUnloaded = true;
86.196 -#endif
86.197 - return true;
86.198 - }
86.199 -
86.200 - return false;
86.201 -}
86.202 -
86.203 -bool SDKExtension::IsMetamodExtension()
86.204 -{
86.205 -#if defined SMEXT_CONF_METAMOD
86.206 - return true;
86.207 -#else
86.208 - return false;
86.209 -#endif
86.210 -}
86.211 -
86.212 -void SDKExtension::OnExtensionPauseChange(bool state)
86.213 -{
86.214 -#if defined SMEXT_CONF_METAMOD
86.215 - m_WeGotPauseChange = true;
86.216 -#endif
86.217 - SDK_OnPauseChange(state);
86.218 -}
86.219 -
86.220 -void SDKExtension::OnExtensionsAllLoaded()
86.221 -{
86.222 - SDK_OnAllLoaded();
86.223 -}
86.224 -
86.225 -void SDKExtension::OnExtensionUnload()
86.226 -{
86.227 -#if defined SMEXT_CONF_METAMOD
86.228 - m_WeAreUnloaded = true;
86.229 -#endif
86.230 - SDK_OnUnload();
86.231 -}
86.232 -
86.233 -const char *SDKExtension::GetExtensionAuthor()
86.234 -{
86.235 - return SMEXT_CONF_AUTHOR;
86.236 -}
86.237 -
86.238 -const char *SDKExtension::GetExtensionDateString()
86.239 -{
86.240 - return SMEXT_CONF_DATESTRING;
86.241 -}
86.242 -
86.243 -const char *SDKExtension::GetExtensionDescription()
86.244 -{
86.245 - return SMEXT_CONF_DESCRIPTION;
86.246 -}
86.247 -
86.248 -const char *SDKExtension::GetExtensionVerString()
86.249 -{
86.250 - return SMEXT_CONF_VERSION;
86.251 -}
86.252 -
86.253 -const char *SDKExtension::GetExtensionName()
86.254 -{
86.255 - return SMEXT_CONF_NAME;
86.256 -}
86.257 -
86.258 -const char *SDKExtension::GetExtensionTag()
86.259 -{
86.260 - return SMEXT_CONF_LOGTAG;
86.261 -}
86.262 -
86.263 -const char *SDKExtension::GetExtensionURL()
86.264 -{
86.265 - return SMEXT_CONF_URL;
86.266 -}
86.267 -
86.268 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
86.269 -{
86.270 - return true;
86.271 -}
86.272 -
86.273 -void SDKExtension::SDK_OnUnload()
86.274 -{
86.275 -}
86.276 -
86.277 -void SDKExtension::SDK_OnPauseChange(bool paused)
86.278 -{
86.279 -}
86.280 -
86.281 -void SDKExtension::SDK_OnAllLoaded()
86.282 -{
86.283 -}
86.284 -
86.285 -#if defined SMEXT_CONF_METAMOD
86.286 -
86.287 -PluginId g_PLID = 0; /**< Metamod plugin ID */
86.288 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
86.289 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
86.290 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
86.291 -
86.292 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
86.293 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
86.294 -
86.295 -/** Exposes the extension to Metamod */
86.296 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
86.297 -{
86.298 -#if defined METAMOD_PLAPI_VERSION
86.299 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
86.300 -#else
86.301 - if (name && !strcmp(name, PLAPI_NAME))
86.302 -#endif
86.303 - {
86.304 - if (code)
86.305 - {
86.306 - *code = IFACE_OK;
86.307 - }
86.308 - return static_cast<void *>(g_pExtensionIface);
86.309 - }
86.310 -
86.311 - if (code)
86.312 - {
86.313 - *code = IFACE_FAILED;
86.314 - }
86.315 -
86.316 - return NULL;
86.317 -}
86.318 -
86.319 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
86.320 -{
86.321 - PLUGIN_SAVEVARS();
86.322 -
86.323 -#if !defined METAMOD_PLAPI_VERSION
86.324 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
86.325 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
86.326 -#else
86.327 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
86.328 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
86.329 -#endif
86.330 -
86.331 - m_SourceMMLoaded = true;
86.332 -
86.333 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
86.334 -}
86.335 -
86.336 -bool SDKExtension::Unload(char *error, size_t maxlen)
86.337 -{
86.338 - if (!m_WeAreUnloaded)
86.339 - {
86.340 - if (error)
86.341 - {
86.342 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
86.343 - }
86.344 - return false;
86.345 - }
86.346 -
86.347 - return SDK_OnMetamodUnload(error, maxlen);
86.348 -}
86.349 -
86.350 -bool SDKExtension::Pause(char *error, size_t maxlen)
86.351 -{
86.352 - if (!m_WeGotPauseChange)
86.353 - {
86.354 - if (error)
86.355 - {
86.356 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
86.357 - }
86.358 - return false;
86.359 - }
86.360 -
86.361 - m_WeGotPauseChange = false;
86.362 -
86.363 - return SDK_OnMetamodPauseChange(true, error, maxlen);
86.364 -}
86.365 -
86.366 -bool SDKExtension::Unpause(char *error, size_t maxlen)
86.367 -{
86.368 - if (!m_WeGotPauseChange)
86.369 - {
86.370 - if (error)
86.371 - {
86.372 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
86.373 - }
86.374 - return false;
86.375 - }
86.376 -
86.377 - m_WeGotPauseChange = false;
86.378 -
86.379 - return SDK_OnMetamodPauseChange(false, error, maxlen);
86.380 -}
86.381 -
86.382 -const char *SDKExtension::GetAuthor()
86.383 -{
86.384 - return GetExtensionAuthor();
86.385 -}
86.386 -
86.387 -const char *SDKExtension::GetDate()
86.388 -{
86.389 - return GetExtensionDateString();
86.390 -}
86.391 -
86.392 -const char *SDKExtension::GetDescription()
86.393 -{
86.394 - return GetExtensionDescription();
86.395 -}
86.396 -
86.397 -const char *SDKExtension::GetLicense()
86.398 -{
86.399 - return SMEXT_CONF_LICENSE;
86.400 -}
86.401 -
86.402 -const char *SDKExtension::GetLogTag()
86.403 -{
86.404 - return GetExtensionTag();
86.405 -}
86.406 -
86.407 -const char *SDKExtension::GetName()
86.408 -{
86.409 - return GetExtensionName();
86.410 -}
86.411 -
86.412 -const char *SDKExtension::GetURL()
86.413 -{
86.414 - return GetExtensionURL();
86.415 -}
86.416 -
86.417 -const char *SDKExtension::GetVersion()
86.418 -{
86.419 - return GetExtensionVerString();
86.420 -}
86.421 -
86.422 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
86.423 -{
86.424 - return true;
86.425 -}
86.426 -
86.427 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
86.428 -{
86.429 - return true;
86.430 -}
86.431 -
86.432 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
86.433 -{
86.434 - return true;
86.435 -}
86.436 -
86.437 -#endif
86.438 -
86.439 -/* Overload a few things to prevent libstdc++ linking */
86.440 -#if defined __linux__ || defined __APPLE__
86.441 -extern "C" void __cxa_pure_virtual(void)
86.442 -{
86.443 -}
86.444 -
86.445 -void *operator new(size_t size)
86.446 -{
86.447 - return malloc(size);
86.448 -}
86.449 -
86.450 -void *operator new[](size_t size)
86.451 -{
86.452 - return malloc(size);
86.453 -}
86.454 -
86.455 -void operator delete(void *ptr)
86.456 -{
86.457 - free(ptr);
86.458 -}
86.459 -
86.460 -void operator delete[](void * ptr)
86.461 -{
86.462 - free(ptr);
86.463 -}
86.464 -#endif
86.465 -
87.1 --- a/extensions/topmenus/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
87.3 @@ -1,321 +0,0 @@
87.4 -/**
87.5 - * vim: set ts=4 :
87.6 - * =============================================================================
87.7 - * SourceMod Base Extension Code
87.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
87.9 - * =============================================================================
87.10 - *
87.11 - * This program is free software; you can redistribute it and/or modify it under
87.12 - * the terms of the GNU General Public License, version 3.0, as published by the
87.13 - * Free Software Foundation.
87.14 - *
87.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
87.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
87.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
87.18 - * details.
87.19 - *
87.20 - * You should have received a copy of the GNU General Public License along with
87.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
87.22 - *
87.23 - * As a special exception, AlliedModders LLC gives you permission to link the
87.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
87.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
87.26 - * by the Valve Corporation. You must obey the GNU General Public License in
87.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
87.28 - * this exception to all derivative works. AlliedModders LLC defines further
87.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
87.30 - * or <http://www.sourcemod.net/license.php>.
87.31 - *
87.32 - * Version: $Id$
87.33 - */
87.34 -
87.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
87.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
87.37 -
87.38 -/**
87.39 - * @file smsdk_ext.h
87.40 - * @brief Contains wrappers for making Extensions easier to write.
87.41 - */
87.42 -
87.43 -#include "smsdk_config.h"
87.44 -#include <IExtensionSys.h>
87.45 -#include <IHandleSys.h>
87.46 -#include <sp_vm_api.h>
87.47 -#include <sm_platform.h>
87.48 -#include <ISourceMod.h>
87.49 -#if defined SMEXT_ENABLE_FORWARDSYS
87.50 -#include <IForwardSys.h>
87.51 -#endif //SMEXT_ENABLE_FORWARDSYS
87.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
87.53 -#include <IPlayerHelpers.h>
87.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
87.55 -#if defined SMEXT_ENABLE_DBMANAGER
87.56 -#include <IDBDriver.h>
87.57 -#endif //SMEXT_ENABLE_DBMANAGER
87.58 -#if defined SMEXT_ENABLE_GAMECONF
87.59 -#include <IGameConfigs.h>
87.60 -#endif
87.61 -#if defined SMEXT_ENABLE_MEMUTILS
87.62 -#include <IMemoryUtils.h>
87.63 -#endif
87.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
87.65 -#include <IGameHelpers.h>
87.66 -#endif
87.67 -#if defined SMEXT_ENABLE_TIMERSYS
87.68 -#include <ITimerSystem.h>
87.69 -#endif
87.70 -#if defined SMEXT_ENABLE_ADTFACTORY
87.71 -#include <IADTFactory.h>
87.72 -#endif
87.73 -#if defined SMEXT_ENABLE_THREADER
87.74 -#include <IThreader.h>
87.75 -#endif
87.76 -#if defined SMEXT_ENABLE_LIBSYS
87.77 -#include <ILibrarySys.h>
87.78 -#endif
87.79 -#if defined SMEXT_ENABLE_PLUGINSYS
87.80 -#include <IPluginSys.h>
87.81 -#endif
87.82 -#if defined SMEXT_ENABLE_MENUS
87.83 -#include <IMenuManager.h>
87.84 -#endif
87.85 -#if defined SMEXT_ENABLE_ADMINSYS
87.86 -#include <IAdminSystem.h>
87.87 -#endif
87.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
87.89 -#include <ITextParsers.h>
87.90 -#endif
87.91 -
87.92 -#if defined SMEXT_CONF_METAMOD
87.93 -#include <ISmmPlugin.h>
87.94 -#include <eiface.h>
87.95 -#endif
87.96 -
87.97 -using namespace SourceMod;
87.98 -using namespace SourcePawn;
87.99 -
87.100 -class SDKExtension :
87.101 -#if defined SMEXT_CONF_METAMOD
87.102 - public ISmmPlugin,
87.103 -#endif
87.104 - public IExtensionInterface
87.105 -{
87.106 -public:
87.107 - /** Constructor */
87.108 - SDKExtension();
87.109 -public:
87.110 - /**
87.111 - * @brief This is called after the initial loading sequence has been processed.
87.112 - *
87.113 - * @param error Error message buffer.
87.114 - * @param maxlength Size of error message buffer.
87.115 - * @param late Whether or not the module was loaded after map load.
87.116 - * @return True to succeed loading, false to fail.
87.117 - */
87.118 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
87.119 -
87.120 - /**
87.121 - * @brief This is called right before the extension is unloaded.
87.122 - */
87.123 - virtual void SDK_OnUnload();
87.124 -
87.125 - /**
87.126 - * @brief This is called once all known extensions have been loaded.
87.127 - */
87.128 - virtual void SDK_OnAllLoaded();
87.129 -
87.130 - /**
87.131 - * @brief Called when the pause state is changed.
87.132 - */
87.133 - virtual void SDK_OnPauseChange(bool paused);
87.134 -
87.135 -#if defined SMEXT_CONF_METAMOD
87.136 - /**
87.137 - * @brief Called when Metamod is attached, before the extension version is called.
87.138 - *
87.139 - * @param error Error buffer.
87.140 - * @param maxlength Maximum size of error buffer.
87.141 - * @param late Whether or not Metamod considers this a late load.
87.142 - * @return True to succeed, false to fail.
87.143 - */
87.144 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
87.145 -
87.146 - /**
87.147 - * @brief Called when Metamod is detaching, after the extension version is called.
87.148 - * NOTE: By default this is blocked unless sent from SourceMod.
87.149 - *
87.150 - * @param error Error buffer.
87.151 - * @param maxlength Maximum size of error buffer.
87.152 - * @return True to succeed, false to fail.
87.153 - */
87.154 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
87.155 -
87.156 - /**
87.157 - * @brief Called when Metamod's pause state is changing.
87.158 - * NOTE: By default this is blocked unless sent from SourceMod.
87.159 - *
87.160 - * @param paused Pause state being set.
87.161 - * @param error Error buffer.
87.162 - * @param maxlength Maximum size of error buffer.
87.163 - * @return True to succeed, false to fail.
87.164 - */
87.165 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
87.166 -#endif
87.167 -
87.168 -public: //IExtensionInterface
87.169 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
87.170 - virtual void OnExtensionUnload();
87.171 - virtual void OnExtensionsAllLoaded();
87.172 -
87.173 - /** Returns whether or not this is a Metamod-based extension */
87.174 - virtual bool IsMetamodExtension();
87.175 -
87.176 - /**
87.177 - * @brief Called when the pause state changes.
87.178 - *
87.179 - * @param state True if being paused, false if being unpaused.
87.180 - */
87.181 - virtual void OnExtensionPauseChange(bool state);
87.182 -
87.183 - /** Returns name */
87.184 - virtual const char *GetExtensionName();
87.185 - /** Returns URL */
87.186 - virtual const char *GetExtensionURL();
87.187 - /** Returns log tag */
87.188 - virtual const char *GetExtensionTag();
87.189 - /** Returns author */
87.190 - virtual const char *GetExtensionAuthor();
87.191 - /** Returns version string */
87.192 - virtual const char *GetExtensionVerString();
87.193 - /** Returns description string */
87.194 - virtual const char *GetExtensionDescription();
87.195 - /** Returns date string */
87.196 - virtual const char *GetExtensionDateString();
87.197 -#if defined SMEXT_CONF_METAMOD
87.198 -public: //ISmmPlugin
87.199 - /** Called when the extension is attached to Metamod. */
87.200 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
87.201 - /** Returns the author to MM */
87.202 - virtual const char *GetAuthor();
87.203 - /** Returns the name to MM */
87.204 - virtual const char *GetName();
87.205 - /** Returns the description to MM */
87.206 - virtual const char *GetDescription();
87.207 - /** Returns the URL to MM */
87.208 - virtual const char *GetURL();
87.209 - /** Returns the license to MM */
87.210 - virtual const char *GetLicense();
87.211 - /** Returns the version string to MM */
87.212 - virtual const char *GetVersion();
87.213 - /** Returns the date string to MM */
87.214 - virtual const char *GetDate();
87.215 - /** Returns the logtag to MM */
87.216 - virtual const char *GetLogTag();
87.217 - /** Called on unload */
87.218 - virtual bool Unload(char *error, size_t maxlength);
87.219 - /** Called on pause */
87.220 - virtual bool Pause(char *error, size_t maxlength);
87.221 - /** Called on unpause */
87.222 - virtual bool Unpause(char *error, size_t maxlength);
87.223 -private:
87.224 - bool m_SourceMMLoaded;
87.225 - bool m_WeAreUnloaded;
87.226 - bool m_WeGotPauseChange;
87.227 -#endif
87.228 -};
87.229 -
87.230 -extern SDKExtension *g_pExtensionIface;
87.231 -extern IExtension *myself;
87.232 -
87.233 -extern IShareSys *g_pShareSys;
87.234 -extern IShareSys *sharesys; /* Note: Newer name */
87.235 -extern ISourceMod *g_pSM;
87.236 -extern ISourceMod *smutils; /* Note: Newer name */
87.237 -
87.238 -/* Optional interfaces are below */
87.239 -#if defined SMEXT_ENABLE_FORWARDSYS
87.240 -extern IForwardManager *g_pForwards;
87.241 -extern IForwardManager *forwards; /* Note: Newer name */
87.242 -#endif //SMEXT_ENABLE_FORWARDSYS
87.243 -#if defined SMEXT_ENABLE_HANDLESYS
87.244 -extern IHandleSys *g_pHandleSys;
87.245 -extern IHandleSys *handlesys; /* Note: Newer name */
87.246 -#endif //SMEXT_ENABLE_HANDLESYS
87.247 -#if defined SMEXT_ENABLE_PLAYERHELPERS
87.248 -extern IPlayerManager *playerhelpers;
87.249 -#endif //SMEXT_ENABLE_PLAYERHELPERS
87.250 -#if defined SMEXT_ENABLE_DBMANAGER
87.251 -extern IDBManager *dbi;
87.252 -#endif //SMEXT_ENABLE_DBMANAGER
87.253 -#if defined SMEXT_ENABLE_GAMECONF
87.254 -extern IGameConfigManager *gameconfs;
87.255 -#endif //SMEXT_ENABLE_DBMANAGER
87.256 -#if defined SMEXT_ENABLE_MEMUTILS
87.257 -extern IMemoryUtils *memutils;
87.258 -#endif
87.259 -#if defined SMEXT_ENABLE_GAMEHELPERS
87.260 -extern IGameHelpers *gamehelpers;
87.261 -#endif
87.262 -#if defined SMEXT_ENABLE_TIMERSYS
87.263 -extern ITimerSystem *timersys;
87.264 -#endif
87.265 -#if defined SMEXT_ENABLE_ADTFACTORY
87.266 -extern IADTFactory *adtfactory;
87.267 -#endif
87.268 -#if defined SMEXT_ENABLE_THREADER
87.269 -extern IThreader *threader;
87.270 -#endif
87.271 -#if defined SMEXT_ENABLE_LIBSYS
87.272 -extern ILibrarySys *libsys;
87.273 -#endif
87.274 -#if defined SMEXT_ENABLE_PLUGINSYS
87.275 -extern SourceMod::IPluginManager *plsys;
87.276 -#endif
87.277 -#if defined SMEXT_ENABLE_MENUS
87.278 -extern IMenuManager *menus;
87.279 -#endif
87.280 -#if defined SMEXT_ENABLE_ADMINSYS
87.281 -extern IAdminSystem *adminsys;
87.282 -#endif
87.283 -
87.284 -#if defined SMEXT_CONF_METAMOD
87.285 -PLUGIN_GLOBALVARS();
87.286 -extern IVEngineServer *engine;
87.287 -extern IServerGameDLL *gamedll;
87.288 -#endif
87.289 -
87.290 -/** Creates a SourceMod interface macro pair */
87.291 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
87.292 -/** Automates retrieving SourceMod interfaces */
87.293 -#define SM_GET_IFACE(prefix, addr) \
87.294 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
87.295 - { \
87.296 - if (error != NULL && maxlength) \
87.297 - { \
87.298 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
87.299 - if (len >= maxlength) \
87.300 - { \
87.301 - error[maxlength - 1] = '\0'; \
87.302 - } \
87.303 - } \
87.304 - return false; \
87.305 - }
87.306 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
87.307 -#define SM_GET_LATE_IFACE(prefix, addr) \
87.308 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
87.309 -/** Validates a SourceMod interface pointer */
87.310 -#define SM_CHECK_IFACE(prefix, addr) \
87.311 - if (!addr) \
87.312 - { \
87.313 - if (error != NULL && maxlength) \
87.314 - { \
87.315 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
87.316 - if (len >= maxlength) \
87.317 - { \
87.318 - error[maxlength - 1] = '\0'; \
87.319 - } \
87.320 - } \
87.321 - return false; \
87.322 - }
87.323 -
87.324 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
88.2 +++ b/extensions/topmenus/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
88.3 @@ -0,0 +1,78 @@
88.4 +/**
88.5 + * vim: set ts=4 :
88.6 + * =============================================================================
88.7 + * SourceMod TopMenus Extension
88.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
88.9 + * =============================================================================
88.10 + *
88.11 + * This program is free software; you can redistribute it and/or modify it under
88.12 + * the terms of the GNU General Public License, version 3.0, as published by the
88.13 + * Free Software Foundation.
88.14 + *
88.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
88.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
88.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
88.18 + * details.
88.19 + *
88.20 + * You should have received a copy of the GNU General Public License along with
88.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
88.22 + *
88.23 + * As a special exception, AlliedModders LLC gives you permission to link the
88.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
88.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
88.26 + * by the Valve Corporation. You must obey the GNU General Public License in
88.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
88.28 + * this exception to all derivative works. AlliedModders LLC defines further
88.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
88.30 + * or <http://www.sourcemod.net/license.php>.
88.31 + *
88.32 + * Version: $Id$
88.33 + */
88.34 +
88.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
88.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
88.37 +
88.38 +/**
88.39 + * @file smsdk_config.h
88.40 + * @brief Contains macros for configuring basic extension information.
88.41 + */
88.42 +
88.43 +/* Basic information exposed publicly */
88.44 +#define SMEXT_CONF_NAME "Top Menus"
88.45 +#define SMEXT_CONF_DESCRIPTION "Creates sorted nested menus"
88.46 +#define SMEXT_CONF_VERSION ""
88.47 +#define SMEXT_CONF_AUTHOR "AlliedModders"
88.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
88.49 +#define SMEXT_CONF_LOGTAG "TOPMENUS"
88.50 +#define SMEXT_CONF_LICENSE "GPLv3"
88.51 +#define SMEXT_CONF_DATESTRING ""
88.52 +
88.53 +/**
88.54 + * @brief Exposes plugin's main interface.
88.55 + */
88.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
88.57 +
88.58 +/**
88.59 + * @brief Sets whether or not this plugin required Metamod.
88.60 + * NOTE: Uncomment to enable, comment to disable.
88.61 + */
88.62 +//#define SMEXT_CONF_METAMOD
88.63 +
88.64 +/** Enable interfaces you want to use here by uncommenting lines */
88.65 +//#define SMEXT_ENABLE_FORWARDSYS
88.66 +#define SMEXT_ENABLE_HANDLESYS
88.67 +#define SMEXT_ENABLE_PLAYERHELPERS
88.68 +//#define SMEXT_ENABLE_DBMANAGER
88.69 +//#define SMEXT_ENABLE_GAMECONF
88.70 +//#define SMEXT_ENABLE_MEMUTILS
88.71 +//#define SMEXT_ENABLE_GAMEHELPERS
88.72 +//#define SMEXT_ENABLE_TIMERSYS
88.73 +//#define SMEXT_ENABLE_THREADER
88.74 +//#define SMEXT_ENABLE_LIBSYS
88.75 +#define SMEXT_ENABLE_MENUS
88.76 +//#define SMEXT_ENABLE_ADTFACTORY
88.77 +#define SMEXT_ENABLE_PLUGINSYS
88.78 +#define SMEXT_ENABLE_ADMINSYS
88.79 +#define SMEXT_ENABLE_TEXTPARSERS
88.80 +
88.81 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
89.1 --- a/extensions/updater/AMBuilder Wed Apr 23 21:40:50 2014 -0400
89.2 +++ b/extensions/updater/AMBuilder Wed Apr 23 21:19:28 2014 -0500
89.3 @@ -11,7 +11,7 @@
89.4 'MemoryDownloader.cpp',
89.5 'Updater.cpp',
89.6 'md5.cpp',
89.7 - 'sdk/smsdk_ext.cpp'
89.8 + '../../public/smsdk_ext.cpp'
89.9 ]
89.10
89.11 SM.extensions += [builder.Add(binary)]
90.1 --- a/extensions/updater/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,82 +0,0 @@
90.4 -/**
90.5 - * vim: set ts=4 :
90.6 - * =============================================================================
90.7 - * SourceMod Sample Extension
90.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
90.9 - * =============================================================================
90.10 - *
90.11 - * This program is free software; you can redistribute it and/or modify it under
90.12 - * the terms of the GNU General Public License, version 3.0, as published by the
90.13 - * Free Software Foundation.
90.14 - *
90.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
90.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
90.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
90.18 - * details.
90.19 - *
90.20 - * You should have received a copy of the GNU General Public License along with
90.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
90.22 - *
90.23 - * As a special exception, AlliedModders LLC gives you permission to link the
90.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
90.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
90.26 - * by the Valve Corporation. You must obey the GNU General Public License in
90.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
90.28 - * this exception to all derivative works. AlliedModders LLC defines further
90.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
90.30 - * or <http://www.sourcemod.net/license.php>.
90.31 - *
90.32 - * Version: $Id$
90.33 - */
90.34 -
90.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
90.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
90.37 -
90.38 -/**
90.39 - * @file smsdk_config.h
90.40 - * @brief Contains macros for configuring basic extension information.
90.41 - */
90.42 -
90.43 -/* Basic information exposed publicly */
90.44 -#define SMEXT_CONF_NAME "Automatic Updater"
90.45 -#define SMEXT_CONF_DESCRIPTION "Updates SourceMod gamedata files"
90.46 -#define SMEXT_CONF_VERSION ""
90.47 -#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
90.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
90.49 -#define SMEXT_CONF_LOGTAG "UPDATER"
90.50 -#define SMEXT_CONF_LICENSE "GPL"
90.51 -#define SMEXT_CONF_DATESTRING ""
90.52 -
90.53 -/**
90.54 - * @brief Exposes plugin's main interface.
90.55 - */
90.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
90.57 -
90.58 -/**
90.59 - * @brief Sets whether or not this plugin required Metamod.
90.60 - * NOTE: Uncomment to enable, comment to disable.
90.61 - */
90.62 -//#define SMEXT_CONF_METAMOD
90.63 -
90.64 -/** Enable interfaces you want to use here by uncommenting lines */
90.65 -//#define SMEXT_ENABLE_FORWARDSYS
90.66 -//#define SMEXT_ENABLE_HANDLESYS
90.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
90.68 -//#define SMEXT_ENABLE_DBMANAGER
90.69 -#define SMEXT_ENABLE_GAMECONF
90.70 -//#define SMEXT_ENABLE_MEMUTILS
90.71 -#define SMEXT_ENABLE_GAMEHELPERS
90.72 -//#define SMEXT_ENABLE_TIMERSYS
90.73 -#define SMEXT_ENABLE_THREADER
90.74 -#define SMEXT_ENABLE_LIBSYS
90.75 -//#define SMEXT_ENABLE_MENUS
90.76 -//#define SMEXT_ENABLE_ADTFACTORY
90.77 -//#define SMEXT_ENABLE_PLUGINSYS
90.78 -//#define SMEXT_ENABLE_ADMINSYS
90.79 -#define SMEXT_ENABLE_TEXTPARSERS
90.80 -//#define SMEXT_ENABLE_USERMSGS
90.81 -//#define SMEXT_ENABLE_TRANSLATOR
90.82 -//#define SMEXT_ENABLE_NINVOKE
90.83 -
90.84 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
90.85 -
91.1 --- a/extensions/updater/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
91.3 @@ -1,465 +0,0 @@
91.4 -/**
91.5 - * vim: set ts=4 :
91.6 - * =============================================================================
91.7 - * SourceMod Base Extension Code
91.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
91.9 - * =============================================================================
91.10 - *
91.11 - * This program is free software; you can redistribute it and/or modify it under
91.12 - * the terms of the GNU General Public License, version 3.0, as published by the
91.13 - * Free Software Foundation.
91.14 - *
91.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
91.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
91.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
91.18 - * details.
91.19 - *
91.20 - * You should have received a copy of the GNU General Public License along with
91.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
91.22 - *
91.23 - * As a special exception, AlliedModders LLC gives you permission to link the
91.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
91.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
91.26 - * by the Valve Corporation. You must obey the GNU General Public License in
91.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
91.28 - * this exception to all derivative works. AlliedModders LLC defines further
91.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
91.30 - * or <http://www.sourcemod.net/license.php>.
91.31 - *
91.32 - * Version: $Id$
91.33 - */
91.34 -
91.35 -#include <stdio.h>
91.36 -#include <stdlib.h>
91.37 -#include "smsdk_ext.h"
91.38 -
91.39 -/**
91.40 - * @file smsdk_ext.cpp
91.41 - * @brief Contains wrappers for making Extensions easier to write.
91.42 - */
91.43 -
91.44 -IExtension *myself = NULL; /**< Ourself */
91.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
91.46 -IShareSys *sharesys = NULL; /**< Share system */
91.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
91.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
91.49 -
91.50 -#if defined SMEXT_ENABLE_FORWARDSYS
91.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
91.52 -IForwardManager *forwards = NULL; /**< Forward system */
91.53 -#endif
91.54 -#if defined SMEXT_ENABLE_HANDLESYS
91.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
91.56 -IHandleSys *handlesys = NULL; /**< Handle system */
91.57 -#endif
91.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
91.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
91.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
91.61 -#if defined SMEXT_ENABLE_DBMANAGER
91.62 -IDBManager *dbi = NULL; /**< DB Manager */
91.63 -#endif //SMEXT_ENABLE_DBMANAGER
91.64 -#if defined SMEXT_ENABLE_GAMECONF
91.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
91.66 -#endif //SMEXT_ENABLE_DBMANAGER
91.67 -#if defined SMEXT_ENABLE_MEMUTILS
91.68 -IMemoryUtils *memutils = NULL;
91.69 -#endif //SMEXT_ENABLE_DBMANAGER
91.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
91.71 -IGameHelpers *gamehelpers = NULL;
91.72 -#endif
91.73 -#if defined SMEXT_ENABLE_TIMERSYS
91.74 -ITimerSystem *timersys = NULL;
91.75 -#endif
91.76 -#if defined SMEXT_ENABLE_ADTFACTORY
91.77 -IADTFactory *adtfactory = NULL;
91.78 -#endif
91.79 -#if defined SMEXT_ENABLE_THREADER
91.80 -IThreader *threader = NULL;
91.81 -#endif
91.82 -#if defined SMEXT_ENABLE_LIBSYS
91.83 -ILibrarySys *libsys = NULL;
91.84 -#endif
91.85 -#if defined SMEXT_ENABLE_PLUGINSYS
91.86 -SourceMod::IPluginManager *plsys;
91.87 -#endif
91.88 -#if defined SMEXT_ENABLE_MENUS
91.89 -IMenuManager *menus = NULL;
91.90 -#endif
91.91 -#if defined SMEXT_ENABLE_ADMINSYS
91.92 -IAdminSystem *adminsys = NULL;
91.93 -#endif
91.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
91.95 -ITextParsers *textparsers = NULL;
91.96 -#endif
91.97 -#if defined SMEXT_ENABLE_USERMSGS
91.98 -IUserMessages *usermsgs = NULL;
91.99 -#endif
91.100 -#if defined SMEXT_ENABLE_TRANSLATOR
91.101 -ITranslator *translator = NULL;
91.102 -#endif
91.103 -#if defined SMEXT_ENABLE_NINVOKE
91.104 -INativeInterface *ninvoke = NULL;
91.105 -#endif
91.106 -
91.107 -/** Exports the main interface */
91.108 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
91.109 -{
91.110 - return g_pExtensionIface;
91.111 -}
91.112 -
91.113 -SDKExtension::SDKExtension()
91.114 -{
91.115 -#if defined SMEXT_CONF_METAMOD
91.116 - m_SourceMMLoaded = false;
91.117 - m_WeAreUnloaded = false;
91.118 - m_WeGotPauseChange = false;
91.119 -#endif
91.120 -}
91.121 -
91.122 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
91.123 -{
91.124 - g_pShareSys = sharesys = sys;
91.125 - myself = me;
91.126 -
91.127 -#if defined SMEXT_CONF_METAMOD
91.128 - m_WeAreUnloaded = true;
91.129 -
91.130 - if (!m_SourceMMLoaded)
91.131 - {
91.132 - if (error)
91.133 - {
91.134 - snprintf(error, maxlength, "Metamod attach failed");
91.135 - }
91.136 - return false;
91.137 - }
91.138 -#endif
91.139 - SM_GET_IFACE(SOURCEMOD, g_pSM);
91.140 - smutils = g_pSM;
91.141 -#if defined SMEXT_ENABLE_HANDLESYS
91.142 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
91.143 - handlesys = g_pHandleSys;
91.144 -#endif
91.145 -#if defined SMEXT_ENABLE_FORWARDSYS
91.146 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
91.147 - forwards = g_pForwards;
91.148 -#endif
91.149 -#if defined SMEXT_ENABLE_PLAYERHELPERS
91.150 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
91.151 -#endif
91.152 -#if defined SMEXT_ENABLE_DBMANAGER
91.153 - SM_GET_IFACE(DBI, dbi);
91.154 -#endif
91.155 -#if defined SMEXT_ENABLE_GAMECONF
91.156 - SM_GET_IFACE(GAMECONFIG, gameconfs);
91.157 -#endif
91.158 -#if defined SMEXT_ENABLE_MEMUTILS
91.159 - SM_GET_IFACE(MEMORYUTILS, memutils);
91.160 -#endif
91.161 -#if defined SMEXT_ENABLE_GAMEHELPERS
91.162 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
91.163 -#endif
91.164 -#if defined SMEXT_ENABLE_TIMERSYS
91.165 - SM_GET_IFACE(TIMERSYS, timersys);
91.166 -#endif
91.167 -#if defined SMEXT_ENABLE_ADTFACTORY
91.168 - SM_GET_IFACE(ADTFACTORY, adtfactory);
91.169 -#endif
91.170 -#if defined SMEXT_ENABLE_THREADER
91.171 - SM_GET_IFACE(THREADER, threader);
91.172 -#endif
91.173 -#if defined SMEXT_ENABLE_LIBSYS
91.174 - SM_GET_IFACE(LIBRARYSYS, libsys);
91.175 -#endif
91.176 -#if defined SMEXT_ENABLE_PLUGINSYS
91.177 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
91.178 -#endif
91.179 -#if defined SMEXT_ENABLE_MENUS
91.180 - SM_GET_IFACE(MENUMANAGER, menus);
91.181 -#endif
91.182 -#if defined SMEXT_ENABLE_ADMINSYS
91.183 - SM_GET_IFACE(ADMINSYS, adminsys);
91.184 -#endif
91.185 -#if defined SMEXT_ENABLE_TEXTPARSERS
91.186 - SM_GET_IFACE(TEXTPARSERS, textparsers);
91.187 -#endif
91.188 -#if defined SMEXT_ENABLE_USERMSGS
91.189 - SM_GET_IFACE(USERMSGS, usermsgs);
91.190 -#endif
91.191 -#if defined SMEXT_ENABLE_TRANSLATOR
91.192 - SM_GET_IFACE(TRANSLATOR, translator);
91.193 -#endif
91.194 -
91.195 - if (SDK_OnLoad(error, maxlength, late))
91.196 - {
91.197 -#if defined SMEXT_CONF_METAMOD
91.198 - m_WeAreUnloaded = true;
91.199 -#endif
91.200 - return true;
91.201 - }
91.202 -
91.203 - return false;
91.204 -}
91.205 -
91.206 -bool SDKExtension::IsMetamodExtension()
91.207 -{
91.208 -#if defined SMEXT_CONF_METAMOD
91.209 - return true;
91.210 -#else
91.211 - return false;
91.212 -#endif
91.213 -}
91.214 -
91.215 -void SDKExtension::OnExtensionPauseChange(bool state)
91.216 -{
91.217 -#if defined SMEXT_CONF_METAMOD
91.218 - m_WeGotPauseChange = true;
91.219 -#endif
91.220 - SDK_OnPauseChange(state);
91.221 -}
91.222 -
91.223 -void SDKExtension::OnExtensionsAllLoaded()
91.224 -{
91.225 - SDK_OnAllLoaded();
91.226 -}
91.227 -
91.228 -void SDKExtension::OnExtensionUnload()
91.229 -{
91.230 -#if defined SMEXT_CONF_METAMOD
91.231 - m_WeAreUnloaded = true;
91.232 -#endif
91.233 - SDK_OnUnload();
91.234 -}
91.235 -
91.236 -const char *SDKExtension::GetExtensionAuthor()
91.237 -{
91.238 - return SMEXT_CONF_AUTHOR;
91.239 -}
91.240 -
91.241 -const char *SDKExtension::GetExtensionDateString()
91.242 -{
91.243 - return SMEXT_CONF_DATESTRING;
91.244 -}
91.245 -
91.246 -const char *SDKExtension::GetExtensionDescription()
91.247 -{
91.248 - return SMEXT_CONF_DESCRIPTION;
91.249 -}
91.250 -
91.251 -const char *SDKExtension::GetExtensionVerString()
91.252 -{
91.253 - return SMEXT_CONF_VERSION;
91.254 -}
91.255 -
91.256 -const char *SDKExtension::GetExtensionName()
91.257 -{
91.258 - return SMEXT_CONF_NAME;
91.259 -}
91.260 -
91.261 -const char *SDKExtension::GetExtensionTag()
91.262 -{
91.263 - return SMEXT_CONF_LOGTAG;
91.264 -}
91.265 -
91.266 -const char *SDKExtension::GetExtensionURL()
91.267 -{
91.268 - return SMEXT_CONF_URL;
91.269 -}
91.270 -
91.271 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
91.272 -{
91.273 - return true;
91.274 -}
91.275 -
91.276 -void SDKExtension::SDK_OnUnload()
91.277 -{
91.278 -}
91.279 -
91.280 -void SDKExtension::SDK_OnPauseChange(bool paused)
91.281 -{
91.282 -}
91.283 -
91.284 -void SDKExtension::SDK_OnAllLoaded()
91.285 -{
91.286 -}
91.287 -
91.288 -#if defined SMEXT_CONF_METAMOD
91.289 -
91.290 -PluginId g_PLID = 0; /**< Metamod plugin ID */
91.291 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
91.292 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
91.293 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
91.294 -
91.295 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
91.296 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
91.297 -
91.298 -/** Exposes the extension to Metamod */
91.299 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
91.300 -{
91.301 -#if defined METAMOD_PLAPI_VERSION
91.302 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
91.303 -#else
91.304 - if (name && !strcmp(name, PLAPI_NAME))
91.305 -#endif
91.306 - {
91.307 - if (code)
91.308 - {
91.309 - *code = IFACE_OK;
91.310 - }
91.311 - return static_cast<void *>(g_pExtensionIface);
91.312 - }
91.313 -
91.314 - if (code)
91.315 - {
91.316 - *code = IFACE_FAILED;
91.317 - }
91.318 -
91.319 - return NULL;
91.320 -}
91.321 -
91.322 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
91.323 -{
91.324 - PLUGIN_SAVEVARS();
91.325 -
91.326 -#if !defined METAMOD_PLAPI_VERSION
91.327 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
91.328 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
91.329 -#else
91.330 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
91.331 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
91.332 -#endif
91.333 -
91.334 - m_SourceMMLoaded = true;
91.335 -
91.336 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
91.337 -}
91.338 -
91.339 -bool SDKExtension::Unload(char *error, size_t maxlen)
91.340 -{
91.341 - if (!m_WeAreUnloaded)
91.342 - {
91.343 - if (error)
91.344 - {
91.345 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
91.346 - }
91.347 - return false;
91.348 - }
91.349 -
91.350 - return SDK_OnMetamodUnload(error, maxlen);
91.351 -}
91.352 -
91.353 -bool SDKExtension::Pause(char *error, size_t maxlen)
91.354 -{
91.355 - if (!m_WeGotPauseChange)
91.356 - {
91.357 - if (error)
91.358 - {
91.359 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
91.360 - }
91.361 - return false;
91.362 - }
91.363 -
91.364 - m_WeGotPauseChange = false;
91.365 -
91.366 - return SDK_OnMetamodPauseChange(true, error, maxlen);
91.367 -}
91.368 -
91.369 -bool SDKExtension::Unpause(char *error, size_t maxlen)
91.370 -{
91.371 - if (!m_WeGotPauseChange)
91.372 - {
91.373 - if (error)
91.374 - {
91.375 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
91.376 - }
91.377 - return false;
91.378 - }
91.379 -
91.380 - m_WeGotPauseChange = false;
91.381 -
91.382 - return SDK_OnMetamodPauseChange(false, error, maxlen);
91.383 -}
91.384 -
91.385 -const char *SDKExtension::GetAuthor()
91.386 -{
91.387 - return GetExtensionAuthor();
91.388 -}
91.389 -
91.390 -const char *SDKExtension::GetDate()
91.391 -{
91.392 - return GetExtensionDateString();
91.393 -}
91.394 -
91.395 -const char *SDKExtension::GetDescription()
91.396 -{
91.397 - return GetExtensionDescription();
91.398 -}
91.399 -
91.400 -const char *SDKExtension::GetLicense()
91.401 -{
91.402 - return SMEXT_CONF_LICENSE;
91.403 -}
91.404 -
91.405 -const char *SDKExtension::GetLogTag()
91.406 -{
91.407 - return GetExtensionTag();
91.408 -}
91.409 -
91.410 -const char *SDKExtension::GetName()
91.411 -{
91.412 - return GetExtensionName();
91.413 -}
91.414 -
91.415 -const char *SDKExtension::GetURL()
91.416 -{
91.417 - return GetExtensionURL();
91.418 -}
91.419 -
91.420 -const char *SDKExtension::GetVersion()
91.421 -{
91.422 - return GetExtensionVerString();
91.423 -}
91.424 -
91.425 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
91.426 -{
91.427 - return true;
91.428 -}
91.429 -
91.430 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
91.431 -{
91.432 - return true;
91.433 -}
91.434 -
91.435 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
91.436 -{
91.437 - return true;
91.438 -}
91.439 -
91.440 -#endif
91.441 -
91.442 -/* Overload a few things to prevent libstdc++ linking */
91.443 -#if defined __linux__ || defined __APPLE__
91.444 -extern "C" void __cxa_pure_virtual(void)
91.445 -{
91.446 -}
91.447 -
91.448 -void *operator new(size_t size)
91.449 -{
91.450 - return malloc(size);
91.451 -}
91.452 -
91.453 -void *operator new[](size_t size)
91.454 -{
91.455 - return malloc(size);
91.456 -}
91.457 -
91.458 -void operator delete(void *ptr)
91.459 -{
91.460 - free(ptr);
91.461 -}
91.462 -
91.463 -void operator delete[](void * ptr)
91.464 -{
91.465 - free(ptr);
91.466 -}
91.467 -#endif
91.468 -
92.1 --- a/extensions/updater/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
92.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
92.3 @@ -1,339 +0,0 @@
92.4 -/**
92.5 - * vim: set ts=4 :
92.6 - * =============================================================================
92.7 - * SourceMod Base Extension Code
92.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
92.9 - * =============================================================================
92.10 - *
92.11 - * This program is free software; you can redistribute it and/or modify it under
92.12 - * the terms of the GNU General Public License, version 3.0, as published by the
92.13 - * Free Software Foundation.
92.14 - *
92.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
92.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
92.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
92.18 - * details.
92.19 - *
92.20 - * You should have received a copy of the GNU General Public License along with
92.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
92.22 - *
92.23 - * As a special exception, AlliedModders LLC gives you permission to link the
92.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
92.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
92.26 - * by the Valve Corporation. You must obey the GNU General Public License in
92.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
92.28 - * this exception to all derivative works. AlliedModders LLC defines further
92.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
92.30 - * or <http://www.sourcemod.net/license.php>.
92.31 - *
92.32 - * Version: $Id$
92.33 - */
92.34 -
92.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
92.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
92.37 -
92.38 -/**
92.39 - * @file smsdk_ext.h
92.40 - * @brief Contains wrappers for making Extensions easier to write.
92.41 - */
92.42 -
92.43 -#include "smsdk_config.h"
92.44 -#include <IExtensionSys.h>
92.45 -#include <IHandleSys.h>
92.46 -#include <sp_vm_api.h>
92.47 -#include <sm_platform.h>
92.48 -#include <ISourceMod.h>
92.49 -#if defined SMEXT_ENABLE_FORWARDSYS
92.50 -#include <IForwardSys.h>
92.51 -#endif //SMEXT_ENABLE_FORWARDSYS
92.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
92.53 -#include <IPlayerHelpers.h>
92.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
92.55 -#if defined SMEXT_ENABLE_DBMANAGER
92.56 -#include <IDBDriver.h>
92.57 -#endif //SMEXT_ENABLE_DBMANAGER
92.58 -#if defined SMEXT_ENABLE_GAMECONF
92.59 -#include <IGameConfigs.h>
92.60 -#endif
92.61 -#if defined SMEXT_ENABLE_MEMUTILS
92.62 -#include <IMemoryUtils.h>
92.63 -#endif
92.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
92.65 -#include <IGameHelpers.h>
92.66 -#endif
92.67 -#if defined SMEXT_ENABLE_TIMERSYS
92.68 -#include <ITimerSystem.h>
92.69 -#endif
92.70 -#if defined SMEXT_ENABLE_ADTFACTORY
92.71 -#include <IADTFactory.h>
92.72 -#endif
92.73 -#if defined SMEXT_ENABLE_THREADER
92.74 -#include <IThreader.h>
92.75 -#endif
92.76 -#if defined SMEXT_ENABLE_LIBSYS
92.77 -#include <ILibrarySys.h>
92.78 -#endif
92.79 -#if defined SMEXT_ENABLE_PLUGINSYS
92.80 -#include <IPluginSys.h>
92.81 -#endif
92.82 -#if defined SMEXT_ENABLE_MENUS
92.83 -#include <IMenuManager.h>
92.84 -#endif
92.85 -#if defined SMEXT_ENABLE_ADMINSYS
92.86 -#include <IAdminSystem.h>
92.87 -#endif
92.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
92.89 -#include <ITextParsers.h>
92.90 -#endif
92.91 -#if defined SMEXT_ENABLE_USERMSGS
92.92 -#include <IUserMessages.h>
92.93 -#endif
92.94 -#if defined SMEXT_ENABLE_TRANSLATOR
92.95 -#include <ITranslator.h>
92.96 -#endif
92.97 -#if defined SMEXT_ENABLE_NINVOKE
92.98 -#include <INativeInvoker.h>
92.99 -#endif
92.100 -
92.101 -#if defined SMEXT_CONF_METAMOD
92.102 -#include <ISmmPlugin.h>
92.103 -#include <eiface.h>
92.104 -#endif
92.105 -
92.106 -using namespace SourceMod;
92.107 -using namespace SourcePawn;
92.108 -
92.109 -class SDKExtension :
92.110 -#if defined SMEXT_CONF_METAMOD
92.111 - public ISmmPlugin,
92.112 -#endif
92.113 - public IExtensionInterface
92.114 -{
92.115 -public:
92.116 - /** Constructor */
92.117 - SDKExtension();
92.118 -public:
92.119 - /**
92.120 - * @brief This is called after the initial loading sequence has been processed.
92.121 - *
92.122 - * @param error Error message buffer.
92.123 - * @param maxlength Size of error message buffer.
92.124 - * @param late Whether or not the module was loaded after map load.
92.125 - * @return True to succeed loading, false to fail.
92.126 - */
92.127 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
92.128 -
92.129 - /**
92.130 - * @brief This is called right before the extension is unloaded.
92.131 - */
92.132 - virtual void SDK_OnUnload();
92.133 -
92.134 - /**
92.135 - * @brief This is called once all known extensions have been loaded.
92.136 - */
92.137 - virtual void SDK_OnAllLoaded();
92.138 -
92.139 - /**
92.140 - * @brief Called when the pause state is changed.
92.141 - */
92.142 - virtual void SDK_OnPauseChange(bool paused);
92.143 -
92.144 -#if defined SMEXT_CONF_METAMOD
92.145 - /**
92.146 - * @brief Called when Metamod is attached, before the extension version is called.
92.147 - *
92.148 - * @param error Error buffer.
92.149 - * @param maxlength Maximum size of error buffer.
92.150 - * @param late Whether or not Metamod considers this a late load.
92.151 - * @return True to succeed, false to fail.
92.152 - */
92.153 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
92.154 -
92.155 - /**
92.156 - * @brief Called when Metamod is detaching, after the extension version is called.
92.157 - * NOTE: By default this is blocked unless sent from SourceMod.
92.158 - *
92.159 - * @param error Error buffer.
92.160 - * @param maxlength Maximum size of error buffer.
92.161 - * @return True to succeed, false to fail.
92.162 - */
92.163 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
92.164 -
92.165 - /**
92.166 - * @brief Called when Metamod's pause state is changing.
92.167 - * NOTE: By default this is blocked unless sent from SourceMod.
92.168 - *
92.169 - * @param paused Pause state being set.
92.170 - * @param error Error buffer.
92.171 - * @param maxlength Maximum size of error buffer.
92.172 - * @return True to succeed, false to fail.
92.173 - */
92.174 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
92.175 -#endif
92.176 -
92.177 -public: //IExtensionInterface
92.178 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
92.179 - virtual void OnExtensionUnload();
92.180 - virtual void OnExtensionsAllLoaded();
92.181 -
92.182 - /** Returns whether or not this is a Metamod-based extension */
92.183 - virtual bool IsMetamodExtension();
92.184 -
92.185 - /**
92.186 - * @brief Called when the pause state changes.
92.187 - *
92.188 - * @param state True if being paused, false if being unpaused.
92.189 - */
92.190 - virtual void OnExtensionPauseChange(bool state);
92.191 -
92.192 - /** Returns name */
92.193 - virtual const char *GetExtensionName();
92.194 - /** Returns URL */
92.195 - virtual const char *GetExtensionURL();
92.196 - /** Returns log tag */
92.197 - virtual const char *GetExtensionTag();
92.198 - /** Returns author */
92.199 - virtual const char *GetExtensionAuthor();
92.200 - /** Returns version string */
92.201 - virtual const char *GetExtensionVerString();
92.202 - /** Returns description string */
92.203 - virtual const char *GetExtensionDescription();
92.204 - /** Returns date string */
92.205 - virtual const char *GetExtensionDateString();
92.206 -#if defined SMEXT_CONF_METAMOD
92.207 -public: //ISmmPlugin
92.208 - /** Called when the extension is attached to Metamod. */
92.209 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
92.210 - /** Returns the author to MM */
92.211 - virtual const char *GetAuthor();
92.212 - /** Returns the name to MM */
92.213 - virtual const char *GetName();
92.214 - /** Returns the description to MM */
92.215 - virtual const char *GetDescription();
92.216 - /** Returns the URL to MM */
92.217 - virtual const char *GetURL();
92.218 - /** Returns the license to MM */
92.219 - virtual const char *GetLicense();
92.220 - /** Returns the version string to MM */
92.221 - virtual const char *GetVersion();
92.222 - /** Returns the date string to MM */
92.223 - virtual const char *GetDate();
92.224 - /** Returns the logtag to MM */
92.225 - virtual const char *GetLogTag();
92.226 - /** Called on unload */
92.227 - virtual bool Unload(char *error, size_t maxlength);
92.228 - /** Called on pause */
92.229 - virtual bool Pause(char *error, size_t maxlength);
92.230 - /** Called on unpause */
92.231 - virtual bool Unpause(char *error, size_t maxlength);
92.232 -private:
92.233 - bool m_SourceMMLoaded;
92.234 - bool m_WeAreUnloaded;
92.235 - bool m_WeGotPauseChange;
92.236 -#endif
92.237 -};
92.238 -
92.239 -extern SDKExtension *g_pExtensionIface;
92.240 -extern IExtension *myself;
92.241 -
92.242 -extern IShareSys *g_pShareSys;
92.243 -extern IShareSys *sharesys; /* Note: Newer name */
92.244 -extern ISourceMod *g_pSM;
92.245 -extern ISourceMod *smutils; /* Note: Newer name */
92.246 -
92.247 -/* Optional interfaces are below */
92.248 -#if defined SMEXT_ENABLE_FORWARDSYS
92.249 -extern IForwardManager *g_pForwards;
92.250 -extern IForwardManager *forwards; /* Note: Newer name */
92.251 -#endif //SMEXT_ENABLE_FORWARDSYS
92.252 -#if defined SMEXT_ENABLE_HANDLESYS
92.253 -extern IHandleSys *g_pHandleSys;
92.254 -extern IHandleSys *handlesys; /* Note: Newer name */
92.255 -#endif //SMEXT_ENABLE_HANDLESYS
92.256 -#if defined SMEXT_ENABLE_PLAYERHELPERS
92.257 -extern IPlayerManager *playerhelpers;
92.258 -#endif //SMEXT_ENABLE_PLAYERHELPERS
92.259 -#if defined SMEXT_ENABLE_DBMANAGER
92.260 -extern IDBManager *dbi;
92.261 -#endif //SMEXT_ENABLE_DBMANAGER
92.262 -#if defined SMEXT_ENABLE_GAMECONF
92.263 -extern IGameConfigManager *gameconfs;
92.264 -#endif //SMEXT_ENABLE_DBMANAGER
92.265 -#if defined SMEXT_ENABLE_MEMUTILS
92.266 -extern IMemoryUtils *memutils;
92.267 -#endif
92.268 -#if defined SMEXT_ENABLE_GAMEHELPERS
92.269 -extern IGameHelpers *gamehelpers;
92.270 -#endif
92.271 -#if defined SMEXT_ENABLE_TIMERSYS
92.272 -extern ITimerSystem *timersys;
92.273 -#endif
92.274 -#if defined SMEXT_ENABLE_ADTFACTORY
92.275 -extern IADTFactory *adtfactory;
92.276 -#endif
92.277 -#if defined SMEXT_ENABLE_THREADER
92.278 -extern IThreader *threader;
92.279 -#endif
92.280 -#if defined SMEXT_ENABLE_LIBSYS
92.281 -extern ILibrarySys *libsys;
92.282 -#endif
92.283 -#if defined SMEXT_ENABLE_PLUGINSYS
92.284 -extern SourceMod::IPluginManager *plsys;
92.285 -#endif
92.286 -#if defined SMEXT_ENABLE_MENUS
92.287 -extern IMenuManager *menus;
92.288 -#endif
92.289 -#if defined SMEXT_ENABLE_ADMINSYS
92.290 -extern IAdminSystem *adminsys;
92.291 -#endif
92.292 -#if defined SMEXT_ENABLE_USERMSGS
92.293 -extern IUserMessages *usermsgs;
92.294 -#endif
92.295 -#if defined SMEXT_ENABLE_TRANSLATOR
92.296 -extern ITranslator *translator;
92.297 -#endif
92.298 -#if defined SMEXT_ENABLE_NINVOKE
92.299 -extern INativeInterface *ninvoke;
92.300 -#endif
92.301 -
92.302 -#if defined SMEXT_CONF_METAMOD
92.303 -PLUGIN_GLOBALVARS();
92.304 -extern IVEngineServer *engine;
92.305 -extern IServerGameDLL *gamedll;
92.306 -#endif
92.307 -
92.308 -/** Creates a SourceMod interface macro pair */
92.309 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
92.310 -/** Automates retrieving SourceMod interfaces */
92.311 -#define SM_GET_IFACE(prefix, addr) \
92.312 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
92.313 - { \
92.314 - if (error != NULL && maxlength) \
92.315 - { \
92.316 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
92.317 - if (len >= maxlength) \
92.318 - { \
92.319 - error[maxlength - 1] = '\0'; \
92.320 - } \
92.321 - } \
92.322 - return false; \
92.323 - }
92.324 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
92.325 -#define SM_GET_LATE_IFACE(prefix, addr) \
92.326 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
92.327 -/** Validates a SourceMod interface pointer */
92.328 -#define SM_CHECK_IFACE(prefix, addr) \
92.329 - if (!addr) \
92.330 - { \
92.331 - if (error != NULL && maxlength) \
92.332 - { \
92.333 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
92.334 - if (len >= maxlength) \
92.335 - { \
92.336 - error[maxlength - 1] = '\0'; \
92.337 - } \
92.338 - } \
92.339 - return false; \
92.340 - }
92.341 -
92.342 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/extensions/updater/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
93.3 @@ -0,0 +1,82 @@
93.4 +/**
93.5 + * vim: set ts=4 :
93.6 + * =============================================================================
93.7 + * SourceMod Sample Extension
93.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
93.9 + * =============================================================================
93.10 + *
93.11 + * This program is free software; you can redistribute it and/or modify it under
93.12 + * the terms of the GNU General Public License, version 3.0, as published by the
93.13 + * Free Software Foundation.
93.14 + *
93.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
93.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
93.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
93.18 + * details.
93.19 + *
93.20 + * You should have received a copy of the GNU General Public License along with
93.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
93.22 + *
93.23 + * As a special exception, AlliedModders LLC gives you permission to link the
93.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
93.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
93.26 + * by the Valve Corporation. You must obey the GNU General Public License in
93.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
93.28 + * this exception to all derivative works. AlliedModders LLC defines further
93.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
93.30 + * or <http://www.sourcemod.net/license.php>.
93.31 + *
93.32 + * Version: $Id$
93.33 + */
93.34 +
93.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
93.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
93.37 +
93.38 +/**
93.39 + * @file smsdk_config.h
93.40 + * @brief Contains macros for configuring basic extension information.
93.41 + */
93.42 +
93.43 +/* Basic information exposed publicly */
93.44 +#define SMEXT_CONF_NAME "Automatic Updater"
93.45 +#define SMEXT_CONF_DESCRIPTION "Updates SourceMod gamedata files"
93.46 +#define SMEXT_CONF_VERSION ""
93.47 +#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
93.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
93.49 +#define SMEXT_CONF_LOGTAG "UPDATER"
93.50 +#define SMEXT_CONF_LICENSE "GPL"
93.51 +#define SMEXT_CONF_DATESTRING ""
93.52 +
93.53 +/**
93.54 + * @brief Exposes plugin's main interface.
93.55 + */
93.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
93.57 +
93.58 +/**
93.59 + * @brief Sets whether or not this plugin required Metamod.
93.60 + * NOTE: Uncomment to enable, comment to disable.
93.61 + */
93.62 +//#define SMEXT_CONF_METAMOD
93.63 +
93.64 +/** Enable interfaces you want to use here by uncommenting lines */
93.65 +//#define SMEXT_ENABLE_FORWARDSYS
93.66 +//#define SMEXT_ENABLE_HANDLESYS
93.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
93.68 +//#define SMEXT_ENABLE_DBMANAGER
93.69 +#define SMEXT_ENABLE_GAMECONF
93.70 +//#define SMEXT_ENABLE_MEMUTILS
93.71 +#define SMEXT_ENABLE_GAMEHELPERS
93.72 +//#define SMEXT_ENABLE_TIMERSYS
93.73 +#define SMEXT_ENABLE_THREADER
93.74 +#define SMEXT_ENABLE_LIBSYS
93.75 +//#define SMEXT_ENABLE_MENUS
93.76 +//#define SMEXT_ENABLE_ADTFACTORY
93.77 +//#define SMEXT_ENABLE_PLUGINSYS
93.78 +//#define SMEXT_ENABLE_ADMINSYS
93.79 +#define SMEXT_ENABLE_TEXTPARSERS
93.80 +//#define SMEXT_ENABLE_USERMSGS
93.81 +//#define SMEXT_ENABLE_TRANSLATOR
93.82 +//#define SMEXT_ENABLE_NINVOKE
93.83 +
93.84 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
93.85 +
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94.2 +++ b/public/CDetour/detourhelpers.h Wed Apr 23 21:19:28 2014 -0500
94.3 @@ -0,0 +1,100 @@
94.4 +/**
94.5 + * vim: set ts=4 :
94.6 + * =============================================================================
94.7 + * SourceMod
94.8 + * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
94.9 + * =============================================================================
94.10 + *
94.11 + * This program is free software; you can redistribute it and/or modify it under
94.12 + * the terms of the GNU General Public License, version 3.0, as published by the
94.13 + * Free Software Foundation.
94.14 + *
94.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
94.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
94.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
94.18 + * details.
94.19 + *
94.20 + * You should have received a copy of the GNU General Public License along with
94.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
94.22 + *
94.23 + * As a special exception, AlliedModders LLC gives you permission to link the
94.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
94.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
94.26 + * by the Valve Corporation. You must obey the GNU General Public License in
94.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
94.28 + * this exception to all derivative works. AlliedModders LLC defines further
94.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
94.30 + * or <http://www.sourcemod.net/license.php>.
94.31 + *
94.32 + * Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $
94.33 + */
94.34 +
94.35 +#ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
94.36 +#define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
94.37 +
94.38 +#if defined PLATFORM_POSIX
94.39 +#include <sys/mman.h>
94.40 +#ifndef PAGE_SIZE
94.41 +#define PAGE_SIZE 4096
94.42 +#endif
94.43 +#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
94.44 +#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
94.45 +#endif
94.46 +
94.47 +struct patch_t
94.48 +{
94.49 + patch_t()
94.50 + {
94.51 + patch[0] = 0;
94.52 + bytes = 0;
94.53 + }
94.54 + unsigned char patch[20];
94.55 + size_t bytes;
94.56 +};
94.57 +
94.58 +inline void ProtectMemory(void *addr, int length, int prot)
94.59 +{
94.60 +#if defined PLATFORM_POSIX
94.61 + void *addr2 = (void *)ALIGN(addr);
94.62 + mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
94.63 +#elif defined PLATFORM_WINDOWS
94.64 + DWORD old_prot;
94.65 + VirtualProtect(addr, length, prot, &old_prot);
94.66 +#endif
94.67 +}
94.68 +
94.69 +inline void SetMemPatchable(void *address, size_t size)
94.70 +{
94.71 + ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
94.72 +}
94.73 +
94.74 +inline void DoGatePatch(unsigned char *target, void *callback)
94.75 +{
94.76 + SetMemPatchable(target, 20);
94.77 +
94.78 + target[0] = 0xFF; /* JMP */
94.79 + target[1] = 0x25; /* MEM32 */
94.80 + *(void **)(&target[2]) = callback;
94.81 +}
94.82 +
94.83 +inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
94.84 +{
94.85 + ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
94.86 +
94.87 + unsigned char *addr = (unsigned char *)address + offset;
94.88 + if (restore)
94.89 + {
94.90 + for (size_t i=0; i<patch->bytes; i++)
94.91 + {
94.92 + restore->patch[i] = addr[i];
94.93 + }
94.94 + restore->bytes = patch->bytes;
94.95 + }
94.96 +
94.97 + for (size_t i=0; i<patch->bytes; i++)
94.98 + {
94.99 + addr[i] = patch->patch[i];
94.100 + }
94.101 +}
94.102 +
94.103 +#endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_
95.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
95.2 +++ b/public/CDetour/detours.cpp Wed Apr 23 21:19:28 2014 -0500
95.3 @@ -0,0 +1,192 @@
95.4 +/**
95.5 +* vim: set ts=4 :
95.6 +* =============================================================================
95.7 +* SourceMod
95.8 +* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
95.9 +* =============================================================================
95.10 +*
95.11 +* This program is free software; you can redistribute it and/or modify it under
95.12 +* the terms of the GNU General Public License, version 3.0, as published by the
95.13 +* Free Software Foundation.
95.14 +*
95.15 +* This program is distributed in the hope that it will be useful, but WITHOUT
95.16 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
95.17 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
95.18 +* details.
95.19 +*
95.20 +* You should have received a copy of the GNU General Public License along with
95.21 +* this program. If not, see <http://www.gnu.org/licenses/>.
95.22 +*
95.23 +* As a special exception, AlliedModders LLC gives you permission to link the
95.24 +* code of this program (as well as its derivative works) to "Half-Life 2," the
95.25 +* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
95.26 +* by the Valve Corporation. You must obey the GNU General Public License in
95.27 +* all respects for all other code used. Additionally, AlliedModders LLC grants
95.28 +* this exception to all derivative works. AlliedModders LLC defines further
95.29 +* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
95.30 +* or <http://www.sourcemod.net/license.php>.
95.31 +*
95.32 +* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
95.33 +*/
95.34 +
95.35 +#include "detours.h"
95.36 +#include <asm/asm.h>
95.37 +
95.38 +ISourcePawnEngine *CDetourManager::spengine = NULL;
95.39 +IGameConfig *CDetourManager::gameconf = NULL;
95.40 +
95.41 +void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
95.42 +{
95.43 + CDetourManager::spengine = spengine;
95.44 + CDetourManager::gameconf = gameconf;
95.45 +}
95.46 +
95.47 +CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
95.48 +{
95.49 + CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
95.50 + if (detour)
95.51 + {
95.52 + if (!detour->Init(spengine, gameconf))
95.53 + {
95.54 + delete detour;
95.55 + return NULL;
95.56 + }
95.57 +
95.58 + return detour;
95.59 + }
95.60 +
95.61 + return NULL;
95.62 +}
95.63 +
95.64 +CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
95.65 +{
95.66 + enabled = false;
95.67 + detoured = false;
95.68 + detour_address = NULL;
95.69 + detour_trampoline = NULL;
95.70 + this->signame = signame;
95.71 + this->detour_callback = callbackfunction;
95.72 + spengine = NULL;
95.73 + gameconf = NULL;
95.74 + this->trampoline = trampoline;
95.75 +}
95.76 +
95.77 +bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
95.78 +{
95.79 + this->spengine = spengine;
95.80 + this->gameconf = gameconf;
95.81 +
95.82 + if (!CreateDetour())
95.83 + {
95.84 + enabled = false;
95.85 + return enabled;
95.86 + }
95.87 +
95.88 + enabled = true;
95.89 +
95.90 + return enabled;
95.91 +}
95.92 +
95.93 +void CDetour::Destroy()
95.94 +{
95.95 + DeleteDetour();
95.96 + delete this;
95.97 +}
95.98 +
95.99 +bool CDetour::IsEnabled()
95.100 +{
95.101 + return enabled;
95.102 +}
95.103 +
95.104 +bool CDetour::CreateDetour()
95.105 +{
95.106 + if (!gameconf->GetMemSig(signame, &detour_address))
95.107 + {
95.108 + g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame);
95.109 + return false;
95.110 + }
95.111 +
95.112 + if (!detour_address)
95.113 + {
95.114 + g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame);
95.115 + return false;
95.116 + }
95.117 +
95.118 + detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE+1);
95.119 +
95.120 + /* First, save restore bits */
95.121 + for (size_t i=0; i<detour_restore.bytes; i++)
95.122 + {
95.123 + detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
95.124 + }
95.125 +
95.126 + JitWriter wr;
95.127 + JitWriter *jit = ≀
95.128 + jit_uint32_t CodeSize = 0;
95.129 +
95.130 + wr.outbase = NULL;
95.131 + wr.outptr = NULL;
95.132 +
95.133 +jit_rewind:
95.134 +
95.135 + /* Patch old bytes in */
95.136 + if (wr.outbase != NULL)
95.137 + {
95.138 + copy_bytes((unsigned char *)detour_address, (unsigned char*)wr.outptr, detour_restore.bytes);
95.139 + }
95.140 + wr.outptr += detour_restore.bytes;
95.141 +
95.142 + /* Return to the original function */
95.143 + jitoffs_t call = IA32_Jump_Imm32(jit, 0);
95.144 + IA32_Write_Jump32_Abs(jit, call, (unsigned char *)detour_address + detour_restore.bytes);
95.145 +
95.146 + if (wr.outbase == NULL)
95.147 + {
95.148 + CodeSize = wr.get_outputpos();
95.149 + wr.outbase = (jitcode_t)spengine->AllocatePageMemory(CodeSize);
95.150 + spengine->SetReadWrite(wr.outbase);
95.151 + wr.outptr = wr.outbase;
95.152 + detour_trampoline = wr.outbase;
95.153 + goto jit_rewind;
95.154 + }
95.155 +
95.156 + spengine->SetReadExecute(wr.outbase);
95.157 +
95.158 + *trampoline = detour_trampoline;
95.159 +
95.160 + return true;
95.161 +}
95.162 +
95.163 +void CDetour::DeleteDetour()
95.164 +{
95.165 + if (detoured)
95.166 + {
95.167 + DisableDetour();
95.168 + }
95.169 +
95.170 + if (detour_trampoline)
95.171 + {
95.172 + /* Free the allocated trampoline memory */
95.173 + spengine->FreePageMemory(detour_trampoline);
95.174 + detour_trampoline = NULL;
95.175 + }
95.176 +}
95.177 +
95.178 +void CDetour::EnableDetour()
95.179 +{
95.180 + if (!detoured)
95.181 + {
95.182 + DoGatePatch((unsigned char *)detour_address, &detour_callback);
95.183 + detoured = true;
95.184 + }
95.185 +}
95.186 +
95.187 +void CDetour::DisableDetour()
95.188 +{
95.189 + if (detoured)
95.190 + {
95.191 + /* Remove the patch */
95.192 + ApplyPatch(detour_address, 0, &detour_restore, NULL);
95.193 + detoured = false;
95.194 + }
95.195 +}
96.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
96.2 +++ b/public/CDetour/detours.h Wed Apr 23 21:19:28 2014 -0500
96.3 @@ -0,0 +1,251 @@
96.4 +/**
96.5 +* vim: set ts=4 :
96.6 +* =============================================================================
96.7 +* SourceMod
96.8 +* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
96.9 +* =============================================================================
96.10 +*
96.11 +* This program is free software; you can redistribute it and/or modify it under
96.12 +* the terms of the GNU General Public License, version 3.0, as published by the
96.13 +* Free Software Foundation.
96.14 +*
96.15 +* This program is distributed in the hope that it will be useful, but WITHOUT
96.16 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
96.17 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
96.18 +* details.
96.19 +*
96.20 +* You should have received a copy of the GNU General Public License along with
96.21 +* this program. If not, see <http://www.gnu.org/licenses/>.
96.22 +*
96.23 +* As a special exception, AlliedModders LLC gives you permission to link the
96.24 +* code of this program (as well as its derivative works) to "Half-Life 2," the
96.25 +* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
96.26 +* by the Valve Corporation. You must obey the GNU General Public License in
96.27 +* all respects for all other code used. Additionally, AlliedModders LLC grants
96.28 +* this exception to all derivative works. AlliedModders LLC defines further
96.29 +* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
96.30 +* or <http://www.sourcemod.net/license.php>.
96.31 +*
96.32 +* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
96.33 +*/
96.34 +
96.35 +#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
96.36 +#define _INCLUDE_SOURCEMOD_DETOURS_H_
96.37 +
96.38 +#include "extension.h"
96.39 +#include <jit/jit_helpers.h>
96.40 +#include <jit/x86/x86_macros.h>
96.41 +#include "detourhelpers.h"
96.42 +
96.43 +/**
96.44 + * CDetours class for SourceMod Extensions by pRED*
96.45 + * detourhelpers.h entirely stolen from CSS:DM and were written by BAILOPAN (I assume).
96.46 + * asm.h/c from devmaster.net (thanks cybermind) edited by pRED* to handle gcc -fPIC thunks correctly
96.47 + * Concept by Nephyrin Zey (http://www.doublezen.net/) and Windows Detour Library (http://research.microsoft.com/sn/detours/)
96.48 + * Member function pointer ideas by Don Clugston (http://www.codeproject.com/cpp/FastDelegate.asp)
96.49 + */
96.50 +
96.51 +#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
96.52 +#define DETOUR_STATIC_CALL(name) (name##_Actual)
96.53 +
96.54 +#define DETOUR_DECL_STATIC0(name, ret) \
96.55 +ret (*name##_Actual)(void) = NULL; \
96.56 +ret name(void)
96.57 +
96.58 +#define DETOUR_DECL_STATIC1(name, ret, p1type, p1name) \
96.59 +ret (*name##_Actual)(p1type) = NULL; \
96.60 +ret name(p1type p1name)
96.61 +
96.62 +#define DETOUR_DECL_STATIC4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
96.63 +ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
96.64 +ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
96.65 +
96.66 +#define DETOUR_DECL_MEMBER0(name, ret) \
96.67 +class name##Class \
96.68 +{ \
96.69 +public: \
96.70 + ret name(); \
96.71 + static ret (name##Class::* name##_Actual)(void); \
96.72 +}; \
96.73 +ret (name##Class::* name##Class::name##_Actual)(void) = NULL; \
96.74 +ret name##Class::name()
96.75 +
96.76 +#define DETOUR_DECL_MEMBER1(name, ret, p1type, p1name) \
96.77 +class name##Class \
96.78 +{ \
96.79 +public: \
96.80 + ret name(p1type p1name); \
96.81 + static ret (name##Class::* name##_Actual)(p1type); \
96.82 +}; \
96.83 +ret (name##Class::* name##Class::name##_Actual)(p1type) = NULL; \
96.84 +ret name##Class::name(p1type p1name)
96.85 +
96.86 +#define DETOUR_DECL_MEMBER2(name, ret, p1type, p1name, p2type, p2name) \
96.87 +class name##Class \
96.88 +{ \
96.89 +public: \
96.90 + ret name(p1type p1name, p2type p2name); \
96.91 + static ret (name##Class::* name##_Actual)(p1type, p2type); \
96.92 +}; \
96.93 +ret (name##Class::* name##Class::name##_Actual)(p1type, p2type) = NULL; \
96.94 +ret name##Class::name(p1type p1name, p2type p2name)
96.95 +
96.96 +#define DETOUR_DECL_MEMBER3(name, ret, p1type, p1name, p2type, p2name, p3type, p3name) \
96.97 +class name##Class \
96.98 +{ \
96.99 +public: \
96.100 + ret name(p1type p1name, p2type p2name, p3type p3name); \
96.101 + static ret (name##Class::* name##_Actual)(p1type, p2type, p3type); \
96.102 +}; \
96.103 +ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type) = NULL; \
96.104 +ret name##Class::name(p1type p1name, p2type p2name, p3type p3name)
96.105 +
96.106 +#define DETOUR_DECL_MEMBER4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
96.107 +class name##Class \
96.108 +{ \
96.109 +public: \
96.110 + ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name); \
96.111 + static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type); \
96.112 +}; \
96.113 +ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
96.114 +ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
96.115 +
96.116 +#define DETOUR_DECL_MEMBER8(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name) \
96.117 +class name##Class \
96.118 +{ \
96.119 +public: \
96.120 + ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name); \
96.121 + static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type); \
96.122 +}; \
96.123 +ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
96.124 +ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
96.125 +
96.126 +
96.127 +#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
96.128 +#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
96.129 +
96.130 +#define GET_STATIC_CALLBACK(name) (void *)&name
96.131 +#define GET_STATIC_TRAMPOLINE(name) (void **)&name##_Actual
96.132 +
96.133 +#define DETOUR_CREATE_MEMBER(name, gamedata) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), gamedata);
96.134 +#define DETOUR_CREATE_STATIC(name, gamedata) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), gamedata);
96.135 +
96.136 +
96.137 +class GenericClass {};
96.138 +typedef void (GenericClass::*VoidFunc)();
96.139 +
96.140 +inline void *GetCodeAddr(VoidFunc mfp)
96.141 +{
96.142 + return *(void **)&mfp;
96.143 +}
96.144 +
96.145 +/**
96.146 + * Converts a member function pointer to a void pointer.
96.147 + * This relies on the assumption that the code address lies at mfp+0
96.148 + * This is the case for both g++ and later MSVC versions on non virtual functions but may be different for other compilers
96.149 + * Based on research by Don Clugston : http://www.codeproject.com/cpp/FastDelegate.asp
96.150 + */
96.151 +#define GetCodeAddress(mfp) GetCodeAddr(reinterpret_cast<VoidFunc>(mfp))
96.152 +
96.153 +class CDetourManager;
96.154 +
96.155 +class CDetour
96.156 +{
96.157 +public:
96.158 +
96.159 + bool IsEnabled();
96.160 +
96.161 + /**
96.162 + * These would be somewhat self-explanatory I hope
96.163 + */
96.164 + void EnableDetour();
96.165 + void DisableDetour();
96.166 +
96.167 + void Destroy();
96.168 +
96.169 + friend class CDetourManager;
96.170 +
96.171 +protected:
96.172 + CDetour(void *callbackfunction, void **trampoline, const char *signame);
96.173 +
96.174 + bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
96.175 +private:
96.176 +
96.177 + /* These create/delete the allocated memory */
96.178 + bool CreateDetour();
96.179 + void DeleteDetour();
96.180 +
96.181 + bool enabled;
96.182 + bool detoured;
96.183 +
96.184 + patch_t detour_restore;
96.185 + /* Address of the detoured function */
96.186 + void *detour_address;
96.187 + /* Address of the allocated trampoline function */
96.188 + void *detour_trampoline;
96.189 + /* Address of the callback handler */
96.190 + void *detour_callback;
96.191 + /* The function pointer used to call our trampoline */
96.192 + void **trampoline;
96.193 +
96.194 + const char *signame;
96.195 + ISourcePawnEngine *spengine;
96.196 + IGameConfig *gameconf;
96.197 +};
96.198 +
96.199 +class CDetourManager
96.200 +{
96.201 +public:
96.202 +
96.203 + static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
96.204 +
96.205 + /**
96.206 + * Creates a new detour
96.207 + *
96.208 + * @param callbackfunction Void pointer to your detour callback function.
96.209 + * @param trampoline Address of the trampoline pointer
96.210 + * @param signame Section name containing a signature to fetch from the gamedata file.
96.211 + * @return A new CDetour pointer to control your detour.
96.212 + *
96.213 + * Example:
96.214 + *
96.215 + * CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
96.216 + *
96.217 + * Define a new class with the required function and a member function pointer to the same type:
96.218 + *
96.219 + * class CBaseServerDetour
96.220 + * {
96.221 + * public:
96.222 + * bool ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
96.223 + * static bool (CBaseServerDetour::* ConnectClient_Actual)(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
96.224 + * }
96.225 + *
96.226 + * void *callbackfunc = GetCodeAddress(&CBaseServerDetour::ConnectClient);
96.227 + * void **trampoline = (void **)(&CBaseServerDetour::ConnectClient_Actual);
96.228 + *
96.229 + * Creation:
96.230 + * CDetourManager::CreateDetour(callbackfunc, trampoline, "ConnectClient");
96.231 + *
96.232 + * Usage:
96.233 + *
96.234 + * CBaseServerDetour::ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int)
96.235 + * {
96.236 + * //pre hook code
96.237 + * bool result = (this->*ConnectClient_Actual)(netaddr_s, rest of params);
96.238 + * //post hook code
96.239 + * return result;
96.240 + * }
96.241 + *
96.242 + * Note we changed the netadr_s reference into a void* to avoid needing to define the type
96.243 + */
96.244 + static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
96.245 +
96.246 + friend class CBlocker;
96.247 + friend class CDetour;
96.248 +
96.249 +private:
96.250 + static ISourcePawnEngine *spengine;
96.251 + static IGameConfig *gameconf;
96.252 +};
96.253 +
96.254 +#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
97.2 +++ b/public/asm/asm.c Wed Apr 23 21:19:28 2014 -0500
97.3 @@ -0,0 +1,421 @@
97.4 +#include "asm.h"
97.5 +
97.6 +#ifndef WIN32
97.7 +#define _GNU_SOURCE
97.8 +#include <dlfcn.h>
97.9 +#include <string.h>
97.10 +
97.11 +#define REG_EAX 0
97.12 +#define REG_ECX 1
97.13 +#define REG_EDX 2
97.14 +#define REG_EBX 3
97.15 +
97.16 +#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
97.17 +#endif
97.18 +
97.19 +extern void Msg( const char *, ... );
97.20 +
97.21 +/**
97.22 +* Checks if a call to a fpic thunk has just been written into dest.
97.23 +* If found replaces it with a direct mov that sets the required register to the value of pc.
97.24 +*
97.25 +* @param dest Destination buffer where a call opcode + addr (5 bytes) has just been written.
97.26 +* @param pc The program counter value that needs to be set (usually the next address from the source).
97.27 +* @noreturn
97.28 +*/
97.29 +void check_thunks(unsigned char *dest, unsigned char *pc)
97.30 +{
97.31 +#if defined WIN32
97.32 + return;
97.33 +#else
97.34 + /* Step write address back 4 to the start of the function address */
97.35 + unsigned char *writeaddr = dest - 4;
97.36 + unsigned char *calloffset = *(unsigned char **)writeaddr;
97.37 + unsigned char *calladdr = (unsigned char *)(dest + (unsigned int)calloffset);
97.38 +
97.39 + /* Lookup name of function being called */
97.40 + if ((*calladdr == 0x8B) && (*(calladdr+2) == 0x24) && (*(calladdr+3) == 0xC3))
97.41 + {
97.42 + //a thunk maybe?
97.43 + char movByte = IA32_MOV_REG_IMM;
97.44 +
97.45 + /* Calculate the correct mov opcode */
97.46 + switch (*(calladdr+1))
97.47 + {
97.48 + case 0x04:
97.49 + {
97.50 + movByte += REG_EAX;
97.51 + break;
97.52 + }
97.53 + case 0x1C:
97.54 + {
97.55 + movByte += REG_EBX;
97.56 + break;
97.57 + }
97.58 + case 0x0C:
97.59 + {
97.60 + movByte += REG_ECX;
97.61 + break;
97.62 + }
97.63 + case 0x14:
97.64 + {
97.65 + movByte += REG_EDX;
97.66 + break;
97.67 + }
97.68 + default:
97.69 + {
97.70 + Msg("Unknown thunk: %c\n", *(calladdr+1));
97.71 + break;
97.72 + }
97.73 + }
97.74 +
97.75 + /* Move our write address back one to where the call opcode was */
97.76 + writeaddr--;
97.77 +
97.78 +
97.79 + /* Write our mov */
97.80 + *writeaddr = movByte;
97.81 + writeaddr++;
97.82 +
97.83 + /* Write the value - The provided program counter value */
97.84 + *(void **)writeaddr = (void *)pc;
97.85 + writeaddr += 4;
97.86 + }
97.87 +
97.88 + return;
97.89 +#endif
97.90 +}
97.91 +
97.92 +//if dest is NULL, returns minimum number of bytes needed to be copied
97.93 +//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
97.94 +//http://www.devmaster.net/forums/showthread.php?t=2311
97.95 +int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
97.96 + int bytecount = 0;
97.97 +
97.98 + while(bytecount < required_len && *func != 0xCC)
97.99 + {
97.100 + // prefixes F0h, F2h, F3h, 66h, 67h, D8h-DFh, 2Eh, 36h, 3Eh, 26h, 64h and 65h
97.101 + int operandSize = 4;
97.102 + int FPU = 0;
97.103 + int twoByte = 0;
97.104 + unsigned char opcode = 0x90;
97.105 + unsigned char modRM = 0xFF;
97.106 + while(*func == 0xF0 ||
97.107 + *func == 0xF2 ||
97.108 + *func == 0xF3 ||
97.109 + (*func & 0xFC) == 0x64 ||
97.110 + (*func & 0xF8) == 0xD8 ||
97.111 + (*func & 0x7E) == 0x62)
97.112 + {
97.113 + if(*func == 0x66)
97.114 + {
97.115 + operandSize = 2;
97.116 + }
97.117 + else if((*func & 0xF8) == 0xD8)
97.118 + {
97.119 + FPU = *func;
97.120 + if (dest)
97.121 + *dest++ = *func++;
97.122 + else
97.123 + func++;
97.124 + bytecount++;
97.125 + break;
97.126 + }
97.127 +
97.128 + if (dest)
97.129 + *dest++ = *func++;
97.130 + else
97.131 + func++;
97.132 + bytecount++;
97.133 + }
97.134 +
97.135 + // two-byte opcode byte
97.136 + if(*func == 0x0F)
97.137 + {
97.138 + twoByte = 1;
97.139 + if (dest)
97.140 + *dest++ = *func++;
97.141 + else
97.142 + func++;
97.143 + bytecount++;
97.144 + }
97.145 +
97.146 + // opcode byte
97.147 + opcode = *func++;
97.148 + if (dest) *dest++ = opcode;
97.149 + bytecount++;
97.150 +
97.151 + // mod R/M byte
97.152 + modRM = 0xFF;
97.153 + if(FPU)
97.154 + {
97.155 + if((opcode & 0xC0) != 0xC0)
97.156 + {
97.157 + modRM = opcode;
97.158 + }
97.159 + }
97.160 + else if(!twoByte)
97.161 + {
97.162 + if((opcode & 0xC4) == 0x00 ||
97.163 + ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) ||
97.164 + (opcode & 0xF0) == 0x80 ||
97.165 + ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) ||
97.166 + (opcode & 0xFC) == 0xD0 ||
97.167 + (opcode & 0xF6) == 0xF6)
97.168 + {
97.169 + modRM = *func++;
97.170 + if (dest) *dest++ = modRM;
97.171 + bytecount++;
97.172 + }
97.173 + }
97.174 + else
97.175 + {
97.176 + if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) ||
97.177 + (opcode & 0xF0) == 0x30 ||
97.178 + opcode == 0x77 ||
97.179 + (opcode & 0xF0) == 0x80 ||
97.180 + ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) ||
97.181 + (opcode & 0xF8) == 0xC8)
97.182 + {
97.183 + // No mod R/M byte
97.184 + }
97.185 + else
97.186 + {
97.187 + modRM = *func++;
97.188 + if (dest) *dest++ = modRM;
97.189 + bytecount++;
97.190 + }
97.191 + }
97.192 +
97.193 + // SIB
97.194 + if((modRM & 0x07) == 0x04 &&
97.195 + (modRM & 0xC0) != 0xC0)
97.196 + {
97.197 + if (dest)
97.198 + *dest++ = *func++; //SIB
97.199 + else
97.200 + func++;
97.201 + bytecount++;
97.202 + }
97.203 +
97.204 + // mod R/M displacement
97.205 +
97.206 + // Dword displacement, no base
97.207 + if((modRM & 0xC5) == 0x05) {
97.208 + if (dest) {
97.209 + *(unsigned int*)dest = *(unsigned int*)func;
97.210 + dest += 4;
97.211 + }
97.212 + func += 4;
97.213 + bytecount += 4;
97.214 + }
97.215 +
97.216 + // Byte displacement
97.217 + if((modRM & 0xC0) == 0x40) {
97.218 + if (dest)
97.219 + *dest++ = *func++;
97.220 + else
97.221 + func++;
97.222 + bytecount++;
97.223 + }
97.224 +
97.225 + // Dword displacement
97.226 + if((modRM & 0xC0) == 0x80) {
97.227 + if (dest) {
97.228 + *(unsigned int*)dest = *(unsigned int*)func;
97.229 + dest += 4;
97.230 + }
97.231 + func += 4;
97.232 + bytecount += 4;
97.233 + }
97.234 +
97.235 + // immediate
97.236 + if(FPU)
97.237 + {
97.238 + // Can't have immediate operand
97.239 + }
97.240 + else if(!twoByte)
97.241 + {
97.242 + if((opcode & 0xC7) == 0x04 ||
97.243 + (opcode & 0xFE) == 0x6A || // PUSH/POP/IMUL
97.244 + (opcode & 0xF0) == 0x70 || // Jcc
97.245 + opcode == 0x80 ||
97.246 + opcode == 0x83 ||
97.247 + (opcode & 0xFD) == 0xA0 || // MOV
97.248 + opcode == 0xA8 || // TEST
97.249 + (opcode & 0xF8) == 0xB0 || // MOV
97.250 + (opcode & 0xFE) == 0xC0 || // RCL
97.251 + opcode == 0xC6 || // MOV
97.252 + opcode == 0xCD || // INT
97.253 + (opcode & 0xFE) == 0xD4 || // AAD/AAM
97.254 + (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ
97.255 + opcode == 0xEB ||
97.256 + (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST
97.257 + {
97.258 + if (dest)
97.259 + *dest++ = *func++;
97.260 + else
97.261 + func++;
97.262 + bytecount++;
97.263 + }
97.264 + else if((opcode & 0xF7) == 0xC2) // RET
97.265 + {
97.266 + if (dest) {
97.267 + *(unsigned short*)dest = *(unsigned short*)func;
97.268 + dest += 2;
97.269 + }
97.270 + func += 2;
97.271 + bytecount += 2;
97.272 + }
97.273 + else if((opcode & 0xFC) == 0x80 ||
97.274 + (opcode & 0xC7) == 0x05 ||
97.275 + (opcode & 0xF8) == 0xB8 ||
97.276 + (opcode & 0xFE) == 0xE8 || // CALL/Jcc
97.277 + (opcode & 0xFE) == 0x68 ||
97.278 + (opcode & 0xFC) == 0xA0 ||
97.279 + (opcode & 0xEE) == 0xA8 ||
97.280 + opcode == 0xC7 ||
97.281 + (opcode == 0xF7 && (modRM & 0x30) == 0x00))
97.282 + {
97.283 + if (dest) {
97.284 + //Fix CALL/JMP offset
97.285 + if ((opcode & 0xFE) == 0xE8) {
97.286 + if (operandSize == 4)
97.287 + {
97.288 + *(long*)dest = ((func + *(long*)func) - dest);
97.289 +
97.290 + //pRED* edit. func is the current address of the call address, +4 is the next instruction, so the value of $pc
97.291 + check_thunks(dest+4, func+4);
97.292 + }
97.293 + else
97.294 + *(short*)dest = ((func + *(short*)func) - dest);
97.295 +
97.296 + } else {
97.297 + if (operandSize == 4)
97.298 + *(unsigned long*)dest = *(unsigned long*)func;
97.299 + else
97.300 + *(unsigned short*)dest = *(unsigned short*)func;
97.301 + }
97.302 + dest += operandSize;
97.303 + }
97.304 + func += operandSize;
97.305 + bytecount += operandSize;
97.306 +
97.307 + }
97.308 + }
97.309 + else
97.310 + {
97.311 + if(opcode == 0xBA || // BT
97.312 + opcode == 0x0F || // 3DNow!
97.313 + (opcode & 0xFC) == 0x70 || // PSLLW
97.314 + (opcode & 0xF7) == 0xA4 || // SHLD
97.315 + opcode == 0xC2 ||
97.316 + opcode == 0xC4 ||
97.317 + opcode == 0xC5 ||
97.318 + opcode == 0xC6)
97.319 + {
97.320 + if (dest)
97.321 + *dest++ = *func++;
97.322 + else
97.323 + func++;
97.324 + }
97.325 + else if((opcode & 0xF0) == 0x80) // Jcc -i
97.326 + {
97.327 + if (dest) {
97.328 + if (operandSize == 4)
97.329 + *(unsigned long*)dest = *(unsigned long*)func;
97.330 + else
97.331 + *(unsigned short*)dest = *(unsigned short*)func;
97.332 +
97.333 + dest += operandSize;
97.334 + }
97.335 + func += operandSize;
97.336 + bytecount += operandSize;
97.337 + }
97.338 + }
97.339 + }
97.340 +
97.341 + return bytecount;
97.342 +}
97.343 +
97.344 +//insert a specific JMP instruction at the given location
97.345 +void inject_jmp(void* src, void* dest) {
97.346 + *(unsigned char*)src = OP_JMP;
97.347 + *(long*)((unsigned char*)src+1) = (long)((unsigned char*)dest - ((unsigned char*)src + OP_JMP_SIZE));
97.348 +}
97.349 +
97.350 +//fill a given block with NOPs
97.351 +void fill_nop(void* src, unsigned int len) {
97.352 + unsigned char* src2 = (unsigned char*)src;
97.353 + while (len) {
97.354 + *src2++ = OP_NOP;
97.355 + --len;
97.356 + }
97.357 +}
97.358 +
97.359 +void* eval_jump(void* src) {
97.360 + unsigned char* addr = (unsigned char*)src;
97.361 +
97.362 + if (!addr) return 0;
97.363 +
97.364 + //import table jump
97.365 + if (addr[0] == OP_PREFIX && addr[1] == OP_JMP_SEG) {
97.366 + addr += 2;
97.367 + addr = *(unsigned char**)addr;
97.368 + //TODO: if addr points into the IAT
97.369 + return *(void**)addr;
97.370 + }
97.371 +
97.372 + //8bit offset
97.373 + else if (addr[0] == OP_JMP_BYTE) {
97.374 + addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1];
97.375 + //mangled 32bit jump?
97.376 + if (addr[0] == OP_JMP) {
97.377 + addr = addr + *(int*)&addr[1];
97.378 + }
97.379 + return addr;
97.380 + }
97.381 + /*
97.382 + //32bit offset
97.383 + else if (addr[0] == OP_JMP) {
97.384 + addr = &addr[OP_JMP_SIZE] + *(int*)&addr[1];
97.385 + }
97.386 + */
97.387 +
97.388 + return addr;
97.389 +}
97.390 +/*
97.391 +from ms detours package
97.392 +static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress)
97.393 +{
97.394 + MEMORY_BASIC_INFORMATION mbi;
97.395 + VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi));
97.396 + __try {
97.397 + PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase;
97.398 + if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
97.399 + return false;
97.400 + }
97.401 +
97.402 + PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader +
97.403 + pDosHeader->e_lfanew);
97.404 + if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
97.405 + return false;
97.406 + }
97.407 +
97.408 + if (pbAddress >= ((PBYTE)pDosHeader +
97.409 + pNtHeader->OptionalHeader
97.410 + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) &&
97.411 + pbAddress < ((PBYTE)pDosHeader +
97.412 + pNtHeader->OptionalHeader
97.413 + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress +
97.414 + pNtHeader->OptionalHeader
97.415 + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) {
97.416 + return true;
97.417 + }
97.418 + return false;
97.419 + }
97.420 + __except(EXCEPTION_EXECUTE_HANDLER) {
97.421 + return false;
97.422 + }
97.423 +}
97.424 +*/
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
98.2 +++ b/public/asm/asm.h Wed Apr 23 21:19:28 2014 -0500
98.3 @@ -0,0 +1,40 @@
98.4 +#ifndef __ASM_H__
98.5 +#define __ASM_H__
98.6 +
98.7 +#define OP_JMP 0xE9
98.8 +#define OP_JMP_SIZE 5
98.9 +
98.10 +#define OP_NOP 0x90
98.11 +#define OP_NOP_SIZE 1
98.12 +
98.13 +#define OP_PREFIX 0xFF
98.14 +#define OP_JMP_SEG 0x25
98.15 +
98.16 +#define OP_JMP_BYTE 0xEB
98.17 +#define OP_JMP_BYTE_SIZE 2
98.18 +
98.19 +#ifdef __cplusplus
98.20 +extern "C" {
98.21 +#endif
98.22 +
98.23 +void check_thunks(unsigned char *dest, unsigned char *pc);
98.24 +
98.25 +//if dest is NULL, returns minimum number of bytes needed to be copied
98.26 +//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
98.27 +//http://www.devmaster.net/forums/showthread.php?t=2311
98.28 +int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
98.29 +
98.30 +//insert a specific JMP instruction at the given location
98.31 +void inject_jmp(void* src, void* dest);
98.32 +
98.33 +//fill a given block with NOPs
98.34 +void fill_nop(void* src, unsigned int len);
98.35 +
98.36 +//evaluate a JMP at the target
98.37 +void* eval_jump(void* src);
98.38 +
98.39 +#ifdef __cplusplus
98.40 +}
98.41 +#endif
98.42 +
98.43 +#endif //__ASM_H__
99.1 --- a/public/sample_ext/Makefile Wed Apr 23 21:40:50 2014 -0400
99.2 +++ b/public/sample_ext/Makefile Wed Apr 23 21:19:28 2014 -0500
99.3 @@ -24,7 +24,7 @@
99.4 #Uncomment for Metamod: Source enabled extension
99.5 #USEMETA = true
99.6
99.7 -OBJECTS = sdk/smsdk_ext.cpp extension.cpp
99.8 +OBJECTS = smsdk_ext.cpp extension.cpp
99.9
99.10 ##############################################
99.11 ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
99.12 @@ -204,7 +204,8 @@
99.13 $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
99.14
99.15 all: check
99.16 - mkdir -p $(BIN_DIR)/sdk
99.17 + mkdir -p $(BIN_DIR)
99.18 + ln -sf ../smsdk_ext.cpp
99.19 if [ "$(USEMETA)" = "true" ]; then \
99.20 ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \
99.21 ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \
99.22 @@ -228,6 +229,5 @@
99.23
99.24 clean: check
99.25 rm -rf $(BIN_DIR)/*.o
99.26 - rm -rf $(BIN_DIR)/sdk/*.o
99.27 rm -rf $(BIN_DIR)/$(BINARY)
99.28
100.1 --- a/public/sample_ext/sdk/smsdk_config.h Wed Apr 23 21:40:50 2014 -0400
100.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
100.3 @@ -1,82 +0,0 @@
100.4 -/**
100.5 - * vim: set ts=4 :
100.6 - * =============================================================================
100.7 - * SourceMod Sample Extension
100.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
100.9 - * =============================================================================
100.10 - *
100.11 - * This program is free software; you can redistribute it and/or modify it under
100.12 - * the terms of the GNU General Public License, version 3.0, as published by the
100.13 - * Free Software Foundation.
100.14 - *
100.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
100.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
100.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
100.18 - * details.
100.19 - *
100.20 - * You should have received a copy of the GNU General Public License along with
100.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
100.22 - *
100.23 - * As a special exception, AlliedModders LLC gives you permission to link the
100.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
100.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
100.26 - * by the Valve Corporation. You must obey the GNU General Public License in
100.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
100.28 - * this exception to all derivative works. AlliedModders LLC defines further
100.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
100.30 - * or <http://www.sourcemod.net/license.php>.
100.31 - *
100.32 - * Version: $Id$
100.33 - */
100.34 -
100.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
100.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
100.37 -
100.38 -/**
100.39 - * @file smsdk_config.h
100.40 - * @brief Contains macros for configuring basic extension information.
100.41 - */
100.42 -
100.43 -/* Basic information exposed publicly */
100.44 -#define SMEXT_CONF_NAME "Sample Extension"
100.45 -#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers"
100.46 -#define SMEXT_CONF_VERSION "0.0.0.0"
100.47 -#define SMEXT_CONF_AUTHOR "AlliedModders"
100.48 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
100.49 -#define SMEXT_CONF_LOGTAG "SAMPLE"
100.50 -#define SMEXT_CONF_LICENSE "GPL"
100.51 -#define SMEXT_CONF_DATESTRING __DATE__
100.52 -
100.53 -/**
100.54 - * @brief Exposes plugin's main interface.
100.55 - */
100.56 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
100.57 -
100.58 -/**
100.59 - * @brief Sets whether or not this plugin required Metamod.
100.60 - * NOTE: Uncomment to enable, comment to disable.
100.61 - */
100.62 -//#define SMEXT_CONF_METAMOD
100.63 -
100.64 -/** Enable interfaces you want to use here by uncommenting lines */
100.65 -//#define SMEXT_ENABLE_FORWARDSYS
100.66 -//#define SMEXT_ENABLE_HANDLESYS
100.67 -//#define SMEXT_ENABLE_PLAYERHELPERS
100.68 -//#define SMEXT_ENABLE_DBMANAGER
100.69 -//#define SMEXT_ENABLE_GAMECONF
100.70 -//#define SMEXT_ENABLE_MEMUTILS
100.71 -//#define SMEXT_ENABLE_GAMEHELPERS
100.72 -//#define SMEXT_ENABLE_TIMERSYS
100.73 -//#define SMEXT_ENABLE_THREADER
100.74 -//#define SMEXT_ENABLE_LIBSYS
100.75 -//#define SMEXT_ENABLE_MENUS
100.76 -//#define SMEXT_ENABLE_ADTFACTORY
100.77 -//#define SMEXT_ENABLE_PLUGINSYS
100.78 -//#define SMEXT_ENABLE_ADMINSYS
100.79 -//#define SMEXT_ENABLE_TEXTPARSERS
100.80 -//#define SMEXT_ENABLE_USERMSGS
100.81 -//#define SMEXT_ENABLE_TRANSLATOR
100.82 -//#define SMEXT_ENABLE_NINVOKE
100.83 -//#define SMEXT_ENABLE_ROOTCONSOLEMENU
100.84 -
100.85 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
101.1 --- a/public/sample_ext/sdk/smsdk_ext.cpp Wed Apr 23 21:40:50 2014 -0400
101.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
101.3 @@ -1,483 +0,0 @@
101.4 -/**
101.5 - * vim: set ts=4 sw=4 tw=99 noet:
101.6 - * =============================================================================
101.7 - * SourceMod Base Extension Code
101.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
101.9 - * =============================================================================
101.10 - *
101.11 - * This program is free software; you can redistribute it and/or modify it under
101.12 - * the terms of the GNU General Public License, version 3.0, as published by the
101.13 - * Free Software Foundation.
101.14 - *
101.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
101.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
101.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
101.18 - * details.
101.19 - *
101.20 - * You should have received a copy of the GNU General Public License along with
101.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
101.22 - *
101.23 - * As a special exception, AlliedModders LLC gives you permission to link the
101.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
101.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
101.26 - * by the Valve Corporation. You must obey the GNU General Public License in
101.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
101.28 - * this exception to all derivative works. AlliedModders LLC defines further
101.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
101.30 - * or <http://www.sourcemod.net/license.php>.
101.31 - *
101.32 - * Version: $Id$
101.33 - */
101.34 -
101.35 -#include <stdio.h>
101.36 -#include <stdlib.h>
101.37 -#include "smsdk_ext.h"
101.38 -
101.39 -/**
101.40 - * @file smsdk_ext.cpp
101.41 - * @brief Contains wrappers for making Extensions easier to write.
101.42 - */
101.43 -
101.44 -IExtension *myself = NULL; /**< Ourself */
101.45 -IShareSys *g_pShareSys = NULL; /**< Share system */
101.46 -IShareSys *sharesys = NULL; /**< Share system */
101.47 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
101.48 -ISourceMod *smutils = NULL; /**< SourceMod helpers */
101.49 -
101.50 -#if defined SMEXT_ENABLE_FORWARDSYS
101.51 -IForwardManager *g_pForwards = NULL; /**< Forward system */
101.52 -IForwardManager *forwards = NULL; /**< Forward system */
101.53 -#endif
101.54 -#if defined SMEXT_ENABLE_HANDLESYS
101.55 -IHandleSys *g_pHandleSys = NULL; /**< Handle system */
101.56 -IHandleSys *handlesys = NULL; /**< Handle system */
101.57 -#endif
101.58 -#if defined SMEXT_ENABLE_PLAYERHELPERS
101.59 -IPlayerManager *playerhelpers = NULL; /**< Player helpers */
101.60 -#endif //SMEXT_ENABLE_PLAYERHELPERS
101.61 -#if defined SMEXT_ENABLE_DBMANAGER
101.62 -IDBManager *dbi = NULL; /**< DB Manager */
101.63 -#endif //SMEXT_ENABLE_DBMANAGER
101.64 -#if defined SMEXT_ENABLE_GAMECONF
101.65 -IGameConfigManager *gameconfs = NULL; /**< Game config manager */
101.66 -#endif //SMEXT_ENABLE_DBMANAGER
101.67 -#if defined SMEXT_ENABLE_MEMUTILS
101.68 -IMemoryUtils *memutils = NULL;
101.69 -#endif //SMEXT_ENABLE_DBMANAGER
101.70 -#if defined SMEXT_ENABLE_GAMEHELPERS
101.71 -IGameHelpers *gamehelpers = NULL;
101.72 -#endif
101.73 -#if defined SMEXT_ENABLE_TIMERSYS
101.74 -ITimerSystem *timersys = NULL;
101.75 -#endif
101.76 -#if defined SMEXT_ENABLE_ADTFACTORY
101.77 -IADTFactory *adtfactory = NULL;
101.78 -#endif
101.79 -#if defined SMEXT_ENABLE_THREADER
101.80 -IThreader *threader = NULL;
101.81 -#endif
101.82 -#if defined SMEXT_ENABLE_LIBSYS
101.83 -ILibrarySys *libsys = NULL;
101.84 -#endif
101.85 -#if defined SMEXT_ENABLE_PLUGINSYS
101.86 -SourceMod::IPluginManager *plsys;
101.87 -#endif
101.88 -#if defined SMEXT_ENABLE_MENUS
101.89 -IMenuManager *menus = NULL;
101.90 -#endif
101.91 -#if defined SMEXT_ENABLE_ADMINSYS
101.92 -IAdminSystem *adminsys = NULL;
101.93 -#endif
101.94 -#if defined SMEXT_ENABLE_TEXTPARSERS
101.95 -ITextParsers *textparsers = NULL;
101.96 -#endif
101.97 -#if defined SMEXT_ENABLE_USERMSGS
101.98 -IUserMessages *usermsgs = NULL;
101.99 -#endif
101.100 -#if defined SMEXT_ENABLE_TRANSLATOR
101.101 -ITranslator *translator = NULL;
101.102 -#endif
101.103 -#if defined SMEXT_ENABLE_NINVOKE
101.104 -INativeInterface *ninvoke = NULL;
101.105 -#endif
101.106 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
101.107 -IRootConsole *rootconsole = NULL;
101.108 -#endif
101.109 -
101.110 -/** Exports the main interface */
101.111 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
101.112 -{
101.113 - return g_pExtensionIface;
101.114 -}
101.115 -
101.116 -SDKExtension::SDKExtension()
101.117 -{
101.118 -#if defined SMEXT_CONF_METAMOD
101.119 - m_SourceMMLoaded = false;
101.120 - m_WeAreUnloaded = false;
101.121 - m_WeGotPauseChange = false;
101.122 -#endif
101.123 -}
101.124 -
101.125 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
101.126 -{
101.127 - g_pShareSys = sharesys = sys;
101.128 - myself = me;
101.129 -
101.130 -#if defined SMEXT_CONF_METAMOD
101.131 - m_WeAreUnloaded = true;
101.132 -
101.133 - if (!m_SourceMMLoaded)
101.134 - {
101.135 - if (error)
101.136 - {
101.137 - snprintf(error, maxlength, "Metamod attach failed");
101.138 - }
101.139 - return false;
101.140 - }
101.141 -#endif
101.142 - SM_GET_IFACE(SOURCEMOD, g_pSM);
101.143 - smutils = g_pSM;
101.144 -#if defined SMEXT_ENABLE_HANDLESYS
101.145 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
101.146 - handlesys = g_pHandleSys;
101.147 -#endif
101.148 -#if defined SMEXT_ENABLE_FORWARDSYS
101.149 - SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
101.150 - forwards = g_pForwards;
101.151 -#endif
101.152 -#if defined SMEXT_ENABLE_PLAYERHELPERS
101.153 - SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
101.154 -#endif
101.155 -#if defined SMEXT_ENABLE_DBMANAGER
101.156 - SM_GET_IFACE(DBI, dbi);
101.157 -#endif
101.158 -#if defined SMEXT_ENABLE_GAMECONF
101.159 - SM_GET_IFACE(GAMECONFIG, gameconfs);
101.160 -#endif
101.161 -#if defined SMEXT_ENABLE_MEMUTILS
101.162 - SM_GET_IFACE(MEMORYUTILS, memutils);
101.163 -#endif
101.164 -#if defined SMEXT_ENABLE_GAMEHELPERS
101.165 - SM_GET_IFACE(GAMEHELPERS, gamehelpers);
101.166 -#endif
101.167 -#if defined SMEXT_ENABLE_TIMERSYS
101.168 - SM_GET_IFACE(TIMERSYS, timersys);
101.169 -#endif
101.170 -#if defined SMEXT_ENABLE_ADTFACTORY
101.171 - SM_GET_IFACE(ADTFACTORY, adtfactory);
101.172 -#endif
101.173 -#if defined SMEXT_ENABLE_THREADER
101.174 - SM_GET_IFACE(THREADER, threader);
101.175 -#endif
101.176 -#if defined SMEXT_ENABLE_LIBSYS
101.177 - SM_GET_IFACE(LIBRARYSYS, libsys);
101.178 -#endif
101.179 -#if defined SMEXT_ENABLE_PLUGINSYS
101.180 - SM_GET_IFACE(PLUGINSYSTEM, plsys);
101.181 -#endif
101.182 -#if defined SMEXT_ENABLE_MENUS
101.183 - SM_GET_IFACE(MENUMANAGER, menus);
101.184 -#endif
101.185 -#if defined SMEXT_ENABLE_ADMINSYS
101.186 - SM_GET_IFACE(ADMINSYS, adminsys);
101.187 -#endif
101.188 -#if defined SMEXT_ENABLE_TEXTPARSERS
101.189 - SM_GET_IFACE(TEXTPARSERS, textparsers);
101.190 -#endif
101.191 -#if defined SMEXT_ENABLE_USERMSGS
101.192 - SM_GET_IFACE(USERMSGS, usermsgs);
101.193 -#endif
101.194 -#if defined SMEXT_ENABLE_TRANSLATOR
101.195 - SM_GET_IFACE(TRANSLATOR, translator);
101.196 -#endif
101.197 -#if defined SMEXT_ENABLE_NINVOKE
101.198 - SM_GET_IFACE(NINVOKE, ninvoke);
101.199 -#endif
101.200 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
101.201 - SM_GET_IFACE(ROOTCONSOLE, rootconsole);
101.202 -#endif
101.203 -
101.204 - if (SDK_OnLoad(error, maxlength, late))
101.205 - {
101.206 -#if defined SMEXT_CONF_METAMOD
101.207 - m_WeAreUnloaded = true;
101.208 -#endif
101.209 - return true;
101.210 - }
101.211 -
101.212 - return false;
101.213 -}
101.214 -
101.215 -bool SDKExtension::IsMetamodExtension()
101.216 -{
101.217 -#if defined SMEXT_CONF_METAMOD
101.218 - return true;
101.219 -#else
101.220 - return false;
101.221 -#endif
101.222 -}
101.223 -
101.224 -void SDKExtension::OnExtensionPauseChange(bool state)
101.225 -{
101.226 -#if defined SMEXT_CONF_METAMOD
101.227 - m_WeGotPauseChange = true;
101.228 -#endif
101.229 - SDK_OnPauseChange(state);
101.230 -}
101.231 -
101.232 -void SDKExtension::OnExtensionsAllLoaded()
101.233 -{
101.234 - SDK_OnAllLoaded();
101.235 -}
101.236 -
101.237 -void SDKExtension::OnExtensionUnload()
101.238 -{
101.239 -#if defined SMEXT_CONF_METAMOD
101.240 - m_WeAreUnloaded = true;
101.241 -#endif
101.242 - SDK_OnUnload();
101.243 -}
101.244 -
101.245 -void SDKExtension::OnDependenciesDropped()
101.246 -{
101.247 - SDK_OnDependenciesDropped();
101.248 -}
101.249 -
101.250 -const char *SDKExtension::GetExtensionAuthor()
101.251 -{
101.252 - return SMEXT_CONF_AUTHOR;
101.253 -}
101.254 -
101.255 -const char *SDKExtension::GetExtensionDateString()
101.256 -{
101.257 - return SMEXT_CONF_DATESTRING;
101.258 -}
101.259 -
101.260 -const char *SDKExtension::GetExtensionDescription()
101.261 -{
101.262 - return SMEXT_CONF_DESCRIPTION;
101.263 -}
101.264 -
101.265 -const char *SDKExtension::GetExtensionVerString()
101.266 -{
101.267 - return SMEXT_CONF_VERSION;
101.268 -}
101.269 -
101.270 -const char *SDKExtension::GetExtensionName()
101.271 -{
101.272 - return SMEXT_CONF_NAME;
101.273 -}
101.274 -
101.275 -const char *SDKExtension::GetExtensionTag()
101.276 -{
101.277 - return SMEXT_CONF_LOGTAG;
101.278 -}
101.279 -
101.280 -const char *SDKExtension::GetExtensionURL()
101.281 -{
101.282 - return SMEXT_CONF_URL;
101.283 -}
101.284 -
101.285 -bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
101.286 -{
101.287 - return true;
101.288 -}
101.289 -
101.290 -void SDKExtension::SDK_OnUnload()
101.291 -{
101.292 -}
101.293 -
101.294 -void SDKExtension::SDK_OnPauseChange(bool paused)
101.295 -{
101.296 -}
101.297 -
101.298 -void SDKExtension::SDK_OnAllLoaded()
101.299 -{
101.300 -}
101.301 -
101.302 -void SDKExtension::SDK_OnDependenciesDropped()
101.303 -{
101.304 -}
101.305 -
101.306 -#if defined SMEXT_CONF_METAMOD
101.307 -
101.308 -PluginId g_PLID = 0; /**< Metamod plugin ID */
101.309 -ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
101.310 -SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
101.311 -ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
101.312 -
101.313 -IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
101.314 -IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
101.315 -
101.316 -/** Exposes the extension to Metamod */
101.317 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
101.318 -{
101.319 -#if defined METAMOD_PLAPI_VERSION
101.320 - if (name && !strcmp(name, METAMOD_PLAPI_NAME))
101.321 -#else
101.322 - if (name && !strcmp(name, PLAPI_NAME))
101.323 -#endif
101.324 - {
101.325 - if (code)
101.326 - {
101.327 - *code = IFACE_OK;
101.328 - }
101.329 - return static_cast<void *>(g_pExtensionIface);
101.330 - }
101.331 -
101.332 - if (code)
101.333 - {
101.334 - *code = IFACE_FAILED;
101.335 - }
101.336 -
101.337 - return NULL;
101.338 -}
101.339 -
101.340 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
101.341 -{
101.342 - PLUGIN_SAVEVARS();
101.343 -
101.344 -#if !defined METAMOD_PLAPI_VERSION
101.345 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
101.346 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
101.347 -#else
101.348 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
101.349 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
101.350 -#endif
101.351 -
101.352 - m_SourceMMLoaded = true;
101.353 -
101.354 - return SDK_OnMetamodLoad(ismm, error, maxlen, late);
101.355 -}
101.356 -
101.357 -bool SDKExtension::Unload(char *error, size_t maxlen)
101.358 -{
101.359 - if (!m_WeAreUnloaded)
101.360 - {
101.361 - if (error)
101.362 - {
101.363 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
101.364 - }
101.365 - return false;
101.366 - }
101.367 -
101.368 - return SDK_OnMetamodUnload(error, maxlen);
101.369 -}
101.370 -
101.371 -bool SDKExtension::Pause(char *error, size_t maxlen)
101.372 -{
101.373 - if (!m_WeGotPauseChange)
101.374 - {
101.375 - if (error)
101.376 - {
101.377 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
101.378 - }
101.379 - return false;
101.380 - }
101.381 -
101.382 - m_WeGotPauseChange = false;
101.383 -
101.384 - return SDK_OnMetamodPauseChange(true, error, maxlen);
101.385 -}
101.386 -
101.387 -bool SDKExtension::Unpause(char *error, size_t maxlen)
101.388 -{
101.389 - if (!m_WeGotPauseChange)
101.390 - {
101.391 - if (error)
101.392 - {
101.393 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
101.394 - }
101.395 - return false;
101.396 - }
101.397 -
101.398 - m_WeGotPauseChange = false;
101.399 -
101.400 - return SDK_OnMetamodPauseChange(false, error, maxlen);
101.401 -}
101.402 -
101.403 -const char *SDKExtension::GetAuthor()
101.404 -{
101.405 - return GetExtensionAuthor();
101.406 -}
101.407 -
101.408 -const char *SDKExtension::GetDate()
101.409 -{
101.410 - return GetExtensionDateString();
101.411 -}
101.412 -
101.413 -const char *SDKExtension::GetDescription()
101.414 -{
101.415 - return GetExtensionDescription();
101.416 -}
101.417 -
101.418 -const char *SDKExtension::GetLicense()
101.419 -{
101.420 - return SMEXT_CONF_LICENSE;
101.421 -}
101.422 -
101.423 -const char *SDKExtension::GetLogTag()
101.424 -{
101.425 - return GetExtensionTag();
101.426 -}
101.427 -
101.428 -const char *SDKExtension::GetName()
101.429 -{
101.430 - return GetExtensionName();
101.431 -}
101.432 -
101.433 -const char *SDKExtension::GetURL()
101.434 -{
101.435 - return GetExtensionURL();
101.436 -}
101.437 -
101.438 -const char *SDKExtension::GetVersion()
101.439 -{
101.440 - return GetExtensionVerString();
101.441 -}
101.442 -
101.443 -bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
101.444 -{
101.445 - return true;
101.446 -}
101.447 -
101.448 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
101.449 -{
101.450 - return true;
101.451 -}
101.452 -
101.453 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
101.454 -{
101.455 - return true;
101.456 -}
101.457 -
101.458 -#endif
101.459 -
101.460 -/* Overload a few things to prevent libstdc++ linking */
101.461 -#if defined __linux__ || defined __APPLE__
101.462 -extern "C" void __cxa_pure_virtual(void)
101.463 -{
101.464 -}
101.465 -
101.466 -void *operator new(size_t size)
101.467 -{
101.468 - return malloc(size);
101.469 -}
101.470 -
101.471 -void *operator new[](size_t size)
101.472 -{
101.473 - return malloc(size);
101.474 -}
101.475 -
101.476 -void operator delete(void *ptr)
101.477 -{
101.478 - free(ptr);
101.479 -}
101.480 -
101.481 -void operator delete[](void * ptr)
101.482 -{
101.483 - free(ptr);
101.484 -}
101.485 -#endif
101.486 -
102.1 --- a/public/sample_ext/sdk/smsdk_ext.h Wed Apr 23 21:40:50 2014 -0400
102.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
102.3 @@ -1,354 +0,0 @@
102.4 -/**
102.5 - * vim: set ts=4 sw=4 tw=99 noet:
102.6 - * =============================================================================
102.7 - * SourceMod Base Extension Code
102.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
102.9 - * =============================================================================
102.10 - *
102.11 - * This program is free software; you can redistribute it and/or modify it under
102.12 - * the terms of the GNU General Public License, version 3.0, as published by the
102.13 - * Free Software Foundation.
102.14 - *
102.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
102.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
102.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
102.18 - * details.
102.19 - *
102.20 - * You should have received a copy of the GNU General Public License along with
102.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
102.22 - *
102.23 - * As a special exception, AlliedModders LLC gives you permission to link the
102.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
102.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
102.26 - * by the Valve Corporation. You must obey the GNU General Public License in
102.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
102.28 - * this exception to all derivative works. AlliedModders LLC defines further
102.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
102.30 - * or <http://www.sourcemod.net/license.php>.
102.31 - *
102.32 - * Version: $Id$
102.33 - */
102.34 -
102.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
102.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
102.37 -
102.38 -/**
102.39 - * @file smsdk_ext.h
102.40 - * @brief Contains wrappers for making Extensions easier to write.
102.41 - */
102.42 -
102.43 -#include "smsdk_config.h"
102.44 -#include <IExtensionSys.h>
102.45 -#include <IHandleSys.h>
102.46 -#include <sp_vm_api.h>
102.47 -#include <sm_platform.h>
102.48 -#include <ISourceMod.h>
102.49 -#if defined SMEXT_ENABLE_FORWARDSYS
102.50 -#include <IForwardSys.h>
102.51 -#endif //SMEXT_ENABLE_FORWARDSYS
102.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
102.53 -#include <IPlayerHelpers.h>
102.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
102.55 -#if defined SMEXT_ENABLE_DBMANAGER
102.56 -#include <IDBDriver.h>
102.57 -#endif //SMEXT_ENABLE_DBMANAGER
102.58 -#if defined SMEXT_ENABLE_GAMECONF
102.59 -#include <IGameConfigs.h>
102.60 -#endif
102.61 -#if defined SMEXT_ENABLE_MEMUTILS
102.62 -#include <IMemoryUtils.h>
102.63 -#endif
102.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
102.65 -#include <IGameHelpers.h>
102.66 -#endif
102.67 -#if defined SMEXT_ENABLE_TIMERSYS
102.68 -#include <ITimerSystem.h>
102.69 -#endif
102.70 -#if defined SMEXT_ENABLE_ADTFACTORY
102.71 -#include <IADTFactory.h>
102.72 -#endif
102.73 -#if defined SMEXT_ENABLE_THREADER
102.74 -#include <IThreader.h>
102.75 -#endif
102.76 -#if defined SMEXT_ENABLE_LIBSYS
102.77 -#include <ILibrarySys.h>
102.78 -#endif
102.79 -#if defined SMEXT_ENABLE_PLUGINSYS
102.80 -#include <IPluginSys.h>
102.81 -#endif
102.82 -#if defined SMEXT_ENABLE_MENUS
102.83 -#include <IMenuManager.h>
102.84 -#endif
102.85 -#if defined SMEXT_ENABLE_ADMINSYS
102.86 -#include <IAdminSystem.h>
102.87 -#endif
102.88 -#if defined SMEXT_ENABLE_TEXTPARSERS
102.89 -#include <ITextParsers.h>
102.90 -#endif
102.91 -#if defined SMEXT_ENABLE_USERMSGS
102.92 -#include <IUserMessages.h>
102.93 -#endif
102.94 -#if defined SMEXT_ENABLE_TRANSLATOR
102.95 -#include <ITranslator.h>
102.96 -#endif
102.97 -#if defined SMEXT_ENABLE_NINVOKE
102.98 -#include <INativeInvoker.h>
102.99 -#endif
102.100 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
102.101 -#include <IRootConsoleMenu.h>
102.102 -#endif
102.103 -
102.104 -#if defined SMEXT_CONF_METAMOD
102.105 -#include <ISmmPlugin.h>
102.106 -#include <eiface.h>
102.107 -#endif
102.108 -
102.109 -using namespace SourceMod;
102.110 -using namespace SourcePawn;
102.111 -
102.112 -class SDKExtension :
102.113 -#if defined SMEXT_CONF_METAMOD
102.114 - public ISmmPlugin,
102.115 -#endif
102.116 - public IExtensionInterface
102.117 -{
102.118 -public:
102.119 - /** Constructor */
102.120 - SDKExtension();
102.121 -public:
102.122 - /**
102.123 - * @brief This is called after the initial loading sequence has been processed.
102.124 - *
102.125 - * @param error Error message buffer.
102.126 - * @param maxlength Size of error message buffer.
102.127 - * @param late Whether or not the module was loaded after map load.
102.128 - * @return True to succeed loading, false to fail.
102.129 - */
102.130 - virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
102.131 -
102.132 - /**
102.133 - * @brief This is called once the extension unloading process begins.
102.134 - */
102.135 - virtual void SDK_OnUnload();
102.136 -
102.137 - /**
102.138 - * @brief This is called once all known extensions have been loaded.
102.139 - */
102.140 - virtual void SDK_OnAllLoaded();
102.141 -
102.142 - /**
102.143 - * @brief Called when the pause state is changed.
102.144 - */
102.145 - virtual void SDK_OnPauseChange(bool paused);
102.146 -
102.147 - /**
102.148 - * @brief Called after SDK_OnUnload, once all dependencies have been
102.149 - * removed, and the extension is about to be removed from memory.
102.150 - */
102.151 - virtual void SDK_OnDependenciesDropped();
102.152 -
102.153 -#if defined SMEXT_CONF_METAMOD
102.154 - /**
102.155 - * @brief Called when Metamod is attached, before the extension version is called.
102.156 - *
102.157 - * @param error Error buffer.
102.158 - * @param maxlength Maximum size of error buffer.
102.159 - * @param late Whether or not Metamod considers this a late load.
102.160 - * @return True to succeed, false to fail.
102.161 - */
102.162 - virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
102.163 -
102.164 - /**
102.165 - * @brief Called when Metamod is detaching, after the extension version is called.
102.166 - * NOTE: By default this is blocked unless sent from SourceMod.
102.167 - *
102.168 - * @param error Error buffer.
102.169 - * @param maxlength Maximum size of error buffer.
102.170 - * @return True to succeed, false to fail.
102.171 - */
102.172 - virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
102.173 -
102.174 - /**
102.175 - * @brief Called when Metamod's pause state is changing.
102.176 - * NOTE: By default this is blocked unless sent from SourceMod.
102.177 - *
102.178 - * @param paused Pause state being set.
102.179 - * @param error Error buffer.
102.180 - * @param maxlength Maximum size of error buffer.
102.181 - * @return True to succeed, false to fail.
102.182 - */
102.183 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
102.184 -#endif
102.185 -
102.186 -public: //IExtensionInterface
102.187 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
102.188 - virtual void OnExtensionUnload();
102.189 - virtual void OnExtensionsAllLoaded();
102.190 -
102.191 - /** Returns whether or not this is a Metamod-based extension */
102.192 - virtual bool IsMetamodExtension();
102.193 -
102.194 - /**
102.195 - * @brief Called when the pause state changes.
102.196 - *
102.197 - * @param state True if being paused, false if being unpaused.
102.198 - */
102.199 - virtual void OnExtensionPauseChange(bool state);
102.200 -
102.201 - /** Returns name */
102.202 - virtual const char *GetExtensionName();
102.203 - /** Returns URL */
102.204 - virtual const char *GetExtensionURL();
102.205 - /** Returns log tag */
102.206 - virtual const char *GetExtensionTag();
102.207 - /** Returns author */
102.208 - virtual const char *GetExtensionAuthor();
102.209 - /** Returns version string */
102.210 - virtual const char *GetExtensionVerString();
102.211 - /** Returns description string */
102.212 - virtual const char *GetExtensionDescription();
102.213 - /** Returns date string */
102.214 - virtual const char *GetExtensionDateString();
102.215 -
102.216 - /** Called after OnExtensionUnload, once dependencies have been dropped. */
102.217 - virtual void OnDependenciesDropped();
102.218 -#if defined SMEXT_CONF_METAMOD
102.219 -public: //ISmmPlugin
102.220 - /** Called when the extension is attached to Metamod. */
102.221 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
102.222 - /** Returns the author to MM */
102.223 - virtual const char *GetAuthor();
102.224 - /** Returns the name to MM */
102.225 - virtual const char *GetName();
102.226 - /** Returns the description to MM */
102.227 - virtual const char *GetDescription();
102.228 - /** Returns the URL to MM */
102.229 - virtual const char *GetURL();
102.230 - /** Returns the license to MM */
102.231 - virtual const char *GetLicense();
102.232 - /** Returns the version string to MM */
102.233 - virtual const char *GetVersion();
102.234 - /** Returns the date string to MM */
102.235 - virtual const char *GetDate();
102.236 - /** Returns the logtag to MM */
102.237 - virtual const char *GetLogTag();
102.238 - /** Called on unload */
102.239 - virtual bool Unload(char *error, size_t maxlength);
102.240 - /** Called on pause */
102.241 - virtual bool Pause(char *error, size_t maxlength);
102.242 - /** Called on unpause */
102.243 - virtual bool Unpause(char *error, size_t maxlength);
102.244 -private:
102.245 - bool m_SourceMMLoaded;
102.246 - bool m_WeAreUnloaded;
102.247 - bool m_WeGotPauseChange;
102.248 -#endif
102.249 -};
102.250 -
102.251 -extern SDKExtension *g_pExtensionIface;
102.252 -extern IExtension *myself;
102.253 -
102.254 -extern IShareSys *g_pShareSys;
102.255 -extern IShareSys *sharesys; /* Note: Newer name */
102.256 -extern ISourceMod *g_pSM;
102.257 -extern ISourceMod *smutils; /* Note: Newer name */
102.258 -
102.259 -/* Optional interfaces are below */
102.260 -#if defined SMEXT_ENABLE_FORWARDSYS
102.261 -extern IForwardManager *g_pForwards;
102.262 -extern IForwardManager *forwards; /* Note: Newer name */
102.263 -#endif //SMEXT_ENABLE_FORWARDSYS
102.264 -#if defined SMEXT_ENABLE_HANDLESYS
102.265 -extern IHandleSys *g_pHandleSys;
102.266 -extern IHandleSys *handlesys; /* Note: Newer name */
102.267 -#endif //SMEXT_ENABLE_HANDLESYS
102.268 -#if defined SMEXT_ENABLE_PLAYERHELPERS
102.269 -extern IPlayerManager *playerhelpers;
102.270 -#endif //SMEXT_ENABLE_PLAYERHELPERS
102.271 -#if defined SMEXT_ENABLE_DBMANAGER
102.272 -extern IDBManager *dbi;
102.273 -#endif //SMEXT_ENABLE_DBMANAGER
102.274 -#if defined SMEXT_ENABLE_GAMECONF
102.275 -extern IGameConfigManager *gameconfs;
102.276 -#endif //SMEXT_ENABLE_DBMANAGER
102.277 -#if defined SMEXT_ENABLE_MEMUTILS
102.278 -extern IMemoryUtils *memutils;
102.279 -#endif
102.280 -#if defined SMEXT_ENABLE_GAMEHELPERS
102.281 -extern IGameHelpers *gamehelpers;
102.282 -#endif
102.283 -#if defined SMEXT_ENABLE_TIMERSYS
102.284 -extern ITimerSystem *timersys;
102.285 -#endif
102.286 -#if defined SMEXT_ENABLE_ADTFACTORY
102.287 -extern IADTFactory *adtfactory;
102.288 -#endif
102.289 -#if defined SMEXT_ENABLE_THREADER
102.290 -extern IThreader *threader;
102.291 -#endif
102.292 -#if defined SMEXT_ENABLE_LIBSYS
102.293 -extern ILibrarySys *libsys;
102.294 -#endif
102.295 -#if defined SMEXT_ENABLE_PLUGINSYS
102.296 -extern SourceMod::IPluginManager *plsys;
102.297 -#endif
102.298 -#if defined SMEXT_ENABLE_MENUS
102.299 -extern IMenuManager *menus;
102.300 -#endif
102.301 -#if defined SMEXT_ENABLE_ADMINSYS
102.302 -extern IAdminSystem *adminsys;
102.303 -#endif
102.304 -#if defined SMEXT_ENABLE_USERMSGS
102.305 -extern IUserMessages *usermsgs;
102.306 -#endif
102.307 -#if defined SMEXT_ENABLE_TRANSLATOR
102.308 -extern ITranslator *translator;
102.309 -#endif
102.310 -#if defined SMEXT_ENABLE_NINVOKE
102.311 -extern INativeInterface *ninvoke;
102.312 -#endif
102.313 -#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
102.314 -extern IRootConsole *rootconsole;
102.315 -#endif
102.316 -
102.317 -#if defined SMEXT_CONF_METAMOD
102.318 -PLUGIN_GLOBALVARS();
102.319 -extern IVEngineServer *engine;
102.320 -extern IServerGameDLL *gamedll;
102.321 -#endif
102.322 -
102.323 -/** Creates a SourceMod interface macro pair */
102.324 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
102.325 -/** Automates retrieving SourceMod interfaces */
102.326 -#define SM_GET_IFACE(prefix, addr) \
102.327 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
102.328 - { \
102.329 - if (error != NULL && maxlength) \
102.330 - { \
102.331 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
102.332 - if (len >= maxlength) \
102.333 - { \
102.334 - error[maxlength - 1] = '\0'; \
102.335 - } \
102.336 - } \
102.337 - return false; \
102.338 - }
102.339 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
102.340 -#define SM_GET_LATE_IFACE(prefix, addr) \
102.341 - g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
102.342 -/** Validates a SourceMod interface pointer */
102.343 -#define SM_CHECK_IFACE(prefix, addr) \
102.344 - if (!addr) \
102.345 - { \
102.346 - if (error != NULL && maxlength) \
102.347 - { \
102.348 - size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
102.349 - if (len >= maxlength) \
102.350 - { \
102.351 - error[maxlength - 1] = '\0'; \
102.352 - } \
102.353 - } \
102.354 - return false; \
102.355 - }
102.356 -
102.357 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
103.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
103.2 +++ b/public/sample_ext/smsdk_config.h Wed Apr 23 21:19:28 2014 -0500
103.3 @@ -0,0 +1,82 @@
103.4 +/**
103.5 + * vim: set ts=4 :
103.6 + * =============================================================================
103.7 + * SourceMod Sample Extension
103.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
103.9 + * =============================================================================
103.10 + *
103.11 + * This program is free software; you can redistribute it and/or modify it under
103.12 + * the terms of the GNU General Public License, version 3.0, as published by the
103.13 + * Free Software Foundation.
103.14 + *
103.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
103.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
103.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
103.18 + * details.
103.19 + *
103.20 + * You should have received a copy of the GNU General Public License along with
103.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
103.22 + *
103.23 + * As a special exception, AlliedModders LLC gives you permission to link the
103.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
103.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
103.26 + * by the Valve Corporation. You must obey the GNU General Public License in
103.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
103.28 + * this exception to all derivative works. AlliedModders LLC defines further
103.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
103.30 + * or <http://www.sourcemod.net/license.php>.
103.31 + *
103.32 + * Version: $Id$
103.33 + */
103.34 +
103.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
103.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
103.37 +
103.38 +/**
103.39 + * @file smsdk_config.h
103.40 + * @brief Contains macros for configuring basic extension information.
103.41 + */
103.42 +
103.43 +/* Basic information exposed publicly */
103.44 +#define SMEXT_CONF_NAME "Sample Extension"
103.45 +#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers"
103.46 +#define SMEXT_CONF_VERSION "0.0.0.0"
103.47 +#define SMEXT_CONF_AUTHOR "AlliedModders"
103.48 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
103.49 +#define SMEXT_CONF_LOGTAG "SAMPLE"
103.50 +#define SMEXT_CONF_LICENSE "GPL"
103.51 +#define SMEXT_CONF_DATESTRING __DATE__
103.52 +
103.53 +/**
103.54 + * @brief Exposes plugin's main interface.
103.55 + */
103.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
103.57 +
103.58 +/**
103.59 + * @brief Sets whether or not this plugin required Metamod.
103.60 + * NOTE: Uncomment to enable, comment to disable.
103.61 + */
103.62 +//#define SMEXT_CONF_METAMOD
103.63 +
103.64 +/** Enable interfaces you want to use here by uncommenting lines */
103.65 +//#define SMEXT_ENABLE_FORWARDSYS
103.66 +//#define SMEXT_ENABLE_HANDLESYS
103.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
103.68 +//#define SMEXT_ENABLE_DBMANAGER
103.69 +//#define SMEXT_ENABLE_GAMECONF
103.70 +//#define SMEXT_ENABLE_MEMUTILS
103.71 +//#define SMEXT_ENABLE_GAMEHELPERS
103.72 +//#define SMEXT_ENABLE_TIMERSYS
103.73 +//#define SMEXT_ENABLE_THREADER
103.74 +//#define SMEXT_ENABLE_LIBSYS
103.75 +//#define SMEXT_ENABLE_MENUS
103.76 +//#define SMEXT_ENABLE_ADTFACTORY
103.77 +//#define SMEXT_ENABLE_PLUGINSYS
103.78 +//#define SMEXT_ENABLE_ADMINSYS
103.79 +//#define SMEXT_ENABLE_TEXTPARSERS
103.80 +//#define SMEXT_ENABLE_USERMSGS
103.81 +//#define SMEXT_ENABLE_TRANSLATOR
103.82 +//#define SMEXT_ENABLE_NINVOKE
103.83 +//#define SMEXT_ENABLE_ROOTCONSOLEMENU
103.84 +
103.85 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
104.2 +++ b/public/sm_memtable.h Wed Apr 23 21:19:28 2014 -0500
104.3 @@ -0,0 +1,170 @@
104.4 +/**
104.5 + * vim: set ts=4 sw=4 tw=99 noet :
104.6 + * =============================================================================
104.7 + * SourceMod
104.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
104.9 + * =============================================================================
104.10 + *
104.11 + * This program is free software; you can redistribute it and/or modify it under
104.12 + * the terms of the GNU General Public License, version 3.0, as published by the
104.13 + * Free Software Foundation.
104.14 + *
104.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
104.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
104.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
104.18 + * details.
104.19 + *
104.20 + * You should have received a copy of the GNU General Public License along with
104.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
104.22 + *
104.23 + * As a special exception, AlliedModders LLC gives you permission to link the
104.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
104.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
104.26 + * by the Valve Corporation. You must obey the GNU General Public License in
104.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
104.28 + * this exception to all derivative works. AlliedModders LLC defines further
104.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
104.30 + * or <http://www.sourcemod.net/license.php>.
104.31 + *
104.32 + * Version: $Id$
104.33 + */
104.34 +
104.35 +#ifndef _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
104.36 +#define _INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
104.37 +
104.38 +#include <stdlib.h>
104.39 +#include <string.h>
104.40 +
104.41 +class BaseMemTable
104.42 +{
104.43 +public:
104.44 + BaseMemTable(unsigned int init_size)
104.45 + {
104.46 + membase = (unsigned char *)malloc(init_size);
104.47 + size = init_size;
104.48 + tail = 0;
104.49 + }
104.50 + ~BaseMemTable()
104.51 + {
104.52 + free(membase);
104.53 + membase = NULL;
104.54 + }
104.55 +public:
104.56 + /**
104.57 + * Allocates 'size' bytes of memory.
104.58 + * Optionally outputs the address through 'addr'.
104.59 + * Returns an index >= 0 on success, < 0 on failure.
104.60 + */
104.61 + int CreateMem(unsigned int addsize, void **addr)
104.62 + {
104.63 + int idx = (int)tail;
104.64 +
104.65 + while (tail + addsize >= size) {
104.66 + size *= 2;
104.67 + membase = (unsigned char *)realloc(membase, size);
104.68 + }
104.69 +
104.70 + tail += addsize;
104.71 + if (addr)
104.72 + *addr = (void *)&membase[idx];
104.73 +
104.74 + return idx;
104.75 + }
104.76 +
104.77 + /**
104.78 + * Given an index into the memory table, returns its address.
104.79 + * Returns NULL if invalid.
104.80 + */
104.81 + void *GetAddress(int index)
104.82 + {
104.83 + if (index < 0 || (unsigned int)index >= tail)
104.84 + return NULL;
104.85 + return &membase[index];
104.86 + }
104.87 +
104.88 + /**
104.89 + * Scraps the memory table. For caching purposes, the memory
104.90 + * is not freed, however subsequent calls to CreateMem() will
104.91 + * begin at the first index again.
104.92 + */
104.93 + void Reset()
104.94 + {
104.95 + tail = 0;
104.96 + }
104.97 +
104.98 + inline unsigned int GetMemUsage()
104.99 + {
104.100 + return size;
104.101 + }
104.102 +
104.103 + inline unsigned int GetActualMemUsed()
104.104 + {
104.105 + return tail;
104.106 + }
104.107 +
104.108 +private:
104.109 + unsigned char *membase;
104.110 + unsigned int size;
104.111 + unsigned int tail;
104.112 +};
104.113 +
104.114 +class BaseStringTable
104.115 +{
104.116 +public:
104.117 + BaseStringTable(unsigned int init_size) : m_table(init_size)
104.118 + {
104.119 + }
104.120 +public:
104.121 + /**
104.122 + * Adds a string to the string table and returns its index.
104.123 + */
104.124 + int AddString(const char *string)
104.125 + {
104.126 + return AddString(string, strlen(string));
104.127 + }
104.128 +
104.129 + /**
104.130 + * Adds a string to the string table and returns its index.
104.131 + */
104.132 + int AddString(const char *string, size_t length)
104.133 + {
104.134 + size_t len = length + 1;
104.135 + int idx;
104.136 + char *addr;
104.137 +
104.138 + idx = m_table.CreateMem(len, (void **)&addr);
104.139 + memcpy(addr, string, length + 1);
104.140 + return idx;
104.141 + }
104.142 +
104.143 + /**
104.144 + * Given an index into the string table, returns the associated string.
104.145 + */
104.146 + inline const char *GetString(int str)
104.147 + {
104.148 + return (const char *)m_table.GetAddress(str);
104.149 + }
104.150 +
104.151 + /**
104.152 + * Scraps the string table. For caching purposes, the memory
104.153 + * is not freed, however subsequent calls to AddString() will
104.154 + * begin at the first index again.
104.155 + */
104.156 + void Reset()
104.157 + {
104.158 + m_table.Reset();
104.159 + }
104.160 +
104.161 + /**
104.162 + * Returns the parent BaseMemTable that this string table uses.
104.163 + */
104.164 + inline BaseMemTable *GetMemTable()
104.165 + {
104.166 + return &m_table;
104.167 + }
104.168 +private:
104.169 + BaseMemTable m_table;
104.170 +};
104.171 +
104.172 +#endif //_INCLUDE_SOURCEMOD_CORE_STRINGTABLE_H_
104.173 +
105.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
105.2 +++ b/public/smsdk_ext.cpp Wed Apr 23 21:19:28 2014 -0500
105.3 @@ -0,0 +1,483 @@
105.4 +/**
105.5 + * vim: set ts=4 sw=4 tw=99 noet:
105.6 + * =============================================================================
105.7 + * SourceMod Base Extension Code
105.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
105.9 + * =============================================================================
105.10 + *
105.11 + * This program is free software; you can redistribute it and/or modify it under
105.12 + * the terms of the GNU General Public License, version 3.0, as published by the
105.13 + * Free Software Foundation.
105.14 + *
105.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
105.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
105.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
105.18 + * details.
105.19 + *
105.20 + * You should have received a copy of the GNU General Public License along with
105.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
105.22 + *
105.23 + * As a special exception, AlliedModders LLC gives you permission to link the
105.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
105.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
105.26 + * by the Valve Corporation. You must obey the GNU General Public License in
105.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
105.28 + * this exception to all derivative works. AlliedModders LLC defines further
105.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
105.30 + * or <http://www.sourcemod.net/license.php>.
105.31 + *
105.32 + * Version: $Id$
105.33 + */
105.34 +
105.35 +#include <stdio.h>
105.36 +#include <stdlib.h>
105.37 +#include "smsdk_ext.h"
105.38 +
105.39 +/**
105.40 + * @file smsdk_ext.cpp
105.41 + * @brief Contains wrappers for making Extensions easier to write.
105.42 + */
105.43 +
105.44 +IExtension *myself = NULL; /**< Ourself */
105.45 +IShareSys *g_pShareSys = NULL; /**< Share system */
105.46 +IShareSys *sharesys = NULL; /**< Share system */
105.47 +ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
105.48 +ISourceMod *smutils = NULL; /**< SourceMod helpers */
105.49 +
105.50 +#if defined SMEXT_ENABLE_FORWARDSYS
105.51 +IForwardManager *g_pForwards = NULL; /**< Forward system */
105.52 +IForwardManager *forwards = NULL; /**< Forward system */
105.53 +#endif
105.54 +#if defined SMEXT_ENABLE_HANDLESYS
105.55 +IHandleSys *g_pHandleSys = NULL; /**< Handle system */
105.56 +IHandleSys *handlesys = NULL; /**< Handle system */
105.57 +#endif
105.58 +#if defined SMEXT_ENABLE_PLAYERHELPERS
105.59 +IPlayerManager *playerhelpers = NULL; /**< Player helpers */
105.60 +#endif //SMEXT_ENABLE_PLAYERHELPERS
105.61 +#if defined SMEXT_ENABLE_DBMANAGER
105.62 +IDBManager *dbi = NULL; /**< DB Manager */
105.63 +#endif //SMEXT_ENABLE_DBMANAGER
105.64 +#if defined SMEXT_ENABLE_GAMECONF
105.65 +IGameConfigManager *gameconfs = NULL; /**< Game config manager */
105.66 +#endif //SMEXT_ENABLE_DBMANAGER
105.67 +#if defined SMEXT_ENABLE_MEMUTILS
105.68 +IMemoryUtils *memutils = NULL;
105.69 +#endif //SMEXT_ENABLE_DBMANAGER
105.70 +#if defined SMEXT_ENABLE_GAMEHELPERS
105.71 +IGameHelpers *gamehelpers = NULL;
105.72 +#endif
105.73 +#if defined SMEXT_ENABLE_TIMERSYS
105.74 +ITimerSystem *timersys = NULL;
105.75 +#endif
105.76 +#if defined SMEXT_ENABLE_ADTFACTORY
105.77 +IADTFactory *adtfactory = NULL;
105.78 +#endif
105.79 +#if defined SMEXT_ENABLE_THREADER
105.80 +IThreader *threader = NULL;
105.81 +#endif
105.82 +#if defined SMEXT_ENABLE_LIBSYS
105.83 +ILibrarySys *libsys = NULL;
105.84 +#endif
105.85 +#if defined SMEXT_ENABLE_PLUGINSYS
105.86 +SourceMod::IPluginManager *plsys;
105.87 +#endif
105.88 +#if defined SMEXT_ENABLE_MENUS
105.89 +IMenuManager *menus = NULL;
105.90 +#endif
105.91 +#if defined SMEXT_ENABLE_ADMINSYS
105.92 +IAdminSystem *adminsys = NULL;
105.93 +#endif
105.94 +#if defined SMEXT_ENABLE_TEXTPARSERS
105.95 +ITextParsers *textparsers = NULL;
105.96 +#endif
105.97 +#if defined SMEXT_ENABLE_USERMSGS
105.98 +IUserMessages *usermsgs = NULL;
105.99 +#endif
105.100 +#if defined SMEXT_ENABLE_TRANSLATOR
105.101 +ITranslator *translator = NULL;
105.102 +#endif
105.103 +#if defined SMEXT_ENABLE_NINVOKE
105.104 +INativeInterface *ninvoke = NULL;
105.105 +#endif
105.106 +#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
105.107 +IRootConsole *rootconsole = NULL;
105.108 +#endif
105.109 +
105.110 +/** Exports the main interface */
105.111 +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
105.112 +{
105.113 + return g_pExtensionIface;
105.114 +}
105.115 +
105.116 +SDKExtension::SDKExtension()
105.117 +{
105.118 +#if defined SMEXT_CONF_METAMOD
105.119 + m_SourceMMLoaded = false;
105.120 + m_WeAreUnloaded = false;
105.121 + m_WeGotPauseChange = false;
105.122 +#endif
105.123 +}
105.124 +
105.125 +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
105.126 +{
105.127 + g_pShareSys = sharesys = sys;
105.128 + myself = me;
105.129 +
105.130 +#if defined SMEXT_CONF_METAMOD
105.131 + m_WeAreUnloaded = true;
105.132 +
105.133 + if (!m_SourceMMLoaded)
105.134 + {
105.135 + if (error)
105.136 + {
105.137 + snprintf(error, maxlength, "Metamod attach failed");
105.138 + }
105.139 + return false;
105.140 + }
105.141 +#endif
105.142 + SM_GET_IFACE(SOURCEMOD, g_pSM);
105.143 + smutils = g_pSM;
105.144 +#if defined SMEXT_ENABLE_HANDLESYS
105.145 + SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
105.146 + handlesys = g_pHandleSys;
105.147 +#endif
105.148 +#if defined SMEXT_ENABLE_FORWARDSYS
105.149 + SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
105.150 + forwards = g_pForwards;
105.151 +#endif
105.152 +#if defined SMEXT_ENABLE_PLAYERHELPERS
105.153 + SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
105.154 +#endif
105.155 +#if defined SMEXT_ENABLE_DBMANAGER
105.156 + SM_GET_IFACE(DBI, dbi);
105.157 +#endif
105.158 +#if defined SMEXT_ENABLE_GAMECONF
105.159 + SM_GET_IFACE(GAMECONFIG, gameconfs);
105.160 +#endif
105.161 +#if defined SMEXT_ENABLE_MEMUTILS
105.162 + SM_GET_IFACE(MEMORYUTILS, memutils);
105.163 +#endif
105.164 +#if defined SMEXT_ENABLE_GAMEHELPERS
105.165 + SM_GET_IFACE(GAMEHELPERS, gamehelpers);
105.166 +#endif
105.167 +#if defined SMEXT_ENABLE_TIMERSYS
105.168 + SM_GET_IFACE(TIMERSYS, timersys);
105.169 +#endif
105.170 +#if defined SMEXT_ENABLE_ADTFACTORY
105.171 + SM_GET_IFACE(ADTFACTORY, adtfactory);
105.172 +#endif
105.173 +#if defined SMEXT_ENABLE_THREADER
105.174 + SM_GET_IFACE(THREADER, threader);
105.175 +#endif
105.176 +#if defined SMEXT_ENABLE_LIBSYS
105.177 + SM_GET_IFACE(LIBRARYSYS, libsys);
105.178 +#endif
105.179 +#if defined SMEXT_ENABLE_PLUGINSYS
105.180 + SM_GET_IFACE(PLUGINSYSTEM, plsys);
105.181 +#endif
105.182 +#if defined SMEXT_ENABLE_MENUS
105.183 + SM_GET_IFACE(MENUMANAGER, menus);
105.184 +#endif
105.185 +#if defined SMEXT_ENABLE_ADMINSYS
105.186 + SM_GET_IFACE(ADMINSYS, adminsys);
105.187 +#endif
105.188 +#if defined SMEXT_ENABLE_TEXTPARSERS
105.189 + SM_GET_IFACE(TEXTPARSERS, textparsers);
105.190 +#endif
105.191 +#if defined SMEXT_ENABLE_USERMSGS
105.192 + SM_GET_IFACE(USERMSGS, usermsgs);
105.193 +#endif
105.194 +#if defined SMEXT_ENABLE_TRANSLATOR
105.195 + SM_GET_IFACE(TRANSLATOR, translator);
105.196 +#endif
105.197 +#if defined SMEXT_ENABLE_NINVOKE
105.198 + SM_GET_IFACE(NINVOKE, ninvoke);
105.199 +#endif
105.200 +#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
105.201 + SM_GET_IFACE(ROOTCONSOLE, rootconsole);
105.202 +#endif
105.203 +
105.204 + if (SDK_OnLoad(error, maxlength, late))
105.205 + {
105.206 +#if defined SMEXT_CONF_METAMOD
105.207 + m_WeAreUnloaded = true;
105.208 +#endif
105.209 + return true;
105.210 + }
105.211 +
105.212 + return false;
105.213 +}
105.214 +
105.215 +bool SDKExtension::IsMetamodExtension()
105.216 +{
105.217 +#if defined SMEXT_CONF_METAMOD
105.218 + return true;
105.219 +#else
105.220 + return false;
105.221 +#endif
105.222 +}
105.223 +
105.224 +void SDKExtension::OnExtensionPauseChange(bool state)
105.225 +{
105.226 +#if defined SMEXT_CONF_METAMOD
105.227 + m_WeGotPauseChange = true;
105.228 +#endif
105.229 + SDK_OnPauseChange(state);
105.230 +}
105.231 +
105.232 +void SDKExtension::OnExtensionsAllLoaded()
105.233 +{
105.234 + SDK_OnAllLoaded();
105.235 +}
105.236 +
105.237 +void SDKExtension::OnExtensionUnload()
105.238 +{
105.239 +#if defined SMEXT_CONF_METAMOD
105.240 + m_WeAreUnloaded = true;
105.241 +#endif
105.242 + SDK_OnUnload();
105.243 +}
105.244 +
105.245 +void SDKExtension::OnDependenciesDropped()
105.246 +{
105.247 + SDK_OnDependenciesDropped();
105.248 +}
105.249 +
105.250 +const char *SDKExtension::GetExtensionAuthor()
105.251 +{
105.252 + return SMEXT_CONF_AUTHOR;
105.253 +}
105.254 +
105.255 +const char *SDKExtension::GetExtensionDateString()
105.256 +{
105.257 + return SMEXT_CONF_DATESTRING;
105.258 +}
105.259 +
105.260 +const char *SDKExtension::GetExtensionDescription()
105.261 +{
105.262 + return SMEXT_CONF_DESCRIPTION;
105.263 +}
105.264 +
105.265 +const char *SDKExtension::GetExtensionVerString()
105.266 +{
105.267 + return SMEXT_CONF_VERSION;
105.268 +}
105.269 +
105.270 +const char *SDKExtension::GetExtensionName()
105.271 +{
105.272 + return SMEXT_CONF_NAME;
105.273 +}
105.274 +
105.275 +const char *SDKExtension::GetExtensionTag()
105.276 +{
105.277 + return SMEXT_CONF_LOGTAG;
105.278 +}
105.279 +
105.280 +const char *SDKExtension::GetExtensionURL()
105.281 +{
105.282 + return SMEXT_CONF_URL;
105.283 +}
105.284 +
105.285 +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
105.286 +{
105.287 + return true;
105.288 +}
105.289 +
105.290 +void SDKExtension::SDK_OnUnload()
105.291 +{
105.292 +}
105.293 +
105.294 +void SDKExtension::SDK_OnPauseChange(bool paused)
105.295 +{
105.296 +}
105.297 +
105.298 +void SDKExtension::SDK_OnAllLoaded()
105.299 +{
105.300 +}
105.301 +
105.302 +void SDKExtension::SDK_OnDependenciesDropped()
105.303 +{
105.304 +}
105.305 +
105.306 +#if defined SMEXT_CONF_METAMOD
105.307 +
105.308 +PluginId g_PLID = 0; /**< Metamod plugin ID */
105.309 +ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
105.310 +SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
105.311 +ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
105.312 +
105.313 +IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
105.314 +IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
105.315 +
105.316 +/** Exposes the extension to Metamod */
105.317 +SMM_API void *PL_EXPOSURE(const char *name, int *code)
105.318 +{
105.319 +#if defined METAMOD_PLAPI_VERSION
105.320 + if (name && !strcmp(name, METAMOD_PLAPI_NAME))
105.321 +#else
105.322 + if (name && !strcmp(name, PLAPI_NAME))
105.323 +#endif
105.324 + {
105.325 + if (code)
105.326 + {
105.327 + *code = IFACE_OK;
105.328 + }
105.329 + return static_cast<void *>(g_pExtensionIface);
105.330 + }
105.331 +
105.332 + if (code)
105.333 + {
105.334 + *code = IFACE_FAILED;
105.335 + }
105.336 +
105.337 + return NULL;
105.338 +}
105.339 +
105.340 +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
105.341 +{
105.342 + PLUGIN_SAVEVARS();
105.343 +
105.344 +#if !defined METAMOD_PLAPI_VERSION
105.345 + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
105.346 + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
105.347 +#else
105.348 + GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
105.349 + GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
105.350 +#endif
105.351 +
105.352 + m_SourceMMLoaded = true;
105.353 +
105.354 + return SDK_OnMetamodLoad(ismm, error, maxlen, late);
105.355 +}
105.356 +
105.357 +bool SDKExtension::Unload(char *error, size_t maxlen)
105.358 +{
105.359 + if (!m_WeAreUnloaded)
105.360 + {
105.361 + if (error)
105.362 + {
105.363 + snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
105.364 + }
105.365 + return false;
105.366 + }
105.367 +
105.368 + return SDK_OnMetamodUnload(error, maxlen);
105.369 +}
105.370 +
105.371 +bool SDKExtension::Pause(char *error, size_t maxlen)
105.372 +{
105.373 + if (!m_WeGotPauseChange)
105.374 + {
105.375 + if (error)
105.376 + {
105.377 + snprintf(error, maxlen, "This extension must be paused by SourceMod.");
105.378 + }
105.379 + return false;
105.380 + }
105.381 +
105.382 + m_WeGotPauseChange = false;
105.383 +
105.384 + return SDK_OnMetamodPauseChange(true, error, maxlen);
105.385 +}
105.386 +
105.387 +bool SDKExtension::Unpause(char *error, size_t maxlen)
105.388 +{
105.389 + if (!m_WeGotPauseChange)
105.390 + {
105.391 + if (error)
105.392 + {
105.393 + snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
105.394 + }
105.395 + return false;
105.396 + }
105.397 +
105.398 + m_WeGotPauseChange = false;
105.399 +
105.400 + return SDK_OnMetamodPauseChange(false, error, maxlen);
105.401 +}
105.402 +
105.403 +const char *SDKExtension::GetAuthor()
105.404 +{
105.405 + return GetExtensionAuthor();
105.406 +}
105.407 +
105.408 +const char *SDKExtension::GetDate()
105.409 +{
105.410 + return GetExtensionDateString();
105.411 +}
105.412 +
105.413 +const char *SDKExtension::GetDescription()
105.414 +{
105.415 + return GetExtensionDescription();
105.416 +}
105.417 +
105.418 +const char *SDKExtension::GetLicense()
105.419 +{
105.420 + return SMEXT_CONF_LICENSE;
105.421 +}
105.422 +
105.423 +const char *SDKExtension::GetLogTag()
105.424 +{
105.425 + return GetExtensionTag();
105.426 +}
105.427 +
105.428 +const char *SDKExtension::GetName()
105.429 +{
105.430 + return GetExtensionName();
105.431 +}
105.432 +
105.433 +const char *SDKExtension::GetURL()
105.434 +{
105.435 + return GetExtensionURL();
105.436 +}
105.437 +
105.438 +const char *SDKExtension::GetVersion()
105.439 +{
105.440 + return GetExtensionVerString();
105.441 +}
105.442 +
105.443 +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
105.444 +{
105.445 + return true;
105.446 +}
105.447 +
105.448 +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
105.449 +{
105.450 + return true;
105.451 +}
105.452 +
105.453 +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
105.454 +{
105.455 + return true;
105.456 +}
105.457 +
105.458 +#endif
105.459 +
105.460 +/* Overload a few things to prevent libstdc++ linking */
105.461 +#if defined __linux__ || defined __APPLE__
105.462 +extern "C" void __cxa_pure_virtual(void)
105.463 +{
105.464 +}
105.465 +
105.466 +void *operator new(size_t size)
105.467 +{
105.468 + return malloc(size);
105.469 +}
105.470 +
105.471 +void *operator new[](size_t size)
105.472 +{
105.473 + return malloc(size);
105.474 +}
105.475 +
105.476 +void operator delete(void *ptr)
105.477 +{
105.478 + free(ptr);
105.479 +}
105.480 +
105.481 +void operator delete[](void * ptr)
105.482 +{
105.483 + free(ptr);
105.484 +}
105.485 +#endif
105.486 +
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
106.2 +++ b/public/smsdk_ext.h Wed Apr 23 21:19:28 2014 -0500
106.3 @@ -0,0 +1,354 @@
106.4 +/**
106.5 + * vim: set ts=4 sw=4 tw=99 noet:
106.6 + * =============================================================================
106.7 + * SourceMod Base Extension Code
106.8 + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
106.9 + * =============================================================================
106.10 + *
106.11 + * This program is free software; you can redistribute it and/or modify it under
106.12 + * the terms of the GNU General Public License, version 3.0, as published by the
106.13 + * Free Software Foundation.
106.14 + *
106.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
106.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
106.17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
106.18 + * details.
106.19 + *
106.20 + * You should have received a copy of the GNU General Public License along with
106.21 + * this program. If not, see <http://www.gnu.org/licenses/>.
106.22 + *
106.23 + * As a special exception, AlliedModders LLC gives you permission to link the
106.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
106.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
106.26 + * by the Valve Corporation. You must obey the GNU General Public License in
106.27 + * all respects for all other code used. Additionally, AlliedModders LLC grants
106.28 + * this exception to all derivative works. AlliedModders LLC defines further
106.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
106.30 + * or <http://www.sourcemod.net/license.php>.
106.31 + *
106.32 + * Version: $Id$
106.33 + */
106.34 +
106.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
106.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
106.37 +
106.38 +/**
106.39 + * @file smsdk_ext.h
106.40 + * @brief Contains wrappers for making Extensions easier to write.
106.41 + */
106.42 +
106.43 +#include "smsdk_config.h"
106.44 +#include <IExtensionSys.h>
106.45 +#include <IHandleSys.h>
106.46 +#include <sp_vm_api.h>
106.47 +#include <sm_platform.h>
106.48 +#include <ISourceMod.h>
106.49 +#if defined SMEXT_ENABLE_FORWARDSYS
106.50 +#include <IForwardSys.h>
106.51 +#endif //SMEXT_ENABLE_FORWARDSYS
106.52 +#if defined SMEXT_ENABLE_PLAYERHELPERS
106.53 +#include <IPlayerHelpers.h>
106.54 +#endif //SMEXT_ENABLE_PlAYERHELPERS
106.55 +#if defined SMEXT_ENABLE_DBMANAGER
106.56 +#include <IDBDriver.h>
106.57 +#endif //SMEXT_ENABLE_DBMANAGER
106.58 +#if defined SMEXT_ENABLE_GAMECONF
106.59 +#include <IGameConfigs.h>
106.60 +#endif
106.61 +#if defined SMEXT_ENABLE_MEMUTILS
106.62 +#include <IMemoryUtils.h>
106.63 +#endif
106.64 +#if defined SMEXT_ENABLE_GAMEHELPERS
106.65 +#include <IGameHelpers.h>
106.66 +#endif
106.67 +#if defined SMEXT_ENABLE_TIMERSYS
106.68 +#include <ITimerSystem.h>
106.69 +#endif
106.70 +#if defined SMEXT_ENABLE_ADTFACTORY
106.71 +#include <IADTFactory.h>
106.72 +#endif
106.73 +#if defined SMEXT_ENABLE_THREADER
106.74 +#include <IThreader.h>
106.75 +#endif
106.76 +#if defined SMEXT_ENABLE_LIBSYS
106.77 +#include <ILibrarySys.h>
106.78 +#endif
106.79 +#if defined SMEXT_ENABLE_PLUGINSYS
106.80 +#include <IPluginSys.h>
106.81 +#endif
106.82 +#if defined SMEXT_ENABLE_MENUS
106.83 +#include <IMenuManager.h>
106.84 +#endif
106.85 +#if defined SMEXT_ENABLE_ADMINSYS
106.86 +#include <IAdminSystem.h>
106.87 +#endif
106.88 +#if defined SMEXT_ENABLE_TEXTPARSERS
106.89 +#include <ITextParsers.h>
106.90 +#endif
106.91 +#if defined SMEXT_ENABLE_USERMSGS
106.92 +#include <IUserMessages.h>
106.93 +#endif
106.94 +#if defined SMEXT_ENABLE_TRANSLATOR
106.95 +#include <ITranslator.h>
106.96 +#endif
106.97 +#if defined SMEXT_ENABLE_NINVOKE
106.98 +#include <INativeInvoker.h>
106.99 +#endif
106.100 +#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
106.101 +#include <IRootConsoleMenu.h>
106.102 +#endif
106.103 +
106.104 +#if defined SMEXT_CONF_METAMOD
106.105 +#include <ISmmPlugin.h>
106.106 +#include <eiface.h>
106.107 +#endif
106.108 +
106.109 +using namespace SourceMod;
106.110 +using namespace SourcePawn;
106.111 +
106.112 +class SDKExtension :
106.113 +#if defined SMEXT_CONF_METAMOD
106.114 + public ISmmPlugin,
106.115 +#endif
106.116 + public IExtensionInterface
106.117 +{
106.118 +public:
106.119 + /** Constructor */
106.120 + SDKExtension();
106.121 +public:
106.122 + /**
106.123 + * @brief This is called after the initial loading sequence has been processed.
106.124 + *
106.125 + * @param error Error message buffer.
106.126 + * @param maxlength Size of error message buffer.
106.127 + * @param late Whether or not the module was loaded after map load.
106.128 + * @return True to succeed loading, false to fail.
106.129 + */
106.130 + virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
106.131 +
106.132 + /**
106.133 + * @brief This is called once the extension unloading process begins.
106.134 + */
106.135 + virtual void SDK_OnUnload();
106.136 +
106.137 + /**
106.138 + * @brief This is called once all known extensions have been loaded.
106.139 + */
106.140 + virtual void SDK_OnAllLoaded();
106.141 +
106.142 + /**
106.143 + * @brief Called when the pause state is changed.
106.144 + */
106.145 + virtual void SDK_OnPauseChange(bool paused);
106.146 +
106.147 + /**
106.148 + * @brief Called after SDK_OnUnload, once all dependencies have been
106.149 + * removed, and the extension is about to be removed from memory.
106.150 + */
106.151 + virtual void SDK_OnDependenciesDropped();
106.152 +
106.153 +#if defined SMEXT_CONF_METAMOD
106.154 + /**
106.155 + * @brief Called when Metamod is attached, before the extension version is called.
106.156 + *
106.157 + * @param error Error buffer.
106.158 + * @param maxlength Maximum size of error buffer.
106.159 + * @param late Whether or not Metamod considers this a late load.
106.160 + * @return True to succeed, false to fail.
106.161 + */
106.162 + virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
106.163 +
106.164 + /**
106.165 + * @brief Called when Metamod is detaching, after the extension version is called.
106.166 + * NOTE: By default this is blocked unless sent from SourceMod.
106.167 + *
106.168 + * @param error Error buffer.
106.169 + * @param maxlength Maximum size of error buffer.
106.170 + * @return True to succeed, false to fail.
106.171 + */
106.172 + virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
106.173 +
106.174 + /**
106.175 + * @brief Called when Metamod's pause state is changing.
106.176 + * NOTE: By default this is blocked unless sent from SourceMod.
106.177 + *
106.178 + * @param paused Pause state being set.
106.179 + * @param error Error buffer.
106.180 + * @param maxlength Maximum size of error buffer.
106.181 + * @return True to succeed, false to fail.
106.182 + */
106.183 + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
106.184 +#endif
106.185 +
106.186 +public: //IExtensionInterface
106.187 + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
106.188 + virtual void OnExtensionUnload();
106.189 + virtual void OnExtensionsAllLoaded();
106.190 +
106.191 + /** Returns whether or not this is a Metamod-based extension */
106.192 + virtual bool IsMetamodExtension();
106.193 +
106.194 + /**
106.195 + * @brief Called when the pause state changes.
106.196 + *
106.197 + * @param state True if being paused, false if being unpaused.
106.198 + */
106.199 + virtual void OnExtensionPauseChange(bool state);
106.200 +
106.201 + /** Returns name */
106.202 + virtual const char *GetExtensionName();
106.203 + /** Returns URL */
106.204 + virtual const char *GetExtensionURL();
106.205 + /** Returns log tag */
106.206 + virtual const char *GetExtensionTag();
106.207 + /** Returns author */
106.208 + virtual const char *GetExtensionAuthor();
106.209 + /** Returns version string */
106.210 + virtual const char *GetExtensionVerString();
106.211 + /** Returns description string */
106.212 + virtual const char *GetExtensionDescription();
106.213 + /** Returns date string */
106.214 + virtual const char *GetExtensionDateString();
106.215 +
106.216 + /** Called after OnExtensionUnload, once dependencies have been dropped. */
106.217 + virtual void OnDependenciesDropped();
106.218 +#if defined SMEXT_CONF_METAMOD
106.219 +public: //ISmmPlugin
106.220 + /** Called when the extension is attached to Metamod. */
106.221 + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
106.222 + /** Returns the author to MM */
106.223 + virtual const char *GetAuthor();
106.224 + /** Returns the name to MM */
106.225 + virtual const char *GetName();
106.226 + /** Returns the description to MM */
106.227 + virtual const char *GetDescription();
106.228 + /** Returns the URL to MM */
106.229 + virtual const char *GetURL();
106.230 + /** Returns the license to MM */
106.231 + virtual const char *GetLicense();
106.232 + /** Returns the version string to MM */
106.233 + virtual const char *GetVersion();
106.234 + /** Returns the date string to MM */
106.235 + virtual const char *GetDate();
106.236 + /** Returns the logtag to MM */
106.237 + virtual const char *GetLogTag();
106.238 + /** Called on unload */
106.239 + virtual bool Unload(char *error, size_t maxlength);
106.240 + /** Called on pause */
106.241 + virtual bool Pause(char *error, size_t maxlength);
106.242 + /** Called on unpause */
106.243 + virtual bool Unpause(char *error, size_t maxlength);
106.244 +private:
106.245 + bool m_SourceMMLoaded;
106.246 + bool m_WeAreUnloaded;
106.247 + bool m_WeGotPauseChange;
106.248 +#endif
106.249 +};
106.250 +
106.251 +extern SDKExtension *g_pExtensionIface;
106.252 +extern IExtension *myself;
106.253 +
106.254 +extern IShareSys *g_pShareSys;
106.255 +extern IShareSys *sharesys; /* Note: Newer name */
106.256 +extern ISourceMod *g_pSM;
106.257 +extern ISourceMod *smutils; /* Note: Newer name */
106.258 +
106.259 +/* Optional interfaces are below */
106.260 +#if defined SMEXT_ENABLE_FORWARDSYS
106.261 +extern IForwardManager *g_pForwards;
106.262 +extern IForwardManager *forwards; /* Note: Newer name */
106.263 +#endif //SMEXT_ENABLE_FORWARDSYS
106.264 +#if defined SMEXT_ENABLE_HANDLESYS
106.265 +extern IHandleSys *g_pHandleSys;
106.266 +extern IHandleSys *handlesys; /* Note: Newer name */
106.267 +#endif //SMEXT_ENABLE_HANDLESYS
106.268 +#if defined SMEXT_ENABLE_PLAYERHELPERS
106.269 +extern IPlayerManager *playerhelpers;
106.270 +#endif //SMEXT_ENABLE_PLAYERHELPERS
106.271 +#if defined SMEXT_ENABLE_DBMANAGER
106.272 +extern IDBManager *dbi;
106.273 +#endif //SMEXT_ENABLE_DBMANAGER
106.274 +#if defined SMEXT_ENABLE_GAMECONF
106.275 +extern IGameConfigManager *gameconfs;
106.276 +#endif //SMEXT_ENABLE_DBMANAGER
106.277 +#if defined SMEXT_ENABLE_MEMUTILS
106.278 +extern IMemoryUtils *memutils;
106.279 +#endif
106.280 +#if defined SMEXT_ENABLE_GAMEHELPERS
106.281 +extern IGameHelpers *gamehelpers;
106.282 +#endif
106.283 +#if defined SMEXT_ENABLE_TIMERSYS
106.284 +extern ITimerSystem *timersys;
106.285 +#endif
106.286 +#if defined SMEXT_ENABLE_ADTFACTORY
106.287 +extern IADTFactory *adtfactory;
106.288 +#endif
106.289 +#if defined SMEXT_ENABLE_THREADER
106.290 +extern IThreader *threader;
106.291 +#endif
106.292 +#if defined SMEXT_ENABLE_LIBSYS
106.293 +extern ILibrarySys *libsys;
106.294 +#endif
106.295 +#if defined SMEXT_ENABLE_PLUGINSYS
106.296 +extern SourceMod::IPluginManager *plsys;
106.297 +#endif
106.298 +#if defined SMEXT_ENABLE_MENUS
106.299 +extern IMenuManager *menus;
106.300 +#endif
106.301 +#if defined SMEXT_ENABLE_ADMINSYS
106.302 +extern IAdminSystem *adminsys;
106.303 +#endif
106.304 +#if defined SMEXT_ENABLE_USERMSGS
106.305 +extern IUserMessages *usermsgs;
106.306 +#endif
106.307 +#if defined SMEXT_ENABLE_TRANSLATOR
106.308 +extern ITranslator *translator;
106.309 +#endif
106.310 +#if defined SMEXT_ENABLE_NINVOKE
106.311 +extern INativeInterface *ninvoke;
106.312 +#endif
106.313 +#if defined SMEXT_ENABLE_ROOTCONSOLEMENU
106.314 +extern IRootConsole *rootconsole;
106.315 +#endif
106.316 +
106.317 +#if defined SMEXT_CONF_METAMOD
106.318 +PLUGIN_GLOBALVARS();
106.319 +extern IVEngineServer *engine;
106.320 +extern IServerGameDLL *gamedll;
106.321 +#endif
106.322 +
106.323 +/** Creates a SourceMod interface macro pair */
106.324 +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
106.325 +/** Automates retrieving SourceMod interfaces */
106.326 +#define SM_GET_IFACE(prefix, addr) \
106.327 + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
106.328 + { \
106.329 + if (error != NULL && maxlength) \
106.330 + { \
106.331 + size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
106.332 + if (len >= maxlength) \
106.333 + { \
106.334 + error[maxlength - 1] = '\0'; \
106.335 + } \
106.336 + } \
106.337 + return false; \
106.338 + }
106.339 +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
106.340 +#define SM_GET_LATE_IFACE(prefix, addr) \
106.341 + g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
106.342 +/** Validates a SourceMod interface pointer */
106.343 +#define SM_CHECK_IFACE(prefix, addr) \
106.344 + if (!addr) \
106.345 + { \
106.346 + if (error != NULL && maxlength) \
106.347 + { \
106.348 + size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
106.349 + if (len >= maxlength) \
106.350 + { \
106.351 + error[maxlength - 1] = '\0'; \
106.352 + } \
106.353 + } \
106.354 + return false; \
106.355 + }
106.356 +
106.357 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_