mirror of
https://github.com/srcdslab/sm-ext-cssfixes.git
synced 2025-12-07 10:38:24 +00:00
Merge 84149c4df2 into ee41205361
This commit is contained in:
commit
dce4e4231d
42
.github/workflows/ci.yml
vendored
42
.github/workflows/ci.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04]
|
os: [ubuntu-20.04]
|
||||||
sourcemod-version: [1.11-dev]
|
sourcemod-version: [master]
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-20.04
|
||||||
target-archs: x86,x86_64
|
target-archs: x86,x86_64
|
||||||
@ -24,15 +24,16 @@ jobs:
|
|||||||
sudo apt install -yq --no-install-recommends g++-multilib
|
sudo apt install -yq --no-install-recommends g++-multilib
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v5
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
submodules: recursive
|
||||||
path: extension
|
path: extension
|
||||||
|
|
||||||
- name: Checkout SourceMod
|
- name: Checkout SourceMod
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: alliedmodders/sourcemod
|
repository: alliedmodders/sourcemod
|
||||||
ref: ${{ matrix.sourcemod-version }}
|
ref: ${{ matrix.sourcemod-version }}
|
||||||
@ -40,20 +41,20 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Checkout AMBuild
|
- name: Checkout AMBuild
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: alliedmodders/ambuild
|
repository: alliedmodders/ambuild
|
||||||
path: ambuild
|
path: ambuild
|
||||||
|
|
||||||
- name: Checkout sm-ext-common
|
- name: Checkout sm-ext-common
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: srcdslab/sm-ext-common
|
repository: srcdslab/sm-ext-common
|
||||||
path: sourcemod/extensions/sm-ext-common
|
path: sourcemod/extensions/sm-ext-common
|
||||||
|
|
||||||
- name: Install sourcemod dependencies
|
- name: Install sourcemod dependencies
|
||||||
run: |
|
run: |
|
||||||
bash sourcemod/tools/checkout-deps.sh -m -s ${{ matrix.sdks }}
|
bash sourcemod/tools/checkout-deps.sh -m -s "${{ matrix.sdks }}"
|
||||||
|
|
||||||
- name: Install AMBuild
|
- name: Install AMBuild
|
||||||
uses: BSFishy/pip-action@v1
|
uses: BSFishy/pip-action@v1
|
||||||
@ -67,15 +68,26 @@ jobs:
|
|||||||
BREAKPAD_SYMBOL_SERVER: ${{ secrets.BREAKPAD_SYMBOL_SERVER }}
|
BREAKPAD_SYMBOL_SERVER: ${{ secrets.BREAKPAD_SYMBOL_SERVER }}
|
||||||
run: |
|
run: |
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
python ../configure.py --enable-optimize --targets=${{ matrix.target-archs }} --sdks=${{ matrix.sdks }}
|
python ../configure.py --enable-optimize --targets=${{ matrix.target-archs }} --sdks="${{ matrix.sdks }}"
|
||||||
ambuild
|
ambuild
|
||||||
|
|
||||||
|
- name: Prepare artifact structure
|
||||||
|
run: |
|
||||||
|
# linux-x86_64
|
||||||
|
mkdir -p artifact/linux-x86_64/addons/sourcemod/extensions
|
||||||
|
cp -r extension/addons/sourcemod/* artifact/linux-x86_64/addons/sourcemod/
|
||||||
|
cp extension/build/CSSFixes.ext.2.css/linux-x86_64/CSSFixes.ext.2.css.so artifact/linux-x86_64/addons/sourcemod/extensions/
|
||||||
|
# linux-x86
|
||||||
|
mkdir -p artifact/linux-x86/addons/sourcemod/extensions
|
||||||
|
cp -r extension/addons/sourcemod/* artifact/linux-x86/addons/sourcemod/
|
||||||
|
cp extension/build/CSSFixes.ext.2.css/linux-x86/CSSFixes.ext.2.css.so artifact/linux-x86/addons/sourcemod/extensions/
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ runner.os }}
|
name: CSSFixes
|
||||||
path: extension/build/package
|
path: artifact/**
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
@ -85,22 +97,22 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
run: |
|
run: |
|
||||||
version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`
|
version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`
|
||||||
if [ -d "./Linux/" ]; then
|
if [ -d "./Linux/" ]; then
|
||||||
cd ./Linux/
|
cd ./Linux/
|
||||||
tar -czf ../${{ github.event.repository.name }}-${version}-linux.tar.gz -T <(\ls -1)
|
tar -czf ../${{ github.event.repository.name }}-${version}-linux.tar.gz -T <(\ls -)
|
||||||
fi
|
fi
|
||||||
if [ -d "./macOS/" ]; then
|
if [ -d "./macOS/" ]; then
|
||||||
cd ./macOS/
|
cd ./macOS/
|
||||||
tar -czf ../${{ github.event.repository.name }}-${version}-mac.tar.gz -T <(\ls -1)
|
tar -czf ../${{ github.event.repository.name }}-${version}-mac.tar.gz -T <(\ls -)
|
||||||
fi
|
fi
|
||||||
if [ -d "./Windows/" ]; then
|
if [ -d "./Windows/" ]; then
|
||||||
cd ./Windows/
|
cd ./Windows/
|
||||||
tar -czf ../${{ github.event.repository.name }}-${version}-windows.tar.gz -T <(\ls -1)
|
tar -czf ../${{ github.event.repository.name }}-${version}-windows.tar.gz -T <(\ls -)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
|
|||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*build/
|
||||||
|
*vs
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "hl2sdk-manifests"]
|
||||||
|
path = hl2sdk-manifests
|
||||||
|
url = https://github.com/alliedmodders/hl2sdk-manifests
|
||||||
491
AMBuildScript
491
AMBuildScript
@ -1,39 +1,5 @@
|
|||||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||||
import os, sys
|
import os
|
||||||
import traceback
|
|
||||||
|
|
||||||
class SDK(object):
|
|
||||||
def __init__(self, sdk, ext, aDef, name, platform, dir):
|
|
||||||
self.folder = 'hl2sdk-' + dir
|
|
||||||
self.envvar = sdk
|
|
||||||
self.ext = ext
|
|
||||||
self.code = aDef
|
|
||||||
self.define = name
|
|
||||||
self.platform = platform
|
|
||||||
self.name = dir
|
|
||||||
self.path = None # Actual path
|
|
||||||
self.platformSpec = platform
|
|
||||||
|
|
||||||
# By default, nothing supports x64.
|
|
||||||
if type(platform) is list:
|
|
||||||
self.platformSpec = {p: ['x86'] for p in platform}
|
|
||||||
else:
|
|
||||||
self.platformSpec = platform
|
|
||||||
|
|
||||||
def shouldBuild(self, targets):
|
|
||||||
for cxx in targets:
|
|
||||||
if cxx.target.platform in self.platformSpec:
|
|
||||||
if cxx.target.arch in self.platformSpec[cxx.target.platform]:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
WinOnly = ['windows']
|
|
||||||
WinLinux = ['windows', 'linux']
|
|
||||||
WinLinuxMac = ['windows', 'linux', 'mac']
|
|
||||||
|
|
||||||
PossibleSDKs = {
|
|
||||||
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
|
|
||||||
}
|
|
||||||
|
|
||||||
def ResolveEnvPath(env, folder):
|
def ResolveEnvPath(env, folder):
|
||||||
if env in os.environ:
|
if env in os.environ:
|
||||||
@ -64,30 +30,43 @@ def SetArchFlags(compiler):
|
|||||||
if compiler.target.arch == 'x86_64':
|
if compiler.target.arch == 'x86_64':
|
||||||
compiler.defines += ['WIN64']
|
compiler.defines += ['WIN64']
|
||||||
|
|
||||||
|
hl2sdk_manifests_path = None
|
||||||
|
|
||||||
|
# First we check if the manifest exists in the current path
|
||||||
|
hl2sdk_manifests_path = os.path.join(builder.sourcePath, 'hl2sdk-manifests/SdkHelpers.ambuild')
|
||||||
|
|
||||||
|
if not os.path.exists(hl2sdk_manifests_path):
|
||||||
|
# manifests does not exists in the project file, use the path from --hl2sdk-manifest-path
|
||||||
|
if not builder.options.hl2sdk_manifest:
|
||||||
|
raise Exception('HL2SDK Manifest root path not set! (--hl2sdk-manifest-path)')
|
||||||
|
else:
|
||||||
|
hl2sdk_manifests_path = os.path.join(builder.options.hl2sdk_manifest, 'SdkHelpers.ambuild')
|
||||||
|
|
||||||
|
if not os.path.exists(hl2sdk_manifests_path):
|
||||||
|
raise Exception('Could not find SdkHelpers.ambuild in the given HL2SDK Manifest path!')
|
||||||
|
|
||||||
|
|
||||||
|
SdkHelpers = builder.Eval(hl2sdk_manifests_path, {
|
||||||
|
'Project': 'sm-extension'
|
||||||
|
})
|
||||||
|
|
||||||
class ExtensionConfig(object):
|
class ExtensionConfig(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.sdk_manifests = []
|
||||||
self.sdks = {}
|
self.sdks = {}
|
||||||
self.binaries = []
|
self.sdk_targets = []
|
||||||
self.spvm = []
|
|
||||||
self.extensions = []
|
self.extensions = []
|
||||||
self.generated_headers = None
|
self.generated_headers = None
|
||||||
self.sm_root = None
|
|
||||||
self.mms_root = None
|
self.mms_root = None
|
||||||
self.mysql_root = {}
|
self.sm_root = None
|
||||||
self.spcomp = None
|
|
||||||
self.spcomp_bins = None
|
|
||||||
self.smx_files = {}
|
|
||||||
self.versionlib = None
|
|
||||||
self.all_targets = []
|
self.all_targets = []
|
||||||
self.target_archs = set()
|
self.target_archs = set()
|
||||||
|
self.libsafetyhook = {}
|
||||||
|
|
||||||
if builder.options.targets:
|
if builder.options.targets:
|
||||||
target_archs = builder.options.targets.split(',')
|
target_archs = builder.options.targets.split(',')
|
||||||
else:
|
else:
|
||||||
target_archs = ['x86']
|
target_archs = ['x86', 'x86_64']
|
||||||
if builder.backend != 'amb2':
|
|
||||||
target_archs.append('x86_64')
|
|
||||||
|
|
||||||
for arch in target_archs:
|
for arch in target_archs:
|
||||||
try:
|
try:
|
||||||
@ -104,82 +83,73 @@ class ExtensionConfig(object):
|
|||||||
if not self.all_targets:
|
if not self.all_targets:
|
||||||
raise Exception('No suitable C/C++ compiler was found.')
|
raise Exception('No suitable C/C++ compiler was found.')
|
||||||
|
|
||||||
|
def use_auto_versioning(self):
|
||||||
|
if builder.backend != 'amb2':
|
||||||
|
return False
|
||||||
|
return not getattr(builder.options, 'disable_auto_versioning', False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag(self):
|
def tag(self):
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
return 'Debug'
|
return 'Debug'
|
||||||
return 'Release'
|
return 'Release'
|
||||||
|
|
||||||
def detectProductVersion(self):
|
def findSdkPath(self, sdk_name):
|
||||||
builder.AddConfigureFile('product.version')
|
dir_name = 'hl2sdk-{}'.format(sdk_name)
|
||||||
|
if builder.options.hl2sdk_root:
|
||||||
|
sdk_path = os.path.join(builder.options.hl2sdk_root, dir_name)
|
||||||
|
if os.path.exists(sdk_path):
|
||||||
|
return sdk_path
|
||||||
|
return ResolveEnvPath('HL2SDK{}'.format(sdk_name.upper()), dir_name)
|
||||||
|
|
||||||
# For OS X dylib versioning
|
def shouldIncludeSdk(self, sdk):
|
||||||
import re
|
return not sdk.get('source2', False)
|
||||||
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)
|
|
||||||
|
|
||||||
def detectSDKs(self):
|
def detectSDKs(self):
|
||||||
sdk_list = builder.options.sdks.split(',')
|
sdk_list = [s for s in builder.options.sdks.split(',') if s]
|
||||||
use_none = sdk_list[0] == 'none'
|
SdkHelpers.sdk_filter = self.shouldIncludeSdk
|
||||||
use_all = sdk_list[0] == 'all'
|
SdkHelpers.find_sdk_path = self.findSdkPath
|
||||||
use_present = sdk_list[0] == 'present'
|
SdkHelpers.findSdks(builder, self.all_targets, sdk_list)
|
||||||
|
|
||||||
for sdk_name in PossibleSDKs:
|
self.sdks = SdkHelpers.sdks
|
||||||
sdk = PossibleSDKs[sdk_name]
|
self.sdk_manifests = SdkHelpers.sdk_manifests
|
||||||
if sdk.shouldBuild(self.all_targets):
|
self.sdk_targets = SdkHelpers.sdk_targets
|
||||||
if builder.options.hl2sdk_root:
|
|
||||||
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
|
|
||||||
else:
|
|
||||||
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
|
|
||||||
if sdk_path is None or not os.path.isdir(sdk_path):
|
|
||||||
if use_all or sdk_name in sdk_list:
|
|
||||||
raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
|
|
||||||
continue
|
|
||||||
if use_all or use_present or sdk_name in sdk_list:
|
|
||||||
sdk.path = Normalize(sdk_path)
|
|
||||||
self.sdks[sdk_name] = sdk
|
|
||||||
|
|
||||||
if len(self.sdks) < 1 and len(sdk_list) and not use_none:
|
|
||||||
raise Exception('No applicable SDKs were found, nothing to do')
|
|
||||||
|
|
||||||
if builder.options.sm_path:
|
|
||||||
self.sm_root = builder.options.sm_path
|
|
||||||
else:
|
|
||||||
self.sm_root = ResolveEnvPath('SOURCEMOD18', 'sourcemod-1.10')
|
|
||||||
if not self.sm_root:
|
|
||||||
self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod-source')
|
|
||||||
if not self.sm_root:
|
|
||||||
self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod-central')
|
|
||||||
if not self.sm_root:
|
|
||||||
self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod')
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
if builder.options.mms_path:
|
if builder.options.mms_path:
|
||||||
self.mms_root = builder.options.mms_path
|
self.mms_root = builder.options.mms_path
|
||||||
else:
|
else:
|
||||||
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
|
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
|
||||||
|
if not self.mms_root:
|
||||||
|
self.mms_root = ResolveEnvPath('MMSOURCE', 'metamod-source')
|
||||||
if not self.mms_root:
|
if not self.mms_root:
|
||||||
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
|
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
|
||||||
if not self.mms_root:
|
if not self.mms_root:
|
||||||
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
|
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
|
||||||
if not self.mms_root:
|
|
||||||
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod')
|
|
||||||
|
|
||||||
if not self.mms_root or not os.path.isdir(self.mms_root):
|
if not self.mms_root or not os.path.isdir(self.mms_root):
|
||||||
raise Exception('Could not find a source copy of Metamod:Source')
|
raise Exception('Could not find a source copy of Metamod:Source')
|
||||||
self.mms_root = Normalize(self.mms_root)
|
self.mms_root = Normalize(self.mms_root)
|
||||||
|
|
||||||
|
if builder.options.sm_path:
|
||||||
|
self.sm_root = builder.options.sm_path
|
||||||
|
else:
|
||||||
|
self.sm_root = ResolveEnvPath('SOURCEMOD112', 'sourcemod-1.12')
|
||||||
|
if not self.sm_root:
|
||||||
|
self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod')
|
||||||
|
if not self.sm_root:
|
||||||
|
self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod')
|
||||||
|
if not self.sm_root:
|
||||||
|
self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod-central')
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
if not set(self.target_archs).issubset(['x86', 'x86_64']):
|
|
||||||
|
allowed_archs = ['x86','x86_64']
|
||||||
|
|
||||||
|
if not set(self.target_archs).issubset(allowed_archs):
|
||||||
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
|
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
|
||||||
|
|
||||||
for cxx in self.all_targets:
|
for cxx in self.all_targets:
|
||||||
@ -187,21 +157,21 @@ class ExtensionConfig(object):
|
|||||||
|
|
||||||
def configure_cxx(self, cxx):
|
def configure_cxx(self, cxx):
|
||||||
if cxx.family == 'msvc':
|
if cxx.family == 'msvc':
|
||||||
if cxx.version < 1900:
|
if cxx.version < 1914 and builder.options.generator != 'vs':
|
||||||
raise Exception('Only MSVC 2015 and later are supported, c++14 support is required.')
|
raise Exception(f'Only MSVC 2017 15.7 and later are supported, full C++17 support is required. ({str(cxx.version)} < 1914)')
|
||||||
if cxx.family == 'gcc':
|
elif cxx.family == 'gcc':
|
||||||
if cxx.version < 'gcc-4.9':
|
if cxx.version < 'gcc-8':
|
||||||
raise Exception('Only GCC versions 4.9 or greater are supported, c++14 support is required.')
|
raise Exception('Only GCC versions 8 or later are supported, full C++17 support is required.')
|
||||||
if cxx.family == 'clang':
|
elif cxx.family == 'clang':
|
||||||
if cxx.version < 'clang-3.4':
|
if cxx.version < 'clang-5':
|
||||||
raise Exception('Only clang versions 3.4 or greater are supported, c++14 support is required.')
|
raise Exception('Only clang versions 5 or later are supported, full C++17 support is required.')
|
||||||
|
|
||||||
if cxx.like('gcc'):
|
if cxx.like('gcc'):
|
||||||
self.configure_gcc(cxx)
|
self.configure_gcc(cxx)
|
||||||
elif cxx.family == 'msvc':
|
elif cxx.family == 'msvc':
|
||||||
self.configure_msvc(cxx)
|
self.configure_msvc(cxx)
|
||||||
|
|
||||||
# Optimizaiton
|
# Optimization
|
||||||
if builder.options.opt == '1':
|
if builder.options.opt == '1':
|
||||||
cxx.defines += ['NDEBUG']
|
cxx.defines += ['NDEBUG']
|
||||||
|
|
||||||
@ -217,11 +187,6 @@ class ExtensionConfig(object):
|
|||||||
elif cxx.target.platform == 'windows':
|
elif cxx.target.platform == 'windows':
|
||||||
self.configure_windows(cxx)
|
self.configure_windows(cxx)
|
||||||
|
|
||||||
# Finish up.
|
|
||||||
cxx.includes += [
|
|
||||||
os.path.join(self.sm_root, 'public'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def configure_gcc(self, cxx):
|
def configure_gcc(self, cxx):
|
||||||
cxx.defines += [
|
cxx.defines += [
|
||||||
'stricmp=strcasecmp',
|
'stricmp=strcasecmp',
|
||||||
@ -239,50 +204,31 @@ class ExtensionConfig(object):
|
|||||||
'-Wno-unused',
|
'-Wno-unused',
|
||||||
'-Wno-switch',
|
'-Wno-switch',
|
||||||
'-Wno-array-bounds',
|
'-Wno-array-bounds',
|
||||||
'-msse',
|
|
||||||
'-fvisibility=hidden',
|
'-fvisibility=hidden',
|
||||||
]
|
]
|
||||||
|
|
||||||
if cxx.version == 'apple-clang-6.0' or cxx.version == 'clang-3.4':
|
if cxx.target.arch in ['x86', 'x86_64']:
|
||||||
cxx.cxxflags += ['-std=c++1y']
|
cxx.cflags += ['-msse']
|
||||||
else:
|
|
||||||
cxx.cxxflags += ['-std=c++14']
|
|
||||||
|
|
||||||
cxx.cxxflags += [
|
cxx.cxxflags += [
|
||||||
'-fno-threadsafe-statics',
|
'-fno-threadsafe-statics',
|
||||||
'-Wno-non-virtual-dtor',
|
'-Wno-non-virtual-dtor',
|
||||||
'-Wno-overloaded-virtual',
|
'-Wno-overloaded-virtual',
|
||||||
|
'-Wno-register',
|
||||||
'-fvisibility-inlines-hidden',
|
'-fvisibility-inlines-hidden',
|
||||||
|
'-std=c++17',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
have_gcc = cxx.family == 'gcc'
|
have_gcc = cxx.family == 'gcc'
|
||||||
have_clang = cxx.family == 'clang'
|
have_clang = cxx.family == 'clang'
|
||||||
if cxx.version >= 'clang-3.9' or cxx.version == 'clang-3.4' or cxx.version > 'apple-clang-6.0':
|
|
||||||
cxx.cxxflags += ['-Wno-expansion-to-defined']
|
# Work around errors from smsdk_ext.cpp
|
||||||
if cxx.version == 'clang-3.9' or cxx.version == 'apple-clang-8.0':
|
|
||||||
cxx.cflags += ['-Wno-varargs']
|
|
||||||
if cxx.version >= 'clang-3.4' or cxx.version >= 'apple-clang-7.0':
|
|
||||||
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
|
||||||
if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0':
|
|
||||||
cxx.cxxflags += ['-Wno-null-dereference']
|
|
||||||
if have_clang or (cxx.version >= 'gcc-4.6'):
|
|
||||||
cxx.cflags += ['-Wno-narrowing']
|
|
||||||
if have_clang or (cxx.version >= 'gcc-4.7'):
|
|
||||||
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
|
||||||
if cxx.version >= 'gcc-4.8':
|
|
||||||
cxx.cflags += ['-Wno-unused-result']
|
|
||||||
if cxx.version >= 'gcc-9.0':
|
|
||||||
cxx.cxxflags += ['-Wno-class-memaccess', '-Wno-packed-not-aligned']
|
|
||||||
if have_clang:
|
if have_clang:
|
||||||
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
||||||
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
|
||||||
cxx.cxxflags += ['-Wno-deprecated-register']
|
|
||||||
else:
|
|
||||||
cxx.cxxflags += ['-Wno-deprecated']
|
|
||||||
cxx.cflags += ['-Wno-sometimes-uninitialized']
|
|
||||||
|
|
||||||
# Work around SDK warnings.
|
# Work around SDK warnings.
|
||||||
if cxx.version >= 'clang-10.0':
|
if cxx.version >= 'clang-10.0' or cxx.version >= 'apple-clang-12.0':
|
||||||
cxx.cflags += [
|
cxx.cflags += [
|
||||||
'-Wno-implicit-int-float-conversion',
|
'-Wno-implicit-int-float-conversion',
|
||||||
'-Wno-tautological-overlap-compare',
|
'-Wno-tautological-overlap-compare',
|
||||||
@ -293,20 +239,13 @@ class ExtensionConfig(object):
|
|||||||
cxx.cflags += ['-Wno-maybe-uninitialized']
|
cxx.cflags += ['-Wno-maybe-uninitialized']
|
||||||
|
|
||||||
if builder.options.opt == '1':
|
if builder.options.opt == '1':
|
||||||
cxx.cflags += [
|
cxx.cflags += ['-O3']
|
||||||
'-O3',
|
|
||||||
'-fexperimental-new-pass-manager',
|
|
||||||
'-mllvm',
|
|
||||||
'-inline-threshold=1000',
|
|
||||||
'-mllvm',
|
|
||||||
'-vectorize-loops',
|
|
||||||
'-ftree-vectorize',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Don't omit the frame pointer.
|
# Don't omit the frame pointer.
|
||||||
cxx.cflags += ['-fno-omit-frame-pointer']
|
cxx.cflags += ['-fno-omit-frame-pointer']
|
||||||
|
|
||||||
def configure_msvc(self, cxx):
|
def configure_msvc(self, cxx):
|
||||||
|
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
cxx.cflags += ['/MTd']
|
cxx.cflags += ['/MTd']
|
||||||
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||||
@ -325,6 +264,7 @@ class ExtensionConfig(object):
|
|||||||
'/EHsc',
|
'/EHsc',
|
||||||
'/GR-',
|
'/GR-',
|
||||||
'/TP',
|
'/TP',
|
||||||
|
'/std:c++17',
|
||||||
]
|
]
|
||||||
cxx.linkflags += [
|
cxx.linkflags += [
|
||||||
'kernel32.lib',
|
'kernel32.lib',
|
||||||
@ -353,7 +293,7 @@ class ExtensionConfig(object):
|
|||||||
cxx.cflags += ['/Oy-']
|
cxx.cflags += ['/Oy-']
|
||||||
|
|
||||||
def configure_linux(self, cxx):
|
def configure_linux(self, cxx):
|
||||||
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
|
cxx.defines += ['LINUX', '_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
|
||||||
cxx.linkflags += ['-lm']
|
cxx.linkflags += ['-lm']
|
||||||
if cxx.family == 'gcc':
|
if cxx.family == 'gcc':
|
||||||
cxx.linkflags += ['-static-libgcc']
|
cxx.linkflags += ['-static-libgcc']
|
||||||
@ -363,9 +303,9 @@ class ExtensionConfig(object):
|
|||||||
|
|
||||||
def configure_mac(self, cxx):
|
def configure_mac(self, cxx):
|
||||||
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
||||||
cxx.cflags += ['-mmacosx-version-min=10.7']
|
cxx.cflags += ['-mmacosx-version-min=10.15']
|
||||||
cxx.linkflags += [
|
cxx.linkflags += [
|
||||||
'-mmacosx-version-min=10.7',
|
'-mmacosx-version-min=10.15',
|
||||||
'-stdlib=libc++',
|
'-stdlib=libc++',
|
||||||
'-lc++',
|
'-lc++',
|
||||||
]
|
]
|
||||||
@ -373,70 +313,20 @@ class ExtensionConfig(object):
|
|||||||
|
|
||||||
def configure_windows(self, cxx):
|
def configure_windows(self, cxx):
|
||||||
cxx.defines += ['WIN32', '_WINDOWS']
|
cxx.defines += ['WIN32', '_WINDOWS']
|
||||||
|
|
||||||
def add_libamtl(self):
|
|
||||||
# Add libamtl.
|
|
||||||
self.libamtl = {}
|
|
||||||
for cxx in self.all_targets:
|
|
||||||
def get_configure_fn(cxx):
|
|
||||||
return lambda builder, name: self.StaticLibrary(builder, cxx, name)
|
|
||||||
extra_vars = {'Configure': get_configure_fn(cxx)}
|
|
||||||
libamtl = builder.Build('public/amtl/amtl/AMBuilder', extra_vars)
|
|
||||||
self.libamtl[cxx.target.arch] = libamtl.binary
|
|
||||||
|
|
||||||
def AddVersioning(self, binary):
|
|
||||||
if binary.compiler.target.platform == 'windows':
|
|
||||||
binary.sources += ['version.rc']
|
|
||||||
binary.compiler.rcdefines += [
|
|
||||||
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
|
||||||
'RC_COMPILE',
|
|
||||||
]
|
|
||||||
elif binary.compiler.target.platform == 'mac':
|
|
||||||
if binary.type == 'library':
|
|
||||||
binary.compiler.postlink += [
|
|
||||||
'-compatibility_version', '1.0.0',
|
|
||||||
'-current_version', self.productVersion
|
|
||||||
]
|
|
||||||
return binary
|
|
||||||
|
|
||||||
def LibraryBuilder(self, compiler, name):
|
def LibraryBuilder(self, compiler, name):
|
||||||
binary = compiler.Library(name)
|
binary = compiler.Library(name)
|
||||||
self.AddVersioning(binary)
|
self.AddVersioning(binary)
|
||||||
if binary.compiler.like('msvc'):
|
if binary.compiler.like('msvc'):
|
||||||
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
|
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
|
||||||
|
self.AddCxxCompat(binary)
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
def ProgramBuilder(self, compiler, name):
|
|
||||||
binary = compiler.Program(name)
|
|
||||||
self.AddVersioning(binary)
|
|
||||||
if '-static-libgcc' in binary.compiler.linkflags:
|
|
||||||
binary.compiler.linkflags.remove('-static-libgcc')
|
|
||||||
if '-lgcc_eh' in binary.compiler.linkflags:
|
|
||||||
binary.compiler.linkflags.remove('-lgcc_eh')
|
|
||||||
if binary.compiler.like('gcc'):
|
|
||||||
binary.compiler.linkflags += ['-lstdc++', '-lpthread']
|
|
||||||
if binary.compiler.like('msvc'):
|
|
||||||
binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE']
|
|
||||||
return binary
|
|
||||||
|
|
||||||
def StaticLibraryBuilder(self, compiler, name):
|
|
||||||
return compiler.StaticLibrary(name)
|
|
||||||
|
|
||||||
def Library(self, context, compiler, name):
|
def Library(self, context, compiler, name):
|
||||||
compiler = compiler.clone()
|
compiler = compiler.clone()
|
||||||
SetArchFlags(compiler)
|
SetArchFlags(compiler)
|
||||||
return self.LibraryBuilder(compiler, name)
|
return self.LibraryBuilder(compiler, name)
|
||||||
|
|
||||||
def Program(self, context, compiler, name):
|
|
||||||
compiler = compiler.clone()
|
|
||||||
SetArchFlags(compiler)
|
|
||||||
return self.ProgramBuilder(compiler, name)
|
|
||||||
|
|
||||||
def StaticLibrary(self, context, compiler, name):
|
|
||||||
compiler = compiler.clone()
|
|
||||||
SetArchFlags(compiler)
|
|
||||||
return self.StaticLibraryBuilder(compiler, name)
|
|
||||||
|
|
||||||
def ConfigureForExtension(self, context, compiler):
|
def ConfigureForExtension(self, context, compiler):
|
||||||
compiler.cxxincludes += [
|
compiler.cxxincludes += [
|
||||||
os.path.join(context.currentSourcePath),
|
os.path.join(context.currentSourcePath),
|
||||||
@ -446,9 +336,27 @@ class ExtensionConfig(object):
|
|||||||
os.path.join(self.sm_root, 'sourcepawn', 'include'),
|
os.path.join(self.sm_root, 'sourcepawn', 'include'),
|
||||||
os.path.join(self.sm_root, 'public', 'amtl', 'amtl'),
|
os.path.join(self.sm_root, 'public', 'amtl', 'amtl'),
|
||||||
os.path.join(self.sm_root, 'public', 'amtl'),
|
os.path.join(self.sm_root, 'public', 'amtl'),
|
||||||
os.path.join(self.sm_root, 'extensions', 'sm-ext-common', 'include'),
|
|
||||||
]
|
]
|
||||||
return compiler
|
return compiler
|
||||||
|
|
||||||
|
def AddCDetour(self, binary):
|
||||||
|
public_path = os.path.join(self.sm_root, 'public')
|
||||||
|
binary.sources += [
|
||||||
|
os.path.join(public_path, 'CDetour', 'detours.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'allocator.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'easy.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'inline_hook.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'mid_hook.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'os.linux.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'utility.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'src', 'vmt_hook.cpp'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'zydis', 'Zydis.c')
|
||||||
|
]
|
||||||
|
|
||||||
|
binary.compiler.includes += [
|
||||||
|
os.path.join(public_path, 'safetyhook', 'include'),
|
||||||
|
os.path.join(public_path, 'safetyhook', 'zydis'),
|
||||||
|
]
|
||||||
|
|
||||||
def ExtLibrary(self, context, compiler, name):
|
def ExtLibrary(self, context, compiler, name):
|
||||||
binary = self.Library(context, compiler, name)
|
binary = self.Library(context, compiler, name)
|
||||||
@ -456,6 +364,12 @@ class ExtensionConfig(object):
|
|||||||
self.ConfigureForExtension(context, binary.compiler)
|
self.ConfigureForExtension(context, binary.compiler)
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
|
def AddCxxCompat(self, binary):
|
||||||
|
if binary.compiler.target.platform == 'linux':
|
||||||
|
binary.sources += [
|
||||||
|
os.path.join(self.sm_root, 'public', 'amtl', 'compat', 'stdcxx.cpp'),
|
||||||
|
]
|
||||||
|
|
||||||
def ConfigureForHL2(self, context, binary, sdk):
|
def ConfigureForHL2(self, context, binary, sdk):
|
||||||
compiler = binary.compiler
|
compiler = binary.compiler
|
||||||
SetArchFlags(compiler)
|
SetArchFlags(compiler)
|
||||||
@ -465,134 +379,10 @@ class ExtensionConfig(object):
|
|||||||
os.path.join(self.mms_root, 'core', 'sourcehook'),
|
os.path.join(self.mms_root, 'core', 'sourcehook'),
|
||||||
]
|
]
|
||||||
|
|
||||||
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
|
for other_sdk in self.sdk_manifests:
|
||||||
compiler.defines += defines
|
compiler.defines += ['SE_{}={}'.format(other_sdk['define'], other_sdk['code'])]
|
||||||
|
|
||||||
paths = [
|
SdkHelpers.configureCxx(context, binary, sdk)
|
||||||
['public'],
|
|
||||||
['public', 'engine'],
|
|
||||||
['public', 'mathlib'],
|
|
||||||
['public', 'vstdlib'],
|
|
||||||
['public', 'tier0'],
|
|
||||||
['public', 'tier1']
|
|
||||||
]
|
|
||||||
if sdk.name == 'episode1' or sdk.name == 'darkm':
|
|
||||||
paths.append(['public', 'dlls'])
|
|
||||||
paths.append(['game_shared'])
|
|
||||||
else:
|
|
||||||
paths.append(['public', 'game', 'server'])
|
|
||||||
paths.append(['public', 'toolframework'])
|
|
||||||
paths.append(['game', 'shared'])
|
|
||||||
paths.append(['common'])
|
|
||||||
|
|
||||||
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
|
|
||||||
|
|
||||||
if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'):
|
|
||||||
# The 2013 SDK already has these in public/tier0/basetypes.h
|
|
||||||
compiler.defines.remove('stricmp=strcasecmp')
|
|
||||||
compiler.defines.remove('_stricmp=strcasecmp')
|
|
||||||
compiler.defines.remove('_snprintf=snprintf')
|
|
||||||
compiler.defines.remove('_vsnprintf=vsnprintf')
|
|
||||||
|
|
||||||
if compiler.like('msvc'):
|
|
||||||
compiler.defines += ['COMPILER_MSVC']
|
|
||||||
if compiler.target.arch == 'x86':
|
|
||||||
compiler.defines += ['COMPILER_MSVC32']
|
|
||||||
elif compiler.target.arch == 'x86_64':
|
|
||||||
compiler.defines += ['COMPILER_MSVC64']
|
|
||||||
compiler.linkflags += ['legacy_stdio_definitions.lib']
|
|
||||||
else:
|
|
||||||
compiler.defines += ['COMPILER_GCC']
|
|
||||||
|
|
||||||
if compiler.target.arch == 'x86_64':
|
|
||||||
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']
|
|
||||||
|
|
||||||
# For everything after Swarm, this needs to be defined for entity networking
|
|
||||||
# to work properly with sendprop value changes.
|
|
||||||
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
|
|
||||||
compiler.defines += ['NETWORK_VARS_ENABLED']
|
|
||||||
|
|
||||||
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']:
|
|
||||||
if compiler.target.platform in ['linux', 'mac']:
|
|
||||||
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
|
|
||||||
|
|
||||||
if compiler.target.platform == 'linux':
|
|
||||||
if sdk.name in ['csgo', 'blade']:
|
|
||||||
compiler.linkflags.remove('-static-libstdc++')
|
|
||||||
compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
|
|
||||||
|
|
||||||
for path in paths:
|
|
||||||
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
|
|
||||||
|
|
||||||
if compiler.target.platform == 'linux':
|
|
||||||
if sdk.name == 'episode1':
|
|
||||||
lib_folder = os.path.join(sdk.path, 'linux_sdk')
|
|
||||||
elif sdk.name in ['sdk2013', 'bms']:
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
|
|
||||||
elif compiler.target.arch == 'x86_64':
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'linux64')
|
|
||||||
else:
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
|
|
||||||
elif compiler.target.platform == 'mac':
|
|
||||||
if sdk.name in ['sdk2013', 'bms']:
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
|
|
||||||
elif compiler.target.arch == 'x86_64':
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'osx64')
|
|
||||||
else:
|
|
||||||
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
|
|
||||||
|
|
||||||
if compiler.target.platform in ['linux', 'mac']:
|
|
||||||
if sdk.name in ['sdk2013', 'bms'] or compiler.target.arch == 'x86_64':
|
|
||||||
compiler.postlink += [
|
|
||||||
os.path.join(lib_folder, 'tier1.a'),
|
|
||||||
os.path.join(lib_folder, 'mathlib.a')
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
compiler.postlink += [
|
|
||||||
os.path.join(lib_folder, 'tier1_i486.a'),
|
|
||||||
os.path.join(lib_folder, 'mathlib_i486.a')
|
|
||||||
]
|
|
||||||
|
|
||||||
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
|
|
||||||
if compiler.target.arch == 'x86_64':
|
|
||||||
compiler.postlink += [os.path.join(lib_folder, 'interfaces.a')]
|
|
||||||
else:
|
|
||||||
compiler.postlink += [os.path.join(lib_folder, 'interfaces_i486.a')]
|
|
||||||
|
|
||||||
dynamic_libs = []
|
|
||||||
if compiler.target.platform == 'linux':
|
|
||||||
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']:
|
|
||||||
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
|
|
||||||
elif compiler.target.arch == 'x86_64' and sdk.name in ['csgo', 'blade']:
|
|
||||||
dynamic_libs = ['libtier0_client.so', 'libvstdlib_client.so']
|
|
||||||
elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo']:
|
|
||||||
dynamic_libs = ['libtier0.so', 'libvstdlib.so']
|
|
||||||
else:
|
|
||||||
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
|
|
||||||
elif compiler.target.platform == 'mac':
|
|
||||||
compiler.linkflags.append('-liconv')
|
|
||||||
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
|
|
||||||
elif compiler.target.platform == 'windows':
|
|
||||||
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
|
|
||||||
if sdk.name in ['swarm', 'blade', 'insurgency', 'doi', 'csgo']:
|
|
||||||
libs.append('interfaces')
|
|
||||||
for lib in libs:
|
|
||||||
if compiler.target.arch == 'x86':
|
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
|
|
||||||
elif compiler.target.arch == 'x86_64':
|
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'public', 'win64', lib) + '.lib'
|
|
||||||
compiler.linkflags.append(lib_path)
|
|
||||||
|
|
||||||
for library in dynamic_libs:
|
|
||||||
source_path = os.path.join(lib_folder, library)
|
|
||||||
output_path = os.path.join(binary.localFolder, library)
|
|
||||||
|
|
||||||
# Ensure the output path exists.
|
|
||||||
context.AddFolder(binary.localFolder)
|
|
||||||
output = context.AddSymlink(source_path, output_path)
|
|
||||||
|
|
||||||
compiler.weaklinkdeps += [output]
|
|
||||||
compiler.linkflags[0:0] = [library]
|
|
||||||
|
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
@ -601,43 +391,32 @@ class ExtensionConfig(object):
|
|||||||
self.ConfigureForExtension(context, binary.compiler)
|
self.ConfigureForExtension(context, binary.compiler)
|
||||||
return self.ConfigureForHL2(context, binary, sdk)
|
return self.ConfigureForHL2(context, binary, sdk)
|
||||||
|
|
||||||
def HL2Project(self, context, compiler, name):
|
|
||||||
project = context.LibraryProject(name)
|
|
||||||
self.ConfigureForExtension(context, compiler)
|
|
||||||
return project
|
|
||||||
|
|
||||||
def HL2Config(self, project, context, compiler, name, sdk):
|
def HL2Config(self, project, context, compiler, name, sdk):
|
||||||
binary = project.Configure(compiler, name,
|
binary = project.Configure(compiler, name,
|
||||||
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
|
||||||
self.AddVersioning(binary)
|
self.AddCxxCompat(binary)
|
||||||
return self.ConfigureForHL2(context, binary, sdk)
|
return self.ConfigureForHL2(context, binary, sdk)
|
||||||
|
|
||||||
def HL2ExtConfig(self, project, context, compiler, name, sdk):
|
def HL2ExtConfig(self, project, context, compiler, name, sdk):
|
||||||
binary = project.Configure(compiler, name,
|
binary = project.Configure(compiler, name,
|
||||||
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
|
||||||
self.AddVersioning(binary)
|
self.AddCxxCompat(binary)
|
||||||
self.ConfigureForHL2(context, binary, sdk)
|
self.ConfigureForHL2(context, binary, sdk)
|
||||||
self.ConfigureForExtension(context, binary.compiler)
|
self.ConfigureForExtension(context, binary.compiler)
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
if getattr(builder, 'target', None) is not None:
|
Extension = ExtensionConfig()
|
||||||
sys.stderr.write("Your output folder was configured for AMBuild 2.1, and SourceMod is now\n")
|
Extension.detectSDKs()
|
||||||
sys.stderr.write("configured to use AMBuild 2.2. Please remove your output folder and\n")
|
Extension.configure()
|
||||||
sys.stderr.write("reconfigure to continue.\n")
|
|
||||||
os._exit(1)
|
|
||||||
|
|
||||||
SM = ExtensionConfig()
|
|
||||||
SM.detectSDKs()
|
|
||||||
SM.configure()
|
|
||||||
|
|
||||||
# This will clone the list and each cxx object as we recurse, preventing child
|
# This will clone the list and each cxx object as we recurse, preventing child
|
||||||
# scripts from messing up global state.
|
# scripts from messing up global state.
|
||||||
builder.targets = builder.CloneableList(SM.all_targets)
|
builder.targets = builder.CloneableList(Extension.all_targets)
|
||||||
|
|
||||||
if builder.backend == 'amb2':
|
BuildScripts = [
|
||||||
BuildScripts = [
|
'AMBuilder',
|
||||||
'AMBuilder',
|
'PackageScript',
|
||||||
'PackageScript',
|
]
|
||||||
]
|
|
||||||
|
builder.Build(BuildScripts, { 'Extension': Extension })
|
||||||
|
|
||||||
builder.Build(BuildScripts, { 'SM': SM})
|
|
||||||
|
|||||||
62
AMBuilder
62
AMBuilder
@ -1,44 +1,36 @@
|
|||||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
if not "SM" in globals():
|
||||||
|
SM = Extension
|
||||||
|
|
||||||
projectName = 'CSSFixes'
|
projectName = 'CSSFixes'
|
||||||
|
|
||||||
for cxx in builder.targets:
|
project = builder.LibraryProject(projectName)
|
||||||
for sdk_name in SM.sdks:
|
project.sources += [
|
||||||
sdk = SM.sdks[sdk_name]
|
'extension.cpp',
|
||||||
|
os.path.join(SM.sm_root, 'public', 'smsdk_ext.cpp')
|
||||||
|
]
|
||||||
|
|
||||||
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
|
for sdk_name in SM.sdks:
|
||||||
|
sdk = SM.sdks[sdk_name]
|
||||||
|
if sdk['name'] in ['mock']:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for cxx in builder.targets:
|
||||||
|
cxx.defines += ['HAVE_STRING_H'];
|
||||||
|
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
binary = SM.HL2Library(builder, cxx, projectName + '.ext.' + sdk.ext, sdk)
|
binary = Extension.HL2ExtConfig(project, builder, cxx, projectName + '.ext.' + sdk['extension'], sdk)
|
||||||
|
|
||||||
|
SM.AddCDetour(binary)
|
||||||
|
|
||||||
|
binary.compiler.cxxflags += [
|
||||||
|
'-Wno-dangling-else',
|
||||||
|
'-Wno-unknown-pragmas',
|
||||||
|
'-Wno-unused-result',
|
||||||
|
'-Wno-sign-compare',
|
||||||
|
]
|
||||||
|
|
||||||
binary.compiler.defines += [
|
SM.extensions += builder.Add(project)
|
||||||
'HAVE_STRING_H',
|
|
||||||
]
|
|
||||||
|
|
||||||
if cxx.target.platform == 'linux':
|
|
||||||
cxx.postlink += ['-lpthread', '-lrt']
|
|
||||||
elif cxx.target.platform == 'mac':
|
|
||||||
cxx.cflags += ['-Wno-deprecated-declarations']
|
|
||||||
cxx.postlink += ['-framework', 'CoreServices']
|
|
||||||
|
|
||||||
if cxx.family == 'gcc' or cxx.family == 'clang':
|
|
||||||
cxx.cxxflags += ['-fno-rtti']
|
|
||||||
elif cxx.family == 'msvc':
|
|
||||||
cxx.cxxflags += ['/GR-']
|
|
||||||
|
|
||||||
binary.sources += [
|
|
||||||
'extension.cpp',
|
|
||||||
os.path.join(SM.sm_root, 'extensions', 'sm-ext-common', 'mathstubs.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'smsdk_ext.cpp'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'CDetour', 'detours.cpp'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'asm', 'asm.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'decode.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'itab.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'syn-att.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'syn-intel.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'syn.c'),
|
|
||||||
os.path.join(SM.sm_root, 'public', 'libudis86', 'udis86.c'),
|
|
||||||
]
|
|
||||||
|
|
||||||
SM.extensions += [builder.Add(binary)]
|
|
||||||
|
|||||||
@ -1,57 +1,27 @@
|
|||||||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||||
import os
|
import sys
|
||||||
|
from ambuild2 import run
|
||||||
|
|
||||||
# This is where the files will be output to
|
# Simple extensions do not need to modify this file.
|
||||||
# package is the default
|
|
||||||
builder.SetBuildFolder('package')
|
|
||||||
|
|
||||||
# Add any folders you need to this list
|
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
|
||||||
folder_list = [
|
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
||||||
'addons/sourcemod/extensions',
|
help='Root search folder for HL2SDKs')
|
||||||
'addons/sourcemod/scripting/include',
|
parser.options.add_argument('--hl2sdk-manifest-path', type=str, dest='hl2sdk_manifest', default=None,
|
||||||
'addons/sourcemod/gamedata'
|
help='Path to HL2SDK Manifests')
|
||||||
]
|
parser.options.add_argument('--sm-path', type=str, dest='sm_path', default=None,
|
||||||
|
help='Path to SourceMod')
|
||||||
|
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
|
||||||
|
help='Path to Metamod:Source')
|
||||||
|
|
||||||
if 'x86_64' in SM.target_archs:
|
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
|
||||||
folder_list.extend([
|
help='Enable debugging symbols')
|
||||||
'addons/sourcemod/extensions/x64',
|
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||||
])
|
help='Enable optimization')
|
||||||
|
parser.options.add_argument('-s', '--sdks', default='present', dest='sdks',
|
||||||
|
help='Build against specified SDKs; valid args are "none", "all", "present",'
|
||||||
|
' or comma-delimited list of engine names')
|
||||||
|
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
|
||||||
|
help="Override the target architecture (use commas to separate multiple targets).")
|
||||||
|
parser.Configure()
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# Copy binaries.
|
|
||||||
for cxx_task in SM.extensions:
|
|
||||||
if cxx_task.target.arch == 'x86_64':
|
|
||||||
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions/x64'])
|
|
||||||
else:
|
|
||||||
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions'])
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
dest_path = os.path.join(dest_entry.path, source_file)
|
|
||||||
if not os.path.isfile(str(dest_path)):
|
|
||||||
builder.AddCopy(source_path, dest_entry)
|
|
||||||
|
|
||||||
# Gamedata
|
|
||||||
CopyFiles('addons/sourcemod/gamedata', 'addons/sourcemod/gamedata',
|
|
||||||
[ 'CSSFixes.games.txt' ]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Include
|
|
||||||
CopyFiles('addons/sourcemod/scripting/include', 'addons/sourcemod/scripting/include',
|
|
||||||
[ 'CSSFixes.inc' ]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Autoload extension
|
|
||||||
CopyFiles('addons/sourcemod/extensions', 'addons/sourcemod/extensions',
|
|
||||||
[ 'CSSFixes.autoload' ]
|
|
||||||
)
|
|
||||||
|
|||||||
42
configure.py
42
configure.py
@ -1,39 +1,27 @@
|
|||||||
# vim: set ts=2 sw=2 tw=99 noet:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||||
import sys
|
import sys
|
||||||
try:
|
from ambuild2 import run
|
||||||
from ambuild2 import run, util
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import ambuild
|
|
||||||
sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
|
|
||||||
sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
|
|
||||||
except:
|
|
||||||
sys.stderr.write('AMBuild must be installed to build this project.\n')
|
|
||||||
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Hack to show a decent upgrade message, which wasn't done until 2.2.
|
# Simple extensions do not need to modify this file.
|
||||||
ambuild_version = getattr(run, 'CURRENT_API', '2.1')
|
|
||||||
if ambuild_version.startswith('2.1'):
|
|
||||||
sys.stderr.write("AMBuild 2.2 or higher is required; please update\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
parser = run.BuildParser(sourcePath = sys.path[0], api='2.2')
|
|
||||||
|
|
||||||
|
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
|
||||||
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
||||||
help='Root search folder for HL2SDKs')
|
help='Root search folder for HL2SDKs')
|
||||||
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
|
parser.options.add_argument('--hl2sdk-manifest-path', type=str, dest='hl2sdk_manifest', default=None,
|
||||||
help='Path to Metamod:Source')
|
help='Path to HL2SDK Manifests')
|
||||||
parser.options.add_argument('--sm-path', type=str, dest='sm_path', default=None,
|
parser.options.add_argument('--sm-path', type=str, dest='sm_path', default=None,
|
||||||
help='Path to SourceMod')
|
help='Path to SourceMod')
|
||||||
|
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
|
||||||
|
help='Path to Metamod:Source')
|
||||||
|
|
||||||
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
|
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
|
||||||
help='Enable debugging symbols')
|
help='Enable debugging symbols')
|
||||||
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
|
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||||
help='Enable optimization')
|
help='Enable optimization')
|
||||||
parser.options.add_argument('-s', '--sdks', default='all', dest='sdks',
|
parser.options.add_argument('-s', '--sdks', default='present', dest='sdks',
|
||||||
help='Build against specified SDKs; valid args are "all", "present", or '
|
help='Build against specified SDKs; valid args are "none", "all", "present",'
|
||||||
'comma-delimited list of engine names (default: %default)')
|
' or comma-delimited list of engine names')
|
||||||
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
|
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
|
||||||
help="Override the target architecture (use commas to separate multiple targets).")
|
help="Override the target architecture (use commas to separate multiple targets).")
|
||||||
|
|
||||||
parser.Configure()
|
parser.Configure()
|
||||||
|
|
||||||
|
|||||||
155
extension.cpp
155
extension.cpp
@ -40,6 +40,9 @@
|
|||||||
#include <utlvector.h>
|
#include <utlvector.h>
|
||||||
#include <string_t.h>
|
#include <string_t.h>
|
||||||
|
|
||||||
|
#define VPROF_ENABLED
|
||||||
|
#include <tier0/vprof.h>
|
||||||
|
|
||||||
#define SetBit(A,I) ((A)[(I) >> 5] |= (1 << ((I) & 31)))
|
#define SetBit(A,I) ((A)[(I) >> 5] |= (1 << ((I) & 31)))
|
||||||
#define ClearBit(A,I) ((A)[(I) >> 5] &= ~(1 << ((I) & 31)))
|
#define ClearBit(A,I) ((A)[(I) >> 5] &= ~(1 << ((I) & 31)))
|
||||||
#define CheckBit(A,I) !!((A)[(I) >> 5] & (1 << ((I) & 31)))
|
#define CheckBit(A,I) !!((A)[(I) >> 5] & (1 << ((I) & 31)))
|
||||||
@ -149,69 +152,77 @@ static struct SrcdsPatch
|
|||||||
// 0: game_ui should not apply FL_ONTRAIN flag, else client prediction turns off
|
// 0: game_ui should not apply FL_ONTRAIN flag, else client prediction turns off
|
||||||
{
|
{
|
||||||
"_ZN7CGameUI5ThinkEv",
|
"_ZN7CGameUI5ThinkEv",
|
||||||
(unsigned char *)"\xC7\x44\x24\x04\x10\x00\x00\x00\x89\x34\x24\xE8\x00\x00\x00\x00",
|
(unsigned char *)"\x0F\x82\xC4\x03\x00\x00\x83\xEC\x08\x6A\x10\x53\xE8\x91\x00\xF5\xFF",
|
||||||
"xxxxxxxxxxxx????",
|
"xx????xx?x?xx????",
|
||||||
(unsigned char *)"\xC7\x44\x24\x04\x10\x00\x00\x00\x89\x34\x24\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x0F\x82\xC4\x03\x00\x00\x83\xEC\x08\x6A\x10\x53\x90\x90\x90\x90\x90",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 1: player_speedmod should not turn off flashlight
|
// 1: player_speedmod should not turn off flashlight
|
||||||
{
|
{
|
||||||
"_ZN17CMovementSpeedMod13InputSpeedModER11inputdata_t",
|
"_ZN17CMovementSpeedMod13InputSpeedModER11inputdata_t",
|
||||||
(unsigned char *)"\xFF\x90\x8C\x05\x00\x00\x85\xC0\x0F\x85\x85\x02\x00\x00",
|
(unsigned char *)"\x8B\x90\xA4\x05\x00\x00\x81\xFA\x10\x6E\x3E\x00\x0F\x85\xC7\x02\x00\x00\x8B\x80\xA0\x05\x00\x00\x3D\x00\x6E\x3E\x00\x0F\x85\xEE\x02\x00\x00",
|
||||||
"xxxxxxxxxxxxxx",
|
"xx????xx????xx????xx????x????xx????",
|
||||||
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x8B\x90\xA4\x05\x00\x00\x81\xFA\x10\x6E\x3E\x00\x0F\x84\xC7\x02\x00\x00\x8B\x80\xA0\x05\x00\x00\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 2: only select CT spawnpoints
|
// 2: only select CT spawnpoints
|
||||||
{
|
{
|
||||||
"_ZN9CCSPlayer19EntSelectSpawnPointEv",
|
"_ZN9CCSPlayer19EntSelectSpawnPointEv",
|
||||||
(unsigned char *)"\x89\x1C\x24\xE8\x00\x00\x00\x00\x83\xF8\x03\x74\x6B",
|
(unsigned char *)"\x74\x57\x83\xEC\x0C\x53\xE8\x6E\x34\xCA\xFF\x83\xC4\x10\x83\xF8\x02\x0F\x84",
|
||||||
"xxxx????xxxxx",
|
"x?xx?xx????xx?xx?xx",
|
||||||
(unsigned char *)"\x89\x1C\x24\x90\x90\x90\x90\x90\x90\x90\x90\xEB\x6B",
|
(unsigned char *)"\xEB\x57\x83\xEC\x0C\x53\xE8\x6E\x34\xCA\xFF\x83\xC4\x10\x83\xF8\x02\x0F\x84",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 3: don't check if we have T spawns
|
// 3: don't check if we have T spawns
|
||||||
{
|
{
|
||||||
"_ZN12CCSGameRules18NeededPlayersCheckERb",
|
"_ZN12CCSGameRules18NeededPlayersCheckERb",
|
||||||
(unsigned char *)"\x74\x0E\x8B\x83\x80\x02\x00\x00\x85\xC0\x0F\x85\x9E\x00\x00\x00\xC7\x04\x24\xAC\xF7\x87\x00\xE8\xC2\x82\x91\x00",
|
(unsigned char *)"\x74\x0A\x8B\x83\x94\x02\x00\x00\x85\xC0\x75\x4A\x83\xEC\x0C\x68\xE8\xCF\x93\x00\xE8\xA9\x46\x52\x00\x5A\x59",
|
||||||
"xxxxxxxxxxxxxxxx????????????",
|
"xxxx????xxx?xx?x????x????xx",
|
||||||
(unsigned char *)"\x0F\x85\xA8\x00\x00\x00\x8B\x83\x80\x02\x00\x00\x85\xC0\x0F\x85\x9A\x00\x00\x00\x90\x90\x90\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x75\x54\x8B\x83\x94\x02\x00\x00\x85\xC0\x75\x4A\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 5: disable alive check in point_viewcontrol->Disable
|
// 5: disable alive check in point_viewcontrol->Disable
|
||||||
{
|
{
|
||||||
"_ZN14CTriggerCamera7DisableEv",
|
"_ZN14CTriggerCamera7DisableEv",
|
||||||
(unsigned char *)"\x8B\x10\x89\x04\x24\xFF\x92\x08\x01\x00\x00\x84\xC0\x0F\x84\x58\xFF\xFF\xFF",
|
(unsigned char *)"\x0F\x84\x47\x02\x00\x00\xF6\x83\x40\x01\x00\x00\x20\x0F\x85",
|
||||||
"xxxxxxx??xxxxxx?xxx",
|
"xx????xx?????xx",
|
||||||
(unsigned char *)"\x8B\x10\x89\x04\x24\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x90\x90\x90\x90\x90\x90\xF6\x83\x40\x01\x00\x00\x20\x0F\x85",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 6: disable player->m_takedamage = DAMAGE_NO in point_viewcontrol->Enable
|
// 6: disable player->m_takedamage = DAMAGE_NO in point_viewcontrol->Enable
|
||||||
{
|
{
|
||||||
"_ZN14CTriggerCamera6EnableEv",
|
"_ZN14CTriggerCamera6EnableEv",
|
||||||
(unsigned char *)"\xC6\x86\x00\x00\x00\x00\x00\x8B\x83\x00\x00\x00\x00\xA8\x20",
|
(unsigned char *)"\xC6\x80\xFD\x00\x00\x00\x00\x8B\x83",
|
||||||
"xx?????xx????xx",
|
"xxxxxxxxx",
|
||||||
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x8B\x83\x00\x00\x00\x00\xA8\x20",
|
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x8B\x83",
|
||||||
"cstrike/bin/server_srv.so",
|
"cstrike/bin/server_srv.so",
|
||||||
0x600
|
0x600
|
||||||
},
|
},
|
||||||
// 7: disable player->m_takedamage = m_nOldTakeDamage in point_viewcontrol->Disable
|
// 7: disable player->m_takedamage = m_nOldTakeDamage in point_viewcontrol->Disable
|
||||||
{
|
{
|
||||||
"_ZN14CTriggerCamera7DisableEv",
|
"_ZN14CTriggerCamera7DisableEv",
|
||||||
(unsigned char *)"\x89\xF9\x38\x8E\xFD\x00\x00\x00\x0F\x84\xCA\xFD\xFF\xFF",
|
(unsigned char *)"\x74\x1A\x8B\x16\x8B\x92\x04\x02\x00\x00\x81\xFA\x30\xF9\x29\x00\x0F\x85",
|
||||||
"xxxx?xxxxxxxxx",
|
"x?xxxx????xx????xx",
|
||||||
(unsigned char *)"\x89\xF9\x38\x8E\xFD\x00\x00\x00\x90\xE9\xCA\xFD\xFF\xFF",
|
(unsigned char *)"\xEB\x1A\x8B\x16\x8B\x92\x04\x02\x00\x00\x81\xFA\x30\xF9\x29\x00\x0F\x85",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 8: userinfo stringtable don't write fakeclient field
|
// 8: userinfo stringtable don't write fakeclient field
|
||||||
{
|
{
|
||||||
"_ZN11CBaseClient12FillUserInfoER13player_info_s",
|
"_ZN11CBaseClient12FillUserInfoER13player_info_s",
|
||||||
(unsigned char *)"\xFF\x50\x70\x88\x46\x6C",
|
(unsigned char *)"\x88\x46\x6C",
|
||||||
"xxxxxx",
|
"xxx",
|
||||||
(unsigned char *)"\x90\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x90\x90\x90",
|
||||||
"bin/engine_srv.so"
|
"bin/engine_srv.so"
|
||||||
},
|
},
|
||||||
// 9: fix server lagging resulting from too many ConMsgs due to packet spam
|
// 9: dont reset cash to 16000 when buying an item
|
||||||
|
{
|
||||||
|
"_ZN9CCSPlayer10AddAccountEibbPKc",
|
||||||
|
(unsigned char *)"\x3D\x80\x3E\x00\x00\x0F\x8F\x00\x00\x00\x00\x8D\x65",
|
||||||
|
"x????xx????xx",
|
||||||
|
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x8D\x65",
|
||||||
|
"cstrike/bin/server_srv.so"
|
||||||
|
},
|
||||||
|
// 10: fix server lagging resulting from too many ConMsgs due to packet spam
|
||||||
{
|
{
|
||||||
"_ZN8CNetChan19ProcessPacketHeaderEP11netpacket_s",
|
"_ZN8CNetChan19ProcessPacketHeaderEP11netpacket_s",
|
||||||
(unsigned char *)"_Z6ConMsgPKcz",
|
(unsigned char *)"_Z6ConMsgPKcz",
|
||||||
@ -221,7 +232,7 @@ static struct SrcdsPatch
|
|||||||
0x7d1, 100,
|
0x7d1, 100,
|
||||||
true, "bin/libtier0_srv.so"
|
true, "bin/libtier0_srv.so"
|
||||||
},
|
},
|
||||||
// 10: fix server lagging resulting from too many ConMsgs due to packet spam
|
// 11: fix server lagging resulting from too many ConMsgs due to packet spam
|
||||||
{
|
{
|
||||||
"_Z11NET_GetLongiP11netpacket_s",
|
"_Z11NET_GetLongiP11netpacket_s",
|
||||||
(unsigned char *)"Msg",
|
(unsigned char *)"Msg",
|
||||||
@ -231,7 +242,8 @@ static struct SrcdsPatch
|
|||||||
0x800, 100,
|
0x800, 100,
|
||||||
true, "bin/libtier0_srv.so"
|
true, "bin/libtier0_srv.so"
|
||||||
},
|
},
|
||||||
// 11: Always transmit point_viewcontrol (for debugging)
|
// 12: Always transmit point_viewcontrol (for debugging)
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
"_ZN14CTriggerCamera19UpdateTransmitStateEv",
|
"_ZN14CTriggerCamera19UpdateTransmitStateEv",
|
||||||
(unsigned char *)"\x74\x16",
|
(unsigned char *)"\x74\x16",
|
||||||
@ -239,22 +251,32 @@ static struct SrcdsPatch
|
|||||||
(unsigned char *)"\xEB\x16",
|
(unsigned char *)"\xEB\x16",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 12: CTriggerCamera::FollowTarget: Don't early return when the player handle is null
|
*/
|
||||||
|
// 13: CTriggerCamera::FollowTarget: Don't early return when the player handle is null
|
||||||
{
|
{
|
||||||
"_ZN14CTriggerCamera12FollowTargetEv",
|
"_ZN14CTriggerCamera12FollowTargetEv",
|
||||||
(unsigned char *)"\x74\x1B\x89\xD0\x25\x00\x00\x00\x00\xC1\xE0\x04",
|
(unsigned char *)"\x0F\x84\xD6\x02\x00\x00\x83\xFA\xFF",
|
||||||
"xxxxx????xxx",
|
"xxxxxxxxx",
|
||||||
(unsigned char *)"\xEB\x23\x89\xD0\x25\x00\x00\x00\x00\xC1\xE0\x04",
|
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x83\xFA\xFF",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
// 13: CGameMovement::LadderMove NOP out player->SetGravity( 0 );
|
// 14: CGameMovement::LadderMove NOP out player->SetGravity( 0 );
|
||||||
|
// This is in a cloned function which has a weird symbol (_ZN13CGameMovement10LadderMoveEv_part_0) so I went with the function right before it
|
||||||
{
|
{
|
||||||
"_ZN13CGameMovement10LadderMoveEv",
|
"_ZN13CGameMovement12CheckFallingEv",
|
||||||
(unsigned char *)"\xC7\x80\x78\x02\x00\x00\x00\x00\x00\x00",
|
(unsigned char *)"\xC7\x80\xA4\x02\x00\x00\x00\x00\x00\x00\x8B\x03\x8B\x80",
|
||||||
"xxxxxxx???",
|
"xx????????xxxx",
|
||||||
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",
|
(unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x8B\x03\x8B\x80",
|
||||||
"cstrike/bin/server_srv.so"
|
"cstrike/bin/server_srv.so"
|
||||||
},
|
},
|
||||||
|
// 18: Remove weird filename handle check in CZipPackFile::GetFileInfo that broke loading mixed case files in bsp pakfiles
|
||||||
|
{
|
||||||
|
"_ZN12CZipPackFile11GetFileInfoEPKcRiRxS2_S2_Rt",
|
||||||
|
(unsigned char *)"\x75\x00\x8B\x09",
|
||||||
|
"x?xx",
|
||||||
|
(unsigned char *)"\x90\x90\x8B\x09",
|
||||||
|
"bin/dedicated_srv.so"
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
@ -326,7 +348,6 @@ DETOUR_DECL_MEMBER1(DETOUR_InputTestActivator, void, inputdata_t *, inputdata)
|
|||||||
|
|
||||||
const char *pszNonEdicts[] =
|
const char *pszNonEdicts[] =
|
||||||
{
|
{
|
||||||
"ambient_generic",
|
|
||||||
"game_score",
|
"game_score",
|
||||||
"game_text",
|
"game_text",
|
||||||
"game_ui",
|
"game_ui",
|
||||||
@ -342,6 +363,8 @@ const char *pszNonEdicts[] =
|
|||||||
|
|
||||||
DETOUR_DECL_MEMBER1(DETOUR_PostConstructor, void, const char *, szClassname)
|
DETOUR_DECL_MEMBER1(DETOUR_PostConstructor, void, const char *, szClassname)
|
||||||
{
|
{
|
||||||
|
VPROF_ENTER_SCOPE("CSSFixes::DETOUR_PostConstructor");
|
||||||
|
|
||||||
CBaseEntity *pEntity = (CBaseEntity *)this;
|
CBaseEntity *pEntity = (CBaseEntity *)this;
|
||||||
|
|
||||||
static datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
|
static datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
|
||||||
@ -371,6 +394,8 @@ DETOUR_DECL_MEMBER1(DETOUR_PostConstructor, void, const char *, szClassname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DETOUR_MEMBER_CALL(DETOUR_PostConstructor)(szClassname);
|
DETOUR_MEMBER_CALL(DETOUR_PostConstructor)(szClassname);
|
||||||
|
|
||||||
|
VPROF_EXIT_SCOPE();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation for custom filter entities
|
// Implementation for custom filter entities
|
||||||
@ -424,15 +449,23 @@ DETOUR_DECL_MEMBER2(DETOUR_PassesFilterImpl, bool, CBaseEntity*, pCaller, CBaseE
|
|||||||
// Switch new entity classnames to ones that can be instantiated while keeping the classname keyvalue intact so it can be used later
|
// Switch new entity classnames to ones that can be instantiated while keeping the classname keyvalue intact so it can be used later
|
||||||
DETOUR_DECL_STATIC2(DETOUR_CreateEntityByName, CBaseEntity*, const char*, className, int, iForceEdictIndex)
|
DETOUR_DECL_STATIC2(DETOUR_CreateEntityByName, CBaseEntity*, const char*, className, int, iForceEdictIndex)
|
||||||
{
|
{
|
||||||
|
VPROF_ENTER_SCOPE("CSSFixes::DETOUR_CreateEntityByName");
|
||||||
|
|
||||||
// Nice of valve to expose CBaseFilter as filter_base :)
|
// Nice of valve to expose CBaseFilter as filter_base :)
|
||||||
if (strcasecmp(className, "filter_activator_context") == 0)
|
if (strcasecmp(className, "filter_activator_context") == 0)
|
||||||
className = "filter_base";
|
className = "filter_base";
|
||||||
|
|
||||||
return DETOUR_STATIC_CALL(DETOUR_CreateEntityByName)(className, iForceEdictIndex);
|
CBaseEntity *pEntity = DETOUR_STATIC_CALL(DETOUR_CreateEntityByName)(className, iForceEdictIndex);
|
||||||
|
|
||||||
|
VPROF_EXIT_SCOPE();
|
||||||
|
|
||||||
|
return pEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *, szValue)
|
DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *, szValue)
|
||||||
{
|
{
|
||||||
|
VPROF_ENTER_SCOPE("CSSFixes::DETOUR_KeyValue");
|
||||||
|
|
||||||
CBaseEntity *pEntity = (CBaseEntity *)this;
|
CBaseEntity *pEntity = (CBaseEntity *)this;
|
||||||
|
|
||||||
// Fix crash bug in engine
|
// Fix crash bug in engine
|
||||||
@ -474,7 +507,11 @@ DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *
|
|||||||
vecAbsVelocity->Init(tmp[0], tmp[1], tmp[2]);
|
vecAbsVelocity->Init(tmp[0], tmp[1], tmp[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DETOUR_MEMBER_CALL(DETOUR_KeyValue)(szKeyName, szValue);
|
bool bHandled = DETOUR_MEMBER_CALL(DETOUR_KeyValue)(szKeyName, szValue);
|
||||||
|
|
||||||
|
VPROF_EXIT_SCOPE();
|
||||||
|
|
||||||
|
return bHandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore players in +USE trace */
|
/* Ignore players in +USE trace */
|
||||||
@ -492,7 +529,7 @@ DETOUR_DECL_MEMBER3(DETOUR_CTraceFilterSimple, void, const IHandleEntity *, pass
|
|||||||
DETOUR_MEMBER_CALL(DETOUR_CTraceFilterSimple)(passedict, collisionGroup, pExtraShouldHitFunc);
|
DETOUR_MEMBER_CALL(DETOUR_CTraceFilterSimple)(passedict, collisionGroup, pExtraShouldHitFunc);
|
||||||
|
|
||||||
// If we're in FindUseEntity right now then switch out the VTable
|
// If we're in FindUseEntity right now then switch out the VTable
|
||||||
if(g_InFindUseEntity)
|
if (g_InFindUseEntity)
|
||||||
*(uintptr_t *)this = g_CTraceFilterNoNPCsOrPlayer;
|
*(uintptr_t *)this = g_CTraceFilterNoNPCsOrPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,6 +805,8 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
g_SH_SkipTwoEntitiesShouldHitEntity = SH_ADD_DVPHOOK(CTraceFilterSkipTwoEntities, ShouldHitEntity, g_CTraceFilterSkipTwoEntities, SH_STATIC(ShouldHitEntity), true);
|
g_SH_SkipTwoEntitiesShouldHitEntity = SH_ADD_DVPHOOK(CTraceFilterSkipTwoEntities, ShouldHitEntity, g_CTraceFilterSkipTwoEntities, SH_STATIC(ShouldHitEntity), true);
|
||||||
g_SH_SimpleShouldHitEntity = SH_ADD_DVPHOOK(CTraceFilterSimple, ShouldHitEntity, g_CTraceFilterSimple, SH_STATIC(ShouldHitEntity), true);
|
g_SH_SimpleShouldHitEntity = SH_ADD_DVPHOOK(CTraceFilterSimple, ShouldHitEntity, g_CTraceFilterSimple, SH_STATIC(ShouldHitEntity), true);
|
||||||
|
|
||||||
|
bool bSuccess = true;
|
||||||
|
|
||||||
// Apply all patches
|
// Apply all patches
|
||||||
for(size_t i = 0; i < sizeof(gs_Patches) / sizeof(*gs_Patches); i++)
|
for(size_t i = 0; i < sizeof(gs_Patches) / sizeof(*gs_Patches); i++)
|
||||||
{
|
{
|
||||||
@ -777,19 +816,19 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
void *pBinary = dlopen(pPatch->pLibrary, RTLD_NOW);
|
void *pBinary = dlopen(pPatch->pLibrary, RTLD_NOW);
|
||||||
if(!pBinary)
|
if(!pBinary)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Could not dlopen %s", pPatch->pLibrary);
|
g_pSM->LogError(myself, "Could not dlopen %s", pPatch->pLibrary);
|
||||||
SDK_OnUnload();
|
bSuccess = false;
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPatch->pAddress = (uintptr_t)memutils->ResolveSymbol(pBinary, pPatch->pSignature);
|
pPatch->pAddress = (uintptr_t)memutils->ResolveSymbol(pBinary, pPatch->pSignature);
|
||||||
dlclose(pBinary);
|
dlclose(pBinary);
|
||||||
if(!pPatch->pAddress)
|
if(!pPatch->pAddress)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Could not find symbol: %s in %s (%p)",
|
g_pSM->LogError(myself, "Could not find symbol: %s in %s (%p)",
|
||||||
pPatch->pSignature, pPatch->pLibrary, pBinary);
|
pPatch->pSignature, pPatch->pLibrary, pBinary);
|
||||||
SDK_OnUnload();
|
bSuccess = false;
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrcdsPatch::Restore **ppRestore = &pPatch->pRestore;
|
SrcdsPatch::Restore **ppRestore = &pPatch->pRestore;
|
||||||
@ -799,19 +838,19 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
void *pFunctionBinary = dlopen(pPatch->pFunctionLibrary, RTLD_NOW);
|
void *pFunctionBinary = dlopen(pPatch->pFunctionLibrary, RTLD_NOW);
|
||||||
if(!pFunctionBinary)
|
if(!pFunctionBinary)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Could not dlopen %s", pPatch->pFunctionLibrary);
|
g_pSM->LogError(myself, "Could not dlopen %s", pPatch->pFunctionLibrary);
|
||||||
SDK_OnUnload();
|
bSuccess = false;
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPatch->pSignatureAddress = (uintptr_t)memutils->ResolveSymbol(pFunctionBinary, (char *)pPatch->pPatchSignature);
|
pPatch->pSignatureAddress = (uintptr_t)memutils->ResolveSymbol(pFunctionBinary, (char *)pPatch->pPatchSignature);
|
||||||
dlclose(pFunctionBinary);
|
dlclose(pFunctionBinary);
|
||||||
if(!pPatch->pSignatureAddress)
|
if(!pPatch->pSignatureAddress)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Could not find patch signature symbol: %s in %s (%p)",
|
g_pSM->LogError(myself, "Could not find patch signature symbol: %s in %s (%p)",
|
||||||
(char *)pPatch->pPatchSignature, pPatch->pFunctionLibrary, pFunctionBinary);
|
(char *)pPatch->pPatchSignature, pPatch->pFunctionLibrary, pFunctionBinary);
|
||||||
SDK_OnUnload();
|
bSuccess = false;
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,9 +869,9 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
if(found)
|
if(found)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
snprintf(error, maxlength, "Could not find patch signature for symbol: %s", pPatch->pSignature);
|
g_pSM->LogError(myself, "Could not find patch signature for symbol: %s", pPatch->pSignature);
|
||||||
SDK_OnUnload();
|
bSuccess = false;
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
ofs = pPatchAddress - pPatch->pAddress + PatchLen;
|
ofs = pPatchAddress - pPatch->pAddress + PatchLen;
|
||||||
|
|
||||||
@ -854,6 +893,12 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bSuccess)
|
||||||
|
{
|
||||||
|
SDK_OnUnload();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
hl2sdk-manifests
Submodule
1
hl2sdk-manifests
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit f559b1cc8f9e47d88e13bd46a220c32ec26af7b6
|
||||||
@ -40,7 +40,7 @@
|
|||||||
/* Basic information exposed publicly */
|
/* Basic information exposed publicly */
|
||||||
#define SMEXT_CONF_NAME "CSSFixes"
|
#define SMEXT_CONF_NAME "CSSFixes"
|
||||||
#define SMEXT_CONF_DESCRIPTION "Patches bugs in the CSS server binary and more..."
|
#define SMEXT_CONF_DESCRIPTION "Patches bugs in the CSS server binary and more..."
|
||||||
#define SMEXT_CONF_VERSION "1.18"
|
#define SMEXT_CONF_VERSION "1.2"
|
||||||
#define SMEXT_CONF_AUTHOR "BotoX"
|
#define SMEXT_CONF_AUTHOR "BotoX"
|
||||||
#define SMEXT_CONF_URL ""
|
#define SMEXT_CONF_URL ""
|
||||||
#define SMEXT_CONF_LOGTAG "CSSFIXES"
|
#define SMEXT_CONF_LOGTAG "CSSFIXES"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user