Compare commits
198
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cf8f2b11f | ||
|
|
91cc6b300c | ||
|
|
ec3351a320 | ||
|
|
aa2a71fc67 | ||
|
|
142e76bd92 | ||
|
|
632429700b | ||
|
|
a8d95ca044 | ||
|
|
28b4b248f7 | ||
|
|
964c9ae835 | ||
|
|
d099dbb659 | ||
|
|
688e274c30 | ||
|
|
a5ff53f00f | ||
|
|
38fc001a1d | ||
|
|
4b949e8228 | ||
|
|
080c4bb8e2 | ||
|
|
149b16cbf3 | ||
|
|
b940b01be4 | ||
|
|
45258b8561 | ||
|
|
ab7b9b231d | ||
|
|
76c2addeb9 | ||
|
|
7cb7703cf9 | ||
|
|
c2b204e810 | ||
|
|
24c92c021c | ||
|
|
dd370c3904 | ||
|
|
384fb668d1 | ||
|
|
1903c0bd2b | ||
|
|
13034eff05 | ||
|
|
a4703722be | ||
|
|
2e13460823 | ||
|
|
d356d80537 | ||
|
|
412759cbc4 | ||
|
|
08841227a4 | ||
|
|
18b2ffa786 | ||
|
|
3e9a48c778 | ||
|
|
339fd85c6f | ||
|
|
59144cf868 | ||
|
|
ad3a44427a | ||
|
|
737d8c3240 | ||
|
|
4688783baf | ||
|
|
ba5c6ad07c | ||
|
|
69045ccd52 | ||
|
|
cf39d4b820 | ||
|
|
cb218a4911 | ||
|
|
344284196c | ||
|
|
e7c0726acd | ||
|
|
d0b34e783d | ||
|
|
d481e5fcb7 | ||
|
|
1459c10112 | ||
|
|
8b9131f6e4 | ||
|
|
ce1a21ba0b | ||
|
|
e2237ce875 | ||
|
|
250bbf5955 | ||
|
|
0478912d73 | ||
|
|
d50e4b7a2f | ||
|
|
abf59a4f4b | ||
|
|
9b80e46097 | ||
|
|
bbbaebd32a | ||
|
|
1204d1fd0f | ||
|
|
ef34cc67b6 | ||
|
|
25184aa9c7 | ||
|
|
b789d30658 | ||
|
|
305799b441 | ||
|
|
92fc27f67f | ||
|
|
5292721f0b | ||
|
|
4e0c47a1d5 | ||
|
|
65b6602a19 | ||
|
|
1723f97202 | ||
|
|
ec92653bb7 | ||
|
|
b25d25890a | ||
|
|
b27243c3ac | ||
|
|
be648382d7 | ||
|
|
b5ed266941 | ||
|
|
2ffaa04130 | ||
|
|
eddf9cf843 | ||
|
|
7c1095e4e7 | ||
|
|
686e8b4d7e | ||
|
|
edc73649ff | ||
|
|
1ad8bb4560 | ||
|
|
7eabeaa384 | ||
|
|
4547270934 | ||
|
|
3a2c5cb0f7 | ||
|
|
7648c7fe03 | ||
|
|
ffb6d769e8 | ||
|
|
77f999f810 | ||
|
|
c5049990a3 | ||
|
|
0e4894e8db | ||
|
|
19f1ffa401 | ||
|
|
c206ac3099 | ||
|
|
e03320c80e | ||
|
|
2ae4624344 | ||
|
|
66c8005666 | ||
|
|
210219030e | ||
|
|
370fa8209b | ||
|
|
88a0a458a6 | ||
|
|
e4afe31fc0 | ||
|
|
fb0144900f | ||
|
|
542b7673d6 | ||
|
|
cc1c02e3de | ||
|
|
4fc0a85581 | ||
|
|
6733c4182d | ||
|
|
28ef59ada5 | ||
|
|
647e320b57 | ||
|
|
cdfbdcc29d | ||
|
|
4f94b4f900 | ||
|
|
53be0e0812 | ||
|
|
88dd142f5c | ||
|
|
1d5ec7b982 | ||
|
|
f1a71b0d5a | ||
|
|
85b8e09e8a | ||
|
|
df9b0ef1b3 | ||
|
|
f81412b4fa | ||
|
|
bd478ebdfc | ||
|
|
a57573864a | ||
|
|
6b6436db17 | ||
|
|
c88b18e520 | ||
|
|
8c001872a8 | ||
|
|
5db571bbc6 | ||
|
|
1f561b54f3 | ||
|
|
77a0fb4402 | ||
|
|
c72736dcfa | ||
|
|
d16f45c4b6 | ||
|
|
e280d33a28 | ||
|
|
fb1d501c24 | ||
|
|
3c0f700a6b | ||
|
|
45e9da90fc | ||
|
|
a60c443b29 | ||
|
|
b064366169 | ||
|
|
a06a903989 | ||
|
|
e67fdf2331 | ||
|
|
e2ca3a9493 | ||
|
|
9099634b95 | ||
|
|
f182feed9d | ||
|
|
02dd6a9c00 | ||
|
|
b421a0c594 | ||
|
|
9ec5cb819c | ||
|
|
f8e664b797 | ||
|
|
42575f7cc3 | ||
|
|
aa98f60ca3 | ||
|
|
d5f47a88e6 | ||
|
|
62f08a31fc | ||
|
|
e565c83494 | ||
|
|
a68ff2a587 | ||
|
|
377888276e | ||
|
|
52b8e95aae | ||
|
|
bb6e6fd3b6 | ||
|
|
0449342bb0 | ||
|
|
3171d4fb7b | ||
|
|
066818fbec | ||
|
|
255f5ea745 | ||
|
|
2e763c287c | ||
|
|
29c33bfcc9 | ||
|
|
88bdbf4866 | ||
|
|
1559b75ae7 | ||
|
|
ff00e3d036 | ||
|
|
daa1a4df14 | ||
|
|
4e2ace9d2f | ||
|
|
ee722d778f | ||
|
|
e82f0acdb8 | ||
|
|
383cd81be6 | ||
|
|
6250db7dba | ||
|
|
8ae3be7185 | ||
|
|
64b897822f | ||
|
|
0ad0d839a0 | ||
|
|
55382e0a0f | ||
|
|
d8b00675d6 | ||
|
|
633298b6a9 | ||
|
|
656a9fa94f | ||
|
|
bb7929594d | ||
|
|
d4545a105e | ||
|
|
1c788b5c0a | ||
|
|
7ce8a80bf6 | ||
|
|
d0c4657b75 | ||
|
|
167e6d8571 | ||
|
|
b909ea07ec | ||
|
|
410eb01f91 | ||
|
|
f18c6fb9af | ||
|
|
c66175d64e | ||
|
|
a3fbbe41f2 | ||
|
|
ed5713b3fd | ||
|
|
4b01feea45 | ||
|
|
800f613f92 | ||
|
|
4c9e856197 | ||
|
|
0cb3fcaed8 | ||
|
|
02e2659ba5 | ||
|
|
507b09c975 | ||
|
|
907fa77381 | ||
|
|
c5c302dccc | ||
|
|
c49d51206c | ||
|
|
f48cbaab75 | ||
|
|
61c634a870 | ||
|
|
fec978afb4 | ||
|
|
74ad70ba30 | ||
|
|
fe27c8810e | ||
|
|
b4c5726fc2 | ||
|
|
53c8d5533a | ||
|
|
4e66452e58 | ||
|
|
63545eb741 | ||
|
|
a7af242453 |
@@ -1,8 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
# Check for updates to GitHub Actions every week
|
||||
interval: "weekly"
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-18.04, ubuntu-latest, windows-latest]
|
||||
include:
|
||||
- os: windows-latest
|
||||
os_short: win
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
os_short: linux
|
||||
compiler_cc: clang
|
||||
compiler_cxx: clang++
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-18.04
|
||||
os_short: linux
|
||||
compiler_cc: clang-8
|
||||
compiler_cxx: clang++-8
|
||||
@@ -34,15 +34,15 @@ jobs:
|
||||
DEPENDENCIES_FOLDER: dependencies
|
||||
DEPENDENCIES_ROOT: ${{ github.workspace }}/dependencies
|
||||
MYSQL_VERSION: '5.5'
|
||||
MMSOURCE_VERSION: '1.12'
|
||||
MMSOURCE_VERSION: '1.10'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
path: sourcemod
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: hl2sdk-mysql-mmsource
|
||||
with:
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-
|
||||
|
||||
# Setup Python for AMBuild
|
||||
- uses: actions/setup-python@v5
|
||||
- uses: actions/setup-python@v2
|
||||
name: Setup Python 3.8
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
name: hl2sdk-mock tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- '[0-9]+.[0-9]+-dev'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- '[0-9]+.[0-9]+-dev'
|
||||
jobs:
|
||||
mock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
name: Clone sourcemod
|
||||
with:
|
||||
submodules: recursive
|
||||
path: sourcemod
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
name: Clone metamod-source
|
||||
with:
|
||||
repository: alliedmodders/metamod-source
|
||||
submodules: recursive
|
||||
path: metamod-source
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
name: Clone hl2sdk-mock
|
||||
with:
|
||||
repository: alliedmodders/hl2sdk-mock
|
||||
submodules: recursive
|
||||
path: hl2sdk-mock
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
name: Setup Python 3.10
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install AMBuild
|
||||
run: |
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install git+https://github.com/alliedmodders/ambuild
|
||||
|
||||
- name: Build MetaMod:Source
|
||||
working-directory: metamod-source
|
||||
run: |
|
||||
python configure.py --enable-optimize --sdks=mock --targets=x86_64
|
||||
ambuild objdir
|
||||
|
||||
- name: Build SourceMod
|
||||
working-directory: sourcemod
|
||||
run: |
|
||||
python configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86_64
|
||||
ambuild objdir
|
||||
|
||||
- name: Build hl2sdk-mock
|
||||
working-directory: hl2sdk-mock
|
||||
run: |
|
||||
python configure.py --enable-optimize --targets=x86_64
|
||||
ambuild objdir
|
||||
|
||||
- name: Setup gamedir
|
||||
working-directory: hl2sdk-mock
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ../gamedir
|
||||
./build_gamedir.sh ../gamedir ../metamod-source/objdir/package
|
||||
./build_gamedir.sh ../gamedir ../sourcemod/objdir/package
|
||||
|
||||
- name: Compile testsuite
|
||||
working-directory: hl2sdk-mock
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ../gamedir/addons/sourcemod/plugins/optional
|
||||
|
||||
for f in ../sourcemod/plugins/testsuite/mock/*.sp; do
|
||||
echo "Compiling $(basename $f)"
|
||||
../gamedir/addons/sourcemod/scripting/spcomp64 -i ../gamedir/addons/sourcemod/scripting/include -o "../gamedir/addons/sourcemod/plugins/optional/$(basename $f .sp).smx" -E "$f"
|
||||
done
|
||||
|
||||
- name: Test
|
||||
working-directory: hl2sdk-mock
|
||||
shell: bash
|
||||
run: |
|
||||
for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do
|
||||
echo "==================================="
|
||||
echo "Running $(basename $f)..."
|
||||
echo "==================================="
|
||||
timeout 60 ./objdir/dist/x86_64/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 |
|
||||
{
|
||||
failed=0
|
||||
while IFS= read -r line; do
|
||||
echo "$line"
|
||||
if [[ "$line" == *"FAIL"* ]]; then
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
if [ "$failed" = "1" ]; then
|
||||
echo "$(basename $f) failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
done
|
||||
@@ -27,12 +27,12 @@ jobs:
|
||||
env:
|
||||
ARCH: x86,x86_64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# Setup Python for AMBuild
|
||||
- uses: actions/setup-python@v5
|
||||
- uses: actions/setup-python@v2
|
||||
name: Setup Python 3.8
|
||||
with:
|
||||
python-version: 3.8
|
||||
@@ -41,9 +41,9 @@ jobs:
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install git+https://github.com/alliedmodders/ambuild
|
||||
|
||||
- name: Build universal x64/arm64 on macOS
|
||||
- name: Build only for x64 on macOS
|
||||
if: startsWith(runner.os, 'macOS')
|
||||
run: echo "ARCH=x86_64,arm64" >> $GITHUB_ENV
|
||||
run: echo "ARCH=x86_64" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: startsWith(runner.os, 'Linux')
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
echo "SM_VERSION=$(cat ../product.version)" >> $GITHUB_ENV
|
||||
|
||||
- name: Archive tooling
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: sourcemod-tooling-${{ env.SM_VERSION }}-${{ matrix.os_short }}
|
||||
path: build/package
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
name: Update translation project
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'translations/**'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
update_translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
name: Setup Python 3.10
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install Python dependencies
|
||||
working-directory: tools/language_check
|
||||
run: |
|
||||
python -m pip install --upgrade -r requirements.txt
|
||||
|
||||
- name: Generate token
|
||||
id: generate_token
|
||||
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
|
||||
with:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.APP_PEM }}
|
||||
|
||||
- name: Update translation project
|
||||
working-directory: tools/language_check
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
ORGANIZATION: alliedmodders
|
||||
PROJECT_NUMBER: 1
|
||||
run: |
|
||||
python ./compare_translation_phrases.py
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
name: Sanity check translation phrases
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'translations/**'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'translations/**'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
check_translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
name: Setup Python 3.10
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Check translation phrases syntax
|
||||
working-directory: tools/language_check
|
||||
run: |
|
||||
python ./sanity_check.py
|
||||
|
||||
+2
-3
@@ -28,6 +28,7 @@ LIB-Debug/
|
||||
[Tt]humbs.db
|
||||
|
||||
# AMBuild build directories
|
||||
build*/
|
||||
obj-*/
|
||||
*~
|
||||
*.rej
|
||||
@@ -36,8 +37,6 @@ obj-*/
|
||||
*.swp
|
||||
*.gdb_history
|
||||
objdir
|
||||
# Not standardized, but common name for build directories
|
||||
build*/
|
||||
|
||||
.vs/*
|
||||
.vscode/*
|
||||
.vscode/*
|
||||
@@ -6,9 +6,3 @@
|
||||
path = sourcepawn
|
||||
url = https://github.com/alliedmodders/sourcepawn
|
||||
shallow = true
|
||||
[submodule "hl2sdk-manifests"]
|
||||
path = hl2sdk-manifests
|
||||
url = https://github.com/alliedmodders/hl2sdk-manifests.git
|
||||
[submodule "public/safetyhook"]
|
||||
path = public/safetyhook
|
||||
url = https://github.com/alliedmodders/safetyhook
|
||||
|
||||
+270
-107
@@ -2,6 +2,81 @@
|
||||
import collections
|
||||
import os, sys
|
||||
import subprocess
|
||||
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']
|
||||
Blade = {
|
||||
'windows': ['x86', 'x86_64'],
|
||||
'linux': ['x86_64'],
|
||||
'mac': ['x86_64']
|
||||
}
|
||||
CSGO = {
|
||||
'windows': ['x86'],
|
||||
'linux': ['x86', 'x86_64'],
|
||||
'mac': ['x86_64']
|
||||
}
|
||||
Mock = {
|
||||
'windows': ['x86', 'x86_64'],
|
||||
'linux': ['x86', 'x86_64'],
|
||||
'mac': ['x86_64']
|
||||
}
|
||||
|
||||
SDKMap = {
|
||||
'episode1': SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
|
||||
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
|
||||
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
|
||||
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
|
||||
'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
|
||||
'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
|
||||
'tf2': SDK('HL2SDKTF2', '2.tf2', '11', 'TF2', WinLinuxMac, 'tf2'),
|
||||
'l4d': SDK('HL2SDKL4D', '2.l4d', '12', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
|
||||
'nucleardawn': SDK('HL2SDKND', '2.nd', '13', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
|
||||
'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '15', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
|
||||
'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
|
||||
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'),
|
||||
'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
|
||||
'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
|
||||
'csgo': SDK('HL2SDKCSGO', '2.csgo', '21', 'CSGO', CSGO, 'csgo'),
|
||||
'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'),
|
||||
'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', Blade, 'blade'),
|
||||
'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'),
|
||||
'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'),
|
||||
'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'),
|
||||
'doi': SDK('HL2SDKDOI', '2.doi', '20', 'DOI', WinLinuxMac, 'doi'),
|
||||
'mock': SDK('HL2SDK-MOCK', '2.mock', '999', 'MOCK', Mock, 'mock'),
|
||||
}
|
||||
|
||||
# Stable sorting for command equivalence in AMBuild.
|
||||
PossibleSDKs = collections.OrderedDict()
|
||||
for key in sorted(SDKMap.keys()):
|
||||
PossibleSDKs[key] = SDKMap[key]
|
||||
|
||||
def ResolveEnvPath(env, folder):
|
||||
if env in os.environ:
|
||||
@@ -32,15 +107,9 @@ def SetArchFlags(compiler):
|
||||
if compiler.target.arch == 'x86_64':
|
||||
compiler.defines += ['WIN64']
|
||||
|
||||
SdkHelpers = builder.Eval('hl2sdk-manifests/SdkHelpers.ambuild', {
|
||||
'Project': 'sourcemod'
|
||||
})
|
||||
|
||||
class SMConfig(object):
|
||||
def __init__(self):
|
||||
self.sdk_manifests = []
|
||||
self.sdks = {}
|
||||
self.sdk_targets = []
|
||||
self.binaries = []
|
||||
self.spvm = []
|
||||
self.extensions = []
|
||||
@@ -48,14 +117,13 @@ class SMConfig(object):
|
||||
self.mms_root = None
|
||||
self.mysql_root = {}
|
||||
self.spcomp = None
|
||||
self.spcomp_bins = []
|
||||
self.spcomp_bins = None
|
||||
self.smx_files = {}
|
||||
self.versionlib = None
|
||||
self.all_targets = []
|
||||
self.target_archs = set()
|
||||
self.enable_asan = getattr(builder.options, 'enable_asan', False)
|
||||
self.asan_libs = {}
|
||||
self.libsafetyhook = {}
|
||||
|
||||
if builder.options.targets:
|
||||
target_archs = builder.options.targets.split(',')
|
||||
@@ -97,38 +165,43 @@ class SMConfig(object):
|
||||
import re
|
||||
with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp:
|
||||
productContents = fp.read()
|
||||
m = re.match(r'(\d+)\.(\d+)\.(\d+).*', productContents)
|
||||
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 findSdkPath(self, sdk_name):
|
||||
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)
|
||||
|
||||
def shouldIncludeSdk(self, sdk):
|
||||
return not sdk.get('source2', False)
|
||||
|
||||
def detectSDKs(self):
|
||||
sdk_list = [s for s in builder.options.sdks.split(',') if s]
|
||||
SdkHelpers.sdk_filter = self.shouldIncludeSdk
|
||||
SdkHelpers.find_sdk_path = self.findSdkPath
|
||||
SdkHelpers.findSdks(builder, self.all_targets, sdk_list)
|
||||
sdk_list = builder.options.sdks.split(',')
|
||||
use_none = sdk_list[0] == 'none'
|
||||
use_all = sdk_list[0] == 'all'
|
||||
use_present = sdk_list[0] == 'present'
|
||||
|
||||
self.sdks = SdkHelpers.sdks
|
||||
self.sdk_manifests = SdkHelpers.sdk_manifests
|
||||
self.sdk_targets = SdkHelpers.sdk_targets
|
||||
for sdk_name in PossibleSDKs:
|
||||
sdk = PossibleSDKs[sdk_name]
|
||||
if sdk.shouldBuild(self.all_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 and sdk_name != 'mock') 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.mms_path:
|
||||
self.mms_root = builder.options.mms_path
|
||||
else:
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE111', 'mmsource-1.11')
|
||||
if not self.mms_root:
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
|
||||
if not self.mms_root:
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
|
||||
if not self.mms_root:
|
||||
@@ -166,14 +239,7 @@ class SMConfig(object):
|
||||
def configure(self):
|
||||
builder.AddConfigureFile('pushbuild.txt')
|
||||
|
||||
allowed_archs = ['x86_64']
|
||||
if builder.host.platform == 'mac':
|
||||
if getattr(builder.options, 'scripting_only', False):
|
||||
allowed_archs += ['arm64']
|
||||
else:
|
||||
allowed_archs += ['x86']
|
||||
|
||||
if not set(self.target_archs).issubset(allowed_archs):
|
||||
if not set(self.target_archs).issubset(['x86', 'x86_64']):
|
||||
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
|
||||
|
||||
for cxx in self.all_targets:
|
||||
@@ -181,14 +247,14 @@ class SMConfig(object):
|
||||
|
||||
def configure_cxx(self, cxx):
|
||||
if cxx.family == 'msvc':
|
||||
if cxx.version < 1914 and builder.options.generator != 'vs':
|
||||
raise Exception(f'Only MSVC 2017 15.7 and later are supported, full C++17 support is required. ({str(cxx.version)} < 1914)')
|
||||
elif cxx.family == 'gcc':
|
||||
if cxx.version < 'gcc-9':
|
||||
raise Exception('Only GCC versions 9 or later are supported, full C++17 support is required.')
|
||||
elif cxx.family == 'clang':
|
||||
if cxx.version < 'clang-5':
|
||||
raise Exception('Only clang versions 5 or later are supported, full C++17 support is required.')
|
||||
if cxx.version < 1900:
|
||||
raise Exception('Only MSVC 2015 and later are supported, c++14 support is required.')
|
||||
if cxx.family == 'gcc':
|
||||
if cxx.version < 'gcc-4.9':
|
||||
raise Exception('Only GCC versions 4.9 or greater are supported, c++14 support is required.')
|
||||
if cxx.family == 'clang':
|
||||
if cxx.version < 'clang-3.4':
|
||||
raise Exception('Only clang versions 3.4 or greater are supported, c++14 support is required.')
|
||||
|
||||
if cxx.like('gcc'):
|
||||
self.configure_gcc(cxx)
|
||||
@@ -243,18 +309,19 @@ class SMConfig(object):
|
||||
'-Wno-unused',
|
||||
'-Wno-switch',
|
||||
'-Wno-array-bounds',
|
||||
'-msse',
|
||||
'-fvisibility=hidden',
|
||||
]
|
||||
if cxx.target.arch in ['x86', 'x86_64']:
|
||||
cxx.cflags += ['-msse']
|
||||
|
||||
cxx.cxxflags += ['-std=c++17']
|
||||
if cxx.version == 'apple-clang-6.0' or cxx.version == 'clang-3.4':
|
||||
cxx.cxxflags += ['-std=c++1y']
|
||||
else:
|
||||
cxx.cxxflags += ['-std=c++14']
|
||||
|
||||
cxx.cxxflags += [
|
||||
'-fno-threadsafe-statics',
|
||||
'-Wno-non-virtual-dtor',
|
||||
'-Wno-overloaded-virtual',
|
||||
'-Wno-register',
|
||||
'-fvisibility-inlines-hidden',
|
||||
]
|
||||
|
||||
@@ -331,7 +398,6 @@ class SMConfig(object):
|
||||
'/EHsc',
|
||||
'/GR-',
|
||||
'/TP',
|
||||
'/std:c++17',
|
||||
]
|
||||
cxx.linkflags += [
|
||||
'kernel32.lib',
|
||||
@@ -383,7 +449,7 @@ class SMConfig(object):
|
||||
self.asan_libs[cxx.target.arch] = os.path.dirname(output)
|
||||
|
||||
def configure_linux(self, cxx):
|
||||
cxx.defines += ['LINUX', '_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
|
||||
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
|
||||
cxx.linkflags += ['-lm']
|
||||
if cxx.family == 'gcc':
|
||||
cxx.linkflags += ['-static-libgcc']
|
||||
@@ -393,9 +459,9 @@ class SMConfig(object):
|
||||
|
||||
def configure_mac(self, cxx):
|
||||
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.15']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.7']
|
||||
cxx.linkflags += [
|
||||
'-mmacosx-version-min=10.15',
|
||||
'-mmacosx-version-min=10.7',
|
||||
'-stdlib=libc++',
|
||||
'-lc++',
|
||||
]
|
||||
@@ -439,7 +505,6 @@ class SMConfig(object):
|
||||
self.AddVersioning(binary)
|
||||
if binary.compiler.like('msvc'):
|
||||
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
|
||||
self.AddCxxCompat(binary)
|
||||
|
||||
# Dumb clang behavior means we have to manually find libclang_rt.
|
||||
if self.enable_asan:
|
||||
@@ -499,12 +564,6 @@ class SMConfig(object):
|
||||
self.ConfigureForExtension(context, binary.compiler)
|
||||
return binary
|
||||
|
||||
def AddCxxCompat(self, binary):
|
||||
if binary.compiler.target.platform == 'linux':
|
||||
binary.sources += [
|
||||
os.path.join(builder.sourcePath, 'public', 'amtl', 'compat', 'stdcxx.cpp'),
|
||||
]
|
||||
|
||||
def ConfigureForHL2(self, context, binary, sdk):
|
||||
compiler = binary.compiler
|
||||
SetArchFlags(compiler)
|
||||
@@ -514,24 +573,155 @@ class SMConfig(object):
|
||||
os.path.join(self.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
|
||||
for other_sdk in self.sdk_manifests:
|
||||
compiler.defines += ['SE_{}={}'.format(other_sdk['define'], other_sdk['code'])]
|
||||
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
|
||||
compiler.defines += defines
|
||||
|
||||
SdkHelpers.configureCxx(context, binary, sdk)
|
||||
paths = [
|
||||
['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.linkflags += ['-lstdc++']
|
||||
compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
|
||||
elif compiler.target.platform == 'mac':
|
||||
if sdk.name in ['csgo']:
|
||||
# Switch libc++ to libstdc++ for protobuf linkage.
|
||||
compiler.cxxflags.remove('-stdlib=libc++')
|
||||
compiler.linkflags.remove('-stdlib=libc++')
|
||||
compiler.linkflags.remove('-lc++')
|
||||
|
||||
compiler.cxxflags += ['-stdlib=libstdc++']
|
||||
compiler.linkflags += ['-stdlib=libstdc++']
|
||||
compiler.linkflags += ['-lstdc++']
|
||||
|
||||
if 'c++1y' in compiler.cxxflags:
|
||||
compiler.cxxflags.remove('-std=c++1y')
|
||||
compiler.cxxflags += ['-std=c++11']
|
||||
elif 'c++14' in compiler.cxxflags:
|
||||
compiler.cxxflags.remove('-std=c++14')
|
||||
compiler.cxxflags += ['-std=c++11']
|
||||
|
||||
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', 'mock']:
|
||||
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
|
||||
|
||||
def AddCDetour(self, binary):
|
||||
public_path = os.path.join(builder.sourcePath, 'public')
|
||||
binary.sources += [ os.path.join(public_path, 'CDetour', 'detours.cpp') ]
|
||||
binary.compiler.cxxincludes += [ os.path.join(public_path, 'safetyhook', 'include') ]
|
||||
|
||||
for task in self.libsafetyhook:
|
||||
if task.target.arch == binary.compiler.target.arch:
|
||||
binary.compiler.linkflags += [task.binary]
|
||||
return
|
||||
raise Exception('No suitable build of safetyhook was found.')
|
||||
|
||||
def HL2Library(self, context, compiler, name, sdk):
|
||||
binary = self.Library(context, compiler, name)
|
||||
self.ConfigureForExtension(context, binary.compiler)
|
||||
@@ -539,15 +729,13 @@ class SMConfig(object):
|
||||
|
||||
def HL2Config(self, project, context, compiler, name, sdk):
|
||||
binary = project.Configure(compiler, name,
|
||||
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
|
||||
self.AddCxxCompat(binary)
|
||||
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
||||
self.AddVersioning(binary)
|
||||
return self.ConfigureForHL2(context, binary, sdk)
|
||||
|
||||
def HL2ExtConfig(self, project, context, compiler, name, sdk):
|
||||
binary = project.Configure(compiler, name,
|
||||
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
|
||||
self.AddCxxCompat(binary)
|
||||
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
||||
self.AddVersioning(binary)
|
||||
self.ConfigureForHL2(context, binary, sdk)
|
||||
self.ConfigureForExtension(context, binary.compiler)
|
||||
@@ -580,19 +768,7 @@ if SM.use_auto_versioning():
|
||||
{ 'SM': SM }
|
||||
)
|
||||
|
||||
class SafetyHookShim(object):
|
||||
def __init__(self):
|
||||
self.all_targets = {}
|
||||
self.libsafetyhook = {}
|
||||
|
||||
SafetyHook = SafetyHookShim()
|
||||
SafetyHook.all_targets = SM.all_targets
|
||||
builder.Build('public/safetyhook/AMBuilder', {'SafetyHook': SafetyHook })
|
||||
SM.libsafetyhook = SafetyHook.libsafetyhook
|
||||
|
||||
class SPRoot(object):
|
||||
def __init__(self):
|
||||
self.generated_headers = SM.generated_headers
|
||||
# SourcePawn's build scripts are always one-offs, and attach the current target
|
||||
# to the builder, so we have to provide a shim to our StaticLibrary() method.
|
||||
def StaticLibrary(self, builder, name):
|
||||
@@ -620,24 +796,11 @@ SP = builder.Build('sourcepawn/AMBuildScript', {
|
||||
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
|
||||
'external_build': SP_build_parts,
|
||||
})
|
||||
|
||||
def IsBetterDefaultSpcomp(spcomp, other):
|
||||
if other is None:
|
||||
return True
|
||||
if spcomp.target.arch == 'universal':
|
||||
return True
|
||||
if other.target.arch == 'universal':
|
||||
return False
|
||||
return spcomp.target.arch == 'x86'
|
||||
|
||||
for spcomp in SP.spcomp:
|
||||
if IsBetterDefaultSpcomp(spcomp, SM.spcomp):
|
||||
SM.spcomp = spcomp
|
||||
SM.spcomp_bins.append(spcomp)
|
||||
|
||||
# If we have a universal binary, ignore all other spcomps.
|
||||
if SM.spcomp.target.arch == 'universal':
|
||||
SM.spcomp_bins = [SM.spcomp]
|
||||
if len(SP.spcomp) > 1:
|
||||
SM.spcomp = SP.spcomp['x86']
|
||||
else:
|
||||
SM.spcomp = SP.spcomp[list(SP.spcomp.keys())[0]]
|
||||
SM.spcomp_bins = list(SP.spcomp.values())
|
||||
|
||||
if not getattr(builder.options, 'scripting_only', False):
|
||||
for cxx in SM.all_targets:
|
||||
|
||||
@@ -16,7 +16,6 @@ Development
|
||||
- [SourcePawn scripting](https://wiki.alliedmods.net/Category:SourceMod_Scripting): SourcePawn examples and introduction to the language
|
||||
- [SourceMod plugin API](https://sm.alliedmods.net/new-api): Online SourceMod plugin API reference generated from the include files
|
||||
- [SourceMod extension development](https://wiki.alliedmods.net/Category:SourceMod_Development): C++ examples and introduction to various extension interfaces
|
||||
- [Translation project](https://github.com/orgs/alliedmodders/projects/1): Help [translate SourceMod](https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)) into your language
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
@@ -86,6 +86,9 @@ public:
|
||||
const char *gamesuffix;
|
||||
/* Data */
|
||||
ServerGlobals *serverGlobals;
|
||||
void * serverFactory;
|
||||
void * engineFactory;
|
||||
void * matchmakingDSFactory;
|
||||
SMGlobalClass * listeners;
|
||||
|
||||
// ConVar functions.
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0;
|
||||
virtual bool EndOfFile(FileHandle_t file) = 0;
|
||||
virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0;
|
||||
virtual unsigned int Size(FileHandle_t file) = 0;
|
||||
virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0;
|
||||
virtual int Read(void* pOutput, int size, FileHandle_t file) = 0;
|
||||
virtual int Write(void const* pInput, int size, FileHandle_t file) = 0;
|
||||
@@ -57,7 +56,6 @@ public:
|
||||
virtual void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID = 0) = 0;
|
||||
virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0;
|
||||
virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0;
|
||||
virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0;
|
||||
};
|
||||
|
||||
} // namespace SourceMod
|
||||
|
||||
@@ -53,6 +53,24 @@
|
||||
* passwords to work, for security reasons.
|
||||
*/
|
||||
"PassInfoVar" "_password"
|
||||
|
||||
/**
|
||||
* Specifies the sound that gets played when an item is selected from a menu.
|
||||
*/
|
||||
"MenuItemSound" "buttons/button14.wav"
|
||||
|
||||
/**
|
||||
* Specifies the sound that gets played when an "Exit" button is selected
|
||||
* from a menu.
|
||||
*/
|
||||
"MenuExitSound" "buttons/combine_button7.wav"
|
||||
|
||||
/**
|
||||
* Specifies the sound that gets played when an "Exit Back" button is selected
|
||||
* from a menu. This is the special "Back" button that is intended to roll back
|
||||
* to a previous menu.
|
||||
*/
|
||||
"MenuExitBackSound" "buttons/combine_button7.wav"
|
||||
|
||||
/**
|
||||
* Enables or disables whether SourceMod reads a client's cl_language cvar to set
|
||||
|
||||
+1
-35
@@ -1,38 +1,4 @@
|
||||
"Languages"
|
||||
{
|
||||
"ar" "Arabic" // Arabic
|
||||
"bg" "Bulgarian" // Bulgarian
|
||||
"chi" "SChinese" // Chinese (Simplified)
|
||||
"cze" "Czech" // Czech
|
||||
"da" "Danish" // Danish
|
||||
"de" "German" // German
|
||||
"el" "Greek" // Greek
|
||||
"en" "English" // English
|
||||
"es" "Spanish" // Spanish
|
||||
"fi" "Finnish" // Finnish
|
||||
"fr" "French" // French
|
||||
"he" "Hebrew" // Hebrew
|
||||
"hu" "Hungarian" // Hungarian
|
||||
"it" "Italian" // Italian
|
||||
"jp" "Japanese" // Japanese
|
||||
"ko" "Korean" // Korean
|
||||
"ko" "KoreanA" // Korean (https://bugs.alliedmods.net/show_bug.cgi?id=4667)
|
||||
"las" "LatAm" // Latin American Spanish
|
||||
"lt" "Lithuanian" // Lithuanian
|
||||
"lv" "Latvian" // Latvian
|
||||
"nl" "Dutch" // Dutch
|
||||
"no" "Norwegian" // Norwegian
|
||||
"pl" "Polish" // Polish
|
||||
"pt" "Brazilian" // Brazilian Portuguese
|
||||
"pt_p" "Portuguese" // Portuguese
|
||||
"ro" "Romanian" // Romanian
|
||||
"ru" "Russian" // Russian
|
||||
"sk" "Slovak" // Slovak
|
||||
"sv" "Swedish" // Swedish
|
||||
"th" "Thai" // Thai
|
||||
"tr" "Turkish" // Turkish
|
||||
"ua" "Ukrainian" // Ukrainian
|
||||
"vi" "Vietnamese" // Vietnamese
|
||||
"zho" "TChinese" // Chinese (Traditional)
|
||||
|
||||
"en" "English"
|
||||
}
|
||||
|
||||
+79
-85
@@ -42,99 +42,93 @@ project.sources += [
|
||||
'GameHooks.cpp',
|
||||
]
|
||||
|
||||
# SDK name to shipping gamedir
|
||||
pb_gamedir_map = {
|
||||
'csgo': 'csgo',
|
||||
'blade': 'berimbau',
|
||||
'mcv': 'vietnam',
|
||||
}
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
for cxx in builder.targets:
|
||||
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
|
||||
continue
|
||||
|
||||
# SDK name to source code gamedir
|
||||
pb_gamesrcdir_map = {
|
||||
'csgo': 'cstrike15',
|
||||
'blade': 'berimbau',
|
||||
'mcv': 'vietnam',
|
||||
}
|
||||
binary_name = 'sourcemod.' + sdk.ext
|
||||
|
||||
for sdk_target in SM.sdk_targets:
|
||||
sdk = sdk_target.sdk
|
||||
cxx = sdk_target.cxx
|
||||
binary = SM.HL2Config(project, builder, cxx, binary_name, sdk)
|
||||
SM.ConfigureForExtension(builder, binary.compiler)
|
||||
|
||||
binary_name = 'sourcemod.' + sdk['extension']
|
||||
needs_protobuf = sdk['name'] in ['csgo', 'blade', 'mcv']
|
||||
|
||||
binary = SM.HL2Config(project, builder, cxx, binary_name, sdk)
|
||||
SM.ConfigureForExtension(builder, binary.compiler)
|
||||
|
||||
compiler = binary.compiler
|
||||
compiler.cxxincludes += [
|
||||
builder.sourcePath
|
||||
]
|
||||
|
||||
if needs_protobuf:
|
||||
compiler = binary.compiler
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(sdk['path'], 'common', 'protobuf-2.5.0', 'src'),
|
||||
os.path.join(sdk['path'], 'public', 'engine', 'protobuf'),
|
||||
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf')
|
||||
builder.sourcePath
|
||||
]
|
||||
|
||||
if sdk.name == 'csgo':
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
|
||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf')
|
||||
]
|
||||
elif sdk.name == 'blade':
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
|
||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf')
|
||||
]
|
||||
|
||||
if compiler.like('msvc'):
|
||||
compiler.defines += ['_ALLOW_KEYWORD_MACROS']
|
||||
if cxx.target.platform == 'linux':
|
||||
compiler.postlink += ['-lpthread', '-lrt']
|
||||
|
||||
if sdk.name in ['csgo', 'blade']:
|
||||
if compiler.target.platform == 'linux':
|
||||
if compiler.target.arch == 'x86':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'linux64', 'release', 'libprotobuf.a')
|
||||
compiler.linkflags += ['-Wl,--exclude-libs=libprotobuf.a']
|
||||
elif compiler.target.platform == 'mac':
|
||||
if compiler.target.arch == 'x86':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'osx32', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'osx64', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.platform == 'windows':
|
||||
msvc_ver = compiler.version
|
||||
vs_year = ''
|
||||
platform = ''
|
||||
if compiler.target.arch == 'x86':
|
||||
platform = 'win32'
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
platform = 'win64'
|
||||
|
||||
if 1900 <= msvc_ver < 2000:
|
||||
vs_year = '2015'
|
||||
else:
|
||||
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
|
||||
|
||||
if 'DEBUG' in compiler.defines:
|
||||
lib_path = os.path.join(sdk.path, 'lib', platform, 'debug', 'vs' + vs_year, 'libprotobuf.lib')
|
||||
else:
|
||||
lib_path = os.path.join(sdk.path, 'lib', platform, 'release', 'vs' + vs_year, 'libprotobuf.lib')
|
||||
compiler.linkflags.insert(0, lib_path)
|
||||
|
||||
if compiler.like('msvc'):
|
||||
compiler.defines += ['_ALLOW_KEYWORD_MACROS']
|
||||
if cxx.target.platform == 'linux':
|
||||
compiler.postlink += ['-lpthread', '-lrt']
|
||||
if sdk.name in ['csgo', 'blade']:
|
||||
binary.sources += ['smn_protobuf.cpp']
|
||||
else:
|
||||
binary.sources += ['smn_bitbuffer.cpp']
|
||||
|
||||
if needs_protobuf:
|
||||
if compiler.target.platform == 'linux':
|
||||
if compiler.target.arch == 'x86':
|
||||
lib_path = os.path.join(sdk['path'], 'lib', 'linux32', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
lib_path = os.path.join(sdk['path'], 'lib', 'linux64', 'release', 'libprotobuf.a')
|
||||
compiler.linkflags += ['-Wl,--exclude-libs=libprotobuf.a']
|
||||
elif compiler.target.platform == 'mac':
|
||||
if compiler.target.arch == 'x86':
|
||||
lib_path = os.path.join(sdk['path'], 'lib', 'osx32', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
lib_path = os.path.join(sdk['path'], 'lib', 'osx64', 'release', 'libprotobuf.a')
|
||||
elif compiler.target.platform == 'windows':
|
||||
msvc_ver = compiler.version
|
||||
vs_year = ''
|
||||
platform = ''
|
||||
if compiler.target.arch == 'x86':
|
||||
platform = 'win32'
|
||||
elif compiler.target.arch == 'x86_64':
|
||||
platform = 'win64'
|
||||
|
||||
if 1900 <= msvc_ver < 2000:
|
||||
vs_year = '2015'
|
||||
else:
|
||||
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
|
||||
|
||||
if 'DEBUG' in compiler.defines:
|
||||
lib_path = os.path.join(sdk['path'], 'lib', platform, 'debug', 'vs' + vs_year, 'libprotobuf.lib')
|
||||
else:
|
||||
lib_path = os.path.join(sdk['path'], 'lib', platform, 'release', 'vs' + vs_year, 'libprotobuf.lib')
|
||||
compiler.linkflags.insert(0, lib_path)
|
||||
|
||||
if needs_protobuf:
|
||||
binary.sources += ['smn_protobuf.cpp']
|
||||
else:
|
||||
binary.sources += ['smn_bitbuffer.cpp']
|
||||
|
||||
if sdk['name'] != 'blade':
|
||||
binary.sources += [
|
||||
'vprof_tool.cpp',
|
||||
]
|
||||
|
||||
if needs_protobuf:
|
||||
binary.sources += [
|
||||
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
||||
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessages.pb.cc'),
|
||||
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessage_helpers.cpp'),
|
||||
]
|
||||
if sdk['name'] == 'mcv':
|
||||
if sdk.name != 'blade':
|
||||
binary.sources += [
|
||||
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_gcmessages.pb.cc'),
|
||||
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'engine_gcmessages.pb.cc'),
|
||||
'vprof_tool.cpp',
|
||||
]
|
||||
|
||||
if sdk.name == 'csgo':
|
||||
binary.sources += [
|
||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'),
|
||||
]
|
||||
elif sdk.name == 'blade':
|
||||
binary.sources += [
|
||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessages.pb.cc'),
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessage_helpers.cpp'),
|
||||
]
|
||||
|
||||
SM.binaries += builder.Add(project)
|
||||
|
||||
@@ -461,23 +461,3 @@ bool ChatTriggers::WasFloodedMessage()
|
||||
{
|
||||
return m_bWasFloodedMessage;
|
||||
}
|
||||
|
||||
const char *ChatTriggers::GetPublicChatTrigger()
|
||||
{
|
||||
if (!m_PubTrigger.length())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_PubTrigger.c_str();
|
||||
}
|
||||
|
||||
const char *ChatTriggers::GetPrivateChatTrigger()
|
||||
{
|
||||
if (!m_PrivTrigger.length())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_PrivTrigger.c_str();
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ public:
|
||||
unsigned int SetReplyTo(unsigned int reply);
|
||||
bool IsChatTrigger();
|
||||
bool WasFloodedMessage();
|
||||
const char *GetPublicChatTrigger();
|
||||
const char *GetPrivateChatTrigger();
|
||||
private:
|
||||
enum ChatTriggerType {
|
||||
ChatTrigger_Public,
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ void GameHooks::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPla
|
||||
const char *cvarName, const char *cvarValue){
|
||||
int client = IndexOfEdict(pPlayer);
|
||||
|
||||
# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (g_Players.HandleConVarQuery(cookie, client, result, cvarName, cvarValue))
|
||||
return;
|
||||
# endif
|
||||
|
||||
+23
-72
@@ -47,8 +47,6 @@
|
||||
#include <cstrike15_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
#include <berimbau_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
#include <vietnam_usermessages.pb.h>
|
||||
#endif
|
||||
|
||||
typedef ICommandLine *(*FakeGetCommandLine)();
|
||||
@@ -186,8 +184,7 @@ void CHalfLife2::InitLogicalEntData()
|
||||
|| SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS \
|
||||
|| SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_NUCLEARDAWN \
|
||||
|| SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_NUCLEARDAWN
|
||||
|
||||
if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr))
|
||||
{
|
||||
@@ -413,17 +410,6 @@ ServerClass *CHalfLife2::FindServerClass(const char *classname)
|
||||
return pInfo->sc;
|
||||
}
|
||||
|
||||
ServerClass *CHalfLife2::FindEntityServerClass(CBaseEntity *pEntity)
|
||||
{
|
||||
IServerNetworkable* pNetwork = ((IServerUnknown *)pEntity)->GetNetworkable();
|
||||
if (pNetwork == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pNetwork->GetServerClass();
|
||||
}
|
||||
|
||||
DataTableInfo *CHalfLife2::_FindServerClass(const char *classname)
|
||||
{
|
||||
DataTableInfo *pInfo = NULL;
|
||||
@@ -456,25 +442,20 @@ bool CHalfLife2::FindSendPropInfo(const char *classname, const char *offset, sm_
|
||||
return false;
|
||||
}
|
||||
|
||||
DataTableInfo::SendPropInfo temp;
|
||||
|
||||
if (!pInfo->lookup.retrieve(offset, &temp))
|
||||
if (!pInfo->lookup.retrieve(offset, info))
|
||||
{
|
||||
bool found = UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp.info, 0);
|
||||
temp.name = offset;
|
||||
sm_sendprop_info_t temp_info;
|
||||
|
||||
pInfo->lookup.insert(offset, temp);
|
||||
|
||||
if (found)
|
||||
if (!UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp_info, 0))
|
||||
{
|
||||
*info = temp.info;
|
||||
return false;
|
||||
}
|
||||
|
||||
return found;
|
||||
pInfo->lookup.insert(offset, temp_info);
|
||||
*info = temp_info;
|
||||
}
|
||||
|
||||
*info = temp.info;
|
||||
return info->prop != nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SendProp *CHalfLife2::FindInSendTable(const char *classname, const char *offset)
|
||||
@@ -508,25 +489,15 @@ bool CHalfLife2::FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatab
|
||||
m_Maps.add(i, pMap, new DataMapCache());
|
||||
|
||||
DataMapCache *cache = i->value;
|
||||
DataMapCacheInfo temp;
|
||||
|
||||
if (!cache->retrieve(offset, &temp))
|
||||
if (!cache->retrieve(offset, pDataTable))
|
||||
{
|
||||
bool found = UTIL_FindDataMapInfo(pMap, offset, &temp.info);
|
||||
temp.name = offset;
|
||||
|
||||
cache->insert(offset, temp);
|
||||
|
||||
if (found)
|
||||
{
|
||||
*pDataTable = temp.info;
|
||||
}
|
||||
|
||||
return found;
|
||||
if (!UTIL_FindDataMapInfo(pMap, offset, pDataTable))
|
||||
return false;
|
||||
cache->insert(offset, *pDataTable);
|
||||
}
|
||||
|
||||
*pDataTable = temp.info;
|
||||
return pDataTable->prop != nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset)
|
||||
@@ -567,7 +538,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
|
||||
char buffer[253];
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s\1\n", msg);
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_SayText *pMsg;
|
||||
if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
@@ -594,7 +565,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
|
||||
}
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_TextMsg *pMsg;
|
||||
if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
@@ -631,7 +602,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
|
||||
{
|
||||
cell_t players[] = {client};
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_HintText *pMsg;
|
||||
if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
@@ -661,7 +632,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
|
||||
|
||||
bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_HintText *pMsg;
|
||||
if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
@@ -696,7 +667,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo
|
||||
int count = 0;
|
||||
cell_t players[] = {client};
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_VGUIMenu *pMsg;
|
||||
if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
|
||||
{
|
||||
@@ -721,7 +692,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo
|
||||
SubKey = data->GetFirstSubKey();
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
pMsg->set_name(name);
|
||||
pMsg->set_show(show);
|
||||
|
||||
@@ -1110,26 +1081,8 @@ int CHalfLife2::ReferenceToIndex(cell_t entRef)
|
||||
|
||||
return hndl.GetEntryIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
CEntInfo *pInfo = LookupEntity(entRef);
|
||||
if (!pInfo)
|
||||
{
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
IServerUnknown *pUnk = static_cast<IServerUnknown *>(pInfo->m_pEntity);
|
||||
if (!pUnk)
|
||||
{
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
CBaseEntity *pEntity = pUnk->GetBaseEntity();
|
||||
if (!pEntity)
|
||||
{
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
return entRef;
|
||||
}
|
||||
return entRef;
|
||||
}
|
||||
|
||||
cell_t CHalfLife2::EntityToBCompatRef(CBaseEntity *pEntity)
|
||||
@@ -1386,7 +1339,7 @@ SMFindMapResult CHalfLife2::FindMap(const char *pMapName, char *pFoundMap, size_
|
||||
}
|
||||
|
||||
#elif SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_HL2DM \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS
|
||||
static IVEngineServer *engine23 = (IVEngineServer *)(g_SMAPI->GetEngineFactory()("VEngineServer023", nullptr));
|
||||
if (engine23)
|
||||
{
|
||||
@@ -1573,9 +1526,7 @@ uint64_t CHalfLife2::GetServerSteamId64() const
|
||||
|| SOURCE_ENGINE == SE_DOI \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_ALIENSWARM \
|
||||
|| SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_PVKII \
|
||||
|| SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_TF2
|
||||
const CSteamID *sid = engine->GetGameServerSteamID();
|
||||
if (sid)
|
||||
{
|
||||
|
||||
+9
-26
@@ -74,7 +74,7 @@ using namespace SourceMod;
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI
|
||||
#define SOURCE_BIN_PREFIX "lib"
|
||||
#define SOURCE_BIN_SUFFIX "_srv"
|
||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_PVKII
|
||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||
#define SOURCE_BIN_PREFIX "lib"
|
||||
#define SOURCE_BIN_SUFFIX ""
|
||||
#else
|
||||
@@ -89,24 +89,16 @@ using namespace SourceMod;
|
||||
|
||||
struct DataTableInfo
|
||||
{
|
||||
struct SendPropInfo
|
||||
struct SendPropPolicy
|
||||
{
|
||||
static inline bool matches(const char *name, const SendPropInfo &info)
|
||||
static inline bool matches(const char *name, const sm_sendprop_info_t &info)
|
||||
{
|
||||
return strcmp(name, info.name.c_str()) == 0;
|
||||
return strcmp(name, info.prop->GetName()) == 0;
|
||||
}
|
||||
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||
{
|
||||
return key.hash();
|
||||
}
|
||||
|
||||
SendPropInfo()
|
||||
: name(), info{nullptr, 0}
|
||||
{
|
||||
}
|
||||
|
||||
std::string name;
|
||||
sm_sendprop_info_t info;
|
||||
};
|
||||
|
||||
static inline bool matches(const char *name, const DataTableInfo *info)
|
||||
@@ -124,30 +116,22 @@ struct DataTableInfo
|
||||
}
|
||||
|
||||
ServerClass *sc;
|
||||
NameHashSet<SendPropInfo> lookup;
|
||||
NameHashSet<sm_sendprop_info_t, SendPropPolicy> lookup;
|
||||
};
|
||||
|
||||
struct DataMapCacheInfo
|
||||
struct DataMapCachePolicy
|
||||
{
|
||||
static inline bool matches(const char *name, const DataMapCacheInfo &info)
|
||||
static inline bool matches(const char *name, const sm_datatable_info_t &info)
|
||||
{
|
||||
return strcmp(name, info.name.c_str()) == 0;
|
||||
return strcmp(name, info.prop->fieldName) == 0;
|
||||
}
|
||||
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||
{
|
||||
return key.hash();
|
||||
}
|
||||
|
||||
DataMapCacheInfo()
|
||||
: name(), info{nullptr, 0}
|
||||
{
|
||||
}
|
||||
|
||||
std::string name;
|
||||
sm_datatable_info_t info;
|
||||
};
|
||||
|
||||
typedef NameHashSet<DataMapCacheInfo> DataMapCache;
|
||||
typedef NameHashSet<sm_datatable_info_t, DataMapCachePolicy> DataMapCache;
|
||||
|
||||
struct DelayedFakeCliCmd
|
||||
{
|
||||
@@ -221,7 +205,6 @@ public: //IGameHelpers
|
||||
bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
|
||||
datamap_t *GetDataMap(CBaseEntity *pEntity);
|
||||
ServerClass *FindServerClass(const char *classname);
|
||||
ServerClass *FindEntityServerClass(CBaseEntity *pEntity);
|
||||
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
|
||||
bool FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatable_info_t *pDataTable);
|
||||
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
|
||||
|
||||
+26
-29
@@ -38,7 +38,6 @@
|
||||
#include "sourcemm_api.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "MenuStyle_Valve.h"
|
||||
#include <IGameConfigs.h>
|
||||
#include "sourcemm_api.h"
|
||||
#include "logic_bridge.h"
|
||||
|
||||
@@ -69,29 +68,6 @@ void MenuManager::OnSourceModAllInitialized()
|
||||
m_StyleType = handlesys->CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL);
|
||||
}
|
||||
|
||||
void MenuManager::OnSourceModAllInitialized_Post()
|
||||
{
|
||||
const char* pTmp;
|
||||
|
||||
pTmp = g_pGameConf->GetKeyValue("MenuItemSound");
|
||||
if (nullptr != pTmp)
|
||||
{
|
||||
m_SelectSound = pTmp;
|
||||
}
|
||||
|
||||
pTmp = g_pGameConf->GetKeyValue("MenuExitSound");
|
||||
if (nullptr != pTmp)
|
||||
{
|
||||
m_ExitSound = pTmp;
|
||||
}
|
||||
|
||||
pTmp = g_pGameConf->GetKeyValue("MenuExitBackSound");
|
||||
if (nullptr != pTmp)
|
||||
{
|
||||
m_ExitBackSound = pTmp;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager::OnSourceModAllShutdown()
|
||||
{
|
||||
handlesys->RemoveType(m_MenuType, g_pCoreIdent);
|
||||
@@ -723,9 +699,30 @@ bool MenuManager::MenuSoundsEnabled()
|
||||
return (sm_menu_sounds.GetInt() != 0);
|
||||
}
|
||||
|
||||
std::string *MenuManager::GetMenuSound(ItemSelection sel)
|
||||
ConfigResult MenuManager::OnSourceModConfigChanged(const char *key,
|
||||
const char *value,
|
||||
ConfigSource source,
|
||||
char *error,
|
||||
size_t maxlength)
|
||||
{
|
||||
std::string *sound = nullptr;
|
||||
if (strcmp(key, "MenuItemSound") == 0)
|
||||
{
|
||||
m_SelectSound.assign(value);
|
||||
return ConfigResult_Accept;
|
||||
} else if (strcmp(key, "MenuExitBackSound") == 0) {
|
||||
m_ExitBackSound.assign(value);
|
||||
return ConfigResult_Accept;
|
||||
} else if (strcmp(key, "MenuExitSound") == 0) {
|
||||
m_ExitSound.assign(value);
|
||||
return ConfigResult_Accept;
|
||||
}
|
||||
|
||||
return ConfigResult_Ignore;
|
||||
}
|
||||
|
||||
const char *MenuManager::GetMenuSound(ItemSelection sel)
|
||||
{
|
||||
const char *sound = NULL;
|
||||
|
||||
switch (sel)
|
||||
{
|
||||
@@ -735,7 +732,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
|
||||
{
|
||||
if (m_SelectSound.size() > 0)
|
||||
{
|
||||
sound = &m_SelectSound;
|
||||
sound = m_SelectSound.c_str();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -743,7 +740,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
|
||||
{
|
||||
if (m_ExitBackSound.size() > 0)
|
||||
{
|
||||
sound = &m_ExitBackSound;
|
||||
sound = m_ExitBackSound.c_str();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -751,7 +748,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
|
||||
{
|
||||
if (m_ExitSound.size() > 0)
|
||||
{
|
||||
sound = &m_ExitSound;
|
||||
sound = m_ExitSound.c_str();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-6
@@ -36,8 +36,8 @@
|
||||
#include <sh_vector.h>
|
||||
#include <sh_stack.h>
|
||||
#include <sh_list.h>
|
||||
#include <sh_string.h>
|
||||
#include "sm_globals.h"
|
||||
#include <string>
|
||||
|
||||
using namespace SourceMod;
|
||||
using namespace SourceHook;
|
||||
@@ -55,8 +55,12 @@ public:
|
||||
MenuManager();
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModAllInitialized_Post();
|
||||
void OnSourceModAllShutdown();
|
||||
ConfigResult OnSourceModConfigChanged(const char *key,
|
||||
const char *value,
|
||||
ConfigSource source,
|
||||
char *error,
|
||||
size_t maxlength);
|
||||
void OnSourceModLevelChange(const char *mapName);
|
||||
public: //IMenuManager
|
||||
virtual const char *GetInterfaceName()
|
||||
@@ -95,7 +99,7 @@ public:
|
||||
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
|
||||
public:
|
||||
bool MenuSoundsEnabled();
|
||||
std::string *GetMenuSound(ItemSelection sel);
|
||||
const char *GetMenuSound(ItemSelection sel);
|
||||
protected:
|
||||
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
|
||||
Handle_t CreateStyleHandle(IMenuStyle *style);
|
||||
@@ -105,9 +109,9 @@ private:
|
||||
CVector<IMenuStyle *> m_Styles;
|
||||
HandleType_t m_StyleType;
|
||||
HandleType_t m_MenuType;
|
||||
std::string m_SelectSound = "";
|
||||
std::string m_ExitBackSound = "";
|
||||
std::string m_ExitSound = "";
|
||||
String m_SelectSound;
|
||||
String m_ExitBackSound;
|
||||
String m_ExitSound;
|
||||
};
|
||||
|
||||
extern MenuManager g_Menus;
|
||||
|
||||
+21
-77
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -99,7 +99,7 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool
|
||||
|
||||
/* Fire callbacks */
|
||||
mh->OnMenuCancel(menu, client, reason);
|
||||
|
||||
|
||||
/* Only fire end if there's a valid menu */
|
||||
if (menu)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ void BaseMenuStyle::ProcessWatchList()
|
||||
}
|
||||
|
||||
#if defined MENU_DEBUG
|
||||
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||
m_WatchList.m_Size,
|
||||
m_WatchList.m_FirstLink,
|
||||
m_WatchList.m_FreeNodes,
|
||||
@@ -302,7 +302,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
ItemSelection type = states.slots[key_press].type;
|
||||
|
||||
/* Check if we should play a sound about the type */
|
||||
if (g_Menus.MenuSoundsEnabled() &&
|
||||
if (g_Menus.MenuSoundsEnabled() &&
|
||||
(!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND))
|
||||
{
|
||||
CellRecipientFilter filter;
|
||||
@@ -311,9 +311,9 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
clients[0] = client;
|
||||
filter.Initialize(clients, 1);
|
||||
|
||||
std::string *sound = g_Menus.GetMenuSound(type);
|
||||
const char *sound = g_Menus.GetMenuSound(type);
|
||||
|
||||
if (nullptr != sound && !sound->empty())
|
||||
if (sound != NULL)
|
||||
{
|
||||
edict_t *pEdict = PEntityOfEntIndex(client);
|
||||
if (pEdict)
|
||||
@@ -323,23 +323,23 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
if (pCollideable)
|
||||
{
|
||||
const Vector & pos = pCollideable->GetCollisionOrigin();
|
||||
enginesound->EmitSound(filter,
|
||||
client,
|
||||
CHAN_AUTO,
|
||||
enginesound->EmitSound(filter,
|
||||
client,
|
||||
CHAN_AUTO,
|
||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||
sound->c_str(),
|
||||
-1,
|
||||
sound,
|
||||
-1,
|
||||
#endif
|
||||
sound->c_str(),
|
||||
VOL_NORM,
|
||||
ATTN_NORM,
|
||||
sound,
|
||||
VOL_NORM,
|
||||
ATTN_NORM,
|
||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||
0,
|
||||
0,
|
||||
#endif
|
||||
0,
|
||||
PITCH_NORM,
|
||||
0,
|
||||
PITCH_NORM,
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
|
||||
0,
|
||||
#endif
|
||||
&pos);
|
||||
@@ -604,9 +604,9 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
||||
return true;
|
||||
}
|
||||
|
||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||
m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_nFlags(MENUFLAG_BUTTON_EXIT)
|
||||
{
|
||||
}
|
||||
@@ -754,62 +754,6 @@ unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
|
||||
return position;
|
||||
}
|
||||
|
||||
void CBaseMenu::ShufflePerClient(int start, int stop)
|
||||
{
|
||||
// limit map len to 255 items since it's using uint8
|
||||
int length = MIN(GetItemCount(), 255);
|
||||
if (stop >= 0)
|
||||
length = MIN(length, stop);
|
||||
|
||||
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
|
||||
{
|
||||
// populate per-client map ...
|
||||
m_RandomMaps[i].resize(length);
|
||||
for (int j = 0; j < length; j++)
|
||||
m_RandomMaps[i][j] = j;
|
||||
|
||||
// ... and random shuffle it
|
||||
for (int j = length - 1; j > start; j--)
|
||||
{
|
||||
int x = rand() % (j - start + 1) + start;
|
||||
uint8_t tmp = m_RandomMaps[i][x];
|
||||
m_RandomMaps[i][x] = m_RandomMaps[i][j];
|
||||
m_RandomMaps[i][j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseMenu::SetClientMapping(int client, int *array, int length)
|
||||
{
|
||||
length = MIN(length, 255);
|
||||
m_RandomMaps[client].resize(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
m_RandomMaps[client][i] = array[i];
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseMenu::IsPerClientShuffled()
|
||||
{
|
||||
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
|
||||
{
|
||||
if(m_RandomMaps[i].length() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
|
||||
{
|
||||
if (client > 0 && position < m_RandomMaps[client].length())
|
||||
{
|
||||
position = m_RandomMaps[client][position];
|
||||
return m_items[position].index;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
unsigned int CBaseMenu::GetItemCount()
|
||||
{
|
||||
return m_items.size();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
class CBaseMenu;
|
||||
|
||||
class BaseMenuStyle :
|
||||
class BaseMenuStyle :
|
||||
public IMenuStyle,
|
||||
public IClientListener
|
||||
{
|
||||
@@ -113,11 +113,11 @@ public: //IClientListener
|
||||
public: //what derived must implement
|
||||
virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
|
||||
virtual void SendDisplay(int client, IMenuPanel *display) =0;
|
||||
public: //what derived may implement
|
||||
virtual bool DoClientMenu(int client,
|
||||
CBaseMenu *menu,
|
||||
public: //what derived may implement
|
||||
virtual bool DoClientMenu(int client,
|
||||
CBaseMenu *menu,
|
||||
unsigned int first_item,
|
||||
IMenuHandler *mh,
|
||||
IMenuHandler *mh,
|
||||
unsigned int time);
|
||||
virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
|
||||
virtual void AddClientToWatch(int client);
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
#include <game/shared/berimbau/protobuf/berimbau_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
#include <game/shared/vietnam/protobuf/vietnam_usermessages.pb.h>
|
||||
#endif
|
||||
|
||||
extern const char *g_RadioNumTable[];
|
||||
@@ -184,7 +182,7 @@ void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFil
|
||||
{
|
||||
int count = pFilter->GetRecipientCount();
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
int c = ((CCSUsrMsg_ShowMenu &)msg).display_time();
|
||||
#else
|
||||
bf_read br(bf->GetBasePointer(), 3);
|
||||
@@ -502,7 +500,7 @@ void CRadioMenuPlayer::Radio_Refresh()
|
||||
time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
// TODO: find what happens past 240 on CS:GO
|
||||
CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
||||
if (!msg)
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "UserMessages.h"
|
||||
#include "sm_fastlink.h"
|
||||
#include <sh_stack.h>
|
||||
#include <sh_string.h>
|
||||
#include <compat_wrappers.h>
|
||||
#include "logic/common_logic.h"
|
||||
#include "AutoHandleRooter.h"
|
||||
|
||||
+1
-20
@@ -109,8 +109,6 @@ bool NextMapManager::SetNextMap(const char *map)
|
||||
return true;
|
||||
}
|
||||
|
||||
static char g_nextMap[PLATFORM_MAX_PATH];
|
||||
|
||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||
void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
|
||||
#else
|
||||
@@ -124,16 +122,8 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
|
||||
}
|
||||
|
||||
const char *newmap = sm_nextmap.GetString();
|
||||
if (newmap[0] != '\0') {
|
||||
ke::SafeStrcpy(g_nextMap, sizeof(g_nextMap), newmap);
|
||||
newmap = g_nextMap;
|
||||
|
||||
// Clear the value so that if the map load fails later we don't get stuck in a loop.
|
||||
// This might cause us to go off-cycle for a map, but nextmap will get us back on track.
|
||||
sm_nextmap.SetValue("");
|
||||
}
|
||||
|
||||
if (newmap[0] == '\0' || !g_HL2.IsMapValid(newmap))
|
||||
if (newmap[0] == 0 || !g_HL2.IsMapValid(newmap))
|
||||
{
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
@@ -152,15 +142,6 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
|
||||
|
||||
void NextMapManager::OnSourceModLevelChange( const char *mapName )
|
||||
{
|
||||
// If we were controlling the map change, reset sm_nextmap to be the name of the map we successfully changed to.
|
||||
// This maintains an old API contract on the plugin side. We use the real map name even if it was different from
|
||||
// the expected map name as if the expected map failed to load we let the game take over instead, but the nextmap
|
||||
// plugin compares the sm_nextmap value to the current map to decide if it should advance the mapcycle.
|
||||
if (g_nextMap[0] != '\0') {
|
||||
sm_nextmap.SetValue(mapName);
|
||||
g_nextMap[0] = '\0';
|
||||
}
|
||||
|
||||
/* Skip the first 'mapchange' when the server starts up */
|
||||
if (m_tempChangeInfo.startTime != 0)
|
||||
{
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ public:
|
||||
|
||||
private:
|
||||
MapChangeData m_tempChangeInfo;
|
||||
char lastMap[PLATFORM_MAX_PATH];
|
||||
char lastMap[32];
|
||||
};
|
||||
|
||||
extern NextMapManager g_NextMap;
|
||||
|
||||
+78
-32
@@ -59,8 +59,6 @@ bool g_OnMapStarted = false;
|
||||
IForward *PreAdminCheck = NULL;
|
||||
IForward *PostAdminCheck = NULL;
|
||||
IForward *PostAdminFilter = NULL;
|
||||
IForward *ServerEnterHibernation = NULL;
|
||||
IForward *ServerExitHibernation = NULL;
|
||||
|
||||
const unsigned int *g_NumPlayersToAuth = NULL;
|
||||
int lifestate_offset = -1;
|
||||
@@ -205,8 +203,6 @@ void PlayerManager::OnSourceModAllInitialized()
|
||||
PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
|
||||
PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
|
||||
PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1);
|
||||
ServerEnterHibernation = forwardsys->CreateForward("OnServerEnterHibernation", ET_Ignore, 0, NULL);
|
||||
ServerExitHibernation = forwardsys->CreateForward("OnServerExitHibernation", ET_Ignore, 0, NULL);
|
||||
|
||||
m_bIsListenServer = !engine->IsDedicatedServer();
|
||||
m_ListenClient = 0;
|
||||
@@ -261,8 +257,6 @@ void PlayerManager::OnSourceModShutdown()
|
||||
forwardsys->ReleaseForward(PreAdminCheck);
|
||||
forwardsys->ReleaseForward(PostAdminCheck);
|
||||
forwardsys->ReleaseForward(PostAdminFilter);
|
||||
forwardsys->ReleaseForward(ServerEnterHibernation);
|
||||
forwardsys->ReleaseForward(ServerExitHibernation);
|
||||
|
||||
delete [] m_Players;
|
||||
|
||||
@@ -525,7 +519,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
|
||||
/* Get the client's language */
|
||||
if (m_QueryLang)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
pPlayer->m_LangId = translator->GetServerLanguage();
|
||||
#else
|
||||
const char *name;
|
||||
@@ -539,7 +533,6 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
|
||||
pPlayer->m_LangId = translator->GetServerLanguage();
|
||||
}
|
||||
#endif
|
||||
pPlayer->m_OriginalLangId = pPlayer->m_LangId;
|
||||
}
|
||||
|
||||
List<IClientListener *>::iterator iter;
|
||||
@@ -657,7 +650,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
||||
|
||||
int userId = engine->GetPlayerUserId(pEntity);
|
||||
#if (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_PVKII)
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
static ConVar *tv_name = icvar->FindVar("tv_name");
|
||||
#endif
|
||||
#if SOURCE_ENGINE == SE_TF2
|
||||
@@ -680,13 +673,12 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
||||
&& ((!m_bIsReplayActive && newCount == 1)
|
||||
|| (m_bIsReplayActive && newCount == 2))
|
||||
&& (m_SourceTVUserId == userId
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_MCV
|
||||
// It seems likely that MCV will change this at some point, but it's GOTV at the moment.
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
|| strcmp(playername, "GOTV") == 0
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
|| strcmp(playername, "BBTV") == 0
|
||||
#elif (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_PVKII)
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
|| (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0)
|
||||
#else
|
||||
|| strcmp(playername, "SourceTV") == 0
|
||||
@@ -740,7 +732,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
|
||||
}
|
||||
pPlayer->Authorize_Post();
|
||||
}
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
else if(m_QueryLang)
|
||||
{
|
||||
// Not a bot
|
||||
@@ -789,11 +781,6 @@ void PlayerManager::OnSourceModLevelEnd()
|
||||
|
||||
void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
|
||||
{
|
||||
cell_t res;
|
||||
if (bHibernating)
|
||||
ServerEnterHibernation->Execute(&res);
|
||||
else
|
||||
ServerExitHibernation->Execute(&res);
|
||||
/* If bots were added at map start, but not fully inited before hibernation, there will
|
||||
* be no OnClientDisconnect for them, despite them getting booted right before this.
|
||||
*/
|
||||
@@ -805,7 +792,7 @@ void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
|
||||
CPlayer *pPlayer = &m_Players[i];
|
||||
if (pPlayer->IsConnected() && pPlayer->IsFakeClient())
|
||||
{
|
||||
#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_NUCLEARDAWN
|
||||
// These games have the bug fixed where hltv/replay was getting kicked on hibernation
|
||||
if (pPlayer->IsSourceTV() || pPlayer->IsReplay())
|
||||
continue;
|
||||
@@ -991,6 +978,8 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
|
||||
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
{
|
||||
char buffer[256];
|
||||
unsigned int id = 0;
|
||||
unsigned int start = 0;
|
||||
|
||||
AutoExtensionList extensions(extsys);
|
||||
if (!extensions->size())
|
||||
@@ -999,6 +988,11 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.ArgC() > 2)
|
||||
{
|
||||
start = atoi(args.Arg(2));
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < extensions->size(); i++)
|
||||
{
|
||||
@@ -1010,6 +1004,17 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
continue;
|
||||
}
|
||||
|
||||
id++;
|
||||
if (id < start)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id - start > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
IExtensionInterface *api = ext->GetAPI();
|
||||
|
||||
const char *name = api->GetExtensionName();
|
||||
@@ -1034,14 +1039,31 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||
len += ke::SafeSprintf(&buffer[len], sizeof(buffer)-len, ": %s", description);
|
||||
}
|
||||
|
||||
|
||||
ClientConsolePrint(player->GetEdict(), "%s", buffer);
|
||||
}
|
||||
|
||||
for (; i < extensions->size(); i++)
|
||||
{
|
||||
char error[255];
|
||||
if (extensions->at(i)->IsRunning(error, sizeof(error)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < extensions->size())
|
||||
{
|
||||
ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
|
||||
}
|
||||
}
|
||||
|
||||
void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
{
|
||||
char buffer[256];
|
||||
unsigned int id = 0;
|
||||
edict_t *e = player->GetEdict();
|
||||
unsigned int start = 0;
|
||||
|
||||
AutoPluginList plugins(scripts);
|
||||
if (!plugins->size())
|
||||
@@ -1050,6 +1072,11 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.ArgC() > 2)
|
||||
{
|
||||
start = atoi(args.Arg(2));
|
||||
}
|
||||
|
||||
SourceHook::List<SMPlugin *> m_FailList;
|
||||
|
||||
size_t i = 0;
|
||||
@@ -1062,6 +1089,18 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Count valid plugins */
|
||||
id++;
|
||||
if (id < start)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id - start > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
size_t len;
|
||||
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
||||
len = ke::SafeSprintf(buffer, sizeof(buffer), " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
|
||||
@@ -1079,6 +1118,21 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
|
||||
}
|
||||
ClientConsolePrint(e, "%s", buffer);
|
||||
}
|
||||
|
||||
/* See if we can get more plugins */
|
||||
for (; i < plugins->size(); i++)
|
||||
{
|
||||
if (plugins->at(i)->GetStatus() == Plugin_Running)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we actually have more plugins? */
|
||||
if (i < plugins->size())
|
||||
{
|
||||
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
|
||||
}
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
@@ -1164,7 +1218,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
|
||||
if (g_ConsoleDetours.IsEnabled())
|
||||
{
|
||||
cell_t res2 = g_ConsoleDetours.InternalDispatch(client, &cargs);
|
||||
if (res2 >= Pl_Handled)
|
||||
if (res2 >= Pl_Stop)
|
||||
{
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
@@ -1981,7 +2035,7 @@ void CmdMaxplayersCallback()
|
||||
g_Players.MaxPlayersChanged();
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
||||
{
|
||||
for (int i = 1; i <= m_maxClients; i++)
|
||||
@@ -1991,7 +2045,6 @@ bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQue
|
||||
unsigned int langid;
|
||||
unsigned int new_langid = (translator->GetLanguageByName(cvarValue, &langid)) ? langid : translator->GetServerLanguage();
|
||||
m_Players[i].m_LangId = new_langid;
|
||||
m_Players[i].m_OriginalLangId = new_langid;
|
||||
OnClientLanguageChanged(i, new_langid);
|
||||
|
||||
return true;
|
||||
@@ -2041,7 +2094,6 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||
m_pEdict = pEntity;
|
||||
m_iIndex = IndexOfEdict(pEntity);
|
||||
m_LangId = translator->GetServerLanguage();
|
||||
m_OriginalLangId = m_LangId;
|
||||
|
||||
m_Serial.bits.index = m_iIndex;
|
||||
m_Serial.bits.serial = g_PlayerSerialCount++;
|
||||
@@ -2063,8 +2115,7 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||
|| SOURCE_ENGINE == SE_BMS \
|
||||
|| SOURCE_ENGINE == SE_INSURGENCY \
|
||||
|| SOURCE_ENGINE == SE_DOI \
|
||||
|| SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BLADE
|
||||
m_pIClient = engine->GetIServer()->GetClient(m_iIndex - 1);
|
||||
#else
|
||||
#if SOURCE_ENGINE == SE_SDK2013
|
||||
@@ -2240,7 +2291,7 @@ void CPlayer::Disconnect()
|
||||
m_bIsSourceTV = false;
|
||||
m_bIsReplay = false;
|
||||
m_Serial.value = -1;
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
m_LanguageCookie = InvalidQueryCvarCookie;
|
||||
#endif
|
||||
ClearNetchannelQueue();
|
||||
@@ -2462,7 +2513,7 @@ void CPlayer::Kick(const char *str)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
pClient->Disconnect(str);
|
||||
#else
|
||||
pClient->Disconnect("%s", str);
|
||||
@@ -2609,11 +2660,6 @@ unsigned int CPlayer::GetLanguageId()
|
||||
return m_LangId;
|
||||
}
|
||||
|
||||
unsigned int CPlayer::GetOriginalLanguageId()
|
||||
{
|
||||
return m_OriginalLangId;
|
||||
}
|
||||
|
||||
void CPlayer::SetLanguageId(unsigned int id)
|
||||
{
|
||||
if(m_LangId != id)
|
||||
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
bool IsInKickQueue();
|
||||
IPlayerInfo *GetPlayerInfo();
|
||||
unsigned int GetLanguageId();
|
||||
unsigned int GetOriginalLanguageId();
|
||||
void SetLanguageId(unsigned int id);
|
||||
int GetUserId();
|
||||
bool RunAdminCacheChecks();
|
||||
@@ -146,14 +145,13 @@ private:
|
||||
bool m_bAdminCheckSignalled = false;
|
||||
int m_iIndex;
|
||||
unsigned int m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
||||
unsigned int m_OriginalLangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
||||
int m_UserId = -1;
|
||||
bool m_bFakeClient = false;
|
||||
bool m_bIsSourceTV = false;
|
||||
bool m_bIsReplay = false;
|
||||
serial_t m_Serial;
|
||||
CSteamID m_SteamId;
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
QueryCvarCookie_t m_LanguageCookie = InvalidQueryCvarCookie;
|
||||
#endif
|
||||
std::deque<std::string> m_PrintfBuffer;
|
||||
@@ -219,6 +217,9 @@ public: //IPlayerManager
|
||||
void RecheckAnyAdmins();
|
||||
public: // IGameEventListener2
|
||||
void FireGameEvent(IGameEvent *pEvent);
|
||||
#if SOURCE_ENGINE >= SE_ALIENSWARM
|
||||
virtual int GetEventDebugID( void ) { return 42; }
|
||||
#endif
|
||||
public:
|
||||
inline int MaxClients()
|
||||
{
|
||||
@@ -242,7 +243,7 @@ public:
|
||||
{
|
||||
return m_bInCCKVHook;
|
||||
}
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
bool HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue);
|
||||
#endif
|
||||
private:
|
||||
|
||||
@@ -816,6 +816,9 @@ public:
|
||||
|
||||
inline bool GetColor(const char *pszFieldName, Color *out)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
|
||||
return false;
|
||||
#else
|
||||
GETCHECK_FIELD();
|
||||
CHECK_FIELD_TYPE(MESSAGE);
|
||||
CHECK_FIELD_NOT_REPEATED();
|
||||
@@ -829,10 +832,14 @@ public:
|
||||
);
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool SetColor(const char *pszFieldName, const Color &value)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
|
||||
return false;
|
||||
#else
|
||||
GETCHECK_FIELD();
|
||||
CHECK_FIELD_TYPE(MESSAGE);
|
||||
CHECK_FIELD_NOT_REPEATED();
|
||||
@@ -844,10 +851,14 @@ public:
|
||||
msgRGBA->set_a(value.a());
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool GetRepeatedColor(const char *pszFieldName, int index, Color *out)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
|
||||
return false;
|
||||
#else
|
||||
GETCHECK_FIELD();
|
||||
CHECK_FIELD_TYPE(MESSAGE);
|
||||
CHECK_FIELD_REPEATED();
|
||||
@@ -862,10 +873,14 @@ public:
|
||||
);
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool SetRepeatedColor(const char *pszFieldName, int index, const Color &value)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
|
||||
return false;
|
||||
#else
|
||||
GETCHECK_FIELD();
|
||||
CHECK_FIELD_TYPE(MESSAGE);
|
||||
CHECK_FIELD_REPEATED();
|
||||
@@ -878,10 +893,14 @@ public:
|
||||
msgRGBA->set_a(value.a());
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool AddColor(const char *pszFieldName, const Color &value)
|
||||
{
|
||||
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
|
||||
return false;
|
||||
#else
|
||||
GETCHECK_FIELD();
|
||||
CHECK_FIELD_TYPE(MESSAGE);
|
||||
CHECK_FIELD_REPEATED();
|
||||
@@ -893,6 +912,7 @@ public:
|
||||
msgRGBA->set_a(value.a());
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool GetVector2D(const char *pszFieldName, Vector2D *out)
|
||||
|
||||
+14
-24
@@ -37,14 +37,12 @@
|
||||
#include <cstrike15_usermessage_helpers.h>
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
#include <berimbau_usermessage_helpers.h>
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
#include <vietnam_usermessage_helpers.h>
|
||||
#endif
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
UserMessages g_UserMsgs;
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
SH_DECL_HOOK3_void(IVEngineServer, SendUserMessage, SH_NOATTRIB, 0, IRecipientFilter &, int, const protobuf::Message &);
|
||||
#else
|
||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||
@@ -53,7 +51,7 @@ SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRec
|
||||
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
|
||||
#endif
|
||||
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
|
||||
#endif // ==SE_CSGO || ==SE_BLADE || ==SE_MCV
|
||||
#endif // ==SE_CSGO || ==SE_BLADE
|
||||
|
||||
UserMessages::UserMessages()
|
||||
#ifndef USE_PROTOBUF_USERMESSAGES
|
||||
@@ -97,7 +95,7 @@ void UserMessages::OnSourceModAllShutdown()
|
||||
{
|
||||
if (m_HookCount)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||
#else
|
||||
@@ -117,8 +115,6 @@ int UserMessages::GetMessageIndex(const char *msg)
|
||||
return g_Cstrike15UsermessageHelpers.GetIndex(msg);
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
return g_BerimbauUsermessageHelpers.GetIndex(msg);
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
return g_VietnamUsermessageHelpers.GetIndex(msg);
|
||||
#else
|
||||
|
||||
int msgid;
|
||||
@@ -158,8 +154,6 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
|
||||
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msgid);
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msgid);
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
const char *pszName = g_VietnamUsermessageHelpers.GetName(msgid);
|
||||
#endif
|
||||
if (!pszName)
|
||||
return false;
|
||||
@@ -309,7 +303,7 @@ bool UserMessages::EndMessage()
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (m_CurFlags & USERMSG_BLOCKHOOKS)
|
||||
{
|
||||
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(m_CellRecFilter), m_CurId, *m_FakeEngineBuffer);
|
||||
@@ -339,7 +333,7 @@ bool UserMessages::EndMessage()
|
||||
} else {
|
||||
engine->MessageEnd();
|
||||
}
|
||||
#endif // SE_CSGO || SE_BLADE || SE_MCV
|
||||
#endif // SE_CSGO || SE_BLADE
|
||||
|
||||
m_InExec = false;
|
||||
m_CurFlags = 0;
|
||||
@@ -424,7 +418,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene
|
||||
|
||||
if (!m_HookCount++)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||
#else
|
||||
@@ -452,8 +446,6 @@ const protobuf::Message *UserMessages::GetMessagePrototype(int msg_type)
|
||||
return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type);
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
return g_BerimbauUsermessageHelpers.GetPrototype(msg_type);
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
return g_VietnamUsermessageHelpers.GetPrototype(msg_type);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -503,7 +495,7 @@ void UserMessages::_DecRefCounter()
|
||||
{
|
||||
if (--m_HookCount == 0)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||
#else
|
||||
@@ -515,15 +507,13 @@ void UserMessages::_DecRefCounter()
|
||||
}
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msg_type);
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msg_type);
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
const char *pszName = g_VietnamUsermessageHelpers.GetName(msg_type);
|
||||
#endif
|
||||
|
||||
OnStartMessage_Pre(&filter, msg_type, pszName);
|
||||
@@ -572,7 +562,7 @@ void UserMessages::OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type
|
||||
RETURN_META(res)
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
protobuf::Message *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||
@@ -612,7 +602,7 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ
|
||||
UM_RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
protobuf::Message *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||
@@ -777,7 +767,7 @@ void UserMessages::OnMessageEnd_Pre()
|
||||
|
||||
if (!handled && intercepted)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(*m_CurRecFilter), m_CurId, *m_InterceptBuffer);
|
||||
#else
|
||||
bf_write *engine_bfw;
|
||||
@@ -789,11 +779,11 @@ void UserMessages::OnMessageEnd_Pre()
|
||||
m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten());
|
||||
engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten());
|
||||
ENGINE_CALL(MessageEnd)();
|
||||
#endif // SE_CSGO || SE_BLADE || SE_MCV
|
||||
#endif // SE_CSGO || SE_BLADE
|
||||
}
|
||||
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
int size = m_OrigBuffer->ByteSize();
|
||||
uint8 *data = (uint8 *)stackalloc(size);
|
||||
m_OrigBuffer->SerializePartialToArray(data, size);
|
||||
@@ -823,7 +813,7 @@ void UserMessages::OnMessageEnd_Pre()
|
||||
iter++;
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
delete pTempMsg;
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@
|
||||
using namespace SourceHook;
|
||||
using namespace SourceMod;
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
#define USE_PROTOBUF_USERMESSAGES
|
||||
#endif
|
||||
|
||||
@@ -102,12 +102,12 @@ public: //IUserMessages
|
||||
bool intercept=false);
|
||||
UserMessageType GetUserMessageType() const;
|
||||
public:
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
void OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
||||
void OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
protobuf::Message *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
||||
protobuf::Message *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
SH_DECL_HOOK2_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *, bool);
|
||||
#else
|
||||
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
void LinkConCommandBase(ConCommandBase *pBase, bool unknown)
|
||||
#else
|
||||
void LinkConCommandBase(ConCommandBase *pBase)
|
||||
|
||||
@@ -16,7 +16,7 @@ for cxx in builder.targets:
|
||||
'SM_DEFAULT_THREADER',
|
||||
'SM_LOGIC'
|
||||
]
|
||||
|
||||
|
||||
if binary.compiler.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lpthread', '-lrt']
|
||||
elif binary.compiler.target.platform == 'mac':
|
||||
|
||||
@@ -395,6 +395,11 @@ void CExtension::AddDependency(const IfaceInfo *pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
|
||||
{
|
||||
return (i1.iface == i2.iface) && (i1.owner == i2.owner);
|
||||
}
|
||||
|
||||
void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
|
||||
{
|
||||
IfaceInfo info;
|
||||
|
||||
+37
-128
@@ -30,7 +30,6 @@
|
||||
#include "common_logic.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <sh_list.h>
|
||||
#include <sh_string.h>
|
||||
#include "GameConfigs.h"
|
||||
@@ -47,7 +46,6 @@
|
||||
#include <am-string.h>
|
||||
#include <bridge/include/ILogger.h>
|
||||
#include <bridge/include/CoreProvider.h>
|
||||
#include <bridge/include/IFileSystemBridge.h>
|
||||
|
||||
#if defined PLATFORM_POSIX
|
||||
#include <dlfcn.h>
|
||||
@@ -105,6 +103,8 @@ struct TempSigInfo
|
||||
char sig[1024];
|
||||
char library[64];
|
||||
} s_TempSig;
|
||||
unsigned int s_ServerBinCRC;
|
||||
bool s_ServerBinCRC_Ok = false;
|
||||
|
||||
static bool DoesGameMatch(const char *value)
|
||||
{
|
||||
@@ -303,21 +303,38 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
||||
{
|
||||
char error[255];
|
||||
error[0] = '\0';
|
||||
GameBinaryInfo binInfo;
|
||||
if (!g_GameConfigs.TryGetGameBinaryInfo(name, &binInfo))
|
||||
if (strcmp(name, "server") != 0)
|
||||
{
|
||||
ke::SafeSprintf(error, sizeof(error), "Unrecognized library \"%s\"", name);
|
||||
}
|
||||
else if (!binInfo.m_crcOK)
|
||||
else if (!s_ServerBinCRC_Ok)
|
||||
{
|
||||
ke::SafeSprintf(error, sizeof(error), "Could not get CRC for binary: %s", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
bCurrentBinCRC_Ok = binInfo.m_crcOK;
|
||||
bCurrentBinCRC = binInfo.m_crc;
|
||||
}
|
||||
FILE *fp;
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
|
||||
char binName[64];
|
||||
bridge->FormatSourceBinaryName(name, binName, sizeof(binName));
|
||||
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "bin/%s", binName);
|
||||
if ((fp = fopen(path, "rb")) == NULL)
|
||||
{
|
||||
ke::SafeSprintf(error, sizeof(error), "Could not open binary: %s", path);
|
||||
} else {
|
||||
size_t size;
|
||||
void *buffer;
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
buffer = malloc(size);
|
||||
fread(buffer, size, 1, fp);
|
||||
s_ServerBinCRC = UTIL_CRC32(buffer, size);
|
||||
free(buffer);
|
||||
s_ServerBinCRC_Ok = true;
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
if (error[0] != '\0')
|
||||
{
|
||||
m_IgnoreLevel = 1;
|
||||
@@ -444,12 +461,12 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
||||
}
|
||||
} else if (m_ParseState == PSTATE_GAMEDEFS_CRC_BINARY) {
|
||||
if (DoesPlatformMatch(key)
|
||||
&& bCurrentBinCRC_Ok
|
||||
&& s_ServerBinCRC_Ok
|
||||
&& !bShouldBeReadingDefault)
|
||||
{
|
||||
unsigned int crc = 0;
|
||||
sscanf(value, "%08X", &crc);
|
||||
if (bCurrentBinCRC == crc)
|
||||
if (s_ServerBinCRC == crc)
|
||||
{
|
||||
bShouldBeReadingDefault = true;
|
||||
}
|
||||
@@ -586,12 +603,14 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
|
||||
strncopy(s_TempSig.library, "server", sizeof(s_TempSig.library));
|
||||
}
|
||||
void *addrInBase = NULL;
|
||||
GameBinaryInfo binInfo;
|
||||
if (g_GameConfigs.TryGetGameBinaryInfo(s_TempSig.library, &binInfo))
|
||||
if (strcmp(s_TempSig.library, "server") == 0)
|
||||
{
|
||||
addrInBase = binInfo.m_pAddr;
|
||||
addrInBase = bridge->serverFactory;
|
||||
} else if (strcmp(s_TempSig.library, "engine") == 0) {
|
||||
addrInBase = bridge->engineFactory;
|
||||
} else if (strcmp(s_TempSig.library, "matchmaking_ds") == 0) {
|
||||
addrInBase = bridge->matchmakingDSFactory;
|
||||
}
|
||||
|
||||
void *final_addr = NULL;
|
||||
if (addrInBase == NULL)
|
||||
{
|
||||
@@ -1083,42 +1102,6 @@ bool CGameConfig::GetMemSig(const char *key, void **addr)
|
||||
return m_Sigs.retrieve(key, addr);
|
||||
}
|
||||
|
||||
void GameBinPathManager::Init()
|
||||
{
|
||||
char search_path[PLATFORM_MAX_PATH * 8];
|
||||
bridge->filesystem->GetSearchPath("GAMEBIN", false, search_path, sizeof(search_path));
|
||||
|
||||
char addons_folder[12];
|
||||
ke::SafeSprintf(addons_folder, sizeof(addons_folder), "%caddons%c", PLATFORM_SEP_CHAR, PLATFORM_SEP_CHAR);
|
||||
|
||||
std::istringstream iss(search_path);
|
||||
for (std::string path; std::getline(iss, path, ';');)
|
||||
{
|
||||
if (path.length() > 0
|
||||
&& path.find(addons_folder) == std::string::npos
|
||||
&& m_lookup.find(path) == m_lookup.cend()
|
||||
)
|
||||
{
|
||||
m_lookup.insert(path);
|
||||
m_ordered.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
iss.clear();
|
||||
|
||||
bridge->filesystem->GetSearchPath("EXECUTABLE_PATH", false, search_path, sizeof(search_path));
|
||||
iss.str(search_path);
|
||||
|
||||
for (std::string path; std::getline(iss, path, ';');)
|
||||
{
|
||||
if (m_lookup.find(path) == m_lookup.cend())
|
||||
{
|
||||
m_lookup.insert(path);
|
||||
m_ordered.push_back(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameConfigManager::GameConfigManager()
|
||||
{
|
||||
}
|
||||
@@ -1129,8 +1112,6 @@ GameConfigManager::~GameConfigManager()
|
||||
|
||||
void GameConfigManager::OnSourceModStartup(bool late)
|
||||
{
|
||||
m_gameBinPathManager.Init();
|
||||
|
||||
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
|
||||
|
||||
strncopy(g_Game, g_pSM->GetGameFolderName(), sizeof(g_Game));
|
||||
@@ -1253,75 +1234,3 @@ void GameConfigManager::RemoveCachedConfig(CGameConfig *config)
|
||||
{
|
||||
m_Lookup.remove(config->m_File);
|
||||
}
|
||||
|
||||
void GameConfigManager::CacheGameBinaryInfo(const char* pszName)
|
||||
{
|
||||
GameBinaryInfo info;
|
||||
|
||||
char name[64];
|
||||
bridge->FormatSourceBinaryName(pszName, name, sizeof(name));
|
||||
|
||||
char binary_path[PLATFORM_MAX_PATH];
|
||||
for (auto it = m_gameBinPathManager.Paths().begin(); it != m_gameBinPathManager.Paths().end(); ++it)
|
||||
{
|
||||
ke::SafeSprintf(binary_path, sizeof(binary_path), "%s%s%s", it->c_str(), it->back() == PLATFORM_SEP_CHAR ? "" : PLATFORM_SEP, name);
|
||||
#if defined PLATFORM_WINDOWS
|
||||
HMODULE hModule = LoadLibraryA(binary_path);
|
||||
if (hModule)
|
||||
{
|
||||
info.m_pAddr = GetProcAddress(hModule, "CreateInterface");
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
#else
|
||||
void *pHandle = dlopen(binary_path, RTLD_NOW);
|
||||
if (pHandle)
|
||||
{
|
||||
info.m_pAddr = dlsym(pHandle, "CreateInterface");
|
||||
dlclose(pHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (info.m_pAddr)
|
||||
break;
|
||||
}
|
||||
|
||||
// Don't bother trying to get CRC if we couldn't find the bin loaded
|
||||
if (info.m_pAddr)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(binary_path, "rb")) == 0)
|
||||
{
|
||||
info.m_crc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t size;
|
||||
void* buffer;
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
buffer = malloc(size);
|
||||
fread(buffer, size, 1, fp);
|
||||
info.m_crc = UTIL_CRC32(buffer, size);
|
||||
free(buffer);
|
||||
info.m_crcOK = true;
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
// But insert regardless, to cache the first lookup (even as failed)
|
||||
m_gameBinInfos.insert(pszName, info);
|
||||
}
|
||||
|
||||
bool GameConfigManager::TryGetGameBinaryInfo(const char* pszName, GameBinaryInfo* pDest)
|
||||
{
|
||||
if (m_gameBinInfos.retrieve(pszName, pDest))
|
||||
return pDest->m_pAddr != nullptr;
|
||||
|
||||
CacheGameBinaryInfo(pszName);
|
||||
|
||||
return m_gameBinInfos.retrieve(pszName, pDest);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <am-refcounting.h>
|
||||
#include <sm_stringhashmap.h>
|
||||
#include <sm_namehashset.h>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@@ -92,8 +91,6 @@ private:
|
||||
std::string m_offset;
|
||||
std::string m_Game;
|
||||
std::string m_Key;
|
||||
unsigned int bCurrentBinCRC;
|
||||
bool bCurrentBinCRC_Ok = false;
|
||||
bool bShouldBeReadingDefault;
|
||||
bool had_game;
|
||||
bool matched_game;
|
||||
@@ -129,30 +126,6 @@ private:
|
||||
time_t m_ModTime;
|
||||
};
|
||||
|
||||
struct GameBinaryInfo
|
||||
{
|
||||
void *m_pAddr = nullptr;
|
||||
uint32_t m_crc = 0;
|
||||
bool m_crcOK = false;
|
||||
};
|
||||
|
||||
class GameBinPathManager
|
||||
{
|
||||
public:
|
||||
GameBinPathManager() {}
|
||||
~GameBinPathManager() {}
|
||||
public:
|
||||
void Init();
|
||||
|
||||
inline const std::vector<std::string>& Paths() const
|
||||
{
|
||||
return m_ordered;
|
||||
}
|
||||
private:
|
||||
std::unordered_set<std::string> m_lookup;
|
||||
std::vector<std::string> m_ordered;
|
||||
};
|
||||
|
||||
class GameConfigManager :
|
||||
public IGameConfigManager,
|
||||
public SMGlobalClass
|
||||
@@ -175,16 +148,11 @@ public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModAllShutdown();
|
||||
public:
|
||||
bool TryGetGameBinaryInfo(const char* pszName, GameBinaryInfo* pDest);
|
||||
void RemoveCachedConfig(CGameConfig *config);
|
||||
private:
|
||||
void CacheGameBinaryInfo(const char* pszName);
|
||||
private:
|
||||
NameHashSet<CGameConfig *> m_Lookup;
|
||||
StringHashMap<GameBinaryInfo> m_gameBinInfos;
|
||||
public:
|
||||
StringHashMap<ITextListener_SMC *> m_customHandlers;
|
||||
GameBinPathManager m_gameBinPathManager;
|
||||
};
|
||||
|
||||
extern GameConfigManager g_GameConfigs;
|
||||
|
||||
@@ -273,7 +273,10 @@ NativeInvoker::Invoke(cell_t *result)
|
||||
/* Make the call if we can */
|
||||
if (ok)
|
||||
{
|
||||
*result = native_->func()(context_, _temp_params);
|
||||
if(native_->native)
|
||||
*result = native_->native->func(context_, _temp_params);
|
||||
else
|
||||
*result = native_->fake->wrapper->Invoke(context_, _temp_params);
|
||||
}
|
||||
|
||||
/* i should be equal to the last valid parameter + 1 */
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
#include <amtl/am-autoptr.h>
|
||||
#include <amtl/am-refcounting.h>
|
||||
#include "Native.h"
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
#include <bridge/include/IVEngineServerBridge.h>
|
||||
#include <bridge/include/CoreProvider.h>
|
||||
|
||||
#define SOURCEMOD_PLUGINAPI_VERSION 7
|
||||
|
||||
CPluginManager g_PluginSys;
|
||||
HandleType_t g_PluginType = 0;
|
||||
IdentityType_t g_PluginIdent = 0;
|
||||
@@ -311,12 +309,12 @@ bool CPlugin::ReadInfo()
|
||||
|
||||
base->GetPubvarAddrs(idx, &local_addr, (cell_t **)&info);
|
||||
m_FileVersion = info->version;
|
||||
if (m_FileVersion >= 5) {
|
||||
if (m_FileVersion >= 4) {
|
||||
base->LocalToString(info->date, (char **)&pDate);
|
||||
base->LocalToString(info->time, (char **)&pTime);
|
||||
ke::SafeSprintf(m_DateTime, sizeof(m_DateTime), "%s %s", pDate, pTime);
|
||||
}
|
||||
if (m_FileVersion > SOURCEMOD_PLUGINAPI_VERSION) {
|
||||
if (m_FileVersion > 5) {
|
||||
base->LocalToString(info->filevers, (char **)&pFileVers);
|
||||
EvictWithError(Plugin_Failed, "Newer SourceMod required (%s or higher)", pFileVers);
|
||||
return false;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SourceMod
|
||||
|
||||
struct IfaceInfo
|
||||
{
|
||||
bool operator ==(const IfaceInfo &info) const
|
||||
bool operator ==(const IfaceInfo &info)
|
||||
{
|
||||
return (info.iface == iface && info.owner == owner);
|
||||
}
|
||||
|
||||
@@ -281,19 +281,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
|
||||
}
|
||||
|
||||
// the blocknumber is not guaranteed to always be passed
|
||||
size_t blocknumber = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
blocknumber = (size_t)params[5];
|
||||
}
|
||||
|
||||
if (blocknumber >= array->blocksize())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
|
||||
}
|
||||
|
||||
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
|
||||
cell_t *blk = array->at(idx);
|
||||
size_t numWritten = 0;
|
||||
|
||||
pContext->StringToLocalUTF8(params[3], params[4], (char *)blk, &numWritten);
|
||||
@@ -319,19 +307,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
|
||||
}
|
||||
|
||||
// the blocknumber is not guaranteed to always be passed
|
||||
size_t blocknumber = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
blocknumber = (size_t)params[5];
|
||||
}
|
||||
|
||||
if (blocknumber >= array->blocksize())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
|
||||
}
|
||||
|
||||
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
|
||||
cell_t *blk = array->at(idx);
|
||||
size_t indexes = array->blocksize();
|
||||
if (params[4] != -1 && (size_t)params[4] <= array->blocksize())
|
||||
{
|
||||
@@ -403,30 +379,12 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
|
||||
}
|
||||
|
||||
// the blocknumber is not guaranteed to always be passed
|
||||
size_t blocknumber = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
blocknumber = (size_t)params[5];
|
||||
}
|
||||
|
||||
if (blocknumber >= array->blocksize())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
|
||||
}
|
||||
|
||||
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
|
||||
cell_t *blk = array->at(idx);
|
||||
|
||||
char *str;
|
||||
pContext->LocalToString(params[3], &str);
|
||||
|
||||
size_t maxlength = array->blocksize() * sizeof(cell_t);
|
||||
if (params[0] >= 4 && params[4] != -1 && (size_t)params[4] <= array->blocksize())
|
||||
{
|
||||
maxlength = (size_t)params[4];
|
||||
}
|
||||
|
||||
return strncopy((char*)blk, str, maxlength);
|
||||
return strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
|
||||
}
|
||||
|
||||
static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
@@ -447,19 +405,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
|
||||
}
|
||||
|
||||
// the blocknumber is not guaranteed to always be passed
|
||||
size_t blocknumber = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
blocknumber = (size_t)params[5];
|
||||
}
|
||||
|
||||
if (blocknumber >= array->blocksize())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
|
||||
}
|
||||
|
||||
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
|
||||
cell_t *blk = array->at(idx);
|
||||
size_t indexes = array->blocksize();
|
||||
if (params[4] != -1 && (size_t)params[4] <= array->blocksize())
|
||||
{
|
||||
@@ -587,24 +533,12 @@ static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
// the blocknumber is not guaranteed to always be passed
|
||||
size_t blocknumber = 0;
|
||||
if (params[0] >= 3)
|
||||
{
|
||||
blocknumber = (size_t)params[3];
|
||||
}
|
||||
|
||||
if (blocknumber >= array->blocksize())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
|
||||
}
|
||||
|
||||
char *str;
|
||||
pContext->LocalToString(params[2], &str);
|
||||
|
||||
for (unsigned int i = 0; i < array->size(); i++)
|
||||
{
|
||||
const char *array_str = (const char *)&array->base()[i * array->blocksize() + blocknumber];
|
||||
const char *array_str = (const char *)array->at(i);
|
||||
if (strcmp(str, array_str) == 0)
|
||||
{
|
||||
return (cell_t) i;
|
||||
|
||||
@@ -240,9 +240,9 @@ static cell_t PopStackCell(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (idx >= array->blocksize() * sizeof(cell_t))
|
||||
if (idx >= array->blocksize() * 4)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
|
||||
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * 4);
|
||||
}
|
||||
*buffer = (cell_t)*((char *)blk + idx);
|
||||
}
|
||||
@@ -356,8 +356,8 @@ static cell_t ArrayStack_Pop(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", idx, array->blocksize());
|
||||
rval = blk[idx];
|
||||
} else {
|
||||
if (idx >= array->blocksize() * sizeof(cell_t))
|
||||
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
|
||||
if (idx >= array->blocksize() * 4)
|
||||
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * 4);
|
||||
rval = (cell_t)*((char *)blk + idx);
|
||||
}
|
||||
|
||||
@@ -365,32 +365,6 @@ static cell_t ArrayStack_Pop(IPluginContext *pContext, const cell_t *params)
|
||||
return rval;
|
||||
}
|
||||
|
||||
static cell_t ArrayStack_Top(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
|
||||
if (!array.Ok())
|
||||
return 0;
|
||||
|
||||
if (array->size() == 0)
|
||||
return pContext->ThrowNativeError("stack is empty");
|
||||
|
||||
cell_t *blk = array->at(array->size() - 1);
|
||||
size_t idx = (size_t)params[2];
|
||||
|
||||
cell_t rval;
|
||||
if (params[3] == 0) {
|
||||
if (idx >= array->blocksize())
|
||||
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", idx, array->blocksize());
|
||||
rval = blk[idx];
|
||||
} else {
|
||||
if (idx >= array->blocksize() * sizeof(cell_t))
|
||||
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
|
||||
rval = (cell_t)*((char *)blk + idx);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static cell_t ArrayStack_PopString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
|
||||
@@ -413,27 +387,6 @@ static cell_t ArrayStack_PopString(IPluginContext *pContext, const cell_t *param
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t ArrayStack_TopString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
|
||||
if (!array.Ok())
|
||||
return 0;
|
||||
|
||||
if (array->size() == 0)
|
||||
return pContext->ThrowNativeError("stack is empty");
|
||||
|
||||
size_t idx = array->size() - 1;
|
||||
cell_t *blk = array->at(idx);
|
||||
|
||||
cell_t *pWritten;
|
||||
pContext->LocalToPhysAddr(params[4], &pWritten);
|
||||
|
||||
size_t numWritten;
|
||||
pContext->StringToLocalUTF8(params[2], params[3], (char *)blk, &numWritten);
|
||||
*pWritten = (cell_t)numWritten;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t ArrayStack_PopArray(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
|
||||
@@ -458,29 +411,6 @@ static cell_t ArrayStack_PopArray(IPluginContext *pContext, const cell_t *params
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell_t ArrayStack_TopArray(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
|
||||
if (!array.Ok())
|
||||
return 0;
|
||||
|
||||
if (array->size() == 0)
|
||||
return pContext->ThrowNativeError("stack is empty");
|
||||
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[2], &addr);
|
||||
|
||||
size_t idx = array->size() - 1;
|
||||
cell_t *blk = array->at(idx);
|
||||
size_t indexes = array->blocksize();
|
||||
|
||||
if (params[3] != -1 && (size_t)params[3] <= array->blocksize())
|
||||
indexes = params[3];
|
||||
|
||||
memcpy(addr, blk, sizeof(cell_t) * indexes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell_t GetStackBlockSize(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
@@ -496,21 +426,6 @@ static cell_t GetStackBlockSize(IPluginContext *pContext, const cell_t *params)
|
||||
return array->blocksize();
|
||||
}
|
||||
|
||||
static cell_t GetStackSize(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
CellArray *array;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
return array->size();
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(cellStackNatives)
|
||||
{
|
||||
{"CreateStack", CreateStack},
|
||||
@@ -529,17 +444,13 @@ REGISTER_NATIVES(cellStackNatives)
|
||||
{"ArrayStack.Clear", ClearStack},
|
||||
{"ArrayStack.Clone", CloneStack},
|
||||
{"ArrayStack.Pop", ArrayStack_Pop},
|
||||
{"ArrayStack.Top", ArrayStack_Top},
|
||||
{"ArrayStack.PopString", ArrayStack_PopString},
|
||||
{"ArrayStack.TopString", ArrayStack_TopString},
|
||||
{"ArrayStack.PopArray", ArrayStack_PopArray},
|
||||
{"ArrayStack.TopArray", ArrayStack_TopArray},
|
||||
{"ArrayStack.Push", PushStackCell},
|
||||
{"ArrayStack.PushString", PushStackString},
|
||||
{"ArrayStack.PushArray", PushStackArray},
|
||||
{"ArrayStack.Empty.get", IsStackEmpty},
|
||||
{"ArrayStack.BlockSize.get", GetStackBlockSize},
|
||||
{"ArrayStack.Length.get", GetStackSize},
|
||||
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include "common_logic.h"
|
||||
#include "Logger.h"
|
||||
@@ -275,49 +273,6 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ParseTime(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *datetime;
|
||||
char *format;
|
||||
pContext->LocalToStringNULL(params[1], &datetime);
|
||||
pContext->LocalToStringNULL(params[2], &format);
|
||||
|
||||
if (format == NULL)
|
||||
{
|
||||
format = const_cast<char *>(bridge->GetCvarString(g_datetime_format));
|
||||
}
|
||||
else if (!format[0])
|
||||
{
|
||||
return pContext->ThrowNativeError("Time format string cannot be empty.");
|
||||
}
|
||||
if (!datetime || !datetime[0])
|
||||
{
|
||||
return pContext->ThrowNativeError("Date/time string cannot be empty.");
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/33542189
|
||||
std::tm t{};
|
||||
std::istringstream input(datetime);
|
||||
|
||||
auto previousLocale = input.imbue(std::locale::classic());
|
||||
input >> std::get_time(&t, format);
|
||||
bool failed = input.fail();
|
||||
input.imbue(previousLocale);
|
||||
|
||||
if (failed)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid date/time string or time format.");
|
||||
}
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
return _mkgmtime(&t);
|
||||
#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
|
||||
return timegm(&t);
|
||||
#else
|
||||
return pContext->ThrowNativeError("Platform has no implemented UTC conversion for std::tm to std::time_t");
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginIterator *iter = scripts->GetPluginIterator();
|
||||
@@ -1133,7 +1088,6 @@ REGISTER_NATIVES(coreNatives)
|
||||
{"ThrowError", ThrowError},
|
||||
{"GetTime", GetTime},
|
||||
{"FormatTime", FormatTime},
|
||||
{"ParseTime", ParseTime},
|
||||
{"GetPluginIterator", GetPluginIterator},
|
||||
{"MorePlugins", MorePlugins},
|
||||
{"ReadPlugin", ReadPlugin},
|
||||
|
||||
@@ -1787,10 +1787,10 @@ static cell_t SQL_ExecuteTransaction(IPluginContext *pContext, const cell_t *par
|
||||
|
||||
IPluginFunction *onSuccess = NULL;
|
||||
IPluginFunction *onError = NULL;
|
||||
if (!pContext->GetFunctionByIdOrNull(params[3], &onSuccess))
|
||||
return 0;
|
||||
if (!pContext->GetFunctionByIdOrNull(params[4], &onError))
|
||||
return 0;
|
||||
if (params[3] != -1 && ((onSuccess = pContext->GetFunctionById(params[3])) == NULL))
|
||||
return pContext->ThrowNativeError("Function id %x is invalid", params[3]);
|
||||
if (params[4] != -1 && ((onError = pContext->GetFunctionById(params[4])) == NULL))
|
||||
return pContext->ThrowNativeError("Function id %x is invalid", params[4]);
|
||||
|
||||
cell_t data = params[5];
|
||||
PrioQueueLevel priority = PrioQueue_Normal;
|
||||
|
||||
@@ -244,19 +244,7 @@ static cell_t smn_WritePackFunction(IPluginContext *pContext, const cell_t *para
|
||||
pDataPack->RemoveItem();
|
||||
}
|
||||
|
||||
cell_t funcid = params[2];
|
||||
if (pContext->IsNullFunctionId(funcid))
|
||||
{
|
||||
pDataPack->PackFunction(0);
|
||||
}
|
||||
else if (funcid <= 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDataPack->PackFunction(funcid);
|
||||
}
|
||||
pDataPack->PackFunction(params[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -377,12 +365,7 @@ static cell_t smn_ReadPackFunction(IPluginContext *pContext, const cell_t *param
|
||||
return pContext->ThrowNativeError("Invalid data pack type (got %d / expected %d).", pDataPack->GetCurrentType(), CDataPackType::Function);
|
||||
}
|
||||
|
||||
cell_t funcid = pDataPack->ReadFunction();
|
||||
if (!funcid)
|
||||
{
|
||||
return pContext->GetNullFunctionValue();
|
||||
}
|
||||
return funcid;
|
||||
return pDataPack->ReadFunction();
|
||||
}
|
||||
|
||||
static cell_t smn_ReadPackCellArray(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
@@ -366,33 +366,6 @@ static cell_t SetNativeArray(IPluginContext *pContext, const cell_t *params)
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
static cell_t GetNativeFunction(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);
|
||||
}
|
||||
|
||||
cell_t funcid = s_curparams[param];
|
||||
if (s_curcaller->IsNullFunctionId(funcid))
|
||||
{
|
||||
// see alliedmodders/sourcepawn#912, alliedmodders/sourcemod#2068
|
||||
// convert null function to receiver's expected value so equality checks against INVALID_FUNCTION pass
|
||||
return pContext->GetNullFunctionValue();
|
||||
}
|
||||
else if (funcid <= 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
}
|
||||
return funcid;
|
||||
}
|
||||
|
||||
static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!s_curnative || (s_curnative->ctx != pContext))
|
||||
@@ -510,7 +483,7 @@ REGISTER_NATIVES(nativeNatives)
|
||||
{"GetNativeArray", GetNativeArray},
|
||||
{"GetNativeCell", GetNativeCell},
|
||||
{"GetNativeCellRef", GetNativeCellRef},
|
||||
{"GetNativeFunction", GetNativeFunction},
|
||||
{"GetNativeFunction", GetNativeCell},
|
||||
{"GetNativeString", GetNativeString},
|
||||
{"GetNativeStringLength", GetNativeStringLength},
|
||||
{"FormatNativeString", FormatNativeString},
|
||||
|
||||
@@ -73,7 +73,6 @@ class FileObject
|
||||
public:
|
||||
virtual ~FileObject()
|
||||
{}
|
||||
virtual size_t Size() = 0;
|
||||
virtual size_t Read(void *pOut, int size) = 0;
|
||||
virtual char *ReadLine(char *pOut, int size) = 0;
|
||||
virtual size_t Write(const void *pData, int size) = 0;
|
||||
@@ -120,10 +119,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Size() override {
|
||||
return (size_t)bridge->filesystem->Size(handle_);
|
||||
}
|
||||
|
||||
size_t Read(void *pOut, int size) override {
|
||||
return (size_t)bridge->filesystem->Read(pOut, size, handle_);
|
||||
}
|
||||
@@ -188,30 +183,6 @@ public:
|
||||
return unlink(path) == 0;
|
||||
}
|
||||
|
||||
size_t Size() override {
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
struct _stat s;
|
||||
int fd = _fileno(fp_);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
if (_fstat(fd, &s) != 0)
|
||||
return -1;
|
||||
if (s.st_mode & S_IFREG)
|
||||
return static_cast<size_t>(s.st_size);
|
||||
return -1;
|
||||
#elif defined PLATFORM_POSIX
|
||||
struct stat s;
|
||||
int fd = fileno(fp_);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
if (fstat(fd, &s) != 0)
|
||||
return -1;
|
||||
if (S_ISREG(s.st_mode))
|
||||
return static_cast<size_t>(s.st_size);
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t Read(void *pOut, int size) override {
|
||||
return fread(pOut, 1, size, fp_);
|
||||
}
|
||||
@@ -317,10 +288,6 @@ public:
|
||||
}
|
||||
virtual bool LogPrint(const char *msg)
|
||||
{
|
||||
if (!g_pLogHook) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cell_t result = 0;
|
||||
g_pLogHook->PushString(msg);
|
||||
g_pLogHook->Execute(&result);
|
||||
@@ -643,7 +610,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
|
||||
g_pSM->BuildPath(Path_Game, old_realpath, sizeof(old_realpath), "%s", oldpath);
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
return (MoveFileExA(old_realpath, new_realpath, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) ? 1 : 0;
|
||||
return (MoveFileA(old_realpath, new_realpath)) ? 1 : 0;
|
||||
#elif defined PLATFORM_POSIX
|
||||
return (rename(old_realpath, new_realpath)) ? 0 : 1;
|
||||
#endif
|
||||
@@ -755,39 +722,6 @@ static cell_t sm_SetFilePermissions(IPluginContext *pContext, const cell_t *para
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t sm_GetFilePermissions(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
char realpath[PLATFORM_MAX_PATH];
|
||||
|
||||
pContext->LocalToString(params[1], &name);
|
||||
g_pSM->BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name);
|
||||
|
||||
cell_t *mask;
|
||||
pContext->LocalToPhysAddr(params[2], &mask);
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
struct _stat buffer;
|
||||
cell_t valid = _stat(realpath, &buffer) == 0;
|
||||
|
||||
if ((buffer.st_mode & _S_IREAD) != 0) {
|
||||
*mask |= (FPERM_U_READ|FPERM_G_READ|FPERM_O_READ)|(FPERM_U_EXEC|FPERM_G_EXEC|FPERM_O_EXEC);
|
||||
}
|
||||
|
||||
if ((buffer.st_mode & _S_IWRITE) != 0) {
|
||||
*mask |= (FPERM_U_WRITE|FPERM_G_WRITE|FPERM_O_WRITE);
|
||||
}
|
||||
|
||||
return valid;
|
||||
#else
|
||||
struct stat buffer;
|
||||
cell_t valid = stat(realpath, &buffer) == 0;
|
||||
|
||||
*mask = buffer.st_mode;
|
||||
return valid;
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t sm_CreateDirectory(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
@@ -1191,15 +1125,6 @@ static cell_t sm_RemoveGameLogHook(IPluginContext *pContext, const cell_t *param
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t File_Size(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<FileObject> file(pContext, params[1], g_FileType);
|
||||
if (!file.Ok())
|
||||
return -1;
|
||||
|
||||
return file->Size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static cell_t File_ReadTyped(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
@@ -1261,7 +1186,6 @@ REGISTER_NATIVES(filesystem)
|
||||
{"RemoveGameLogHook", sm_RemoveGameLogHook},
|
||||
{"CreateDirectory", sm_CreateDirectory},
|
||||
{"SetFilePermissions", sm_SetFilePermissions},
|
||||
{"GetFilePermissions", sm_GetFilePermissions},
|
||||
|
||||
{"File.ReadLine", sm_ReadFileLine},
|
||||
{"File.Read", sm_ReadFile},
|
||||
@@ -1273,7 +1197,6 @@ REGISTER_NATIVES(filesystem)
|
||||
{"File.Seek", sm_FileSeek},
|
||||
{"File.Flush", sm_FlushFile},
|
||||
{"File.Position.get", sm_FilePosition},
|
||||
{"File.Size", File_Size},
|
||||
{"File.ReadInt8", File_ReadTyped<int8_t>},
|
||||
{"File.ReadUint8", File_ReadTyped<uint8_t>},
|
||||
{"File.ReadInt16", File_ReadTyped<int16_t>},
|
||||
|
||||
@@ -231,13 +231,6 @@ static cell_t sm_FloatFraction(IPluginContext *pCtx, const cell_t *params)
|
||||
return sp_ftoc(val);
|
||||
}
|
||||
|
||||
static cell_t sm_FloatMod(IPluginContext* pCtx, const cell_t* params)
|
||||
{
|
||||
float val = fmodf(sp_ctof(params[1]), sp_ctof(params[2]));
|
||||
|
||||
return sp_ftoc(val);
|
||||
}
|
||||
|
||||
static cell_t sm_Sine(IPluginContext *pCtx, const cell_t *params)
|
||||
{
|
||||
float val = sp_ctof(params[1]);
|
||||
@@ -365,16 +358,10 @@ REGISTER_NATIVES(floatnatives)
|
||||
{"FloatAdd", sm_FloatAdd},
|
||||
{"FloatSub", sm_FloatSub},
|
||||
{"FloatFraction", sm_FloatFraction},
|
||||
{"FloatMod", sm_FloatMod},
|
||||
{"RoundToZero", sm_RoundToZero},
|
||||
{"RoundToCeil", sm_RoundToCeil},
|
||||
{"RoundToFloor", sm_RoundToFloor},
|
||||
{"RoundToNearest", sm_RoundToNearest},
|
||||
{"__FLOAT_MUL__", sm_FloatMul},
|
||||
{"__FLOAT_DIV__", sm_FloatDiv},
|
||||
{"__FLOAT_ADD__", sm_FloatAdd},
|
||||
{"__FLOAT_SUB__", sm_FloatSub},
|
||||
{"__FLOAT_MOD__", sm_FloatMod},
|
||||
{"__FLOAT_GT__", sm_FloatGt},
|
||||
{"__FLOAT_GE__", sm_FloatGe},
|
||||
{"__FLOAT_LT__", sm_FloatLt},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <IHandleSys.h>
|
||||
#include <IForwardSys.h>
|
||||
#include <ISourceMod.h>
|
||||
#include <amtl/am-autoptr.h>
|
||||
#include "ShareSys.h"
|
||||
#include "NativeInvoker.h"
|
||||
|
||||
@@ -49,7 +48,7 @@ static IPluginFunction *s_pFunction = NULL;
|
||||
static IForward *s_pForward = NULL;
|
||||
static NativeInvoker *s_pInvoker = NULL;
|
||||
|
||||
class ForwardNativeHelpers :
|
||||
class ForwardNativeHelpers :
|
||||
public SMGlobalClass,
|
||||
public IHandleTypeDispatch
|
||||
{
|
||||
@@ -138,7 +137,7 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
|
||||
if (pPlugin->GetBaseContext()->FindPublicByName(name, &idx) == SP_ERROR_NOT_FOUND)
|
||||
{
|
||||
/* Return INVALID_FUNCTION if not found */
|
||||
return pContext->GetNullFunctionValue();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Return function ID */
|
||||
@@ -155,7 +154,7 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
|
||||
{
|
||||
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, NULL);
|
||||
}
|
||||
|
||||
|
||||
pContext->LocalToString(params[1], &name);
|
||||
|
||||
cell_t *addr;
|
||||
@@ -235,15 +234,11 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
}
|
||||
|
||||
cell_t funcid = params[3];
|
||||
if (funcid <= 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
}
|
||||
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
|
||||
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[3]);
|
||||
|
||||
if (!pFunction)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
|
||||
}
|
||||
|
||||
return pForward->AddFunction(pFunction);
|
||||
@@ -276,15 +271,11 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
|
||||
}
|
||||
}
|
||||
|
||||
cell_t funcid = params[3];
|
||||
if (funcid <= 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
}
|
||||
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
|
||||
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[3]);
|
||||
|
||||
if (!pFunction)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
|
||||
}
|
||||
|
||||
return pForward->RemoveFunction(pFunction);
|
||||
@@ -342,15 +333,11 @@ static cell_t sm_CallStartFunction(IPluginContext *pContext, const cell_t *param
|
||||
}
|
||||
}
|
||||
|
||||
cell_t funcid = params[2];
|
||||
if (funcid <= 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
}
|
||||
s_pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
|
||||
s_pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[2]);
|
||||
|
||||
if (!s_pFunction)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
|
||||
}
|
||||
|
||||
s_pCallable = static_cast<ICallable *>(s_pFunction);
|
||||
|
||||
@@ -119,7 +119,5 @@ REGISTER_NATIVES(handles)
|
||||
{"CloseHandle", sm_CloseHandle},
|
||||
{"CloneHandle", sm_CloneHandle},
|
||||
{"GetMyHandle", sm_GetMyHandle},
|
||||
{"Handle.Close", sm_CloseHandle},
|
||||
{"Handle.~Handle", sm_CloseHandle},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -144,18 +144,6 @@ static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *param
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetClientOriginalLanguage(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
|
||||
|
||||
if (!player || !player->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
|
||||
}
|
||||
|
||||
return player->GetOriginalLanguageId();
|
||||
}
|
||||
|
||||
static cell_t sm_GetLanguageByCode(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *code;
|
||||
@@ -193,7 +181,6 @@ REGISTER_NATIVES(langNatives)
|
||||
{"GetLanguageCount", sm_GetLanguageCount},
|
||||
{"GetLanguageInfo", sm_GetLanguageInfo},
|
||||
{"SetClientLanguage", sm_SetClientLanguage},
|
||||
{"GetClientOriginalLanguage", sm_GetClientOriginalLanguage},
|
||||
{"GetLanguageByCode", sm_GetLanguageByCode},
|
||||
{"GetLanguageByName", sm_GetLanguageByName},
|
||||
{NULL, NULL},
|
||||
|
||||
@@ -1568,11 +1568,15 @@ static cell_t InternalShowMenu(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
IMenuHandler *pHandler;
|
||||
CPanelHandler *pActualHandler = NULL;
|
||||
IPluginFunction* func;
|
||||
if (!pContext->GetFunctionByIdOrNull(params[5], &func))
|
||||
return 0;
|
||||
if (func)
|
||||
pActualHandler = g_MenuHelpers.GetPanelHandler(func);
|
||||
if (params[5] != -1)
|
||||
{
|
||||
IPluginFunction *pFunction = pContext->GetFunctionById(params[5]);
|
||||
if (pFunction == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function index %x", params[5]);
|
||||
}
|
||||
pActualHandler = g_MenuHelpers.GetPanelHandler(pFunction);
|
||||
}
|
||||
|
||||
if (pActualHandler == NULL)
|
||||
{
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "common_logic.h"
|
||||
#include <ITextParsers.h>
|
||||
#include <ISourceMod.h>
|
||||
@@ -266,32 +264,6 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
|
||||
return (cell_t)p_err;
|
||||
}
|
||||
|
||||
static cell_t SMC_ParseString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
OpenHandle<ParseInfo> parse(pContext, params[1], g_TypeSMC);
|
||||
if (!parse.Ok())
|
||||
return 0;
|
||||
|
||||
char *str;
|
||||
pContext->LocalToString(params[2], &str);
|
||||
|
||||
SMCStates states;
|
||||
SMCError p_err = textparsers->ParseSMCStream(str,
|
||||
strlen(str),
|
||||
parse,
|
||||
&states,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
cell_t *c_line, *c_col;
|
||||
pContext->LocalToPhysAddr(params[3], &c_line);
|
||||
pContext->LocalToPhysAddr(params[4], &c_col);
|
||||
|
||||
*c_line = states.line;
|
||||
*c_col = states.col;
|
||||
return (cell_t)p_err;
|
||||
}
|
||||
|
||||
static cell_t SMC_GetErrorString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
const char *str = textparsers->GetSMCErrorString((SMCError)params[1]);
|
||||
@@ -362,7 +334,6 @@ REGISTER_NATIVES(textNatives)
|
||||
// Transitional syntax support.
|
||||
{"SMCParser.SMCParser", SMC_CreateParser},
|
||||
{"SMCParser.ParseFile", SMC_ParseFile},
|
||||
{"SMCParser.ParseString", SMC_ParseString},
|
||||
{"SMCParser.OnStart.set", SMC_SetParseStart},
|
||||
{"SMCParser.OnEnd.set", SMC_SetParseEnd},
|
||||
{"SMCParser.OnEnterSection.set", SMCParser_OnEnterSection_set},
|
||||
|
||||
+31
-42
@@ -102,98 +102,90 @@ public:
|
||||
class VFileSystem_Logic : public IFileSystemBridge
|
||||
{
|
||||
public:
|
||||
const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) override
|
||||
const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle)
|
||||
{
|
||||
return filesystem->FindFirstEx(pWildCard, pPathID, pHandle);
|
||||
}
|
||||
const char *FindNext(FileFindHandle_t handle) override
|
||||
const char *FindNext(FileFindHandle_t handle)
|
||||
{
|
||||
return filesystem->FindNext(handle);
|
||||
}
|
||||
bool FindIsDirectory(FileFindHandle_t handle) override
|
||||
bool FindIsDirectory(FileFindHandle_t handle)
|
||||
{
|
||||
return filesystem->FindIsDirectory(handle);
|
||||
}
|
||||
void FindClose(FileFindHandle_t handle) override
|
||||
void FindClose(FileFindHandle_t handle)
|
||||
{
|
||||
filesystem->FindClose(handle);
|
||||
}
|
||||
FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) override
|
||||
FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0)
|
||||
{
|
||||
return filesystem->Open(pFileName, pOptions, pathID);
|
||||
}
|
||||
void Close(FileHandle_t file) override
|
||||
void Close(FileHandle_t file)
|
||||
{
|
||||
filesystem->Close(file);
|
||||
}
|
||||
char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) override
|
||||
char *ReadLine(char *pOutput, int maxChars, FileHandle_t file)
|
||||
{
|
||||
return filesystem->ReadLine(pOutput, maxChars, file);
|
||||
}
|
||||
bool EndOfFile(FileHandle_t file) override
|
||||
bool EndOfFile(FileHandle_t file)
|
||||
{
|
||||
return filesystem->EndOfFile(file);
|
||||
}
|
||||
bool FileExists(const char *pFileName, const char *pPathID = 0) override
|
||||
bool FileExists(const char *pFileName, const char *pPathID = 0)
|
||||
{
|
||||
return filesystem->FileExists(pFileName, pPathID);
|
||||
}
|
||||
unsigned int Size(FileHandle_t file) override
|
||||
{
|
||||
return filesystem->Size(file);
|
||||
}
|
||||
unsigned int Size(const char *pFileName, const char *pPathID = 0) override
|
||||
unsigned int Size(const char *pFileName, const char *pPathID = 0)
|
||||
{
|
||||
return filesystem->Size(pFileName, pPathID);
|
||||
}
|
||||
int Read(void* pOutput, int size, FileHandle_t file) override
|
||||
int Read(void* pOutput, int size, FileHandle_t file)
|
||||
{
|
||||
return filesystem->Read(pOutput, size, file);
|
||||
}
|
||||
int Write(void const* pInput, int size, FileHandle_t file) override
|
||||
int Write(void const* pInput, int size, FileHandle_t file)
|
||||
{
|
||||
return filesystem->Write(pInput, size, file);
|
||||
}
|
||||
void Seek(FileHandle_t file, int pos, int seekType) override
|
||||
void Seek(FileHandle_t file, int pos, int seekType)
|
||||
{
|
||||
filesystem->Seek(file, pos, (FileSystemSeek_t) seekType);
|
||||
}
|
||||
unsigned int Tell(FileHandle_t file) override
|
||||
unsigned int Tell(FileHandle_t file)
|
||||
{
|
||||
return filesystem->Tell(file);
|
||||
}
|
||||
int FPrint(FileHandle_t file, const char *pData) override
|
||||
int FPrint(FileHandle_t file, const char *pData)
|
||||
{
|
||||
return filesystem->FPrintf(file, "%s", pData);
|
||||
}
|
||||
void Flush(FileHandle_t file) override
|
||||
void Flush(FileHandle_t file)
|
||||
{
|
||||
filesystem->Flush(file);
|
||||
}
|
||||
bool IsOk(FileHandle_t file) override
|
||||
bool IsOk(FileHandle_t file)
|
||||
{
|
||||
return filesystem->IsOk(file);
|
||||
}
|
||||
void RemoveFile(const char *pRelativePath, const char *pathID) override
|
||||
void RemoveFile(const char *pRelativePath, const char *pathID)
|
||||
{
|
||||
filesystem->RemoveFile(pRelativePath, pathID);
|
||||
}
|
||||
void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID) override
|
||||
void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID)
|
||||
{
|
||||
filesystem->RenameFile(pOldPath, pNewPath, pathID);
|
||||
}
|
||||
bool IsDirectory(const char *pFileName, const char *pathID) override
|
||||
bool IsDirectory(const char *pFileName, const char *pathID)
|
||||
{
|
||||
return filesystem->IsDirectory(pFileName, pathID);
|
||||
}
|
||||
void CreateDirHierarchy(const char *path, const char *pathID) override
|
||||
void CreateDirHierarchy(const char *path, const char *pathID)
|
||||
{
|
||||
filesystem->CreateDirHierarchy(path, pathID);
|
||||
}
|
||||
int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) override
|
||||
{
|
||||
return filesystem->GetSearchPath(pathID, bGetPackFiles, pPath, nMaxLen);
|
||||
}
|
||||
} fs_wrapper;
|
||||
|
||||
class VPlayerInfo_Logic : public IPlayerInfoBridge
|
||||
@@ -379,12 +371,6 @@ void UTIL_ConsolePrint(const char *fmt, ...)
|
||||
#define GAMEFIX "2.csgo"
|
||||
#elif SOURCE_ENGINE == SE_CONTAGION
|
||||
#define GAMEFIX "2.contagion"
|
||||
#elif SOURCE_ENGINE == SE_PVKII
|
||||
#define GAMEFIX "2.pvkii"
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
#define GAMEFIX "2.mcv"
|
||||
#elif SOURCE_ENGINE == SE_MOCK
|
||||
#define GAMEFIX "2.mock"
|
||||
#else
|
||||
#define GAMEFIX "2.ep1"
|
||||
#endif
|
||||
@@ -417,6 +403,9 @@ CoreProviderImpl::CoreProviderImpl()
|
||||
this->GetGlobalTarget = get_global_target;
|
||||
this->gamesuffix = GAMEFIX;
|
||||
this->serverGlobals = &::serverGlobals;
|
||||
this->serverFactory = nullptr;
|
||||
this->engineFactory = nullptr;
|
||||
this->matchmakingDSFactory = nullptr;
|
||||
this->listeners = nullptr;
|
||||
}
|
||||
|
||||
@@ -506,10 +495,6 @@ const char *CoreProviderImpl::GetSourceEngineName()
|
||||
return "csgo";
|
||||
#elif SOURCE_ENGINE == SE_MOCK
|
||||
return "mock";
|
||||
#elif SOURCE_ENGINE == SE_PVKII
|
||||
return "pvkii";
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
return "mcv";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -527,9 +512,7 @@ bool CoreProviderImpl::SymbolsAreHidden()
|
||||
|| (SOURCE_ENGINE == SE_INSURGENCY) \
|
||||
|| (SOURCE_ENGINE == SE_DOI) \
|
||||
|| (SOURCE_ENGINE == SE_BLADE) \
|
||||
|| (SOURCE_ENGINE == SE_CSGO) \
|
||||
|| (SOURCE_ENGINE == SE_PVKII) \
|
||||
|| (SOURCE_ENGINE == SE_MCV)
|
||||
|| (SOURCE_ENGINE == SE_CSGO)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@@ -642,8 +625,14 @@ void CoreProviderImpl::InitializeBridge()
|
||||
::serverGlobals.frametime = &gpGlobals->frametime;
|
||||
::serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick;
|
||||
|
||||
this->engineFactory = (void *)g_SMAPI->GetEngineFactory(false);
|
||||
this->serverFactory = (void *)g_SMAPI->GetServerFactory(false);
|
||||
this->listeners = SMGlobalClass::head;
|
||||
|
||||
if (auto mmlib = ::filesystem->LoadModule("matchmaking_ds" SOURCE_BIN_SUFFIX, "GAMEBIN")) {
|
||||
this->matchmakingDSFactory = (void*)Sys_GetFactory(mmlib);
|
||||
}
|
||||
|
||||
logic_init_(this, &logicore);
|
||||
|
||||
// Join logic's SMGlobalClass instances.
|
||||
|
||||
+9
-57
@@ -51,7 +51,7 @@
|
||||
#include <bridge/include/ILogger.h>
|
||||
#include <ITranslator.h>
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
#include <netmessages.pb.h>
|
||||
#endif
|
||||
|
||||
@@ -989,14 +989,11 @@ static cell_t sm_ServerCommandEx(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
|
||||
engine->ServerExecute();
|
||||
if (!g_ShouldCatchSpew) {
|
||||
g_ShouldCatchSpew = true;
|
||||
engine->ServerCommand("sm_conhook_start\n");
|
||||
engine->ServerCommand(buffer);
|
||||
engine->ServerCommand("sm_conhook_stop\n");
|
||||
} else {
|
||||
engine->ServerCommand(buffer);
|
||||
}
|
||||
|
||||
g_ShouldCatchSpew = true;
|
||||
engine->ServerCommand("sm_conhook_start\n");
|
||||
engine->ServerCommand(buffer);
|
||||
engine->ServerCommand("sm_conhook_stop\n");
|
||||
|
||||
engine->ServerExecute();
|
||||
|
||||
@@ -1104,26 +1101,6 @@ static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
|
||||
return g_ChatTriggers.IsChatTrigger() ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t GetPublicChatTriggers(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
size_t length;
|
||||
|
||||
const char *triggers = g_ChatTriggers.GetPublicChatTrigger();
|
||||
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
|
||||
|
||||
return static_cast<cell_t>(length);
|
||||
}
|
||||
|
||||
static cell_t GetSilentChatTriggers(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
size_t length;
|
||||
|
||||
const char *triggers = g_ChatTriggers.GetPrivateChatTrigger();
|
||||
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
|
||||
|
||||
return static_cast<cell_t>(length);
|
||||
}
|
||||
|
||||
static cell_t SetCommandFlags(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
@@ -1242,7 +1219,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
|
||||
char data[256];
|
||||
bf_write buffer(data, sizeof(data));
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CNETMsg_SetConVar msg;
|
||||
CMsg_CVars_CVar *cvar = msg.mutable_convars()->add_cvars();
|
||||
|
||||
@@ -1426,7 +1403,7 @@ static cell_t sm_CommandIteratorNext(IPluginContext *pContext, const cell_t *par
|
||||
return iter->iter != cmds.end();
|
||||
}
|
||||
|
||||
static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t sm_CommandIteratorFlags(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
GlobCmdIter *iter;
|
||||
HandleError err;
|
||||
@@ -1447,27 +1424,6 @@ static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_
|
||||
return pInfo->eflags;
|
||||
}
|
||||
|
||||
static cell_t sm_CommandIteratorConVarFlags(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
GlobCmdIter *iter;
|
||||
HandleError err;
|
||||
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hCmdIterType, &sec, (void **)&iter))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]);
|
||||
}
|
||||
const List<ConCmdInfo *> &cmds = g_ConCmds.GetCommandList();
|
||||
if (!iter->started || iter->iter == cmds.end())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid CommandIterator position");
|
||||
}
|
||||
|
||||
ConCmdInfo *pInfo = (*(iter->iter));
|
||||
return pInfo->pCmd->m_nFlags;
|
||||
}
|
||||
|
||||
static cell_t sm_CommandIteratorGetDesc(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
GlobCmdIter *iter;
|
||||
@@ -1569,8 +1525,6 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"ReadCommandIterator", ReadCommandIterator},
|
||||
{"FakeClientCommandEx", FakeClientCommandEx},
|
||||
{"IsChatTrigger", IsChatTrigger},
|
||||
{"GetPublicChatTriggers", GetPublicChatTriggers},
|
||||
{"GetSilentChatTriggers", GetSilentChatTriggers},
|
||||
{"SetCommandFlags", SetCommandFlags},
|
||||
{"GetCommandFlags", GetCommandFlags},
|
||||
{"FindFirstConCommand", FindFirstConCommand},
|
||||
@@ -1609,9 +1563,7 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"CommandIterator.Next", sm_CommandIteratorNext},
|
||||
{"CommandIterator.GetDescription", sm_CommandIteratorGetDesc},
|
||||
{"CommandIterator.GetName", sm_CommandIteratorGetName},
|
||||
{"CommandIterator.Flags.get", sm_CommandIteratorAdminFlags},
|
||||
{"CommandIterator.AdminFlags.get", sm_CommandIteratorAdminFlags},
|
||||
{"CommandIterator.ConVarFlags.get", sm_CommandIteratorConVarFlags},
|
||||
{"CommandIterator.Flags.get", sm_CommandIteratorFlags},
|
||||
{"CommandIterator.Plugin.get", sm_CommandIteratorPlugin},
|
||||
|
||||
{NULL, NULL}
|
||||
|
||||
+34
-110
@@ -134,10 +134,12 @@ inline edict_t *BaseEntityToEdict(CBaseEntity *pEntity)
|
||||
{
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
if (pNet == nullptr)
|
||||
|
||||
if (!pNet)
|
||||
{
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pNet->GetEdict();
|
||||
}
|
||||
|
||||
@@ -283,11 +285,6 @@ static cell_t RemoveEdict(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Edict %d (%d) is not a valid edict", g_HL2.ReferenceToIndex(params[1]), params[1]);
|
||||
}
|
||||
|
||||
if (g_HL2.ReferenceToIndex(params[1]) == 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Cannot remove worldspawn (edict 0)");
|
||||
}
|
||||
|
||||
engine->RemoveEdict(pEdict);
|
||||
|
||||
return 1;
|
||||
@@ -301,11 +298,6 @@ static cell_t RemoveEntity(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Entity %d (%d) is not a valid entity", g_HL2.ReferenceToIndex(params[1]), params[1]);
|
||||
}
|
||||
|
||||
if (g_HL2.ReferenceToIndex(params[1]) == 0)
|
||||
{
|
||||
return pContext->ThrowNativeError("Cannot remove worldspawn (entity 0)");
|
||||
}
|
||||
|
||||
// Some games have UTIL_Remove exposed on IServerTools, but for consistence, we'll
|
||||
// use this method for all. Results in DeathNotice( this ) being called on parent,
|
||||
// and parent being cleared (both if any parent) before UTIL_Remove is called.
|
||||
@@ -361,20 +353,14 @@ static cell_t IsValidEntity(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t IsEntNetworkable(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IServerUnknown *pUnknown = (IServerUnknown *)g_HL2.ReferenceToEntity(params[1]);
|
||||
if (!pUnknown)
|
||||
edict_t *pEdict = GetEdict(params[1]);
|
||||
|
||||
if (!pEdict)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
IServerNetworkable *pNet = pUnknown->GetNetworkable();
|
||||
if (!pNet)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t* edict = pNet->GetEdict();
|
||||
return (edict && !edict->IsFree()) ? 1 : 0;
|
||||
return (pEdict->GetNetworkable() != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t GetEntityCount(IPluginContext *pContext, const cell_t *params)
|
||||
@@ -440,12 +426,14 @@ static cell_t GetEntityNetClass(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid entity (%d - %d)", g_HL2.ReferenceToIndex(params[1]), params[1]);
|
||||
}
|
||||
|
||||
ServerClass *pClass = g_HL2.FindEntityServerClass(pEntity);
|
||||
if (!pClass)
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
if (!pNet)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ServerClass *pClass = pNet->GetServerClass();
|
||||
|
||||
pContext->StringToLocal(params[2], params[3], pClass->GetName());
|
||||
|
||||
return 1;
|
||||
@@ -718,36 +706,6 @@ static cell_t GetEntDataEnt2(IPluginContext *pContext, const cell_t *params)
|
||||
return g_HL2.EntityToBCompatRef(pHandleEntity);
|
||||
}
|
||||
|
||||
//memory addresses below 0x10000 are automatically considered invalid for dereferencing
|
||||
//this is copied over from smn_core.cpp
|
||||
#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
|
||||
|
||||
static cell_t LoadEntityFromHandleAddress(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
void *addr = reinterpret_cast<void*>(params[1]);
|
||||
#else
|
||||
void *addr = g_SourceMod.FromPseudoAddress(params[1]);
|
||||
#endif
|
||||
|
||||
if (addr == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Address cannot be null");
|
||||
}
|
||||
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
|
||||
}
|
||||
|
||||
CBaseHandle &hndl = *reinterpret_cast<CBaseHandle*>(addr);
|
||||
CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex());
|
||||
|
||||
if (!pHandleEntity || hndl != reinterpret_cast<IHandleEntity *>(pHandleEntity)->GetRefEHandle())
|
||||
return -1;
|
||||
|
||||
return g_HL2.EntityToBCompatRef(pHandleEntity);
|
||||
}
|
||||
|
||||
/* THIS GUY IS DEPRECATED. */
|
||||
static cell_t SetEntDataEnt(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
@@ -833,44 +791,6 @@ static cell_t SetEntDataEnt2(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t StoreEntityToHandleAddress(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
void *addr = reinterpret_cast<void*>(params[1]);
|
||||
#else
|
||||
void *addr = g_SourceMod.FromPseudoAddress(params[1]);
|
||||
#endif
|
||||
|
||||
if (addr == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Address cannot be null");
|
||||
}
|
||||
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
|
||||
}
|
||||
|
||||
CBaseHandle &hndl = *reinterpret_cast<CBaseHandle*>(addr);
|
||||
|
||||
if ((unsigned)params[2] == INVALID_EHANDLE_INDEX)
|
||||
{
|
||||
hndl.Set(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
CBaseEntity *pOther = GetEntity(params[2]);
|
||||
|
||||
if (!pOther)
|
||||
{
|
||||
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[2]), params[2]);
|
||||
}
|
||||
|
||||
IHandleEntity *pHandleEnt = (IHandleEntity *)pOther;
|
||||
hndl.Set(pHandleEnt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t ChangeEdictState(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
edict_t *pEdict = GetEdict(params[1]);
|
||||
@@ -1272,11 +1192,13 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
|
||||
#define FIND_PROP_SEND(type, type_name) \
|
||||
sm_sendprop_info_t info;\
|
||||
SendProp *pProp; \
|
||||
ServerClass *pServerClass = g_HL2.FindEntityServerClass(pEntity); \
|
||||
if (pServerClass == nullptr) { \
|
||||
pContext->ThrowNativeError("Failed to retrieve entity %d (%d) server class!", g_HL2.ReferenceToIndex(params[1]), params[1]); \
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pEntity; \
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable(); \
|
||||
if (!pNet) \
|
||||
{ \
|
||||
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]); \
|
||||
} \
|
||||
if (!g_HL2.FindSendPropInfo(pServerClass->GetName(), prop, &info)) \
|
||||
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info)) \
|
||||
{ \
|
||||
const char *class_name = g_HL2.GetEntityClassname(pEntity); \
|
||||
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)", \
|
||||
@@ -1434,13 +1356,13 @@ static cell_t GetEntPropArraySize(IPluginContext *pContext, const cell_t *params
|
||||
{
|
||||
sm_sendprop_info_t info;
|
||||
|
||||
ServerClass *pServerClass = g_HL2.FindEntityServerClass(pEntity);
|
||||
if (pServerClass == nullptr)
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
if (!pNet)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to retrieve entity %d (%d) server class!", g_HL2.ReferenceToIndex(params[1]), params[1]);
|
||||
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]);
|
||||
}
|
||||
|
||||
if (!g_HL2.FindSendPropInfo(pServerClass->GetName(), prop, &info))
|
||||
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
|
||||
{
|
||||
const char *class_name = g_HL2.GetEntityClassname(pEntity);
|
||||
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
|
||||
@@ -1536,8 +1458,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
|
||||
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_PVKII \
|
||||
|| SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (pProp->GetFlags() & SPROP_VARINT)
|
||||
{
|
||||
bit_count = sizeof(int) * 8;
|
||||
@@ -1656,8 +1577,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params)
|
||||
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_PVKII \
|
||||
|| SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (pProp->GetFlags() & SPROP_VARINT)
|
||||
{
|
||||
bit_count = sizeof(int) * 8;
|
||||
@@ -2079,7 +1999,13 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
|
||||
edict_t *pOtherEdict = NULL;
|
||||
if (pOther)
|
||||
{
|
||||
pOtherEdict = BaseEntityToEdict(pOther);
|
||||
IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable();
|
||||
if (!pNetworkable)
|
||||
{
|
||||
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]);
|
||||
}
|
||||
|
||||
pOtherEdict = pNetworkable->GetEdict();
|
||||
if (!pOtherEdict || pOtherEdict->IsFree())
|
||||
{
|
||||
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]);
|
||||
@@ -2582,7 +2508,7 @@ static int32_t SDKEntFlagToSMEntFlag(int flag)
|
||||
case FL_FREEZING:
|
||||
return ENTFLAG_FREEZING;
|
||||
#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2
|
||||
case FL_EP2V_UNKNOWN:
|
||||
return ENTFLAG_EP2V_UNKNOWN1;
|
||||
#endif
|
||||
@@ -2661,7 +2587,7 @@ static int32_t SMEntFlagToSDKEntFlag(int32_t flag)
|
||||
case ENTFLAG_FREEZING:
|
||||
return FL_FREEZING;
|
||||
#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2
|
||||
case ENTFLAG_EP2V_UNKNOWN1:
|
||||
return FL_EP2V_UNKNOWN;
|
||||
#endif
|
||||
@@ -2824,7 +2750,5 @@ REGISTER_NATIVES(entityNatives)
|
||||
{"SetEntPropVector", SetEntPropVector},
|
||||
{"GetEntityAddress", GetEntityAddress},
|
||||
{"FindDataMapInfo", FindDataMapInfo},
|
||||
{"LoadEntityFromHandleAddress", LoadEntityFromHandleAddress},
|
||||
{"StoreEntityToHandleAddress", StoreEntityToHandleAddress},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -505,7 +505,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
|
||||
case SOURCE_ENGINE_TF2:
|
||||
case SOURCE_ENGINE_BMS:
|
||||
case SOURCE_ENGINE_SDK2013:
|
||||
case SOURCE_ENGINE_PVKII:
|
||||
return 35;
|
||||
case SOURCE_ENGINE_LEFT4DEAD:
|
||||
return 40;
|
||||
@@ -519,7 +518,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
|
||||
return 70;
|
||||
case SOURCE_ENGINE_CSGO:
|
||||
return 80;
|
||||
// Deprecated, and not very useful. Don't bother adding new games
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+3
-18
@@ -41,8 +41,6 @@
|
||||
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_BLADE
|
||||
#include <game/shared/berimbau/protobuf/berimbau_usermessages.pb.h>
|
||||
#elif SOURCE_ENGINE == SE_MCV
|
||||
#include <game/shared/vietnam/protobuf/vietnam_usermessages.pb.h>
|
||||
#endif
|
||||
|
||||
#define MAX_HUD_CHANNELS 6
|
||||
@@ -72,7 +70,6 @@ struct hud_text_parms
|
||||
float holdTime;
|
||||
float fxTime;
|
||||
int channel;
|
||||
bool isSet = false;
|
||||
};
|
||||
|
||||
class HudMsgHelpers :
|
||||
@@ -285,7 +282,6 @@ static cell_t SetHudTextParams(IPluginContext *pContext, const cell_t *params)
|
||||
g_hud_params.g2 = 255;
|
||||
g_hud_params.b2 = 250;
|
||||
g_hud_params.a2 = 0;
|
||||
g_hud_params.isSet = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -312,7 +308,6 @@ static cell_t SetHudTextParamsEx(IPluginContext *pContext, const cell_t *params)
|
||||
g_hud_params.g2 = static_cast<byte>(color2[1]);
|
||||
g_hud_params.b2 = static_cast<byte>(color2[2]);
|
||||
g_hud_params.a2 = static_cast<byte>(color2[3]);
|
||||
g_hud_params.isSet = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -323,7 +318,7 @@ void UTIL_SendHudText(int client, const hud_text_parms &textparms, const char *p
|
||||
|
||||
players[0] = client;
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CCSUsrMsg_HudMsg *msg = (CCSUsrMsg_HudMsg *)g_UserMsgs.StartProtobufMessage(g_HudMsgNum, players, 1, 0);
|
||||
if (!msg)
|
||||
{
|
||||
@@ -382,7 +377,7 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params)
|
||||
Handle_t err;
|
||||
CPlayer *pPlayer;
|
||||
hud_syncobj_t *obj;
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
char message_buffer[512];
|
||||
#else
|
||||
char message_buffer[255-36];
|
||||
@@ -393,11 +388,6 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!g_hud_params.isSet)
|
||||
{
|
||||
return pContext->ThrowNativeError("ShowSyncHudText first requires a call to SetHudTextParams or SetHudTextParamsEx");
|
||||
}
|
||||
|
||||
if ((err = s_HudMsgHelpers.ReadHudSyncObj(params[2], pContext->GetIdentity(), &obj)) != HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[2], err);
|
||||
@@ -471,7 +461,7 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client;
|
||||
CPlayer *pPlayer;
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
char message_buffer[512];
|
||||
#else
|
||||
char message_buffer[255-36];
|
||||
@@ -482,11 +472,6 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!g_hud_params.isSet)
|
||||
{
|
||||
return pContext->ThrowNativeError("ShowHudText first requires a call to SetHudTextParams or SetHudTextParamsEx");
|
||||
}
|
||||
|
||||
client = params[1];
|
||||
if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL)
|
||||
{
|
||||
|
||||
+2
-14
@@ -669,21 +669,9 @@ static cell_t smn_KvRewind(IPluginContext *pCtx, const cell_t *params)
|
||||
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
|
||||
}
|
||||
|
||||
// Older plugins do not have the clearHistory param
|
||||
if (params[0] < 2 || params[2])
|
||||
while (pStk->pCurRoot.size() > 1)
|
||||
{
|
||||
while (pStk->pCurRoot.size() > 1)
|
||||
{
|
||||
pStk->pCurRoot.pop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto root = pStk->pCurRoot.begin();
|
||||
if (root != pStk->pCurRoot.end())
|
||||
{
|
||||
pStk->pCurRoot.push(*root);
|
||||
}
|
||||
pStk->pCurRoot.pop();
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -70,7 +70,7 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
|
||||
PLUGIN_SAVEVARS();
|
||||
|
||||
GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
#if SOURCE_ENGINE == SE_SDK2013
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_SDK2013
|
||||
// Shim to avoid hooking shims
|
||||
engine = (IVEngineServer *)ismm->GetEngineFactory()("VEngineServer023", nullptr);
|
||||
if (!engine)
|
||||
|
||||
+57
-55
File diff suppressed because one or more lines are too long
@@ -725,7 +725,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u
|
||||
ObjectClass classes[MAX_CLASSES];
|
||||
int numWords = ClassifyObject(smInfo, classes);
|
||||
|
||||
if (classes[0] == ObjectClass::Pointer || classes[0] == ObjectClass::Memory)
|
||||
if (classes[0] == ObjectClass::Pointer)
|
||||
goto push_byref;
|
||||
|
||||
int neededIntRegs = 0;
|
||||
@@ -787,7 +787,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u
|
||||
return;
|
||||
|
||||
#elif defined PLATFORM_WINDOWS
|
||||
if (info->size > 8 || (info->size & (info->size - 1)) != 0)
|
||||
if (info->size < 64 && (info->size & (info->size - 1)) == 0)
|
||||
goto push_byref;
|
||||
else {
|
||||
SourceHook::PassInfo podInfo;
|
||||
@@ -1055,11 +1055,7 @@ void *JIT_CallCompile(CallWrapper *pWrapper, FuncAddrMethod method)
|
||||
int numWords;
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
g_StackUsage = 0;
|
||||
#elif defined PLATFORM_WINDOWS
|
||||
g_StackUsage = 32; // Shadow space
|
||||
#endif
|
||||
|
||||
writer.outbase = NULL;
|
||||
writer.outptr = NULL;
|
||||
@@ -1159,12 +1155,8 @@ skip_retbuffer:
|
||||
#endif
|
||||
|
||||
/* Clean up the calling stack */
|
||||
#ifdef PLATFORM_POSIX
|
||||
if (hasParams && g_StackUsage)
|
||||
#endif
|
||||
{
|
||||
Write_RectifyStack(jit, g_StackAlign);
|
||||
}
|
||||
|
||||
/* Copy the return type to the return buffer if the function is not void */
|
||||
if (pRet && !Needs_Retbuf)
|
||||
|
||||
@@ -398,7 +398,7 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
|
||||
/* User passed a function id for a callback */
|
||||
if (!pContext->IsNullFunctionId(params[4]))
|
||||
if (params[4] != -1)
|
||||
{
|
||||
pItem->forward = forwards->CreateForwardEx(NULL, ET_Ignore, 5, NULL, Param_Cell, Param_Cell, Param_Cell, Param_String, Param_Cell);
|
||||
pItem->forward->AddFunction(pContext, static_cast<funcid_t>(params[4]));
|
||||
|
||||
@@ -9,7 +9,15 @@ project.sources += [
|
||||
'timeleft.cpp',
|
||||
'forwards.cpp',
|
||||
'util_cstrike.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c',
|
||||
'../../public/libudis86/decode.c',
|
||||
'../../public/libudis86/itab.c',
|
||||
'../../public/libudis86/syn-att.c',
|
||||
'../../public/libudis86/syn-intel.c',
|
||||
'../../public/libudis86/syn.c',
|
||||
'../../public/libudis86/udis86.c',
|
||||
]
|
||||
|
||||
for sdk_name in ['css', 'csgo']:
|
||||
@@ -21,33 +29,31 @@ for sdk_name in ['css', 'csgo']:
|
||||
project.sources += ['rulesfix.cpp']
|
||||
|
||||
for cxx in builder.targets:
|
||||
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
|
||||
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
|
||||
continue
|
||||
|
||||
cxx.defines += ['HAVE_STRING_H']
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk['extension'], sdk)
|
||||
SM.AddCDetour(binary)
|
||||
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk.ext, sdk)
|
||||
if sdk_name == 'csgo':
|
||||
compiler = binary.compiler
|
||||
compiler.cxxincludes += [os.path.join(sdk['path'], 'public', 'steam')]
|
||||
compiler.cxxincludes += [os.path.join(sdk.path, 'public', 'steam')]
|
||||
compiler.defines += ['VERSION_SAFE_STEAM_API_INTERFACES']
|
||||
|
||||
library_name = ''
|
||||
if cxx.target.platform == 'windows':
|
||||
compiler.linkflags += [os.path.join(sdk['path'], 'lib', 'public', 'steam_api.lib')]
|
||||
compiler.linkflags += [os.path.join(sdk.path, 'lib', 'public', 'steam_api.lib')]
|
||||
elif cxx.target.platform == 'linux':
|
||||
library_name = 'libsteam_api.so'
|
||||
if cxx.target.arch == 'x86_64':
|
||||
source_path = os.path.join(sdk['path'], 'lib', 'linux64')
|
||||
source_path = os.path.join(sdk.path, 'lib', 'linux64')
|
||||
else:
|
||||
source_path = os.path.join(sdk['path'], 'lib', 'linux')
|
||||
source_path = os.path.join(sdk.path, 'lib', 'linux')
|
||||
elif cxx.target.platform == 'mac':
|
||||
library_name = 'libsteam_api.dylib'
|
||||
if cxx.target.arch == 'x86_64':
|
||||
source_path = os.path.join(sdk['path'], 'lib', 'osx64')
|
||||
source_path = os.path.join(sdk.path, 'lib', 'osx64')
|
||||
else:
|
||||
source_path = os.path.join(sdk['path'], 'lib', 'mac')
|
||||
source_path = os.path.join(sdk.path, 'lib', 'mac')
|
||||
|
||||
if library_name:
|
||||
source_path = os.path.join(source_path, library_name)
|
||||
|
||||
@@ -254,13 +254,10 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
//Psychonic is awesome for this
|
||||
sm_sendprop_info_t spi;
|
||||
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pWeapon);
|
||||
if (pServerClass == nullptr)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to retrieve entity %d server class!", params[2]);
|
||||
}
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
|
||||
if (!UTIL_FindDataTable(pServerClass->m_pTable, "DT_WeaponCSBase", &spi, 0))
|
||||
if (!UTIL_FindDataTable(pNet->GetServerClass()->m_pTable, "DT_WeaponCSBase", &spi, 0))
|
||||
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
|
||||
|
||||
if (!gamehelpers->FindSendPropInfo("CBaseCombatWeapon", "m_hOwnerEntity", &spi))
|
||||
@@ -957,21 +954,6 @@ static cell_t CS_WeaponIDToItemDefIndex(IPluginContext *pContext, const cell_t *
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell_t CS_WeaponIDToLoadoutSlot(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)params[1]);
|
||||
|
||||
if (!res.found())
|
||||
return pContext->ThrowNativeError("Invalid weapon id passed.");
|
||||
|
||||
return res->value.m_iLoadoutSlot;
|
||||
#else
|
||||
return pContext->ThrowNativeError("CS_WeaponIDToLoadoutSlot is not supported on this game");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
sp_nativeinfo_t g_CSNatives[] =
|
||||
{
|
||||
{"CS_RespawnPlayer", CS_RespawnPlayer},
|
||||
@@ -996,7 +978,6 @@ sp_nativeinfo_t g_CSNatives[] =
|
||||
{"CS_IsValidWeaponID", CS_IsValidWeaponID},
|
||||
{"CS_ItemDefIndexToID", CS_ItemDefIndexToID},
|
||||
{"CS_WeaponIDToItemDefIndex", CS_WeaponIDToItemDefIndex},
|
||||
{"CS_WeaponIDToLoadoutSlot", CS_WeaponIDToLoadoutSlot},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
// Grab the convar ref
|
||||
ConVar *host_rules_show = nullptr;
|
||||
bool bPatched = false;
|
||||
int iPatchSize = -1;
|
||||
|
||||
RulesFix rulesfix;
|
||||
|
||||
@@ -54,7 +53,7 @@ bool SetMTUMax(int iValue)
|
||||
|
||||
//If we never changed skip resetting
|
||||
if (iOriginalValue == -1 && iValue == -1)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if (m_pMaxMTU == nullptr)
|
||||
{
|
||||
@@ -78,16 +77,10 @@ bool SetMTUMax(int iValue)
|
||||
|
||||
void RulesFix::OnLoad()
|
||||
{
|
||||
const char *patchSize = g_pGameConf->GetKeyValue("MTUPatchSize");
|
||||
if (patchSize != NULL)
|
||||
{
|
||||
iPatchSize = atoi(patchSize);
|
||||
}
|
||||
|
||||
host_rules_show = g_pCVar->FindVar("host_rules_show");
|
||||
if (host_rules_show)
|
||||
{
|
||||
if (SetMTUMax(iPatchSize))
|
||||
if (SetMTUMax(5000))
|
||||
{
|
||||
// Default to enabled. Explicit disable via cfg will still be obeyed.
|
||||
host_rules_show->SetValue(true);
|
||||
@@ -131,7 +124,7 @@ static void OnConVarChanged(IConVar *var, const char *pOldValue, float flOldValu
|
||||
{
|
||||
if (!bPatched)
|
||||
{
|
||||
if (SetMTUMax(iPatchSize))
|
||||
if (SetMTUMax(5000))
|
||||
{
|
||||
bPatched = true;
|
||||
NotifyAllCVars();
|
||||
|
||||
@@ -19,7 +19,6 @@ for cxx in builder.targets:
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core'),
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
os.path.join(builder.sourcePath, 'extensions', 'dhooks'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
|
||||
@@ -28,10 +27,6 @@ for cxx in builder.targets:
|
||||
os.path.join(builder.sourcePath, 'extensions', 'dhooks', 'DynamicHooks'),
|
||||
]
|
||||
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.sourcePath, 'extensions', 'dhooks')
|
||||
]
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'listeners.cpp',
|
||||
@@ -41,13 +36,13 @@ for cxx in builder.targets:
|
||||
'util.cpp',
|
||||
'dynhooks_sourcepawn.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'asm/asm.c',
|
||||
'libudis86/decode.c',
|
||||
'libudis86/itab.c',
|
||||
'libudis86/syn-att.c',
|
||||
'libudis86/syn-intel.c',
|
||||
'libudis86/syn.c',
|
||||
'libudis86/udis86.c',
|
||||
'../../public/asm/asm.c',
|
||||
'../../public/libudis86/decode.c',
|
||||
'../../public/libudis86/itab.c',
|
||||
'../../public/libudis86/syn-att.c',
|
||||
'../../public/libudis86/syn-intel.c',
|
||||
'../../public/libudis86/syn.c',
|
||||
'../../public/libudis86/udis86.c',
|
||||
'../../sourcepawn/vm/x86/assembler-x86.cpp',
|
||||
]
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
|
||||
{
|
||||
ReturnAction_t lastPreReturnAction = m_LastPreReturnAction.back();
|
||||
m_LastPreReturnAction.pop_back();
|
||||
if (lastPreReturnAction >= ReturnAction_Override)
|
||||
if (lastPreReturnAction == ReturnAction_Override)
|
||||
m_pCallingConvention->RestoreReturnValue(m_pRegisters);
|
||||
if (lastPreReturnAction < ReturnAction_Supercede)
|
||||
m_pCallingConvention->RestoreCallArguments(m_pRegisters);
|
||||
@@ -191,7 +191,7 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
|
||||
if (eHookType == HOOKTYPE_PRE)
|
||||
{
|
||||
m_LastPreReturnAction.push_back(returnAction);
|
||||
if (returnAction >= ReturnAction_Override)
|
||||
if (returnAction == ReturnAction_Override)
|
||||
m_pCallingConvention->SaveReturnValue(m_pRegisters);
|
||||
if (returnAction < ReturnAction_Supercede)
|
||||
m_pCallingConvention->SaveCallArguments(m_pRegisters);
|
||||
|
||||
@@ -119,10 +119,7 @@ void DHooks::SDK_OnAllLoaded()
|
||||
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
|
||||
SM_GET_LATE_IFACE(SDKHOOKS, g_pSDKHooks);
|
||||
|
||||
if (g_pSDKHooks)
|
||||
{
|
||||
g_pSDKHooks->AddEntityListener(g_pEntityListener);
|
||||
}
|
||||
g_pSDKHooks->AddEntityListener(g_pEntityListener);
|
||||
gameconfs->AddUserConfigHook("Functions", g_pSignatures);
|
||||
}
|
||||
|
||||
@@ -134,10 +131,7 @@ void DHooks::SDK_OnUnload()
|
||||
{
|
||||
g_pEntityListener->CleanupListeners();
|
||||
g_pEntityListener->CleanupRemoveList();
|
||||
if (g_pSDKHooks)
|
||||
{
|
||||
g_pSDKHooks->RemoveEntityListener(g_pEntityListener);
|
||||
}
|
||||
g_pSDKHooks->RemoveEntityListener(g_pEntityListener);
|
||||
delete g_pEntityListener;
|
||||
}
|
||||
plsys->RemovePluginsListener(this);
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
const DatabaseInfo &GetInfo();
|
||||
private:
|
||||
MYSQL *m_mysql;
|
||||
std::recursive_mutex m_FullLock;
|
||||
std::mutex m_FullLock;
|
||||
|
||||
/* ---------- */
|
||||
DatabaseInfo m_Info;
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
void SetLastIDAndRows(unsigned int insertID, unsigned int affectedRows);
|
||||
private:
|
||||
PGconn *m_pgsql;
|
||||
std::recursive_mutex m_FullLock;
|
||||
std::mutex m_FullLock;
|
||||
|
||||
unsigned int m_lastInsertID;
|
||||
unsigned int m_lastAffectedRows;
|
||||
|
||||
@@ -56,7 +56,7 @@ void RegEx::Clear ()
|
||||
re = nullptr;
|
||||
mFree = true;
|
||||
if (subject)
|
||||
free(subject);
|
||||
delete [] subject;
|
||||
subject = nullptr;
|
||||
mMatchCount = 0;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ void RegEx::ClearMatch()
|
||||
mErrorCode = 0;
|
||||
mError = nullptr;
|
||||
if (subject)
|
||||
free(subject);
|
||||
delete [] subject;
|
||||
subject = nullptr;
|
||||
mMatchCount = 0;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,17 @@ project.sources += [
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
if sdk.name == 'mock':
|
||||
continue
|
||||
|
||||
for cxx in builder.targets:
|
||||
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
|
||||
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
|
||||
continue
|
||||
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdkhooks.ext.' + sdk['extension'], sdk)
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdkhooks.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared')
|
||||
]
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
|
||||
|
||||
@@ -152,7 +152,6 @@ CUtlVector<IEntityListener *> *EntListeners()
|
||||
/**
|
||||
* IServerGameDLL & IVEngineServer Hooks
|
||||
*/
|
||||
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
|
||||
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, const char *, const char *, const char *, const char *, bool, bool);
|
||||
#ifdef GAMEDESC_CAN_CHANGE
|
||||
SH_DECL_HOOK0(IServerGameDLL, GetGameDescription, SH_NOATTRIB, 0, const char *);
|
||||
@@ -179,7 +178,7 @@ SH_DECL_MANUALHOOK1_void(StartTouch, 0, 0, 0, CBaseEntity *);
|
||||
SH_DECL_MANUALHOOK0_void(Think, 0, 0, 0);
|
||||
SH_DECL_MANUALHOOK1_void(Touch, 0, 0, 0, CBaseEntity *);
|
||||
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
|
||||
SH_DECL_MANUALHOOK4_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *, CDmgAccumulator *);
|
||||
#else
|
||||
SH_DECL_MANUALHOOK3_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *);
|
||||
@@ -232,15 +231,10 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
if (!entListeners)
|
||||
{
|
||||
g_pSM->Format(error, maxlength, "Failed to setup entity listeners");
|
||||
#if SOURCE_ENGINE != SE_MOCK
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
entListeners->AddToTail(this);
|
||||
}
|
||||
|
||||
entListeners->AddToTail(this);
|
||||
|
||||
sharesys->AddDependency(myself, "bintools.ext", true, true);
|
||||
sharesys->AddNatives(myself, g_Natives);
|
||||
@@ -248,8 +242,7 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
sharesys->AddInterface(myself, &g_Interface);
|
||||
sharesys->AddCapabilityProvider(myself, this, "SDKHook_DmgCustomInOTD");
|
||||
sharesys->AddCapabilityProvider(myself, this, "SDKHook_LogicalEntSupport");
|
||||
|
||||
SH_ADD_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SDKHooks::LevelShutdown), false);
|
||||
sharesys->AddCapabilityProvider(myself, this, "SDKHook_OnEntitySpawned");
|
||||
|
||||
playerhelpers->AddClientListener(&g_Interface);
|
||||
|
||||
@@ -371,19 +364,15 @@ void SDKHooks::SDK_OnUnload()
|
||||
forwards->ReleaseForward(g_pOnLevelInit);
|
||||
|
||||
plsys->RemovePluginsListener(&g_Interface);
|
||||
|
||||
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SDKHooks::LevelShutdown), true);
|
||||
|
||||
|
||||
playerhelpers->RemoveClientListener(&g_Interface);
|
||||
|
||||
sharesys->DropCapabilityProvider(myself, this, "SDKHook_DmgCustomInOTD");
|
||||
sharesys->DropCapabilityProvider(myself, this, "SDKHook_LogicalEntSupport");
|
||||
sharesys->DropCapabilityProvider(myself, this, "SDKHook_OnEntitySpawned");
|
||||
|
||||
CUtlVector<IEntityListener *> *entListeners = EntListeners();
|
||||
if (entListeners)
|
||||
{
|
||||
entListeners->FindAndRemove(this);
|
||||
}
|
||||
entListeners->FindAndRemove(this);
|
||||
|
||||
gameconfs->CloseGameConfigFile(g_pGameConf);
|
||||
}
|
||||
@@ -454,24 +443,6 @@ void SDKHooks::OnClientDisconnecting(int client)
|
||||
HandleEntityDeleted(pEntity);
|
||||
}
|
||||
|
||||
void SDKHooks::LevelShutdown()
|
||||
{
|
||||
#if defined PLATFORM_LINUX
|
||||
for (size_t type = 0; type < SDKHook_MAXHOOKS; ++type)
|
||||
{
|
||||
std::vector<CVTableList *> &vtablehooklist = g_HookList[type];
|
||||
for (size_t listentry = 0; listentry < vtablehooklist.size(); ++listentry)
|
||||
{
|
||||
std::vector<HookList> &pawnhooks = vtablehooklist[listentry]->hooks;
|
||||
pawnhooks.clear();
|
||||
|
||||
delete vtablehooklist[listentry];
|
||||
}
|
||||
vtablehooklist.clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDKHooks::AddEntityListener(ISMEntityListener *listener)
|
||||
{
|
||||
m_EntListeners.push_back(listener);
|
||||
@@ -618,16 +589,11 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac
|
||||
|
||||
if (!!strcmp(g_HookTypes[type].dtReq, ""))
|
||||
{
|
||||
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pEnt);
|
||||
if (pServerClass == nullptr)
|
||||
{
|
||||
return HookRet_BadEntForHookType;
|
||||
}
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pEnt;
|
||||
|
||||
if (!UTIL_ContainsDataTable(pServerClass->m_pTable, g_HookTypes[type].dtReq))
|
||||
{
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
if (pNet && !UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, g_HookTypes[type].dtReq))
|
||||
return HookRet_BadEntForHookType;
|
||||
}
|
||||
}
|
||||
|
||||
size_t entry;
|
||||
@@ -823,14 +789,12 @@ void SDKHooks::Unhook(CBaseEntity *pEntity)
|
||||
entry--;
|
||||
}
|
||||
|
||||
#if !defined PLATFORM_LINUX
|
||||
if (pawnhooks.size() == 0)
|
||||
{
|
||||
delete vtablehooklist[listentry];
|
||||
vtablehooklist.erase(vtablehooklist.begin() + listentry);
|
||||
listentry--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -854,14 +818,12 @@ void SDKHooks::Unhook(IPluginContext *pContext)
|
||||
entry--;
|
||||
}
|
||||
|
||||
#if !defined PLATFORM_LINUX
|
||||
if (pawnhooks.size() == 0)
|
||||
{
|
||||
delete vtablehooklist[listentry];
|
||||
vtablehooklist.erase(vtablehooklist.begin() + listentry);
|
||||
listentry--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,14 +860,12 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback)
|
||||
entry--;
|
||||
}
|
||||
|
||||
#if !defined PLATFORM_LINUX
|
||||
if (pawnhooks.size() == 0)
|
||||
{
|
||||
delete vtablehooklist[listentry];
|
||||
vtablehooklist.erase(vtablehooklist.begin() + listentry);
|
||||
listentry--;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1113,7 +1073,7 @@ int SDKHooks::Hook_GetMaxHealth()
|
||||
|
||||
int new_max = original_max;
|
||||
|
||||
cell_t ret = Pl_Continue;
|
||||
cell_t res = Pl_Continue;
|
||||
|
||||
std::vector<IPluginFunction *> callbackList;
|
||||
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||
@@ -1122,20 +1082,10 @@ int SDKHooks::Hook_GetMaxHealth()
|
||||
IPluginFunction *callback = callbackList[entry];
|
||||
callback->PushCell(entity);
|
||||
callback->PushCellByRef(&new_max);
|
||||
|
||||
cell_t res;
|
||||
callback->Execute(&res);
|
||||
|
||||
if (res > ret)
|
||||
{
|
||||
ret = res;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret >= Pl_Handled)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, original_max);
|
||||
|
||||
if (ret >= Pl_Changed)
|
||||
if (res >= Pl_Changed)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, new_max);
|
||||
|
||||
break;
|
||||
@@ -1460,7 +1410,7 @@ void SDKHooks::Hook_Spawn()
|
||||
}
|
||||
|
||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
cell_t ret = Pl_Continue;
|
||||
cell_t res = Pl_Continue;
|
||||
|
||||
std::vector<IPluginFunction *> callbackList;
|
||||
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||
@@ -1468,17 +1418,10 @@ void SDKHooks::Hook_Spawn()
|
||||
{
|
||||
IPluginFunction *callback = callbackList[entry];
|
||||
callback->PushCell(entity);
|
||||
|
||||
cell_t res;
|
||||
callback->Execute(&res);
|
||||
|
||||
if (res > ret)
|
||||
{
|
||||
ret = res;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret >= Pl_Handled)
|
||||
if (res >= Pl_Handled)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
|
||||
break;
|
||||
@@ -1539,7 +1482,7 @@ void SDKHooks::Hook_TouchPost(CBaseEntity *pOther)
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
|
||||
void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator)
|
||||
#else
|
||||
void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr)
|
||||
@@ -1620,7 +1563,7 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir,
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
|
||||
void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator)
|
||||
#else
|
||||
void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr)
|
||||
@@ -1689,14 +1632,7 @@ void SDKHooks::Hook_Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
|
||||
callback->PushCell(caller);
|
||||
callback->PushCell(useType);
|
||||
callback->PushFloat(value);
|
||||
|
||||
cell_t res;
|
||||
callback->Execute(&res);
|
||||
|
||||
if (res > ret)
|
||||
{
|
||||
ret = res;
|
||||
}
|
||||
callback->Execute(&ret);
|
||||
}
|
||||
|
||||
if (ret >= Pl_Handled)
|
||||
@@ -1867,44 +1803,42 @@ bool SDKHooks::Hook_WeaponSwitchPost(CBaseCombatWeapon *pWeapon, int viewmodelin
|
||||
void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref)
|
||||
{
|
||||
const char *pName = gamehelpers->GetEntityClassname(pEntity);
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
|
||||
if (!pName)
|
||||
pName = "";
|
||||
|
||||
// Send OnEntityCreated to SM listeners
|
||||
SourceHook::List<ISMEntityListener *>::iterator iter;
|
||||
ISMEntityListener *pListener = NULL;
|
||||
for (iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
|
||||
{
|
||||
pListener = (*iter);
|
||||
pListener->OnEntityCreated(pEntity, pName ? pName : "");
|
||||
pListener->OnEntityCreated(pEntity, pName);
|
||||
}
|
||||
|
||||
// Call OnEntityCreated forward
|
||||
g_pOnEntityCreated->PushCell(bcompatRef);
|
||||
g_pOnEntityCreated->PushString(pName ? pName : "");
|
||||
g_pOnEntityCreated->Execute(NULL);
|
||||
if (g_pOnEntityCreated->GetFunctionCount())
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
g_pOnEntityCreated->PushCell(bcompatRef);
|
||||
g_pOnEntityCreated->PushString(pName);
|
||||
g_pOnEntityCreated->Execute(NULL);
|
||||
}
|
||||
|
||||
m_EntityCache[index] = ref;
|
||||
}
|
||||
|
||||
void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
|
||||
{
|
||||
if (g_pOnEntitySpawned->GetFunctionCount() || m_EntListeners.size())
|
||||
if (g_pOnEntitySpawned->GetFunctionCount())
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
const char *pName = gamehelpers->GetEntityClassname(pEntity);
|
||||
if (!pName)
|
||||
pName = "";
|
||||
|
||||
// Send OnEntitySpawned to SM listeners
|
||||
for (SourceHook::List<ISMEntityListener *>::iterator iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
|
||||
{
|
||||
ISMEntityListener *pListener = (*iter);
|
||||
pListener->OnEntitySpawned(pEntity, pName);
|
||||
}
|
||||
|
||||
// Call OnEntitySpawned forward
|
||||
if (g_pOnEntitySpawned->GetFunctionCount())
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
g_pOnEntitySpawned->PushCell(bcompatRef);
|
||||
g_pOnEntitySpawned->PushString(pName);
|
||||
g_pOnEntitySpawned->Execute(NULL);
|
||||
@@ -1914,8 +1848,6 @@ void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
|
||||
|
||||
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
|
||||
// Send OnEntityDestroyed to SM listeners
|
||||
SourceHook::List<ISMEntityListener *>::iterator iter;
|
||||
ISMEntityListener *pListener = NULL;
|
||||
@@ -1926,8 +1858,12 @@ void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
|
||||
}
|
||||
|
||||
// Call OnEntityDestroyed forward
|
||||
g_pOnEntityDestroyed->PushCell(bcompatRef);
|
||||
g_pOnEntityDestroyed->Execute(NULL);
|
||||
if (g_pOnEntityDestroyed->GetFunctionCount())
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
g_pOnEntityDestroyed->PushCell(bcompatRef);
|
||||
g_pOnEntityDestroyed->Execute(NULL);
|
||||
}
|
||||
|
||||
Unhook(pEntity);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#if SOURCE_ENGINE >= SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD
|
||||
#define GETMAXHEALTH_IS_VIRTUAL
|
||||
#endif
|
||||
#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && \
|
||||
SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN && \
|
||||
SOURCE_ENGINE != SE_BLADE && SOURCE_ENGINE != SE_MCV
|
||||
#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN && SOURCE_ENGINE != SE_BLADE
|
||||
#define GAMEDESC_CAN_CHANGE
|
||||
#endif
|
||||
|
||||
@@ -139,15 +137,11 @@ class IEntityListener
|
||||
{
|
||||
public:
|
||||
#if SOURCE_ENGINE == SE_BMS
|
||||
virtual ~IEntityListener() {};
|
||||
virtual void OnEntityPreSpawned( CBaseEntity *pEntity ) {};
|
||||
#endif
|
||||
virtual void OnEntityCreated( CBaseEntity *pEntity ) {};
|
||||
virtual void OnEntitySpawned( CBaseEntity *pEntity ) {};
|
||||
virtual void OnEntityDeleted( CBaseEntity *pEntity ) {};
|
||||
#if SOURCE_ENGINE == SE_BMS
|
||||
virtual void OnEntityFlagsChanged( CBaseEntity *pEntity, int nAddedFlags, int nRemovedFlags ) {};
|
||||
#endif
|
||||
};
|
||||
|
||||
class SDKHooks :
|
||||
@@ -260,8 +254,6 @@ public: // ISDKHooks
|
||||
virtual void AddEntityListener(ISMEntityListener *listener);
|
||||
virtual void RemoveEntityListener(ISMEntityListener *listener);
|
||||
|
||||
public: // IServerGameDLL
|
||||
void LevelShutdown();
|
||||
private:
|
||||
SourceHook::List<ISMEntityListener *> m_EntListeners;
|
||||
|
||||
@@ -317,7 +309,7 @@ public:
|
||||
void Hook_Touch(CBaseEntity *pOther);
|
||||
void Hook_TouchPost(CBaseEntity *pOther);
|
||||
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
|
||||
void Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator);
|
||||
void Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator);
|
||||
#else
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -60,17 +60,17 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params)
|
||||
break;
|
||||
case HookRet_BadEntForHookType:
|
||||
{
|
||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
|
||||
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
|
||||
if (!pClassname)
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
|
||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
|
||||
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
|
||||
if (!pClassname)
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
CBaseEntity *pVictim = gamehelpers->ReferenceToEntity(params[1]);
|
||||
if (!pVictim)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for victim", params[1]);
|
||||
|
||||
|
||||
CBaseEntity *pInflictor = gamehelpers->ReferenceToEntity(params[2]);
|
||||
if (!pInflictor)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for inflictor", params[2]);
|
||||
@@ -181,7 +181,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition, iDamageCustom);
|
||||
|
||||
if (params[0] < 10 || params[9] != 0)
|
||||
if (params[0] < 10 || params[10] != 0)
|
||||
{
|
||||
SH_MCALL(pVictim, OnTakeDamage)((CTakeDamageInfoHack&)info);
|
||||
}
|
||||
@@ -191,10 +191,10 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
if (!pCall)
|
||||
{
|
||||
int offset;
|
||||
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
|
||||
}
|
||||
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
|
||||
}
|
||||
|
||||
PassInfo pass[2];
|
||||
pass[0].type = PassType_Object;
|
||||
@@ -231,18 +231,15 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(gamehelpers->ReferenceToIndex(params[1]));
|
||||
if (!pGamePlayer || !pGamePlayer->IsInGame())
|
||||
return pContext->ThrowNativeError("Client index %d not in game", params[1]);
|
||||
|
||||
|
||||
CBaseEntity *pWeapon = gamehelpers->ReferenceToEntity(params[2]);
|
||||
if (!pWeapon)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
|
||||
|
||||
ServerClass *pClass = gamehelpers->FindEntityServerClass(pWeapon);
|
||||
if (pClass == nullptr)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to retrieve entity %d server class!", params[2]);
|
||||
}
|
||||
|
||||
if (!UTIL_ContainsDataTable(pClass->m_pTable, "DT_BaseCombatWeapon"))
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
|
||||
if (!UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, "DT_BaseCombatWeapon"))
|
||||
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
|
||||
|
||||
sm_sendprop_info_t spi;
|
||||
@@ -253,12 +250,9 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
if (params[1] != hndl.GetEntryIndex())
|
||||
return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
|
||||
|
||||
Vector vecTarget;
|
||||
cell_t *addr;
|
||||
int err;
|
||||
|
||||
Vector vecTarget;
|
||||
Vector *pVecTarget = nullptr;
|
||||
|
||||
if ((err = pContext->LocalToPhysAddr(params[3], &addr)) != SP_ERROR_NONE)
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not read vecTarget vector");
|
||||
@@ -270,12 +264,15 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
sp_ctof(addr[0]),
|
||||
sp_ctof(addr[1]),
|
||||
sp_ctof(addr[2]));
|
||||
pVecTarget = &vecTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon *)pWeapon, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vector vecVelocity;
|
||||
Vector *pVecVelocity = nullptr;
|
||||
|
||||
if ((err = pContext->LocalToPhysAddr(params[4], &addr)) != SP_ERROR_NONE)
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not read vecVelocity vector");
|
||||
@@ -292,7 +289,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
if (params[0] < 5 || params[5] != 0)
|
||||
{
|
||||
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, pVecTarget, pVecVelocity);
|
||||
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, &vecTarget, pVecVelocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -300,9 +297,9 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
if (!pCall)
|
||||
{
|
||||
int offset;
|
||||
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
|
||||
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
|
||||
}
|
||||
|
||||
PassInfo pass[3];
|
||||
@@ -319,7 +316,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
pCall = g_pBinTools->CreateVCall(offset, 0, 0, nullptr, pass, 3);
|
||||
}
|
||||
|
||||
pCall->Execute(ArgBuffer<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, pVecTarget, pVecVelocity), nullptr);
|
||||
pCall->Execute(ArgBuffer<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, &vecTarget, pVecVelocity), nullptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
|
||||
m_iDamagedOtherPlayers = 0;
|
||||
m_iPlayerPenetrationCount = 0;
|
||||
m_flDamageBonus = 0.0f;
|
||||
@@ -89,7 +89,7 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
|
||||
m_flRadius = 0.0f;
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
m_iDamagedOtherPlayers = 0;
|
||||
m_iObjectsPenetrated = 0;
|
||||
m_uiBulletID = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -58,7 +58,7 @@
|
||||
class CTakeDamageInfoHack : public CTakeDamageInfo
|
||||
{
|
||||
public:
|
||||
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0);
|
||||
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0 );
|
||||
int GetAttacker() const;
|
||||
void SetAttacker(CBaseEntity *pAttacker);
|
||||
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }
|
||||
|
||||
@@ -24,40 +24,35 @@ project.sources += [
|
||||
'hooks.cpp',
|
||||
'gamerulesnatives.cpp',
|
||||
'vstringtable.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c',
|
||||
'../../public/libudis86/decode.c',
|
||||
'../../public/libudis86/itab.c',
|
||||
'../../public/libudis86/syn-att.c',
|
||||
'../../public/libudis86/syn-intel.c',
|
||||
'../../public/libudis86/syn.c',
|
||||
'../../public/libudis86/udis86.c',
|
||||
]
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
if sdk['name'] in ['mock']:
|
||||
continue
|
||||
|
||||
for cxx in builder.targets:
|
||||
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
|
||||
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
|
||||
continue
|
||||
if sdk_name == 'mock':
|
||||
continue
|
||||
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk['extension'], sdk)
|
||||
SM.AddCDetour(binary)
|
||||
|
||||
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
]
|
||||
binary.compiler.defines += ['HAVE_STRING_H'];
|
||||
|
||||
if sdk['name'] in ('episode1', 'darkm'):
|
||||
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'game_shared')]
|
||||
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'dlls')]
|
||||
else:
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk['path'], 'game', 'shared'),
|
||||
os.path.join(sdk['path'], 'game', 'server'),
|
||||
]
|
||||
|
||||
#binary.sources += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server', 'variant_t.cpp')]
|
||||
|
||||
binary.compiler.defines += ['HAVE_STRING_H']
|
||||
|
||||
if sdk['name'] != 'episode1':
|
||||
if sdk.name != 'episode1':
|
||||
binary.compiler.defines += ['HOOKING_ENABLED']
|
||||
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
|
||||
@@ -108,7 +108,7 @@ extern sp_nativeinfo_t g_ClientNatives[];
|
||||
|
||||
static void InitSDKToolsAPI();
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
CDetour *g_WriteBaselinesDetour = NULL;
|
||||
|
||||
DETOUR_DECL_MEMBER3(CNetworkStringTableContainer__WriteBaselines, void, char const *, mapName, void *, buffer, int, currentTick)
|
||||
@@ -209,7 +209,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
m_CSGOBadList.add("m_bIsQuestEligible");
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
g_WriteBaselinesDetour = DETOUR_CREATE_MEMBER(CNetworkStringTableContainer__WriteBaselines, "WriteBaselines");
|
||||
if (g_WriteBaselinesDetour) {
|
||||
g_WriteBaselinesDetour->EnableDetour();
|
||||
@@ -247,7 +247,7 @@ void SDKTools::SDK_OnUnload()
|
||||
g_RegCalls.clear();
|
||||
ShutdownHelpers();
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (g_WriteBaselinesDetour) {
|
||||
g_WriteBaselinesDetour->DisableDetour();
|
||||
g_WriteBaselinesDetour = NULL;
|
||||
|
||||
@@ -61,8 +61,7 @@
|
||||
#include <itoolentity.h>
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_ALIENSWARM || SOURCE_ENGINE == SE_PORTAL2 || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI \
|
||||
|| SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_MCV
|
||||
#if SOURCE_ENGINE == SE_ALIENSWARM || SOURCE_ENGINE == SE_PORTAL2 || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_CSGO
|
||||
#define CLIENTVOICE_HOOK_SUPPORT
|
||||
#else
|
||||
#include <inetmsghandler.h>
|
||||
|
||||
@@ -45,27 +45,26 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname)
|
||||
int maxEntities = gpGlobals->maxEntities;
|
||||
for (int i = start; i < maxEntities; i++)
|
||||
{
|
||||
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
|
||||
if (pEntity == nullptr)
|
||||
{
|
||||
edict_t *current = gamehelpers->EdictOfIndex(i);
|
||||
if (current == NULL || current->IsFree())
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pEntity);
|
||||
if (pServerClass == nullptr)
|
||||
{
|
||||
IServerNetworkable *network = current->GetNetworkable();
|
||||
if (network == NULL)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const char *name = pServerClass->GetName();
|
||||
IHandleEntity *pHandleEnt = network->GetEntityHandle();
|
||||
if (pHandleEnt == NULL)
|
||||
continue;
|
||||
|
||||
ServerClass *sClass = network->GetServerClass();
|
||||
const char *name = sClass->GetName();
|
||||
|
||||
if (!strcmp(name, classname))
|
||||
{
|
||||
return pEntity;
|
||||
}
|
||||
return gamehelpers->ReferenceToEntity(gamehelpers->IndexOfEdict(current));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CBaseEntity* GetGameRulesProxyEnt()
|
||||
@@ -214,8 +213,7 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_PVKII || SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (pProp->GetFlags() & SPROP_VARINT)
|
||||
{
|
||||
bit_count = sizeof(int) * 8;
|
||||
@@ -289,8 +287,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params)
|
||||
FIND_PROP_SEND(DPT_Int, "integer");
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_PVKII || SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
|
||||
if (pProp->GetFlags() & SPROP_VARINT)
|
||||
{
|
||||
bit_count = sizeof(int) * 8;
|
||||
|
||||
@@ -52,7 +52,7 @@ static bool PVD_used = false;
|
||||
|
||||
SH_DECL_MANUALHOOK2_void(PlayerRunCmdHook, 0, 0, 0, CUserCmd *, IMoveHelper *);
|
||||
SH_DECL_HOOK2(IBaseFileSystem, FileExists, SH_NOATTRIB, 0, bool, const char*, const char *);
|
||||
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
|
||||
SH_DECL_HOOK3(INetChannel, SendFile, SH_NOATTRIB, 0, bool, const char *, unsigned int, bool);
|
||||
#else
|
||||
SH_DECL_HOOK2(INetChannel, SendFile, SH_NOATTRIB, 0, bool, const char *, unsigned int);
|
||||
@@ -65,6 +65,9 @@ SH_DECL_HOOK2_void(INetChannel, ProcessPacket, SH_NOATTRIB, 0, struct netpacket_
|
||||
SourceHook::CallClass<IBaseFileSystem> *basefilesystemPatch = NULL;
|
||||
|
||||
CHookManager::CHookManager()
|
||||
#if SOURCE_ENGINE == SE_TF2
|
||||
: replay_enabled("replay_enabled", false)
|
||||
#endif
|
||||
{
|
||||
m_usercmdsPreFwd = NULL;
|
||||
m_usercmdsFwd = NULL;
|
||||
@@ -443,8 +446,7 @@ void CHookManager::NetChannelHook(int client)
|
||||
|
||||
/* Initial Hook */
|
||||
#if SOURCE_ENGINE == SE_TF2
|
||||
ConVarRef replay_enable("replay_enable", false);
|
||||
if (replay_enable.GetBool())
|
||||
if (replay_enabled.GetBool())
|
||||
{
|
||||
if (!m_bFSTranHookWarned)
|
||||
{
|
||||
@@ -538,7 +540,7 @@ void CHookManager::ProcessPacket_Post(struct netpacket_s* packet, bool bHasHeade
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
|
||||
bool CHookManager::SendFile(const char *filename, unsigned int transferID, bool isReplayDemo)
|
||||
#else
|
||||
bool CHookManager::SendFile(const char *filename, unsigned int transferID)
|
||||
@@ -570,7 +572,7 @@ bool CHookManager::SendFile(const char *filename, unsigned int transferID)
|
||||
if (res != Pl_Continue)
|
||||
{
|
||||
/* Mimic the Engine. */
|
||||
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
|
||||
pNetChannel->DenyFile(filename, transferID, isReplayDemo);
|
||||
#else
|
||||
pNetChannel->DenyFile(filename, transferID);
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
void OnMapStart();
|
||||
public: /* NetChannel/Related Hooks */
|
||||
bool FileExists(const char *filename, const char *pathID);
|
||||
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
|
||||
bool SendFile(const char *filename, unsigned int transferID, bool isReplayDemo);
|
||||
#else
|
||||
bool SendFile(const char *filename, unsigned int transferID);
|
||||
@@ -90,6 +90,9 @@ private:
|
||||
#endif
|
||||
INetChannel *m_pActiveNetChannel;
|
||||
bool m_bFSTranHookWarned = false;
|
||||
#if SOURCE_ENGINE == SE_TF2
|
||||
ConVarRef replay_enabled;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern CHookManager g_Hooks;
|
||||
|
||||
@@ -73,7 +73,7 @@ bool EntityOutputManager::IsEnabled()
|
||||
return enabled;
|
||||
}
|
||||
|
||||
#if defined PLATFORM_WINDOWS && defined PLATFORM_X86
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
DETOUR_DECL_MEMBER8(FireOutput, void, int, what, int, the, int, hell, int, msvc, void *, variant_t, CBaseEntity *, pActivator, CBaseEntity *, pCaller, float, fDelay)
|
||||
{
|
||||
bool fireOutput = g_OutputManager.FireEventDetour((void *)this, pActivator, pCaller, fDelay);
|
||||
|
||||
@@ -128,6 +128,7 @@ private:
|
||||
|
||||
int HookCount;
|
||||
|
||||
patch_t info_restore;
|
||||
void *info_address;
|
||||
void *info_callback;
|
||||
};
|
||||
|
||||
@@ -311,7 +311,7 @@ static cell_t FireEntityOutput(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
return pContext->ThrowNativeError("\"FireEntityOutput\" not supported by this mod");
|
||||
}
|
||||
#if defined PLATFORM_WINDOWS && defined PLATFORM_X86
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
int iMaxParam = 8;
|
||||
//Instead of being one param, MSVC broke variant_t param into 5 params..
|
||||
PassInfo pass[8];
|
||||
|
||||
@@ -50,20 +50,19 @@ void InitTeamNatives()
|
||||
|
||||
int edictCount = gpGlobals->maxEntities;
|
||||
|
||||
for (int i = 0; i < edictCount; i++)
|
||||
for (int i=0; i<edictCount; i++)
|
||||
{
|
||||
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
|
||||
if (pEntity == nullptr)
|
||||
edict_t *pEdict = PEntityOfEntIndex(i);
|
||||
if (!pEdict || pEdict->IsFree())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!pEdict->GetNetworkable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerClass *pClass = gamehelpers->FindEntityServerClass(pEntity);
|
||||
if (pClass == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
|
||||
if (FindNestedDataTable(pClass->m_pTable, "DT_Team"))
|
||||
{
|
||||
SendProp *pTeamNumProp = g_pGameHelpers->FindInSendTable(pClass->GetName(), "m_iTeamNum");
|
||||
@@ -71,14 +70,15 @@ void InitTeamNatives()
|
||||
if (pTeamNumProp != NULL)
|
||||
{
|
||||
int offset = pTeamNumProp->GetOffset();
|
||||
int TeamIndex = *(int *)((unsigned char *)pEntity + offset);
|
||||
CBaseEntity *pEnt = pEdict->GetUnknown()->GetBaseEntity();
|
||||
int TeamIndex = *(int *)((unsigned char *)pEnt + offset);
|
||||
|
||||
if (TeamIndex >= (int)g_Teams.size())
|
||||
{
|
||||
g_Teams.resize(TeamIndex+1);
|
||||
}
|
||||
g_Teams[TeamIndex].ClassName = pClass->GetName();
|
||||
g_Teams[TeamIndex].pEnt = pEntity;
|
||||
g_Teams[TeamIndex].pEnt = pEnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
*/
|
||||
|
||||
#include "tempents.h"
|
||||
#include <basehandle.h>
|
||||
|
||||
TempEntityManager g_TEManager;
|
||||
ICallWrapper *g_GetServerClass = NULL;
|
||||
@@ -184,43 +183,6 @@ bool TempEntityInfo::TE_GetEntData(const char *name, int *value)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TempEntityInfo::TE_SetEntDataEnt(const char *name, IHandleEntity *value)
|
||||
{
|
||||
/* Search for our offset */
|
||||
int offset = _FindOffset(name);
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
|
||||
pHndl->Set(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TempEntityInfo::TE_GetEntDataEnt(const char *name, IHandleEntity **value)
|
||||
{
|
||||
/* Search for our offset */
|
||||
int offset = _FindOffset(name);
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
|
||||
auto *pEnt = reinterpret_cast<IHandleEntity *>(gamehelpers->ReferenceToEntity(pHndl->GetEntryIndex()));
|
||||
if (!pEnt || *pHndl != pEnt->GetRefEHandle())
|
||||
return false;
|
||||
|
||||
*value = pEnt;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TempEntityInfo::TE_SetEntDataFloat(const char *name, float value)
|
||||
{
|
||||
/* Search for our offset */
|
||||
@@ -330,8 +292,7 @@ void TempEntityManager::Initialize()
|
||||
|| SOURCE_ENGINE == SE_SDK2013 \
|
||||
|| SOURCE_ENGINE == SE_BMS \
|
||||
|| SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_NUCLEARDAWN \
|
||||
|| SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_NUCLEARDAWN
|
||||
|
||||
if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr))
|
||||
{
|
||||
|
||||
@@ -47,12 +47,10 @@ public:
|
||||
ServerClass *GetServerClass();
|
||||
bool IsValidProp(const char *name);
|
||||
bool TE_SetEntData(const char *name, int value);
|
||||
bool TE_SetEntDataEnt(const char *name, IHandleEntity *value);
|
||||
bool TE_SetEntDataFloat(const char *name, float value);
|
||||
bool TE_SetEntDataVector(const char *name, float vector[3]);
|
||||
bool TE_SetEntDataFloatArray(const char *name, cell_t *array, int size);
|
||||
bool TE_GetEntData(const char *name, int *value);
|
||||
bool TE_GetEntDataEnt(const char *name, IHandleEntity **value);
|
||||
bool TE_GetEntDataFloat(const char *name, float *value);
|
||||
bool TE_GetEntDataVector(const char *name, float vector[3]);
|
||||
void Send(IRecipientFilter &filter, float delay);
|
||||
|
||||
@@ -307,57 +307,6 @@ static cell_t smn_TEReadNum(IPluginContext *pContext, const cell_t *params)
|
||||
return val;
|
||||
}
|
||||
|
||||
static cell_t smn_TEWriteEnt(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_TEManager.IsAvailable())
|
||||
{
|
||||
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
|
||||
}
|
||||
if (!g_CurrentTE)
|
||||
{
|
||||
return pContext->ThrowNativeError("No TempEntity call is in progress");
|
||||
}
|
||||
|
||||
char *prop;
|
||||
pContext->LocalToString(params[1], &prop);
|
||||
|
||||
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[2]);
|
||||
if (!pEntity && params[2] != -1)
|
||||
{
|
||||
return pContext->ThrowNativeError("Entity %d (%d) is invalid", gamehelpers->ReferenceToIndex(params[2]));
|
||||
}
|
||||
|
||||
if (!g_CurrentTE->TE_SetEntDataEnt(prop, reinterpret_cast<IHandleEntity *>(pEntity)))
|
||||
{
|
||||
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TEReadEnt(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_TEManager.IsAvailable())
|
||||
{
|
||||
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
|
||||
}
|
||||
if (!g_CurrentTE)
|
||||
{
|
||||
return pContext->ThrowNativeError("No TempEntity call is in progress");
|
||||
}
|
||||
|
||||
char *prop;
|
||||
IHandleEntity *val;
|
||||
pContext->LocalToString(params[1], &prop);
|
||||
|
||||
if (!g_CurrentTE->TE_GetEntDataEnt(prop, &val))
|
||||
{
|
||||
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
|
||||
}
|
||||
|
||||
return gamehelpers->EntityToBCompatRef(reinterpret_cast<CBaseEntity *>(val));
|
||||
}
|
||||
|
||||
static cell_t smn_TE_WriteFloat(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_TEManager.IsAvailable())
|
||||
@@ -598,8 +547,6 @@ sp_nativeinfo_t g_TENatives[] =
|
||||
{"TE_Start", smn_TEStart},
|
||||
{"TE_WriteNum", smn_TEWriteNum},
|
||||
{"TE_ReadNum", smn_TEReadNum},
|
||||
{"TE_WriteEnt", smn_TEWriteEnt},
|
||||
{"TE_ReadEnt", smn_TEReadEnt},
|
||||
{"TE_WriteFloat", smn_TE_WriteFloat},
|
||||
{"TE_ReadFloat", smn_TE_ReadFloat},
|
||||
{"TE_WriteVector", smn_TEWriteVector},
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
cell_t m_EntRef = INVALID_EHANDLE_INDEX;
|
||||
};
|
||||
|
||||
class CSMTraceFilter : public ITraceFilter
|
||||
class CSMTraceFilter : public CTraceFilter
|
||||
{
|
||||
public:
|
||||
bool ShouldHitEntity(IHandleEntity *pEntity, int contentsMask)
|
||||
@@ -74,19 +74,10 @@ public:
|
||||
m_pFunc = pFunc;
|
||||
m_Data = data;
|
||||
}
|
||||
virtual TraceType_t GetTraceType() const
|
||||
{
|
||||
return m_TraceType;
|
||||
}
|
||||
void SetTraceType(TraceType_t traceType)
|
||||
{
|
||||
m_TraceType = traceType;
|
||||
}
|
||||
private:
|
||||
ExceptionHandler *m_pEh;
|
||||
IPluginFunction *m_pFunc;
|
||||
cell_t m_Data;
|
||||
TraceType_t m_TraceType;
|
||||
};
|
||||
|
||||
class CSMTraceEnumerator : public IPartitionEnumerator
|
||||
@@ -467,7 +458,6 @@ static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *param
|
||||
cell_t *startaddr, *endaddr;
|
||||
IPluginFunction *pFunc;
|
||||
cell_t data;
|
||||
TraceType_t traceType;
|
||||
|
||||
pFunc = pContext->GetFunctionById(params[5]);
|
||||
if (!pFunc)
|
||||
@@ -487,17 +477,6 @@ static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *param
|
||||
DetectExceptions eh(pContext);
|
||||
g_SMTraceFilter.SetFunctionPtr(&eh, pFunc, data);
|
||||
|
||||
if (params[0] >= 7)
|
||||
{
|
||||
traceType = (TraceType_t)params[7];
|
||||
}
|
||||
else
|
||||
{
|
||||
traceType = TRACE_EVERYTHING;
|
||||
}
|
||||
|
||||
g_SMTraceFilter.SetTraceType(traceType);
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||
|
||||
@@ -534,7 +513,6 @@ static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *para
|
||||
cell_t data;
|
||||
IPluginFunction *pFunc;
|
||||
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||
TraceType_t traceType;
|
||||
|
||||
pFunc = pContext->GetFunctionById(params[6]);
|
||||
if (!pFunc)
|
||||
@@ -547,17 +525,6 @@ static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *para
|
||||
DetectExceptions eh(pContext);
|
||||
g_SMTraceFilter.SetFunctionPtr(&eh, pFunc, data);
|
||||
|
||||
if (params[0] >= 8)
|
||||
{
|
||||
traceType = (TraceType_t)params[8];
|
||||
}
|
||||
else
|
||||
{
|
||||
traceType = TRACE_EVERYTHING;
|
||||
}
|
||||
|
||||
g_SMTraceFilter.SetTraceType(traceType);
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||
pContext->LocalToPhysAddr(params[3], &mins);
|
||||
@@ -783,7 +750,6 @@ static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *par
|
||||
IPluginFunction *pFunc;
|
||||
cell_t *startaddr, *endaddr;
|
||||
cell_t data;
|
||||
TraceType_t traceType;
|
||||
|
||||
pFunc = pContext->GetFunctionById(params[5]);
|
||||
if (!pFunc)
|
||||
@@ -808,17 +774,6 @@ static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *par
|
||||
|
||||
DetectExceptions eh(pContext);
|
||||
smfilter.SetFunctionPtr(&eh, pFunc, data);
|
||||
|
||||
if (params[0] >= 7)
|
||||
{
|
||||
traceType = (TraceType_t)params[7];
|
||||
}
|
||||
else
|
||||
{
|
||||
traceType = TRACE_EVERYTHING;
|
||||
}
|
||||
|
||||
smfilter.SetTraceType(traceType);
|
||||
|
||||
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||
|
||||
@@ -863,7 +818,6 @@ static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *pa
|
||||
IPluginFunction *pFunc;
|
||||
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||
cell_t data;
|
||||
TraceType_t traceType;
|
||||
|
||||
pFunc = pContext->GetFunctionById(params[6]);
|
||||
if (!pFunc)
|
||||
@@ -883,17 +837,6 @@ static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *pa
|
||||
|
||||
DetectExceptions eh(pContext);
|
||||
smfilter.SetFunctionPtr(&eh, pFunc, data);
|
||||
|
||||
if (params[0] >= 8)
|
||||
{
|
||||
traceType = (TraceType_t)params[8];
|
||||
}
|
||||
else
|
||||
{
|
||||
traceType = TRACE_EVERYTHING;
|
||||
}
|
||||
|
||||
smfilter.SetTraceType(traceType);
|
||||
|
||||
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||
vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
|
||||
@@ -1217,7 +1160,7 @@ static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *par
|
||||
{
|
||||
mask = enginetrace->GetPointContents(pos);
|
||||
} else {
|
||||
#if (SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_BMS)
|
||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_BMS
|
||||
mask = enginetrace->GetPointContents(pos, MASK_ALL, &hentity);
|
||||
#else
|
||||
mask = enginetrace->GetPointContents(pos, &hentity);
|
||||
|
||||
@@ -33,14 +33,7 @@
|
||||
#include "variant-t.h"
|
||||
#include <datamap.h>
|
||||
|
||||
variant_t g_Variant_t;
|
||||
|
||||
// copy this definition as the original file includes cbase.h which explodes in a shower of compile errors
|
||||
void variant_t::SetEntity( CBaseEntity *val )
|
||||
{
|
||||
eVal = val;
|
||||
fieldType = FIELD_EHANDLE;
|
||||
}
|
||||
unsigned char g_Variant_t[SIZEOF_VARIANT_T] = {0};
|
||||
|
||||
#define ENTINDEX_TO_CBASEENTITY(ref, buffer) \
|
||||
buffer = gamehelpers->ReferenceToEntity(ref); \
|
||||
@@ -49,66 +42,132 @@ void variant_t::SetEntity( CBaseEntity *val )
|
||||
return pContext->ThrowNativeError("Entity %d (%d) is not a CBaseEntity", gamehelpers->ReferenceToIndex(ref), ref); \
|
||||
}
|
||||
|
||||
/* Hack to init the variant_t object for the first time */
|
||||
class VariantFirstTimeInit
|
||||
{
|
||||
public:
|
||||
VariantFirstTimeInit()
|
||||
{
|
||||
*(unsigned int *)(&g_Variant_t[12]) = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
} g_VariantFirstTimeInit;
|
||||
|
||||
static cell_t SetVariantBool(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
g_Variant_t.SetBool((params[1]) ? true : false);
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
*(bool *)vptr = (params[1]) ? true : false;
|
||||
vptr += sizeof(int)*3 + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_BOOLEAN;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *str;
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
pContext->LocalToString(params[1], &str);
|
||||
g_Variant_t.SetString(MAKE_STRING(str));
|
||||
|
||||
*(string_t *)vptr = MAKE_STRING(str);
|
||||
vptr += sizeof(int)*3 + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_STRING;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantInt(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
g_Variant_t.SetInt(params[1]);
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
*(int *)vptr = params[1];
|
||||
vptr += sizeof(int)*3 + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_INTEGER;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantFloat(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
g_Variant_t.SetFloat(sp_ctof(params[1]));
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
*(float *)vptr = sp_ctof(params[1]);
|
||||
vptr += sizeof(int)*3 + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_FLOAT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantVector3D(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *val;
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &val);
|
||||
|
||||
Vector v(sp_ctof(val[0]), sp_ctof(val[1]), sp_ctof(val[2]));
|
||||
g_Variant_t.SetVector3D(v);
|
||||
*(float *)vptr = sp_ctof(val[0]);
|
||||
vptr += sizeof(float);
|
||||
*(float *)vptr = sp_ctof(val[1]);
|
||||
vptr += sizeof(float);
|
||||
*(float *)vptr = sp_ctof(val[2]);
|
||||
vptr += sizeof(float) + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_VECTOR;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantPosVector3D(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *val;
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &val);
|
||||
|
||||
Vector v(sp_ctof(val[0]), sp_ctof(val[1]), sp_ctof(val[2]));
|
||||
g_Variant_t.SetPositionVector3D(v);
|
||||
*(float *)vptr = sp_ctof(val[0]);
|
||||
vptr += sizeof(float);
|
||||
*(float *)vptr = sp_ctof(val[1]);
|
||||
vptr += sizeof(float);
|
||||
*(float *)vptr = sp_ctof(val[2]);
|
||||
vptr += sizeof(float) + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_POSITION_VECTOR;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantColor(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *val;
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &val);
|
||||
|
||||
g_Variant_t.SetColor32(val[0], val[1], val[2], val[3]);
|
||||
*(unsigned char *)vptr = val[0];
|
||||
vptr += sizeof(unsigned char);
|
||||
*(unsigned char *)vptr = val[1];
|
||||
vptr += sizeof(unsigned char);
|
||||
*(unsigned char *)vptr = val[2];
|
||||
vptr += sizeof(unsigned char);
|
||||
*(unsigned char *)vptr = val[3];
|
||||
vptr += sizeof(unsigned char) + sizeof(int)*2 + sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_COLOR32;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t SetVariantEntity(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
CBaseEntity *pEntity;
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
CBaseHandle bHandle;
|
||||
|
||||
ENTINDEX_TO_CBASEENTITY(params[1], pEntity);
|
||||
g_Variant_t.SetEntity(pEntity);
|
||||
bHandle = reinterpret_cast<IHandleEntity *>(pEntity)->GetRefEHandle();
|
||||
|
||||
vptr += sizeof(int)*3;
|
||||
*(unsigned long *)vptr = (unsigned long)(bHandle.ToInt());
|
||||
vptr += sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_EHANDLE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -124,4 +183,4 @@ sp_nativeinfo_t g_VariantTNatives[] =
|
||||
{"SetVariantColor", SetVariantColor},
|
||||
{"SetVariantEntity", SetVariantEntity},
|
||||
{NULL, NULL},
|
||||
};
|
||||
};
|
||||
@@ -32,22 +32,26 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
|
||||
|
||||
#include "variant_t.h"
|
||||
|
||||
#define SIZEOF_VARIANT_T sizeof(variant_t)
|
||||
#define SIZEOF_VARIANT_T 20
|
||||
|
||||
/**
|
||||
* @file variant-t.h
|
||||
* @brief SDK Tools extension gamerules natives header.
|
||||
*/
|
||||
|
||||
extern variant_t g_Variant_t;
|
||||
extern unsigned char g_Variant_t[SIZEOF_VARIANT_T];
|
||||
|
||||
extern sp_nativeinfo_t g_VariantTNatives[];
|
||||
|
||||
inline void _init_variant_t()
|
||||
{
|
||||
memset(&g_Variant_t, 0, sizeof(g_Variant_t));
|
||||
unsigned char *vptr = g_Variant_t;
|
||||
|
||||
*(int *)vptr = 0;
|
||||
vptr += sizeof(int)*3;
|
||||
*(unsigned long *)vptr = INVALID_EHANDLE_INDEX;
|
||||
vptr += sizeof(unsigned long);
|
||||
*(fieldtype_t *)vptr = FIELD_VOID;
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
|
||||
@@ -151,9 +151,7 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p
|
||||
|| SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_INSURGENCY \
|
||||
|| SOURCE_ENGINE == SE_DOI \
|
||||
|| SOURCE_ENGINE == SE_CSGO \
|
||||
|| SOURCE_ENGINE == SE_PVKII \
|
||||
|| SOURCE_ENGINE == SE_MCV
|
||||
|| SOURCE_ENGINE == SE_CSGO
|
||||
s_call_addr = memutils->ResolveSymbol(handle, &sig[1]);
|
||||
#else
|
||||
s_call_addr = dlsym(handle, &sig[1]);
|
||||
@@ -338,25 +336,15 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
break;
|
||||
case ValveCall_Server:
|
||||
{
|
||||
if (iserver == NULL)
|
||||
{
|
||||
vc->stk_put(ptr);
|
||||
return pContext->ThrowNativeError("Server unsupported or not available; file a bug report");
|
||||
}
|
||||
*(void **)ptr = iserver;
|
||||
}
|
||||
break;
|
||||
case ValveCall_Engine:
|
||||
{
|
||||
if (engine == NULL)
|
||||
{
|
||||
vc->stk_put(ptr);
|
||||
return pContext->ThrowNativeError("Engine unsupported or not available; file a bug report");
|
||||
}
|
||||
*(void **)ptr = engine;
|
||||
}
|
||||
break;
|
||||
{
|
||||
if (iserver == NULL)
|
||||
{
|
||||
vc->stk_put(ptr);
|
||||
return pContext->ThrowNativeError("Server unsupported or not available; file a bug report");
|
||||
}
|
||||
*(void **)ptr = iserver;
|
||||
}
|
||||
break;
|
||||
case ValveCall_GameRules:
|
||||
{
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
@@ -396,17 +396,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
|
||||
if (index >= 1 && index <= playerhelpers->GetMaxClients())
|
||||
{
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
|
||||
|
||||
if(!player->IsConnected()) {
|
||||
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
|
||||
&& !player->IsConnected())
|
||||
{
|
||||
pContext->ThrowNativeError("Client %d is not connected", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
||||
} else if (!player->IsInGame()) {
|
||||
pContext->ThrowNativeError("Client %d is not in game", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
pEntity = gamehelpers->ReferenceToEntity(param);
|
||||
} else if (param == -1) {
|
||||
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
||||
@@ -443,17 +441,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
|
||||
if (index >= 1 && index <= playerhelpers->GetMaxClients())
|
||||
{
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
|
||||
|
||||
if(!player->IsConnected()) {
|
||||
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
|
||||
&& !player->IsConnected())
|
||||
{
|
||||
pContext->ThrowNativeError("Client %d is not connected", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
||||
} else if (!player->IsInGame()) {
|
||||
pContext->ThrowNativeError("Client %d is not in game", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
pEntity = gamehelpers->ReferenceToEntity(param);
|
||||
} else if (param == -1) {
|
||||
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
||||
@@ -497,17 +493,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
|
||||
if (param >= 1 && param <= playerhelpers->GetMaxClients())
|
||||
{
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(param);
|
||||
|
||||
if(!player->IsConnected()) {
|
||||
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
|
||||
&& !player->IsConnected())
|
||||
{
|
||||
pContext->ThrowNativeError("Client %d is not connected", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
||||
} else if (!player->IsInGame()) {
|
||||
pContext->ThrowNativeError("Client %d is not in game", param);
|
||||
return Data_Fail;
|
||||
}
|
||||
|
||||
pEdict = player->GetEdict();
|
||||
} else if (param == -1) {
|
||||
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
||||
|
||||
@@ -83,7 +83,6 @@ enum ValveCallType
|
||||
ValveCall_EntityList, /**< Thiscall (CGlobalEntityList implicit first paramater) */
|
||||
ValveCall_Raw, /**< Thiscall (address explicit first parameter) */
|
||||
ValveCall_Server, /**< Thiscall (CBaseServer implicit first parameter) */
|
||||
ValveCall_Engine, /**< Thiscall (CVEngineServer implicit first parameter) */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -235,8 +235,7 @@ void GetIServer()
|
||||
|| SOURCE_ENGINE == SE_BMS \
|
||||
|| SOURCE_ENGINE == SE_DOI \
|
||||
|| SOURCE_ENGINE == SE_BLADE \
|
||||
|| SOURCE_ENGINE == SE_INSURGENCY \
|
||||
|| SOURCE_ENGINE == SE_PVKII
|
||||
|| SOURCE_ENGINE == SE_INSURGENCY
|
||||
|
||||
#if SOURCE_ENGINE == SE_SDK2013
|
||||
if (g_SMAPI->GetEngineFactory(false)("VEngineServer022", nullptr))
|
||||
@@ -321,23 +320,28 @@ void GetResourceEntity()
|
||||
{
|
||||
int edictCount = gpGlobals->maxEntities;
|
||||
|
||||
for (int i = 0; i < edictCount; i++)
|
||||
for (int i=0; i<edictCount; i++)
|
||||
{
|
||||
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
|
||||
if (pEntity == nullptr)
|
||||
edict_t *pEdict = PEntityOfEntIndex(i);
|
||||
if (!pEdict || pEdict->IsFree())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!pEdict->GetNetworkable())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerClass *pClass = gamehelpers->FindEntityServerClass(pEntity);
|
||||
if (pClass == nullptr)
|
||||
IHandleEntity *pHandleEnt = pEdict->GetNetworkable()->GetEntityHandle();
|
||||
if (!pHandleEnt)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
|
||||
if (FindNestedDataTable(pClass->m_pTable, "DT_PlayerResource"))
|
||||
{
|
||||
g_ResourceEntity = ((IHandleEntity *)pEntity)->GetRefEHandle();
|
||||
g_ResourceEntity = pHandleEnt->GetRefEHandle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user