Compare commits

..
Author SHA1 Message Date
David Anderson d0fda1f919 Bumped all versions. 2009-02-25 20:24:56 -05:00
David Anderson 79ea33beda Pushing build. 2009-02-25 20:21:47 -05:00
David Anderson fef5bd321c Added tag sourcemod-1.1.1 for changeset ffa740152efd 2009-02-25 20:10:12 -05:00
David Anderson 6c7a763b76 Fixed changelog. 2009-02-25 20:09:22 -05:00
David Anderson 78fa1c9995 Merge. 2009-02-25 20:07:20 -05:00
David Anderson 3623ee3ce8 Backed out changeset fa286305bd3f 2009-02-25 20:07:12 -05:00
David Anderson ba28da5fdc Removed -dev tag for release build. 2009-02-25 20:02:47 -05:00
David Anderson c2b7bd10ec Updated changelog. 2009-02-25 19:38:45 -05:00
David Anderson 35ab37c76c Merge. 2009-02-25 19:22:47 -05:00
David Anderson c968dfa113 Allow for second private chat trigger (bug 3667, r,a11=pred). 2009-02-25 19:22:36 -05:00
Matt Woodrow 8541040bb9 Fixed CommitSuicide offset. 2009-02-26 12:42:59 +13:00
Matt Woodrow 8ae003046c Updated CDetour code in TF2 extension to prevent crashes with spies. Updated windows sig. 2009-02-26 12:42:13 +13:00
Fyren 38c37b8160 Fixed modules.versions not including clientprefs (bug 3647, r=dvander) 2009-02-19 14:22:22 +13:00
Matt Woodrow aec3469c03 Fixed CalcCriticalKnife signature for TF2 (r=bl4nk) 2009-02-18 19:13:08 +13:00
David Anderson 71b48fad0f Merge. 2009-02-07 23:57:11 -05:00
David Anderson a3fade1c1d Fixed EventManager holding onto stale pointers (bug 3548, r=ds). 2009-02-07 23:56:48 -05:00
Milo 3ab1ef139f Fixed documentation typo on TF2_GetPlayerClass (bug 3608, r=dvander). 2009-02-07 22:05:04 -05:00
mr.e.unk 36bd6423c2 Allow longer path strings in adminmenu (bug 3620, r=pred). 2009-02-07 22:01:09 -05:00
mr.e.unk 178347f9f1 Removed RTV section from maplists.cfg. (bug 3611 r=Liam) 2009-02-01 20:39:23 -05:00
[email protected] 94303ea9a0 Fixed nextmap trigger showing wrong output with end-of-map voting disabled and sm_trigger_show set to zero (bug 3597, r=pred). 2009-02-01 02:09:15 -05:00
David Anderson 50e1c5ba1f Database fallback for clientprefs is now more "intelligent" (bug 3564, r=pred). 2009-01-31 23:42:35 -05:00
David Anderson 7d3ebce7d1 Fixed sm_sql_addgroup not working (bug 3578, r=liam). 2009-01-31 22:46:34 -05:00
Scott Ehlert 7167a807bf Fixed a crash in the Event Manager when a game fired an event from a listener that was looking for the same event (bug 3468, r=me).
In other words it was a problem where our FireEvent hooks were being re-entered for the _same_ game event. The Event Manager was not able to handle this and crashed.
2009-01-27 23:53:48 -06:00
TheDOO a8e1a4f2fd Update of Obsidian CommitSuicide offset (bug 2699, r=dvander).
(transplanted from sourcemod-central ffc584a3c382c064006b857e6697c99fff1a681d)

