Merge branch 'master' into csgo-hashmap

This commit is contained in:
Ruben Gonzalez 2017-10-27 18:57:28 -04:00 committed by GitHub
commit b6a2f72e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 1721 additions and 1251 deletions

View File

@ -1,33 +1,116 @@
git:
depth: 3
sudo: false
language: cpp
os: linux
dist: trusty
addons:
apt:
packages:
- lib32stdc++6
- lib32z1-dev
- libc6-dev-i386
- linux-libc-dev
- g++-multilib
- g++-4.8
sources:
- ubuntu-toolchain-r-test
cache:
directories:
- ../mysql-5.0
language: cpp
sudo: false
compiler:
- clang
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- llvm-toolchain-trusty-5.0
packages:
- lib32stdc++6
- lib32z1-dev
- libc6-dev-i386
- linux-libc-dev
- g++-multilib
# - clang-3.6
# - clang-3.8
# - clang-4.0
# - clang-5.0
# - g++-6
# - g++-6-multilib
- g++-4.8-multilib
- g++-4.8
- g++-4.9-multilib
- g++-4.9
- g++-5-multilib
- g++-5
- g++-7-multilib
- g++-7
cache:
directories:
- ../mysql-5.0
env:
global:
- LLVM_ARCHIVE_URI=http://sourcemod.net/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
before_install:
- wget -nc $LLVM_ARCHIVE_URI -O $HOME/clang+llvm.tar.xz
- mkdir -p $HOME/clang+llvm
- tar -xf $HOME/clang+llvm.tar.xz -C $HOME/clang+llvm --strip-components 1
- export PATH=$HOME/clang+llvm/bin:$PATH
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
matrix:
fast_finish: true
include:
- os: linux
sudo: false
language: cpp
addons:
apt:
packages: ['clang-3.6', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib']
cache:
directories: ['../mysql-5.0']
env: ['MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"']
- os: linux
sudo: false
language: cpp
addons:
apt:
packages: ['clang-3.8', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib']
cache:
directories: ['../mysql-5.0']
env: ['MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"']
- os: linux
sudo: false
language: cpp
addons:
apt:
sources: ['llvm-toolchain-trusty-4.0']
packages: ['clang-4.0', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib']
cache:
directories: ['../mysql-5.0']
env: ['MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"']
- os: linux
sudo: false
language: cpp
addons:
apt:
sources: ['llvm-toolchain-trusty-5.0']
packages: ['clang-5.0', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib']
cache:
directories: ['../mysql-5.0']
env: ['MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"']
- os: linux
sudo: false
language: cpp
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'g++-6-multilib', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib']
cache:
directories: ['../mysql-5.0']
env: ['MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"']
allow_failures:
- env: MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
- env: MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
- env: MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- env: MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- env: MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
before_script:
- CHECKOUT_DIR=$PWD && cd .. && $CHECKOUT_DIR/tools/checkout-deps.sh && cd $CHECKOUT_DIR
script:
- mkdir build && cd build
- PATH="~/.local/bin:$PATH"
- CC=clang-3.8 CXX=clang-3.8 python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota
- eval "${MATRIX_EVAL}"
- python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota
- ambuild

View File

@ -104,7 +104,7 @@ class SMConfig(object):
for sdk_name in PossibleSDKs:
sdk = PossibleSDKs[sdk_name]
if builder.target_platform in sdk.platform:
if builder.target.platform in sdk.platform:
if builder.options.hl2sdk_root:
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
else:
@ -148,11 +148,11 @@ class SMConfig(object):
def configure(self):
builder.AddConfigureFile('pushbuild.txt')
cxx = builder.DetectCompilers()
cxx = builder.DetectCxx()
if cxx.like('gcc'):
self.configure_gcc(cxx)
elif cxx.vendor == 'msvc':
elif cxx.family == 'msvc':
self.configure_msvc(cxx)
# Optimizaiton
@ -164,11 +164,11 @@ class SMConfig(object):
cxx.defines += ['DEBUG', '_DEBUG']
# Platform-specifics
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
self.configure_linux(cxx)
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
self.configure_mac(cxx)
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
self.configure_windows(cxx)
# Finish up.
@ -217,10 +217,16 @@ class SMConfig(object):
]
cxx.linkflags += ['-m32']
have_gcc = cxx.vendor == 'gcc'
have_clang = cxx.vendor == 'clang'
if cxx.version >= 'clang-3.6':
have_gcc = cxx.family == 'gcc'
have_clang = cxx.family == 'clang'
if cxx.version >= 'clang-3.9':
cxx.cxxflags += ['-Wno-expansion-to-defined']
if cxx.version == 'clang-3.9' or cxx.version == 'apple-clang-8.0':
cxx.cflags += ['-Wno-varargs']
if cxx.version >= 'clang-3.6' 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'):
@ -238,6 +244,7 @@ class SMConfig(object):
if have_gcc:
cxx.cflags += ['-mfpmath=sse']
cxx.cflags += ['-Wno-maybe-uninitialized']
if builder.options.opt == '1':
cxx.cflags += ['-O3']
@ -292,13 +299,13 @@ class SMConfig(object):
def configure_linux(self, cxx):
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
cxx.linkflags += ['-Wl,--exclude-libs,ALL', '-lm']
if cxx.vendor == 'gcc':
if cxx.family == 'gcc':
cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == 'clang':
elif cxx.family == 'clang':
cxx.linkflags += ['-lgcc_eh']
def configure_mac(self, cxx):
cxx.defines += ['OSX', '_OSX', 'POSIX']
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
cxx.cflags += ['-mmacosx-version-min=10.5']
cxx.linkflags += [
'-mmacosx-version-min=10.5',
@ -312,7 +319,7 @@ class SMConfig(object):
cxx.defines += ['WIN32', '_WINDOWS']
def AddVersioning(self, binary):
if builder.target_platform == 'windows':
if builder.target.platform == 'windows':
binary.sources += ['version.rc']
binary.compiler.rcdefines += [
'BINARY_NAME="{0}"'.format(binary.outputFile),
@ -320,7 +327,7 @@ class SMConfig(object):
]
if self.use_auto_versioning():
binary.compiler.rcdefines += ['SM_GENERATED_BUILD']
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
if binary.type == 'library':
binary.compiler.postlink += [
'-compatibility_version', '1.0.0',
@ -330,18 +337,42 @@ class SMConfig(object):
binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += SM.generated_headers
return binary
def Library(self, context, name):
binary = context.compiler.Library(name)
def LibraryBuilder(self, compiler, name):
binary = compiler.Library(name)
self.AddVersioning(binary)
if binary.compiler.like('msvc'):
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
return self.AddVersioning(binary)
return binary
def Program(self, context, name):
binary = context.compiler.Program(name)
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++']
if binary.compiler.like('msvc'):
binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE']
return self.AddVersioning(binary)
return binary
def StaticLibraryBuilder(self, compiler, name):
binary = compiler.StaticLibrary(name)
return binary;
def Library(self, context, name):
compiler = context.cxx.clone()
return self.LibraryBuilder(compiler, name)
def Program(self, context, name):
compiler = context.cxx.clone()
return self.ProgramBuilder(compiler, name)
def StaticLibrary(self, context, name):
compiler = context.cxx.clone()
return self.StaticLibraryBuilder(compiler, name)
def ConfigureForExtension(self, context, compiler):
compiler.cxxincludes += [
@ -355,9 +386,9 @@ class SMConfig(object):
return compiler
def ExtLibrary(self, context, name):
binary = context.compiler.Library(name)
binary = self.Library(context, name)
self.ConfigureForExtension(context, binary.compiler)
return self.AddVersioning(binary)
return binary
def ConfigureForHL2(self, binary, sdk):
compiler = binary.compiler
@ -409,29 +440,29 @@ class SMConfig(object):
compiler.defines += ['NETWORK_VARS_ENABLED']
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']:
if builder.target_platform in ['linux', 'mac']:
if builder.target.platform in ['linux', 'mac']:
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
if sdk.name == 'csgo' and builder.target_platform == 'linux':
if sdk.name == 'csgo' and builder.target.platform == 'linux':
compiler.linkflags += ['-lstdc++']
for path in paths:
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
if builder.target_platform == 'linux':
if builder.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')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
if sdk.name in ['sdk2013', 'bms']:
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
if builder.target_platform in ['linux', 'mac']:
if builder.target.platform in ['linux', 'mac']:
if sdk.name in ['sdk2013', 'bms']:
compiler.postlink += [
compiler.Dep(os.path.join(lib_folder, 'tier1.a')),
@ -446,20 +477,18 @@ class SMConfig(object):
if sdk.name in ['blade', 'insurgency', 'csgo']:
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
self.AddVersioning(binary)
dynamic_libs = []
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency']:
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo']:
dynamic_libs = ['libtier0.so', 'libvstdlib.so']
else:
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
compiler.linkflags.append('-liconv')
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo']:
libs.append('interfaces')
@ -483,17 +512,18 @@ class SMConfig(object):
return binary
def HL2Library(self, context, name, sdk):
binary = context.compiler.Library(name)
binary = self.Library(context, name)
self.ConfigureForExtension(context, binary.compiler)
return self.ConfigureForHL2(binary, sdk)
def HL2Project(self, context, name):
project = context.compiler.LibraryProject(name)
project = context.cxx.LibraryProject(name)
self.ConfigureForExtension(context, project.compiler)
return project
def HL2Config(self, project, name, sdk):
binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name))
self.AddVersioning(binary)
return self.ConfigureForHL2(binary, sdk)
SM = SMConfig()
@ -502,23 +532,21 @@ SM.detectSDKs()
SM.configure()
if SM.use_auto_versioning():
SM.generated_headers = builder.RunScript(
SM.generated_headers = builder.Build(
'tools/buildbot/Versioning',
{ 'SM': SM }
)
SM.versionlib = builder.RunScript(
SM.versionlib = builder.Build(
'versionlib/AMBuilder',
{ 'SM': SM }
)
# Build SourcePawn externally.
SourcePawn = builder.RunScript('sourcepawn/AMBuildScript', {})
SP = SourcePawn(
root = SM,
amtl = os.path.join(builder.sourcePath, 'public', 'amtl'),
)
SP.BuildSpcomp()
SP.BuildVM()
SP = builder.Build('sourcepawn/AMBuildScript', {
'external_root': SM,
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
'external_build': ['core'],
})
SM.spcomp = SP.spcomp
SM.binaries += [
SP.libsourcepawn
@ -549,7 +577,7 @@ if builder.backend == 'amb2':
'tools/buildbot/PackageScript',
]
builder.RunBuildScripts(BuildScripts, { 'SM': SM })
builder.Build(BuildScripts, { 'SM': SM })
if builder.options.breakpad_dump:
builder.RunScript('tools/buildbot/BreakpadSymbols', { 'SM': SM })
builder.Build('tools/buildbot/BreakpadSymbols', { 'SM': SM })

View File

@ -1,7 +1,7 @@
# vim: set ts=2 sw=2 tw=99 noet:
import sys
try:
from ambuild2 import run
from ambuild2 import run, util
except:
try:
import ambuild
@ -12,25 +12,29 @@ except:
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
sys.exit(1)
run = run.PrepareBuild(sourcePath=sys.path[0])
run.default_build_folder = 'obj-' + run.target_platform
run.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
def make_objdir_name(p):
return 'obj-' + util.Platform() + '-' + p.target_arch
parser = run.BuildParser(sourcePath=sys.path[0], api='2.1')
parser.default_arch = 'x86'
parser.default_build_folder = make_objdir_name
parser.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
run.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None,
parser.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None,
help='Path to MySQL 5')
run.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
parser.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')
run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
parser.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',
parser.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization')
run.options.add_option('--no-mysql', action='store_false', default=True, dest='hasMySql',
parser.options.add_option('--no-mysql', action='store_false', default=True, dest='hasMySql',
help='Disable building MySQL extension')
run.options.add_option('-s', '--sdks', default='all', dest='sdks',
parser.options.add_option('-s', '--sdks', default='all', dest='sdks',
help='Build against specified SDKs; valid args are "all", "present", or '
'comma-delimited list of engine names (default: %default)')
run.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump',
parser.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump',
default=False, help='Dump and upload breakpad symbols')
run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning',
parser.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning',
default=False, help='Disable the auto versioning script')
run.Configure()
parser.Configure()

View File

@ -60,15 +60,15 @@ for sdk_name in SM.sdks:
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf')
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
compiler.postlink += ['-lpthread', '-lrt']
if sdk.name == 'csgo':
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a')
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
lib_path = os.path.join(sdk.path, 'lib', 'osx32', 'release', 'libprotobuf.a')
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
msvc_ver = compiler.version
vs_year = ''
if msvc_ver == 1800:

View File

@ -277,7 +277,7 @@ SMCResult CoreConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key,
ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ConfigSource source, char *error, size_t maxlength)
{
ConfigResult result;
ConfigResult result = ConfigResult_Ignore;
/* Notify! */
SMGlobalClass *pBase = SMGlobalClass::head;
@ -285,7 +285,7 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value,
{
if ((result = pBase->OnSourceModConfigChanged(option, value, source, error, maxlength)) != ConfigResult_Ignore)
{
return result;
break;
}
pBase = pBase->m_pGlobalClassNext;
}
@ -293,7 +293,7 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value,
ke::AString vstr(value);
m_KeyValues.replace(option, ke::Move(vstr));
return ConfigResult_Ignore;
return result;
}
const char *CoreConfig::GetCoreConfigValue(const char *key)

View File

@ -171,13 +171,16 @@ ConfigResult CHalfLife2::OnSourceModConfigChanged(const char *key, const char *v
if (strcasecmp(value, "no") == 0)
{
m_bFollowCSGOServerGuidelines = false;
return ConfigResult_Accept;
}
else if (strcasecmp(value, "yes") == 0)
{
m_bFollowCSGOServerGuidelines = true;
return ConfigResult_Accept;
}
else
{
ke::SafeSprintf(error, maxlength, "Invalid value: must be \"yes\" or \"no\"");
return ConfigResult_Reject;
}
#endif

View File

@ -16,15 +16,15 @@ binary.compiler.defines += [
'SM_LOGIC'
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-lpthread', '-lrt']
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
binary.compiler.cflags += ['-Wno-deprecated-declarations']
binary.compiler.postlink += ['-framework', 'CoreServices']
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [
@ -83,7 +83,7 @@ binary.sources += [
'frame_tasks.cpp',
'smn_halflife.cpp',
]
if builder.target_platform == 'windows':
if builder.target.platform == 'windows':
binary.sources += ['thread/WinThreads.cpp']
else:
binary.sources += ['thread/PosixThreads.cpp']

View File

@ -185,7 +185,7 @@ size_t CDataPack::GetPosition() const
bool CDataPack::SetPosition(size_t pos) const
{
if (pos > m_size-1)
if (pos > m_size)
{
return false;
}

View File

@ -269,21 +269,9 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
if ((i >= m_numparams) || (type & SP_PARAMFLAG_BYREF))
{
/* If we're byref or we're vararg, we always push everything by ref.
* Even if they're byval, we must push them byref.
*/
if (type == Param_String)
{
err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
}
else if (type == Param_Float || type == Param_Cell)
{
err = func->PushCellByRef(&param->val);
}
else
{
err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags);
assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
}
* Even if they're byval, we must push them byref.
*/
err = _ExecutePushRef(func, type, param);
}
else
{
@ -382,6 +370,58 @@ done:
return SP_ERROR_NONE;
}
int CForward::_ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param)
{
/* If we're byref or we're vararg, we always push everything by ref.
* Even if they're byval, we must push them byref.
*/
int err;
IPluginRuntime *runtime = func->GetParentRuntime();
switch (type)
{
case Param_String:
// Normal string was pushed.
if (!param->isnull)
return func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
// If NULL_STRING was pushed, push the reference to the pubvar of the callee instead.
uint32_t null_string_idx;
err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx);
if (err)
return err;
cell_t null_string;
err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr);
if (err)
return err;
return func->PushCell(null_string);
case Param_Float:
case Param_Cell:
return func->PushCellByRef(&param->val);
default:
assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
// No NULL_VECTOR was pushed.
if (type != Param_Array || !param->isnull)
return func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags);
// If NULL_VECTOR was pushed, push the reference to the pubvar of the callee instead.
uint32_t null_vector_idx;
err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx);
if (err)
return err;
cell_t null_vector;
err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr);
if (err)
return err;
return func->PushCell(null_vector);
}
}
int CForward::PushCell(cell_t cell)
{
if (m_curparam < m_numparams)
@ -400,6 +440,7 @@ int CForward::PushCell(cell_t cell)
m_params[m_curparam].pushedas = Param_Cell;
}
m_params[m_curparam].isnull = false;
m_params[m_curparam++].val = cell;
return SP_ERROR_NONE;
@ -423,6 +464,7 @@ int CForward::PushFloat(float number)
m_params[m_curparam].pushedas = Param_Float;
}
m_params[m_curparam].isnull = false;
m_params[m_curparam++].val = *(cell_t *)&number;
return SP_ERROR_NONE;
@ -481,14 +523,22 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags)
m_params[m_curparam].byref.cells = cells;
m_params[m_curparam].byref.flags = flags;
m_params[m_curparam].byref.orig_addr = inarray;
m_params[m_curparam].isnull = false;
}
int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags)
{
/* We don't allow this here */
/* Push a reference to the NULL_VECTOR pubvar if NULL was passed. */
if (!inarray)
{
return SetError(SP_ERROR_PARAM);
/* Make sure this was intentional. */
if (cells == 3)
{
return PushNullVector();
} else {
/* We don't allow this here */
return SetError(SP_ERROR_PARAM);
}
}
if (m_curparam < m_numparams)
@ -520,10 +570,17 @@ void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags
m_params[m_curparam].byref.flags = cp_flags;
m_params[m_curparam].byref.orig_addr = inarray;
m_params[m_curparam].byref.sz_flags = sz_flags;
m_params[m_curparam].isnull = false;
}
int CForward::PushString(const char *string)
{
/* Push a reference to the NULL_STRING pubvar if NULL was passed. */
if (!string)
{
return PushNullString();
}
if (m_curparam < m_numparams)
{
if (m_types[m_curparam] == Param_Any)
@ -570,6 +627,52 @@ int CForward::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_fla
return SP_ERROR_NONE;
}
int CForward::PushNullString()
{
if (m_curparam < m_numparams)
{
if (m_types[m_curparam] == Param_Any)
{
m_params[m_curparam].pushedas = Param_String;
} else if (m_types[m_curparam] != Param_String) {
return SetError(SP_ERROR_PARAM);
}
} else {
if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
{
return SetError(SP_ERROR_PARAMS_MAX);
}
m_params[m_curparam].pushedas = Param_String;
}
m_params[m_curparam++].isnull = true;
return SP_ERROR_NONE;
}
int CForward::PushNullVector()
{
if (m_curparam < m_numparams)
{
if (m_types[m_curparam] == Param_Any)
{
m_params[m_curparam].pushedas = Param_Array;
} else if (m_types[m_curparam] != Param_Array) {
return SetError(SP_ERROR_PARAM);
}
} else {
if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS)
{
return SetError(SP_ERROR_PARAMS_MAX);
}
m_params[m_curparam].pushedas = Param_Array;
}
m_params[m_curparam++].isnull = true;
return SP_ERROR_NONE;
}
void CForward::Cancel()
{
if (!m_curparam)

View File

@ -72,6 +72,9 @@ private:
CForward(ExecType et, const char *name,
const ParamType *types, unsigned num_params);
int PushNullString();
int PushNullVector();
int _ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param);
void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags);
void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags);
inline int SetError(int err)

