diff --git a/AMBuildScript b/AMBuildScript
index 42e0456..93cecab 100644
--- a/AMBuildScript
+++ b/AMBuildScript
@@ -28,9 +28,15 @@ class SDK(object):
return True
return False
-WinOnly = ['windows']
WinLinux = ['windows', 'linux']
-WinLinuxMac = ['windows', 'linux', 'mac']
+TF2 = {
+ 'windows': ['x86', 'x86_64'],
+ 'linux': ['x86', 'x86_64']
+}
+CSGO = {
+ 'windows': ['x86'],
+ 'linux': ['x86', 'x86_64']
+}
PossibleSDKs = {
# 'episode1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
@@ -38,21 +44,21 @@ PossibleSDKs = {
# 'orangebox': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
# 'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
# 'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
- 'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
- 'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
- 'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
- 'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
+ 'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinux, 'css'),
+ 'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinux, 'hl2dm'),
+ 'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinux, 'dods'),
+ 'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinux, 'sdk2013'),
# 'bms': SDK('HL2SDKBMS', '2.bms', '11', 'BMS', WinLinux, 'bms'),
- 'tf2': SDK('HL2SDKTF2', '2.tf2', '12', 'TF2', WinLinuxMac, 'tf2'),
- 'l4d': SDK('HL2SDKL4D', '2.l4d', '13', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
+ 'tf2': SDK('HL2SDKTF2', '2.tf2', '12', 'TF2', TF2, 'tf2'),
+ 'l4d': SDK('HL2SDKL4D', '2.l4d', '13', 'LEFT4DEAD', WinLinux, 'l4d'),
# 'nucleardawn': SDK('HL2SDKND', '2.nd', '14', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
# 'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '15', 'CONTAGION', WinOnly, 'contagion'),
- 'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '16', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
+ 'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '16', 'LEFT4DEAD2', WinLinux, 'l4d2'),
# 'swarm': SDK('HL2SDK-SWARM', '2.swarm', '17', 'ALIENSWARM', WinOnly, 'swarm'),
# 'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '18', 'PORTAL2', [], 'portal2'),
# 'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'),
# 'blade': SDK('HL2SDKBLADE', '2.blade', '21', 'BLADE', WinLinux, 'blade'),
- 'csgo': SDK('HL2SDKCSGO', '2.csgo', '23', 'CSGO', WinLinuxMac, 'csgo'),
+ 'csgo': SDK('HL2SDKCSGO', '2.csgo', '23', 'CSGO', CSGO, 'csgo'),
}
def ResolveEnvPath(env, folder):
@@ -99,9 +105,7 @@ class ExtensionConfig(object):
if builder.options.targets:
target_archs = builder.options.targets.split(',')
else:
- target_archs = ['x86']
- if builder.backend != 'amb2':
- target_archs.append('x86_64')
+ target_archs = ['x86', 'x86_64']
for arch in target_archs:
try:
@@ -151,7 +155,7 @@ class ExtensionConfig(object):
import re
with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp:
productContents = fp.read()
- m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
+ m = re.match('(\\d+)\.(\\d+)\.(\\d+).*', productContents)
if m == None:
self.productVersion = '1.0.0'
else:
@@ -228,6 +232,7 @@ class ExtensionConfig(object):
self.configure_gcc(cxx)
elif cxx.family == 'msvc':
self.configure_msvc(cxx)
+ cxx.defines += ['HAVE_STRING_H']
# Optimizaiton
if builder.options.opt == '1':
@@ -273,7 +278,6 @@ class ExtensionConfig(object):
'-Wno-switch',
'-Wno-array-bounds',
'-msse',
- '-m32',
'-fvisibility=hidden',
]
cxx.cxxflags += [
@@ -284,7 +288,6 @@ class ExtensionConfig(object):
'-fvisibility-inlines-hidden',
'-fpermissive'
]
- cxx.linkflags += ['-m32']
have_gcc = cxx.vendor == 'gcc'
have_clang = cxx.vendor == 'clang'
@@ -534,14 +537,7 @@ class ExtensionConfig(object):
for library in dynamic_libs:
source_path = os.path.join(lib_folder, library)
- output_path = os.path.join(binary.localFolder, library)
-
- # Ensure the output path exists.
- context.AddFolder(binary.localFolder)
- output = context.AddSymlink(source_path, output_path)
-
- compiler.weaklinkdeps += [output]
- compiler.linkflags[0:0] = [library]
+ compiler.postlink.append(source_path)
return binary
diff --git a/buildbot/PackageScript b/buildbot/PackageScript
index fecc709..014a2f1 100644
--- a/buildbot/PackageScript
+++ b/buildbot/PackageScript
@@ -29,7 +29,7 @@ def CopyFiles(src, dest, filter_ext=None):
builder.AddCopy(entry_path, dest)
-folders = CreateFolders(['addons/sourcemod/extensions', 'addons/sourcemod/gamedata', 'addons/sourcemod/scripting', 'addons/sourcemod/scripting/include'])
+folders = CreateFolders(['addons/sourcemod/extensions', 'addons/sourcemod/extensions/x64', 'addons/sourcemod/gamedata', 'addons/sourcemod/scripting', 'addons/sourcemod/scripting/include'])
pdblog = open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt')
for cxx_task in Extension.extensions:
diff --git a/extension/AMBuilder b/extension/AMBuilder
index 0010f32..e711315 100644
--- a/extension/AMBuilder
+++ b/extension/AMBuilder
@@ -6,9 +6,15 @@ projectname = 'connect'
project = builder.LibraryProject(projectname + '.ext')
project.sources = [
'extension.cpp',
- 'asm/asm.c',
- 'CDetour/detours.cpp',
- 'sdk/smsdk_ext.cpp'
+ os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp'),
+ os.path.join(Extension.sm_root, 'public', 'CDetour', 'detours.cpp'),
+ os.path.join(Extension.sm_root, 'public', 'asm', 'asm.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'decode.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'itab.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-att.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-intel.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn.c'),
+ os.path.join(Extension.sm_root, 'public', 'libudis86', 'udis86.c')
]
for sdk_name in Extension.sdks:
diff --git a/extension/CDetour/detourhelpers.h b/extension/CDetour/detourhelpers.h
deleted file mode 100644
index 85cda0e..0000000
--- a/extension/CDetour/detourhelpers.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * vim: set ts=4 :
- * =============================================================================
- * SourceMod
- * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
- * =============================================================================
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, 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 .
- *
- * 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 .
- *
- * 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
-#include
-#define PAGE_SIZE 4096
-#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
-#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
-#endif
-
-struct patch_t
-{
- patch_t()
- {
- patch[0] = 0;
- bytes = 0;
- }
- unsigned char patch[20];
- size_t bytes;
-};
-
-inline void ProtectMemory(void *addr, int length, int prot)
-{
-#if defined PLATFORM_POSIX
- void *addr2 = (void *)ALIGN(addr);
- mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
-#elif defined PLATFORM_WINDOWS
- DWORD old_prot;
- VirtualProtect(addr, length, prot, &old_prot);
-#endif
-}
-
-inline void SetMemPatchable(void *address, size_t size)
-{
- ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
-}
-
-inline void DoGatePatch(unsigned char *target, void *callback)
-{
- SetMemPatchable(target, 20);
-
- target[0] = 0xFF; /* JMP */
- target[1] = 0x25; /* MEM32 */
- *(void **)(&target[2]) = callback;
-}
-
-inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
-{
- ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
-
- unsigned char *addr = (unsigned char *)address + offset;
- if (restore)
- {
- for (size_t i=0; ibytes; i++)
- {
- restore->patch[i] = addr[i];
- }
- restore->bytes = patch->bytes;
- }
-
- for (size_t i=0; ibytes; i++)
- {
- addr[i] = patch->patch[i];
- }
-}
-
-#endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_
diff --git a/extension/CDetour/detours.cpp b/extension/CDetour/detours.cpp
deleted file mode 100644
index 71aba44..0000000
--- a/extension/CDetour/detours.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
-* vim: set ts=4 :
-* =============================================================================
-* SourceMod
-* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
-* =============================================================================
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the GNU General Public License, 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 .
-*
-* 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 .
-*
-* Version: $Id: detours.cpp 248 2008-08-27 00:56:22Z pred $
-*/
-
-#include "detours.h"
-#include
-
-ISourcePawnEngine *CDetourManager::spengine = NULL;
-IGameConfig *CDetourManager::gameconf = NULL;
-
-void CDetourManager::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
-{
- CDetourManager::spengine = spengine;
- CDetourManager::gameconf = gameconf;
-}
-
-CDetour *CDetourManager::CreateDetour(void *callbackfunction, void **trampoline, const char *signame)
-{
- CDetour *detour = new CDetour(callbackfunction, trampoline, signame);
- if (detour)
- {
- if (!detour->Init(spengine, gameconf))
- {
- delete detour;
- return NULL;
- }
-
- return detour;
- }
-
- return NULL;
-}
-
-CDetour::CDetour(void *callbackfunction, void **trampoline, const char *signame)
-{
- enabled = false;
- detoured = false;
- detour_address = NULL;
- detour_trampoline = NULL;
- this->signame = signame;
- this->detour_callback = callbackfunction;
- spengine = NULL;
- gameconf = NULL;
- this->trampoline = trampoline;
-}
-
-bool CDetour::Init(ISourcePawnEngine *spengine, IGameConfig *gameconf)
-{
- this->spengine = spengine;
- this->gameconf = gameconf;
-
- if (!CreateDetour())
- {
- enabled = false;
- return enabled;
- }
-
- enabled = true;
-
- return enabled;
-}
-
-void CDetour::Destroy()
-{
- DeleteDetour();
- delete this;
-}
-
-bool CDetour::IsEnabled()
-{
- return enabled;
-}
-
-bool CDetour::CreateDetour()
-{
- if (!gameconf->GetMemSig(signame, &detour_address))
- {
- g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame);
- return false;
- }
-
- if (!detour_address)
- {
- g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame);
- return false;
- }
-
- detour_restore.bytes = copy_bytes((unsigned char *)detour_address, NULL, OP_JMP_SIZE+1);
-
- /* First, save restore bits */
- for (size_t i=0; iAllocatePageMemory(CodeSize);
- spengine->SetReadWrite(wr.outbase);
- wr.outptr = 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)
- {
- DoGatePatch((unsigned char *)detour_address, &detour_callback);
- detoured = true;
- }
-}
-
-void CDetour::DisableDetour()
-{
- if (detoured)
- {
- /* Remove the patch */
- ApplyPatch(detour_address, 0, &detour_restore, NULL);
- detoured = false;
- }
-}
diff --git a/extension/CDetour/detours.h b/extension/CDetour/detours.h
deleted file mode 100644
index 289e2b3..0000000
--- a/extension/CDetour/detours.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/**
-* vim: set ts=4 :
-* =============================================================================
-* SourceMod
-* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
-* =============================================================================
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the GNU General Public License, 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 .
-*
-* 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 .
-*
-* Version: $Id: detours.h 257 2008-09-23 03:12:13Z pred $
-*/
-
-#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
-#define _INCLUDE_SOURCEMOD_DETOURS_H_
-
-#include "extension.hpp"
-#include
-#include
-#include "detourhelpers.h"
-
-/**
- * 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) 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_STATIC2(name, ret, p1type, p1name, p2type, p2name) \
- ret (*name##_Actual)(p1type, p2type) = NULL; \
- ret name(p1type p1name, p2type p2name)
-
-#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_MEMBER5(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name) \
-class name##Class \
-{ \
-public: \
- ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name); \
- static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type); \
-}; \
-ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type) = NULL; \
-ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name)
-
-#define DETOUR_DECL_MEMBER7(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name) \
-class name##Class \
-{ \
-public: \
- ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name); \
- static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type); \
-}; \
-ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type) = NULL; \
-ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name)
-
-#define DETOUR_DECL_MEMBER8(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name) \
-class name##Class \
-{ \
-public: \
- ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name); \
- static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type); \
-}; \
-ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
-ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
-
-#define DETOUR_DECL_MEMBER9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
-class name##Class \
-{ \
-public: \
- ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name); \
- static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type); \
-}; \
-ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
-ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
-
-#define DETOUR_DECL_MEMBER10(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name) \
-class name##Class \
-{ \
-public: \
- ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name); \
- static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type); \
-}; \
-ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type) = NULL; \
-ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name)
-
-#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(mfp))
-
-class CDetourManager;
-
-class CDetour
-{
-public:
-
- bool IsEnabled();
-
- /**
- * These would be somewhat self-explanatory I hope
- */
- void EnableDetour();
- void DisableDetour();
-
- void Destroy();
-
- friend class CDetourManager;
-
-protected:
- CDetour(void *callbackfunction, void **trampoline, const char *signame);
-
- bool Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
-private:
-
- /* These create/delete the allocated memory */
- bool CreateDetour();
- void DeleteDetour();
-
- bool enabled;
- 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;
- ISourcePawnEngine *spengine;
- IGameConfig *gameconf;
-};
-
-class CDetourManager
-{
-public:
-
- static void Init(ISourcePawnEngine *spengine, IGameConfig *gameconf);
-
- /**
- * Creates a new detour
- *
- * @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.
- *
- * Example:
- *
- * CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int)
- *
- * 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(callbackfunc, trampoline, "ConnectClient");
- *
- * 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 CDetour *CreateDetour(void *callbackfunction, void **trampoline, const char *signame);
-
- friend class CBlocker;
- friend class CDetour;
-
-private:
- static ISourcePawnEngine *spengine;
- static IGameConfig *gameconf;
-};
-
-#define DECL_DETOUR(name) \
- CDetour *name##_Detour = NULL;
-
-#define CREATE_DETOUR(name) \
- name##_Detour = DETOUR_CREATE_MEMBER(name, #name); \
- if (name##_Detour != NULL) \
- { \
- name##_Detour->EnableDetour(); \
- } else { \
- snprintf(error, maxlen, "Failed to create " #name " detour, check error log.\n"); \
- return false; \
- }
-
-#define DESTROY_DETOUR(name) \
- if (name##_Detour != NULL) \
-{ \
- name##_Detour->Destroy(); \
- name##_Detour = NULL; \
-}
-
-#endif // _INCLUDE_SOURCEMOD_DETOURS_H_
diff --git a/extension/asm/asm.c b/extension/asm/asm.c
deleted file mode 100644
index 2facf8d..0000000
--- a/extension/asm/asm.c
+++ /dev/null
@@ -1,421 +0,0 @@
-#include "asm.h"
-
-#ifndef WIN32
-#define _GNU_SOURCE
-#include
-#include
-
-#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
-#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
-int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) {
- int bytecount = 0;
-
- while(bytecount < required_len && *func != 0xCC)
- {
- // prefixes F0h, F2h, F3h, 66h, 67h, D8h-DFh, 2Eh, 36h, 3Eh, 26h, 64h and 65h
- int operandSize = 4;
- int FPU = 0;
- int twoByte = 0;
- unsigned char opcode = 0x90;
- unsigned char modRM = 0xFF;
- while(*func == 0xF0 ||
- *func == 0xF2 ||
- *func == 0xF3 ||
- (*func & 0xFC) == 0x64 ||
- (*func & 0xF8) == 0xD8 ||
- (*func & 0x7E) == 0x62)
- {
- if(*func == 0x66)
- {
- operandSize = 2;
- }
- else if((*func & 0xF8) == 0xD8)
- {
- FPU = *func;
- if (dest)
- *dest++ = *func++;
- else
- func++;
- bytecount++;
- break;
- }
-
- if (dest)
- *dest++ = *func++;
- else
- func++;
- bytecount++;
- }
-
- // two-byte opcode byte
- if(*func == 0x0F)
- {
- twoByte = 1;
- if (dest)
- *dest++ = *func++;
- else
- func++;
- bytecount++;
- }
-
- // opcode byte
- opcode = *func++;
- if (dest) *dest++ = opcode;
- bytecount++;
-
- // mod R/M byte
- modRM = 0xFF;
- if(FPU)
- {
- if((opcode & 0xC0) != 0xC0)
- {
- modRM = opcode;
- }
- }
- else if(!twoByte)
- {
- if((opcode & 0xC4) == 0x00 ||
- ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) ||
- (opcode & 0xF0) == 0x80 ||
- ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) ||
- (opcode & 0xFC) == 0xD0 ||
- (opcode & 0xF6) == 0xF6)
- {
- modRM = *func++;
- if (dest) *dest++ = modRM;
- bytecount++;
- }
- }
- else
- {
- if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) ||
- (opcode & 0xF0) == 0x30 ||
- opcode == 0x77 ||
- (opcode & 0xF0) == 0x80 ||
- ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) ||
- (opcode & 0xF8) == 0xC8)
- {
- // No mod R/M byte
- }
- else
- {
- modRM = *func++;
- if (dest) *dest++ = modRM;
- bytecount++;
- }
- }
-
- // SIB
- if((modRM & 0x07) == 0x04 &&
- (modRM & 0xC0) != 0xC0)
- {
- if (dest)
- *dest++ = *func++; //SIB
- else
- func++;
- bytecount++;
- }
-
- // mod R/M displacement
-
- // Dword displacement, no base
- if((modRM & 0xC5) == 0x05) {
- if (dest) {
- *(unsigned int*)dest = *(unsigned int*)func;
- dest += 4;
- }
- func += 4;
- bytecount += 4;
- }
-
- // Byte displacement
- if((modRM & 0xC0) == 0x40) {
- if (dest)
- *dest++ = *func++;
- else
- func++;
- bytecount++;
- }
-
- // Dword displacement
- if((modRM & 0xC0) == 0x80) {
- if (dest) {
- *(unsigned int*)dest = *(unsigned int*)func;
- dest += 4;
- }
- func += 4;
- bytecount += 4;
- }
-
- // immediate
- if(FPU)
- {
- // Can't have immediate operand
- }
- else if(!twoByte)
- {
- if((opcode & 0xC7) == 0x04 ||
- (opcode & 0xFE) == 0x6A || // PUSH/POP/IMUL
- (opcode & 0xF0) == 0x70 || // Jcc
- opcode == 0x80 ||
- opcode == 0x83 ||
- (opcode & 0xFD) == 0xA0 || // MOV
- opcode == 0xA8 || // TEST
- (opcode & 0xF8) == 0xB0 || // MOV
- (opcode & 0xFE) == 0xC0 || // RCL
- opcode == 0xC6 || // MOV
- opcode == 0xCD || // INT
- (opcode & 0xFE) == 0xD4 || // AAD/AAM
- (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ
- opcode == 0xEB ||
- (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST
- {
- if (dest)
- *dest++ = *func++;
- else
- func++;
- bytecount++;
- }
- else if((opcode & 0xF7) == 0xC2) // RET
- {
- if (dest) {
- *(unsigned short*)dest = *(unsigned short*)func;
- dest += 2;
- }
- func += 2;
- bytecount += 2;
- }
- else if((opcode & 0xFC) == 0x80 ||
- (opcode & 0xC7) == 0x05 ||
- (opcode & 0xF8) == 0xB8 ||
- (opcode & 0xFE) == 0xE8 || // CALL/Jcc
- (opcode & 0xFE) == 0x68 ||
- (opcode & 0xFC) == 0xA0 ||
- (opcode & 0xEE) == 0xA8 ||
- opcode == 0xC7 ||
- (opcode == 0xF7 && (modRM & 0x30) == 0x00))
- {
- if (dest) {
- //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;
- else
- *(unsigned short*)dest = *(unsigned short*)func;
- }
- dest += operandSize;
- }
- func += operandSize;
- bytecount += operandSize;
-
- }
- }
- else
- {
- if(opcode == 0xBA || // BT
- opcode == 0x0F || // 3DNow!
- (opcode & 0xFC) == 0x70 || // PSLLW
- (opcode & 0xF7) == 0xA4 || // SHLD
- opcode == 0xC2 ||
- opcode == 0xC4 ||
- opcode == 0xC5 ||
- opcode == 0xC6)
- {
- if (dest)
- *dest++ = *func++;
- else
- func++;
- }
- else if((opcode & 0xF0) == 0x80) // Jcc -i
- {
- if (dest) {
- if (operandSize == 4)
- *(unsigned long*)dest = *(unsigned long*)func;
- else
- *(unsigned short*)dest = *(unsigned short*)func;
-
- dest += operandSize;
- }
- func += operandSize;
- bytecount += operandSize;
- }
- }
- }
-
- return bytecount;
-}
-
-//insert a specific JMP instruction at the given location
-void inject_jmp(void* src, void* dest) {
- *(unsigned char*)src = OP_JMP;
- *(long*)((unsigned char*)src+1) = (long)((unsigned char*)dest - ((unsigned char*)src + OP_JMP_SIZE));
-}
-
-//fill a given block with NOPs
-void fill_nop(void* src, unsigned int len) {
- unsigned char* src2 = (unsigned char*)src;
- while (len) {
- *src2++ = OP_NOP;
- --len;
- }
-}
-
-void* eval_jump(void* src) {
- unsigned char* addr = (unsigned char*)src;
-
- if (!addr) return 0;
-
- //import table jump
- if (addr[0] == OP_PREFIX && addr[1] == OP_JMP_SEG) {
- addr += 2;
- addr = *(unsigned char**)addr;
- //TODO: if addr points into the IAT
- return *(void**)addr;
- }
-
- //8bit offset
- else if (addr[0] == OP_JMP_BYTE) {
- addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1];
- //mangled 32bit jump?
- if (addr[0] == OP_JMP) {
- addr = addr + *(int*)&addr[1];
- }
- return addr;
- }
- /*
- //32bit offset
- else if (addr[0] == OP_JMP) {
- addr = &addr[OP_JMP_SIZE] + *(int*)&addr[1];
- }
- */
-
- return addr;
-}
-/*
-from ms detours package
-static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress)
-{
- MEMORY_BASIC_INFORMATION mbi;
- VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi));
- __try {
- PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase;
- if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
- return false;
- }
-
- PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader +
- pDosHeader->e_lfanew);
- if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
- return false;
- }
-
- if (pbAddress >= ((PBYTE)pDosHeader +
- pNtHeader->OptionalHeader
- .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) &&
- pbAddress < ((PBYTE)pDosHeader +
- pNtHeader->OptionalHeader
- .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress +
- pNtHeader->OptionalHeader
- .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) {
- return true;
- }
- return false;
- }
- __except(EXCEPTION_EXECUTE_HANDLER) {
- return false;
- }
-}
-*/
diff --git a/extension/asm/asm.h b/extension/asm/asm.h
deleted file mode 100644
index 6086232..0000000
--- a/extension/asm/asm.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __ASM_H__
-#define __ASM_H__
-
-#define OP_JMP 0xE9
-#define OP_JMP_SIZE 5
-
-#define OP_NOP 0x90
-#define OP_NOP_SIZE 1
-
-#define OP_PREFIX 0xFF
-#define OP_JMP_SEG 0x25
-
-#define OP_JMP_BYTE 0xEB
-#define OP_JMP_BYTE_SIZE 2
-
-#ifdef __cplusplus
-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
-int copy_bytes(unsigned char *func, unsigned char* dest, int required_len);
-
-//insert a specific JMP instruction at the given location
-void inject_jmp(void* src, void* dest);
-
-//fill a given block with NOPs
-void fill_nop(void* src, unsigned int len);
-
-//evaluate a JMP at the target
-void* eval_jump(void* src);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__ASM_H__
diff --git a/extension/extension.cpp b/extension/extension.cpp
index 42899fa..22e54f9 100644
--- a/extension/extension.cpp
+++ b/extension/extension.cpp
@@ -17,7 +17,7 @@
* this program. If not, see .
*/
-#include "extension.hpp"
+#include "extension.h"
#include "CDetour/detours.h"
#include "steam/steamclientpublic.h"
@@ -217,9 +217,9 @@ void EndAuthSession(CSteamID steamID)
return (void)(reinterpret_cast(this_ptr)->*u.mfpnew)(steamID);
}
-DECL_DETOUR(CBaseServer__ConnectClient);
-DECL_DETOUR(CBaseServer__RejectConnection)
-DECL_DETOUR(CBaseServer__CheckChallengeType);
+CDetour* detourCBaseServer__ConnectClient = nullptr;
+CDetour* detourCBaseServer__RejectConnection = nullptr;
+CDetour* detourCBaseServer__CheckChallengeType = nullptr;
bool g_bEndAuthSessionOnRejectConnection = false;
CSteamID g_lastClientSteamID;
@@ -227,7 +227,18 @@ CSteamID g_lastClientSteamID;
bool g_bSuppressCheckChallengeType = false;
char passwordBuffer[255];
-DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient *, netadr_t &, address, int, nProtocol, int, iChallenge, int, iClientChallenge, int, nAuthProtocol, const char *, pchName, const char *, pchPassword, const char *, pCookie, int, cbCookie)
+
+#define DETOUR_DECL_MEMBER9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
+class name##Class \
+{ \
+public: \
+ ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name); \
+ static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type); \
+}; \
+ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
+ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
+
+DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, int, nProtocol, int, iChallenge, int, iClientChallenge, int, nAuthProtocol, const char *, pchName, const char *, pchPassword, const char *, pCookie, int, cbCookie)
{
if (nAuthProtocol != k_EAuthProtocolSteam)
{
@@ -385,9 +396,9 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late)
CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf);
- CREATE_DETOUR(CBaseServer__ConnectClient);
- CREATE_DETOUR(CBaseServer__RejectConnection);
- CREATE_DETOUR(CBaseServer__CheckChallengeType);
+ detourCBaseServer__ConnectClient = DETOUR_CREATE_MEMBER(CBaseServer__ConnectClient, "CBaseServer__ConnectClient");
+ detourCBaseServer__RejectConnection = DETOUR_CREATE_MEMBER(CBaseServer__RejectConnection, "CBaseServer__RejectConnection");
+ detourCBaseServer__CheckChallengeType = DETOUR_CREATE_MEMBER(CBaseServer__CheckChallengeType, "CBaseServer__CheckChallengeType");
g_pConnectForward = g_pForwards->CreateForward("OnClientPreConnectEx", ET_LowEvent, 5, NULL, Param_String, Param_String, Param_String, Param_String, Param_String);
@@ -412,9 +423,21 @@ void Connect::SDK_OnUnload()
bool Connect::SDK_OnMetamodUnload(char *error, size_t maxlen)
{
- DESTROY_DETOUR(CBaseServer__ConnectClient);
- DESTROY_DETOUR(CBaseServer__RejectConnection);
- DESTROY_DETOUR(CBaseServer__CheckChallengeType);
+ if (detourCBaseServer__ConnectClient)
+ {
+ detourCBaseServer__ConnectClient->DisableDetour();
+ delete detourCBaseServer__ConnectClient;
+ }
+ if (detourCBaseServer__RejectConnection)
+ {
+ detourCBaseServer__RejectConnection->DisableDetour();
+ delete detourCBaseServer__RejectConnection;
+ }
+ if (detourCBaseServer__CheckChallengeType)
+ {
+ detourCBaseServer__CheckChallengeType->DisableDetour();
+ delete detourCBaseServer__CheckChallengeType;
+ }
return true;
}
diff --git a/extension/extension.hpp b/extension/extension.h
similarity index 96%
rename from extension/extension.hpp
rename to extension/extension.h
index 72a84f5..5d6fdd3 100644
--- a/extension/extension.hpp
+++ b/extension/extension.h
@@ -1,103 +1,103 @@
-/**
- * =============================================================================
- * TF2 Items Extension
- * Copyright (C) 2009-2010 AzuiSleet, Asher Baker (asherkin). All rights reserved.
- * =============================================================================
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, 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 .
- *
- */
-
-#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
-#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
-
-/**
- * @file extension.hpp
- * @brief Connect extension code header.
- */
-
-#include "smsdk_ext.hpp"
-
-/**
- * @brief Sample implementation of the SDK Extension.
- * Note: Uncomment one of the pre-defined virtual functions in order to use it.
- */
-class Connect : public SDKExtension, public IConCommandBaseAccessor
-{
-public:
- /**
- * @brief This is called after the initial loading sequence has been processed.
- *
- * @param error Error message buffer.
- * @param maxlength Size of error message buffer.
- * @param late Whether or not the module was loaded after map load.
- * @return True to succeed loading, false to fail.
- */
- virtual bool SDK_OnLoad(char *error, size_t maxlen, bool late);
-
- /**
- * @brief This is called right before the extension is unloaded.
- */
- virtual void SDK_OnUnload();
-
- /**
- * @brief Called when the pause state is changed.
- */
- //virtual void SDK_OnPauseChange(bool paused);
-
- /**
- * @brief this is called when Core wants to know if your extension is working.
- *
- * @param error Error message buffer.
- * @param maxlength Size of error message buffer.
- * @return True if working, false otherwise.
- */
- //virtual bool QueryRunning(char *error, size_t maxlen);
-public:
-#if defined SMEXT_CONF_METAMOD
- /**
- * @brief Called when Metamod is attached, before the extension version is called.
- *
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @param late Whether or not Metamod considers this a late load.
- * @return True to succeed, false to fail.
- */
- virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
-
- /**
- * @brief Called when Metamod is detaching, after the extension version is called.
- * NOTE: By default this is blocked unless sent from SourceMod.
- *
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @return True to succeed, false to fail.
- */
- virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
-
- /**
- * @brief Called when Metamod's pause state is changing.
- * NOTE: By default this is blocked unless sent from SourceMod.
- *
- * @param paused Pause state being set.
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @return True to succeed, false to fail.
- */
- //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
-#endif
-public: //IConCommandBaseAccessor
- bool RegisterConCommandBase(ConCommandBase *pCommand);
-};
-
-#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
+/**
+ * =============================================================================
+ * TF2 Items Extension
+ * Copyright (C) 2009-2010 AzuiSleet, Asher Baker (asherkin). All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, 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 .
+ *
+ */
+
+#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
+#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
+
+/**
+ * @file extension.hpp
+ * @brief Connect extension code header.
+ */
+
+#include "smsdk_ext.h"
+
+/**
+ * @brief Sample implementation of the SDK Extension.
+ * Note: Uncomment one of the pre-defined virtual functions in order to use it.
+ */
+class Connect : public SDKExtension, public IConCommandBaseAccessor
+{
+public:
+ /**
+ * @brief This is called after the initial loading sequence has been processed.
+ *
+ * @param error Error message buffer.
+ * @param maxlength Size of error message buffer.
+ * @param late Whether or not the module was loaded after map load.
+ * @return True to succeed loading, false to fail.
+ */
+ virtual bool SDK_OnLoad(char *error, size_t maxlen, bool late);
+
+ /**
+ * @brief This is called right before the extension is unloaded.
+ */
+ virtual void SDK_OnUnload();
+
+ /**
+ * @brief Called when the pause state is changed.
+ */
+ //virtual void SDK_OnPauseChange(bool paused);
+
+ /**
+ * @brief this is called when Core wants to know if your extension is working.
+ *
+ * @param error Error message buffer.
+ * @param maxlength Size of error message buffer.
+ * @return True if working, false otherwise.
+ */
+ //virtual bool QueryRunning(char *error, size_t maxlen);
+public:
+#if defined SMEXT_CONF_METAMOD
+ /**
+ * @brief Called when Metamod is attached, before the extension version is called.
+ *
+ * @param error Error buffer.
+ * @param maxlength Maximum size of error buffer.
+ * @param late Whether or not Metamod considers this a late load.
+ * @return True to succeed, false to fail.
+ */
+ virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
+
+ /**
+ * @brief Called when Metamod is detaching, after the extension version is called.
+ * NOTE: By default this is blocked unless sent from SourceMod.
+ *
+ * @param error Error buffer.
+ * @param maxlength Maximum size of error buffer.
+ * @return True to succeed, false to fail.
+ */
+ virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
+
+ /**
+ * @brief Called when Metamod's pause state is changing.
+ * NOTE: By default this is blocked unless sent from SourceMod.
+ *
+ * @param paused Pause state being set.
+ * @param error Error buffer.
+ * @param maxlength Maximum size of error buffer.
+ * @return True to succeed, false to fail.
+ */
+ //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
+#endif
+public: //IConCommandBaseAccessor
+ bool RegisterConCommandBase(ConCommandBase *pCommand);
+};
+
+#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
diff --git a/extension/sdk/smsdk_ext.cpp b/extension/sdk/smsdk_ext.cpp
deleted file mode 100644
index de7c400..0000000
--- a/extension/sdk/smsdk_ext.cpp
+++ /dev/null
@@ -1,475 +0,0 @@
-/**
- * vim: set ts=4 :
- * =============================================================================
- * SourceMod Base Extension Code
- * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
- * =============================================================================
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, 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 .
- *
- * 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 .
- *
- * Version: $Id$
- */
-
-#include
-#include
-#include "smsdk_ext.hpp"
-
-/**
- * @file smsdk_ext.cpp
- * @brief Contains wrappers for making Extensions easier to write.
- */
-
-IExtension *myself = NULL; /**< Ourself */
-IShareSys *g_pShareSys = NULL; /**< Share system */
-IShareSys *sharesys = NULL; /**< Share system */
-ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
-ISourceMod *smutils = NULL; /**< SourceMod helpers */
-
-#if defined SMEXT_ENABLE_FORWARDSYS
-IForwardManager *g_pForwards = NULL; /**< Forward system */
-IForwardManager *forwards = NULL; /**< Forward system */
-#endif
-#if defined SMEXT_ENABLE_HANDLESYS
-IHandleSys *g_pHandleSys = NULL; /**< Handle system */
-IHandleSys *handlesys = NULL; /**< Handle system */
-#endif
-#if defined SMEXT_ENABLE_PLAYERHELPERS
-IPlayerManager *playerhelpers = NULL; /**< Player helpers */
-#endif //SMEXT_ENABLE_PLAYERHELPERS
-#if defined SMEXT_ENABLE_DBMANAGER
-IDBManager *dbi = NULL; /**< DB Manager */
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_GAMECONF
-IGameConfigManager *gameconfs = NULL; /**< Game config manager */
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_MEMUTILS
-IMemoryUtils *memutils = NULL;
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_GAMEHELPERS
-IGameHelpers *gamehelpers = NULL;
-#endif
-#if defined SMEXT_ENABLE_TIMERSYS
-ITimerSystem *timersys = NULL;
-#endif
-#if defined SMEXT_ENABLE_ADTFACTORY
-IADTFactory *adtfactory = NULL;
-#endif
-#if defined SMEXT_ENABLE_THREADER
-IThreader *threader = NULL;
-#endif
-#if defined SMEXT_ENABLE_LIBSYS
-ILibrarySys *libsys = NULL;
-#endif
-#if defined SMEXT_ENABLE_PLUGINSYS
-SourceMod::IPluginManager *plsys;
-#endif
-#if defined SMEXT_ENABLE_MENUS
-IMenuManager *menus = NULL;
-#endif
-#if defined SMEXT_ENABLE_ADMINSYS
-IAdminSystem *adminsys = NULL;
-#endif
-#if defined SMEXT_ENABLE_TEXTPARSERS
-ITextParsers *textparsers = NULL;
-#endif
-#if defined SMEXT_ENABLE_USERMSGS
-IUserMessages *usermsgs = NULL;
-#endif
-#if defined SMEXT_ENABLE_TRANSLATOR
-ITranslator *translator = NULL;
-#endif
-#if defined SMEXT_ENABLE_NINVOKE
-INativeInterface *ninvoke = NULL;
-#endif
-
-/** Exports the main interface */
-PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
-{
- return g_pExtensionIface;
-}
-
-SDKExtension::SDKExtension()
-{
-#if defined SMEXT_CONF_METAMOD
- m_SourceMMLoaded = false;
- m_WeAreUnloaded = false;
- m_WeGotPauseChange = false;
-#endif
-}
-
-bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
-{
- g_pShareSys = sharesys = sys;
- myself = me;
-
-#if defined SMEXT_CONF_METAMOD
- m_WeAreUnloaded = true;
-
- if (!m_SourceMMLoaded)
- {
- if (error)
- {
- snprintf(error, maxlength, "Metamod attach failed");
- }
- return false;
- }
-#endif
- SM_GET_IFACE(SOURCEMOD, g_pSM);
- smutils = g_pSM;
-#if defined SMEXT_ENABLE_HANDLESYS
- SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
- handlesys = g_pHandleSys;
-#endif
-#if defined SMEXT_ENABLE_FORWARDSYS
- SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
- forwards = g_pForwards;
-#endif
-#if defined SMEXT_ENABLE_PLAYERHELPERS
- SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
-#endif
-#if defined SMEXT_ENABLE_DBMANAGER
- SM_GET_IFACE(DBI, dbi);
-#endif
-#if defined SMEXT_ENABLE_GAMECONF
- SM_GET_IFACE(GAMECONFIG, gameconfs);
-#endif
-#if defined SMEXT_ENABLE_MEMUTILS
- SM_GET_IFACE(MEMORYUTILS, memutils);
-#endif
-#if defined SMEXT_ENABLE_GAMEHELPERS
- SM_GET_IFACE(GAMEHELPERS, gamehelpers);
-#endif
-#if defined SMEXT_ENABLE_TIMERSYS
- SM_GET_IFACE(TIMERSYS, timersys);
-#endif
-#if defined SMEXT_ENABLE_ADTFACTORY
- SM_GET_IFACE(ADTFACTORY, adtfactory);
-#endif
-#if defined SMEXT_ENABLE_THREADER
- SM_GET_IFACE(THREADER, threader);
-#endif
-#if defined SMEXT_ENABLE_LIBSYS
- SM_GET_IFACE(LIBRARYSYS, libsys);
-#endif
-#if defined SMEXT_ENABLE_PLUGINSYS
- SM_GET_IFACE(PLUGINSYSTEM, plsys);
-#endif
-#if defined SMEXT_ENABLE_MENUS
- SM_GET_IFACE(MENUMANAGER, menus);
-#endif
-#if defined SMEXT_ENABLE_ADMINSYS
- SM_GET_IFACE(ADMINSYS, adminsys);
-#endif
-#if defined SMEXT_ENABLE_TEXTPARSERS
- SM_GET_IFACE(TEXTPARSERS, textparsers);
-#endif
-#if defined SMEXT_ENABLE_USERMSGS
- SM_GET_IFACE(USERMSGS, usermsgs);
-#endif
-#if defined SMEXT_ENABLE_TRANSLATOR
- SM_GET_IFACE(TRANSLATOR, translator);
-#endif
-
- if (SDK_OnLoad(error, maxlength, late))
- {
-#if defined SMEXT_CONF_METAMOD
- m_WeAreUnloaded = true;
-#endif
- return true;
- }
-
- return false;
-}
-
-bool SDKExtension::IsMetamodExtension()
-{
-#if defined SMEXT_CONF_METAMOD
- return true;
-#else
- return false;
-#endif
-}
-
-void SDKExtension::OnExtensionPauseChange(bool state)
-{
-#if defined SMEXT_CONF_METAMOD
- m_WeGotPauseChange = true;
-#endif
- SDK_OnPauseChange(state);
-}
-
-void SDKExtension::OnExtensionsAllLoaded()
-{
- SDK_OnAllLoaded();
-}
-
-void SDKExtension::OnExtensionUnload()
-{
-#if defined SMEXT_CONF_METAMOD
- m_WeAreUnloaded = true;
-#endif
- SDK_OnUnload();
-}
-
-const char *SDKExtension::GetExtensionAuthor()
-{
- return SMEXT_CONF_AUTHOR;
-}
-
-const char *SDKExtension::GetExtensionDateString()
-{
- return SMEXT_CONF_DATESTRING;
-}
-
-const char *SDKExtension::GetExtensionDescription()
-{
- return SMEXT_CONF_DESCRIPTION;
-}
-
-const char *SDKExtension::GetExtensionVerString()
-{
- return SMEXT_CONF_VERSION;
-}
-
-const char *SDKExtension::GetExtensionName()
-{
- return SMEXT_CONF_NAME;
-}
-
-const char *SDKExtension::GetExtensionTag()
-{
- return SMEXT_CONF_LOGTAG;
-}
-
-const char *SDKExtension::GetExtensionURL()
-{
- return SMEXT_CONF_URL;
-}
-
-bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
-{
- return true;
-}
-
-void SDKExtension::SDK_OnUnload()
-{
-}
-
-void SDKExtension::SDK_OnPauseChange(bool paused)
-{
-}
-
-void SDKExtension::SDK_OnAllLoaded()
-{
-}
-
-#if defined SMEXT_CONF_METAMOD
-
-PluginId g_PLID = 0; /**< Metamod plugin ID */
-ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
-SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
-ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
-
-IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
-IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
-
-/** Exposes the extension to Metamod */
-SMM_API void *PL_EXPOSURE(const char *name, int *code)
-{
-#if defined METAMOD_PLAPI_VERSION
- if (name && !strcmp(name, METAMOD_PLAPI_NAME))
-#else
- if (name && !strcmp(name, PLAPI_NAME))
-#endif
- {
- if (code)
- {
- *code = IFACE_OK;
- }
- return static_cast(g_pExtensionIface);
- }
-
- if (code)
- {
- *code = IFACE_FAILED;
- }
-
- return NULL;
-}
-
-bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
-{
- PLUGIN_SAVEVARS();
-
-#if !defined METAMOD_PLAPI_VERSION
- GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
- GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
-#else
- GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
- GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
-#endif
-
- m_SourceMMLoaded = true;
-
- return SDK_OnMetamodLoad(ismm, error, maxlen, late);
-}
-
-bool SDKExtension::Unload(char *error, size_t maxlen)
-{
- if (!m_WeAreUnloaded)
- {
- if (error)
- {
- snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
- }
- return false;
- }
-
- return SDK_OnMetamodUnload(error, maxlen);
-}
-
-bool SDKExtension::Pause(char *error, size_t maxlen)
-{
- if (!m_WeGotPauseChange)
- {
- if (error)
- {
- snprintf(error, maxlen, "This extension must be paused by SourceMod.");
- }
- return false;
- }
-
- m_WeGotPauseChange = false;
-
- return SDK_OnMetamodPauseChange(true, error, maxlen);
-}
-
-bool SDKExtension::Unpause(char *error, size_t maxlen)
-{
- if (!m_WeGotPauseChange)
- {
- if (error)
- {
- snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
- }
- return false;
- }
-
- m_WeGotPauseChange = false;
-
- return SDK_OnMetamodPauseChange(false, error, maxlen);
-}
-
-const char *SDKExtension::GetAuthor()
-{
- return GetExtensionAuthor();
-}
-
-const char *SDKExtension::GetDate()
-{
- return GetExtensionDateString();
-}
-
-const char *SDKExtension::GetDescription()
-{
- return GetExtensionDescription();
-}
-
-const char *SDKExtension::GetLicense()
-{
- return SMEXT_CONF_LICENSE;
-}
-
-const char *SDKExtension::GetLogTag()
-{
- return GetExtensionTag();
-}
-
-const char *SDKExtension::GetName()
-{
- return GetExtensionName();
-}
-
-const char *SDKExtension::GetURL()
-{
- return GetExtensionURL();
-}
-
-const char *SDKExtension::GetVersion()
-{
- return GetExtensionVerString();
-}
-
-bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
-{
- return true;
-}
-
-bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
-{
- return true;
-}
-
-bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
-{
- return true;
-}
-
-#endif
-
-/* Overload a few things to prevent libstdc++ linking */
-#if defined __linux__ || defined __APPLE__
-extern "C" void __cxa_pure_virtual(void)
-{
-}
-
-void *operator new(size_t size)
-{
- return malloc(size);
-}
-
-void *operator new[](size_t size)
-{
- return malloc(size);
-}
-
-void operator delete(void *ptr)
-{
- free(ptr);
-}
-
-void operator delete[](void * ptr)
-{
- free(ptr);
-}
-
-void operator delete(void *ptr, size_t size)
-{
- free(ptr);
-}
-
-void operator delete[](void * ptr, size_t size)
-{
- free(ptr);
-}
-#endif
-
diff --git a/extension/sdk/smsdk_ext.hpp b/extension/sdk/smsdk_ext.hpp
deleted file mode 100644
index a3de9b3..0000000
--- a/extension/sdk/smsdk_ext.hpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/**
- * vim: set ts=4 :
- * =============================================================================
- * SourceMod Base Extension Code
- * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
- * =============================================================================
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, 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 .
- *
- * 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 .
- *
- * Version: $Id$
- */
-
-#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
-#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
-
-/**
- * @file smsdk_ext.hpp
- * @brief Contains wrappers for making Extensions easier to write.
- */
-
-#include "smsdk_config.hpp"
-#include
-#include
-#include
-#include
-#include
-#if defined SMEXT_ENABLE_FORWARDSYS
-#include
-#endif //SMEXT_ENABLE_FORWARDSYS
-#if defined SMEXT_ENABLE_PLAYERHELPERS
-#include
-#endif //SMEXT_ENABLE_PlAYERHELPERS
-#if defined SMEXT_ENABLE_DBMANAGER
-#include
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_GAMECONF
-#include
-#endif
-#if defined SMEXT_ENABLE_MEMUTILS
-#include
-#endif
-#if defined SMEXT_ENABLE_GAMEHELPERS
-#include
-#endif
-#if defined SMEXT_ENABLE_TIMERSYS
-#include
-#endif
-#if defined SMEXT_ENABLE_ADTFACTORY
-#include
-#endif
-#if defined SMEXT_ENABLE_THREADER
-#include
-#endif
-#if defined SMEXT_ENABLE_LIBSYS
-#include
-#endif
-#if defined SMEXT_ENABLE_PLUGINSYS
-#include
-#endif
-#if defined SMEXT_ENABLE_MENUS
-#include
-#endif
-#if defined SMEXT_ENABLE_ADMINSYS
-#include
-#endif
-#if defined SMEXT_ENABLE_TEXTPARSERS
-#include
-#endif
-#if defined SMEXT_ENABLE_USERMSGS
-#include
-#endif
-#if defined SMEXT_ENABLE_TRANSLATOR
-#include
-#endif
-#if defined SMEXT_ENABLE_NINVOKE
-#include
-#endif
-
-#if defined SMEXT_CONF_METAMOD
-#include
-#include
-#endif
-
-using namespace SourceMod;
-using namespace SourcePawn;
-
-class SDKExtension :
-#if defined SMEXT_CONF_METAMOD
- public ISmmPlugin,
-#endif
- public IExtensionInterface
-{
-public:
- /** Constructor */
- SDKExtension();
-public:
- /**
- * @brief This is called after the initial loading sequence has been processed.
- *
- * @param error Error message buffer.
- * @param maxlength Size of error message buffer.
- * @param late Whether or not the module was loaded after map load.
- * @return True to succeed loading, false to fail.
- */
- virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
-
- /**
- * @brief This is called right before the extension is unloaded.
- */
- virtual void SDK_OnUnload();
-
- /**
- * @brief This is called once all known extensions have been loaded.
- */
- virtual void SDK_OnAllLoaded();
-
- /**
- * @brief Called when the pause state is changed.
- */
- virtual void SDK_OnPauseChange(bool paused);
-
-#if defined SMEXT_CONF_METAMOD
- /**
- * @brief Called when Metamod is attached, before the extension version is called.
- *
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @param late Whether or not Metamod considers this a late load.
- * @return True to succeed, false to fail.
- */
- virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
-
- /**
- * @brief Called when Metamod is detaching, after the extension version is called.
- * NOTE: By default this is blocked unless sent from SourceMod.
- *
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @return True to succeed, false to fail.
- */
- virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
-
- /**
- * @brief Called when Metamod's pause state is changing.
- * NOTE: By default this is blocked unless sent from SourceMod.
- *
- * @param paused Pause state being set.
- * @param error Error buffer.
- * @param maxlength Maximum size of error buffer.
- * @return True to succeed, false to fail.
- */
- virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
-#endif
-
-public: //IExtensionInterface
- virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
- virtual void OnExtensionUnload();
- virtual void OnExtensionsAllLoaded();
-
- /** Returns whether or not this is a Metamod-based extension */
- virtual bool IsMetamodExtension();
-
- /**
- * @brief Called when the pause state changes.
- *
- * @param state True if being paused, false if being unpaused.
- */
- virtual void OnExtensionPauseChange(bool state);
-
- /** Returns name */
- virtual const char *GetExtensionName();
- /** Returns URL */
- virtual const char *GetExtensionURL();
- /** Returns log tag */
- virtual const char *GetExtensionTag();
- /** Returns author */
- virtual const char *GetExtensionAuthor();
- /** Returns version string */
- virtual const char *GetExtensionVerString();
- /** Returns description string */
- virtual const char *GetExtensionDescription();
- /** Returns date string */
- virtual const char *GetExtensionDateString();
-#if defined SMEXT_CONF_METAMOD
-public: //ISmmPlugin
- /** Called when the extension is attached to Metamod. */
- virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
- /** Returns the author to MM */
- virtual const char *GetAuthor();
- /** Returns the name to MM */
- virtual const char *GetName();
- /** Returns the description to MM */
- virtual const char *GetDescription();
- /** Returns the URL to MM */
- virtual const char *GetURL();
- /** Returns the license to MM */
- virtual const char *GetLicense();
- /** Returns the version string to MM */
- virtual const char *GetVersion();
- /** Returns the date string to MM */
- virtual const char *GetDate();
- /** Returns the logtag to MM */
- virtual const char *GetLogTag();
- /** Called on unload */
- virtual bool Unload(char *error, size_t maxlength);
- /** Called on pause */
- virtual bool Pause(char *error, size_t maxlength);
- /** Called on unpause */
- virtual bool Unpause(char *error, size_t maxlength);
-private:
- bool m_SourceMMLoaded;
- bool m_WeAreUnloaded;
- bool m_WeGotPauseChange;
-#endif
-};
-
-extern SDKExtension *g_pExtensionIface;
-extern IExtension *myself;
-
-extern IShareSys *g_pShareSys;
-extern IShareSys *sharesys; /* Note: Newer name */
-extern ISourceMod *g_pSM;
-extern ISourceMod *smutils; /* Note: Newer name */
-
-/* Optional interfaces are below */
-#if defined SMEXT_ENABLE_FORWARDSYS
-extern IForwardManager *g_pForwards;
-extern IForwardManager *forwards; /* Note: Newer name */
-#endif //SMEXT_ENABLE_FORWARDSYS
-#if defined SMEXT_ENABLE_HANDLESYS
-extern IHandleSys *g_pHandleSys;
-extern IHandleSys *handlesys; /* Note: Newer name */
-#endif //SMEXT_ENABLE_HANDLESYS
-#if defined SMEXT_ENABLE_PLAYERHELPERS
-extern IPlayerManager *playerhelpers;
-#endif //SMEXT_ENABLE_PLAYERHELPERS
-#if defined SMEXT_ENABLE_DBMANAGER
-extern IDBManager *dbi;
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_GAMECONF
-extern IGameConfigManager *gameconfs;
-#endif //SMEXT_ENABLE_DBMANAGER
-#if defined SMEXT_ENABLE_MEMUTILS
-extern IMemoryUtils *memutils;
-#endif
-#if defined SMEXT_ENABLE_GAMEHELPERS
-extern IGameHelpers *gamehelpers;
-#endif
-#if defined SMEXT_ENABLE_TIMERSYS
-extern ITimerSystem *timersys;
-#endif
-#if defined SMEXT_ENABLE_ADTFACTORY
-extern IADTFactory *adtfactory;
-#endif
-#if defined SMEXT_ENABLE_THREADER
-extern IThreader *threader;
-#endif
-#if defined SMEXT_ENABLE_LIBSYS
-extern ILibrarySys *libsys;
-#endif
-#if defined SMEXT_ENABLE_PLUGINSYS
-extern SourceMod::IPluginManager *plsys;
-#endif
-#if defined SMEXT_ENABLE_MENUS
-extern IMenuManager *menus;
-#endif
-#if defined SMEXT_ENABLE_ADMINSYS
-extern IAdminSystem *adminsys;
-#endif
-#if defined SMEXT_ENABLE_USERMSGS
-extern IUserMessages *usermsgs;
-#endif
-#if defined SMEXT_ENABLE_TRANSLATOR
-extern ITranslator *translator;
-#endif
-#if defined SMEXT_ENABLE_NINVOKE
-extern INativeInterface *ninvoke;
-#endif
-
-#if defined SMEXT_CONF_METAMOD
-PLUGIN_GLOBALVARS();
-extern IVEngineServer *engine;
-extern IServerGameDLL *gamedll;
-#endif
-
-/** Creates a SourceMod interface macro pair */
-#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
-/** Automates retrieving SourceMod interfaces */
-#define SM_GET_IFACE(prefix, addr) \
- if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
- { \
- if (error != NULL && maxlength) \
- { \
- size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
- if (len >= maxlength) \
- { \
- error[maxlength - 1] = '\0'; \
- } \
- } \
- return false; \
- }
-/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
-#define SM_GET_LATE_IFACE(prefix, addr) \
- g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
-/** Validates a SourceMod interface pointer */
-#define SM_CHECK_IFACE(prefix, addr) \
- if (!addr) \
- { \
- if (error != NULL && maxlength) \
- { \
- size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
- if (len >= maxlength) \
- { \
- error[maxlength - 1] = '\0'; \
- } \
- } \
- return false; \
- }
-
-#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
diff --git a/extension/sdk/smsdk_config.hpp b/extension/smsdk_config.h
similarity index 97%
rename from extension/sdk/smsdk_config.hpp
rename to extension/smsdk_config.h
index db37f02..6951814 100644
--- a/extension/sdk/smsdk_config.hpp
+++ b/extension/smsdk_config.h
@@ -1,80 +1,80 @@
-/**
- * =============================================================================
- * connect Extension
- * Copyright (C) 2011 Asher Baker (asherkin). All rights reserved.
- * =============================================================================
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, 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 .
- *
- * 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 .
- */
-
-#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
-#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
-
-/**
- * @file smsdk_config.hpp
- * @brief Contains macros for configuring basic extension information.
- */
-
- #include "version.h" // SM_FULL_VERSION
-
-/* Basic information exposed publicly */
-#define SMEXT_CONF_NAME "Connect"
-#define SMEXT_CONF_DESCRIPTION "Forward for early connection"
-#define SMEXT_CONF_VERSION SM_FULL_VERSION
-#define SMEXT_CONF_AUTHOR "Asher \"asherkin\" Baker"
-#define SMEXT_CONF_URL "http://limetech.org/"
-#define SMEXT_CONF_LOGTAG "CONNECT"
-#define SMEXT_CONF_LICENSE "GPL"
-#define SMEXT_CONF_DATESTRING __DATE__
-
-/**
- * @brief Exposes plugin's main interface.
- */
-#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
-
-/**
- * @brief Sets whether or not this plugin required Metamod.
- * NOTE: Uncomment to enable, comment to disable.
- */
-#define SMEXT_CONF_METAMOD
-
-/** Enable interfaces you want to use here by uncommenting lines */
-#define SMEXT_ENABLE_FORWARDSYS
-//#define SMEXT_ENABLE_HANDLESYS
-//#define SMEXT_ENABLE_PLAYERHELPERS
-//#define SMEXT_ENABLE_DBMANAGER
-#define SMEXT_ENABLE_GAMECONF
-//#define SMEXT_ENABLE_MEMUTILS
-//#define SMEXT_ENABLE_GAMEHELPERS
-//#define SMEXT_ENABLE_TIMERSYS
-//#define SMEXT_ENABLE_THREADER
-//#define SMEXT_ENABLE_LIBSYS
-//#define SMEXT_ENABLE_MENUS
-//#define SMEXT_ENABLE_ADTFACTORY
-//#define SMEXT_ENABLE_PLUGINSYS
-//#define SMEXT_ENABLE_ADMINSYS
-//#define SMEXT_ENABLE_TEXTPARSERS
-//#define SMEXT_ENABLE_USERMSGS
-//#define SMEXT_ENABLE_TRANSLATOR
-//#define SMEXT_ENABLE_NINVOKE
-
-#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
+/**
+ * =============================================================================
+ * connect Extension
+ * Copyright (C) 2011 Asher Baker (asherkin). All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, 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 .
+ *
+ * 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 .
+ */
+
+#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
+#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
+
+/**
+ * @file smsdk_config.hpp
+ * @brief Contains macros for configuring basic extension information.
+ */
+
+ #include "version.h" // SM_FULL_VERSION
+
+/* Basic information exposed publicly */
+#define SMEXT_CONF_NAME "Connect"
+#define SMEXT_CONF_DESCRIPTION "Forward for early connection"
+#define SMEXT_CONF_VERSION SM_FULL_VERSION
+#define SMEXT_CONF_AUTHOR "Asher \"asherkin\" Baker"
+#define SMEXT_CONF_URL "http://limetech.org/"
+#define SMEXT_CONF_LOGTAG "CONNECT"
+#define SMEXT_CONF_LICENSE "GPL"
+#define SMEXT_CONF_DATESTRING __DATE__
+
+/**
+ * @brief Exposes plugin's main interface.
+ */
+#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
+
+/**
+ * @brief Sets whether or not this plugin required Metamod.
+ * NOTE: Uncomment to enable, comment to disable.
+ */
+#define SMEXT_CONF_METAMOD
+
+/** Enable interfaces you want to use here by uncommenting lines */
+#define SMEXT_ENABLE_FORWARDSYS
+//#define SMEXT_ENABLE_HANDLESYS
+//#define SMEXT_ENABLE_PLAYERHELPERS
+//#define SMEXT_ENABLE_DBMANAGER
+#define SMEXT_ENABLE_GAMECONF
+//#define SMEXT_ENABLE_MEMUTILS
+//#define SMEXT_ENABLE_GAMEHELPERS
+//#define SMEXT_ENABLE_TIMERSYS
+//#define SMEXT_ENABLE_THREADER
+//#define SMEXT_ENABLE_LIBSYS
+//#define SMEXT_ENABLE_MENUS
+//#define SMEXT_ENABLE_ADTFACTORY
+//#define SMEXT_ENABLE_PLUGINSYS
+//#define SMEXT_ENABLE_ADMINSYS
+//#define SMEXT_ENABLE_TEXTPARSERS
+//#define SMEXT_ENABLE_USERMSGS
+//#define SMEXT_ENABLE_TRANSLATOR
+//#define SMEXT_ENABLE_NINVOKE
+
+#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_