--HG--
extra : transplant_source : %FF%C5%84%A3%C3%82%C0d%00k%85%7Ef%97%C9%9F%FF%1Ah%1D
2009-01-12 02:33:03 -05:00
Scott Ehlert 157f050f89 Fixed a memory leak when game events were hooked as EventHookMode_Post (no bug, r=me).
The duplicated event data that was being carried over to the IGameEventManager2::FireEvent post hook was not being freed. EventHookMode_Post is the default so this leak could have happened fairly often.
2009-01-27 13:41:57 -06:00
David Anderson c676ecc026 Fixed regression in printing floats with no precision (bug 3447, r=ds). 2009-01-07 19:23:24 -05:00
David Anderson 0fbb87e3b2 Fixed various wrong offsets in Insurgency (bug 3544, r=me). 2009-01-07 16:43:23 -05:00
David Anderson 29996d0133 Cleaned up SourceForts entries in sdktools.games.txt (bug 3492). 2009-01-07 04:06:18 -05:00
The DOO 7807f3e31a Added basic SDKTools/core support for Obsidian Conflict (bug 2699). 2009-01-07 03:33:45 -05:00
IceMatrix e246d14a6b Added Age of Chivalry offsets (bug 3366). 2009-01-07 03:25:53 -05:00
David Anderson a34a27be65 Fixed top menu categories being available even if not usable (bug 3256, r=me). 2009-01-07 02:08:14 -05:00
Scott Ehlert e1d2b88c23 Fixed some inconsistencies in admins_simple.ini (bug 3540). 2009-01-02 00:31:23 -06:00
Scott Ehlert 5c92b0d154 Bumped version to 1.1.1 and added back -dev build string. 2008-12-28 23:50:26 -06:00
Scott Ehlert 2b7ccf6625 Tagging SourceMod 1.1.0 2008-12-28 23:41:14 -06:00
44 changed files with 979 additions and 799 deletions
+2
View File
@@ -1 +1,3 @@
54539fa4e51f98d7841c853c1370dff6ccd3cdf2 sourcemod-1.0.0
e6ef5ecdf8d75740ca2685a709bf321f8873bc3b sourcemod-1.1.0
ffa740152efd042ad0461c797d52c5e6eab3d52c sourcemod-1.1.1
+20
View File
@@ -2,6 +2,26 @@ SourceMod Changelog
----------------------------
SourceMod 1.1.1 [2009-02-25]
URL: http://wiki.alliedmods.net/SourceMod_1.1.1_Release Notes
Changes:
- Added Age of Chivalry support (bug 3366, IceMatrix).
- Added Obsidian Conflict support (bug 2699, The DOO).
- Fixed compatibility issues with latest TF2 update.
- Fixed crash when an event handler fired an event of the same name (bug 3468).
- Fixed rare crash in the event manager on post hooks (bug 3548).
- Fixed formatting error with zero precision floats (bug 3447).
- Fixed various Insurgency offsets (bug 3544).
- Fixed admin menu (topmenu) categories being selectable when not usable (bug 3256).
- Fixed sm_sql_addgroup not working (bug 3578).
- Fixed memory leak when events were hooked as EventHookMode_Post.
- Fixed nextmap trigger showing wrong output with end-of-map voting disabled and sm_trigger_show set to zero (bug 3597, mr.e.unk).
----------------------------
SourceMod 1.1.0 [2008-12-28]
URL: http://wiki.alliedmods.net/SourceMod_1.1.0_Release_Notes
+3 -3
View File
@@ -16,7 +16,7 @@
// "@Full Admins"
//
// You can also specify immunity values. Two examples:
// "83:abcdefg" //Immunity is 83, flags are abcefgh
// "83:abcdefgh" //Immunity is 83, flags are abcdefgh
// "6:@Full Admins" //Immunity is 6, group is "Full Admins"
//
// Immunity values can be any number. An admin cannot target an admin with
@@ -37,9 +37,9 @@
////////////////////////////////
// Examples: (do not put // in front of real lines, as // means 'comment')
//
// "STEAM_0:1:16" "bce" //kick, ban, slay for this steam ID, no immunity
// "STEAM_0:1:16" "bce" //generic, kick, unban for this steam ID, no immunity
// "!127.0.0.1" "99:z" //all permissions for this ip, immunity value is 99
// "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, kick, ban
// "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, generic, kick
//
////////////////////////////////
-6
View File
@@ -51,12 +51,6 @@
"target" "default"
}
/* For the "rockthevote" plugin */
"rockthevote"
{
"target" "default"
}
/* For the "nominations" plugin */
"nominations"
{
+41 -19
View File
@@ -193,6 +193,9 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
pHook->pPostHook->AddFunction(pFunction);
}
/* Cache the name for post hooks */
pHook->name = strdup(name);
/* Increase reference count */
pHook->refCount++;
@@ -296,6 +299,9 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
/* Delete entry in trie */
sm_trie_delete(m_EventHooks, name);
/* Free the cached name */
free(pHook->name);
/* And finally free structure memory */
delete pHook;
}
@@ -365,33 +371,36 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{
RETURN_META_VALUE(MRES_IGNORED, false);
}
/* Get the event name, we're going to need this for passing to post hooks */
name = pEvent->GetName();
m_EventNames.push(name);
if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))
{
/* Push the event onto the event stack. The reference count is increased to make sure
* the structure is not garbage collected in between now and the post hook.
*/
pHook->refCount++;
m_EventStack.push(pHook);
pForward = pHook->pPreHook;
if (pForward)
{
EventInfo info = { pEvent, NULL };
EventInfo info(pEvent, NULL);
HandleSecurity sec(NULL, g_pCoreIdent);
Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
pForward->PushCell(hndl);
pForward->PushString(name);
pForward->PushCell(bDontBroadcast);
pForward->Execute(&res, NULL);
HandleSecurity sec(NULL, g_pCoreIdent);
g_HandleSys.FreeHandle(hndl, &sec);
}
if (pHook->postCopy)
{
pHook->pEventCopy = gameevents->DuplicateEvent(pEvent);
m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
}
if (res)
@@ -400,6 +409,10 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
RETURN_META_VALUE(MRES_SUPERCEDE, false);
}
}
else
{
m_EventStack.push(NULL);
}
RETURN_META_VALUE(MRES_IGNORED, true);
}
@@ -407,10 +420,9 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
/* IGameEventManager2::FireEvent post hook */
bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
{
IGameEvent *pEventCopy = NULL;
EventHook *pHook;
EventInfo info;
IChangeableForward *pForward;
const char *name;
Handle_t hndl = 0;
/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
@@ -419,18 +431,18 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
RETURN_META_VALUE(MRES_IGNORED, false);
}
name = m_EventNames.front();
pHook = m_EventStack.front();
if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))
if (pHook != NULL)
{
pForward = pHook->pPostHook;
if (pForward)
{
EventInfo info = { pHook->pEventCopy, NULL };
if (pHook->postCopy)
{
info.pEvent = m_EventCopies.front();
info.pOwner = NULL;
hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
pForward->PushCell(hndl);
@@ -438,7 +450,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
pForward->PushCell(BAD_HANDLE);
}
pForward->PushString(name);
pForward->PushString(pHook->name);
pForward->PushCell(bDontBroadcast);
pForward->Execute(NULL);
@@ -449,13 +461,23 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
g_HandleSys.FreeHandle(hndl, &sec);
/* Free event structure */
gameevents->FreeEvent(pEventCopy);
pHook->pEventCopy = NULL;
gameevents->FreeEvent(info.pEvent);
m_EventCopies.pop();
}
}
/* Decrement reference count, check if a delayed delete is needed */
if (--pHook->refCount == 0)
{
assert(pHook->pPostHook == NULL);
assert(pHook->pPreHook == NULL);
sm_trie_delete(m_EventHooks, pHook->name);
free(pHook->name);
delete pHook;
}
}
m_EventNames.pop();
m_EventStack.pop();
RETURN_META_VALUE(MRES_IGNORED, true);
}
+9 -3
View File
@@ -45,6 +45,12 @@ using namespace SourceHook;
struct EventInfo
{
EventInfo()
{
}
EventInfo(IGameEvent *ev, IdentityToken_t *owner) : pEvent(ev), pOwner(owner)
{
}
IGameEvent *pEvent;
IdentityToken_t *pOwner;
};
@@ -56,14 +62,13 @@ struct EventHook
pPreHook = NULL;
pPostHook = NULL;
postCopy = false;
pEventCopy = NULL;
refCount = 0;
}
IChangeableForward *pPreHook;
IChangeableForward *pPostHook;
bool postCopy;
IGameEvent *pEventCopy;
unsigned int refCount;
char *name;
};
enum EventHookMode
@@ -120,7 +125,8 @@ private:
HandleType_t m_EventType;
Trie *m_EventHooks;
CStack<EventInfo *> m_FreeEvents;
CStack<const char *> m_EventNames;
CStack<EventHook *> m_EventStack;
CStack<IGameEvent *> m_EventCopies;
};
extern EventManager g_EventManager;
+1 -1
View File
@@ -281,7 +281,7 @@ void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, in
}
// write the fraction part
if (maxlen)
if (maxlen && prec)
{
*buf++ = '.';
maxlen--;
+3 -3
View File
@@ -41,8 +41,8 @@
*/
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SOURCEMOD_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_BINTOOLS_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_BINTOOLS_VERSION_H_
+23
View File
@@ -46,6 +46,7 @@ CookieTypeHandler g_CookieTypeHandler;
HandleType_t g_CookieIterator = 0;
CookieIteratorHandler g_CookieIteratorHandler;
DbDriver g_DriverType;
static const DatabaseInfo *storage_local = NULL;
bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
@@ -58,6 +59,20 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
DBInfo = dbi->FindDatabaseConf("default");
if (DBInfo == NULL ||
(strcmp(DBInfo->host, "localhost") == 0 &&
strcmp(DBInfo->database, "sourcemod") == 0 &&
strcmp(DBInfo->user, "root") == 0 &&
strcmp(DBInfo->pass, "") == 0 &&
strcmp(DBInfo->driver, "") == 0))
{
storage_local = dbi->FindDatabaseConf("storage-local");
if (DBInfo == NULL)
{
DBInfo = storage_local;
}
}
if (DBInfo == NULL)
{
snprintf(error, maxlength, "Could not find \"clientprefs\" or \"default\" database configs");
@@ -176,6 +191,14 @@ void ClientPrefs::DatabaseConnect()
Database = Driver->Connect(DBInfo, true, error, sizeof(error));
if (Database == NULL &&
DBInfo != storage_local &&
storage_local != NULL)
{
DBInfo = storage_local;
Database = Driver->Connect(DBInfo, true, error, sizeof(error));
}
if (Database == NULL)
{
g_pSM->LogError(myself, error);
+4 -2
View File
@@ -36,7 +36,9 @@
#ifndef _INCLUDE_CLIENTPREFS_VERSION_H_
#define _INCLUDE_CLIENTPREFS_VERSION_H_
#define SVN_FULL_VERSION "1.1.0-svn"
#define SVN_FILE_VERSION 1,1,0,2230
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_CLIENTPREFS_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_SDKTOOLS_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SDKTOOLS_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_GEOIP_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_GEOIP_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_MYSQLEXT_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_MYSQLEXT_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_REGEXEXT_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_REGEXEXT_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_SDKTOOLS_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SDKTOOLS_VERSION_H_
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_SQLITEEXT_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SQLITEEXT_VERSION_H_
+3 -3
View File
@@ -26,13 +26,13 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
* Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $
*/
#ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
#define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
#include <sys/mman.h>
#define PAGE_SIZE 4096
#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
@@ -52,7 +52,7 @@ struct patch_t
inline void ProtectMemory(void *addr, int length, int prot)
{
#if defined PLATFORM_POSIX
#if defined PLATFORM_LINUX
void *addr2 = (void *)ALIGN(addr);
mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
#elif defined PLATFORM_WINDOWS
+32 -212
View File
@@ -26,7 +26,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
*/
#include "detours.h"
@@ -34,7 +34,6 @@
ISourcePawnEngine *CDetourManager::spengine = NULL;
IGameConfig *CDetourManager::gameconf = NULL;
int CDetourManager::returnValue = 0;
void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
{
@@ -42,9 +41,9 @@ void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
CDetourManager::gameconf = gameconf;
}
CDetour *CDetourManager::CreateDetour(void *callbackfunction, size_t paramsize, const char *signame)
CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
{
CDetour *detour = new CDetour(callbackfunction, paramsize, signame);
CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
if (detour)
{
if (!detour->Init(spengine, gameconf))
@@ -59,50 +58,17 @@ CDetour *CDetourManager::CreateDetour(void *callbackfunction, size_t paramsize,
return NULL;
}
void CDetourManager::DeleteDetour(CDetour *detour)
{
delete detour;
}
CBlocker * CDetourManager::CreateFunctionBlock( const char *signame, bool isVoid )
{
CBlocker *block = new CBlocker(signame, isVoid);
if (block)
{
if (!block->Init(spengine, gameconf))
{
delete block;
return NULL;
}
return block;
}
return NULL;
}
void CDetourManager::DeleteFunctionBlock(CBlocker *block)
{
delete block;
}
CDetour::CDetour(void *callbackfunction, size_t paramsize, const char *signame)
CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
{
enabled = false;
detoured = false;
detour_address = NULL;
detour_callback = NULL;
detour_trampoline = NULL;
this->signame = signame;
this->callbackfunction = callbackfunction;
this->detour_callback = callbackfunction;
spengine = NULL;
gameconf = NULL;
this->paramsize = paramsize;
}
CDetour::~CDetour()
{
DeleteDetour();
this->trampoline = trampoline;
}
bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
@@ -121,6 +87,12 @@ bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
return enabled;
}
void CDetour::Destroy()
{
DeleteDetour();
delete this;
}
bool CDetour::IsEnabled()
{
return enabled;
@@ -148,7 +120,6 @@ bool CDetour::CreateDetour()
detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
}
//detour_callback = spengine->ExecAlloc(100);
JitWriter wr;
JitWriter *jit = &wr;
jit_uint32_t CodeSize = 0;
@@ -158,47 +129,6 @@ bool CDetour::CreateDetour()
jit_rewind:
/* Push all our params onto the stack */
for (size_t i=0; i<paramsize; i++)
{
#if defined PLATFORM_WINDOWS
IA32_Push_Rm_Disp8_ESP(jit, (paramsize*4));
#elif defined PLATFORM_LINUX
IA32_Push_Rm_Disp8_ESP(jit, 4 +(paramsize*4));
#endif
}
/* Push thisptr onto the stack */
#if defined PLATFORM_WINDOWS
IA32_Push_Reg(jit, REG_ECX);
#elif defined PLATFORM_LINUX
IA32_Push_Rm_Disp8_ESP(jit, 4 + (paramsize*4));
#endif
jitoffs_t call = IA32_Call_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, call, callbackfunction);
/* Pop thisptr */
#if defined PLATFORM_LINUX
IA32_Add_Rm_Imm8(jit, REG_ESP, 4, MOD_REG); //add esp, 4
#elif defined PLATFORM_WINDOWS
IA32_Pop_Reg(jit, REG_ECX);
#endif
/* Pop params from the stack */
for (size_t i=0; i<paramsize; i++)
{
IA32_Add_Rm_Imm8(jit, REG_ESP, 4, MOD_REG);
}
//If TempDetour returns non-zero we want to load something into eax and return this value
//test eax, eax
IA32_Test_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG);
//jnz _skip
jitoffs_t jmp = IA32_Jump_Cond_Imm8(jit, CC_NZ, 0);
/* Patch old bytes in */
if (wr.outbase != NULL)
{
@@ -207,15 +137,8 @@ jit_rewind:
wr.outptr += detour_restore.bytes;
/* Return to the original function */
call = IA32_Jump_Imm32(jit, 0);
jitoffs_t call = IA32_Jump_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, call, (unsigned char *)detour_address + detour_restore.bytes);
//_skip:
//mov eax, [g_returnvalue]
//ret
IA32_Send_Jump8_Here(jit, jmp);
IA32_Mov_Eax_Mem(jit, (jit_int32_t)&CDetourManager::returnValue);
IA32_Return(jit);
if (wr.outbase == NULL)
{
@@ -223,15 +146,32 @@ jit_rewind:
wr.outbase = (jitcode_t)spengine->AllocatePageMemory(CodeSize);
spengine->SetReadWrite(wr.outbase);
wr.outptr = wr.outbase;
detour_callback = wr.outbase;
detour_trampoline = wr.outbase;
goto jit_rewind;
}
spengine->SetReadExecute(wr.outbase);
*trampoline = detour_trampoline;
return true;
}
void CDetour::DeleteDetour()
{
if (detoured)
{
DisableDetour();
}
if (detour_trampoline)
{
/* Free the allocated trampoline memory */
spengine->FreePageMemory(detour_trampoline);
detour_trampoline = NULL;
}
}
void CDetour::EnableDetour()
{
if (!detoured)
@@ -241,132 +181,12 @@ void CDetour::EnableDetour()
}
}
void CDetour::DeleteDetour()
{
if (detoured)
{
DisableDetour();
}
if (detour_callback)
{
/* Free the gate */
spengine->FreePageMemory(detour_callback);
detour_callback = NULL;
}
}
void CDetour::DisableDetour()
{
if (detoured)
{
/* Remove the patch */
/* This may screw up */
ApplyPatch(detour_address, 0, &detour_restore, NULL);
detoured = false;
}
}
CBlocker::CBlocker( const char *signame, bool isVoid )
{
this->isVoid = isVoid;
isEnabled = false;
isValid = false;
spengine = NULL;
gameconf = NULL;
block_address = NULL;
block_sig = signame;
if (isVoid)
{
/* Void functions we only patch in a 'ret' (1 byte) */
block_restore.bytes = 1;
}
else
{
/* Normal functions need an mov eax, value */
block_restore.bytes = 6;
}
}
void CBlocker::EnableBlock( int returnValue )
{
if (!isValid || isEnabled)
{
return;
}
/* First, save restore bits */
for (size_t i=0; i<block_restore.bytes; i++)
{
block_restore.patch[i] = ((unsigned char *)block_address)[i];
}
JitWriter wr;
JitWriter *jit = &wr;
wr.outbase = (jitcode_t)block_address;
wr.outptr = wr.outbase;
if (isVoid)
{
IA32_Return(jit);
}
else
{
IA32_Mov_Reg_Imm32(jit, REG_EAX, returnValue);
IA32_Return(jit);
}
isEnabled = true;
}
void CBlocker::DisableBlock()
{
if (!isValid || !isEnabled)
{
return;
}
/* First, save restore bits */
for (size_t i=0; i<block_restore.bytes; i++)
{
((unsigned char *)block_address)[i] = block_restore.patch[i];
}
isEnabled = false;
}
CBlocker::~CBlocker()
{
if (!isValid || !isEnabled)
{
return;
}
DisableBlock();
}
bool CBlocker::Init( ISourcePawnEngine *spengine, IGameConfig *gameconf )
{
this->spengine = spengine;
this->gameconf = gameconf;
if (!gameconf->GetMemSig(block_sig, &block_address))
{
g_pSM->LogError(myself, "Could not locate %s - Disabling blocker", block_sig);
isValid = false;
return false;
}
if (!block_address)
{
g_pSM->LogError(myself, "Sigscan for %s failed - Disabling blocker", block_sig);
isValid = false;
return false;
}
isValid = true;
return true;
}
+133 -88
View File
@@ -26,7 +26,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
*/
#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
@@ -40,9 +40,103 @@
/**
* CDetours class for SourceMod Extensions by pRED*
* detourhelpers.h entirely stolen from CSS:DM and were written by BAILOPAN (I assume).
* asm.h/c from devmaster.net (thanks cybermind)
* asm.h/c from devmaster.net (thanks cybermind) edited by pRED* to handle gcc -fPIC thunks correctly
* Concept by Nephyrin Zey (http://www.doublezen.net/) and Windows Detour Library (http://research.microsoft.com/sn/detours/)
* Member function pointer ideas by Don Clugston (http://www.codeproject.com/cpp/FastDelegate.asp)
*/
#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
#define DETOUR_STATIC_CALL(name) (name##_Actual)
#define DETOUR_DECL_STATIC0(name, ret) \
ret (*name##_Actual)(void) = NULL; \
ret name(void)
#define DETOUR_DECL_STATIC1(name, ret, p1type, p1name) \
ret (*name##_Actual)(p1type) = NULL; \
ret name(p1type p1name)
#define DETOUR_DECL_STATIC4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
#define DETOUR_DECL_MEMBER0(name, ret) \
class name##Class \
{ \
public: \
ret name(); \
static ret (name##Class::* name##_Actual)(void); \
}; \
ret (name##Class::* name##Class::name##_Actual)(void) = NULL; \
ret name##Class::name()
#define DETOUR_DECL_MEMBER1(name, ret, p1type, p1name) \
class name##Class \
{ \
public: \
ret name(p1type p1name); \
static ret (name##Class::* name##_Actual)(p1type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type) = NULL; \
ret name##Class::name(p1type p1name)
#define DETOUR_DECL_MEMBER2(name, ret, p1type, p1name, p2type, p2name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name); \
static ret (name##Class::* name##_Actual)(p1type, p2type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name)
#define DETOUR_DECL_MEMBER3(name, ret, p1type, p1name, p2type, p2name, p3type, p3name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name)
#define DETOUR_DECL_MEMBER4(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
#define GET_STATIC_CALLBACK(name) (void *)&name
#define GET_STATIC_TRAMPOLINE(name) (void **)&name##_Actual
#define DETOUR_CREATE_MEMBER(name, gamedata) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), gamedata);
#define DETOUR_CREATE_STATIC(name, gamedata) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), gamedata);
class GenericClass {};
typedef void (GenericClass::*VoidFunc)();
inline void *GetCodeAddr(VoidFunc mfp)
{
return *(void **)&mfp;
}
/**
* Converts a member function pointer to a void pointer.
* This relies on the assumption that the code address lies at mfp+0
* This is the case for both g++ and later MSVC versions on non virtual functions but may be different for other compilers
* Based on research by Don Clugston : http://www.codeproject.com/cpp/FastDelegate.asp
*/
#define GetCodeAddress(mfp) GetCodeAddr(reinterpret_cast<VoidFunc>(mfp))
class CDetourManager;
class CDetour
@@ -57,11 +151,12 @@ public:
void EnableDetour();
void DisableDetour();
void Destroy();
friend class CDetourManager;
protected:
CDetour(void *callbackfunction, size_t paramsize, const char *signame);
~CDetour();
CDetour(void *callbackfunction, void **trampoline, const char *signame);
bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
private:
@@ -74,42 +169,16 @@ private:
bool detoured;
patch_t detour_restore;
/* Address of the detoured function */
void *detour_address;
/* Address of the allocated trampoline function */
void *detour_trampoline;
/* Address of the callback handler */
void *detour_callback;
/* The function pointer used to call our trampoline */
void **trampoline;
const char *signame;
void *callbackfunction;
size_t paramsize;
ISourcePawnEngine *spengine;
IGameConfig *gameconf;
};
class CBlocker
{
public:
void EnableBlock(int returnValue = 0);
void DisableBlock();
friend class CDetourManager;
protected:
CBlocker(const char *signame, bool isVoid);
~CBlocker();
bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
private:
bool isValid;
bool isEnabled;
bool isVoid;
patch_t block_restore;
void *block_address;
const char *block_sig;
ISourcePawnEngine *spengine;
IGameConfig *gameconf;
};
@@ -118,25 +187,13 @@ class CDetourManager
{
public:
/**
* Return Types for Detours
*/
enum DetourReturn
{
DetourReturn_Ignored = 0, /** Ignore our result and let the original function run */
DetourReturn_Override = 1, /** Block the original function from running and use our return value */
};
static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
/**
* Creates a new detour
* @param callbackfunction Void pointer to your detour callback function. This should be a static function.
* It should have pointer to the thisptr as the first param and then the same params
* as the original function. Use void * for unknown types.
* @param paramsize This is usually the number of params the function has (not including thisptr). If the function
* passes complex types by value you need to add the sizeof() the type (aligned to 4 bytes).
* Ie: passing something of size 8 would count as 2 in the param count.
*
* @param callbackfunction Void pointer to your detour callback function.
* @param trampoline Address of the trampoline pointer
* @param signame Section name containing a signature to fetch from the gamedata file.
* @return A new CDetour pointer to control your detour.
*
@@ -144,37 +201,34 @@ public:
*
* CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
*
* Callback:
* DetourReturn ConnectClientDetour(void *CBaseServer, void *netaddr_s, int something, int something2, int something3, char const* name, char const* pass, const char* steamcert, int len);
* Define a new class with the required function and a member function pointer to the same type:
*
* class CBaseServerDetour
* {
* public:
* bool ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
* static bool (CBaseServerDetour::* ConnectClient_Actual)(void *netaddr_s, int, int, int, char const*, char const*, char const*, int);
* }
*
* void *callbackfunc = GetCodeAddress(&CBaseServerDetour::ConnectClient);
* void **trampoline = (void **)(&CBaseServerDetour::ConnectClient_Actual);
*
* Creation:
* CDetourManager::CreateDetour((void *)&ConnectClientDetour, 8, "ConnectClient");
*/
static CDetour *CreateDetour(void *callbackfunction, size_t paramsize, const char *signame);
/**
* Deletes a detour
*/
static void DeleteDetour(CDetour *detour);
/**
* Creates a function blocker. This is slightly faster than a detour because it avoids a call.
* CDetourManager::CreateDetour(callbackfunc, trampoline, "ConnectClient");
*
* @param signame Section name containing a signature to fetch from the gamedata file.
* @param isVoid Specifies if the function can return void.
* Usage:
*
* CBaseServerDetour::ConnectClient(void *netaddr_s, int, int, int, char const*, char const*, char const*, int)
* {
* //pre hook code
* bool result = (this->*ConnectClient_Actual)(netaddr_s, rest of params);
* //post hook code
* return result;
* }
*
* Note we changed the netadr_s reference into a void* to avoid needing to define the type
*/
static CBlocker *CreateFunctionBlock(const char *signame, bool isVoid);
/**
* Delete a function blocker.
*/
static void DeleteFunctionBlock(CBlocker *block);
/**
* Global DetourReturn value to use for the current hook
*/
static int returnValue;
static CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
friend class CBlocker;
friend class CDetour;
@@ -184,13 +238,4 @@ private:
static IGameConfig *gameconf;
};
typedef bool DetourReturn;
#define DETOUR_RESULT_IGNORED false
#define DETOUR_RESULT_OVERRIDE true
#define SET_DETOUR_RETURN_VALUE(value) CDetourManager::returnValue=(int)value
#define RETURN_DETOUR(result) return result
#define RETURN_DETOUR_VALUE(result,value) do { SET_DETOUR_RETURN_VALUE(value); return (result); } while(0)
#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
+92
View File
@@ -1,5 +1,91 @@
#include "asm.h"
#ifndef WIN32
#define _GNU_SOURCE
#include <dlfcn.h>
#include <string.h>
#define REG_EAX 0
#define REG_ECX 1
#define REG_EDX 2
#define REG_EBX 3
#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
#endif
extern void Msg( const char *, ... );
/**
* Checks if a call to a fpic thunk has just been written into dest.
* If found replaces it with a direct mov that sets the required register to the value of pc.
*
* @param dest Destination buffer where a call opcode + addr (5 bytes) has just been written.
* @param pc The program counter value that needs to be set (usually the next address from the source).
* @noreturn
*/
void check_thunks(unsigned char *dest, unsigned char *pc)
{
#if defined WIN32
return;
#else
/* Step write address back 4 to the start of the function address */
unsigned char *writeaddr = dest - 4;
unsigned char *calloffset = *(unsigned char **)writeaddr;
unsigned char *calladdr = (unsigned char *)(dest + (unsigned int)calloffset);
/* Lookup name of function being called */
if ((*calladdr == 0x8B) && (*(calladdr+2) == 0x24) && (*(calladdr+3) == 0xC3))
{
//a thunk maybe?
char movByte = IA32_MOV_REG_IMM;
/* Calculate the correct mov opcode */
switch (*(calladdr+1))
{
case 0x04:
{
movByte += REG_EAX;
break;
}
case 0x1C:
{
movByte += REG_EBX;
break;
}
case 0x0C:
{
movByte += REG_ECX;
break;
}
case 0x14:
{
movByte += REG_EDX;
break;
}
default:
{
Msg("Unknown thunk: %c\n", *(calladdr+1));
break;
}
}
/* Move our write address back one to where the call opcode was */
writeaddr--;
/* Write our mov */
*writeaddr = movByte;
writeaddr++;
/* Write the value - The provided program counter value */
*(void **)writeaddr = (void *)pc;
writeaddr += 4;
}
return;
#endif
}
//if dest is NULL, returns minimum number of bytes needed to be copied
//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
//http://www.devmaster.net/forums/showthread.php?t=2311
@@ -195,9 +281,15 @@ int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
//Fix CALL/JMP offset
if ((opcode & 0xFE) == 0xE8) {
if (operandSize == 4)
{
*(long*)dest = ((func + *(long*)func) - dest);
//pRED* edit. func is the current address of the call address, +4 is the next instruction, so the value of $pc
check_thunks(dest+4, func+4);
}
else
*(short*)dest = ((func + *(short*)func) - dest);
} else {
if (operandSize == 4)
*(unsigned long*)dest = *(unsigned long*)func;
+2
View File
@@ -17,6 +17,8 @@
extern "C" {
#endif
void check_thunks(unsigned char *dest, unsigned char *pc);
//if dest is NULL, returns minimum number of bytes needed to be copied
//if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs
//http://www.devmaster.net/forums/showthread.php?t=2311
+42 -42
View File
@@ -39,40 +39,6 @@ CDetour *calcIsAttackCriticalKnifeDetour = NULL;
IForward *g_critForward = NULL;
void InitialiseDetours()
{
calcIsAttackCriticalDetour = CDetourManager::CreateDetour((void *)&TempDetour, 0, "CalcCritical");
calcIsAttackCriticalMeleeDetour = CDetourManager::CreateDetour((void *)&TempDetour, 0, "CalcCriticalMelee");
calcIsAttackCriticalKnifeDetour = CDetourManager::CreateDetour((void *)&TempDetour, 0, "CalcCriticalKnife");
bool HookCreated = false;
if (calcIsAttackCriticalDetour != NULL)
{
calcIsAttackCriticalDetour->EnableDetour();
HookCreated = true;
}
if (calcIsAttackCriticalMeleeDetour != NULL)
{
calcIsAttackCriticalMeleeDetour->EnableDetour();
HookCreated = true;
}
if (calcIsAttackCriticalKnifeDetour != NULL)
{
calcIsAttackCriticalKnifeDetour->EnableDetour();
HookCreated = true;
}
if (!HookCreated)
{
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
return;
}
}
int CheckBaseHandle(CBaseHandle &hndl)
{
if (!hndl.IsValid())
@@ -106,9 +72,9 @@ int CheckBaseHandle(CBaseHandle &hndl)
return index;
}
DetourReturn TempDetour(void *pWeapon)
DETOUR_DECL_MEMBER0(CalcIsAttackCriticalHelper, bool)
{
edict_t *pEdict = gameents->BaseEntityToEdict((CBaseEntity *)pWeapon);
edict_t *pEdict = gameents->BaseEntityToEdict((CBaseEntity *)this);
if (!pEdict)
{
@@ -132,7 +98,7 @@ DetourReturn TempDetour(void *pWeapon)
int returnValue=0;
CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + info.actual_offset);
CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)this + info.actual_offset);
int index = CheckBaseHandle(hndl);
g_critForward->PushCell(index); //Client index
@@ -146,18 +112,52 @@ DetourReturn TempDetour(void *pWeapon)
if (result)
{
RETURN_DETOUR_VALUE(DETOUR_RESULT_OVERRIDE, returnValue);
return !!returnValue;
}
else
{
RETURN_DETOUR_VALUE(DETOUR_RESULT_IGNORED, returnValue);
return DETOUR_MEMBER_CALL(CalcIsAttackCriticalHelper)();
}
}
void InitialiseDetours()
{
calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical");
calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCriticalMelee");
calcIsAttackCriticalKnifeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCriticalKnife");
bool HookCreated = false;
if (calcIsAttackCriticalDetour != NULL)
{
calcIsAttackCriticalDetour->EnableDetour();
HookCreated = true;
}
if (calcIsAttackCriticalMeleeDetour != NULL)
{
calcIsAttackCriticalMeleeDetour->EnableDetour();
HookCreated = true;
}
if (calcIsAttackCriticalKnifeDetour != NULL)
{
calcIsAttackCriticalKnifeDetour->EnableDetour();
HookCreated = true;
}
if (!HookCreated)
{
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
return;
}
}
void RemoveDetours()
{
CDetourManager::DeleteDetour(calcIsAttackCriticalDetour);
CDetourManager::DeleteDetour(calcIsAttackCriticalMeleeDetour);
CDetourManager::DeleteDetour(calcIsAttackCriticalKnifeDetour);
calcIsAttackCriticalDetour->Destroy();
calcIsAttackCriticalMeleeDetour->Destroy();
calcIsAttackCriticalKnifeDetour->Destroy();
}
-2
View File
@@ -40,8 +40,6 @@
void InitialiseDetours();
void RemoveDetours();
bool TempDetour(void *pWeapon);
extern IForward *g_critForward;
extern IServerGameEnts *gameents;
+1 -1
View File
@@ -90,7 +90,7 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
char conf_error[255] = "";
if (!gameconfs->LoadGameConfigFile("sm-tf2.games", &g_pGameConf, conf_error, sizeof(conf_error)))
{
if (conf_error)
if (conf_error[0])
{
UTIL_Format(error, maxlength, "Could not read sm-tf2.games.txt: %s", conf_error);
}
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_SDKTOOLS_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SDKTOOLS_VERSION_H_
+70 -21
View File
@@ -248,6 +248,7 @@ unsigned int TopMenu::AddToMenu2(const char *name,
cat->serial = 1;
/* Add it, then update our serial change number. */
obj->cat_id = m_Categories.size();
m_Categories.push_back(cat);
m_SerialNo++;
@@ -257,6 +258,7 @@ unsigned int TopMenu::AddToMenu2(const char *name,
else if (obj->type == TopMenuObject_Item)
{
/* Update the category, mark it as needing changes */
obj->cat_id = 0;
parent_cat->obj_list.push_back(obj);
parent_cat->reorder = true;
parent_cat->serial++;
@@ -407,6 +409,12 @@ bool TopMenu::DisplayMenu(int client, unsigned int hold_time, TopMenuPosition po
UpdateClientRoot(client, pPlayer);
/* This is unfortunate but it's the best solution. */
for (size_t i = 0; i < m_Categories.size(); i++)
{
UpdateClientCategory(client, i, true);
}
topmenu_player_t *pClient = &m_clients[client];
if (pClient->root == NULL)
{
@@ -443,8 +451,7 @@ bool TopMenu::DisplayCategory(int client, unsigned int category, unsigned int ho
UpdateClientCategory(client, category);
topmenu_player_t *pClient = &m_clients[client];
if (category >= pClient->cat_count
|| pClient->cats[category].menu == NULL)
if (category >= pClient->cat_count || pClient->cats[category].menu == NULL)
{
return false;
}
@@ -488,18 +495,16 @@ void TopMenu::OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsi
if (obj->type == TopMenuObject_Category)
{
/* If it's a category, the user wants to view it.. */
for (size_t i = 0; i < m_Categories.size(); i++)
assert(obj->cat_id < m_Categories.size());
assert(m_Categories[obj->cat_id]->obj == obj);
pClient->last_root_pos = item_on_page;
if (!DisplayCategory(client, obj->cat_id, MENU_TIME_FOREVER, false))
{
if (m_Categories[i]->obj == obj)
{
pClient->last_root_pos = item_on_page;
if (!DisplayCategory(client, (unsigned int)i, MENU_TIME_FOREVER, false))
{
/* If we can't display the category, re-display the root menu */
DisplayMenu(client, MENU_TIME_FOREVER, TopMenuPosition_LastRoot);
}
break;
}
/* If we can't display the category, re-display the root menu.
* This code should be dead as of bug 3256, which disables categories
* that cannot be displayed.
*/
DisplayMenu(client, MENU_TIME_FOREVER, TopMenuPosition_LastRoot);
}
}
else
@@ -535,6 +540,19 @@ void TopMenu::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, uns
obj = *pObject;
/* If the category has nothing to display, disable it. */
if (obj->type == TopMenuObject_Category)
{
assert(obj->cat_id < m_Categories.size());
assert(m_Categories[obj->cat_id]->obj == obj);
topmenu_player_t *pClient = &m_clients[client];
if (obj->cat_id >= pClient->cat_count || pClient->cats[obj->cat_id].menu == NULL)
{
style = ITEMDRAW_IGNORE;
return;
}
}
style = obj->callbacks->OnTopMenuDrawOption(this, client, obj->object_id);
if (style != ITEMDRAW_DEFAULT)
{
@@ -701,13 +719,18 @@ void TopMenu::UpdateClientRoot(int client, IGamePlayer *pGamePlayer)
pClient->last_root_pos = 0;
}
void TopMenu::UpdateClientCategory(int client, unsigned int category)
void TopMenu::UpdateClientCategory(int client, unsigned int category, bool bSkipRootCheck)
{
bool has_access = false;
/* Update the client's root menu just in case it needs it. This
* will validate that we have both a valid client and a valid
* category structure for that client.
*/
UpdateClientRoot(client);
if (!bSkipRootCheck)
{
UpdateClientRoot(client);
}
/* Now it's guaranteed that our category tables will be usable */
topmenu_player_t *pClient = &m_clients[client];
@@ -744,6 +767,13 @@ void TopMenu::UpdateClientCategory(int client, unsigned int category)
for (size_t i = 0; i < cat->sorted.size(); i++)
{
cat_menu->AppendItem(cat->sorted[i]->name, ItemDrawInfo(""));
if (!has_access && adminsys->CheckAccess(client,
cat->sorted[i]->cmdname,
cat->sorted[i]->flags,
false))
{
has_access = true;
}
}
/* Now handle unsorted items */
@@ -761,20 +791,39 @@ void TopMenu::UpdateClientCategory(int client, unsigned int category)
item->name,
sizeof(item->name));
item->obj_index = (unsigned int)i;
if (!has_access && adminsys->CheckAccess(client, obj->cmdname, obj->flags, false))
{
has_access = true;
}
}
/* Sort the names */
qsort(item_list, cat->unsorted.size(), sizeof(obj_by_name_t), _SortObjectNamesDescending);
/* Add to the menu */
for (size_t i = 0; i < cat->unsorted.size(); i++)
if (has_access)
{
cat_menu->AppendItem(cat->unsorted[item_list[i].obj_index]->name, ItemDrawInfo(""));
/* Sort the names */
qsort(item_list,
cat->unsorted.size(),
sizeof(obj_by_name_t),
_SortObjectNamesDescending);
/* Add to the menu */
for (size_t i = 0; i < cat->unsorted.size(); i++)
{
cat_menu->AppendItem(cat->unsorted[item_list[i].obj_index]->name, ItemDrawInfo(""));
}
}
delete [] item_list;
}
/* If the player has access to no items, don't draw a menu. */
if (!has_access)
{
cat_menu->Destroy();
player_cat->menu = NULL;
player_cat->serial = cat->serial;
return;
}
/* Set the menu's title */
char renderbuf[128];
cat->obj->callbacks->OnTopMenuDisplayTitle(this,
+2 -1
View File
@@ -71,6 +71,7 @@ struct topmenu_object_t
TopMenuObjectType type; /** Object Type */
bool is_free; /** Free or not? */
char info[255]; /** Info string */
unsigned int cat_id; /** Set if a category */
};
struct topmenu_category_t
@@ -157,7 +158,7 @@ private:
bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position);
void CreatePlayers(int max_clients);
void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL);
void UpdateClientCategory(int client, unsigned int category);
void UpdateClientCategory(int client, unsigned int category, bool bSkipRootCheck=false);
void TearDownClient(topmenu_player_t *player);
private:
void OnClientConnected(int client);
+3 -3
View File
@@ -37,8 +37,8 @@
#define _INCLUDE_SQLITEEXT_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SQLITEEXT_VERSION_H_
+22 -1
View File
@@ -58,6 +58,23 @@
}
}
"ageofchivalry"
{
"Keys"
{
"RadioMenuTimeout" "4"
}
"Offsets"
{
"GetDataDescMap"
{
"windows" "11"
"linux" "12"
}
}
}
/**
* Which games support ShowMenu?
*/
@@ -75,6 +92,8 @@
"game" "diprip"
"game" "synergy"
"game" "FortressForever"
"game" "ageofchivalry"
"game" "obsidian"
}
"Keys"
@@ -93,6 +112,8 @@
"game" "hl2mp"
"game" "sourceforts"
"game" "tf"
"game" "ageofchivalry"
"game" "obsidian"
}
"Keys"
@@ -136,7 +157,7 @@
}
}
"synergy"
"synergy"
{
"Keys"
{
+183 -2
View File
@@ -33,6 +33,7 @@
{
"game" "dod"
"game" "tf"
"game" "ageofchivalry"
}
"Offsets"
@@ -81,6 +82,7 @@
{
"game" "dod"
"game" "tf"
"game" "ageofchivalry"
}
"Signatures"
@@ -107,6 +109,7 @@
{
"game" "dod"
"game" "tf"
"game" "ageofchivalry"
}
"Offsets"
@@ -148,6 +151,7 @@
{
"game" "dod"
"game" "tf"
"game" "ageofchivalry"
}
"Offsets"
@@ -226,6 +230,7 @@
{
"game" "dod"
"game" "tf"
"game" "ageofchivalry"
}
"Signatures"
{
@@ -313,8 +318,8 @@
}
"CommitSuicide"
{
"windows" "388"
"linux" "388"
"windows" "390"
"linux" "390"
}
"GetVelocity"
{
@@ -451,4 +456,180 @@
}
}
}
/* Afe of Chivalry */
"ageofchivalry"
{
"Offsets"
{
"GiveNamedItem"
{
"windows" "351"
"linux" "352"
}
"RemovePlayerItem"
{
"windows" "239"
"linux" "240"
}
"Weapon_GetSlot"
{
"windows" "237"
"linux" "238"
}
"Ignite"
{
"windows" "194"
"linux" "195"
}
"Extinguish"
{
"windows" "198"
"linux" "199"
}
"Teleport"
{
"windows" "101"
"linux" "102"
}
"CommitSuicide"
{
"windows" "389"
"linux" "389"
}
"GetVelocity"
{
"windows" "130"
"linux" "131"
}
"EyeAngles"
{
"windows" "122"
"linux" "123"
}
"AcceptInput"
{
"windows" "34"
"linux" "35"
}
"DispatchKeyValue"
{
"windows" "29"
"linux" "28"
}
"DispatchKeyValueFloat"
{
"windows" "28"
"linux" "29"
}
"DispatchKeyValueVector"
{
"windows" "27"
"linux" "30"
}
"SetEntityModel"
{
"windows" "23"
"linux" "24"
}
"WeaponEquip"
{
"windows" "230"
"linux" "231"
}
"Activate"
{
"windows" "31"
"linux" "32"
}
}
}
/* Obsidian Conflict 1.3 */
"obsidian"
{
"Offsets"
{
"GiveNamedItem"
{
"windows" "350"
"linux" "351"
}
"RemovePlayerItem"
{
"windows" "237"
"linux" "238"
}
"Weapon_GetSlot"
{
"windows" "235"
"linux" "236"
}
"Ignite"
{
"windows" "190"
"linux" "191"
}
"Extinguish"
{
"windows" "194"
"linux" "195"
}
"Teleport"
{
"windows" "100"
"linux" "101"
}
"CommitSuicide"
{
"windows" "395"
"linux" "395"
}
"GetVelocity"
{
"windows" "127"
"linux" "128"
}
"EyeAngles"
{
"windows" "119"
"linux" "120"
}
"AcceptInput"
{
"windows" "34"
"linux" "35"
}
"DispatchKeyValue"
{
"windows" "29"
"linux" "28"
}
"DispatchKeyValueFloat"
{
"windows" "28"
"linux" "29"
}
"DispatchKeyValueVector"
{
"windows" "27"
"linux" "30"
}
"SetEntityModel"
{
"windows" "23"
"linux" "24"
}
"WeaponEquip"
{
"windows" "228"
"linux" "229"
}
"Activate"
{
"windows" "31"
"linux" "32"
}
}
}
}
+15 -115
View File
@@ -37,8 +37,7 @@
"game" "!Dystopia"
"game" "!Insurgency"
"game" "pvkii"
"game" "!SourceForts v1.9.2"
"game" "$SourceForts v1.9.3"
"game" "sourceforts"
"game" "FortressForever"
"game" "empires"
"game" "synergy"
@@ -97,8 +96,7 @@
"game" "!Dystopia"
"game" "!Insurgency"
"game" "pvkii"
"game" "!SourceForts v1.9.2"
"game" "$SourceForts v1.9.3"
"game" "sourceforts"
"game" "FortressForever"
"game" "empires"
"game" "synergy"
@@ -148,8 +146,7 @@
"game" "ship"
"game" "!Insurgency"
"game" "pvkii"
"game" "!SourceForts v1.9.2"
"game" "$SourceForts v1.9.3"
"game" "sourceforts"
"game" "FortressForever"
"game" "empires"
"game" "synergy"
@@ -198,7 +195,7 @@
"game" "hl2mp"
"game" "!Insurgency"
"game" "pvkii"
"game" "$SourceForts v1.9.3"
"game" "sourceforts"
"game" "empires"
"game" "synergy"
"game" "hidden"
@@ -743,28 +740,28 @@
/* CBasePlayer */
"Ignite"
{
"windows" "174"
"linux" "175"
"windows" "176"
"linux" "177"
}
"Extinguish"
{
"windows" "175"
"linux" "176"
"windows" "176"
"linux" "177"
}
"Teleport"
{
"windows" "90"
"linux" "91"
"windows" "91"
"linux" "92"
}
"GetVelocity"
{
"windows" "115"
"linux" "116"
"windows" "116"
"linux" "117"
}
"EyeAngles"
{
"windows" "107"
"linux" "108"
"windows" "108"
"linux" "109"
}
"AcceptInput"
{
@@ -893,102 +890,6 @@
}
}
/* SourceForts 1.9.2 */
"!SourceForts v1.9.2"
{
"Offsets"
{
/* CBasePlayer */
"GiveNamedItem"
{
"windows" "294"
"linux" "295"
}
"RemovePlayerItem"
{
"windows" "207"
"linux" "208"
}
"Weapon_GetSlot"
{
"windows" "205"
"linux" "206"
}
"Ignite"
{
"windows" "170"
"linux" "171"
}
"Extinguish"
{
"windows" "171"
"linux" "172"
}
"Teleport"
{
"windows" "90"
"linux" "91"
}
"GetVelocity"
{
"windows" "114"
"linux" "115"
}
"EyeAngles"
{
"windows" "106"
"linux" "107"
}
"DispatchKeyValue"
{
"windows" "30"
"linux" "29"
}
"DispatchKeyValueFloat"
{
"windows" "29"
"linux" "30"
}
"DispatchKeyValueVector"
{
"windows" "28"
"linux" "31"
}
"AcceptInput"
{
"windows" "34"
"linux" "35"
}
"SetEntityModel"
{
"windows" "25"
"linux" "26"
}
"TE_GetServerClass"
{
"windows" "0"
"linux" "0"
}
}
"Signatures"
{
"DispatchSpawn"
{
"library" "server"
"linux" "@_Z13DispatchSpawnP11CBaseEntity"
"windows" "\x53\x56\x8B\x74\x24\x0C\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\xCB\xFF\x50\x14\x8B\x16\x8B\xCE"
}
"CreateEntityByName"
{
"library" "server"
"linux" "@_Z18CreateEntityByNamePKci"
"windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x25\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x56\xFF\x50\x54\x85\xC0"
}
}
}
/* Fortress Forever */
"FortressForever"
{
@@ -1269,8 +1170,7 @@
}
}
/* SourceForts 1.9.3 */
"$SourceForts v1.9.3"
"sourceforts"
{
"Offsets"
{
+7 -7
View File
@@ -6,39 +6,39 @@
{
"Burn"
{
"library" "server"
"library" "server"
"windows" "\x56\x8B\xF1\x8B\x8E\x2A\x2A\x00\x00\x8B\x01\x8B\x90\x2A\x2A\x00\x00\xFF\xD2\x84\xC0"
"linux" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayerP13CTFWeaponBase"
}
"RemoveDisguise"
{
"library" "server"
"library" "server"
"windows" "\x51\x56\x8B\xF1\x8B\x46\x2A\x57\x8D\x7E\x2A\x8D\x4C\x24\x08\x83\xE0\xF7"
"linux" "@_ZN15CTFPlayerShared14RemoveDisguiseEv"
}
"Disguise"
{
"library" "server"
"library" "server"
"windows" "\x56\x8B\xF1\x8B\x8E\x2A\x2A\x00\x00\xE8\x2A\x2A\x2A\x2A\x8B\x8E\x2A\x2A\x00\x00\x8B\x89\x2A\x2A\x00\x00"
"linux" "@_ZN15CTFPlayerShared8DisguiseEii"
}
"CalcCritical"
{
"library" "server"
"library" "server"
"linux" "@_ZN13CTFWeaponBase26CalcIsAttackCriticalHelperEv"
"windows" "\x83\xEC\x08\x53\x56\x6A\x00"
}
"CalcCriticalMelee"
{
"library" "server"
"library" "server"
"linux" "@_ZN18CTFWeaponBaseMelee26CalcIsAttackCriticalHelperEv"
"windows" "\x83\xEC\x08\x53\x57\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x8B\xD8"
}
"CalcCriticalKnife"
{
"library" "server"
"library" "server"
"linux" "@_ZN8CTFKnife26CalcIsAttackCriticalHelperEv"
"windows" "\x33\xC0\x83\xB9\x08\x13\x00\x00\x01\x0F\x94\xC0\xC3"
"windows" "\x8B\x81\xF0\x13\x00\x00\x83\xF8\xFF\x74\x29\x8B\x15"
}
}
+3 -3
View File
@@ -41,8 +41,8 @@
*/
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SOURCEMOD_VERSION_H_
+5 -2
View File
@@ -1,7 +1,7 @@
[PRODUCT]
major = 1
minor = 1
revision = 0
revision = 1
[core]
folder = core
@@ -73,4 +73,7 @@ folder = extensions/tf2
in = svn_version.tpl
out = svn_version.h
[clientprefs]
folder = extensions/clientprefs
in = svn_version.tpl
out = svn_version.h
+2 -2
View File
@@ -170,7 +170,7 @@ BuildDynamicMenu()
new count = 1;
decl String:countBuffer[10] = "1";
decl String:inputBuffer[32];
decl String:inputBuffer[48];
while (KvJumpToKey(kvMenu, countBuffer))
{
@@ -718,4 +718,4 @@ stock bool:UnQuoteString(String:input[], String:output[], maxlen, String:quotech
output[count] = 0;
return true;
}
}
+1 -1
View File
@@ -288,7 +288,7 @@ public Action:Command_Say(client, args)
}
else
{
if (mapchooser && !HasEndOfMapVoteFinished())
if (mapchooser && EndOfMapVoteEnabled() && !HasEndOfMapVoteFinished())
{
PrintToChat(client, "[SM] %t", "Pending Vote");
}
+219 -219
View File
@@ -1,219 +1,219 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _tf2_stocks_included
#endinput
#endif
#define _tf2_stocks_included
#include <tf2>
#include <sdktools>
enum TFResourceType
{
TFResource_Ping,
TFResource_Score,
TFResource_Deaths,
TFResource_TotalScore,
TFResource_Captures,
TFResource_Defenses,
TFResource_Dominations,
TFResource_Revenge,
TFResource_BuildingsDestroyed,
TFResource_Headshots,
TFResource_Backstabs,
TFResource_HealPoints,
TFResource_Invulns,
TFResource_Teleports,
TFResource_ResupplyPoints,
TFResource_KillAssists,
TFResource_MaxHealth,
TFResource_PlayerClass
};
static const String:TFResourceNames[TFResourceType][] =
{
"m_iPing",
"m_iScore",
"m_iDeaths",
"m_iTotalScore",
"m_iCaptures",
"m_iDefenses",
"m_iDominations",
"m_iRevenge",
"m_iBuildingsDestroyed",
"m_iHeadshots",
"m_iBackstabs",
"m_iHealPoints",
"m_iInvulns",
"m_iTeleports",
"m_iResupplyPoints",
"m_iKillAssists",
"m_iMaxHealth",
"m_iPlayerClass"
};
/**
* Get's a Clients current class.
*
* @param client Player's index.
* @param class TFClassType to change to.
* @noreturn
* @error Invalid client index.
*/
stock TFClassType:TF2_GetPlayerClass(client)
{
return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
}
/**
* Set's a Clients class.
*
* Note: If setting player class in a player spawn hook weapons should be set to false.
*
* @param client Player's index.
* @param class TFClassType class symbol.
* @param weapons This paramater is ignored.
* @param persistant If true changes the players desired class so the change stays after death.
* @noreturn
* @error Invalid client index.
*/
stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistant=true)
{
SetEntProp(client, Prop_Send, "m_iClass", _:class);
if (persistant)
{
SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
}
}
/**
* Retrieves client data from the resource entity
*
* @param client Player's index.
* @param type ResourceType constant
* @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity.
*/
stock TF2_GetPlayerResourceData(client, TFResourceType:type)
{
if (!IsClientConnected(client))
{
return -1;
}
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
if (offset < 1)
{
return -1;
}
new entity = TF2_GetResourceEntity();
if (entity == -1)
{
return -1;
}
return GetEntData(entity, offset + (client*4));
}
/**
* Sets client data in the resource entity
*
* Note: The game overwrites these values every frame, so changing them will have very little effect.
*
* @param client Player's index.
* @param type ResourceType constant
* @param value Value to set.
* @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity.
*/
stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
{
if (!IsClientConnected(client))
{
return false;
}
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
if (offset < 1)
{
return false;
}
new entity = TF2_GetResourceEntity();
if (entity == -1)
{
return false;
}
SetEntData(entity, offset + (client*4), value);
return true;
}
/**
* Removes all weapons from a client's weapon slot
*
* @param client Player's index.
* @param slot Slot index (0-5)
* @noreturn
* @error Invalid client, invalid slot or lack of mod support
*/
stock TF2_RemoveWeaponSlot(client, slot)
{
new weaponIndex;
while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
{
RemovePlayerItem(client, weaponIndex);
RemoveEdict(weaponIndex);
}
}
/**
* Removes all weapons from a client
*
* @param client Player's index.
* @noreturn
*/
stock TF2_RemoveAllWeapons(client)
{
for (new i = 0; i <= 5; i++)
{
TF2_RemoveWeaponSlot(client, i);
}
}
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _tf2_stocks_included
#endinput
#endif
#define _tf2_stocks_included
#include <tf2>
#include <sdktools>
enum TFResourceType
{
TFResource_Ping,
TFResource_Score,
TFResource_Deaths,
TFResource_TotalScore,
TFResource_Captures,
TFResource_Defenses,
TFResource_Dominations,
TFResource_Revenge,
TFResource_BuildingsDestroyed,
TFResource_Headshots,
TFResource_Backstabs,
TFResource_HealPoints,
TFResource_Invulns,
TFResource_Teleports,
TFResource_ResupplyPoints,
TFResource_KillAssists,
TFResource_MaxHealth,
TFResource_PlayerClass
};
static const String:TFResourceNames[TFResourceType][] =
{
"m_iPing",
"m_iScore",
"m_iDeaths",
"m_iTotalScore",
"m_iCaptures",
"m_iDefenses",
"m_iDominations",
"m_iRevenge",
"m_iBuildingsDestroyed",
"m_iHeadshots",
"m_iBackstabs",
"m_iHealPoints",
"m_iInvulns",
"m_iTeleports",
"m_iResupplyPoints",
"m_iKillAssists",
"m_iMaxHealth",
"m_iPlayerClass"
};
/**
* Get's a Clients current class.
*
* @param client Player's index.
* @return Current TFClassType of player.
* @error Invalid client index.
*/
stock TFClassType:TF2_GetPlayerClass(client)
{
return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
}
/**
* Set's a Clients class.
*
* Note: If setting player class in a player spawn hook weapons should be set to false.
*
* @param client Player's index.
* @param class TFClassType class symbol.
* @param weapons This paramater is ignored.
* @param persistant If true changes the players desired class so the change stays after death.
* @noreturn
* @error Invalid client index.
*/
stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistant=true)
{
SetEntProp(client, Prop_Send, "m_iClass", _:class);
if (persistant)
{
SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
}
}
/**
* Retrieves client data from the resource entity
*
* @param client Player's index.
* @param type ResourceType constant
* @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity.
*/
stock TF2_GetPlayerResourceData(client, TFResourceType:type)
{
if (!IsClientConnected(client))
{
return -1;
}
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
if (offset < 1)
{
return -1;
}
new entity = TF2_GetResourceEntity();
if (entity == -1)
{
return -1;
}
return GetEntData(entity, offset + (client*4));
}
/**
* Sets client data in the resource entity
*
* Note: The game overwrites these values every frame, so changing them will have very little effect.
*
* @param client Player's index.
* @param type ResourceType constant
* @param value Value to set.
* @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity.
*/
stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
{
if (!IsClientConnected(client))
{
return false;
}
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
if (offset < 1)
{
return false;
}
new entity = TF2_GetResourceEntity();
if (entity == -1)
{
return false;
}
SetEntData(entity, offset + (client*4), value);
return true;
}
/**
* Removes all weapons from a client's weapon slot
*
* @param client Player's index.
* @param slot Slot index (0-5)
* @noreturn
* @error Invalid client, invalid slot or lack of mod support
*/
stock TF2_RemoveWeaponSlot(client, slot)
{
new weaponIndex;
while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
{
RemovePlayerItem(client, weaponIndex);
RemoveEdict(weaponIndex);
}
}
/**
* Removes all weapons from a client
*
* @param client Player's index.
* @noreturn
*/
stock TF2_RemoveAllWeapons(client)
{
for (new i = 0; i <= 5; i++)
{
TF2_RemoveWeaponSlot(client, i);
}
}
+2 -2
View File
@@ -37,6 +37,6 @@
#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */
#define SOURCEMOD_V_MINOR 1 /**< SourceMod Minor version */
#define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */
#define SOURCEMOD_V_RELEASE 1 /**< SourceMod Release version */
#define SOURCEMOD_VERSION "1.1.0" /**< SourceMod version string (major.minor.release.build) */
#define SOURCEMOD_VERSION "1.1.1" /**< SourceMod version string (major.minor.release.build) */
+2 -2
View File
@@ -606,7 +606,7 @@ public Action:Command_AddGroup(client, args)
{
if (args < 2)
{
ReplyToCommand(client, "[SM] Usage: sm_sql_addgroup <flags> <name> [immunity]");
ReplyToCommand(client, "[SM] Usage: sm_sql_addgroup <name> <flags> [immunity]");
return Plugin_Handled;
}
@@ -660,8 +660,8 @@ public Action:Command_AddGroup(client, args)
Format(query,
sizeof(query),
"INSERT INTO sm_groups (flags, name, immunity_level) VALUES ('%s', '%s', '%d')",
safe_name,
safe_flags,
safe_name,
immunity);
if (!SQL_FastQuery(db, query))
+1 -1
View File
@@ -1 +1 @@
1.1.0
1.1.1
+1 -2
View File
@@ -1,2 +1 @@
a billion and TRILLIONS
timeout dance
release 1.1.1
+3 -3
View File
@@ -20,8 +20,8 @@
*/
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_SOURCEMOD_VERSION_H_
+3 -3
View File
@@ -33,8 +33,8 @@
#define _INCLUDE_JIT_VERSION_H_
#define SM_BUILD_STRING ""
#define SM_BUILD_UNIQUEID "2439:62cc69f6aa8b" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.0" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,0,0
#define SM_BUILD_UNIQUEID "2473:49a607a25edc" SM_BUILD_STRING
#define SVN_FULL_VERSION "1.1.1" SM_BUILD_STRING
#define SVN_FILE_VERSION 1,1,1,0
#endif //_INCLUDE_JIT_VERSION_H_