View File

@ -759,6 +759,27 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
return 0;
}
static cell_t IsNullVector(IPluginContext *pContext, const cell_t *params)
{
cell_t *pNullVec = pContext->GetNullRef(SP_NULL_VECTOR);
if (!pNullVec)
return 0;
cell_t *addr;
pContext->LocalToPhysAddr(params[1], &addr);
return addr == pNullVec;
}
static cell_t IsNullString(IPluginContext *pContext, const cell_t *params)
{
char *str;
if (pContext->LocalToStringNULL(params[1], &str) != SP_ERROR_NONE)
return 0;
return str == nullptr;
}
REGISTER_NATIVES(coreNatives)
{
{"ThrowError", ThrowError},
@ -787,5 +808,7 @@ REGISTER_NATIVES(coreNatives)
{"RequireFeature", RequireFeature},
{"LoadFromAddress", LoadFromAddress},
{"StoreToAddress", StoreToAddress},
{"IsNullVector", IsNullVector},
{"IsNullString", IsNullString},
{NULL, NULL},
};

View File

@ -424,6 +424,58 @@ static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params)
return SP_ERROR_NONE;
}
static cell_t IsNativeParamNullVector(IPluginContext *pContext, const cell_t *params)
{
if (!s_curnative || (s_curnative->ctx != pContext))
{
return pContext->ThrowNativeError("Not called from inside a native function");
}
cell_t param = params[1];
if (param < 1 || param > s_curparams[0])
{
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAM, "Invalid parameter number: %d", param);
}
int err;
cell_t *addr;
if ((err = s_curcaller->LocalToPhysAddr(s_curparams[param], &addr)) != SP_ERROR_NONE)
{
return err;
}
cell_t *pNullVec = s_curcaller->GetNullRef(SP_NULL_VECTOR);
if (!pNullVec)
{
return 0;
}
return addr == pNullVec ? 1 : 0;
}
static cell_t IsNativeParamNullString(IPluginContext *pContext, const cell_t *params)
{
if (!s_curnative || (s_curnative->ctx != pContext))
{
return pContext->ThrowNativeError("Not called from inside a native function");
}
cell_t param = params[1];
if (param < 1 || param > s_curparams[0])
{
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAM, "Invalid parameter number: %d", param);
}
int err;
char *str;
if ((err = s_curcaller->LocalToStringNULL(s_curparams[param], &str)) != SP_ERROR_NONE)
{
return err;
}
return str == nullptr ? 1 : 0;
}
//tee hee
REGISTER_NATIVES(nativeNatives)
{
@ -439,5 +491,7 @@ REGISTER_NATIVES(nativeNatives)
{"SetNativeArray", SetNativeArray},
{"SetNativeCellRef", SetNativeCellRef},
{"SetNativeString", SetNativeString},
{"IsNativeParamNullVector", IsNativeParamNullVector},
{"IsNativeParamNullString", IsNativeParamNullString},
{NULL, NULL},
};

