diff --git a/AMBuildScript b/AMBuildScript index 2d085f1..f0c3981 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -1,413 +1,253 @@ -# vim: set ts=2 sw=2 tw=99 noet ft=python: +# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: import os -import sys -import ambuild.command as command -from ambuild.command import SymlinkCommand -vboxhack = 0 +def ResolveEnvPath(env, folder): + if env in os.environ: + path = os.environ[env] + if os.path.isdir(path): + return path + return None -class SM: - def __init__(self): - self.compiler = Cpp.Compiler() + head = os.getcwd() + oldhead = None + while head != None and head != oldhead: + path = os.path.join(head, folder) + if os.path.isdir(path): + return path + oldhead = head + head, tail = os.path.split(head) - #Build SDK info - self.sdkInfo = { } - #self.sdkInfo['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1', - # 'name': 'EPISODEONE', 'platform': ['windows', 'linux']} - - self.sdkInfo['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3', - 'name': 'ORANGEBOX', 'platform': ['windows', 'linux']} - - self.sdkInfo['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6', - 'name': 'CSS', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['hl2dm'] = {'sdk': 'HL2SDKHL2DM', 'ext': '2.hl2dm', 'def': '7', - 'name': 'HL2DM', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['dods'] = {'sdk': 'HL2SDKDODS', 'ext': '2.dods', 'def': '8', - 'name': 'DODS', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['tf2'] = {'sdk': 'HL2SDKTF2', 'ext': '2.tf2', 'def': '9', - 'name': 'TF2', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '10', - 'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['nd'] = {'sdk': 'HL2SDKND', 'ext': '2.nd', 'def': '11', - 'name': 'NUCLEARDAWN', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '12', - 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin']} - - self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '13', - 'name': 'ALIENSWARM', 'platform': ['windows']} - - self.sdkInfo['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '15', - 'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin']} + return None - if AMBuild.mode == 'config': - #Detect compilers - self.compiler.DetectAll(AMBuild) +def Normalize(path): + return os.path.abspath(os.path.normpath(path)) + +class DHooksConfig(object): + def __init__(self): + self.mms_root = None + self.sm_root = None + self.task = None + + @property + def tag(self): + if builder.options.debug == '1': + return 'Debug' + return 'Release' - #Detect variables - envvars = { 'MMSOURCE19': 'mmsource-1.9', - 'HL2SDKHL2DM': 'hl2sdk-hl2dm', - 'HL2SDKDODS': 'hl2sdk-dods', - 'HL2SDKTF2': 'hl2sdk-tf2', - 'HL2SDKND': 'hl2sdk-nd', - 'HL2SDKL4D': 'hl2sdk-l4d', - 'HL2SDKL4D2': 'hl2sdk-l4d2', - 'HL2SDKCSGO': 'hl2sdk-csgo', - 'HL2SDKCSS': 'hl2sdk-css', - 'SMCENTRAL': 'sourcemod-central' - } + def detectProductVersion(self): + builder.AddConfigureFile('product.version') - if AMBuild.target['platform'] != 'darwin': - #envvars['HL2SDK'] = 'hl2sdk' - envvars['HL2SDKOB'] = 'hl2sdk-ob' + # For OS X dylib versioning + import re + with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp: + productContents = fp.read() + m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents) + if m == None: + self.productVersion = '1.0.0' + else: + major, minor, release = m.groups() + self.productVersion = '{0}.{1}.{2}'.format(major, minor, release) - #Dark Messiah is Windows-only - if AMBuild.target['platform'] == 'windows': - envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm' + def detectSDKs(self): + if builder.options.mms_path: + self.mms_root = builder.options.mms_path + else: + self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10') + if not self.mms_root: + self.mms_root = ResolveEnvPath('MMSOURCE10', 'metamod-1.10') + if not self.mms_root: + self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source') + if not self.mms_root: + self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central') - #Must have a path for each envvar (file a bug if you don't like this) - for i in envvars: - if i in os.environ: - path = os.environ[i] - if not os.path.isdir(path): - raise Exception('Path for {0} was not found: {1}'.format(i, path)) - else: - head = os.getcwd() - oldhead = None - while head != None and head != oldhead: - path = os.path.join(head, envvars[i]) - if os.path.isdir(path): - break - oldhead = head - head, tail = os.path.split(head) - if head == None or head == oldhead: - raise Exception('Could not find a valid path for {0}'.format(i)) - AMBuild.cache.CacheVariable(i, path) + if not self.mms_root or not os.path.isdir(self.mms_root): + raise Exception('Could not find a source copy of Metamod:Source') + self.mms_root = Normalize(self.mms_root) + + if builder.options.sm_path: + self.sm_root = builder.options.sm_path + else: + #self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod-1.6') + if not self.sm_root: + self.sm_root = ResolveEnvPath('SMCENTRAL', 'sourcemod-central') - #Set up defines - cxx = self.compiler.cxx - if isinstance(cxx, Cpp.CompatGCC): - if isinstance(cxx, Cpp.GCC): - self.vendor = 'gcc' - elif isinstance(cxx, Cpp.Clang): - self.vendor = 'clang' - self.compiler.AddToListVar('CDEFINES', 'COMPILER_GCC') - self.compiler.AddToListVar('CDEFINES', 'POSIX') - self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp') - self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp') - self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf') - self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf') - self.compiler.AddToListVar('CFLAGS', '-pipe') - self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing') - if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang': - self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden') - self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden') - self.compiler.AddToListVar('CFLAGS', '-Wall') - #self.compiler.AddToListVar('CFLAGS', '-Werror') - self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized') - self.compiler.AddToListVar('CFLAGS', '-Wno-unused') - self.compiler.AddToListVar('CFLAGS', '-Wno-switch') - self.compiler.AddToListVar('CFLAGS', '-Wno-invalid-offsetof') - self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse') - self.compiler.AddToListVar('CFLAGS', '-msse') - self.compiler.AddToListVar('CFLAGS', '-m32') - self.compiler.AddToListVar('POSTLINKFLAGS', '-m32') - self.compiler.AddToListVar('CFLAGS', '-static-libgcc') - self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions') - self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti') - self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics') - self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor') - self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual') - self.compiler.AddToListVar('CXXFLAGS', '-Wno-conversion') - if (self.vendor == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \ - (self.vendor == 'clang' and cxx.majorVersion >= 3): - self.compiler.AddToListVar('CXXFLAGS', '-Wno-delete-non-virtual-dtor') - self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H') - self.compiler.AddToListVar('CDEFINES', 'GNUC') - if self.vendor == 'gcc': - self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse') - elif isinstance(cxx, Cpp.MSVC): - self.vendor = 'msvc' - if AMBuild.options.debug == '1': - self.compiler.AddToListVar('CFLAGS', '/MTd') - self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt') - else: - self.compiler.AddToListVar('CFLAGS', '/MT') - self.compiler.AddToListVar('CDEFINES', 'COMPILER_MSVC') - self.compiler.AddToListVar('CDEFINES', 'COMPILER_MSVC32') - self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE') - self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_WARNINGS') - self.compiler.AddToListVar('CDEFINES', '_CRT_NONSTDC_NO_DEPRECATE') - self.compiler.AddToListVar('CXXFLAGS', '/EHsc') - self.compiler.AddToListVar('CXXFLAGS', '/GR-') - self.compiler.AddToListVar('CFLAGS', '/W3') - self.compiler.AddToListVar('CFLAGS', '/nologo') - self.compiler.AddToListVar('CFLAGS', '/Zi') - self.compiler.AddToListVar('CXXFLAGS', '/TP') - self.compiler.AddToListVar('POSTLINKFLAGS', '/DEBUG') - self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X86') - self.compiler.AddToListVar('POSTLINKFLAGS', '/SUBSYSTEM:WINDOWS') - self.compiler.AddToListVar('POSTLINKFLAGS', 'kernel32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'user32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'gdi32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'winspool.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'comdlg32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'advapi32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'shell32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'ole32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'oleaut32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'uuid.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'odbc32.lib') - self.compiler.AddToListVar('POSTLINKFLAGS', 'odbccp32.lib') + if not self.sm_root or not os.path.isdir(self.sm_root): + raise Exception('Could not find a source copy of Sourcemod') + self.sm_root = Normalize(self.sm_root) - #Optimization - if AMBuild.options.opt == '1': - self.compiler.AddToListVar('CDEFINES', 'NDEBUG') - if self.vendor == 'gcc' or self.vendor == 'clang': - self.compiler.AddToListVar('CFLAGS', '-O3') - elif self.vendor == 'msvc': - self.compiler.AddToListVar('CFLAGS', '/Ox') - self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF') - self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF') + def configure(self): + builder.AddConfigureFile('push.txt') - #Debugging - if AMBuild.options.debug == '1': - self.compiler.AddToListVar('CDEFINES', 'DEBUG') - self.compiler.AddToListVar('CDEFINES', '_DEBUG') - if self.vendor == 'gcc' or self.vendor == 'clang': - self.compiler.AddToListVar('CFLAGS', '-g3') - elif self.vendor == 'msvc': - self.compiler.AddToListVar('CFLAGS', '/Od') - self.compiler.AddToListVar('CFLAGS', '/RTC1') + cxx = builder.DetectCompilers() - #Platform-specifics - if AMBuild.target['platform'] == 'linux': - self.compiler.AddToListVar('CDEFINES', '_LINUX') - if self.vendor == 'gcc': - self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc') - if self.vendor == 'clang': - self.compiler.AddToListVar('POSTLINKFLAGS', '-lgcc_eh') - elif AMBuild.target['platform'] == 'darwin': - self.compiler.AddToListVar('POSTLINKFLAGS', '-mmacosx-version-min=10.5') - self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'i386']) - self.compiler.AddToListVar('POSTLINKFLAGS', '-lstdc++') + if cxx.like('gcc'): + cxx.defines += [ + 'stricmp=strcasecmp', + '_stricmp=strcasecmp', + '_snprintf=snprintf', + '_vsnprintf=vsnprintf', + 'HAVE_STDINT_H', + 'GNUC', + ] + cxx.cflags += [ + '-pipe', + '-fno-strict-aliasing', + '-Wall', + '-Werror', + '-Wno-unused', + '-Wno-switch', + '-Wno-format', + '-Wno-format-security', + '-Wno-array-bounds', + '-Wno-sign-compare', + '-msse', + '-m32', + ] + cxx.cxxflags += [ + '-std=c++11', + ] - # For OS X dylib versioning - import re - productFile = open(os.path.join(AMBuild.sourceFolder, 'buildbot', 'product.version'), 'r') - productContents = productFile.read() - productFile.close() - m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents) - if m == None: - self.version = '1.0.0' - else: - major, minor, release = m.groups() - self.version = '{0}.{1}.{2}'.format(major, minor, release) - AMBuild.cache.CacheVariable('version', self.version) - elif AMBuild.target['platform'] == 'windows': - self.compiler.AddToListVar('CDEFINES', 'WIN32') - self.compiler.AddToListVar('CDEFINES', '_WINDOWS') + have_gcc = cxx.vendor == 'gcc' + have_clang = cxx.vendor == 'clang' + if have_clang or (have_gcc and cxx.version >= '4'): + cxx.cflags += ['-fvisibility=hidden'] + cxx.cxxflags += ['-fvisibility-inlines-hidden'] + if have_clang or (have_gcc and cxx.version >= '4.6'): + cxx.cflags += ['-Wno-narrowing'] + if (have_gcc and cxx.version >= '4.7') or (have_clang and cxx.version >= '3'): + cxx.cxxflags += ['-Wno-delete-non-virtual-dtor'] + if have_gcc and cxx.version >= '4.8': + cxx.cflags += ['-Wno-unused-result'] + if have_clang: + cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch'] + if (builder.target_platform == 'mac' and cxx.version >= '5.1') or cxx.version >= '3.4': + cxx.cxxflags += ['-Wno-deprecated-register'] + else: + cxx.cxxflags += ['-Wno-deprecated'] + cxx.cflags += ['-Wno-sometimes-uninitialized'] - #Finish up - self.compiler.AddToListVar('CDEFINES', 'SOURCEMOD_BUILD') - self.compiler.AddToListVar('CDEFINES', 'SM_GENERATED_BUILD') - self.compiler.AddToListVar('CINCLUDES', - os.path.join(AMBuild.outputFolder, 'includes')) - self.compiler.ToConfig(AMBuild, 'compiler') - AMBuild.cache.CacheVariable('vendor', self.vendor) - self.targetMap = { } - AMBuild.cache.CacheVariable('targetMap', self.targetMap) - else: - self.compiler.FromConfig(AMBuild, 'compiler') - self.targetMap = AMBuild.cache['targetMap'] + cxx.linkflags += ['-m32'] + cxx.cxxflags += [ + '-fno-exceptions', + '-fno-threadsafe-statics', + '-Wno-non-virtual-dtor', + '-Wno-overloaded-virtual', + ] - if AMBuild.target['platform'] == 'windows': - self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'extension')) - - self.mmsPath = AMBuild.cache['MMSOURCE19'] + if have_gcc: + cxx.cflags += ['-mfpmath=sse'] + elif cxx.vendor == 'msvc': + if builder.options.debug == '1': + cxx.cflags += ['/MTd'] + cxx.linkflags += ['/NODEFAULTLIB:libcmt'] + else: + cxx.cflags += ['/MT'] + cxx.defines += [ + '_CRT_SECURE_NO_DEPRECATE', + '_CRT_SECURE_NO_WARNINGS', + '_CRT_NONSTDC_NO_DEPRECATE', + '_ITERATOR_DEBUG_LEVEL=0', + ] + cxx.cflags += [ + '/W3', + ] + cxx.cxxflags += [ + '/EHsc', + '/GR-', + '/TP', + ] + cxx.linkflags += [ + '/MACHINE:X86', + '/SUBSYSTEM:WINDOWS', + 'kernel32.lib', + 'user32.lib', + 'gdi32.lib', + 'winspool.lib', + 'comdlg32.lib', + 'advapi32.lib', + 'shell32.lib', + 'ole32.lib', + 'oleaut32.lib', + 'uuid.lib', + 'odbc32.lib', + 'odbccp32.lib', + ] - def DefaultCompiler(self): - return self.compiler.Clone() + # Optimization + if builder.options.opt == '1': + cxx.defines += ['NDEBUG'] + if cxx.like('gcc'): + cxx.cflags += ['-O3'] + elif cxx.like('msvc'): + cxx.cflags += ['/Ox'] + cxx.linkflags += ['/OPT:ICF', '/OPT:REF'] - def JobMatters(self, jobname): - file = sys._getframe().f_code.co_filename - if AMBuild.mode == 'config': - self.targetMap[jobname] = file - return True - if len(AMBuild.args) == 0: - return True - if not jobname in AMBuild.args: - return False + # Debugging + if builder.options.debug == '1': + cxx.defines += ['DEBUG', '_DEBUG'] + if cxx.like('msvc'): + cxx.cflags += ['/Od', '/RTC1'] + if cxx.version >= 1600: + cxx.cflags += ['/d2Zi+'] - def DefaultExtCompiler(self, path): - compiler = self.DefaultCompiler() - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path)) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path, 'sdk')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'extensions')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourcepawn')) - return compiler + # This needs to be after our optimization flags which could otherwise disable it. + if cxx.vendor == 'msvc': + # Don't omit the frame pointer. + cxx.cflags += ['/Oy-'] - def AutoVersion(self, folder, binary): - if AMBuild.target['platform'] == 'windows': - env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'SM_GENERATED_BUILD']} - binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env) - elif AMBuild.target['platform'] == 'darwin' and isinstance(binary, Cpp.LibraryBuilder): - binary.compiler['POSTLINKFLAGS'].extend(['-compatibility_version', '1.0.0']) - binary.compiler['POSTLINKFLAGS'].extend(['-current_version', AMBuild.cache['version']]) - else: - return + # Platform-specifics + if builder.target_platform == 'linux': + cxx.defines += ['_LINUX', 'POSIX'] + if cxx.vendor == 'gcc': + cxx.linkflags += ['-static-libgcc'] + elif cxx.vendor == 'clang': + cxx.linkflags += ['-lgcc_eh'] + elif builder.target_platform == 'mac': + cxx.defines += ['OSX', '_OSX', 'POSIX'] + cxx.cflags += ['-mmacosx-version-min=10.5'] + cxx.linkflags += [ + '-mmacosx-version-min=10.5', + '-arch', 'i386', + '-lstdc++', + '-stdlib=libstdc++', + ] + cxx.cxxflags += ['-stdlib=libstdc++'] + elif builder.target_platform == 'windows': + cxx.defines += ['WIN32', '_WINDOWS'] + + cxx.defines += ['META_NO_HL2SDK'] + + def IncludeSDKs(self, builder): + builder.compiler.cxxincludes += [ + os.path.join(builder.currentSourcePath), + os.path.join(builder.currentSourcePath, 'sdk'), + os.path.join(self.mms_root, 'core'), + os.path.join(self.mms_root, 'core', 'sourcehook'), + os.path.join(self.sm_root, 'public'), + os.path.join(self.sm_root, 'public', 'extensions'), + os.path.join(self.sm_root, 'public', 'sourcepawn'), + os.path.join(self.sm_root, 'public', 'amtl'), + os.path.join(self.sm_root, 'public', 'jit'), + os.path.join(self.sm_root, 'public', 'jit', 'x86'), + ] + - def PreSetupHL2Job(self, job, builder, sdk): - info = self.sdkInfo[sdk] - sdkPath = AMBuild.cache[info['sdk']] - if AMBuild.target['platform'] == 'linux': - if sdk == 'ep1': - staticLibs = os.path.join(sdkPath, 'linux_sdk') - else: - staticLibs = os.path.join(sdkPath, 'lib', 'linux') - workFolder = os.path.join(AMBuild.outputFolder, job.workFolder) - if sdk in ['tf2', 'css', 'l4d2', 'hl2dm', 'dods', 'nd']: - libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib_srv.so', 'libtier0_srv.so'] - for i in libs: - link = os.path.join(workFolder, i) - target = os.path.join(staticLibs, i) - try: - os.lstat(link) - except: - if vboxhack == 1: - job.AddCommand(command.DirectCommand(['cp', '-f', target, link])) - else: - job.AddCommand(SymlinkCommand(link, target)) - elif sdk in ['l4d', 'csgo']: - libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.so', 'libtier0.so'] - if sdk == 'csgo': - libs.append('interfaces_i486.a') - for i in libs: - link = os.path.join(workFolder, i) - target = os.path.join(staticLibs, i) - try: - os.lstat(link) - except: - if vboxhack == 1: - job.AddCommand(command.DirectCommand(['cp', '-f', target, link])) - else: - job.AddCommand(SymlinkCommand(link, target)) - else: - for i in ['tier1_i486.a', 'mathlib_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']: - link = os.path.join(workFolder, i) - target = os.path.join(staticLibs, i) - try: - os.lstat(link) - except: - if vboxhack == 1: - job.AddCommand(command.DirectCommand(['cp', '-f', target, link])) - else: - job.AddCommand(SymlinkCommand(link, target)) - elif AMBuild.target['platform'] == 'darwin': - staticLibs = os.path.join(sdkPath, 'lib', 'mac') - workFolder = os.path.join(AMBuild.outputFolder, job.workFolder) - for i in ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.dylib', 'libtier0.dylib']: - link = os.path.join(workFolder, i) - target = os.path.join(staticLibs, i) - try: - os.lstat(link) - except: - if vboxhack == 1: - job.AddCommand(command.DirectCommand(['cp', '-f', target, link])) - else: - job.AddCommand(SymlinkCommand(link, target)) - elif AMBuild.target['platform'] == 'windows': - libs = ['tier0', 'tier1', 'vstdlib', 'mathlib'] - if sdk in ['swarm', 'csgo']: - libs.append('interfaces') - for lib in libs: - libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib' - builder.RebuildIfNewer(libPath) - builder['POSTLINKFLAGS'].append(libPath) +DHooks = DHooksConfig() +DHooks.detectSDKs() +DHooks.configure() +DHooks.IncludeSDKs(builder) - def PostSetupHL2Job(self, job, builder, sdk): - if AMBuild.target['platform'] in ['linux', 'darwin']: - builder.AddObjectFiles(['tier1_i486.a', 'mathlib_i486.a']) - if sdk == 'csgo': - builder.AddObjectFiles(['interfaces_i486.a']) +program = builder.compiler.Library('dhooks.ext') - def DefaultHL2Compiler(self, path, sdk, noLink = False, oldMms = '-legacy'): - compiler = self.DefaultExtCompiler(path) +program.sources += [ + 'extension.cpp', + 'listeners.cpp', + 'natives.cpp', + 'vhook.cpp', + 'sdk/smsdk_ext.cpp', +] +program.sources += [os.path.join(DHooks.sm_root, 'public', 'jit', 'x86', "assembler-x86.cpp"),] - mms = 'core' - if sdk == 'ep1': - mms += oldMms - - compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms)) - compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms, 'sourcehook')) - - info = self.sdkInfo - compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info]) - compiler['CDEFINES'].append("SE_PORTAL2=10") - - paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'], - ['public', 'tier0'], ['public', 'tier1']] - if sdk == 'ep1' or sdk == 'darkm': - paths.append(['public', 'dlls']) - paths.append(['game_shared']) - else: - paths.append(['public', 'game', 'server']) - paths.append(['game', 'shared']) - paths.append(['common']) - - info = self.sdkInfo[sdk] - sdkPath = AMBuild.cache[info['sdk']] - - compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def']) - - if sdk == 'ep1': - if AMBuild.target['platform'] == 'linux': - staticLibs = os.path.join(sdkPath, 'linux_sdk') - else: - if AMBuild.target['platform'] == 'linux': - staticLibs = os.path.join(sdkPath, 'lib', 'linux') - elif AMBuild.target['platform'] == 'darwin': - staticLibs = os.path.join(sdkPath, 'lib', 'mac') - - for i in paths: - compiler['CXXINCLUDES'].append(os.path.join(sdkPath, *i)) - - if not noLink: - if AMBuild.target['platform'] == 'linux': - compiler['POSTLINKFLAGS'][0:0] = ['-lm'] - if sdk in ['tf2', 'css', 'l4d2', 'hl2dm', 'dods', 'nd']: - compiler['POSTLINKFLAGS'][0:0] = ['libtier0_srv.so'] - compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib_srv.so'] - elif sdk in ['l4d', 'csgo']: - compiler['POSTLINKFLAGS'][0:0] = ['libtier0.so'] - compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.so'] - else: - compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so'] - compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so'] - elif AMBuild.target['platform'] == 'darwin': - compiler['POSTLINKFLAGS'][0:0] = ['libtier0.dylib'] - compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.dylib'] - - return compiler - -sm = SM() -globals = { - 'SM': sm -} - -AMBuild.Include(os.path.join('buildbot', 'Versioning'), globals) - -FileList = [ - ['AMBuilder'], - ['buildbot', 'PackageScript'] - ] - -for parts in FileList: - AMBuild.Include(os.path.join(*parts), globals) +DHooks.task = builder.Add(program) +builder.RunScript('buildbot/PackageScript', { 'DHooks': DHooks }) \ No newline at end of file diff --git a/AMBuilder b/AMBuilder deleted file mode 100644 index fbe8a13..0000000 --- a/AMBuilder +++ /dev/null @@ -1,38 +0,0 @@ -# vim: set ts=2 sw=2 tw=99 noet ft=python: -import os - -for i in SM.sdkInfo: - sdk = SM.sdkInfo[i] - if AMBuild.target['platform'] not in sdk['platform']: - continue - - compiler = SM.DefaultHL2Compiler('.', i) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'sourcepawn')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'extensions')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'jit')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'jit', 'x86')) - compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'amtl')) - - if compiler.cc.name == 'gcc': - compiler['CFLAGS'].append('-Wno-parentheses') - - #if i != 'ep1': - # compiler['CDEFINES'].append('HOOKING_ENABLED') - - name = 'dhooks.ext.' + sdk['ext'] - extension = AMBuild.AddJob(name) - binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) - SM.PreSetupHL2Job(extension, binary, i) - binary.AddSourceFiles('.', [ - 'extension.cpp', - 'listeners.cpp', - 'vhook.cpp', - 'natives.cpp', - 'sdk/smsdk_ext.cpp', - os.path.join(AMBuild.cache['SMCENTRAL'], 'public', 'jit', 'x86', 'assembler-x86.cpp') - ]) - SM.PostSetupHL2Job(extension, binary, i) - #SM.AutoVersion('.', binary) - binary.SendToJob() - diff --git a/Makefile b/Makefile deleted file mode 100644 index 6991416..0000000 --- a/Makefile +++ /dev/null @@ -1,235 +0,0 @@ -# (C)2004-2010 SourceMod Development Team -# Makefile written by David "BAILOPAN" Anderson - -########################################### -### EDIT THESE PATHS FOR YOUR OWN SETUP ### -########################################### - -SMSDK = ../sourcemod-central -HL2SDK_ORIG = ../../../hl2sdk -HL2SDK_OB = ../../../hl2sdk-ob -HL2SDK_CSS = ../hl2sdk-css -HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve -HL2SDK_L4D = ../../../hl2sdk-l4d -HL2SDK_L4D2 = ../../../hl2sdk-l4d2 -HL2SDK_CSGO = ../../../hl2sdk-csgo -MMSOURCE19 = ../mmsource-1.9 - -##################################### -### EDIT BELOW FOR OTHER PROJECTS ### -##################################### - -PROJECT = dhooks - -#Uncomment for Metamod: Source enabled extension -USEMETA = true - -OBJECTS = sdk/smsdk_ext.cpp extension.cpp vhook.cpp $(SMSDK)/public/jit/x86/assembler-x86.cpp listeners.cpp natives.cpp - -############################################## -### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### -############################################## - -C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing -C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 -C_GCC4_FLAGS = -fvisibility=hidden -CPP_GCC4_FLAGS = -fvisibility-inlines-hidden -CPP = gcc -CPP_OSX = clang - -########################## -### SDK CONFIGURATIONS ### -########################## - -override ENGSET = false - -# Check for valid list of engines -ifneq (,$(filter original orangebox orangeboxvalve css left4dead left4dead2 csgo,$(ENGINE))) - override ENGSET = true -endif - -ifeq "$(ENGINE)" "original" - HL2SDK = $(HL2SDK_ORIG) - CFLAGS += -DSOURCE_ENGINE=1 -endif -ifeq "$(ENGINE)" "orangebox" - HL2SDK = $(HL2SDK_OB) - CFLAGS += -DSOURCE_ENGINE=3 -endif -ifeq "$(ENGINE)" "css" - HL2SDK = $(HL2SDK_CSS) - CFLAGS += -DSOURCE_ENGINE=6 -endif -ifeq "$(ENGINE)" "orangeboxvalve" - HL2SDK = $(HL2SDK_OB_VALVE) - CFLAGS += -DSOURCE_ENGINE=7 -endif -ifeq "$(ENGINE)" "left4dead" - HL2SDK = $(HL2SDK_L4D) - CFLAGS += -DSOURCE_ENGINE=8 -endif -ifeq "$(ENGINE)" "left4dead2" - HL2SDK = $(HL2SDK_L4D2) - CFLAGS += -DSOURCE_ENGINE=9 -endif -ifeq "$(ENGINE)" "csgo" - HL2SDK = $(HL2SDK_CSGO) - CFLAGS += -DSOURCE_ENGINE=12 -endif - -HL2PUB = $(HL2SDK)/public - -ifeq "$(ENGINE)" "original" - INCLUDE += -I$(HL2SDK)/public/dlls - METAMOD = $(MMSOURCE19)/core-legacy -else - INCLUDE += -I$(HL2SDK)/public/game/server - METAMOD = $(MMSOURCE19)/core -endif - -OS := $(shell uname -s) - -ifeq "$(OS)" "Darwin" - LIB_EXT = dylib - HL2LIB = $(HL2SDK)/lib/mac -else - LIB_EXT = so - ifeq "$(ENGINE)" "original" - HL2LIB = $(HL2SDK)/linux_sdk - else - HL2LIB = $(HL2SDK)/lib/linux - endif -endif - -# if ENGINE is original or OB -ifneq (,$(filter original orangebox,$(ENGINE))) - LIB_SUFFIX = _i486.$(LIB_EXT) -else - LIB_PREFIX = lib - LIB_SUFFIX = _srv.$(LIB_EXT) -endif - -INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions -I$(SMSDK)/public/jit/x86 -I$(SMSDK)/public/jit - -ifeq "$(USEMETA)" "true" - LINK_HL2 = $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) - ifeq "$(ENGINE)" "csgo" - LINK_HL2 += $(HL2LIB)/interfaces_i486.a - endif - - LINK += $(LINK_HL2) - - INCLUDE += -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(HL2SDK)/game/shared\ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ - -I$(SMSDK)/public/sourcepawn - CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \ - -DSE_ORANGEBOXVALVE=6 -DSE_LEFT4DEAD=7 -DSE_LEFT4DEAD2=8 -DSE_ALIENSWARM=9 \ - -DSE_PORTAL2=10 -DSE_CSGO=11 -DSE_CSS=12 -endif - -LINK += -m32 -lm -ldl - -CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \ - -Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 -CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti - -################################################ -### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ### -################################################ - -BINARY = $(PROJECT).ext.$(LIB_EXT) - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS += $(C_DEBUG_FLAGS) -else - BIN_DIR = Release - CFLAGS += $(C_OPT_FLAGS) -endif - -ifeq "$(USEMETA)" "true" - BIN_DIR := $(BIN_DIR).$(ENGINE) -endif - -ifeq "$(OS)" "Darwin" - CPP = $(CPP_OSX) - LIB_EXT = dylib - CFLAGS += -DOSX -D_OSX - LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 -else - LIB_EXT = so - CFLAGS += -D_LINUX - LINK += -shared -endif - -IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0") - -ifeq "$(IS_CLANG)" "1" - CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/") - CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/") -else - CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1) - CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3) -endif - -# If not clang -ifeq "$(IS_CLANG)" "0" - CFLAGS += -mfpmath=sse -endif - -# Clang || GCC >= 4 -ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1" - CFLAGS += $(C_GCC4_FLAGS) - CPPFLAGS += $(CPP_GCC4_FLAGS) -endif - -# Clang >= 3 || GCC >= 4.7 -ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1" - CFLAGS += -Wno-delete-non-virtual-dtor -endif - -# OS is Linux and not using clang -ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1" - LINK += -static-libgcc -endif - -OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -# This will break if we include other Makefiles, but is fine for now. It allows -# us to make a copy of this file that uses altered paths (ie. Makefile.mine) -# or other changes without mucking up the original. -MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - -all: check - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/../sourcemod-central/public/jit/x86 - if [ "$(USEMETA)" = "true" ]; then \ - ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX); \ - ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX); \ - fi - $(MAKE) -f $(MAKEFILE_NAME) extension - -check: - if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \ - echo "You must supply one of the following values for ENGINE:"; \ - echo "csgo, left4dead2, left4dead, css, orangeboxvalve, orangebox, or original"; \ - exit 1; \ - fi - -extension: check $(OBJ_BIN) - $(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true - -default: all - -clean: check - rm -rf $(BIN_DIR)/*.o - rm -rf $(BIN_DIR)/sdk/*.o - rm -rf $(BIN_DIR)/$(BINARY) - diff --git a/buildbot/PackageScript b/buildbot/PackageScript index 44ada09..f339be9 100644 --- a/buildbot/PackageScript +++ b/buildbot/PackageScript @@ -1,115 +1,32 @@ -# vim: set ts=2 sw=2 tw=99 noet ft=python: +# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: import os -import shutil -import ambuild.osutil as osutil -from ambuild.command import Command -job = AMBuild.AddJob('package') +builder.SetBuildFolder('package') -class DestroyPath(Command): - def __init__(self, folder): - Command.__init__(self) - self.folder = folder +folder_list = [ + 'addons/sourcemod/gamedata', + 'addons/sourcemod/extensions', + 'addons/sourcemod/scripting', + 'addons/sourcemod/scripting/include', +] - def destroy(self, path): - entries = os.listdir(path) - for entry in entries: - newpath = os.path.join(path, entry) - if os.path.isdir(newpath): - self.destroy(newpath) - os.rmdir(newpath) - elif os.path.isfile(newpath): - os.remove(newpath) +# Create the distribution folder hierarchy. +folder_map = {} +for folder in folder_list: + norm_folder = os.path.normpath(folder) + folder_map[folder] = builder.AddFolder(norm_folder) - def run(self, runner, job): - runner.PrintOut('rm -rf {0}/*'.format(self.folder)) - self.destroy(self.folder) +builder.AddCopy(DHooks.task.binary, folder_map['addons/sourcemod/extensions']) -class CreateFolders(Command): - def __init__(self, folders): - Command.__init__(self) - self.folders = folders - - def run(self, runner, job): - for folder in self.folders: - path = os.path.join(*folder) - runner.PrintOut('mkdir {0}'.format(path)) - os.makedirs(path) - -#Shallow folder copy -class CopyFolder(Command): - def __init__(self, fromList, toList, excludes = []): - Command.__init__(self) - self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList) - self.toPath = os.path.join(*toList) - self.excludes = excludes - - def run(self, runner, job): - entries = os.listdir(self.fromPath) - for entry in entries: - if entry in self.excludes: - continue - path = os.path.join(self.fromPath, entry) - if not os.path.isfile(path): - continue - runner.PrintOut('copy {0} to {1}'.format(path, self.toPath)) - shutil.copy(path, self.toPath) - -#Single file copy -class CopyFile(Command): - def __init__(self, fromFile, toPath): - Command.__init__(self) - self.fromFile = fromFile - self.toPath = toPath - - def run(self, runner, job): - runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath)) - shutil.copy(self.fromFile, self.toPath) - - -folders = [ - ['addons', 'sourcemod', 'extensions'], - ['addons', 'sourcemod', 'scripting', 'include'], - ['addons', 'sourcemod', 'gamedata'], - ] - -#Setup -job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package'))) -job.AddCommand(CreateFolders(folders)) - -#Copy Files -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'scripting', 'include', 'dhooks.inc'), - os.path.join('addons', 'sourcemod', 'scripting', 'include'))) - -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'scripting', 'dhooks-test.sp'), - os.path.join('addons', 'sourcemod', 'scripting'))) - -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'gamedata', 'dhooks-test.games.txt'), - os.path.join('addons', 'sourcemod', 'gamedata'))) - -bincopies = [] - -def AddNormalLibrary(name, dest): - dest = os.path.join('addons', 'sourcemod', dest) - bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest)) - #pdb_list.append(name + '\\' + name + '.pdb') - -def AddHL2Library(name, dest): - for i in SM.sdkInfo: - sdk = SM.sdkInfo[i] - if AMBuild.target['platform'] not in sdk['platform']: - continue - AddNormalLibrary(name + '.ext.' + sdk['ext'], dest) - -#pdb_list = [] - -AddHL2Library('dhooks', 'extensions') - -job.AddCommandGroup(bincopies) - -#if AMBuild.target['platform'] == 'windows': -# pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt') -# for pdb in pdb_list: -# pdblog.write(pdb + '\n') -# pdblog.close() +# Do all straight-up file copies from the source tree. +def CopyFiles(src, dest, files): + if not dest: + dest = src + dest_entry = folder_map[dest] + for source_file in files: + source_path = os.path.join(builder.sourcePath, src, source_file) + builder.AddCopy(source_path, dest_entry) +CopyFiles('sourcemod/scripting', 'addons/sourcemod/scripting', ['dhooks-test.sp']) +CopyFiles('sourcemod/scripting/include', 'addons/sourcemod/scripting/include', ['dhooks.inc']) +CopyFiles('sourcemod/gamedata', 'addons/sourcemod/gamedata', ['dhooks-test.games.txt']) \ No newline at end of file diff --git a/buildbot/startbuild.pl b/buildbot/startbuild.pl index abe0dd3..9070834 100644 --- a/buildbot/startbuild.pl +++ b/buildbot/startbuild.pl @@ -10,12 +10,14 @@ require 'helpers.pm'; chdir('../../OUTPUT'); -if ($^O eq "linux" || $^O eq "darwin") { - system("python3 build.py 2>&1"); -} else { - system("C:\\Python31\\python.exe build.py 2>&1"); +my $argn = $#ARGV + 1; +if ($argn > 0) { + $ENV{CC} = $ARGV[0]; + $ENV{CXX} = $ARGV[0]; } +system("ambuild --no-color 2>&1"); + if ($? != 0) { die "Build failed: $!\n"; @@ -24,4 +26,3 @@ else { exit(0); } - diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..19b93f7 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,9 @@ +- 2.0.0 + - Added ability to handle params with a size other than 4 + - Restructed how hooking was handled + - Fixed multiple memory leaks + - Use SDKHooks for entity listeners + - Remove the need for SDK specific builds + - Updated to use AMBuild2 + - General code rewrite + - Add mac support. \ No newline at end of file diff --git a/configure.py b/configure.py index f0f2aa0..2c7e168 100644 --- a/configure.py +++ b/configure.py @@ -1,10 +1,15 @@ -# vim: set ts=2 sw=2 tw=99 noet: +# vim: set sts=2 ts=8 sw=2 tw=99 et: import sys -import ambuild.runner as runner +from ambuild2 import run -run = runner.Runner() -run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', +builder = run.PrepareBuild(sourcePath = sys.path[0]) +builder.default_build_folder = 'obj-' + builder.target_platform +builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', help='Enable debugging symbols') -run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', +builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', help='Enable optimization') -run.Configure(sys.path[0]) +builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None, + help='Path to Metamod:Source') +builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, + help='Path to Sourcemod') +builder.Configure() diff --git a/credits.txt b/credits.txt new file mode 100644 index 0000000..e2db5b2 --- /dev/null +++ b/credits.txt @@ -0,0 +1,5 @@ +dvander - Helping with asm and being a huge help overall. +KyleS - Input and reviewing my shitty commits. +psychonic - Quacking and helping with buildbot along with coding questions. +asherkin - SourceHook knowledge. +Powerlord - Debugging and fixing crashes. \ No newline at end of file diff --git a/extension.cpp b/extension.cpp index 88ac4e6..42ed7b8 100644 --- a/extension.cpp +++ b/extension.cpp @@ -1,7 +1,5 @@ #include "extension.h" -#include "vhook.h" #include "listeners.h" -#include DHooks g_DHooksIface; /**< Global singleton for extension's main interface */ SMEXT_LINK(&g_DHooksIface); @@ -15,8 +13,6 @@ HandleType_t g_HookSetupHandle = 0; HandleType_t g_HookParamsHandle = 0; HandleType_t g_HookReturnHandle = 0; -SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false); - bool DHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) { HandleError err; @@ -49,8 +45,6 @@ bool DHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) g_pEntityListener = new DHooksEntityListener(); - SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, g_pEntityListener, &DHooksEntityListener::LevelShutdown, false); - return true; } @@ -81,15 +75,18 @@ void DHooks::SDK_OnAllLoaded() void DHooks::SDK_OnUnload() { - CleanupHooks(NULL); + CleanupHooks(); if(g_pEntityListener) { - g_pEntityListener->CleanupListeners(NULL); + g_pEntityListener->CleanupListeners(); g_pSDKHooks->RemoveEntityListener(g_pEntityListener); - SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, g_pEntityListener, &DHooksEntityListener::LevelShutdown, false); delete g_pEntityListener; } plsys->RemovePluginsListener(this); + + handlesys->RemoveType(g_HookSetupHandle, myself->GetIdentity()); + handlesys->RemoveType(g_HookParamsHandle, myself->GetIdentity()); + handlesys->RemoveType(g_HookReturnHandle, myself->GetIdentity()); } bool DHooks::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late) @@ -118,38 +115,26 @@ bool DHooks::QueryRunning(char *error, size_t maxlength) SM_CHECK_IFACE(SDKHOOKS, g_pSDKHooks); return true; } -/* -// The default for this one is *supposed* to be false already -bool DHooks::QueryInterfaceDrop(SMInterface *pInterface) -{ - if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKTOOLS_NAME) == 0 - || strcmp(pInterface->GetInterfaceName(), SMINTERFACE_BINTOOL_NAME) == 0) - || strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKHOOKS_NAME) == 0) - { - return false; - } - - return true; -} -*/ void DHooks::NotifyInterfaceDrop(SMInterface *pInterface) { - if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKHOOKS_NAME) == 0) + if(strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKHOOKS_NAME) == 0) { - if (g_pEntityListener) + if(g_pEntityListener) { // If this fails, remove this line and just delete the ent listener instead - g_pSDKHooks->RemoveEntityListener(g_pEntityListener); + g_pSDKHooks->RemoveEntityListener(g_pEntityListener); + + g_pEntityListener->CleanupListeners(); delete g_pEntityListener; g_pEntityListener = NULL; } g_pSDKHooks = NULL; } - else if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_BINTOOLS_NAME) == 0) + else if(strcmp(pInterface->GetInterfaceName(), SMINTERFACE_BINTOOLS_NAME) == 0) { g_pBinTools = NULL; } - else if (strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKTOOLS_NAME) == 0) + else if(strcmp(pInterface->GetInterfaceName(), SMINTERFACE_SDKTOOLS_NAME) == 0) { g_pSDKTools = NULL; } diff --git a/extension.h b/extension.h index 203efec..043937a 100644 --- a/extension.h +++ b/extension.h @@ -42,6 +42,8 @@ #include #include #include +#include +#include "sdk-hacks.h" /** * @brief Sample implementation of the SDK Extension. @@ -91,6 +93,7 @@ public: virtual bool QueryRunning(char *error, size_t maxlength); //virtual bool QueryInterfaceDrop(SMInterface *pInterface); virtual void NotifyInterfaceDrop(SMInterface *pInterface); + virtual void OnCoreMapEnd(); public: #if defined SMEXT_CONF_METAMOD /** diff --git a/listeners.cpp b/listeners.cpp index 4129f3f..ae77bbc 100644 --- a/listeners.cpp +++ b/listeners.cpp @@ -3,28 +3,28 @@ using namespace SourceHook; -CUtlVector g_EntityListeners; +SourceHook::CVector g_EntityListeners; -void DHooksEntityListener::LevelShutdown() +void DHooks::OnCoreMapEnd() { - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(manager->callback->hookType == HookType_GameRules) { delete manager; - g_pHooks.Remove(i); + g_pHooks.erase(g_pHooks.iterAt(i)); } } } void DHooksEntityListener::CleanupListeners(IPluginContext *pContext) { - for(int i = g_EntityListeners.Count() -1; i >= 0; i--) + for(int i = g_EntityListeners.size() -1; i >= 0; i--) { - if(pContext == NULL || pContext == g_EntityListeners.Element(i).callback->GetParentRuntime()->GetDefaultContext()) + if(pContext == NULL || pContext == g_EntityListeners.at(i).callback->GetParentRuntime()->GetDefaultContext()) { - g_EntityListeners.Remove(i); + g_EntityListeners.erase(g_EntityListeners.iterAt(i)); } } } @@ -33,9 +33,9 @@ void DHooksEntityListener::OnEntityCreated(CBaseEntity *pEntity, const char *cla { int entity = gamehelpers->EntityToBCompatRef(pEntity); - for(int i = g_EntityListeners.Count() -1; i >= 0; i--) + for(int i = g_EntityListeners.size() -1; i >= 0; i--) { - EntityListener listerner = g_EntityListeners.Element(i); + EntityListener listerner = g_EntityListeners.at(i); if(listerner.type == ListenType_Created) { IPluginFunction *callback = listerner.callback; @@ -50,9 +50,9 @@ void DHooksEntityListener::OnEntityDestroyed(CBaseEntity *pEntity) { int entity = gamehelpers->EntityToBCompatRef(pEntity); - for(int i = g_EntityListeners.Count() -1; i >= 0; i--) + for(int i = g_EntityListeners.size() -1; i >= 0; i--) { - EntityListener listerner = g_EntityListeners.Element(i); + EntityListener listerner = g_EntityListeners.at(i); if(listerner.type == ListenType_Deleted) { IPluginFunction *callback = listerner.callback; @@ -61,21 +61,21 @@ void DHooksEntityListener::OnEntityDestroyed(CBaseEntity *pEntity) } } - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(manager->callback->entity == entity) { delete manager; - g_pHooks.Remove(i); + g_pHooks.erase(g_pHooks.iterAt(i)); } } } bool DHooksEntityListener::AddPluginEntityListener(ListenType type, IPluginFunction *callback) { - for(int i = g_EntityListeners.Count() -1; i >= 0; i--) + for(int i = g_EntityListeners.size() -1; i >= 0; i--) { - EntityListener listerner = g_EntityListeners.Element(i); + EntityListener listerner = g_EntityListeners.at(i); if(listerner.callback == callback && listerner.type == type) { return true; @@ -84,17 +84,17 @@ bool DHooksEntityListener::AddPluginEntityListener(ListenType type, IPluginFunct EntityListener listener; listener.callback = callback; listener.type = type; - g_EntityListeners.AddToTail(listener); + g_EntityListeners.push_back(listener); return true; } bool DHooksEntityListener::RemovePluginEntityListener(ListenType type, IPluginFunction *callback) { - for(int i = g_EntityListeners.Count() -1; i >= 0; i--) + for(int i = g_EntityListeners.size() -1; i >= 0; i--) { - EntityListener listerner = g_EntityListeners.Element(i); + EntityListener listerner = g_EntityListeners.at(i); if(listerner.callback == callback && listerner.type == type) { - g_EntityListeners.Remove(i); + g_EntityListeners.erase(g_EntityListeners.iterAt(i)); return true; } } diff --git a/listeners.h b/listeners.h index e2af029..8722bae 100644 --- a/listeners.h +++ b/listeners.h @@ -15,8 +15,7 @@ class DHooksEntityListener : public ISMEntityListener public: virtual void OnEntityCreated(CBaseEntity *pEntity, const char *classname); virtual void OnEntityDestroyed(CBaseEntity *pEntity); - void CleanupListeners(IPluginContext *func); - virtual void LevelShutdown(); + void CleanupListeners(IPluginContext *func = NULL); bool AddPluginEntityListener(ListenType type, IPluginFunction *callback); bool RemovePluginEntityListener(ListenType type, IPluginFunction *callback); }; @@ -28,5 +27,5 @@ struct EntityListener IPluginFunction *callback; }; -extern CUtlVector g_pHooks; +extern SourceHook::CVector g_pHooks; #endif diff --git a/msvc10/sdk.sln b/msvc10/sdk.sln index aa5e162..a60095e 100644 --- a/msvc10/sdk.sln +++ b/msvc10/sdk.sln @@ -5,66 +5,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcxproj", "{B3E7 EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32 - Debug - CS GO|Win32 = Debug - CS GO|Win32 - Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32 - Debug - Episode 1|Win32 = Debug - Episode 1|Win32 - Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32 - Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 - Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 - Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32 - Debug - Orange Box|Win32 = Debug - Orange Box|Win32 Debug|Win32 = Debug|Win32 - Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32 - Release - CS GO|Win32 = Release - CS GO|Win32 - Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32 - Release - Episode 1|Win32 = Release - Episode 1|Win32 - Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32 - Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 - Release - Old Metamod|Win32 = Release - Old Metamod|Win32 - Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32 - Release - Orange Box|Win32 = Release - Orange Box|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32 {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32 {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32 {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection diff --git a/msvc10/sdk.vcxproj b/msvc10/sdk.vcxproj index c1275cf..158462e 100644 --- a/msvc10/sdk.vcxproj +++ b/msvc10/sdk.vcxproj @@ -1,82 +1,10 @@  - - Debug - Alien Swarm - Win32 - - - Debug - CS GO - Win32 - - - Debug - Dark Messiah - Win32 - - - Debug - Episode 1 - Win32 - - - Debug - Left 4 Dead 2 - Win32 - - - Debug - Left 4 Dead - Win32 - - - Debug - Old Metamod - Win32 - - - Debug - Orange Box Valve - Win32 - - - Debug - Orange Box - Win32 - Debug Win32 - - Release - Alien Swarm - Win32 - - - Release - CS GO - Win32 - - - Release - Dark Messiah - Win32 - - - Release - Episode 1 - Win32 - - - Release - Left 4 Dead 2 - Win32 - - - Release - Left 4 Dead - Win32 - - - Release - Old Metamod - Win32 - - - Release - Orange Box Valve - Win32 - - - Release - Orange Box - Win32 - Release Win32 @@ -88,105 +16,6 @@ Win32Proj - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v100 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v100 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - - - DynamicLibrary - v110 - MultiByte - true - - - DynamicLibrary - v110 - MultiByte - DynamicLibrary v110 @@ -201,60 +30,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -269,107 +44,19 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\ true + dhooks.ext $(SolutionDir)$(Configuration)\ $(Configuration)\ false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false + dhooks.ext Disabled - ..;..\sdk;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) + ..;..\sdk;$(MMSOURCE10)\core;$(MMSOURCE10)\core\sourcehook;$(SMCENTRAL)\public;$(SMCENTRAL)\public\sourcepawn;$(SMCENTRAL)\public\extensions;$(SMCENTRAL)\public\jit;$(SMCENTRAL)\public\jit\x86;$(SOURCEMOD)\public\amtl + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;META_NO_HL2SDK;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -380,7 +67,7 @@ EditAndContinue - $(OutDir)sample.ext.dll + $(OutDir)dhooks.ext.dll LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) true Windows @@ -390,499 +77,36 @@ - - Speed - ..;..\sdk;..\..;..\..\sourcepawn;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(OutDir)sample.ext.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.1.ep1.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core-legacy;$(MMSOURCE19)\core-legacy\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1;%(PreprocessorDefinitions) + ..;..\sdk;$(MMSOURCE10)\core;$(MMSOURCE10)\core\sourcehook;$(SMCENTRAL)\public;$(SMCENTRAL)\public\sourcepawn;$(SMCENTRAL)\public\extensions;$(SMCENTRAL)\public\jit;$(SMCENTRAL)\public\jit\x86;$(SOURCEMOD)\public\amtl + WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;META_NO_HL2SDK;%(PreprocessorDefinitions) MultiThreaded NotSet false - + + Level3 ProgramDatabase - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.1.ep1.dll + + + $(OutDir)dhooks.ext.dll LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) true Windows true true false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.darkm.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-DARKM)\public;$(HL2SDK-DARKM)\public\dlls;$(HL2SDK-DARKM)\public\engine;$(HL2SDK-DARKM)\public\tier0;$(HL2SDK-DARKM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDK-DARKM)\lib\public\tier0.lib;$(HL2SDK-DARKM)\lib\public\tier1.lib;$(HL2SDK-DARKM)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.darkm.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.ep2.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOB)\public;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\game\server;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDKOB)\lib\public\tier0.lib;$(HL2SDKOB)\lib\public\tier1.lib;$(HL2SDKOB)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.ep2.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.ep2v.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;$(HL2SDKOBVALVE)\public;$(HL2SDKOBVALVE)\public\engine;$(HL2SDKOBVALVE)\public\game\server;$(HL2SDKOBVALVE)\public\tier0;$(HL2SDKOBVALVE)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;$(SMCENTRAL)\public;$(SMCENTRAL)\public\sourcepawn;$(SMCENTRAL)\public\extensions;$(HL2SDKOBVALVE)\game\server;$(HL2SDKOBVALVE)\game\shared;$(SMCENTRAL)\public\jit;$(SMCENTRAL)\public\jit\x86;$(SMCENTRAL)\public\amtl;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=6;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDKOBVALVE)\lib\public\tier0.lib;$(HL2SDKOBVALVE)\lib\public\tier1.lib;$(HL2SDKOBVALVE)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)dhooks.ext.2.css.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.l4d.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D)\public;$(HL2SDKL4D)\public\engine;$(HL2SDKL4D)\public\game\server;$(HL2SDKL4D)\public\tier0;$(HL2SDKL4D)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=7;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDKL4D)\lib\public\tier0.lib;$(HL2SDKL4D)\lib\public\tier1.lib;$(HL2SDKL4D)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.l4d.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.l4d2.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKL4D2)\public;$(HL2SDKL4D2)\public\engine;$(HL2SDKL4D2)\public\game\server;$(HL2SDKL4D2)\public\tier0;$(HL2SDKL4D2)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=8;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDKL4D2)\lib\public\tier0.lib;$(HL2SDKL4D2)\lib\public\tier1.lib;$(HL2SDKL4D2)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.l4d2.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDK-SWARM)\lib\public\interfaces.lib;$(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.swarm.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK-SWARM)\public;$(HL2SDK-SWARM)\public\engine;$(HL2SDK-SWARM)\public\game\server;$(HL2SDK-SWARM)\public\tier0;$(HL2SDK-SWARM)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=9;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDK-SWARM)\lib\public\interfaces.lib;$(HL2SDK-SWARM)\lib\public\tier0.lib;$(HL2SDK-SWARM)\lib\public\tier1.lib;$(HL2SDK-SWARM)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.swarm.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=11;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDKCSGO)\lib\public\interfaces.lib;$(HL2SDKCSGO)\lib\public\tier0.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.csgo.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;$(HL2SDKCSGO)\public;$(HL2SDKCSGO)\public\engine;$(HL2SDKCSGO)\public\game\server;$(HL2SDKCSGO)\public\tier0;$(HL2SDKCSGO)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;$(SMCENTRAL)\public;$(SMCENTRAL)\public\sourcepawn;$(SMCENTRAL)\public\extensions;$(HL2SDKCSGO)\game\server;$(HL2SDKCSGO)\game\shared;$(SMCENTRAL)\public\jit;$(SMCENTRAL)\public\jit\x86;$(SMCENTRAL)\public\amtl - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;COMPILER_MSVC;COMPILER_MSVC32;SOURCE_ENGINE=11;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDKCSGO)\lib\public\interfaces.lib;$(HL2SDKCSGO)\lib\public\tier1.lib;$(HL2SDKCSGO)\lib\public\vstdlib.lib;$(HL2SDKCSGO)\lib\public\tier0.lib - $(OutDir)dhooks.ext.2.csgo.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - - MachineX86 - - - - - /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Disabled - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - NotSet - false - - Level3 - EditAndContinue - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.ep1.dll - LIBC;LIBCD;LIBCMT;%(IgnoreSpecificDefaultLibraries) - true - Windows - false - - MachineX86 - - - - - /MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_BLOODYGOODTIME=4 /D SE_EYE=5 /D SE_ORANGEBOXVALVE=6 /D SE_LEFT4DEAD=7 /D SE_LEFT4DEAD2=8 /D SE_ALIENSWARM=9 /D SE_PORTAL2=10 /D SE_CSGO=11 %(AdditionalOptions) - Speed - ..;..\sdk;..\..;..\..\sourcepawn;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(MMSOURCE19)\core;$(MMSOURCE19)\core\sourcehook;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2;%(PreprocessorDefinitions) - MultiThreaded - NotSet - false - - Level3 - ProgramDatabase - - - $(HL2SDK)\lib\public\tier0.lib;$(HL2SDK)\lib\public\tier1.lib;$(HL2SDK)\lib\public\vstdlib.lib;%(AdditionalDependencies) - $(OutDir)sample.ext.2.ep1.dll - LIBC;LIBCD;LIBCMTD;%(IgnoreSpecificDefaultLibraries) - true - Windows - true - true - false - + + MachineX86 - + @@ -893,11 +117,11 @@ + - diff --git a/msvc10/sdk.vcxproj.filters b/msvc10/sdk.vcxproj.filters index 4da95fe..64a6661 100644 --- a/msvc10/sdk.vcxproj.filters +++ b/msvc10/sdk.vcxproj.filters @@ -6,7 +6,7 @@ - + JIT @@ -25,9 +25,6 @@ sdk - - Headers - Headers @@ -37,6 +34,9 @@ Headers + + Headers + diff --git a/natives.cpp b/natives.cpp index 8b3ca0f..189292e 100644 --- a/natives.cpp +++ b/natives.cpp @@ -1,29 +1,4 @@ #include "natives.h" -#include - -#ifndef _DEBUG -#include -#else -#undef _DEBUG -#include -#define _DEBUG 1 -#endif - -CBaseEntity *UTIL_GetCBaseEntity(int num) -{ - edict_t *pEdict = gamehelpers->EdictOfIndex(num); - if (!pEdict || pEdict->IsFree()) - { - return NULL; - } - IServerUnknown *pUnk; - if ((pUnk=pEdict->GetUnknown()) == NULL) - { - return NULL; - } - - return pUnk->GetBaseEntity(); -} bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *pContext, cell_t param) { @@ -42,22 +17,19 @@ bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *p return true; } -#ifndef __linux__ intptr_t GetObjectAddr(HookParamType type, void **params, int index) { +#ifdef WIN32 if(type == HookParamType_Object) return (intptr_t)¶ms[index]; else if(type == HookParamType_ObjectPtr) return (intptr_t)params[index]; return 0; -} #else -intptr_t GetObjectAddr(HookParamType type, void **params, int index) -{ return (intptr_t)params[index]; -} #endif +} //native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, ThisPointerType:thistype, DHookCallback:callback); cell_t Native_CreateHook(IPluginContext *pContext, const cell_t *params) @@ -117,7 +89,7 @@ cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params) } info.pass_type = GetParamTypePassType(info.type); - setup->params.AddToTail(info); + setup->params.push_back(info); return 1; } @@ -137,15 +109,15 @@ cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) } bool post = params[2] != 0; - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); - if(manager->callback->hookType == HookType_Entity && manager->callback->entity == params[3] && manager->callback->offset == setup->offset && manager->callback->post == post && manager->remove_callback == pContext->GetFunctionById(params[4]) && manager->callback->plugin_callback == setup->callback) + DHooksManager *manager = g_pHooks.at(i); + if(manager->callback->hookType == HookType_Entity && manager->callback->entity == gamehelpers->ReferenceToBCompatRef(params[3]) && manager->callback->offset == setup->offset && manager->callback->post == post && manager->remove_callback == pContext->GetFunctionById(params[4]) && manager->callback->plugin_callback == setup->callback) { return manager->hookid; } } - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[3]); + CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[3]); if(!pEnt) { @@ -160,7 +132,7 @@ cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) return 0; } - g_pHooks.AddToTail(manager); + g_pHooks.push_back(manager); return manager->hookid; } @@ -181,9 +153,9 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) bool post = params[2] != 0; - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(manager->callback->hookType == HookType_GameRules && manager->callback->offset == setup->offset && manager->callback->post == post && manager->remove_callback == pContext->GetFunctionById(params[3]) && manager->callback->plugin_callback == setup->callback) { return manager->hookid; @@ -194,7 +166,7 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) if(!rules) { - return pContext->ThrowNativeError("Could not get game rules pointer"); + return pContext->ThrowNativeError("Could not get gamerules pointer"); } DHooksManager *manager = new DHooksManager(setup, rules, pContext->GetFunctionById(params[3]), post); @@ -205,7 +177,7 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) return 0; } - g_pHooks.AddToTail(manager); + g_pHooks.push_back(manager); return manager->hookid; } @@ -221,14 +193,14 @@ cell_t Native_HookRaw(IPluginContext *pContext, const cell_t *params) if(setup->hookType != HookType_Raw) { - return pContext->ThrowNativeError("Hook is not a gamerules hook"); + return pContext->ThrowNativeError("Hook is not a raw hook"); } bool post = params[2] != 0; - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(manager->callback->hookType == HookType_Raw && manager->callback->offset == setup->offset && manager->callback->post == post && manager->remove_callback == pContext->GetFunctionById(params[3]) && manager->callback->plugin_callback == setup->callback) { return manager->hookid; @@ -250,20 +222,20 @@ cell_t Native_HookRaw(IPluginContext *pContext, const cell_t *params) return 0; } - g_pHooks.AddToTail(manager); + g_pHooks.push_back(manager); return manager->hookid; } // native bool:DHookRemoveHookID(hookid); cell_t Native_RemoveHookID(IPluginContext *pContext, const cell_t *params) { - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(manager->hookid == params[1] && manager->callback->plugin_callback->GetParentRuntime()->GetDefaultContext() == pContext) { delete manager; - g_pHooks.Remove(i); + g_pHooks.erase(g_pHooks.iterAt(i)); return 1; } } @@ -279,23 +251,23 @@ cell_t Native_GetParam(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] < 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] < 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } if(params[2] == 0) { - return paramStruct->dg->params.Count(); + return paramStruct->dg->params.size(); } int index = params[2] - 1; - if(paramStruct->orgParams[index] == NULL && (paramStruct->dg->params.Element(index).type == HookParamType_CBaseEntity || paramStruct->dg->params.Element(index).type == HookParamType_Edict)) + if(paramStruct->orgParams[index] == NULL && (paramStruct->dg->params.at(index).type == HookParamType_CBaseEntity || paramStruct->dg->params.at(index).type == HookParamType_Edict)) { return pContext->ThrowNativeError("Trying to get value for null pointer."); } - switch(paramStruct->dg->params.Element(index).type) + switch(paramStruct->dg->params.at(index).type) { case HookParamType_Int: return (int)paramStruct->orgParams[index]; @@ -308,7 +280,7 @@ cell_t Native_GetParam(IPluginContext *pContext, const cell_t *params) case HookParamType_Float: return sp_ftoc(*(float *)paramStruct->orgParams[index]); default: - return pContext->ThrowNativeError("Invalid param type (%i) to get", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid param type (%i) to get", paramStruct->dg->params.at(index).type); } return 1; @@ -324,14 +296,14 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - switch(paramStruct->dg->params.Element(index).type) + switch(paramStruct->dg->params.at(index).type) { case HookParamType_Int: paramStruct->newParams[index] = (void *)params[3]; @@ -341,7 +313,7 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params) break; case HookParamType_CBaseEntity: { - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[2]); + CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]); if(!pEnt) { return pContext->ThrowNativeError("Invalid entity index passed for param value"); @@ -364,7 +336,7 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params) *(float *)paramStruct->newParams[index] = sp_ctof(params[3]); break; default: - return pContext->ThrowNativeError("Invalid param type (%i) to set", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid param type (%i) to set", paramStruct->dg->params.at(index).type); } paramStruct->isChanged[index] = true; @@ -418,7 +390,7 @@ cell_t Native_SetReturn(IPluginContext *pContext, const cell_t *params) break; case ReturnType_CBaseEntity: { - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[2]); + CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]); if(!pEnt) { return pContext->ThrowNativeError("Invalid entity index passed for return value"); @@ -455,14 +427,14 @@ cell_t Native_GetParamVector(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - switch(paramStruct->dg->params.Element(index).type) + switch(paramStruct->dg->params.at(index).type) { case HookParamType_VectorPtr: { @@ -487,14 +459,14 @@ cell_t Native_SetParamVector(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - switch(paramStruct->dg->params.Element(index).type) + switch(paramStruct->dg->params.at(index).type) { case HookParamType_VectorPtr: { @@ -521,9 +493,9 @@ cell_t Native_GetParamString(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; @@ -532,7 +504,7 @@ cell_t Native_GetParamString(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Trying to get value for null pointer."); } - if(paramStruct->dg->params.Element(index).type == HookParamType_CharPtr) + if(paramStruct->dg->params.at(index).type == HookParamType_CharPtr) { pContext->StringToLocal(params[3], params[4], (const char *)paramStruct->orgParams[index]); } @@ -601,9 +573,9 @@ cell_t Native_SetParamString(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; @@ -611,7 +583,7 @@ cell_t Native_SetParamString(IPluginContext *pContext, const cell_t *params) char *value; pContext->LocalToString(params[3], &value); - if(paramStruct->dg->params.Element(index).type == HookParamType_CharPtr) + if(paramStruct->dg->params.at(index).type == HookParamType_CharPtr) { if((char *)paramStruct->newParams[index] != NULL && paramStruct->isChanged[index]) delete (char *)paramStruct->newParams[index]; @@ -653,19 +625,19 @@ cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - if(paramStruct->dg->params.Element(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.Element(index).type != HookParamType_Object) + if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object) { - return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type); } - intptr_t addr = GetObjectAddr(paramStruct->dg->params.Element(index).type, paramStruct->orgParams, index); + intptr_t addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->orgParams, index); switch((ObjectValueType)params[4]) { @@ -677,13 +649,19 @@ cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param return *(bool *)(addr + params[3]) ? 1 : 0; case ObjectValueType_Ehandle: { - EHANDLE hEntity = *(EHANDLE *)(addr + params[3]); - return hEntity.IsValid()?hEntity.GetEntryIndex():-1; + edict_t *pEnt = gamehelpers->GetHandleEntity(*(CBaseHandle *)(addr + params[3])); + + if(!pEnt) + { + return -1; + } + + return gamehelpers->IndexOfEdict(pEnt); } case ObjectValueType_Float: return sp_ftoc(*(float *)(addr + params[3])); case ObjectValueType_CBaseEntityPtr: - return gamehelpers->EntityToBCompatRef(*(CBaseEntity **)(addr + params[3])); + return gamehelpers->EntityToBCompatRef((CBaseEntity *)(addr + params[3])); case ObjectValueType_IntPtr: { int *ptr = *(int **)(addr + params[3]); @@ -694,10 +672,16 @@ cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param bool *ptr = *(bool **)(addr + params[3]); return *ptr ? 1 : 0; } - case ObjectValueType_EhandlePtr: + case ObjectValueType_EhandlePtr://Im pretty sure this is never gonna happen { - EHANDLE *hEntity = *(EHANDLE **)(addr + params[3]); - return hEntity->IsValid()?hEntity->GetEntryIndex():-1; + edict_t *pEnt = gamehelpers->GetHandleEntity(**(CBaseHandle **)(addr + params[3])); + + if(!pEnt) + { + return -1; + } + + return gamehelpers->IndexOfEdict(pEnt); } case ObjectValueType_FloatPtr: { @@ -719,19 +703,19 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - if(paramStruct->dg->params.Element(index).type != HookParamType_ObjectPtr) + if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr) { - return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type); } - intptr_t addr = GetObjectAddr(paramStruct->dg->params.Element(index).type, paramStruct->orgParams, index); + intptr_t addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->orgParams, index); switch((ObjectValueType)params[4]) { @@ -743,14 +727,14 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param break; case ObjectValueType_Ehandle: { - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[5]); + edict_t *pEnt = gamehelpers->EdictOfIndex(params[5]); - if(!pEnt) + if(pEnt->IsFree()) { return pContext->ThrowNativeError("Invalid entity passed"); } + gamehelpers->SetHandleEntity(*(CBaseHandle *)(addr + params[3]), pEnt); - *(EHANDLE *)(addr + params[3]) = pEnt; break; } case ObjectValueType_Float: @@ -758,7 +742,7 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param break; case ObjectValueType_CBaseEntityPtr: { - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[5]); + CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[5]); if(!pEnt) { @@ -782,15 +766,14 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param } case ObjectValueType_EhandlePtr: { - CBaseEntity *pEnt = UTIL_GetCBaseEntity(params[5]); + edict_t *pEnt = gamehelpers->EdictOfIndex(params[5]); - if(!pEnt) + if(pEnt->IsFree()) { return pContext->ThrowNativeError("Invalid entity passed"); } + gamehelpers->SetHandleEntity(**(CBaseHandle **)(addr + params[3]), pEnt); - EHANDLE *hEntity = *(EHANDLE **)(addr + params[3]); - *hEntity = pEnt; break; } case ObjectValueType_FloatPtr: @@ -815,19 +798,19 @@ cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - if(paramStruct->dg->params.Element(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.Element(index).type != HookParamType_Object) + if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object) { - return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type); } - intptr_t addr = GetObjectAddr(paramStruct->dg->params.Element(index).type, paramStruct->orgParams, index); + intptr_t addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->orgParams, index); cell_t *buffer; pContext->LocalToPhysAddr(params[5], &buffer); @@ -868,19 +851,19 @@ cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - if(paramStruct->dg->params.Element(index).type != HookParamType_ObjectPtr) + if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr) { - return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type); } - intptr_t addr = GetObjectAddr(paramStruct->dg->params.Element(index).type, paramStruct->orgParams, index); + intptr_t addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->orgParams, index); cell_t *buffer; pContext->LocalToPhysAddr(params[5], &buffer); @@ -920,19 +903,19 @@ cell_t Native_GetParamObjectPtrString(IPluginContext *pContext, const cell_t *pa return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - if(paramStruct->dg->params.Element(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.Element(index).type != HookParamType_Object) + if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object) { - return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.Element(index).type); + return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type); } - intptr_t addr = GetObjectAddr(paramStruct->dg->params.Element(index).type, paramStruct->orgParams, index); + intptr_t addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->orgParams, index); switch((ObjectValueType)params[4]) { @@ -1015,14 +998,14 @@ cell_t Native_IsNullParam(IPluginContext *pContext, const cell_t *params) return 0; } - if(params[2] <= 0 || params[2] > paramStruct->dg->params.Count()) + if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size()) { - return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.Count()); + return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size()); } int index = params[2] - 1; - HookParamType type = paramStruct->dg->params.Element(index).type; + HookParamType type = paramStruct->dg->params.at(index).type; //Check that the type is ptr if(type == HookParamType_StringPtr || type == HookParamType_CharPtr || type == HookParamType_VectorPtr || type == HookParamType_CBaseEntity || type == HookParamType_ObjectPtr || type == HookParamType_Edict || type == HookParamType_Unknown) diff --git a/natives.h b/natives.h index 34d07f3..eb34936 100644 --- a/natives.h +++ b/natives.h @@ -10,5 +10,5 @@ extern ISDKTools *g_pSDKTools; extern HandleType_t g_HookSetupHandle; extern HandleType_t g_HookParamsHandle; extern HandleType_t g_HookReturnHandle; -extern CUtlVector g_pHooks; +extern SourceHook::CVector g_pHooks; #endif diff --git a/product.version b/product.version new file mode 100644 index 0000000..67ce2ff --- /dev/null +++ b/product.version @@ -0,0 +1 @@ +2.0.0-dev diff --git a/sdk-hacks.h b/sdk-hacks.h new file mode 100644 index 0000000..c1e7897 --- /dev/null +++ b/sdk-hacks.h @@ -0,0 +1,75 @@ +#ifndef _INCLUDE_SDK_HACKS_H_ +#define _INCLUDE_SDK_HACKS_H_ + +class Vector +{ +public: + Vector(float x1, float y1, float z1) + { + this->x = x1; + this->y = y1; + this->z = z1; + } + Vector(void) + { + this->x = 0.0; + this->y = 0.0; + this->z = 0.0; + } + float x; + float y; + float z; +}; + +struct string_t +{ +public: + bool operator!() const { return ( pszValue == NULL ); } + bool operator==( const string_t &rhs ) const { return ( pszValue == rhs.pszValue ); } + bool operator!=( const string_t &rhs ) const { return ( pszValue != rhs.pszValue ); } + bool operator<( const string_t &rhs ) const { return ((void *)pszValue < (void *)rhs.pszValue ); } + + const char *ToCStr() const { return ( pszValue ) ? pszValue : ""; } + +protected: + const char *pszValue; +}; + +struct castable_string_t : public string_t // string_t is used in unions, hence, no constructor allowed +{ + castable_string_t() { pszValue = NULL; } + castable_string_t( const char *pszFrom ) { pszValue = (pszFrom && *pszFrom) ? pszFrom : 0; } +}; + +#define NULL_STRING castable_string_t() +#define STRING( string_t_obj ) (string_t_obj).ToCStr() +#define MAKE_STRING( c_str ) castable_string_t( c_str ) + +#define FL_EDICT_FREE (1<<1) + +struct edict_t +{ +public: + bool IsFree() + { + return (m_fStateFlags & FL_EDICT_FREE) != 0; + } +private: + int m_fStateFlags; +}; + +class CBaseHandle +{ +/*public: + bool IsValid() const {return m_Index != INVALID_EHANDLE_INDEX;} + int GetEntryIndex() const + { + if ( !IsValid() ) + return NUM_ENT_ENTRIES-1; + return m_Index & ENT_ENTRY_MASK; + }*/ +private: + unsigned long m_Index; +}; + +#endif \ No newline at end of file diff --git a/sdk/smsdk_ext.cpp b/sdk/smsdk_ext.cpp index f5a9ec7..30cf69e 100644 --- a/sdk/smsdk_ext.cpp +++ b/sdk/smsdk_ext.cpp @@ -298,8 +298,10 @@ ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */ SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */ ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */ +#if !defined META_NO_HL2SDK IVEngineServer *engine = NULL; /**< IVEngineServer pointer */ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */ +#endif /** Exposes the extension to Metamod */ SMM_API void *PL_EXPOSURE(const char *name, int *code) @@ -312,14 +314,14 @@ SMM_API void *PL_EXPOSURE(const char *name, int *code) { if (code) { - *code = IFACE_OK; + *code = META_IFACE_OK; } return static_cast(g_pExtensionIface); } if (code) { - *code = IFACE_FAILED; + *code = META_IFACE_FAILED; } return NULL; @@ -329,12 +331,14 @@ bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, { 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); +#if !defined META_NO_HL2SDK + #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 #endif m_SourceMMLoaded = true; diff --git a/sdk/smsdk_ext.h b/sdk/smsdk_ext.h index 024a9f4..08a9e1a 100644 --- a/sdk/smsdk_ext.h +++ b/sdk/smsdk_ext.h @@ -100,7 +100,7 @@ #if defined SMEXT_CONF_METAMOD #include -#include +//#include #endif using namespace SourceMod; @@ -301,8 +301,10 @@ extern INativeInterface *ninvoke; #if defined SMEXT_CONF_METAMOD PLUGIN_GLOBALVARS(); -extern IVEngineServer *engine; -extern IServerGameDLL *gamedll; + #if !defined META_NO_HL2SDK + extern IVEngineServer *engine; + extern IServerGameDLL *gamedll; + #endif #endif /** Creates a SourceMod interface macro pair */ diff --git a/sourcemod/gamedata/dhooks-test.games.txt b/sourcemod/gamedata/dhooks-test.games.txt index 8b2d822..479beff 100644 --- a/sourcemod/gamedata/dhooks-test.games.txt +++ b/sourcemod/gamedata/dhooks-test.games.txt @@ -29,13 +29,13 @@ } "GetMaxs" { - "windows" "337" - "linux" "338" + "windows" "338" + "linux" "339" } "CanUse" { - "windows" "258" - "linux" "259" + "windows" "259" + "linux" "260" } "CanHaveAmmo" { @@ -49,13 +49,13 @@ } "GetMaxPlayerSpeed" { - "windows" "436" - "linux" "437" + "windows" "437" + "linux" "438" } "GiveAmmo" { - "windows" "250" - "linux" "251" + "windows" "251" + "linux" "252" } "OnTakeDamage" { diff --git a/version.rc b/version.rc index ab42084..9635424 100644 --- a/version.rc +++ b/version.rc @@ -8,7 +8,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #endif #ifndef SM_GENERATED_BUILD -#define BINARY_NAME "vphysics.ext.dll\0" +#define BINARY_NAME "dhooks.ext.dll\0" #endif VS_VERSION_INFO VERSIONINFO diff --git a/vfunc_call.h b/vfunc_call.h index 4162cee..2edbdb7 100644 --- a/vfunc_call.h +++ b/vfunc_call.h @@ -5,8 +5,8 @@ #include "extension.h" #define PARAMINFO_SWITCH(passType) \ - paramInfo[i].flags = dg->params.Element(i).flag; \ - paramInfo[i].size = dg->params.Element(i).size; \ + paramInfo[i].flags = dg->params.at(i).flag; \ + paramInfo[i].size = dg->params.at(i).size; \ paramInfo[i].type = passType; #define VSTK_PARAM_SWITCH(paramType) \ @@ -18,9 +18,9 @@ { \ *(paramType *)vptr = (paramType)(paramStruct->orgParams[i]); \ } \ - if(i + 1 != dg->params.Count()) \ + if(i + 1 != dg->params.size()) \ { \ - vptr += dg->params.Element(i).size; \ + vptr += dg->params.at(i).size; \ } \ break; #define VSTK_PARAM_SWITCH_FLOAT() \ @@ -32,9 +32,9 @@ { \ *(float *)vptr = *(float *)(paramStruct->orgParams[i]); \ } \ - if(i + 1 != dg->params.Count()) \ + if(i + 1 != dg->params.size()) \ { \ - vptr += dg->params.Element(i).size; \ + vptr += dg->params.at(i).size; \ } \ break; @@ -70,10 +70,10 @@ T CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface) if(paramStruct) { vptr += sizeof(void *); - paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.Count()); - for(int i = 0; i < dg->params.Count(); i++) + paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.size()); + for(int i = 0; i < (int)dg->params.size(); i++) { - switch(dg->params.Element(i).type) + switch(dg->params.at(i).type) { case HookParamType_Int: PARAMINFO_SWITCH(PassType_Basic); @@ -113,12 +113,12 @@ T CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, void *iface) if(dg->returnType == ReturnType_Void) { - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, NULL, paramInfo, dg->params.Count()); + pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, NULL, paramInfo, dg->params.size()); pCall->Execute(vstk, NULL); } else { - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.Count()); + pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.size()); pCall->Execute(vstk, &ret); } @@ -157,10 +157,10 @@ Vector CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, if(paramStruct) { vptr += sizeof(void *); - paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.Count()); - for(int i = 0; i < dg->params.Count(); i++) + paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.size()); + for(int i = 0; i < (int)dg->params.size(); i++) { - switch(dg->params.Element(i).type) + switch(dg->params.at(i).type) { case HookParamType_Int: PARAMINFO_SWITCH(PassType_Basic); @@ -198,7 +198,7 @@ Vector CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStruct, Vector ret; - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.Count()); + pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.size()); pCall->Execute(vstk, &ret); pCall->Destroy(); @@ -237,10 +237,10 @@ string_t CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStru if(paramStruct) { vptr += sizeof(void *); - paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.Count()); - for(int i = 0; i < dg->params.Count(); i++) + paramInfo = (SourceMod::PassInfo *)malloc(sizeof(SourceMod::PassInfo) * dg->params.size()); + for(int i = 0; i < dg->params.size(); i++) { - switch(dg->params.Element(i).type) + switch(dg->params.at(i).type) { case HookParamType_Int: PARAMINFO_SWITCH(PassType_Basic); @@ -278,7 +278,7 @@ string_t CallVFunction(DHooksCallback *dg, HookParamsStruct *paramStru string_t ret; - pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.Count()); + pCall = g_pBinTools->CreateVCall(dg->offset, 0, 0, &returnInfo, paramInfo, dg->params.size()); pCall->Execute(vstk, &ret); pCall->Destroy(); diff --git a/vhook.cpp b/vhook.cpp index b52358b..00c8638 100644 --- a/vhook.cpp +++ b/vhook.cpp @@ -3,11 +3,11 @@ SourceHook::IHookManagerAutoGen *g_pHookManager = NULL; -CUtlVector g_pHooks; +SourceHook::CVector g_pHooks; using namespace SourceHook; -#ifndef __linux__ +#ifdef WIN32 #define OBJECT_OFFSET sizeof(void *) #else #define OBJECT_OFFSET (sizeof(void *)*2) @@ -24,6 +24,7 @@ DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *rem this->callback->post = post; this->callback->hookType = setup->hookType; this->callback->params = setup->params; + this->addr = 0; if(this->callback->hookType == HookType_Entity) @@ -41,9 +42,9 @@ DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *rem CProtoInfoBuilder protoInfo(ProtoInfo::CallConv_ThisCall); - for(int i = this->callback->params.Count() -1; i >= 0; i--) + for(int i = this->callback->params.size() -1; i >= 0; i--) { - protoInfo.AddParam(this->callback->params.Element(i).size, this->callback->params.Element(i).pass_type, this->callback->params.Element(i).flag, NULL, NULL, NULL, NULL); + protoInfo.AddParam(this->callback->params.at(i).size, this->callback->params.at(i).pass_type, this->callback->params.at(i).flag, NULL, NULL, NULL, NULL); } if(this->callback->returnType == ReturnType_Void) @@ -66,21 +67,21 @@ DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *rem { protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Basic, setup->returnFlag, NULL, NULL, NULL, NULL); } - HookManagerPubFunc hook = g_pHookManager->MakeHookMan(protoInfo, 0, this->callback->offset); + this->pManager = g_pHookManager->MakeHookMan(protoInfo, 0, this->callback->offset); - this->hookid = g_SHPtr->AddHook(g_PLID,ISourceHook::Hook_Normal, iface, 0, hook, this->callback, this->callback->post); + this->hookid = g_SHPtr->AddHook(g_PLID,ISourceHook::Hook_Normal, iface, 0, this->pManager, this->callback, this->callback->post); } void CleanupHooks(IPluginContext *pContext) { - for(int i = g_pHooks.Count() -1; i >= 0; i--) + for(int i = g_pHooks.size() -1; i >= 0; i--) { - DHooksManager *manager = g_pHooks.Element(i); + DHooksManager *manager = g_pHooks.at(i); if(pContext == NULL || pContext == manager->callback->plugin_callback->GetParentRuntime()->GetDefaultContext()) { delete manager; - g_pHooks.Remove(i); + g_pHooks.erase(g_pHooks.iterAt(i)); } } } @@ -110,12 +111,12 @@ SourceHook::PassInfo::PassType GetParamTypePassType(HookParamType type) size_t GetStackArgsSize(DHooksCallback *dg) { size_t res = 0; - for(int i = dg->params.Count() - 1; i >= 0; i--) + for(int i = dg->params.size() - 1; i >= 0; i--) { - res += dg->params.Element(i).size; + res += dg->params.at(i).size; } - #ifndef __linux__ + #ifdef WIN32 if(dg->returnType == ReturnType_Vector)//Account for result vector ptr. #else if(dg->returnType == ReturnType_Vector || dg->returnType == ReturnType_String) @@ -129,7 +130,7 @@ HookParamsStruct *GetParamStruct(DHooksCallback *dg, void **argStack, size_t arg { HookParamsStruct *params = new HookParamsStruct(); params->dg = dg; - #ifndef __linux__ + #ifdef WIN32 if(dg->returnType != ReturnType_Vector) #else if(dg->returnType != ReturnType_Vector && dg->returnType != ReturnType_String) @@ -143,9 +144,9 @@ HookParamsStruct *GetParamStruct(DHooksCallback *dg, void **argStack, size_t arg params->orgParams = (void **)malloc(argStackSize-OBJECT_OFFSET); memcpy(params->orgParams, argStack+OBJECT_OFFSET, argStackSize-OBJECT_OFFSET); } - params->newParams = (void **)malloc(dg->params.Count() * sizeof(void *)); - params->isChanged = (bool *)malloc(dg->params.Count() * sizeof(bool)); - for(int i = 0; i < dg->params.Count(); i++) + params->newParams = (void **)malloc(dg->params.size() * sizeof(void *)); + params->isChanged = (bool *)malloc(dg->params.size() * sizeof(bool)); + for(int i = 0; i < (int)dg->params.size(); i++) { params->newParams[i] = NULL; params->isChanged[i] = false; @@ -224,7 +225,7 @@ cell_t GetThisPtr(void *iface, ThisPointerType type) return (cell_t)iface; } -#ifndef __linux__ +#ifdef WIN32 void *Callback(DHooksCallback *dg, void **argStack, size_t *argsizep) #else void *Callback(DHooksCallback *dg, void **argStack) @@ -235,7 +236,7 @@ void *Callback(DHooksCallback *dg, void **argStack) Handle_t rHndl; Handle_t pHndl; - #ifndef __linux__ + #ifdef WIN32 *argsizep = GetStackArgsSize(dg); #else size_t argsize = GetStackArgsSize(dg); @@ -262,7 +263,7 @@ void *Callback(DHooksCallback *dg, void **argStack) dg->plugin_callback->PushCell(rHndl); } - #ifndef __linux__ + #ifdef WIN32 if(*argsizep > 0) { paramStruct = GetParamStruct(dg, argStack, *argsizep); @@ -380,7 +381,7 @@ void *Callback(DHooksCallback *dg, void **argStack) } return ret; } -#ifndef __linux__ +#ifdef WIN32 float Callback_float(DHooksCallback *dg, void **argStack, size_t *argsizep) #else float Callback_float(DHooksCallback *dg, void **argStack) @@ -391,7 +392,7 @@ float Callback_float(DHooksCallback *dg, void **argStack) Handle_t rHndl; Handle_t pHndl; - #ifndef __linux__ + #ifdef WIN32 *argsizep = GetStackArgsSize(dg); #else size_t argsize = GetStackArgsSize(dg); @@ -417,7 +418,7 @@ float Callback_float(DHooksCallback *dg, void **argStack) } dg->plugin_callback->PushCell(rHndl); - #ifndef __linux__ + #ifdef WIN32 if(*argsizep > 0) { paramStruct = GetParamStruct(dg, argStack, *argsizep); @@ -534,7 +535,7 @@ float Callback_float(DHooksCallback *dg, void **argStack) } return *(float *)ret; } -#ifndef __linux__ +#ifdef WIN32 Vector *Callback_vector(DHooksCallback *dg, void **argStack, size_t *argsizep) #else Vector *Callback_vector(DHooksCallback *dg, void **argStack) @@ -547,7 +548,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack) Handle_t rHndl; Handle_t pHndl; - #ifndef __linux__ + #ifdef WIN32 *argsizep = GetStackArgsSize(dg); #else size_t argsize = GetStackArgsSize(dg); @@ -573,7 +574,7 @@ Vector *Callback_vector(DHooksCallback *dg, void **argStack) } dg->plugin_callback->PushCell(rHndl); - #ifndef __linux__ + #ifdef WIN32 if(*argsizep > 0) { paramStruct = GetParamStruct(dg, argStack, *argsizep); diff --git a/vhook.h b/vhook.h index 5cad268..7867bbd 100644 --- a/vhook.h +++ b/vhook.h @@ -126,7 +126,7 @@ public: class DHooksInfo { public: - CUtlVector params; + SourceHook::CVector params; int offset; unsigned int returnFlag; ReturnType returnType; @@ -154,7 +154,7 @@ public: void **oldvtable; }; -#ifndef __linux__ +#ifdef WIN32 void *Callback(DHooksCallback *dg, void **stack, size_t *argsizep); float Callback_float(DHooksCallback *dg, void **stack, size_t *argsizep); Vector *Callback_vector(DHooksCallback *dg, void **stack, size_t *argsizep); @@ -164,12 +164,13 @@ float Callback_float(DHooksCallback *dg, void **stack); Vector *Callback_vector(DHooksCallback *dg, void **stack); string_t *Callback_stringt(DHooksCallback *dg, void **stack); #endif + bool SetupHookManager(ISmmAPI *ismm); -void CleanupHooks(IPluginContext *pContext); +void CleanupHooks(IPluginContext *pContext = NULL); size_t GetParamTypeSize(HookParamType type); SourceHook::PassInfo::PassType GetParamTypePassType(HookParamType type); -#ifdef __linux__ +#ifndef WIN32 static void *GenerateThunk(ReturnType type) { MacroAssemblerX86 masm; @@ -293,20 +294,20 @@ public: } if(this->newParams != NULL) { - for(int i = dg->params.Count() - 1; i >= 0 ; i--) + for(int i = dg->params.size() - 1; i >= 0 ; i--) { if(this->newParams[i] == NULL) continue; - if(dg->params.Element(i).type == HookParamType_VectorPtr) + if(dg->params.at(i).type == HookParamType_VectorPtr) { delete (Vector *)this->newParams[i]; } - else if(dg->params.Element(i).type == HookParamType_CharPtr) + else if(dg->params.at(i).type == HookParamType_CharPtr) { delete (char *)this->newParams[i]; } - else if(dg->params.Element(i).type == HookParamType_Float) + else if(dg->params.at(i).type == HookParamType_Float) { delete (float *)this->newParams[i]; } @@ -339,7 +340,7 @@ public: ReturnType returnType; HookType hookType; ThisPointerType thisType; - CUtlVector params; + SourceHook::CVector params; int offset; IPluginFunction *callback; }; @@ -358,6 +359,10 @@ public: this->remove_callback->PushCell(this->hookid); this->remove_callback->Execute(NULL); } + if(this->pManager) + { + g_pHookManager->ReleaseHookMan(this->pManager); + } } } public: @@ -365,6 +370,7 @@ public: int hookid; DHooksCallback *callback; IPluginFunction *remove_callback; + SourceHook::HookManagerPubFunc pManager; }; size_t GetStackArgsSize(DHooksCallback *dg);