View File

@ -29,7 +29,7 @@
* Version: $Id$
*/
#include <math.h>
#include <cmath>
#include <string.h>
#include <stdlib.h>
#include "common_logic.h"
@ -288,44 +288,6 @@ static cell_t sm_ArcTangent2(IPluginContext *pCtx, const cell_t *params)
return sp_ftoc(val1);
}
#if 0
static cell_t sm_FloatRound(IPluginContext *pCtx, const cell_t *params)
{
float val = sp_ctof(params[1]);
switch (params[2])
{
case 1:
{
val = floor(val);
break;
}
case 2:
{
val = ceil(val);
break;
}
case 3:
{
if (val >= 0.0f)
{
val = floor(val);
} else {
val = ceil(val);
}
break;
}
default:
{
val = (float)floor(val + 0.5f);
break;
}
}
return static_cast<int>(val);
}
#endif
class RandomHelpers :
public SMGlobalClass,
public IPluginsListener

View File

@ -552,6 +552,88 @@ static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params
return 1;
}
static cell_t sm_CallPushNullVector(IPluginContext *pContext, const cell_t *params)
{
int err = SP_ERROR_NOT_FOUND;
if (!s_CallStarted)
{
return pContext->ThrowNativeError("Cannot push parameters when there is no call in progress");
}
if (s_pFunction)
{
// Find the NULL_VECTOR pubvar in the target plugin and push the local address.
IPluginRuntime *runtime = s_pFunction->GetParentRuntime();
uint32_t null_vector_idx;
err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx);
if (err)
{
return pContext->ThrowNativeErrorEx(err, "Target plugin has no NULL_VECTOR.");
}
cell_t null_vector;
err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr);
if (!err)
err = s_pCallable->PushCell(null_vector);
}
else if (s_pForward)
{
err = s_pForward->PushArray(NULL, 3);
}
if (err)
{
s_pCallable->Cancel();
ResetCall();
return pContext->ThrowNativeErrorEx(err, NULL);
}
return 1;
}
static cell_t sm_CallPushNullString(IPluginContext *pContext, const cell_t *params)
{
int err = SP_ERROR_NOT_FOUND;
if (!s_CallStarted)
{
return pContext->ThrowNativeError("Cannot push parameters when there is no call in progress");
}
if (s_pFunction)
{
// Find the NULL_STRING pubvar in the target plugin and push the local address.
IPluginRuntime *runtime = s_pFunction->GetParentRuntime();
uint32_t null_string_idx;
err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx);
if (err)
{
return pContext->ThrowNativeErrorEx(err, "Target plugin has no NULL_STRING.");
}
cell_t null_string;
err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr);
if (!err)
err = s_pCallable->PushCell(null_string);
}
else if (s_pForward)
{
err = s_pForward->PushString(NULL);
}
if (err)
{
s_pCallable->Cancel();
ResetCall();
return pContext->ThrowNativeErrorEx(err, NULL);
}
return 1;
}
static cell_t sm_CallFinish(IPluginContext *pContext, const cell_t *params)
{
int err = SP_ERROR_NOT_RUNNABLE;
@ -668,6 +750,8 @@ REGISTER_NATIVES(functionNatives)
{"Call_PushArrayEx", sm_CallPushArrayEx},
{"Call_PushString", sm_CallPushString},
{"Call_PushStringEx", sm_CallPushStringEx},
{"Call_PushNullVector", sm_CallPushNullVector},
{"Call_PushNullString", sm_CallPushNullString},
{"Call_Finish", sm_CallFinish},
{"Call_Cancel", sm_CallCancel},
{"RequestFrame", sm_AddFrameAction},

View File

@ -8,9 +8,9 @@ binary.compiler.cxxincludes += [
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [

View File

@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'clientprefs.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [

View File

@ -31,35 +31,35 @@
#include "extension.h"
#include "util_cstrike.h"
#include "RegNatives.h"
#include <iplayerinfo.h>
#if SOURCE_ENGINE == SE_CSGO
#include "itemdef-hash.h"
#include "RegNatives.h"
#include <iplayerinfo.h>
#if SOURCE_ENGINE == SE_CSGO
#include "itemdef-hash.h"
ClassnameMap g_mapClassToDefIdx;
ItemIndexMap g_mapDefIdxToClass;
WeaponIDMap g_mapWeaponIDToDefIdx;
#endif
#define REGISTER_ADDR(name, defaultret, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret; \
} \
code; \
g_RegNatives.Register(pWrapper);
ItemIndexMap g_mapDefIdxToClass;
WeaponIDMap g_mapWeaponIDToDefIdx;
#endif
#define REGISTER_ADDR(name, defaultret, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret; \
} \
code; \
g_RegNatives.Register(pWrapper);
#define GET_MEMSIG(name, defaultret) \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to lookup %s signature.", name); \
return defaultret;\
}
#if SOURCE_ENGINE == SE_CSGO
}
#if SOURCE_ENGINE == SE_CSGO
// Get a CEconItemView for the m4
// Found in CCSPlayer::HandleCommand_Buy_Internal
// Linux a1 - CCSPlayer *pEntity, v5 - Player Team, a3 - ItemLoadoutSlot -1 use default loadoutslot:
@ -70,16 +70,16 @@ WeaponIDMap g_mapWeaponIDToDefIdx;
// The function is CCSPlayerInventory::GetItemInLoadout(int, int)
// We can pass NULL view to the GetAttribute to use default loadoutslot.
// We only really care about m4a1/m4a4 as price differs between them
// thisPtrOffset = 9472/9492
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
{
if (!pEntity)
return NULL;
static ICallWrapper *pWrapper = NULL;
static int thisPtrOffset = -1;
// thisPtrOffset = 9472/9492
CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
{
if (!pEntity)
return NULL;
static ICallWrapper *pWrapper = NULL;
static int thisPtrOffset = -1;
if (!pWrapper)
{
int offset = -1;
@ -119,22 +119,22 @@ CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 2);
g_RegNatives.Register(pWrapper);
}
}
int client = gamehelpers->EntityToBCompatRef(pEntity);
IPlayerInfo *playerinfo = playerhelpers->GetGamePlayer(client)->GetPlayerInfo();
if (!playerinfo)
return NULL;
int team = playerinfo->GetTeamIndex();
if (team != 2 && team != 3)
return NULL;
CEconItemView *ret;
}
}
int client = gamehelpers->EntityToBCompatRef(pEntity);
IPlayerInfo *playerinfo = playerhelpers->GetGamePlayer(client)->GetPlayerInfo();
if (!playerinfo)
return NULL;
int team = playerinfo->GetTeamIndex();
if (team != 2 && team != 3)
return NULL;
CEconItemView *ret;
unsigned char vstk[sizeof(void *) + sizeof(int) * 2];
unsigned char *vptr = vstk;
@ -144,51 +144,51 @@ CEconItemView *GetEconItemView(CBaseEntity *pEntity, int iSlot)
vptr += sizeof(int);
*(int *)vptr = iSlot;
pWrapper->Execute(vstk, &ret);
return ret;
}
CCSWeaponData *GetCCSWeaponData(CEconItemView *view)
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetCCSWeaponData", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(CCSWeaponData *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &retpass, NULL, 0))
}
unsigned char vstk[sizeof(CEconItemView *)];
unsigned char *vptr = vstk;
*(CEconItemView **)vptr = view;
CCSWeaponData *pWpnData = NULL;
pWrapper->Execute(vstk, &pWpnData);
return pWpnData;
}
CEconItemSchema *GetItemSchema()
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetItemSchema", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, NULL, 0))
}
pWrapper->Execute(vstk, &ret);
return ret;
}
CCSWeaponData *GetCCSWeaponData(CEconItemView *view)
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetCCSWeaponData", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(CCSWeaponData *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &retpass, NULL, 0))
}
unsigned char vstk[sizeof(CEconItemView *)];
unsigned char *vptr = vstk;
*(CEconItemView **)vptr = view;
CCSWeaponData *pWpnData = NULL;
pWrapper->Execute(vstk, &pWpnData);
return pWpnData;
}
CEconItemSchema *GetItemSchema()
{
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetItemSchema", NULL,
PassInfo retpass; \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, NULL, 0))
}
void *pSchema = NULL;
pWrapper->Execute(NULL, &pSchema);
@ -197,28 +197,28 @@ CEconItemSchema *GetItemSchema()
return (CEconItemSchema *)((intptr_t)pSchema + 4);
#else
return (CEconItemSchema *)pSchema;
#endif
}
CEconItemDefinition *GetItemDefintionByName(const char *classname)
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
#endif
}
CEconItemDefinition *GetItemDefintionByName(const char *classname)
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
int offset = -1;
if (!g_pGameConf->GetOffset("GetItemDefintionByName", &offset) || offset == -1)
{
smutils->LogError(myself, "Failed to get GetItemDefintionByName offset.");
return NULL;
}
}
PassInfo pass[1];
PassInfo ret;
pass[0].flags = PASSFLAG_BYVAL;
@ -229,11 +229,11 @@ CEconItemDefinition *GetItemDefintionByName(const char *classname)
ret.type = PassType_Basic;
ret.size = sizeof(CEconItemDefinition *);
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
g_RegNatives.Register(pWrapper);
}
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
g_RegNatives.Register(pWrapper);
}
unsigned char vstk[sizeof(void *) + sizeof(const char *)];
unsigned char *vptr = vstk;
@ -244,16 +244,16 @@ CEconItemDefinition *GetItemDefintionByName(const char *classname)
CEconItemDefinition *pItemDef = NULL;
pWrapper->Execute(vstk, &pItemDef);
return pItemDef;
}
void CreateHashMaps()
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return;
return pItemDef;
}
void CreateHashMaps()
{
CEconItemSchema *pSchema = GetItemSchema();
if (!pSchema)
return;
static const char *pPriceKey = NULL;
if (!pPriceKey)
@ -263,18 +263,18 @@ void CreateHashMaps()
{
return;
}
}
static int iHashMapOffset = -1;
if (iHashMapOffset == -1)
{
}
static int iHashMapOffset = -1;
if (iHashMapOffset == -1)
{
if (!g_pGameConf->GetOffset("ItemDefHashOffset", &iHashMapOffset) || iHashMapOffset == -1)
{
return;
}
}
}
}
g_mapClassToDefIdx.init();
g_mapDefIdxToClass.init();
g_mapWeaponIDToDefIdx.init();
@ -314,112 +314,112 @@ void CreateHashMaps()
g_mapWeaponIDToDefIdx.add(t, iWeaponID, ItemDefHashValue(iLoadoutslot, price, iWeaponID, iItemDefIdx, classname));
}
}
}
}
void ClearHashMaps()
{
g_mapClassToDefIdx.clear();
g_mapDefIdxToClass.clear();
g_mapWeaponIDToDefIdx.clear();
}
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx)
{
//DEAR GOD THIS IS HIDEOUS
//None in the middle are weapons that dont exist.
//If they are added and use the same idx they should be changed to their respective ones
static SMCSWeapon weaponIDMap[SMCSWeapon_MAXWEAPONIDS] =
{
SMCSWeapon_NONE, SMCSWeapon_DEAGLE, SMCSWeapon_ELITE, SMCSWeapon_FIVESEVEN,
SMCSWeapon_GLOCK, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_AK47,
SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1,
SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE,
SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90,
SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE,
SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7,
SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER,
SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA,
SMCSWeapon_P250, SMCSWeapon_NONE, SMCSWeapon_SCAR20, SMCSWeapon_SG556,
SMCSWeapon_SSG08, SMCSWeapon_KNIFE_GG, SMCSWeapon_KNIFE, SMCSWeapon_FLASHBANG,
SMCSWeapon_HEGRENADE, SMCSWeapon_SMOKEGRENADE, SMCSWeapon_MOLOTOV, SMCSWeapon_DECOY,
SMCSWeapon_INCGRENADE, SMCSWeapon_C4, SMCSWeapon_KEVLAR, SMCSWeapon_ASSAULTSUIT,
SMCSWeapon_HEAVYASSAULTSUIT, SMCSWeapon_NONE, SMCSWeapon_NIGHTVISION, SMCSWeapon_DEFUSER
};
if (iDefIdx >= SMCSWeapon_MAXWEAPONIDS)
return (SMCSWeapon)iDefIdx;
else
return weaponIDMap[iDefIdx];
}
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
{
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
Q_strlower(tempWeapon);
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
{
}
}
void ClearHashMaps()
{
g_mapClassToDefIdx.clear();
g_mapDefIdxToClass.clear();
g_mapWeaponIDToDefIdx.clear();
}
SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx)
{
//DEAR GOD THIS IS HIDEOUS
//None in the middle are weapons that dont exist.
//If they are added and use the same idx they should be changed to their respective ones
static SMCSWeapon weaponIDMap[SMCSWeapon_MAXWEAPONIDS] =
{
SMCSWeapon_NONE, SMCSWeapon_DEAGLE, SMCSWeapon_ELITE, SMCSWeapon_FIVESEVEN,
SMCSWeapon_GLOCK, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_AK47,
SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1,
SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE,
SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90,
SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE,
SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7,
SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER,
SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA,
SMCSWeapon_P250, SMCSWeapon_NONE, SMCSWeapon_SCAR20, SMCSWeapon_SG556,
SMCSWeapon_SSG08, SMCSWeapon_KNIFE_GG, SMCSWeapon_KNIFE, SMCSWeapon_FLASHBANG,
SMCSWeapon_HEGRENADE, SMCSWeapon_SMOKEGRENADE, SMCSWeapon_MOLOTOV, SMCSWeapon_DECOY,
SMCSWeapon_INCGRENADE, SMCSWeapon_C4, SMCSWeapon_KEVLAR, SMCSWeapon_ASSAULTSUIT,
SMCSWeapon_HEAVYASSAULTSUIT, SMCSWeapon_NONE, SMCSWeapon_NIGHTVISION, SMCSWeapon_DEFUSER
};
if (iDefIdx >= SMCSWeapon_MAXWEAPONIDS)
return (SMCSWeapon)iDefIdx;
else
return weaponIDMap[iDefIdx];
}
ItemDefHashValue *GetHashValueFromWeapon(const char *szWeapon)
{
char tempWeapon[MAX_WEAPON_NAME_LENGTH];
Q_strncpy(tempWeapon, szWeapon, sizeof(tempWeapon));
Q_strlower(tempWeapon);
if (strstr(tempWeapon, "weapon_") == NULL && strstr(tempWeapon, "item_") == NULL)
{
static const char *szClassPrefixs[] = { "weapon_", "item_" };
for (unsigned int i = 0; i < SM_ARRAYSIZE(szClassPrefixs); i++)
{
char classname[MAX_WEAPON_NAME_LENGTH];
Q_snprintf(classname, sizeof(classname), "%s%s", szClassPrefixs[i], tempWeapon);
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
if (res.found())
ClassnameMap::Result res = g_mapClassToDefIdx.find(classname);
if (res.found())
return &res->value;
}
return NULL;
}
ClassnameMap::Result res = g_mapClassToDefIdx.find(tempWeapon);
if (res.found())
return &res->value;
return NULL;
}
#endif
#if SOURCE_ENGINE != SE_CSGO
void *GetWeaponInfo(int weaponID)
{
void *info;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetWeaponInfo", NULL,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(int); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
*(int *)vptr = weaponID;
pWrapper->Execute(vstk, &info);
return info;
}
#endif
const char *GetWeaponNameFromClassname(const char *weapon)
{
}
return NULL;
}
ClassnameMap::Result res = g_mapClassToDefIdx.find(tempWeapon);
if (res.found())
return &res->value;
return NULL;
}
#endif
#if SOURCE_ENGINE != SE_CSGO
void *GetWeaponInfo(int weaponID)
{
void *info;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetWeaponInfo", NULL,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(int); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(void *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
*(int *)vptr = weaponID;
pWrapper->Execute(vstk, &info);
return info;
}
#endif
const char *GetWeaponNameFromClassname(const char *weapon)
{
char *szTemp = strstr((char *)weapon, "_");
if (!szTemp)
@ -429,103 +429,103 @@ const char *GetWeaponNameFromClassname(const char *weapon)
else
{
return (const char *)((intptr_t)szTemp + 1);
}
}
const char *GetTranslatedWeaponAlias(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
const char *alias = NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetTranslatedWeaponAlias", weapon,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &alias);
return alias;
#else //this should work for both games maybe replace both?
static const char *szAliases[] =
{
"cv47", "ak47",
"magnum", "awp",
"d3au1", "g3sg1",
"clarion", "famas",
"bullpup", "aug",
"9x19mm", "glock",
"nighthawk", "deagle",
"elites", "elite",
"fn57", "fiveseven",
"autoshotgun", "xm1014",
"c90", "p90",
"vest", "kevlar",
"vesthelm", "assaultsuit",
"nvgs", "nightvision"
};
for (size_t i = 0; i < SM_ARRAYSIZE(szAliases) / 2; i++)
{
if (Q_stristr(GetWeaponNameFromClassname(weapon), szAliases[i * 2]) != 0)
return szAliases[i * 2 + 1];
}
return GetWeaponNameFromClassname(weapon);
#endif
}
int AliasToWeaponID(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
int weaponID = 0;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("AliasToWeaponID", 0,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(int); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &weaponID);
return weaponID;
#else
ItemDefHashValue *pHashValue = GetHashValueFromWeapon(weapon);
if (pHashValue)
return pHashValue->m_iWeaponID;
return 0;
#endif
}
}
const char *GetTranslatedWeaponAlias(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
const char *alias = NULL;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("GetTranslatedWeaponAlias", weapon,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &alias);
return alias;
#else //this should work for both games maybe replace both?
static const char *szAliases[] =
{
"cv47", "ak47",
"magnum", "awp",
"d3au1", "g3sg1",
"clarion", "famas",
"bullpup", "aug",
"9x19mm", "glock",
"nighthawk", "deagle",
"elites", "elite",
"fn57", "fiveseven",
"autoshotgun", "xm1014",
"c90", "p90",
"vest", "kevlar",
"vesthelm", "assaultsuit",
"nvgs", "nightvision"
};
for (size_t i = 0; i < SM_ARRAYSIZE(szAliases) / 2; i++)
{
if (Q_stristr(GetWeaponNameFromClassname(weapon), szAliases[i * 2]) != 0)
return szAliases[i * 2 + 1];
}
return GetWeaponNameFromClassname(weapon);
#endif
}
int AliasToWeaponID(const char *weapon)
{
#if SOURCE_ENGINE != SE_CSGO
int weaponID = 0;
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
REGISTER_ADDR("AliasToWeaponID", 0,
PassInfo pass[1]; \
PassInfo retpass; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(const char *); \
retpass.flags = PASSFLAG_BYVAL; \
retpass.type = PassType_Basic; \
retpass.size = sizeof(int); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = GetWeaponNameFromClassname(weapon);
pWrapper->Execute(vstk, &weaponID);
return weaponID;
#else
ItemDefHashValue *pHashValue = GetHashValueFromWeapon(weapon);
if (pHashValue)
return pHashValue->m_iWeaponID;
return 0;
#endif
}
const char *WeaponIDToAlias(int weaponID)
@ -565,19 +565,19 @@ const char *WeaponIDToAlias(int weaponID)
return NULL;
#endif
}
bool IsValidWeaponID(int id)
{
if (id <= (int)SMCSWeapon_NONE)
return false;
#if SOURCE_ENGINE == SE_CSGO
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)id);
if (!res.found())
return false;
#else
else if (id > SMCSWeapon_NIGHTVISION || !GetWeaponInfo(id))
return false;
#endif
return true;
}
}
bool IsValidWeaponID(int id)
{
if (id <= (int)SMCSWeapon_NONE)
return false;
#if SOURCE_ENGINE == SE_CSGO
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)id);
if (!res.found())
return false;
#else
else if (id > SMCSWeapon_NIGHTVISION || !GetWeaponInfo(id))
return false;
#endif
return true;
}

View File

@ -1,21 +1,21 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python :
import os
libcurl = builder.RunScript('curl-src/lib/AMBuilder')
libcurl = builder.Build('curl-src/lib/AMBuilder')
binary = SM.ExtLibrary(builder, 'webternet.ext')
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
]
binary.compiler.defines += ['CURL_STATICLIB']
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.compiler.postlink += [libcurl.binary]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-lrt']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.postlink += ['ws2_32.lib']
binary.sources += [

View File

@ -3,27 +3,27 @@ import os, platform
builder.SetBuildFolder('libcurl')
binary = builder.compiler.StaticLibrary('curl')
binary = SM.StaticLibrary(builder, 'curl')
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'lib'),
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
]
if builder.target_platform == 'mac':
if builder.target.platform == 'mac':
mac_version, ignore, ignore = platform.mac_ver()
mac_tuple = mac_version.split('.')
if int(mac_tuple[0]) >= 10 and int(mac_tuple[1]) >= 9:
binary.compiler.defines += ['BUILTIN_STRLCAT']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.defines += [
'BUILDING_LIBCURL',
'CURL_STATICLIB',
'CURL_DISABLE_LDAP',
]
elif builder.target_platform == 'linux':
elif builder.target.platform == 'linux':
binary.compiler.defines += ['_GNU_SOURCE']
if binary.compiler.vendor == 'clang':
if binary.compiler.family == 'clang':
# https://llvm.org/bugs/show_bug.cgi?id=16428
binary.compiler.cflags += ['-Wno-attributes']

View File

@ -2,11 +2,11 @@
import os
binary = SM.ExtLibrary(builder, 'geoip.ext')
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'windows':
if builder.target.platform == 'windows':
binary.compiler.postlink += ['wsock32.lib']
binary.sources += [

View File

@ -7,21 +7,21 @@ if SM.mysql_root:
os.path.join(SM.mysql_root, 'include'),
os.path.join(SM.mms_root, 'core', 'sourcehook')
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'linux' or builder.target_platform == 'mac':
if builder.target.platform == 'linux' or builder.target.platform == 'mac':
binary.compiler.postlink += [
os.path.join(SM.mysql_root, 'lib', 'libmysqlclient_r.a'),
'-lz',
'-lpthread',
'-lm',
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-lrt']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
binary.compiler.postlink += [
os.path.join(SM.mysql_root, 'lib', 'opt', 'mysqlclient.lib'),
os.path.join(SM.mysql_root, 'lib', 'opt', 'zlib.lib'),
@ -38,7 +38,7 @@ if SM.mysql_root:
'extension.cpp'
]
if binary.compiler.vendor == 'msvc' and binary.compiler.version >= 1900:
if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900:
binary.sources += [ 'msvc15hack.c' ]
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']

View File

@ -5,16 +5,16 @@ binary = SM.ExtLibrary(builder, 'regex.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux', 'libpcre.a')
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_win', 'pcre.lib')
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin', 'libpcre.a')
binary.compiler.postlink += [binary.Dep(path)]

View File

@ -17,7 +17,7 @@ for sdk_name in SM.sdks:
binary.compiler.cxxincludes += [
os.path.join(sdk.path, 'game', 'shared')
]
if binary.compiler.cxx.behavior == 'gcc':
if binary.compiler.behavior == 'gcc':
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
SM.extensions += builder.Add(project)

View File

@ -957,7 +957,7 @@ bool SDKHooks::Hook_CanBeAutobalanced()
// Only update our new ret if different from original
// (so if multiple plugins returning different answers,
// the one(s) that changed it win)
if (res != origRet)
if ((bool)res != origRet)
newRet = !origRet;
}

View File

@ -42,7 +42,7 @@ for sdk_name in SM.sdks:
if sdk.name != 'episode1':
binary.compiler.defines += ['HOOKING_ENABLED']
if binary.compiler.cxx.behavior == 'gcc':
if binary.compiler.behavior == 'gcc':
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
SM.extensions += builder.Add(project)

View File

@ -191,6 +191,11 @@ void CHookManager::PlayerRunCmdHook(int client, bool post)
void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
if (!ucmd)
{
RETURN_META(MRES_IGNORED);
}
if (m_usercmdsFwd->GetFunctionCount() == 0)
{
RETURN_META(MRES_IGNORED);
@ -254,6 +259,11 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
void CHookManager::PlayerRunCmdPost(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
if (!ucmd)
{
RETURN_META(MRES_IGNORED);
}
if (m_usercmdsPostFwd->GetFunctionCount() == 0)
{
RETURN_META(MRES_IGNORED);

View File

@ -929,7 +929,16 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
char *classname;
pContext->LocalToString(params[1], &classname);
#if SOURCE_ENGINE != SE_CSGO
CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname);
#else
CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateItemEntityByName(classname);
if(!pEntity)
{
pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname);
}
#endif
return gamehelpers->EntityToBCompatRef(pEntity);
}
#else

View File

@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'dbi.sqlite.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.compiler.defines += [
@ -16,7 +16,7 @@ binary.compiler.defines += [
'SQLITE_USE_URI',
'SQLITE_ALLOW_URI_AUTHORITY',
]
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
binary.compiler.postlink += ['-ldl', '-lpthread']
binary.sources += [

View File

@ -143,6 +143,7 @@ PlayerConditionsMgr::PlayerConditionsMgr()
m_CondOffset[m_nPlayerCondEx] = 32;
m_CondOffset[m_nPlayerCondEx2] = 64;
m_CondOffset[m_nPlayerCondEx3] = 96;
m_CondOffset[m_nPlayerCondEx4] = 128;
}
bool PlayerConditionsMgr::Init()
@ -153,7 +154,8 @@ bool PlayerConditionsMgr::Init()
&& SetupProp<_condition_bits>("_condition_bits")
&& SetupProp<m_nPlayerCondEx>("m_nPlayerCondEx")
&& SetupProp<m_nPlayerCondEx2>("m_nPlayerCondEx2")
&& SetupProp<m_nPlayerCondEx3>("m_nPlayerCondEx3");
&& SetupProp<m_nPlayerCondEx3>("m_nPlayerCondEx3")
&& SetupProp<m_nPlayerCondEx4>("m_nPlayerCondEx4");
if (!bFoundProps)
return false;

View File

@ -52,6 +52,7 @@ public:
m_nPlayerCondEx,
m_nPlayerCondEx2,
m_nPlayerCondEx3,
m_nPlayerCondEx4,
CondVar_Count
};

View File

@ -45,7 +45,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
if(!pWrapper)
{
REGISTER_NATIVE_ADDR("MakeBleed",
PassInfo pass[5]; \
PassInfo pass[6]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].size = sizeof(CBaseEntity *); \
pass[0].type = PassType_Basic; \
@ -61,7 +61,10 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
pass[4].flags = PASSFLAG_BYVAL; \
pass[4].size = sizeof(bool); \
pass[4].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 5))
pass[5].flags = PASSFLAG_BYVAL; \
pass[5].size = sizeof(int); \
pass[5].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 6))
}
CBaseEntity *pEntity;
@ -78,7 +81,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool)];
unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool) + sizeof(int)];
unsigned char *vptr = vstk;
*(void **)vptr = obj;
@ -89,9 +92,11 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(CBaseEntity *);
*(float *)vptr = sp_ctof(params[3]);
vptr += sizeof(float);
*(int *)vptr = 4;
*(int *)vptr = 4; // Damage amount
vptr += sizeof(int);
*(bool *)vptr = false;
*(bool *)vptr = false; // Permanent
vptr += sizeof(bool);
*(int *)vptr = 34; // Custom Damage type (bleeding)
pWrapper->Execute(vstk, NULL);

View File

@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'topmenus.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [

View File

@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'updater.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core', 'sourcehook'),
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.sources += [

View File

@ -7,9 +7,9 @@
{
"CanBeAutobalanced"
{
"windows" "461"
"linux" "462"
"mac" "462"
"windows" "462"
"linux" "463"
"mac" "463"
}
"EndTouch"
{
@ -43,27 +43,27 @@
}
"OnTakeDamage_Alive"
{
"windows" "274"
"linux" "275"
"mac" "275"
"windows" "275"
"linux" "276"
"mac" "276"
}
"PreThink"
{
"windows" "335"
"linux" "336"
"mac" "336"
}
"PostThink"
{
"windows" "336"
"linux" "337"
"mac" "337"
}
"PostThink"
{
"windows" "337"
"linux" "338"
"mac" "338"
}
"Reload"
{
"windows" "275"
"linux" "281"
"mac" "281"
"windows" "276"
"linux" "282"
"mac" "282"
}
"SetTransmit"
{
@ -127,34 +127,34 @@
}
"Weapon_CanSwitchTo"
{
"windows" "268"
"linux" "269"
"mac" "269"
"windows" "269"
"linux" "270"
"mac" "270"
}
"Weapon_CanUse"
{
"windows" "262"
"linux" "263"
"mac" "263"
}
"Weapon_Drop"
{
"windows" "265"
"linux" "266"
"mac" "266"
}
"Weapon_Equip"
{
"windows" "263"
"linux" "264"
"mac" "264"
}
"Weapon_Switch"
"Weapon_Drop"
{
"windows" "266"
"linux" "267"
"mac" "267"
}
"Weapon_Equip"
{
"windows" "264"
"linux" "265"
"mac" "265"
}
"Weapon_Switch"
{
"windows" "267"
"linux" "268"
"mac" "268"
}
}
}

View File

@ -18,33 +18,33 @@
{
"GiveNamedItem"
{
"windows" "400"
"linux" "404"
"mac" "404"
"windows" "401"
"linux" "405"
"mac" "405"
}
"RemovePlayerItem"
{
"windows" "272"
"linux" "273"
"mac" "273"
"windows" "273"
"linux" "274"
"mac" "274"
}
"Weapon_GetSlot"
{
"windows" "270"
"linux" "271"
"mac" "271"
"windows" "271"
"linux" "272"
"mac" "272"
}
"Ignite"
{
"windows" "211"
"linux" "212"
"mac" "212"
"windows" "212"
"linux" "213"
"mac" "213"
}
"Extinguish"
{
"windows" "215"
"linux" "216"
"mac" "216"
"windows" "216"
"linux" "217"
"mac" "217"
}
"Teleport"
{
@ -54,9 +54,9 @@
}
"CommitSuicide"
{
"windows" "444"
"linux" "444"
"mac" "444"
"windows" "445"
"linux" "445"
"mac" "445"
}
"GetVelocity"
{
@ -84,9 +84,9 @@
}
"WeaponEquip"
{
"windows" "263"
"linux" "264"
"mac" "264"
"windows" "264"
"linux" "265"
"mac" "265"
}
"Activate"
{
@ -96,15 +96,15 @@
}
"PlayerRunCmd"
{
"windows" "421"
"linux" "422"
"mac" "422"
"windows" "422"
"linux" "423"
"mac" "423"
}
"GiveAmmo"
{
"windows" "254"
"linux" "255"
"mac" "255"
"windows" "255"
"linux" "256"
"mac" "256"
}
}
@ -123,7 +123,7 @@
"FireOutput"
{
"library" "server"
"windows" "\x55\x8B\xEC\x81\xEC\x24\x01\x00\x00\x53"
"windows" "\x55\x8B\xEC\x81\xEC\x24\x01\x00\x00\x53\x8B\xC1"
"linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f"
"mac" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f"
}

View File

@ -18,21 +18,21 @@
"Burn"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x8B\x8E\x8C\x01\x00\x00\x8B\x01"
"windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x8B\x8E\x90\x01\x00\x00\x8B\x01"
"linux" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayerP13CTFWeaponBasef"
"mac" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayerP13CTFWeaponBasef"
}
"RemoveDisguise"
{
"library" "server"
"windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x57\xF7\x86"
"windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x57\xF7\x86\xD0\x00\x00\x00\x00\x00\x02\x00"
"linux" "@_ZN15CTFPlayerShared14RemoveDisguiseEv"
"mac" "@_ZN15CTFPlayerShared14RemoveDisguiseEv"
}
"Disguise"
{
"library" "server"
"windows" "\x55\x8B\xEC\x51\x56\x57\x8B\xF9\x8B\x8F\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B\x97\x2A\x2A\x2A\x2A\x8B\xF0"
"windows" "\x55\x8B\xEC\x83\xEC\x24\x56\x57\x8B\xF9\x8B\x8F\x90\x01\x00\x00"
"linux" "@_ZN15CTFPlayerShared8DisguiseEiiP9CTFPlayerb"
"mac" "@_ZN15CTFPlayerShared8DisguiseEiiP9CTFPlayerb"
}
@ -53,7 +53,7 @@
"RemoveCondition"
{
"library" "server"
"windows" "\x55\x8B\xEC\x56\x57\x8B\x7D\x08\x8B\xF1\x57\xE8\x2A\x2A\x2A\x2A\x84\xC0\x0F\x84"
"windows" "\x55\x8B\xEC\x83\xEC\x08\x53\x8B\x5D\x08\x56\x53"
"linux" "@_ZN15CTFPlayerShared10RemoveCondE7ETFCondb"
"mac" "@_ZN15CTFPlayerShared10RemoveCondE7ETFCondb"
}
@ -74,16 +74,16 @@
"StunPlayer"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xEC\x24\x57\x8B\xF9\x8B\x87\xF8\x03\x00\x00"
"windows" "\x55\x8B\xEC\x83\xEC\x20\x57\x8B\xF9\x8B\x87\x58\x04\x00\x00"
"linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
"mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
}
"MakeBleed"
{
"library" "server"
"windows" "\x55\x8B\xEC\x83\xEC\x2C\x53\x8B\xD9\x89\x5D\xEC"
"linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib"
"mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib"
"windows" "\x55\x8B\xEC\x83\xEC\x30\x53\x8B\xD9\x89\x5D\xEC"
"linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi"
"mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi"
}
"IsPlayerInDuel"
{
@ -113,21 +113,21 @@
{
"ForceRespawn"
{
"windows" "328"
"linux" "329"
"mac" "329"
"windows" "329"
"linux" "330"
"mac" "330"
}
"CalcIsAttackCriticalHelper"
{
"windows" "387"
"linux" "394"
"mac" "394"
"windows" "389"
"linux" "396"
"mac" "396"
}
"CalcIsAttackCriticalHelperNoCrits"
{
"windows" "388"
"linux" "395"
"mac" "395"
"windows" "390"
"linux" "397"
"mac" "397"
}
// CTFGameRules::IsHolidayActive
@ -140,9 +140,9 @@
"RemoveWearable"
{
"windows" "430"
"linux" "431"
"mac" "431"
"windows" "431"
"linux" "432"
"mac" "432"
}
}
}

View File

@ -1,10 +1,10 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os.path
if builder.target_platform in ['windows', 'mac']:
if builder.target.platform in ['windows', 'mac']:
name = 'sourcemod_mm'
extra_ldflags = []
elif builder.target_platform == 'linux':
elif builder.target.platform == 'linux':
name = 'sourcemod_mm_i486'
extra_ldflags = ['-ldl']
@ -13,9 +13,9 @@ binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core'),
os.path.join(SM.mms_root, 'sourcehook')
]
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.vendor == 'msvc':
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']
binary.compiler.linkflags += extra_ldflags
binary.sources = [

View File

@ -392,7 +392,7 @@ void SendPrivateChat(int client, int target, const char[] message)
}
PrintToChat(target, "\x04(Private to %N) %N: \x01%s", target, client, message);
LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message);
LogAction(client, target, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message);
}
void SendPanelToAll(int from, char[] message)

View File

@ -76,7 +76,7 @@ void PerformBlind(int client, int target, int amount)
EndMessage();
LogAction(client, target, "\"%L\" set blind on \"%L\", amount %d.", client, target, amount);
LogAction(client, target, "\"%L\" set blind on \"%L\" (amount \"%d\")", client, target, amount);
}
public void AdminMenu_Blind(TopMenu topmenu,

View File

@ -36,7 +36,7 @@ int g_GravityTarget[MAXPLAYERS+1];
void PerformGravity(int client, int target, float amount)
{
SetEntityGravity(target, amount);
LogAction(client, target, "\"%L\" set gravity on \"%L\" to %f.", client, target, amount);
LogAction(client, target, "\"%L\" set gravity on \"%L\" (amount \"%f\")", client, target, amount);
}
public void AdminMenu_Gravity(TopMenu topmenu,

View File

@ -143,6 +143,22 @@ struct SharedPlugin
public float NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
public const char NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */
/**
* Check if the given vector is the NULL_VECTOR.
*
* @param vec The vector to test.
* @return True if NULL_VECTOR, false otherwise.
*/
native bool IsNullVector(const float vec[3]);
/**
* Check if the given string is the NULL_STRING.
*
* @param str The string to test.
* @return True if NULL_STRING, false otherwise.
*/
native bool IsNullString(const char[] str);
/**
* Horrible compatibility shim.
*/

View File

@ -290,6 +290,16 @@ native void Call_PushArray(const any[] value, int size);
*/
native void Call_PushArrayEx(any[] value, int size, int cpflags);
/**
* Pushes the NULL_VECTOR onto the current call.
* @see IsNullVector
*
* @note Cannot be used before a call has been started.
*
* @error Called before a call has been started.
*/
native void Call_PushNullVector();
/**
* Pushes a string onto the current call.
*
@ -317,6 +327,16 @@ native void Call_PushString(const char[] value);
*/
native void Call_PushStringEx(char[] value, int length, int szflags, int cpflags);
/**
* Pushes the NULL_STRING onto the current call.
* @see IsNullString
*
* @note Cannot be used before a call has been started.
*
* @error Called before a call has been started.
*/
native void Call_PushNullString();
/**
* Completes a call to a function or forward's call list.
*
@ -465,6 +485,22 @@ native int GetNativeArray(int param, any[] local, int size);
*/
native int SetNativeArray(int param, const any[] local, int size);
/**
* Check if the native parameter is the NULL_VECTOR.
*
* @param param Parameter number, starting from 1.
* @return True if NULL_VECTOR, false otherwise.
*/
native bool IsNativeParamNullVector(int param);
/**
* Check if the native parameter is the NULL_STRING.
*
* @param param Parameter number, starting from 1.
* @return True if NULL_STRING, false otherwise.
*/
native bool IsNativeParamNullString(int param);
/**
* Formats a string using parameters from a native.
*

View File

@ -42,6 +42,7 @@
#define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) /**< no sound or particle */
#define TF_STUNFLAG_THIRDPERSON (1 << 6) /**< panic animation */
#define TF_STUNFLAG_GHOSTEFFECT (1 << 7) /**< ghost particles */
#define TF_STUNFLAG_SOUND (1 << 8) /**< sound */
#define TF_STUNFLAGS_LOSERSTATE TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON
#define TF_STUNFLAGS_GHOSTSCARE TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON
@ -195,7 +196,17 @@ enum TFCond
TFCond_KnockedIntoAir,
TFCond_CompetitiveWinner,
TFCond_CompetitiveLoser,
TFCond_NoTaunting,
TFCond_NoTaunting_DEPRECATED,
TFCond_HealingDebuff = 118,
TFCond_PasstimePenaltyDebuff,
TFCond_GrappledToPlayer,
TFCond_GrappledByPlayer,
TFCond_ParachuteDeployed,
TFCond_Gas,
TFCond_BurningPyro,
TFCond_RocketPack,
TFCond_LostFooting,
TFCond_AirCurrent,
};
const float TFCondDuration_Infinite = -1.0;

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ char g_NewName[MAXPLAYERS+1][MAX_NAME_LENGTH];
void PerformRename(int client, int target)
{
LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]);
LogAction(client, target, "\"%L\" renamed \"%L\" (to \"%s\")", client, target, g_NewName[target]);
SetClientName(target, g_NewName[target]);

View File

@ -50,7 +50,7 @@
using namespace SourcePawn;
#define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager"
#define SMINTERFACE_FORWARDMANAGER_VERSION 3
#define SMINTERFACE_FORWARDMANAGER_VERSION 4
/*
* There is some very important documentation at the bottom of this file.
@ -118,6 +118,7 @@ namespace SourceMod
cell_t val;
ByrefInfo byref;
ParamType pushedas;
bool isnull;
};
class IForwardFilter
@ -177,12 +178,21 @@ namespace SourceMod
* @brief Pushes an array of cells onto the current call. Different rules than ICallable.
* NOTE: On Execute, the pointer passed will be modified according to the copyback rule.
*
* @param inarray Array to copy. Cannot be NULL, unlike ICallable's version.
* @param inarray Array to copy. If NULL and cells is 3 pushes a reference to the NULL_VECTOR pubvar to each callee.
* Pushing other number of cells is not allowed, unlike ICallable's version.
* @param cells Number of cells to allocate and optionally read from the input array.
* @param flags Whether or not changes should be copied back to the input array.
* @return Error code, if any.
*/
virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0;
/**
* @brief Pushes a string onto the current call.
*
* @param string String to push. If NULL pushes a reference to the NULL_STRING pubvar to each callee.
* @return Error code, if any.
*/
virtual int PushString(const char *string) = 0;
};
/**

@ -1 +1 @@
Subproject commit e3a888eab7ee73e7fbff9f3e2f0529a87b284d39
Subproject commit 50dbd2f8f6f13e799037919470064878bd4a3960

View File

@ -71,3 +71,5 @@ R.I.P. Wade Boggs
Your tier1 tower is under attack..
Christmas!!!
the mousse angles are smooth
spoilers

@ -1 +1 @@
Subproject commit 12365b39ccc20ab6c5fa28ec56f1c593d177b91c
Subproject commit c78349382d97d5a9f20b49975c47d9bb805c125d

View File

@ -7,19 +7,19 @@ UPLOAD_SCRIPT = os.path.join(builder.sourcePath, 'tools', 'buildbot', 'upload_sy
cxx_tasks = SM.binaries + SM.extensions + [SM.spcomp]
for cxx_task in cxx_tasks:
if builder.target_platform in ['windows']:
if builder.target.platform in ['windows']:
debug_entry = cxx_task.debug
else:
debug_entry = cxx_task.binary
debug_file = os.path.join(builder.buildPath, debug_entry.path)
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
argv = ['dump_syms', debug_file, os.path.dirname(debug_file)]
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
# Required once dump_syms is updated on the slaves.
#argv = ['dump_syms', '-g', debug_file + '.dSYM', debug_file]
argv = ['dump_syms', debug_file + '.dSYM']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
argv = ['dump_syms.exe', debug_file]
base_file = os.path.splitext(os.path.basename(debug_file))[0]

View File

@ -474,7 +474,7 @@ CopyFiles('plugins/playercommands', 'addons/sourcemod/scripting/playercommands',
]
)
if builder.target_platform == 'windows':
if builder.target.platform == 'windows':
CopyFiles('tools/batchtool', 'addons/sourcemod/scripting', ['compile.exe'])
else:
CopyFiles('plugins', 'addons/sourcemod/scripting', ['compile.sh'])

View File

@ -50,7 +50,7 @@ def output_version_headers():
count, shorthash, longhash = get_git_version()
with open(os.path.join(SourceFolder, 'product.version')) as fp:
contents = fp.read()
contents = fp.read().strip()
m = re.match('(\d+)\.(\d+)\.(\d+)-?(.*)', contents)
if m == None:
raise Exception('Could not detremine product version')

View File

@ -1,7 +1,7 @@
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
import os
lib = builder.compiler.StaticLibrary('version')
lib = SM.StaticLibrary(builder, 'version')
lib.compiler.includes += [
os.path.join(builder.sourcePath, 'public')
]