mirror of
https://github.com/rehlds/rehlds.git
synced 2025-04-07 01:59:05 +03:00
Compare commits
84 Commits
3.12.0.780
...
master
Author | SHA1 | Date | |
---|---|---|---|
5cac7a97ab | |||
|
44e510a25c | ||
|
7bc5d86add | ||
|
98b4103b86 | ||
|
2f87ace7fc | ||
|
a2953ea374 | ||
|
45fe816fdd | ||
|
89958d348e | ||
e9991716fc | |||
|
20c16bfad3 | ||
|
28c205de11 | ||
|
1a68407710 | ||
|
4afb6e3be9 | ||
|
e83b324301 | ||
|
64c684af4a | ||
|
e54adb089c | ||
|
18b173d5c6 | ||
|
6e6368da30 | ||
|
df862d9bb6 | ||
12b35dbe8c | |||
c17dacd152 | |||
85d55d15db | |||
df704585aa | |||
|
5a1f66a6b4 | ||
|
fe184a82e0 | ||
|
b29740c19e | ||
|
7073363c88 | ||
|
2834fb8494 | ||
|
c8308a2c60 | ||
|
ed954a710f | ||
|
9935f8bc75 | ||
|
9c1e84328e | ||
|
c1ccc5009a | ||
|
0f45ec09fa | ||
|
c9f9bbfff9 | ||
|
a761efa75d | ||
|
82a3d1d084 | ||
|
693b51c883 | ||
|
47ffe4b257 | ||
|
3c4acbb046 | ||
|
5b72d06bfb | ||
|
0d1bdbab67 | ||
|
61ee4f9269 | ||
|
b870de768b | ||
|
3c282b435c | ||
|
ec47e4d978 | ||
|
462fe55fb8 | ||
|
f26ad71aba | ||
|
59ed3f6867 | ||
|
516bb93627 | ||
|
174414db81 | ||
|
05f4a279f9 | ||
|
58391b6ee5 | ||
|
498d7e0d18 | ||
|
a7b60451f3 | ||
|
63fde229c9 | ||
|
9b0dbe8dd2 | ||
|
41c5186b2c | ||
|
90cb97ddae | ||
|
76cbd2c140 | ||
|
f29d6c5769 | ||
|
355172d6db | ||
|
62407e0dd6 | ||
|
1d6c6826db | ||
|
5002ff9abe | ||
|
32857e7785 | ||
|
93f5775ac2 | ||
|
0af97d98bb | ||
|
ffb65795dd | ||
|
3f19bc1d3e | ||
|
7fcec97af4 | ||
|
b7f6eb8023 | ||
|
5ec8c29185 | ||
|
6f031901cf | ||
|
de3679f039 | ||
|
2ba27d409c | ||
|
f955b07b69 | ||
|
918612fa23 | ||
|
8841ba4aec | ||
|
0c5ce53666 | ||
|
a680f18ee1 | ||
|
1796459953 | ||
|
5e8b0ba616 | ||
|
14b56e0514 |
247
.github/workflows/build.yml
vendored
247
.github/workflows/build.yml
vendored
@ -10,6 +10,7 @@ on:
|
||||
types: [opened, reopened, synchronize]
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
@ -24,13 +25,16 @@ jobs:
|
||||
buildTest: 'Test Fixes'
|
||||
|
||||
steps:
|
||||
- name: Configure
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Build and Run unittests
|
||||
run: |
|
||||
@ -46,6 +50,11 @@ jobs:
|
||||
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
|
||||
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
|
||||
|
||||
- name: Get rcedit from chocolatey
|
||||
run: |
|
||||
choco install rcedit -y
|
||||
shell: "pwsh"
|
||||
|
||||
- name: Move files
|
||||
run: |
|
||||
mkdir publish\debug
|
||||
@ -69,99 +78,155 @@ jobs:
|
||||
move msvc\${{ env.buildRelease }}\filesystem_stdio.pdb publish\debug\filesystem_stdio.pdb
|
||||
move msvc\${{ env.buildRelease }}\director.pdb publish\debug\director.pdb
|
||||
|
||||
# TODO: Set version to exe dynamicly: 0.0.0.0 to normal version such as at linux
|
||||
- name: Edit resources at windows binaries
|
||||
run: |
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\hlds.exe --set-version-string ProductName "ReHLDS" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "The Half-Life Dedicated Server, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam"
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\hltv.exe --set-version-string ProductName "ReHLTV" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "The Half-Life TV, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam"
|
||||
rcedit ${{ github.workspace }}\publish\tests\swds.dll --set-version-string ProductName "swds.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A dll used by Steamworks Dedicated Servers, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\swds.dll --set-version-string ProductName "swds.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A ddll used by Steamworks Dedicated Servers, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\core.dll --set-version-string ProductName "core.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription " A dll, it is a core of game engine, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\proxy.dll --set-version-string ProductName "proxy.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A dll for proxying network connections, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\demoplayer.dll --set-version-string ProductName "demoplayer.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A dll for demoplayer functionality, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\filesystem_stdio.dll --set-version-string ProductName "filesystem_stdio.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A dll that manages file input/output operations, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
rcedit ${{ github.workspace }}\publish\bin\win32\valve\dlls\director.dll --set-version-string ProductName "director.dll" --set-file-version "0.0.0.0" --set-product-version "0.0.0.0" --set-version-string FileDescription "A dll used for Director functionality in Half-Life 1, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon rehlds/dedicated/msvc/icon.ico
|
||||
shell: "pwsh"
|
||||
|
||||
- name: Import PFX and sign
|
||||
if: github.event_name != 'pull_request'
|
||||
env:
|
||||
KEY_PFX_PASS: ${{ secrets.KEY_PFX_PASS }}
|
||||
run: |
|
||||
$pfxBase64 = "${{ secrets.KEY_PFX_B64 }}"
|
||||
[IO.File]::WriteAllBytes("${{ github.workspace }}\signing-cert.pfx", [Convert]::FromBase64String($pfxBase64))
|
||||
certutil -f -p "${{ secrets.KEY_PFX_PASS }}" -importPFX "${{ github.workspace }}\signing-cert.pfx"
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\hlds.exe
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "reHLTV" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\hltv.exe
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - swds.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\tests\swds.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - swds.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\swds.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - core.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\core.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - proxy.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\proxy.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - demoplayer.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\demoplayer.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - filesystem_stdio.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\filesystem_stdio.dll
|
||||
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReHLDS - director.dll" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha512 /fd sha512 /v ${{ github.workspace }}\publish\bin\win32\valve\dlls\director.dll
|
||||
Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
|
||||
shell: "pwsh"
|
||||
|
||||
- name: Deploy artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: win32
|
||||
path: publish/*
|
||||
|
||||
testdemos:
|
||||
name: 'Test demos'
|
||||
runs-on: ubuntu-latest
|
||||
container: s1lentq/testdemos:latest
|
||||
runs-on: ubuntu-24.04
|
||||
container: rehldsorg/testdemos:latest
|
||||
needs: [windows]
|
||||
|
||||
env:
|
||||
WINEDEBUG: -all
|
||||
WINEDLLOVERRIDES: mshtml=
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: ../../../opt/HLDS
|
||||
working-directory: /opt/HLDS
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
test: [
|
||||
{ file: 'cstrike-muliplayer-1', desc: 'CS: Multiplayer' },
|
||||
{ file: 'rehlds-phys-single1', desc: 'Half-Life: Physics singleplayer' },
|
||||
{ file: 'crossfire-1-multiplayer-1', desc: 'Half-Life: Multiplayer on crossfire map' },
|
||||
{ file: 'shooting-hl-1', desc: 'Half-Life: Shooting with several weapons' },
|
||||
]
|
||||
|
||||
steps:
|
||||
- name: Deploying windows artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: win32
|
||||
|
||||
- name: Play demos
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
chown root ~
|
||||
rsync -a deps/rehlds/* .
|
||||
mv $GITHUB_WORKSPACE/tests/swds.dll .
|
||||
|
||||
descs=(
|
||||
"CS: Multiplayer"
|
||||
"Half-Life: Physics singleplayer"
|
||||
"Half-Life: Multiplayer on crossfire map"
|
||||
"Half-Life: Shooting with several weapons"
|
||||
)
|
||||
|
||||
demos=(
|
||||
"cstrike-muliplayer-1"
|
||||
"rehlds-phys-single1"
|
||||
"crossfire-1-multiplayer-1"
|
||||
"shooting-hl-1"
|
||||
)
|
||||
|
||||
retVal=0
|
||||
for i in "${!demos[@]}"; do
|
||||
params=$(cat "testdemos/${demos[i]}.params")
|
||||
|
||||
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[0m"
|
||||
echo -e " - \e[0;33mParameters $params\e[0m"
|
||||
|
||||
wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demos[i]}.bin" $params &> result.log || retVal=$?
|
||||
|
||||
if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then
|
||||
# Print with catchy messages
|
||||
while read line; do
|
||||
echo -e " \e[0;33m$line"
|
||||
done <<< $(cat result.log | sed '0,/demo failed/I!d;/wine:/d;/./,$!d')
|
||||
|
||||
echo " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸"
|
||||
while read line; do
|
||||
echo -e " \e[1;31m$line";
|
||||
done < rehlds_demo_error.txt
|
||||
echo -e " \e[30;41mExit code: $retVal\e[0m"
|
||||
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;31m Failed ❌"
|
||||
exit 6 # Test demo failed
|
||||
else
|
||||
# Print result HLDS console
|
||||
while read line; do
|
||||
echo -e " \e[0;33m$line"
|
||||
done <<< $(cat result.log | sed '/wine:/d;/./,$!d')
|
||||
echo -e " \e[30;43mExit code: $retVal\e[0m"
|
||||
echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;32m Succeed ✔"
|
||||
fi
|
||||
done
|
||||
- name: Play test
|
||||
env:
|
||||
demo: ${{ matrix.test.file }}
|
||||
desc: ${{ matrix.test.desc }}
|
||||
run: ./runTest.sh
|
||||
|
||||
linux:
|
||||
name: 'Linux'
|
||||
runs-on: ubuntu-latest
|
||||
container: s1lentq/linux86buildtools:latest
|
||||
runs-on: ubuntu-24.04
|
||||
container: debian:11-slim
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dpkg --add-architecture i386
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
gcc-multilib g++-multilib \
|
||||
build-essential \
|
||||
libc6-dev libc6-dev-i386 \
|
||||
git cmake rsync \
|
||||
g++ gcc
|
||||
|
||||
- name: Configure
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: GPG Import
|
||||
run: |
|
||||
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
|
||||
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
|
||||
|
||||
# Import the public key
|
||||
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error: Failed to import the public key"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Import the private key
|
||||
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error: Failed to import the private key"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Extract the fingerprint of the imported public key
|
||||
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
|
||||
|
||||
# Check if the fingerprint was extracted
|
||||
if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
|
||||
echo "Error: Failed to extract the fingerprint of the key"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Set the trust level for the key
|
||||
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
|
||||
gpg --list-keys
|
||||
|
||||
#export for global use
|
||||
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
- name: Build and Run unittests
|
||||
run: |
|
||||
rm -rf build && CC=icc CXX=icpc cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
|
||||
rm -rf build && cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
|
||||
retVal=0
|
||||
export LD_LIBRARY_PATH="rehlds/lib/linux32:$LD_LIBRARY_PATH"
|
||||
./build/rehlds/engine_i486 2> /dev/null > result.log || retVal=$?
|
||||
@ -183,9 +248,9 @@ jobs:
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
- name: Build using Intel C++ Compiler
|
||||
- name: Build using GCC Compiler
|
||||
run: |
|
||||
rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8
|
||||
rm -rf build && cmake -B build && cmake --build build -j8
|
||||
|
||||
- name: Prepare HLSDK
|
||||
run: |
|
||||
@ -228,31 +293,25 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
- name: Deploy artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4
|
||||
id: upload-job
|
||||
with:
|
||||
name: linux32
|
||||
path: publish/*
|
||||
|
||||
- name: Cleanup temporary artifacts
|
||||
if: success() && steps.upload-job.outcome == 'success'
|
||||
run: |
|
||||
rm -rf hlsdk
|
||||
rm -f appversion.h
|
||||
|
||||
publish:
|
||||
name: 'Publish'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [windows, testdemos, linux]
|
||||
|
||||
steps:
|
||||
- name: Deploying linux artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux32
|
||||
|
||||
- name: Deploying windows artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: win32
|
||||
|
||||
@ -270,18 +329,45 @@ jobs:
|
||||
fi
|
||||
rm -f appversion.h
|
||||
|
||||
- name: Packaging bin/dbg
|
||||
- name: Final signing and Packaging bin/dbg
|
||||
id: packaging-job
|
||||
if: |
|
||||
github.event_name == 'release' &&
|
||||
github.event.action == 'published' &&
|
||||
startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/linux32/ hlsdk/
|
||||
|
||||
# new runner, niw signs
|
||||
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
|
||||
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
|
||||
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
|
||||
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
|
||||
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
|
||||
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
|
||||
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
|
||||
|
||||
sign_file() {
|
||||
local file=$1
|
||||
gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to sign $file"
|
||||
exit 2
|
||||
fi
|
||||
echo "$file signed successfully."
|
||||
}
|
||||
|
||||
# Pack and sign final archive
|
||||
7z a -tzip rehlds-bin-${{ env.APP_VERSION }}.zip bin/ hlsdk/
|
||||
sign_file "rehlds-bin-${{ env.APP_VERSION }}.zip"
|
||||
|
||||
# Pack and sign final archive
|
||||
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -aoa rehlds-dbg-${{ env.APP_VERSION }}.7z debug/
|
||||
sign_file "rehlds-dbg-${{ env.APP_VERSION }}.7z"
|
||||
|
||||
shell: bash
|
||||
|
||||
- name: Publish artifacts
|
||||
uses: softprops/action-gh-release@v1
|
||||
uses: softprops/action-gh-release@v2
|
||||
id: publish-job
|
||||
if: |
|
||||
startsWith(github.ref, 'refs/tags/') &&
|
||||
@ -290,11 +376,6 @@ jobs:
|
||||
files: |
|
||||
*.zip
|
||||
*.7z
|
||||
*.asc
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}
|
||||
|
||||
- name: Cleanup temporary artifacts
|
||||
if: success() && steps.publish-job.outcome == 'success'
|
||||
run: |
|
||||
rm -rf bin debug hlsdk
|
||||
rm -f *.7z *.zip appversion.h
|
||||
|
238
CHANGELOG.md
Normal file
238
CHANGELOG.md
Normal file
@ -0,0 +1,238 @@
|
||||
# [ReHLDS](https://github.com/ReHLDS/ReHLDS) Changelog
|
||||
|
||||
**ReHLDS** is a result of reverse engineering of original `HLDS` (build `6152`/`6153`) using `DWARF` debug info embedded into linux version of `HLDS`, `engine_i486.so`.
|
||||
|
||||
Along with reverse engineering, a lot of defects and (potential) bugs were found and fixed.
|
||||
|
||||
---
|
||||
|
||||
## [`3.13.0.788`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.13.0.788) - 2023-07-12
|
||||
|
||||
### Added
|
||||
- Added `SV_AllowPhysent` hook by @justgo97 in [(#951)](ttps://github.com/dreamstalker/ReHLDS/pull/951)
|
||||
- `GetBonePosition`: Added bone index bounds check
|
||||
- `GetAttachment`: Added attachment index bounds check
|
||||
- Added more checks for possible `numleaf` overflow
|
||||
|
||||
### Fixed
|
||||
- `SV_BuildSoundMsg`: fix '`\n`' in args check
|
||||
|
||||
### Changed
|
||||
- Revert "change destinition folder for linux build" by @wopox1337 in [(#977)](https://github.com/dreamstalker/ReHLDS/pull/977)
|
||||
- Allowed the clients to connect on the server of different game: Client should be use `setinfo _gd <game>`
|
||||
- Increased limit leafs `MAX_MAP_LEAFS` up to `32767`
|
||||
|
||||
## New Contributors
|
||||
- @justgo97 made their first contribution in [(#951)](https://github.com/dreamstalker/ReHLDS/pull/951)
|
||||
|
||||
**Full Changelog**: [3.12.0.780...3.13.0.788](https://github.com/ReHLDS/ReHLDS/compare/3.12.0.780...3.13.0.788)
|
||||
|
||||
## [`3.12.0.780`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.12.0.780) - 2022-09-19
|
||||
|
||||
### Fixed
|
||||
- `Netchan_CreateFileFragments`: Fixed a very old and rare bug with dlfile while downloading direct from server, when content of resource size is less than header size first fragment.
|
||||
|
||||
### Changed
|
||||
- `API`: Implement `*_Precache_*`, `ClientPrintf`, `CheckUserInfo` and `AddResource` hooks by @ShadowsAdi in [(#903)](https://github.com/dreamstalker/ReHLDS/pull/903)
|
||||
|
||||
## New Contributors
|
||||
* @ShadowsAdi made their first contribution in [(#903)](https://github.com/dreamstalker/ReHLDS/pull/903)
|
||||
|
||||
**Full Changelog**: [3.11.0.779...3.12.0.780](https://github.com/ReHLDS/ReHLDS/compare/3.11.0.779...3.12.0.780)
|
||||
|
||||
## [`3.11.0.779`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.11.0.779) - 2022-08-24
|
||||
|
||||
### Fixed
|
||||
- `StripUnprintableWorker` did not count the null terminator [e9045e3](https://github.com/dreamstalker/ReHLDS/commit/e9045e3)
|
||||
- Very old and rare bug in function `Netchan_CreateFileFragments` with dlfile hang while downloading direct from server, when content of resource size is less than header size first fragment [d76b06d](https://github.com/dreamstalker/ReHLDS/commit/d76b06d)
|
||||
|
||||
**Full Changelog**: [3.11.0.777...3.11.0.779](https://github.com/ReHLDS/ReHLDS/compare/3.11.0.777...3.11.0.779)
|
||||
|
||||
## [`3.11.0.777`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.11.0.777) - 2022-06-20
|
||||
|
||||
### Fixed
|
||||
* Fixed `null or empty` input string in `COM_LoadFile` (`FS_Open` with input empty string `""` will succeed on some POSIX systems)
|
||||
- Resolved [(#919)](https://github.com/dreamstalker/ReHLDS/issues/919)
|
||||
|
||||
**Full Changelog**: [3.11.0.776...3.11.0.777](https://github.com/ReHLDS/ReHLDS/compare/3.11.0.776...3.11.0.777)
|
||||
|
||||
## [`3.11.0.776`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.11.0.776) - 2022-04-20
|
||||
|
||||
### Fixed
|
||||
* Fixed typo `ZONE_DYNAMIC_SIZE`
|
||||
|
||||
**Full Changelog**: [3.11.0.767...3.11.0.776](https://github.com/ReHLDS/ReHLDS/compare/3.11.0.767...3.11.0.776)
|
||||
|
||||
## [`3.11.0.767`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.11.0.767) - 2021-10-25
|
||||
|
||||
### Added
|
||||
* Implement `SV_EmitPings()` hook by @francoromaniello in [(#858)](https://github.com/ReHLDS/ReHLDS/pull/858)
|
||||
* Implement `Con_Printf()` hook by @francoromaniello in [(#861)](https://github.com/ReHLDS/ReHLDS/pull/861)
|
||||
|
||||
### Changed
|
||||
* `API`: Add hooks `ED_Alloc()` & `ED_Free()`. by @StevenKal in [(#867)](https://github.com/ReHLDS/ReHLDS/pull/867)
|
||||
* `SV_HullForEntity`: better log in `Sys_Error` by @wopox1337 in [(#843)](https://github.com/ReHLDS/ReHLDS/pull/843)
|
||||
* Update on grammar/spelling by @mlgpero in [(#865)](https://github.com/ReHLDS/ReHLDS/pull/865)
|
||||
|
||||
## New Contributors
|
||||
* @StevenKal made their first contribution in [(#867)](https://github.com/ReHLDS/ReHLDS/pull/867)
|
||||
* @francoromaniello made their first contribution in [(#858)](https://github.com/ReHLDS/ReHLDS/pull/858)
|
||||
* @Urufusan made their first contribution in [(#865)](https://github.com/ReHLDS/ReHLDS/pull/865)
|
||||
|
||||
**Full Changelog**: [v3.10.0.761...3.11.0.767](https://github.com/ReHLDS/ReHLDS/compare/v3.10.0.761...3.11.0.767)
|
||||
|
||||
## [`3.10.0.760`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.10.0.760) - 2021-06-23
|
||||
|
||||
### Changed
|
||||
- Changed the destination folder for `Linux build` [(#842)](https://github.com/ReHLDS/ReHLDS/pull/842).
|
||||
- Temporary removed `Windows build`. :warning:
|
||||
|
||||
**Full Changelog**: [3.10.0.759...3.10.0.760](https://github.com/ReHLDS/ReHLDS/compare/3.10.0.759...3.10.0.760)
|
||||
|
||||
|
||||
## [`3.10.0.761`](https://github.com/ReHLDS/ReHLDS/releases/tag/v3.10.0.761) - 2021-06-23
|
||||
|
||||
### Changed
|
||||
- Reset `m_bSentNewResponse` to allow new connection when the client goes through the full stage of connection (`cl:connect` -> `sv:S2C_CONNECTION` -> `cl:new` -> `SV_New_f`)
|
||||
- Related [3a9bfb9](https://github.com/ReHLDS/ReHLDS/commit/3a9bfb9)
|
||||
|
||||
**Full Changelog**: [3.10.0.760...v3.10.0.761](https://github.com/ReHLDS/ReHLDS/compare/3.10.0.760...v3.10.0.761)
|
||||
|
||||
## [`3.10.0.760`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.10.0.760) - 2021-06-23
|
||||
|
||||
### Changed
|
||||
- Changed the destination folder for `Linux build` [(#842)](https://github.com/ReHLDS/ReHLDS/pull/842).
|
||||
- Temporary removed `Windows build`. :warning:
|
||||
|
||||
**Full Changelog**: [3.10.0.759...3.10.0.760](https://github.com/ReHLDS/ReHLDS/compare/3.10.0.759...3.10.0.760)
|
||||
|
||||
## [`3.10.0.759`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.10.0.759) - 2021-06-22
|
||||
|
||||
### Fixed
|
||||
- Fixed volume checking in emit sound [(#341)](https://github.com/ReHLDS/ReHLDS/pull/341)
|
||||
- `static_map.h`: fix lowercase convert [(#806)](https://github.com/ReHLDS/ReHLDS/pull/806)
|
||||
- `SV_New_f`: Deny new connection twice at a time if user messages are received;
|
||||
- `SV_ReadClientMessage`: Fixed empty names on bad read.
|
||||
|
||||
### Changed
|
||||
- `sv_user.cpp`: Small code refactoring [(#810)](https://github.com/ReHLDS/ReHLDS/pull/810)
|
||||
- `ReHLDS API`: Enhanced IGameClient/IRehldsServerData/IRehldsServerStatic interfaces
|
||||
- `sv_main.cpp`: SV_New_f() uses Q_snprintf() unsafe format. #807 [()](https://github.com/ReHLDS/ReHLDS/pull/807)
|
||||
|
||||
**Full Changelog**: [3.9.0.752...3.10.0.759](https://github.com/ReHLDS/ReHLDS/compare/3.9.0.752...3.10.0.759)
|
||||
|
||||
## [`3.9.0.752`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.9.0.752) - 2021-06-14
|
||||
|
||||
### Added
|
||||
- `ReHLDS API`: Add GetEntityInit hook [(#832)](https://github.com/ReHLDS/ReHLDS/pull/832)
|
||||
- Implement CVar `sv_usercmd_custom_random_seed` [(#837)](https://github.com/ReHLDS/ReHLDS/pull/837)
|
||||
|
||||
### Fixed
|
||||
- `HLTV`: Fix crash in ProcessStringCmd [(#838)](https://github.com/ReHLDS/ReHLDS/pull/838)
|
||||
|
||||
### Changed
|
||||
- `SV_ParseMove`, `SV_ParseConsistencyResponse`: check length
|
||||
|
||||
**Full Changelog**: [3.8.0.739...3.9.0.752](https://github.com/ReHLDS/ReHLDS/compare/3.8.0.739...3.9.0.752)
|
||||
|
||||
## [`3.8.0.739`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.8.0.739) - 2021-04-21
|
||||
|
||||
### Added
|
||||
* Added libraries libm/librt built on `GLIBC` `2.11.1` [(#827)](https://github.com/ReHLDS/ReHLDS/pull/827)
|
||||
|
||||
### Fixed
|
||||
* `QuaternionSlerp`: Fixed wrong values [(#763)](https://github.com/ReHLDS/ReHLDS/pull/763)
|
||||
|
||||
### Changed
|
||||
* Updated `Intel C++ Compiler` version `17.0` up to `19.0`
|
||||
|
||||
**Full Changelog**: [3.8.0.723...3.8.0.739](https://github.com/ReHLDS/ReHLDS/compare/3.8.0.723...3.8.0.739)
|
||||
|
||||
## [`3.8.0.723`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.8.0.723) - 2021-03-23
|
||||
|
||||
### Fixed
|
||||
* `CalcSurfaceExtents:` Fixed a fatal error on some maps due loss of floating point
|
||||
* `HLTV:` ExecuteString Fix parser [(#821)](https://github.com/ReHLDS/ReHLDS/pull/821)
|
||||
|
||||
### Changed
|
||||
* `HLTV:` Downgrade GLIBC version
|
||||
|
||||
**Full Changelog**: [3.8.0.715...3.8.0.723](https://github.com/ReHLDS/ReHLDS/compare/3.8.0.715...3.8.0.723)
|
||||
|
||||
## [`3.8.0.715`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.8.0.715) - 2021-03-18
|
||||
|
||||
### Fixed
|
||||
* Make sure the `timer` is high precision [(#799)](https://github.com/ReHLDS/ReHLDS/pull/799)
|
||||
|
||||
**Full Changelog**: [3.8.0.711...3.8.0.715](https://github.com/ReHLDS/ReHLDS/compare/3.8.0.711...3.8.0.715)
|
||||
|
||||
## [`3.8.0.711`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.8.0.711) - 2021-02-06
|
||||
|
||||
### Added
|
||||
* `HLTV`: Added new chatdelay command [(#777)](https://github.com/ReHLDS/ReHLDS/pull/777)
|
||||
* `HLTV`: prevent clients from setting userinfo * keys with setinfo command [(#792)](https://github.com/ReHLDS/ReHLDS/pull/792)
|
||||
* `Cbuf_Execute`: Add checks commented out for multi-lines [(#719)](https://github.com/ReHLDS/ReHLDS/pull/719)
|
||||
|
||||
### Fixed
|
||||
* Fixed local-buffer overrun, may undefined behavior with hitboxes blending or crash (reverse-engineering mistake) [722e19d](https://github.com/ReHLDS/ReHLDS/commit/722e19d)
|
||||
* Fixed dos attack on connection challenges system [(#802)](https://github.com/ReHLDS/ReHLDS/pull/802)
|
||||
* Fixed crash `COM_ListMaps` [(#791)](https://github.com/ReHLDS/ReHLDS/pull/791)
|
||||
|
||||
**Full Changelog**: [3.8.0.702...3.8.0.711](https://github.com/ReHLDS/ReHLDS/compare/3.8.0.702...3.8.0.711)
|
||||
|
||||
## [`3.8.0.702`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.8.0.702) - 2020-11-09
|
||||
|
||||
### Fixed
|
||||
* Fixed crash `MSG_ReadFloat`
|
||||
|
||||
### Changed
|
||||
* **ReHLDS API:** Implemented `SV_ShouldSendConsistencyList`
|
||||
* **ReHLDS API:** Bump minor
|
||||
|
||||
**Full Changelog**: [3.7.0.698...3.8.0.702](https://github.com/ReHLDS/ReHLDS/compare/3.7.0.698...3.8.0.702)
|
||||
|
||||
## [`3.7.0.698`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.7.0.698) - 2020-08-19
|
||||
|
||||
### Added
|
||||
* Graceful shutdown on sigterm [(#776)](https://github.com/ReHLDS/ReHLDS/pull/776)
|
||||
- Add players kick on `SIGINT \ SIGTERM`
|
||||
- Add SIGINT & SIGTERM handling linux console
|
||||
|
||||
### Changed
|
||||
* Changed shutdown method
|
||||
|
||||
**Full Changelog**: [3.7.0.697...3.7.0.698](https://github.com/ReHLDS/ReHLDS/compare/3.7.0.697...3.7.0.698)
|
||||
|
||||
## [`3.7.0.697`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.7.0.697) - 2020-08-10
|
||||
|
||||
### Fixed
|
||||
* **SV_ProcessFile:** Wrap `Con_Printf` in `Con_NetPrintf` to avoid spam in HLDS console
|
||||
|
||||
**Full Changelog**: [3.7.0.696...3.7.0.697](https://github.com/ReHLDS/ReHLDS/compare/3.7.0.696...3.7.0.697)
|
||||
|
||||
## [`3.7.0.696`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.7.0.696) - 2020-05-18
|
||||
|
||||
### Added
|
||||
* Implement `svc_exec` support in the engine and HLTV [(#737)](https://github.com/ReHLDS/ReHLDS/pull/737)
|
||||
- Added `svc_exec` to the list of svc commands in engine
|
||||
- Added `svc_exec` support to HLTV code
|
||||
- Made the engine code forward-compatible with future svc_* additions
|
||||
- Added reserved svc_* slots in the enumerations
|
||||
|
||||
**Full Changelog**: [3.7.0.695...3.7.0.696](https://github.com/ReHLDS/ReHLDS/compare/3.7.0.695...3.7.0.696)
|
||||
|
||||
## [`3.7.0.695`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.7.0.695) - 2020-04-06
|
||||
|
||||
### Fixed
|
||||
* Vulnerability fix WAD part 2
|
||||
- Client-side: Fixed a potential vulnerability from bogus `tempdecal.wad`
|
||||
|
||||
**Full Changelog**: [3.7.0.694...3.7.0.695](https://github.com/ReHLDS/ReHLDS/compare/3.7.0.694...3.7.0.695)
|
||||
|
||||
## [`3.7.0.694`](https://github.com/ReHLDS/ReHLDS/releases/tag/3.7.0.694) - 2020-03-20
|
||||
|
||||
### Fixed
|
||||
* Vulnerability fix WAD part 1
|
||||
- Server-side: Fixed a potential vulnerability from bogus `tempdecal.wad`
|
||||
|
||||
**Full Changelog**: [3.7.0.694](https://github.com/ReHLDS/ReHLDS/commits/3.7.0.694)
|
69
README.md
69
README.md
@ -1,4 +1,4 @@
|
||||
# ReHLDS [](https://github.com/dreamstalker/rehlds/actions/workflows/build.yml) [](https://github.com/dreamstalker/rehlds/releases/latest) []() [](http://isitmaintained.com/project/dreamstalker/rehlds "Percentage of issues still open") [](https://www.gnu.org/licenses/gpl-3.0) <img align="right" src="https://user-images.githubusercontent.com/5860435/111066129-040e5e00-84f0-11eb-9e1f-7a7e8611da2b.png" alt="ReHLDS" />
|
||||
# ReHLDS [](https://github.com/rehlds/ReHLDS/actions/workflows/build.yml) [](https://github.com/rehlds/ReHLDS/releases/latest)  [](http://isitmaintained.com/project/rehlds/ReHLDS "Percentage of issues still open") [](https://www.gnu.org/licenses/gpl-3.0) <img align="right" src="https://user-images.githubusercontent.com/5860435/111066129-040e5e00-84f0-11eb-9e1f-7a7e8611da2b.png" alt="ReHLDS" />
|
||||
Reverse-engineered (and bugfixed) HLDS
|
||||
|
||||
## What is this?
|
||||
@ -8,6 +8,15 @@ Along with reverse engineering, a lot of defects and (potential) bugs were found
|
||||
|
||||
You can try playing on one of many servers that are using ReHLDS: [Game Tracker](http://www.gametracker.com/search/?search_by=server_variable&search_by2=sv_version)
|
||||
|
||||
> [!TIP]
|
||||
> ReHLDS linux-releases now is signed via `GPG`, pubkey is: `63547829004f07716f7be4856c32c4282e60fb67` and could be found at [https://keyserver.ubuntu.com/](https://keyserver.ubuntu.com/pks/lookup?search=63547829004f07716f7be4856c32c4282e60fb67+&fingerprint=on&op=index).
|
||||
>
|
||||
> How to:
|
||||
> 1. [Download](https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x63547829004f07716f7be4856c32c4282e60fb67) `63547829004f07716f7be4856c32c4282e60fb67.asc` key
|
||||
> 2. Import: `gpg --import 63547829004f07716f7be4856c32c4282e60fb67.asc`
|
||||
> 3. Download release `archive` and `.asc` file.
|
||||
> 4. Verify: `gpg --verify some-rehlds.zip.asc some-rehlds.zip`.
|
||||
|
||||
## Goals of the project
|
||||
<ul>
|
||||
<li>Provide more stable (than official) version of Half-Life dedicated server with extended API for mods and plugins</li>
|
||||
@ -15,46 +24,64 @@ You can try playing on one of many servers that are using ReHLDS: [Game Tracker]
|
||||
</ul>
|
||||
|
||||
## How can use it?
|
||||
ReHLDS is fully compatible with latest official HLDS downloaded by steamcmd. All you have to do is to download rehlds binaries and replace original swds.dll/engine_i486.so. For windows you can also copy a swds.pdb file with a debug information.
|
||||
<br /><b>Warning!</b> ReHLDS is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool.
|
||||
ReHLDS is fully compatible with the official pre-anniversary edition of HLDS (engine version <= 8684) downloaded by steamcmd. All you have to do is to download ReHLDS binaries and replace original swds.dll/engine_i486.so. For windows you can also copy a swds.pdb file with a debug information.
|
||||
|
||||
> [!CAUTION]
|
||||
> ReHLDS is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool.
|
||||
|
||||
#### Downloading HLDS via steamcmd
|
||||
|
||||
```
|
||||
app_set_config 90 mod cstrike
|
||||
app_update 90 -beta steam_legacy validate
|
||||
```
|
||||
|
||||
## Downloads
|
||||
* [Release builds](https://github.com/dreamstalker/rehlds/releases)
|
||||
* [Dev builds](https://github.com/dreamstalker/rehlds/actions/workflows/build.yml)
|
||||
* [Release builds](https://github.com/rehlds/ReHLDS/releases)
|
||||
* [Dev builds](https://github.com/rehlds/ReHLDS/actions/workflows/build.yml)
|
||||
|
||||
ReHLDS binaries require `SSE`, `SSE2` and `SSE3` instruction sets to run and can benefit from `SSE4.1` and `SSE4.2`
|
||||
|
||||
<b>Warning!</b> ReHLDS is not binary compatible with original hlds since it's compiled with compilers other than ones used for original hlds.
|
||||
This means that plugins that do binary code analysis (Orpheu for example) probably will not work with rehlds.
|
||||
This means that plugins that do binary code analysis (Orpheu for example) probably will not work with ReHLDS.
|
||||
|
||||
## Configuring
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
<ul>
|
||||
<li>listipcfgfile <filename> // File for permanent ip bans. Default: listip.cfg
|
||||
<li>syserror_logfile <filename> // File for the system error log. Default: sys_error.log
|
||||
<li>sv_auto_precache_sounds_in_models <1|0> // Automatically precache sounds attached to models. Deault: 0
|
||||
<li>sv_delayed_spray_upload <1|0> // Upload custom sprays after entering the game instead of when connecting. It increases upload speed. Default: 0
|
||||
<li>sv_echo_unknown_cmd <1|0> // Echo in the console when trying execute an unknown command. Default: 0
|
||||
<li>sv_rcon_condebug <1|0> // Print rcon debug in the console. Default: 1
|
||||
<li>sv_force_ent_intersection <1|0> // In a 3-rd party plugins used to force colliding of SOLID_SLIDEBOX entities. Default: 0
|
||||
<li>sv_rehlds_force_dlmax <1|0> // Force a client's cl_dlmax cvar to 1024. It avoids an excessive packets fragmentation. Default: 0
|
||||
<li>sv_rehlds_hull_centering <1|0> // Use center of hull instead of corner. Default: 0
|
||||
<li>listipcfgfile <filename> // File for permanent ip bans. Default: listip.cfg
|
||||
<li>syserror_logfile <filename> // File for the system error log. Default: sys_error.log
|
||||
<li>sv_auto_precache_sounds_in_models <1|0> // Automatically precache sounds attached to models. Deault: 0
|
||||
<li>sv_delayed_spray_upload <1|0> // Upload custom sprays after entering the game instead of when connecting. It increases upload speed. Default: 0
|
||||
<li>sv_echo_unknown_cmd <1|0> // Echo in the console when trying execute an unknown command. Default: 0
|
||||
<li>sv_rcon_condebug <1|0> // Print rcon debug in the console. Default: 1
|
||||
<li>sv_force_ent_intersection <1|0> // In a 3-rd party plugins used to force colliding of SOLID_SLIDEBOX entities. Default: 0
|
||||
<li>sv_rehlds_force_dlmax <1|0> // Force a client's cl_dlmax cvar to 1024. It avoids an excessive packets fragmentation. Default: 0
|
||||
<li>sv_rehlds_hull_centering <1|0> // Use center of hull instead of corner. Default: 0
|
||||
<li>sv_rehlds_movecmdrate_max_avg // Max average level of 'move' cmds for ban. Default: 400
|
||||
<li>sv_rehlds_movecmdrate_avg_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
|
||||
<li>sv_rehlds_movecmdrate_max_burst // Max burst level of 'move' cmds for ban. Default: 2500
|
||||
<li>sv_rehlds_movecmdrate_burst_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
|
||||
<li>sv_rehlds_send_mapcycle <1|0> // Send mapcycle.txt in serverinfo message (HLDS behavior, but it is unused on the client). Default: 0
|
||||
<li>sv_rehlds_send_mapcycle <1|0> // Send mapcycle.txt in serverinfo message (HLDS behavior, but it is unused on the client). Default: 0
|
||||
<li>sv_rehlds_stringcmdrate_max_avg // Max average level of 'string' cmds for ban. Default: 80
|
||||
<li>sv_rehlds_stringcmdrate_avg_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
|
||||
<li>sv_rehlds_stringcmdrate_max_burst // Max burst level of 'string' cmds for ban. Default: 400
|
||||
<li>sv_rehlds_stringcmdrate_burst_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
|
||||
<li>sv_rehlds_userinfo_transmitted_fields // Userinfo fields only with these keys will be transmitted to clients via network. If not set then all fields will be transmitted (except prefixed with underscore). Each key must be prefixed by backslash, for example "\name\model\*sid\*hltv\bottomcolor\topcolor". See [wiki](https://github.com/dreamstalker/rehlds/wiki/Userinfo-keys) to collect sufficient set of keys for your server. Default: ""
|
||||
<li>sv_rehlds_userinfo_transmitted_fields // Userinfo fields only with these keys will be transmitted to clients via network. If not set then all fields will be transmitted (except prefixed with underscore). Each key must be prefixed by backslash, for example "\name\model\*sid\*hltv\bottomcolor\topcolor". See [wiki](https://github.com/rehlds/ReHLDS/wiki/Userinfo-keys) to collect sufficient set of keys for your server. Default: ""
|
||||
<li>sv_rehlds_attachedentities_playeranimationspeed_fix // Fixes bug with gait animation speed increase when player has some attached entities (aiments). Can cause animation lags when cl_updaterate is low. Default: 0
|
||||
<li>sv_rehlds_maxclients_from_single_ip // Limit number of connections at the same time from single IP address, not confuse to already connected players. Default: 5
|
||||
<li>sv_rehlds_local_gametime <1|0> // A feature of local gametime which decrease "lags" if you run same map for a long time. Default: 0
|
||||
<li>sv_rehlds_local_gametime <1|0> // A feature of local gametime which decrease "lags" if you run same map for a long time. Default: 0
|
||||
<li>sv_use_entity_file // Use custom entity file for a map. Path to an entity file will be "maps/[map name].ent". 0 - use original entities. 1 - use .ent files from maps directory. 2 - use .ent files from maps directory and create new .ent file if not exist.
|
||||
<li>sv_usercmd_custom_random_seed // When enabled server will populate an additional random seed independent of the client. Default: 0
|
||||
<li>sv_net_incoming_decompression <1|0> // When enabled server will decompress of incoming compressed file transfer payloads. Default: 1
|
||||
<li>sv_net_incoming_decompression_max_ratio <0|100> // Sets the max allowed ratio between compressed and uncompressed data for file transfer. (A ratio close to 90 indicates large uncompressed data with low entropy) Default: 80.0
|
||||
<li>sv_net_incoming_decompression_max_size <16|65536> // Sets the max allowed size for decompressed file transfer data. Default: 65536 bytes
|
||||
<li>sv_net_incoming_decompression_min_failures <0|10> // Sets the min number of decompression failures required before a player's connection is flagged for potential punishment. Default: 4
|
||||
<li>sv_net_incoming_decompression_max_failures <0|10> // Sets the max number of decompression failures allowed within a specified time window before action is taken against the player. Default: 10
|
||||
<li>sv_net_incoming_decompression_min_failuretime: <0.1|10.0> // Sets the min time in secs within which decompression failures are tracked to determine if the player exceeds the failure thresholds. Default: 0.1
|
||||
<li>sv_net_incoming_decompression_punish // Time in minutes for which the player will be banned for malformed/abnormal bzip2 fragments (0 - Permanent, use a negative number for a kick). Default: -1
|
||||
<li>sv_tags <comma-delimited string list of tags> // Sets a string defining the "gametags" for this server, this is optional, but if it is set it allows users/scripts to filter in the matchmaking/server-browser interfaces based on the value. Default: ""
|
||||
<li>sv_filterban <-1|0|1>// Set packet filtering by IP mode. -1 - All players will be rejected without any exceptions. 0 - No checks will happen. 1 - All incoming players will be checked if they're IP banned (if they have an IP filter entry), if they are, they will be kicked. Default: 1
|
||||
</ul>
|
||||
</details>
|
||||
|
||||
@ -62,11 +89,14 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
|
||||
<ul>
|
||||
<li>rescount // Prints the total count of precached resources in the server console
|
||||
<li>reslist <sound | model | decal | generic | event> // Separately prints the details of the precached resources for sounds, models, decals, generic and events in server console. Useful for managing resources and dealing with the goldsource precache limits.
|
||||
<li>rcon_adduser <ipaddress/CIDR> // Add a new IP address or CIDR range to RCON user list (This command adds a new IP address to the RCON user list. The specified IP or CIDR range is granted privileged access to server console. Without any Rcon users, access is allowed to anyone with a valid password)</li>
|
||||
<li>rcon_deluser <ipaddress> {removeAll} // Remove an IP address or CIDR range from RCON user list</li>
|
||||
<li>rcon_users // List all IP addresses and CIDR ranges in RCON user list</li>
|
||||
</ul>
|
||||
|
||||
## Build instructions
|
||||
### Checking requirements
|
||||
There are several software requirements for building rehlds:
|
||||
There are several software requirements for building ReHLDS:
|
||||
|
||||
#### Windows
|
||||
<pre>
|
||||
@ -117,6 +147,7 @@ sudo apt-get update
|
||||
sudo apt-get install -y gcc-multilib g++-multilib
|
||||
sudo apt-get install -y build-essential
|
||||
sudo apt-get install -y libc6-dev libc6-dev-i386
|
||||
sudo apt-get install -y cmake
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
|
@ -182,6 +182,7 @@ set(ENGINE_SRCS
|
||||
rehlds/public_amalgamation.cpp
|
||||
rehlds/rehlds_api_impl.cpp
|
||||
rehlds/rehlds_interfaces_impl.cpp
|
||||
rehlds/rehlds_messagemngr_impl.cpp
|
||||
rehlds/rehlds_security.cpp
|
||||
)
|
||||
|
||||
|
@ -170,7 +170,7 @@ byte *BSPModel::LeafPVS(mleaf_t *leaf)
|
||||
|
||||
byte *BSPModel::DecompressVis(unsigned char *in)
|
||||
{
|
||||
static unsigned char decompressed[MODEL_MAX_PVS];
|
||||
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
|
||||
if (in == nullptr) {
|
||||
return m_novis;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "l_studio.h"
|
||||
#include "edict.h"
|
||||
#include "bspfile.h"
|
||||
|
||||
// values for model_t's needload
|
||||
#define NL_PRESENT 0
|
||||
@ -87,9 +88,7 @@ private:
|
||||
|
||||
protected:
|
||||
model_t m_model;
|
||||
|
||||
enum { MODEL_MAX_PVS = 1024 };
|
||||
byte m_novis[MODEL_MAX_PVS];
|
||||
byte m_novis[MAX_MAP_LEAFS / 8];
|
||||
byte *m_base;
|
||||
|
||||
int m_visframecount;
|
||||
|
@ -1060,15 +1060,18 @@ void World::ParseClientData(BitBuffer *stream, unsigned int deltaSeqNr, BitBuffe
|
||||
}
|
||||
}
|
||||
|
||||
// When a delta command is received from the server
|
||||
// We need to grab the entity # out of it any the bit settings, too
|
||||
int World::ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &numbase, bool &newbl, int &newblindex, bool full, int &offset)
|
||||
{
|
||||
int num;
|
||||
bool isdelta, isnext;
|
||||
bool isdelta;
|
||||
|
||||
offset = 0;
|
||||
custom = false;
|
||||
newbl = false;
|
||||
newbl = false;
|
||||
|
||||
// This full update (non-delta)
|
||||
if (full)
|
||||
{
|
||||
isdelta = stream->ReadBit() ? true : false;
|
||||
@ -1077,6 +1080,8 @@ int World::ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &
|
||||
else
|
||||
{
|
||||
isdelta = false;
|
||||
|
||||
// the entity was removed from server or not
|
||||
remove = stream->ReadBit() ? true : false;
|
||||
}
|
||||
|
||||
@ -1088,11 +1093,11 @@ int World::ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &
|
||||
{
|
||||
if (stream->ReadBit())
|
||||
{
|
||||
num = stream->ReadBits(11);
|
||||
num = stream->ReadBits(MAX_EDICT_BITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
int delta = stream->ReadBits(6);
|
||||
int delta = stream->ReadBits(DELTA_OFFSET_BITS);
|
||||
num = delta + numbase;
|
||||
}
|
||||
}
|
||||
@ -1105,20 +1110,19 @@ int World::ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &
|
||||
|
||||
if (m_MaxInstanced_BaseLine)
|
||||
{
|
||||
isnext = stream->ReadBit() ? true : false;
|
||||
if (isnext)
|
||||
newbl = stream->ReadBit() ? true : false;
|
||||
|
||||
if (newbl)
|
||||
{
|
||||
newbl = true;
|
||||
newblindex = stream->ReadBits(6);
|
||||
newblindex = stream->ReadBits(MAX_BASELINE_BITS);
|
||||
}
|
||||
}
|
||||
|
||||
if (full && !newbl)
|
||||
{
|
||||
isnext = stream->ReadBit() ? true : false;
|
||||
if (isnext)
|
||||
if (stream->ReadBit() != 0)
|
||||
{
|
||||
offset = stream->ReadBits(6);
|
||||
offset = stream->ReadBits(MAX_BASELINE_BITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1152,10 +1156,10 @@ int World::CompressFrame(frame_t *from, BitBuffer *stream)
|
||||
unsigned char *start = stream->CurrentByte();
|
||||
for (auto entnum = 0u; entnum < from->entitynum; entnum++)
|
||||
{
|
||||
header.num = entities[entnum].number;
|
||||
header.custom = (entities[entnum].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.num = entities[entnum].number;
|
||||
header.custom = (entities[entnum].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.newblindex = 0;
|
||||
header.newbl = false;
|
||||
header.newbl = false;
|
||||
|
||||
entity_state_t *baseline = &m_BaseLines[header.num];
|
||||
header.offset = FindBestBaseline(entnum, &baseline, entities, header.num, header.custom);
|
||||
@ -1273,26 +1277,25 @@ bool World::GetDeltaFromCache(unsigned int seqNr, unsigned int deltaNr, BitBuffe
|
||||
return 0;
|
||||
}
|
||||
|
||||
// marker an entity index that not in an old packet (for svc_packetentities)
|
||||
#define ENTITY_SENTINEL 9999
|
||||
|
||||
void World::WritePacketEntities(BitBuffer *stream, frame_t *frame, frame_t *deltaframe)
|
||||
{
|
||||
int oldmax;
|
||||
int oldindex;
|
||||
int newindex;
|
||||
int newnum;
|
||||
int oldnum;
|
||||
entity_state_t *frameEntities;
|
||||
entity_state_t *deltaEntities;
|
||||
unsigned int oldmax, oldindex, newindex;
|
||||
int newnum, oldnum;
|
||||
entity_state_t *frameEntities, *deltaEntities;
|
||||
|
||||
deltacallback_t header;
|
||||
header.instanced_baseline = (m_MaxInstanced_BaseLine > 0) ? true : false;
|
||||
header.num = 0;
|
||||
header.offset = 0;
|
||||
header.numbase = 0;
|
||||
header.num = 0;
|
||||
header.offset = 0;
|
||||
header.numbase = 0;
|
||||
header.newblindex = 0;
|
||||
header.full = false;
|
||||
header.newbl = false;
|
||||
header.remove = false;
|
||||
header.custom = false;
|
||||
header.newbl = false;
|
||||
header.remove = false;
|
||||
header.full = false;
|
||||
header.custom = false;
|
||||
|
||||
if (frame->delta || deltaframe->delta) {
|
||||
m_System->Errorf("World::WritePacketEntities: frame and delta frame must be uncompressed.\n");
|
||||
@ -1302,79 +1305,82 @@ void World::WritePacketEntities(BitBuffer *stream, frame_t *frame, frame_t *delt
|
||||
m_Delta.SetTime(frame->time);
|
||||
|
||||
oldmax = deltaframe->entitynum;
|
||||
newnum = 0; // index in frame->entities
|
||||
oldnum = 0; // index in deltaframe->entities
|
||||
newindex = 0; // index in frame->entities
|
||||
oldindex = 0; // index in deltaframe->entities
|
||||
|
||||
frameEntities = (entity_state_t *)frame->entities;
|
||||
deltaEntities = (entity_state_t *)deltaframe->entities;
|
||||
|
||||
stream->StartBitMode();
|
||||
while (true)
|
||||
|
||||
while (newindex < frame->entitynum || oldindex < oldmax)
|
||||
{
|
||||
if ((unsigned)newnum < frame->entitynum)
|
||||
{
|
||||
newindex = frameEntities[newnum].number;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oldnum >= oldmax)
|
||||
break;
|
||||
newnum = (newindex >= frame->entitynum) ? ENTITY_SENTINEL : frameEntities[newindex].number;
|
||||
oldnum = (oldindex >= oldmax) ? ENTITY_SENTINEL : deltaEntities[oldindex].number;
|
||||
|
||||
// TODO: Unreachable code
|
||||
if ((unsigned)newnum < frame->entitynum)
|
||||
newindex = frameEntities[newnum].number;
|
||||
else
|
||||
newindex = 9999;
|
||||
}
|
||||
|
||||
if (oldnum < oldmax)
|
||||
oldindex = deltaEntities[oldnum].number;
|
||||
else
|
||||
oldindex = 9999;
|
||||
|
||||
if (newindex == oldindex)
|
||||
// this is a delta update of the entity from previous position
|
||||
if (newnum == oldnum)
|
||||
{
|
||||
header.custom = (frameEntities[newnum].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.num = newindex;
|
||||
// delta update from old position
|
||||
// because the force parm is false, this will not result
|
||||
// in any bytes being emitted if the entity has not changed at all
|
||||
// note that players are always 'newentities', this updates their oldorigin always
|
||||
// and prevents warping
|
||||
|
||||
header.custom = (frameEntities[newindex].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.num = newnum;
|
||||
header.newblindex = 0;
|
||||
header.newbl = false;
|
||||
header.remove = false;
|
||||
header.newbl = false;
|
||||
header.remove = false;
|
||||
|
||||
delta_t *delta = GetDeltaEncoder(newindex, header.custom);
|
||||
m_Delta.WriteDelta(stream, (byte *)&deltaEntities[oldnum], (byte *)&frameEntities[newnum], true, delta, &header);
|
||||
delta_t *delta = GetDeltaEncoder(newnum, header.custom);
|
||||
m_Delta.WriteDelta(stream, (byte *)&deltaEntities[oldindex], (byte *)&frameEntities[newindex], false, delta, &header);
|
||||
|
||||
oldnum++;
|
||||
newnum++;
|
||||
oldindex++;
|
||||
newindex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newindex >= oldindex)
|
||||
// Figure out how we want to update the entity
|
||||
// This is a new entity, send it from the baseline
|
||||
if (newnum < oldnum)
|
||||
{
|
||||
if (newindex > oldindex)
|
||||
{
|
||||
header.num = oldindex;
|
||||
header.remove = true;
|
||||
header.newbl = false;
|
||||
header.newblindex = 0;
|
||||
//
|
||||
// If the entity was not in the old packet (oldnum == 9999),
|
||||
// then delta from the baseline since this is a new entity
|
||||
header.custom = (frameEntities[newindex].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.num = newnum;
|
||||
header.newblindex = 0;
|
||||
header.newbl = false;
|
||||
header.remove = false;
|
||||
|
||||
m_Delta.WriteHeader(stream, &header);
|
||||
++oldnum;
|
||||
}
|
||||
delta_t *delta = GetDeltaEncoder(newnum, header.custom);
|
||||
m_Delta.WriteDelta(stream, (byte *)&m_BaseLines[newnum], (byte *)&frameEntities[newindex], true, delta, &header);
|
||||
newindex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
header.custom = (frameEntities[newnum].entityType & ENTITY_BEAM) == ENTITY_BEAM;
|
||||
header.newblindex = 0;
|
||||
header.num = newindex;
|
||||
header.remove = false;
|
||||
header.newbl = false;
|
||||
// the old entity isn't present in the new message
|
||||
if (newnum > oldnum)
|
||||
{
|
||||
//
|
||||
// If the entity was in the old list, but is not in the new list (newindex == 9999),
|
||||
// then construct a special remove message
|
||||
|
||||
delta_t *delta = GetDeltaEncoder(newindex, header.custom);
|
||||
m_Delta.WriteDelta(stream, (byte *)&m_BaseLines[oldnum], (byte *)&frameEntities[newnum], true, delta, &header);
|
||||
newnum++;
|
||||
header.num = oldnum;
|
||||
header.newblindex = 0;
|
||||
header.newbl = false;
|
||||
header.remove = true; // tell the client that entity was removed from server
|
||||
|
||||
m_Delta.WriteHeader(stream, &header);
|
||||
oldindex++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// No more entities.. (end of packet entities)
|
||||
stream->WriteBits(0, 16);
|
||||
|
||||
stream->EndBitMode();
|
||||
}
|
||||
|
||||
@ -1467,13 +1473,14 @@ double World::GetTime()
|
||||
return m_WorldTime;
|
||||
}
|
||||
|
||||
// An svc_packetentities has just been parsed, deal with the rest of the data stream
|
||||
bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsigned int from)
|
||||
{
|
||||
int newnum, oldnum;
|
||||
int oldindex, newindex;
|
||||
int newnum, oldnum;
|
||||
unsigned int oldindex, newindex;
|
||||
|
||||
bool remove, custom, newbl;
|
||||
int newblindex, numbase, offset;
|
||||
bool remove, custom, newbl;
|
||||
int newblindex, numbase, offset;
|
||||
|
||||
frame_t deltaFrame;
|
||||
if (!GetUncompressedFrame(from, &deltaFrame)) {
|
||||
@ -1485,11 +1492,15 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
|
||||
oldindex = 0;
|
||||
newindex = 0;
|
||||
|
||||
remove = false;
|
||||
custom = false;
|
||||
newbl = false;
|
||||
numbase = 0;
|
||||
newblindex = 0;
|
||||
numbase = 0;
|
||||
newbl = false;
|
||||
remove = false;
|
||||
custom = false;
|
||||
|
||||
//
|
||||
// Parse uncompress entities
|
||||
//
|
||||
|
||||
m_Delta.SetTime(frame->time);
|
||||
stream->StartBitMode();
|
||||
@ -1500,60 +1511,75 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
|
||||
while (stream->PeekBits(16))
|
||||
{
|
||||
newnum = ParseDeltaHeader(stream, remove, custom, numbase, newbl, newblindex, false, offset);
|
||||
oldnum = (oldindex >= deltaFrame.entitynum) ? ENTITY_SENTINEL : deltaEntity[oldindex].number;
|
||||
|
||||
if ((unsigned)oldindex < deltaFrame.entitynum)
|
||||
oldnum = deltaEntity[oldindex].number;
|
||||
else
|
||||
oldnum = 9999;
|
||||
|
||||
while (newnum > oldnum)
|
||||
while (oldnum < newnum)
|
||||
{
|
||||
//
|
||||
// one or more entities from the old packet are unchanged
|
||||
|
||||
if (newindex >= MAX_PACKET_ENTITIES)
|
||||
{
|
||||
m_System->DPrintf("WARNING!World::UncompressEntitiesFromStream: newindex >= MAX_PACKET_ENTITIES.\n");
|
||||
stream->m_Overflowed = true;
|
||||
}
|
||||
|
||||
// copy one of the old entities over to the new packet unchanged
|
||||
Q_memcpy(&entity[newindex], &deltaEntity[oldindex], sizeof(entity[newindex]));
|
||||
|
||||
newindex++;
|
||||
oldindex++;
|
||||
|
||||
if ((unsigned)oldindex < deltaFrame.entitynum)
|
||||
oldnum = deltaEntity[oldindex].number;
|
||||
else
|
||||
oldnum = 9999;
|
||||
// lookup next index
|
||||
oldnum = (oldindex >= deltaFrame.entitynum) ? ENTITY_SENTINEL : deltaEntity[oldindex].number;
|
||||
}
|
||||
|
||||
if (newnum >= oldnum)
|
||||
// delta from previous state
|
||||
if (newnum == oldnum)
|
||||
{
|
||||
if (newnum == oldnum)
|
||||
if (remove)
|
||||
{
|
||||
if (remove)
|
||||
{
|
||||
++oldindex;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity[newindex].entityType = custom ? ENTITY_BEAM : ENTITY_NORMAL;
|
||||
|
||||
delta_t *delta = GetDeltaEncoder(newnum, custom);
|
||||
m_Delta.ParseDelta(stream, (byte *)&deltaEntity[oldindex], (byte *)&entity[newindex], delta);
|
||||
|
||||
entity[newindex].number = newnum;
|
||||
++newindex;
|
||||
++oldindex;
|
||||
}
|
||||
oldindex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Insert new the entity to frame
|
||||
|
||||
entity[newindex].entityType = custom ? ENTITY_BEAM : ENTITY_NORMAL;
|
||||
|
||||
delta_t *delta = GetDeltaEncoder(newnum, custom);
|
||||
m_Delta.ParseDelta(stream, (byte *)&deltaEntity[oldindex], (byte *)&entity[newindex], delta);
|
||||
|
||||
entity[newindex].number = newnum;
|
||||
newindex++;
|
||||
oldindex++;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (!remove)
|
||||
|
||||
// Figure out how we want to update the entity
|
||||
// This is a new entity, sent it from the baseline
|
||||
if (newnum < oldnum)
|
||||
{
|
||||
//
|
||||
// If the entity was not in the old packet (oldnum == 9999),
|
||||
// then delta from the baseline since this is a new entity
|
||||
|
||||
if (remove)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newindex >= MAX_PACKET_ENTITIES)
|
||||
{
|
||||
m_System->DPrintf("World::UncompressEntitiesFromStream: newindex >= MAX_PACKET_ENTITIES.\n");
|
||||
stream->m_Overflowed = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Insert new the entity to frame
|
||||
|
||||
entity_state_t *baseline;
|
||||
if (newbl)
|
||||
{
|
||||
@ -1574,9 +1600,12 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
|
||||
m_Delta.ParseDelta(stream, (byte *)baseline, (byte *)&entity[newindex], delta);
|
||||
entity[newindex].number = newnum;
|
||||
newindex++;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// peek bit == 0 end of packet entities
|
||||
if (stream->ReadShort())
|
||||
{
|
||||
m_System->DPrintf("WARNING! World::UncompressEntitiesFromStream: missing end tag.\n");
|
||||
@ -1585,7 +1614,10 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
|
||||
|
||||
stream->EndBitMode();
|
||||
|
||||
while ((unsigned)oldindex < deltaFrame.entitynum)
|
||||
// Copy all the rest of the entities from the old packet
|
||||
//
|
||||
|
||||
while (oldindex != ENTITY_SENTINEL && oldindex < deltaFrame.entitynum)
|
||||
{
|
||||
if (newindex >= MAX_PACKET_ENTITIES)
|
||||
{
|
||||
@ -1593,33 +1625,22 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
|
||||
stream->m_Overflowed = true;
|
||||
}
|
||||
|
||||
// copy everything to the new state we are delta'ing
|
||||
Q_memcpy(&entity[newindex], &deltaEntity[oldindex], sizeof(entity[newindex]));
|
||||
newindex++;
|
||||
oldindex++;
|
||||
}
|
||||
|
||||
if (newindex != frame->entitynum) {
|
||||
m_System->DPrintf("WARNING! World::UncompressEntitiesFromStream: newindex != frame->entitynum.\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream)
|
||||
{
|
||||
int num;
|
||||
int newindex = 0;
|
||||
int entnum = frame->entitynum;
|
||||
int num, newindex = 0;
|
||||
int entnum = frame->entitynum;
|
||||
entity_state_t *baseline;
|
||||
bool remove, custom, newbl;
|
||||
int newblindex, numbase, offset;
|
||||
|
||||
newblindex = 0;
|
||||
numbase = 0;
|
||||
|
||||
remove = false;
|
||||
custom = false;
|
||||
newbl = false;
|
||||
bool remove = false, custom = false, newbl = false;
|
||||
int newblindex = 0, numbase = 0, offset;
|
||||
|
||||
entity_state_t *entities = (entity_state_t *)frame->entities;
|
||||
m_Delta.SetTime(frame->time);
|
||||
@ -2240,8 +2261,8 @@ void World::RearrangeFrame(frame_t *frame, int seqNrOffset, float timeOffset)
|
||||
BitBuffer tempStream(frame->entities, frame->entitiesSize);
|
||||
Q_memset(frame->entities, 0, frame->entitiesSize);
|
||||
|
||||
int newsize = CompressFrame(&fullFrame, &tempStream);
|
||||
if ((unsigned)newsize > frame->entitiesSize || tempStream.IsOverflowed()) {
|
||||
unsigned int newsize = CompressFrame(&fullFrame, &tempStream);
|
||||
if (newsize > frame->entitiesSize || tempStream.IsOverflowed()) {
|
||||
m_System->Printf("WARNING! World::RearrangeFrame: wrong entities size (%i != %i).\n", frame->entitiesSize, newsize);
|
||||
return;
|
||||
}
|
||||
|
@ -39,6 +39,9 @@
|
||||
#define RESOURCE_INDEX_BITS 12
|
||||
#define RESOURCE_MAX_COUNT (1 << RESOURCE_INDEX_BITS)
|
||||
|
||||
#define MAX_BASELINE_BITS 6
|
||||
#define MAX_BASELINES (1 << MAX_BASELINE_BITS)
|
||||
|
||||
class World: public IWorld, public BaseSystemModule {
|
||||
public:
|
||||
World() {}
|
||||
|
@ -98,6 +98,9 @@
|
||||
// Max size of udp packet payload
|
||||
#define MAX_UDP_PACKET 4010 // 9 bytes SPLITHEADER + 4000 payload?
|
||||
|
||||
#define DELTA_OFFSET_BITS 6
|
||||
#define DELTA_OFFSET_MAX ((1 << DELTA_OFFSET_BITS) - 1)
|
||||
|
||||
enum svc_commands_e
|
||||
{
|
||||
svc_bad,
|
||||
|
@ -195,7 +195,7 @@ bool ObjectDictionary::RemoveIndex(int index, bool freeObjectMemory)
|
||||
CheckSize();
|
||||
ClearCache();
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectDictionary::RemoveIndexRange(int minIndex, int maxIndex)
|
||||
|
@ -74,6 +74,7 @@
|
||||
// SV_EmitSound2 flags
|
||||
#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS
|
||||
#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker
|
||||
#define SND_EMIT2_USE_ORIGIN (1<<2) // use given origin instead of entity origin
|
||||
|
||||
// Engine edict->spawnflags
|
||||
#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file
|
||||
|
@ -47,4 +47,16 @@ struct cvar_listener_t
|
||||
const char *name;
|
||||
};
|
||||
|
||||
typedef void (*pfnCvar_HookVariable_t) (cvar_t *pCvar);
|
||||
|
||||
struct cvarhook_t
|
||||
{
|
||||
pfnCvar_HookVariable_t hook;
|
||||
|
||||
cvar_t *cvar;
|
||||
cvarhook_t *next;
|
||||
};
|
||||
|
||||
qboolean Cvar_HookVariable(const char *var_name, cvarhook_t *pHook);
|
||||
|
||||
#endif // CVARDEF_H
|
||||
|
@ -29,6 +29,9 @@
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
// The maximum user messages
|
||||
#define MAX_USERMESSAGES 256
|
||||
|
||||
// user message
|
||||
#define MAX_USER_MSG_DATA 192
|
||||
|
||||
|
@ -235,7 +235,8 @@ void Cbuf_Execute(void)
|
||||
}
|
||||
|
||||
// execute the command line
|
||||
Cmd_ExecuteString(line, src_command);
|
||||
if (line[0])
|
||||
Cmd_ExecuteString(line, src_command);
|
||||
|
||||
if (cmd_wait)
|
||||
{
|
||||
@ -406,17 +407,12 @@ void Cmd_Exec_f(void)
|
||||
else
|
||||
{
|
||||
char *pszDataPtr = configContents;
|
||||
while (true)
|
||||
while (pszDataPtr && *pszDataPtr)
|
||||
{
|
||||
Cbuf_Execute(); // TODO: This doesn't obey the rule to first execute commands from the file, and then the others in the buffer
|
||||
pszDataPtr = COM_ParseLine(pszDataPtr); // TODO: COM_ParseLine can be const char*
|
||||
|
||||
if (com_token[0] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Cbuf_InsertTextLines(com_token);
|
||||
if (com_token[0])
|
||||
Cbuf_InsertTextLines(com_token);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,17 +31,17 @@
|
||||
unsigned char *gPAS;
|
||||
unsigned char *gPVS;
|
||||
int gPVSRowBytes;
|
||||
unsigned char mod_novis[MODEL_MAX_PVS];
|
||||
unsigned char mod_novis[MAX_MAP_LEAFS / 8];
|
||||
|
||||
void Mod_Init(void)
|
||||
{
|
||||
SW_Mod_Init();
|
||||
Q_memset(mod_novis, 255, MODEL_MAX_PVS);
|
||||
Q_memset(mod_novis, 0xFF, MAX_MAP_LEAFS / 8);
|
||||
}
|
||||
|
||||
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model)
|
||||
{
|
||||
static unsigned char decompressed[MODEL_MAX_PVS];
|
||||
static unsigned char decompressed[MAX_MAP_LEAFS / 8];
|
||||
|
||||
if (in == NULL)
|
||||
{
|
||||
|
@ -29,15 +29,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "maintypes.h"
|
||||
#include "model.h"
|
||||
|
||||
// Looks like no more than 8096 visibility leafs per world model
|
||||
const int MODEL_MAX_PVS = 1024;
|
||||
|
||||
extern unsigned char *gPAS;
|
||||
extern unsigned char *gPVS;
|
||||
extern int gPVSRowBytes;
|
||||
extern unsigned char mod_novis[MODEL_MAX_PVS];
|
||||
|
||||
void Mod_Init(void);
|
||||
unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model);
|
||||
|
@ -586,9 +586,9 @@ void MSG_WriteBitData(void *src, int length)
|
||||
|
||||
void MSG_WriteBitAngle(float fAngle, int numbits)
|
||||
{
|
||||
if (numbits >= 32)
|
||||
if (numbits > 22)
|
||||
{
|
||||
Sys_Error("%s: Can't write bit angle with 32 bits precision\n", __func__);
|
||||
Sys_Error("%s: Can't write bit angle with more than 22 bits precision\n", __func__);
|
||||
}
|
||||
|
||||
uint32 shift = (1 << numbits);
|
||||
@ -1978,6 +1978,34 @@ NOXREF int COM_ExpandFilename(char *filename)
|
||||
return *filename != 0;
|
||||
}
|
||||
|
||||
// small helper function shared by lots of modules
|
||||
qboolean COM_IsAbsolutePath(const char *pStr)
|
||||
{
|
||||
if (strchr(pStr, ':') || pStr[0] == '/' || pStr[0] == '\\')
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
qboolean COM_IsValidPath(const char *pszFilename)
|
||||
{
|
||||
if (!pszFilename)
|
||||
return FALSE;
|
||||
|
||||
if (Q_strlen(pszFilename) <= 0 ||
|
||||
Q_strstr(pszFilename, "\\\\") || // to protect network paths
|
||||
Q_strstr(pszFilename, ":") || // to protect absolute paths
|
||||
Q_strstr(pszFilename, "..") || // to protect relative paths
|
||||
Q_strstr(pszFilename, "~") ||
|
||||
Q_strstr(pszFilename, "\n") || // CFileSystem_Stdio::FS_fopen doesn't allow this
|
||||
Q_strstr(pszFilename, "\r")) // CFileSystem_Stdio::FS_fopen doesn't allow this
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int EXT_FUNC COM_FileSize(const char *filename)
|
||||
{
|
||||
FileHandle_t fp;
|
||||
|
@ -187,6 +187,8 @@ void COM_CreatePath(char *path);
|
||||
NOXREF void COM_CopyFile(char *netpath, char *cachepath);
|
||||
NOXREF int COM_ExpandFilename(char *filename);
|
||||
int COM_FileSize(const char *filename);
|
||||
qboolean COM_IsAbsolutePath(const char *pStr);
|
||||
qboolean COM_IsValidPath(const char *pszFilename);
|
||||
unsigned char *COM_LoadFile(const char *path, int usehunk, int *pLength);
|
||||
void COM_FreeFile(void *buffer);
|
||||
void COM_CopyFileChunk(FileHandle_t dst, FileHandle_t src, int nSize);
|
||||
|
@ -32,7 +32,8 @@
|
||||
All cvar names are case insensitive! Values not.
|
||||
*/
|
||||
|
||||
cvar_t *cvar_vars;
|
||||
cvar_t *cvar_vars = NULL;
|
||||
cvarhook_t *cvar_hooks = NULL;
|
||||
char cvar_null_string[] = "";
|
||||
|
||||
void Cvar_Init(void)
|
||||
@ -319,8 +320,10 @@ void Cvar_DirectSet(struct cvar_s *var, const char *value)
|
||||
|
||||
void Cvar_Set(const char *var_name, const char *value)
|
||||
{
|
||||
cvar_t *var = Cvar_FindVar(var_name);
|
||||
cvar_t *var;
|
||||
cvarhook_t *pHook;
|
||||
|
||||
var = Cvar_FindVar(var_name);
|
||||
if (!var)
|
||||
{
|
||||
Con_DPrintf("%s: variable \"%s\" not found\n", __func__, var_name);
|
||||
@ -328,6 +331,15 @@ void Cvar_Set(const char *var_name, const char *value)
|
||||
}
|
||||
|
||||
Cvar_DirectSet(var, value);
|
||||
|
||||
for (pHook = cvar_hooks; pHook; pHook = pHook->next)
|
||||
{
|
||||
if (pHook->cvar == var)
|
||||
{
|
||||
pHook->hook(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cvar_SetValue(const char *var_name, float value)
|
||||
@ -730,3 +742,36 @@ void Cvar_CmdInit(void)
|
||||
{
|
||||
Cmd_AddCommand("cvarlist", Cmd_CvarList_f);
|
||||
}
|
||||
|
||||
qboolean Cvar_HookVariable(const char *var_name, cvarhook_t *pHook)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
|
||||
if (!pHook || !pHook->hook)
|
||||
return FALSE;
|
||||
|
||||
if (pHook->cvar || pHook->next)
|
||||
return FALSE;
|
||||
|
||||
cvar = Cvar_FindVar(var_name);
|
||||
if (!cvar)
|
||||
return FALSE;
|
||||
|
||||
cvarhook_t *pCur = cvar_hooks;
|
||||
pHook->cvar = cvar;
|
||||
|
||||
if (pCur)
|
||||
{
|
||||
while (pCur->next)
|
||||
pCur = pCur->next;
|
||||
|
||||
pCur->next = pHook;
|
||||
}
|
||||
else
|
||||
{
|
||||
// First in chain is null, assign pHook to it
|
||||
cvar_hooks = pHook;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -717,14 +717,9 @@ NOXREF qboolean Draw_CacheReload(cachewad_t *wad, int i, lumpinfo_t *pLump, cach
|
||||
qboolean Draw_ValidateCustomLogo(cachewad_t *wad, unsigned char *data, lumpinfo_t *lump)
|
||||
{
|
||||
texture_t tex;
|
||||
miptex_t *mip;
|
||||
miptex_t tmp;
|
||||
int pix;
|
||||
int pixoffset;
|
||||
int paloffset;
|
||||
int palettesize;
|
||||
int nPalleteCount;
|
||||
int nSize;
|
||||
miptex_t *mip, tmp;
|
||||
int i, pix, paloffset, palettesize;
|
||||
int size;
|
||||
|
||||
if (wad->cacheExtra != DECAL_EXTRASIZE)
|
||||
{
|
||||
@ -734,58 +729,54 @@ qboolean Draw_ValidateCustomLogo(cachewad_t *wad, unsigned char *data, lumpinfo_
|
||||
|
||||
tex = *(texture_t *)data;
|
||||
mip = (miptex_t *)(data + wad->cacheExtra);
|
||||
tmp = *mip;
|
||||
|
||||
// Copy mip texture data
|
||||
tmp = *mip;
|
||||
tex.width = LittleLong(tmp.width);
|
||||
tex.height = LittleLong(tmp.height);
|
||||
tex.anim_max = 0;
|
||||
tex.anim_min = 0;
|
||||
tex.anim_total = 0;
|
||||
tex.alternate_anims = NULL;
|
||||
tex.anim_next = NULL;
|
||||
tex.anim_total = tex.anim_min = tex.anim_max = 0;
|
||||
tex.alternate_anims = tex.anim_next = NULL;
|
||||
|
||||
if (!tex.width || tex.width > 256 || tex.height > 256)
|
||||
{
|
||||
Con_Printf("%s: Bad wad dimensions %s\n", __func__, wad->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MIPLEVELS; i++)
|
||||
for (i = 0; i < MIPLEVELS; i++)
|
||||
tex.offsets[i] = wad->cacheExtra + LittleLong(tmp.offsets[i]);
|
||||
|
||||
if (tex.width <= 0 || tex.height <= 0 ||
|
||||
// Check if texture dimensions exceed limits
|
||||
tex.width > 256 || tex.height > 256)
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad tex size %ux%u on %s\n", __func__, tex.width, tex.height, wad->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pix = tex.width * tex.height;
|
||||
pixoffset = pix + (pix >> 2) + (pix >> 4) + (pix >> 6);
|
||||
size = pix + (pix >> 2) + (pix >> 4) + (pix >> 6);
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
// Ensure that pixoffset won't be exceed the pre allocated buffer
|
||||
// This can happen when there are no color palettes in payload
|
||||
if ((pixoffset + sizeof(texture_t)) >= (unsigned)(wad->cacheExtra + lump->size))
|
||||
if ((unsigned)(size + sizeof(miptex_t)) >= (unsigned)(lump->size + wad->cacheExtra))
|
||||
{
|
||||
Con_Printf("%s: Bad wad payload size %s\n", __func__, wad->name);
|
||||
return FALSE;
|
||||
Con_Printf("%s: Bad cached wad size %i/%i on %s\n", __func__, size + sizeof(miptex_t), lump->size + wad->cacheExtra, wad->name);
|
||||
}
|
||||
#endif
|
||||
|
||||
paloffset = (pix >> 2) + tmp.offsets[0] + pix;
|
||||
palettesize = (pix >> 4) + paloffset;
|
||||
paloffset = size + sizeof(miptex_t);
|
||||
palettesize = *(u_short *)(data + wad->cacheExtra + paloffset); // Get palette size
|
||||
|
||||
if ((tmp.offsets[0] + pix != tmp.offsets[1])
|
||||
|| paloffset != tmp.offsets[2]
|
||||
|| palettesize != tmp.offsets[3])
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad %s\n", __func__, wad->name);
|
||||
// Check if offsets are valid for mip levels
|
||||
if (pix + tmp.offsets[i] != tmp.offsets[i + 1])
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad %s\n", __func__, wad->name);
|
||||
return FALSE;
|
||||
}
|
||||
pix >>= 2;
|
||||
}
|
||||
|
||||
if (palettesize > 256)
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad palette size %i on %s\n", __func__, palettesize, wad->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nPalleteCount = *(u_short *)(data + pixoffset + sizeof(texture_t));
|
||||
if (nPalleteCount > 256)
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad palette size %i on %s\n", __func__, nPalleteCount, wad->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nSize = pixoffset + LittleLong(tmp.offsets[0]) + 3 * nPalleteCount + 2;
|
||||
if (nSize > lump->disksize)
|
||||
if ((palettesize + 2 * (palettesize + 1) + size + LittleLong(tmp.offsets[0])) > lump->disksize)
|
||||
{
|
||||
Con_Printf("%s: Bad cached wad %s\n", __func__, wad->name);
|
||||
return FALSE;
|
||||
|
@ -30,6 +30,9 @@
|
||||
|
||||
#include "entity_state.h"
|
||||
|
||||
// marker an entity index that not in an old packet (for svc_packetentities)
|
||||
#define ENTITY_SENTINEL 9999
|
||||
|
||||
typedef struct packet_entities_s
|
||||
{
|
||||
int num_entities;
|
||||
|
@ -42,9 +42,7 @@ typedef struct ipfilter_s
|
||||
} compare;
|
||||
float banEndTime;
|
||||
float banTime;
|
||||
#ifdef REHLDS_FIXES
|
||||
int cidr;
|
||||
#endif // REHLDS_FIXES
|
||||
} ipfilter_t;
|
||||
|
||||
typedef struct userfilter_s
|
||||
|
@ -620,7 +620,9 @@ qboolean HPAK_ResourceForHash(char *pakname, unsigned char *hash, struct resourc
|
||||
fp = FS_Open(name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
#ifndef REHLDS_FIXES
|
||||
Con_Printf("ERROR: couldn't open %s.\n", name);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
FS_Read(&header, sizeof(hash_pack_header_t), 1, fp);
|
||||
|
@ -57,7 +57,11 @@ cvar_t deathmatch = { "deathmatch", "0", FCVAR_SERVER, 0.0f, NULL };
|
||||
cvar_t coop = { "coop", "0", FCVAR_SERVER, 0.0f, NULL };
|
||||
|
||||
cvar_t sys_ticrate = { "sys_ticrate", "100.0", 0, 0.0f, NULL };
|
||||
|
||||
void sys_timescale_hook_callback(cvar_t *cvar);
|
||||
cvarhook_t sys_timescale_hook = { sys_timescale_hook_callback, NULL, NULL };
|
||||
cvar_t sys_timescale = { "sys_timescale", "1.0", 0, 0.0f, NULL };
|
||||
|
||||
cvar_t fps_max = { "fps_max", "100.0", FCVAR_ARCHIVE, 0.0f, NULL };
|
||||
cvar_t host_killtime = { "host_killtime", "0.0", 0, 0.0f, NULL };
|
||||
cvar_t sv_stats = { "sv_stats", "1", 0, 0.0f, NULL };
|
||||
@ -143,6 +147,9 @@ void Host_InitLocal(void)
|
||||
Host_InitCommands();
|
||||
Cvar_RegisterVariable(&host_killtime);
|
||||
Cvar_RegisterVariable(&sys_ticrate);
|
||||
Cvar_RegisterVariable(&sys_timescale);
|
||||
Cvar_HookVariable(sys_timescale.name, &sys_timescale_hook);
|
||||
|
||||
Cvar_RegisterVariable(&fps_max);
|
||||
Cvar_RegisterVariable(&fps_override);
|
||||
Cvar_RegisterVariable(&host_name);
|
||||
@ -355,7 +362,7 @@ void SV_ClientPrintf(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
char string[1024];
|
||||
|
||||
|
||||
va_start(va, fmt);
|
||||
Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va);
|
||||
va_end(va);
|
||||
@ -367,8 +374,9 @@ void SV_ClientPrintf(const char *fmt, ...)
|
||||
void EXT_FUNC SV_ClientPrintf_internal(const char *Dest)
|
||||
{
|
||||
char string[1024];
|
||||
|
||||
Q_strlcpy(string, Dest, min(strlen(Dest) + 1, sizeof(string)));
|
||||
|
||||
Q_strlcpy(string, Dest);
|
||||
|
||||
MSG_WriteByte(&host_client->netchan.message, svc_print);
|
||||
MSG_WriteString(&host_client->netchan.message, string);
|
||||
}
|
||||
@ -1190,7 +1198,11 @@ int Host_Init(quakeparms_t *parms)
|
||||
else
|
||||
{
|
||||
Cvar_RegisterVariable(&suitvolume);
|
||||
#ifdef REHLDS_FIXES
|
||||
Cvar_RegisterVariable(&r_cachestudio);
|
||||
#endif
|
||||
}
|
||||
|
||||
Cbuf_InsertText("exec valve.rc\n");
|
||||
Hunk_AllocName(0, "-HOST_HUNKLEVEL-");
|
||||
host_hunklevel = Hunk_LowMark();
|
||||
@ -1275,3 +1287,23 @@ void Host_Shutdown(void)
|
||||
g_psv.time = 0.0f;
|
||||
g_pcl.time = 0.0f;
|
||||
}
|
||||
|
||||
void sys_timescale_hook_callback(cvar_t *cvar)
|
||||
{
|
||||
int i;
|
||||
client_t *client = NULL;
|
||||
|
||||
if (!Host_IsServerActive())
|
||||
return;
|
||||
|
||||
for (i = 0; i < g_psvs.maxclients; i++)
|
||||
{
|
||||
client = &g_psvs.clients[i];
|
||||
|
||||
if (!client->fakeclient && (client->active || client->spawned || client->connected))
|
||||
{
|
||||
MSG_WriteByte(&client->netchan.message, svc_timescale);
|
||||
MSG_WriteFloat(&client->netchan.message, max(0.1f, sys_timescale.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,11 +205,19 @@ void Host_Motd_f(void)
|
||||
char *next;
|
||||
|
||||
pFileList = motdfile.string;
|
||||
if (*pFileList == '/' || Q_strstr(pFileList, ":") || Q_strstr(pFileList, "..") || Q_strstr(pFileList, "\\"))
|
||||
if (!COM_IsValidPath(pFileList) || COM_IsAbsolutePath(pFileList))
|
||||
{
|
||||
Con_Printf("Unable to open %s (contains illegal characters)\n", pFileList);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *pchExtension = COM_FileExtension(pFileList);
|
||||
if (Q_stricmp(pchExtension, "txt") != 0)
|
||||
{
|
||||
Con_Printf("Invalid motdfile name %s (wrong file extension, must be .txt)\n", pFileList);
|
||||
return;
|
||||
}
|
||||
|
||||
pFile = FS_Open(pFileList, "rb");
|
||||
if (!pFile)
|
||||
{
|
||||
@ -602,7 +610,6 @@ void Host_Status_f(void)
|
||||
Host_Status_Printf(conprint, log, "players : %i active (%i max)\n\n", nClients, g_psvs.maxclients);
|
||||
Host_Status_Printf(conprint, log, "# name userid uniqueid frag time ping loss adr\n");
|
||||
|
||||
int count = 1;
|
||||
client = g_psvs.clients;
|
||||
for (j = 0; j < g_psvs.maxclients; j++, client++)
|
||||
{
|
||||
@ -626,7 +633,7 @@ void Host_Status_f(void)
|
||||
val = SV_GetClientIDString(client);
|
||||
else val = "BOT";
|
||||
|
||||
Host_Status_Printf(conprint, log, "#%2i %8s %i %s", count++, va("\"%s\"", client->name), client->userid, val);
|
||||
Host_Status_Printf(conprint, log, "#%2i %8s %i %s", j + 1, va("\"%s\"", client->name), client->userid, val);
|
||||
if (client->proxy)
|
||||
{
|
||||
const char *userInfo = Info_ValueForKey(client->userinfo, "hspecs");
|
||||
@ -716,7 +723,6 @@ void Host_Status_Formatted_f(void)
|
||||
Host_Status_Printf(conprint, log, "players : %i active (%i max)\n\n", nClients, g_psvs.maxclients);
|
||||
Host_Status_Printf(conprint, log, "%-2.2s\t%-9.9s\t%-7.7s\t%-20.20s\t%-4.4s\t%-8.8s\t%-4.4s\t%-4.4s\t%-21.21s\n","# ","name","userid ","uniqueid ","frag","time ","ping","loss","adr");
|
||||
|
||||
int count = 1;
|
||||
char *szRemoteAddr;
|
||||
client = g_psvs.clients;
|
||||
for (j = 0; j < g_psvs.maxclients; j++, client++)
|
||||
@ -747,12 +753,117 @@ void Host_Status_Formatted_f(void)
|
||||
#endif // REHLDS_FIXES
|
||||
szIDString = SV_GetClientIDString(client);
|
||||
Host_Status_Printf(conprint, log, "%-2.2s\t%-9.9s\t%-7.7s\t%-20.20s\t%-4.4s\t%-8.8s\t%-4.4s\t%-4.4s\t%-21.21s\n",
|
||||
va("%-2i", count++),va("\"%s\"", client->name),va("%-7i", client->userid),szIDString,
|
||||
va("%-2i", j + 1),va("\"%s\"", client->name),va("%-7i", client->userid),szIDString,
|
||||
va("%-4i", (int)client->edict->v.frags),sz,va("%-4i", SV_CalcPing(client)),va("%-4i", (int)client->packet_loss),szRemoteAddr);
|
||||
}
|
||||
Host_Status_Printf(conprint, log, "%i users\n", nClients);
|
||||
}
|
||||
|
||||
// Sets client to godmode
|
||||
void Host_God_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
|
||||
if (!((int)sv_player->v.flags & FL_GODMODE))
|
||||
SV_ClientPrintf("godmode OFF\n");
|
||||
else
|
||||
SV_ClientPrintf("godmode ON\n");
|
||||
}
|
||||
|
||||
// Sets client to notarget mode
|
||||
void Host_Notarget_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
|
||||
if (!((int)sv_player->v.flags & FL_NOTARGET))
|
||||
SV_ClientPrintf("notarget OFF\n");
|
||||
else
|
||||
SV_ClientPrintf("notarget ON\n");
|
||||
}
|
||||
|
||||
// Searches along the direction ray in steps of "step" to see if
|
||||
// the entity position is passible
|
||||
// Used for putting the player in valid space when toggling off noclip mode
|
||||
int FindPassableSpace(edict_t *pEdict, vec_t *direction, float step)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
VectorMA(pEdict->v.origin, step, direction, pEdict->v.origin);
|
||||
|
||||
if (!SV_TestEntityPosition(pEdict))
|
||||
{
|
||||
// Store old origin
|
||||
VectorCopy(pEdict->v.origin, pEdict->v.oldorigin);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Host_Noclip_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_NOCLIP;
|
||||
SV_ClientPrintf("noclip ON\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_WALK;
|
||||
|
||||
// Store old origin
|
||||
VectorCopy(sv_player->v.origin, sv_player->v.oldorigin);
|
||||
|
||||
SV_ClientPrintf("noclip OFF\n");
|
||||
|
||||
if (SV_TestEntityPosition(sv_player))
|
||||
{
|
||||
vec3_t forward, right, up;
|
||||
AngleVectors(sv_player->v.v_angle, forward, right, up);
|
||||
|
||||
if (!FindPassableSpace(sv_player, forward, 1.0)
|
||||
&& !FindPassableSpace(sv_player, right, 1.0)
|
||||
&& !FindPassableSpace(sv_player, right, -1.0) // left
|
||||
&& !FindPassableSpace(sv_player, up, 1.0) // up
|
||||
&& !FindPassableSpace(sv_player, up, -1.0) // down
|
||||
&& !FindPassableSpace(sv_player, forward, -1.0)) // back
|
||||
{
|
||||
Con_DPrintf("Can't find the world\n");
|
||||
}
|
||||
|
||||
VectorCopy(sv_player->v.oldorigin, sv_player->v.origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Host_Ping_f(void)
|
||||
{
|
||||
int i;
|
||||
@ -3138,11 +3249,12 @@ void Host_InitCommands(void)
|
||||
Cmd_AddCommand("setinfo", Host_SetInfo_f);
|
||||
Cmd_AddCommand("fullinfo", Host_FullInfo_f);
|
||||
|
||||
#ifndef SWDS
|
||||
Cmd_AddCommand("god", Host_God_f);
|
||||
Cmd_AddCommand("notarget", Host_Notarget_f);
|
||||
Cmd_AddCommand("fly", Host_Fly_f);
|
||||
Cmd_AddCommand("noclip", Host_Noclip_f);
|
||||
|
||||
#ifndef SWDS
|
||||
Cmd_AddCommand("fly", Host_Fly_f);
|
||||
Cmd_AddCommand("viewmodel", Host_Viewmodel_f);
|
||||
Cmd_AddCommand("viewframe", Host_Viewframe_f);
|
||||
Cmd_AddCommand("viewnext", Host_Viewnext_f);
|
||||
|
@ -856,6 +856,12 @@ qboolean Info_IsValid(const char *s)
|
||||
return false;
|
||||
};
|
||||
|
||||
// invalid utf8 chars are deprecated
|
||||
if (!Q_UnicodeValidate(s))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (*s == '\\')
|
||||
{
|
||||
const char* key = ++s;
|
||||
|
@ -418,3 +418,12 @@ qboolean VectorCompare(const vec_t *v1, const vec_t *v2)
|
||||
}
|
||||
|
||||
#endif // #if !defined(REHLDS_SSE)
|
||||
|
||||
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2)
|
||||
{
|
||||
if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
|
||||
return FALSE;
|
||||
if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -171,3 +171,4 @@ void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
NOBODY void FloorDivMod(double numer, double denom, int *quotient, int *rem);
|
||||
NOBODY int GreatestCommonDivisor(int i1, int i2);
|
||||
NOBODY fixed16_t Invert24To16(fixed16_t val);
|
||||
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2);
|
||||
|
@ -854,6 +854,7 @@ void CalcSurfaceExtents(msurface_t *s)
|
||||
int i, j, e;
|
||||
mvertex_t *v;
|
||||
mtexinfo_t *tex;
|
||||
vec3_t middle{};
|
||||
int bmins[2], bmaxs[2];
|
||||
|
||||
mins[0] = mins[1] = 999999;
|
||||
@ -869,6 +870,8 @@ void CalcSurfaceExtents(msurface_t *s)
|
||||
else
|
||||
v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
|
||||
|
||||
VectorAdd(middle, v->position, middle);
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
// FIXED: loss of floating point
|
||||
@ -884,6 +887,8 @@ void CalcSurfaceExtents(msurface_t *s)
|
||||
}
|
||||
}
|
||||
|
||||
VectorScale(middle, 1.0f / s->numedges, middle);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
bmins[i] = (int) floor(mins[i] / 16);
|
||||
@ -891,8 +896,16 @@ void CalcSurfaceExtents(msurface_t *s)
|
||||
|
||||
s->texturemins[i] = bmins[i] * 16;
|
||||
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
|
||||
if (!(tex->flags & TEX_SPECIAL) && s->extents[i] > 256)
|
||||
Sys_Error("%s: Bad surface extents", __func__);
|
||||
|
||||
if (!(tex->flags & TEX_SPECIAL) && s->extents[i] > MAX_SURFACE_TEXTURE_SIZE)
|
||||
{
|
||||
int surfID = s - loadmodel->surfaces;
|
||||
Sys_Error("%s: Bad #%d surface extents %d/%d on %s at position (%d,%d,%d)",
|
||||
__func__, surfID, s->extents[0], s->extents[1],
|
||||
tex->texture->name,
|
||||
(int)middle[0], (int)middle[1], (int)middle[2]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,6 +422,7 @@ typedef struct netchan_s
|
||||
|
||||
// Incoming and outgoing flow metrics
|
||||
flow_t flow[MAX_FLOWS];
|
||||
|
||||
} netchan_t;
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
|
@ -36,6 +36,15 @@ cvar_t net_showpackets = { "net_showpackets", "0", 0, 0.0f, nullptr};
|
||||
cvar_t net_showdrop = { "net_showdrop", "0", 0, 0.0f, nullptr};
|
||||
cvar_t net_drawslider = { "net_drawslider", "0", 0, 0.0f, nullptr};
|
||||
cvar_t net_chokeloopback = { "net_chokeloop", "0", 0, 0.0f, nullptr};
|
||||
|
||||
cvar_t sv_net_incoming_decompression = { "sv_net_incoming_decompression", "1", 0, 1.0f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_max_ratio = { "sv_net_incoming_decompression_max_ratio", "80.0", 0, 80.0f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_max_size = { "sv_net_incoming_decompression_max_size", "65536", 0, 65536.0f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_min_failures = { "sv_net_incoming_decompression_min_failures", "4", 0, 4.0f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_max_failures = { "sv_net_incoming_decompression_max_failures", "10", 0, 10.0f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_min_failuretime = { "sv_net_incoming_decompression_min_failuretime", "0.1", 0, 0.1f, nullptr };
|
||||
cvar_t sv_net_incoming_decompression_punish = { "sv_net_incoming_decompression_punish", "-1", 0, -1.0f, nullptr };
|
||||
|
||||
cvar_t sv_filetransfercompression = { "sv_filetransfercompression", "1", 0, 0.0f, nullptr};
|
||||
cvar_t sv_filetransfermaxsize = { "sv_filetransfermaxsize", "10485760", 0, 0.0f, nullptr};
|
||||
|
||||
@ -178,6 +187,7 @@ void Netchan_Clear(netchan_t *chan)
|
||||
void Netchan_Setup(netsrc_t socketnumber, netchan_t *chan, netadr_t adr, int player_slot, void *connection_status, qboolean(*pfnNetchan_Blocksize)(void *))
|
||||
{
|
||||
Netchan_Clear(chan);
|
||||
g_GameClients[player_slot]->NetchanClear();
|
||||
|
||||
Q_memset(chan, 0, sizeof(netchan_t));
|
||||
|
||||
@ -1203,7 +1213,9 @@ int Netchan_CreateFileFragments(qboolean server, netchan_t *chan, const char *fi
|
||||
|
||||
if (!FS_FileExists(filename))
|
||||
return FALSE;
|
||||
if (FS_FileSize(filename) > sv_filetransfermaxsize.value)
|
||||
|
||||
unsigned int nSize = FS_FileSize(filename);
|
||||
if (nSize == 0 || nSize > sv_filetransfermaxsize.value)
|
||||
return FALSE;
|
||||
|
||||
auto wait = (fragbufwaiting_t *)Mem_ZeroMalloc(sizeof(fragbufwaiting_t));
|
||||
@ -1415,6 +1427,93 @@ void Netchan_FlushIncoming(netchan_t *chan, int stream)
|
||||
chan->incomingready[stream] = FALSE;
|
||||
}
|
||||
|
||||
void Netchan_DecompressionCvarsBounds()
|
||||
{
|
||||
if (sv_net_incoming_decompression_min_failures.value < 1)
|
||||
Cvar_SetValue("sv_net_incoming_decompression_min_failures", 1);
|
||||
|
||||
else if (sv_net_incoming_decompression_min_failures.value > NET_DECOMPRESS_MAX_TIMES)
|
||||
Cvar_SetValue("sv_net_incoming_decompression_min_failures", NET_DECOMPRESS_MAX_TIMES);
|
||||
|
||||
if (sv_net_incoming_decompression_max_failures.value < 1)
|
||||
Cvar_SetValue("sv_net_incoming_decompression_max_failures", 1);
|
||||
|
||||
else if (sv_net_incoming_decompression_max_failures.value > NET_DECOMPRESS_MAX_TIMES)
|
||||
Cvar_SetValue("sv_net_incoming_decompression_max_failures", NET_DECOMPRESS_MAX_TIMES);
|
||||
|
||||
if (sv_net_incoming_decompression_max_failures.value < sv_net_incoming_decompression_min_failures.value)
|
||||
{
|
||||
int iTemp = sv_net_incoming_decompression_max_failures.value;
|
||||
Cvar_SetValue("sv_net_incoming_decompression_max_failures", sv_net_incoming_decompression_min_failures.value);
|
||||
Cvar_SetValue("sv_net_incoming_decompression_min_failures", iTemp);
|
||||
}
|
||||
|
||||
if (sv_net_incoming_decompression_min_failuretime.value <= 0.0f)
|
||||
Cvar_SetValue("sv_net_incoming_decompression_min_failuretime", 0.1f);
|
||||
}
|
||||
|
||||
// Check for an abnormal size ratio between compressed and uncompressed data
|
||||
qboolean Netchan_ValidateDecompress(netchan_t *chan, int stream, unsigned int compressedSize, unsigned int uncompressedSize)
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
int i;
|
||||
|
||||
if (sv_net_incoming_decompression_max_ratio.value <= 0)
|
||||
return TRUE; // validation is disabled
|
||||
|
||||
if (compressedSize >= uncompressedSize)
|
||||
return TRUE;
|
||||
|
||||
float ratio = ((float)(uncompressedSize - compressedSize) / uncompressedSize) * 100.0f;
|
||||
if (ratio < sv_net_incoming_decompression_max_ratio.value)
|
||||
return TRUE; // no low entropy for uncompressed data
|
||||
|
||||
if ((chan->player_slot - 1) != host_client - g_psvs.clients)
|
||||
return TRUE;
|
||||
|
||||
Netchan_DecompressionCvarsBounds();
|
||||
|
||||
FragStats_t &stats = g_GameClients[chan->player_slot - 1]->GetFragStats(stream);
|
||||
|
||||
// check if the client should be rejected based on total failed decompress
|
||||
if (stats.num_decompress_failures >= sv_net_incoming_decompression_max_failures.value)
|
||||
{
|
||||
for (i = 0; i < sv_net_incoming_decompression_max_failures.value - 1; i++)
|
||||
stats.decompress_failure_times[i] = stats.decompress_failure_times[i + 1];
|
||||
|
||||
stats.num_decompress_failures = sv_net_incoming_decompression_max_failures.value - 1;
|
||||
}
|
||||
|
||||
stats.decompress_failure_times[stats.num_decompress_failures++] = realtime;
|
||||
|
||||
// check if the client should be rejected based on recent failed decompress
|
||||
int recent_failures = 0;
|
||||
for (i = 0; i < stats.num_decompress_failures; i++)
|
||||
{
|
||||
if ((realtime - stats.decompress_failure_times[i]) <= sv_net_incoming_decompression_min_failuretime.value)
|
||||
recent_failures++;
|
||||
}
|
||||
|
||||
if (recent_failures >= sv_net_incoming_decompression_min_failures.value)
|
||||
{
|
||||
if (chan->player_slot == 0)
|
||||
Con_DPrintf("Incoming abnormal uncompressed size with ratio %.2f\n", ratio);
|
||||
else
|
||||
Con_DPrintf("%s:Incoming abnormal uncompressed size with ratio %.2f from %s\n", NET_AdrToString(chan->remote_address), ratio, host_client->name);
|
||||
|
||||
if (sv_net_incoming_decompression_punish.value >= 0)
|
||||
{
|
||||
Con_DPrintf("%s:Banned for malformed/abnormal bzip2 fragments from %s\n", NET_AdrToString(chan->remote_address), host_client->name);
|
||||
Cbuf_AddText(va("addip %.1f %s\n", sv_net_incoming_decompression_punish.value, NET_BaseAdrToString(chan->remote_address)));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
qboolean Netchan_CopyNormalFragments(netchan_t *chan)
|
||||
{
|
||||
fragbuf_t *p, *n;
|
||||
@ -1431,6 +1530,9 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
|
||||
|
||||
p = chan->incomingbufs[FRAG_NORMAL_STREAM];
|
||||
|
||||
chan->incomingbufs[FRAG_NORMAL_STREAM] = nullptr;
|
||||
chan->incomingready[FRAG_NORMAL_STREAM] = FALSE;
|
||||
|
||||
SZ_Clear(&net_message);
|
||||
MSG_BeginReading();
|
||||
|
||||
@ -1468,26 +1570,62 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
|
||||
}
|
||||
|
||||
SZ_Clear(&net_message);
|
||||
|
||||
chan->incomingbufs[FRAG_NORMAL_STREAM] = nullptr;
|
||||
chan->incomingready[FRAG_NORMAL_STREAM] = FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
|
||||
{
|
||||
// Determine whether decompression of compressed data is allowed
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!sv_net_incoming_decompression.value)
|
||||
{
|
||||
if (chan->player_slot == 0)
|
||||
{
|
||||
Con_DPrintf("Incoming compressed normal fragment disallowed from\n");
|
||||
return FALSE;
|
||||
}
|
||||
// compressed data is expected only after requesting resource list
|
||||
else if (host_client->m_sendrescount == 0)
|
||||
{
|
||||
Con_DPrintf("%s:Incoming compressed normal fragment disallowed from %s\n", NET_AdrToString(chan->remote_address), host_client->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char uncompressed[65536];
|
||||
unsigned int uncompressedSize = 65536;
|
||||
BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char*)net_message.data + 4, net_message.cursize - 4, 1, 0);
|
||||
unsigned int uncompressedSize = clamp((int)sv_net_incoming_decompression_max_size.value, 16, 65536); // valid range (16 - 65536) bytes
|
||||
unsigned int compressedSize = net_message.cursize - 4;
|
||||
|
||||
// Decompress net buffer data
|
||||
qboolean success = TRUE;
|
||||
|
||||
if (BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char *)net_message.data + 4, compressedSize, 1, 0) != BZ_OK)
|
||||
{
|
||||
// malformed data or compressed data exceeding sv_net_incoming_decompression_max_size
|
||||
success = FALSE;
|
||||
}
|
||||
else if (!Netchan_ValidateDecompress(chan, FRAG_NORMAL_STREAM, compressedSize, uncompressedSize))
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!success)
|
||||
{
|
||||
// Drop client if decompression was unsuccessful
|
||||
SV_DropClient(host_client, FALSE, "Malformed/abnormal compressed data");
|
||||
SZ_Clear(&net_message);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Copy uncompressed data back to the net buffer
|
||||
Q_memcpy(net_message.data, uncompressed, uncompressedSize);
|
||||
net_message.cursize = uncompressedSize;
|
||||
}
|
||||
|
||||
chan->incomingbufs[FRAG_NORMAL_STREAM] = nullptr;
|
||||
chan->incomingready[FRAG_NORMAL_STREAM] = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1504,7 +1642,6 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
|
||||
qboolean bCompressed;
|
||||
unsigned int uncompressedSize;
|
||||
|
||||
|
||||
if (!chan->incomingready[FRAG_FILE_STREAM])
|
||||
return FALSE;
|
||||
|
||||
@ -1516,6 +1653,19 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
if (chan->player_slot > 0 && (chan->player_slot - 1) == host_client - g_psvs.clients)
|
||||
{
|
||||
// customization already uploaded with request by operator,
|
||||
// do not accept any other customization
|
||||
if (host_client->uploaddoneregistering)
|
||||
{
|
||||
SV_DropClient(host_client, FALSE, "Too many customization have been uploaded (unrequested customization)");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bCompressed = FALSE;
|
||||
SZ_Clear(&net_message);
|
||||
MSG_BeginReading();
|
||||
@ -1630,10 +1780,53 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
|
||||
|
||||
if (bCompressed)
|
||||
{
|
||||
unsigned char* uncompressedBuffer = (unsigned char*)Mem_Malloc(uncompressedSize);
|
||||
Con_DPrintf("Decompressing file %s (%d -> %d)\n", filename, nsize, uncompressedSize);
|
||||
BZ2_bzBuffToBuffDecompress((char*)uncompressedBuffer, &uncompressedSize, (char*)buffer, nsize, 1, 0);
|
||||
// Determine whether decompression of compressed data is allowed
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!sv_net_incoming_decompression.value)
|
||||
{
|
||||
if (chan->player_slot == 0)
|
||||
{
|
||||
Con_DPrintf("Incoming compressed file fragment disallowed from\n");
|
||||
return FALSE;
|
||||
}
|
||||
// compressed data is expected only after requesting resource list
|
||||
else if (host_client->m_sendrescount == 0)
|
||||
{
|
||||
Con_DPrintf("%s:Incoming compressed file fragment disallowed from %s\n", NET_AdrToString(chan->remote_address), host_client->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uncompressedSize = clamp(uncompressedSize, 16u, (unsigned)sv_net_incoming_decompression_max_size.value); // valid range (16 - 65536) bytes
|
||||
|
||||
qboolean success = TRUE;
|
||||
unsigned char *uncompressedBuffer = (unsigned char *)Mem_Malloc(uncompressedSize);
|
||||
unsigned int compressedSize = nsize;
|
||||
|
||||
// Decompress net buffer data
|
||||
if (BZ2_bzBuffToBuffDecompress((char *)uncompressedBuffer, &uncompressedSize, (char *)buffer, compressedSize, 1, 0) != BZ_OK)
|
||||
{
|
||||
// malformed data or compressed data exceeding sv_net_incoming_decompression_max_size
|
||||
success = FALSE;
|
||||
}
|
||||
else if (!Netchan_ValidateDecompress(chan, FRAG_FILE_STREAM, compressedSize, uncompressedSize))
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
Mem_Free(buffer);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
// Drop client if decompression was unsuccessful
|
||||
SV_DropClient(host_client, FALSE, "Malformed/abnormal compressed data");
|
||||
SZ_Clear(&net_message);
|
||||
Mem_Free(uncompressedBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Con_DPrintf("Decompressing file %s (%d -> %d)\n", filename, compressedSize, uncompressedSize);
|
||||
pos = uncompressedSize;
|
||||
buffer = uncompressedBuffer;
|
||||
}
|
||||
@ -1824,6 +2017,15 @@ void Netchan_Init(void)
|
||||
Cvar_RegisterVariable(&net_chokeloopback);
|
||||
Cvar_RegisterVariable(&net_drawslider);
|
||||
Cvar_RegisterVariable(&sv_filetransfercompression);
|
||||
#ifdef REHLDS_FIXES
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_max_ratio);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_max_size);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_min_failures);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_max_failures);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_min_failuretime);
|
||||
Cvar_RegisterVariable(&sv_net_incoming_decompression_punish);
|
||||
#endif
|
||||
Cvar_RegisterVariable(&sv_filetransfermaxsize);
|
||||
}
|
||||
|
||||
|
@ -651,7 +651,7 @@ void NET_AdjustLag()
|
||||
}
|
||||
lasttime = realtime;
|
||||
|
||||
if (allow_cheats || fakelag.value == 0.0)
|
||||
if (sv_cheats.value || fakelag.value == 0.0)
|
||||
{
|
||||
if (fakelag.value != gFakeLag)
|
||||
{
|
||||
@ -689,7 +689,7 @@ qboolean NET_LagPacket(qboolean newdata, netsrc_t sock, netadr_t *from, sizebuf_
|
||||
{
|
||||
if (fakeloss.value != 0.0)
|
||||
{
|
||||
if (allow_cheats)
|
||||
if (sv_cheats.value)
|
||||
{
|
||||
static int losscount[NS_MAX] = {};
|
||||
++losscount[sock];
|
||||
@ -1768,7 +1768,7 @@ void NET_GetLocalAddress()
|
||||
|
||||
if (noip)
|
||||
{
|
||||
Con_Printf("TCP/IP Disabled.\n");
|
||||
Con_DPrintf("TCP/IP Disabled.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1823,7 +1823,7 @@ void NET_GetLocalAddress()
|
||||
#ifdef _WIN32
|
||||
if (noipx)
|
||||
{
|
||||
Con_Printf("No IPX Support.\n");
|
||||
Con_DPrintf("No IPX Support.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
playermove_t *pmove;
|
||||
movevars_t movevars;
|
||||
movevars_t sv_movevars;
|
||||
|
||||
cvar_t pm_showclip = { "pm_showclip", "0", 0, 0.0f, NULL };
|
||||
|
||||
@ -98,7 +98,7 @@ void PM_Init(playermove_t *ppm)
|
||||
VectorCopy(player_maxs[i], ppm->player_maxs[i]);
|
||||
}
|
||||
|
||||
ppm->_movevars = &movevars;
|
||||
ppm->movevars = &sv_movevars;
|
||||
|
||||
ppm->PM_Info_ValueForKey = Info_ValueForKey;
|
||||
ppm->PM_Particle = CL_Particle;
|
||||
|
@ -39,7 +39,7 @@ extern vec3_t player_mins[MAX_MAP_HULLS];
|
||||
extern vec3_t player_maxs[MAX_MAP_HULLS];
|
||||
|
||||
extern playermove_t *pmove;
|
||||
extern movevars_t movevars;
|
||||
extern movevars_t sv_movevars;
|
||||
|
||||
qboolean PM_AddToTouched(pmtrace_t tr, vec_t *impactvelocity);
|
||||
void PM_StuckTouch(int hitent, pmtrace_t *ptraceresult);
|
||||
|
@ -1447,6 +1447,9 @@ int EXT_FUNC PF_precache_model_I_internal(const char *s)
|
||||
{
|
||||
for (int i = 0; i < MAX_MODELS; i++)
|
||||
{
|
||||
if (!g_psv.model_precache[i])
|
||||
continue;
|
||||
|
||||
// use case-sensitive names to increase performance
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!Q_strcmp(g_psv.model_precache[i], s))
|
||||
@ -1545,7 +1548,7 @@ int EXT_FUNC PF_precache_generic_I_internal(const char *s)
|
||||
{
|
||||
for (int i = 0; i < MAX_GENERIC; i++)
|
||||
{
|
||||
if (!Q_stricmp(g_psv.generic_precache[i], s))
|
||||
if (g_psv.generic_precache[i] && !Q_stricmp(g_psv.generic_precache[i], s))
|
||||
return i;
|
||||
}
|
||||
Host_Error("%s: '%s' Precache can only be done in spawn functions", __func__, s);
|
||||
@ -1799,7 +1802,14 @@ void EXT_FUNC PF_aim_I(edict_t *ent, float speed, float *rgflReturn)
|
||||
bestdir[1] = dir[1];
|
||||
bestdir[2] = dir[2];
|
||||
bestdir[0] = dir[0];
|
||||
bestdist = sv_aim.value;
|
||||
if (sv_allow_autoaim.value)
|
||||
{
|
||||
bestdist = sv_aim.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
bestdist = 0.0f;
|
||||
}
|
||||
|
||||
for (int i = 1; i < g_psv.num_edicts; i++)
|
||||
{
|
||||
@ -2114,7 +2124,7 @@ void EXT_FUNC PF_MessageBegin_I(int msg_dest, int msg_type, const float *pOrigin
|
||||
if (msg_type == 0)
|
||||
Sys_Error("%s: Tried to create a message with a bogus message type ( 0 )", __func__);
|
||||
|
||||
gMsgStarted = 1;
|
||||
gMsgStarted = TRUE;
|
||||
gMsgType = msg_type;
|
||||
gMsgEntity = ed;
|
||||
gMsgDest = msg_dest;
|
||||
@ -2141,7 +2151,7 @@ void EXT_FUNC PF_MessageEnd_I(void)
|
||||
qboolean MsgIsVarLength = 0;
|
||||
if (!gMsgStarted)
|
||||
Sys_Error("%s: called with no active message\n", __func__);
|
||||
gMsgStarted = 0;
|
||||
gMsgStarted = FALSE;
|
||||
|
||||
if (gMsgEntity && (gMsgEntity->v.flags & FL_FAKECLIENT))
|
||||
return;
|
||||
@ -2265,6 +2275,7 @@ void EXT_FUNC PF_WriteByte_I(int iValue)
|
||||
{
|
||||
if (!gMsgStarted)
|
||||
Sys_Error("%s: called with no active message\n", __func__);
|
||||
|
||||
MSG_WriteByte(&gMsgBuffer, iValue);
|
||||
}
|
||||
|
||||
|
@ -881,6 +881,15 @@ void EXT_FUNC AnimationAutomove(const edict_t *pEdict, float flTime)
|
||||
void EXT_FUNC GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles)
|
||||
{
|
||||
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!pstudiohdr)
|
||||
return;
|
||||
|
||||
if (iBone < 0 || iBone >= pstudiohdr->numbones)
|
||||
return; // invalid bone
|
||||
#endif
|
||||
|
||||
g_pSvBlendingAPI->SV_StudioSetupBones(
|
||||
g_psv.models[pEdict->v.modelindex],
|
||||
pEdict->v.frame,
|
||||
@ -906,14 +915,23 @@ void EXT_FUNC GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflO
|
||||
mstudioattachment_t *pattachment;
|
||||
vec3_t angles;
|
||||
|
||||
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!pstudiohdr)
|
||||
return;
|
||||
|
||||
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
|
||||
return; // invalid attachment
|
||||
#endif
|
||||
|
||||
pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex);
|
||||
pattachment += iAttachment;
|
||||
|
||||
angles[0] = -pEdict->v.angles[0];
|
||||
angles[1] = pEdict->v.angles[1];
|
||||
angles[2] = pEdict->v.angles[2];
|
||||
|
||||
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
|
||||
pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex);
|
||||
pattachment += iAttachment;
|
||||
|
||||
g_pSvBlendingAPI->SV_StudioSetupBones(
|
||||
g_psv.models[pEdict->v.modelindex],
|
||||
pEdict->v.frame,
|
||||
|
@ -53,6 +53,7 @@ const int MAX_NAME = 32;
|
||||
#include "pm_defs.h"
|
||||
#include "inst_baseline.h"
|
||||
#include "net_ws.h"
|
||||
#include "pm_shared/pm_movevars.h"
|
||||
|
||||
const int DEFAULT_SOUND_PACKET_VOLUME = 255;
|
||||
const float DEFAULT_SOUND_PACKET_ATTENUATION = 1.0f;
|
||||
@ -95,13 +96,6 @@ typedef enum redirect_e
|
||||
RD_PACKET = 2,
|
||||
} redirect_t;
|
||||
|
||||
typedef enum server_state_e
|
||||
{
|
||||
ss_dead = 0,
|
||||
ss_loading = 1,
|
||||
ss_active = 2,
|
||||
} server_state_t;
|
||||
|
||||
typedef struct server_s
|
||||
{
|
||||
qboolean active;
|
||||
@ -242,6 +236,7 @@ typedef struct client_s
|
||||
double m_lastvoicetime;
|
||||
int m_sendrescount;
|
||||
qboolean m_bSentNewResponse;
|
||||
movevars_t movevars;
|
||||
} client_t;
|
||||
|
||||
enum
|
||||
@ -283,6 +278,7 @@ extern rehlds_server_t g_rehlds_sv;
|
||||
extern cvar_t sv_lan;
|
||||
extern cvar_t sv_lan_rate;
|
||||
extern cvar_t sv_aim;
|
||||
extern cvar_t sv_allow_autoaim;
|
||||
|
||||
extern cvar_t sv_skycolor_r;
|
||||
extern cvar_t sv_skycolor_g;
|
||||
@ -349,7 +345,6 @@ extern cvar_t sv_proxies;
|
||||
extern cvar_t sv_outofdatetime;
|
||||
extern cvar_t mapchangecfgfile;
|
||||
|
||||
extern qboolean allow_cheats;
|
||||
extern cvar_t mp_logecho;
|
||||
extern cvar_t mp_logfile;
|
||||
extern cvar_t sv_allow_download;
|
||||
@ -366,6 +361,7 @@ extern cvar_t sv_visiblemaxplayers;
|
||||
extern cvar_t sv_downloadurl;
|
||||
extern cvar_t sv_allow_dlfile;
|
||||
extern cvar_t sv_version;
|
||||
extern cvar_t sv_tags;
|
||||
#ifdef REHLDS_FIXES
|
||||
extern cvar_t sv_echo_unknown_cmd;
|
||||
extern cvar_t sv_auto_precache_sounds_in_models;
|
||||
@ -405,7 +401,6 @@ enum GameType_e
|
||||
|
||||
extern GameType_e g_eGameType;
|
||||
|
||||
extern int fatbytes;
|
||||
extern int giNextUserMsg;
|
||||
extern int hashstrings_collisions;
|
||||
|
||||
@ -418,10 +413,6 @@ extern delta_t *g_pweapondelta;
|
||||
extern delta_t *g_pusercmddelta;
|
||||
#endif
|
||||
|
||||
extern unsigned char fatpvs[1024];
|
||||
extern int fatpasbytes;
|
||||
extern unsigned char fatpas[1024];
|
||||
|
||||
extern int gPacketSuppressed;
|
||||
|
||||
extern char localinfo[MAX_LOCALINFO];
|
||||
@ -465,13 +456,13 @@ void SV_BuildHashedSoundLookupTable(void);
|
||||
void SV_AddSampleToHashedLookupTable(const char *pszSample, int iSampleIndex);
|
||||
qboolean SV_ValidClientMulticast(client_t *client, int soundLeaf, int to);
|
||||
void SV_Multicast(edict_t *ent, vec_t *origin, int to, qboolean reliable);
|
||||
void SV_WriteMovevarsToClient(sizebuf_t *message);
|
||||
void SV_WriteMovevarsToClient(sizebuf_t *message, struct movevars_s *movevars);
|
||||
void SV_WriteDeltaDescriptionsToClient(sizebuf_t *msg);
|
||||
void SV_SetMoveVars(void);
|
||||
void SV_QueryMovevarsChanged(void);
|
||||
void SV_SetMoveVars(struct movevars_s *movevars);
|
||||
void SV_SendServerinfo(sizebuf_t *msg, client_t *client);
|
||||
void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client);
|
||||
void SV_SendResources(sizebuf_t *msg);
|
||||
void SV_SendResources_internal(sizebuf_t *msg);
|
||||
void SV_WriteClientdataToMessage(client_t *client, sizebuf_t *msg);
|
||||
void SV_WriteSpawn(sizebuf_t *msg);
|
||||
void SV_SendUserReg(sizebuf_t *msg);
|
||||
@ -592,6 +583,9 @@ void SV_ClearEntities(void);
|
||||
int RegUserMsg(const char *pszName, int iSize);
|
||||
qboolean StringToFilter(const char *s, ipfilter_t *f);
|
||||
USERID_t *SV_StringToUserID(const char *str);
|
||||
bool CanBeWrittenWithoutCIDR(const ipfilter_t &f);
|
||||
void FilterToString(const ipfilter_t &f, char *s);
|
||||
bool IsFilterIncludesAnotherFilter(const ipfilter_t &f, const ipfilter_t &f2);
|
||||
void SV_BanId_f(void);
|
||||
void Host_Kick_f(void);
|
||||
void SV_RemoveId_f(void);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1491,28 +1491,7 @@ void SV_Physics()
|
||||
if (i > 0 && i <= g_psvs.maxclients)
|
||||
continue;
|
||||
|
||||
if (ent->v.flags & FL_ONGROUND)
|
||||
{
|
||||
edict_t *groundentity = ent->v.groundentity;
|
||||
if (groundentity && (groundentity->v.flags & FL_CONVEYOR))
|
||||
{
|
||||
if (ent->v.flags & FL_BASEVELOCITY)
|
||||
VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity);
|
||||
else
|
||||
VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity);
|
||||
|
||||
ent->v.flags |= FL_BASEVELOCITY;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(ent->v.flags & FL_BASEVELOCITY))
|
||||
{
|
||||
// Apply momentum (add in half of the previous frame of velocity first)
|
||||
VectorMA(ent->v.velocity, (host_frametime * 0.5f + 1.0f), ent->v.basevelocity, ent->v.velocity);
|
||||
VectorClear(ent->v.basevelocity);
|
||||
}
|
||||
|
||||
ent->v.flags &= ~FL_BASEVELOCITY;
|
||||
SV_CheckMovingGround(ent, host_frametime);
|
||||
|
||||
switch (ent->v.movetype)
|
||||
{
|
||||
|
@ -232,6 +232,10 @@ CSteam3Server::CSteam3Server() :
|
||||
m_CallbackLogonFailure(this, &CSteam3Server::OnLogonFailure),
|
||||
m_SteamIDGS(1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid)
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
m_GameTagsData[0] = '\0';
|
||||
#endif
|
||||
|
||||
m_bHasActivePlayers = false;
|
||||
m_bWantToBeSecure = false;
|
||||
m_bLanOnly = false;
|
||||
@ -499,6 +503,21 @@ void CSteam3Server::RunFrame()
|
||||
}
|
||||
}
|
||||
|
||||
void CSteam3Server::UpdateGameTags()
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
if (!m_GameTagsData[0] && !sv_tags.string[0])
|
||||
return;
|
||||
|
||||
if (m_GameTagsData[0] && !Q_stricmp(m_GameTagsData, sv_tags.string))
|
||||
return;
|
||||
|
||||
Q_strlcpy(m_GameTagsData, sv_tags.string);
|
||||
Q_strlwr(m_GameTagsData);
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->SetGameTags(m_GameTagsData);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSteam3Server::SendUpdatedServerDetails()
|
||||
{
|
||||
int botCount = 0;
|
||||
@ -521,6 +540,8 @@ void CSteam3Server::SendUpdatedServerDetails()
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->SetBotPlayerCount(botCount);
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->SetServerName(Cvar_VariableString("hostname"));
|
||||
CRehldsPlatformHolder::get()->SteamGameServer()->SetMapName(g_psv.name);
|
||||
|
||||
UpdateGameTags();
|
||||
}
|
||||
|
||||
void CSteam3Client::Shutdown()
|
||||
|
@ -54,6 +54,8 @@ protected:
|
||||
bool InitModule();
|
||||
};
|
||||
|
||||
#define MAX_STEAM_TAGS_LENGTH 128 // Steam doesn't send tags string more than 128 bytes
|
||||
|
||||
class CSteam3Server: public CSteam3
|
||||
{
|
||||
public:
|
||||
@ -71,6 +73,10 @@ protected:
|
||||
bool m_bLanOnly;
|
||||
CSteamID m_SteamIDGS;
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
char m_GameTagsData[MAX_STEAM_TAGS_LENGTH];
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
NOBODY void SetServerType();
|
||||
@ -96,6 +102,7 @@ public:
|
||||
void NotifyOfLevelChange(bool bForce);
|
||||
void RunFrame();
|
||||
void SendUpdatedServerDetails();
|
||||
void UpdateGameTags();
|
||||
};
|
||||
|
||||
class CSteam3Client: public CSteam3
|
||||
|
@ -138,13 +138,16 @@ void SV_CreateCustomizationList(client_t *pHost)
|
||||
{
|
||||
pCust->nUserData2 = nLumps;
|
||||
gEntityInterface.pfnPlayerCustomization(pHost->edict, pCust);
|
||||
#ifdef REHLDS_FIXES
|
||||
SV_Customization(pHost, pResource, TRUE);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sv_allow_upload.value == 0.0f)
|
||||
Con_Printf("Ignoring custom decal from %s\n", pHost->name);
|
||||
Con_DPrintf("Ignoring custom decal from %s\n", pHost->name);
|
||||
else
|
||||
Con_Printf("Ignoring invalid custom decal from %s\n", pHost->name);
|
||||
Con_DPrintf("Ignoring invalid custom decal from %s\n", pHost->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,6 +160,11 @@ void SV_Customization(client_t *pPlayer, resource_t *pResource, qboolean bSkipPl
|
||||
int nPlayerNumber;
|
||||
client_t *pHost;
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
if ((pResource->ucFlags & RES_CUSTOM) && !sv_send_logos.value)
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Get originating player id
|
||||
for (i = 0, pHost = g_psvs.clients; i < g_psvs.maxclients; i++, pHost++)
|
||||
{
|
||||
@ -199,18 +207,13 @@ void SV_Customization(client_t *pPlayer, resource_t *pResource, qboolean bSkipPl
|
||||
// Creates customizations list for the current player and sends resources to other players.
|
||||
void SV_RegisterResources(void)
|
||||
{
|
||||
resource_t *pResource;
|
||||
client_t *pHost = host_client;
|
||||
|
||||
pHost->uploading = FALSE;
|
||||
#ifdef REHLDS_FIXES
|
||||
SV_CreateCustomizationList(pHost); // FIXED: Call this function only once. It was crazy to call it for each resource available.
|
||||
for (pResource = pHost->resourcesonhand.pNext; pResource != &pHost->resourcesonhand; pResource = pResource->pNext)
|
||||
{
|
||||
SV_Customization(pHost, pResource, TRUE);
|
||||
}
|
||||
#else // REHLDS_FIXES
|
||||
for (pResource = pHost->resourcesonhand.pNext; pResource != &pHost->resourcesonhand; pResource = pResource->pNext)
|
||||
for (resource_t *pResource = pHost->resourcesonhand.pNext; pResource != &pHost->resourcesonhand; pResource = pResource->pNext)
|
||||
{
|
||||
SV_CreateCustomizationList(pHost);
|
||||
SV_Customization(pHost, pResource, TRUE);
|
||||
@ -509,8 +512,13 @@ void SV_ParseResourceList(client_t *pSenderClient)
|
||||
}
|
||||
}
|
||||
|
||||
host_client->uploading = TRUE;
|
||||
host_client->uploaddoneregistering = FALSE;
|
||||
#ifdef REHLDS_FIXES
|
||||
if (sv_allow_upload.value != 0.0f)
|
||||
#endif //REHLDS_FIXES
|
||||
{
|
||||
host_client->uploading = TRUE;
|
||||
host_client->uploaddoneregistering = FALSE;
|
||||
|
||||
SV_BatchUploadRequest(host_client);
|
||||
SV_BatchUploadRequest(host_client);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ edict_t *sv_player;
|
||||
qboolean nofind;
|
||||
|
||||
#if defined(SWDS) && defined(REHLDS_FIXES)
|
||||
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", "noclip", "god", "notarget", NULL };
|
||||
#else
|
||||
const char *clcommands[23] = { "status", "god", "notarget", "fly", "name", "noclip", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "nextdl", "setinfo", "showinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
#endif
|
||||
@ -511,13 +511,20 @@ void SV_CopyEdictToPhysent(physent_t *pe, int e, edict_t *check)
|
||||
pe->vuser4[2] = check->v.vuser4[2];
|
||||
}
|
||||
|
||||
bool EXT_FUNC SV_AllowPhysent_mod(edict_t* check, edict_t* sv_player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SV_AllowPhysent(edict_t* check, edict_t* sv_player) {
|
||||
return g_RehldsHookchains.m_SV_AllowPhysent.callChain(SV_AllowPhysent_mod, check, sv_player);
|
||||
}
|
||||
|
||||
void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
||||
{
|
||||
struct link_s *l;
|
||||
edict_t *check;
|
||||
int e;
|
||||
physent_t *ve;
|
||||
int i;
|
||||
link_t *next;
|
||||
float *fmax;
|
||||
float *fmin;
|
||||
@ -547,6 +554,11 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
||||
if (check->v.solid != SOLID_BSP && check->v.solid != SOLID_BBOX && check->v.solid != SOLID_SLIDEBOX && check->v.solid != SOLID_NOT)
|
||||
continue;
|
||||
|
||||
// Apply our own custom checks
|
||||
if (!SV_AllowPhysent(check, sv_player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
e = NUM_FOR_EDICT(check);
|
||||
ve = &pmove->visents[pmove->numvisent];
|
||||
pmove->numvisent = pmove->numvisent + 1;
|
||||
@ -575,13 +587,7 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
|
||||
if (check->v.flags & FL_CLIENT)
|
||||
SV_GetTrueMinMax(e - 1, &fmin, &fmax);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (fmin[i] > pmove_maxs[i] || fmax[i] < pmove_mins[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (i != 3)
|
||||
if (!BoundsIntersect(pmove_mins, pmove_maxs, fmin, fmax))
|
||||
continue;
|
||||
|
||||
if (check->v.solid || check->v.skin != -16)
|
||||
@ -680,35 +686,33 @@ qboolean SV_PlayerRunThink(edict_t *ent, float frametime, double clienttimebase)
|
||||
return ent->free == 0;
|
||||
}
|
||||
|
||||
void SV_CheckMovingGround(edict_t *player, float frametime)
|
||||
void SV_CheckMovingGround(edict_t *ent, float frametime)
|
||||
{
|
||||
edict_t *groundentity;
|
||||
|
||||
if (player->v.flags & FL_ONGROUND)
|
||||
if (ent->v.flags & FL_ONGROUND)
|
||||
{
|
||||
groundentity = player->v.groundentity;
|
||||
groundentity = ent->v.groundentity;
|
||||
if (groundentity)
|
||||
{
|
||||
if (groundentity->v.flags & FL_CONVEYOR)
|
||||
{
|
||||
if (player->v.flags & FL_BASEVELOCITY)
|
||||
VectorMA(player->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, player->v.basevelocity);
|
||||
if (ent->v.flags & FL_BASEVELOCITY)
|
||||
VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity);
|
||||
else
|
||||
VectorScale(groundentity->v.movedir, groundentity->v.speed, player->v.basevelocity);
|
||||
player->v.flags |= FL_BASEVELOCITY;
|
||||
VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity);
|
||||
ent->v.flags |= FL_BASEVELOCITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(player->v.flags & FL_BASEVELOCITY))
|
||||
if (!(ent->v.flags & FL_BASEVELOCITY))
|
||||
{
|
||||
VectorMA(player->v.velocity, frametime * 0.5f + 1.0f, player->v.basevelocity, player->v.velocity);
|
||||
player->v.basevelocity[0] = 0;
|
||||
player->v.basevelocity[1] = 0;
|
||||
player->v.basevelocity[2] = 0;
|
||||
VectorMA(ent->v.velocity, frametime * 0.5f + 1.0f, ent->v.basevelocity, ent->v.velocity);
|
||||
VectorClear(ent->v.basevelocity);
|
||||
}
|
||||
|
||||
player->v.flags &= ~FL_BASEVELOCITY;
|
||||
ent->v.flags &= ~FL_BASEVELOCITY;
|
||||
}
|
||||
|
||||
void SV_ConvertPMTrace(trace_t *dest, pmtrace_t *src, edict_t *ent)
|
||||
@ -878,7 +882,11 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed)
|
||||
pmove->spectator = 0;
|
||||
pmove->waterjumptime = sv_player->v.teleport_time;
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
Q_memcpy(&pmove->cmd, ucmd, sizeof(pmove->cmd));
|
||||
#else
|
||||
Q_memcpy(&pmove->cmd, &cmd, sizeof(pmove->cmd));
|
||||
#endif
|
||||
|
||||
pmove->dead = sv_player->v.health <= 0.0;
|
||||
pmove->movetype = sv_player->v.movetype;
|
||||
@ -921,9 +929,17 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed)
|
||||
pmove->PM_PlaySound = PM_SV_PlaySound;
|
||||
pmove->PM_TraceTexture = PM_SV_TraceTexture;
|
||||
pmove->PM_PlaybackEventFull = PM_SV_PlaybackEventFull;
|
||||
pmove->movevars = &host_client->movevars;
|
||||
|
||||
const movevars_t movevars = *pmove->movevars; // preserve current movevars
|
||||
host_client->movevars = sv_movevars; // always use global movevars as a base
|
||||
|
||||
gEntityInterface.pfnPM_Move(pmove, TRUE);
|
||||
|
||||
// Determine whether movevars has changed or not
|
||||
if (!host_client->fakeclient && Q_memcmp(&movevars, pmove->movevars, sizeof(movevars)) != 0)
|
||||
SV_WriteMovevarsToClient(&host_client->netchan.message, pmove->movevars); // sync movevars for the client
|
||||
|
||||
sv_player->v.deadflag = pmove->deadflag;
|
||||
sv_player->v.effects = pmove->effects;
|
||||
sv_player->v.teleport_time = pmove->waterjumptime;
|
||||
|
@ -1083,6 +1083,10 @@ void LoadThisDll(const char *szDllFilename)
|
||||
goto IgnoreThisDLL;
|
||||
}
|
||||
|
||||
#ifdef REHLDS_API
|
||||
MessageManager().Init();
|
||||
#endif
|
||||
|
||||
pfnGiveFnptrsToDll(&g_engfuncsExportedToDlls, &gGlobalVariables);
|
||||
if (g_iextdllMac == MAX_EXTENSION_DLL)
|
||||
{
|
||||
@ -1150,46 +1154,47 @@ void EXT_FUNC EngineFprintf(void *pfile, const char *szFmt, ...)
|
||||
|
||||
void EXT_FUNC AlertMessage(ALERT_TYPE atype, const char *szFmt, ...)
|
||||
{
|
||||
char szOut[2048];
|
||||
va_list argptr;
|
||||
static char szOut[1024];
|
||||
|
||||
va_start(argptr, szFmt);
|
||||
if (atype == at_logged && g_psvs.maxclients > 1)
|
||||
{
|
||||
va_start(argptr, szFmt);
|
||||
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
Log_Printf("%s", szOut);
|
||||
return;
|
||||
}
|
||||
else if (developer.value != 0.0f)
|
||||
{
|
||||
switch (atype)
|
||||
{
|
||||
case at_notice:
|
||||
Q_strcpy(szOut, "NOTE: ");
|
||||
break;
|
||||
case at_console:
|
||||
szOut[0] = 0;
|
||||
break;
|
||||
case at_aiconsole:
|
||||
if (developer.value < 2.0f)
|
||||
return;
|
||||
szOut[0] = 0;
|
||||
break;
|
||||
case at_warning:
|
||||
Q_strcpy(szOut, "WARNING: ");
|
||||
break;
|
||||
case at_error:
|
||||
Q_strcpy(szOut, "ERROR: ");
|
||||
break;
|
||||
case at_logged:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
int iLen = Q_strlen(szOut);
|
||||
Q_vsnprintf(&szOut[iLen], sizeof(szOut) - iLen, szFmt, argptr);
|
||||
Con_Printf("%s", szOut);
|
||||
}
|
||||
|
||||
if (!developer.value)
|
||||
return;
|
||||
|
||||
if (atype == at_aiconsole && developer.value < 2)
|
||||
return;
|
||||
|
||||
va_start(argptr, szFmt);
|
||||
Q_vsnprintf(szOut, sizeof(szOut), szFmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
switch (atype)
|
||||
{
|
||||
case at_notice:
|
||||
Con_Printf("NOTE: %s", szOut);
|
||||
break;
|
||||
case at_console:
|
||||
case at_aiconsole:
|
||||
Con_Printf("%s", szOut);
|
||||
break;
|
||||
case at_warning:
|
||||
Con_Printf("WARNING: %s", szOut);
|
||||
break;
|
||||
case at_error:
|
||||
Con_Printf("ERROR: %s", szOut);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NOXREF void Sys_SplitPath(const char *path, char *drive, char *dir, char *fname, char *ext)
|
||||
@ -1326,7 +1331,7 @@ void Con_Printf(const char *fmt, ...)
|
||||
va_start(va, fmt);
|
||||
Q_vsnprintf(Dest, sizeof(Dest), fmt, va);
|
||||
va_end(va);
|
||||
|
||||
|
||||
g_RehldsHookchains.m_Con_Printf.callChain(Con_Printf_internal, Dest);
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,10 @@ qboolean TEX_InitFromWad(char *path)
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
texfile = FS_Open(wadPath, "rb");
|
||||
texfiles[nTexFiles++] = texfile;
|
||||
if (!texfile)
|
||||
Sys_Error("%s: couldn't open %s\n", __func__, wadPath);
|
||||
|
||||
texfiles[nTexFiles++] = texfile;
|
||||
Con_DPrintf("Using WAD File: %s\n", wadPath);
|
||||
SafeRead(texfile, &header, 12);
|
||||
if (Q_strncmp(header.identification, "WAD2", 4) && Q_strncmp(header.identification, "WAD3", 4))
|
||||
@ -147,8 +147,9 @@ void TEX_CleanupWadInfo(void)
|
||||
|
||||
for (int i = 0; i < nTexFiles; i++)
|
||||
{
|
||||
FS_Close(texfiles[i]);
|
||||
texfiles[i] = 0;
|
||||
if (texfiles[i])
|
||||
FS_Close(texfiles[i]);
|
||||
texfiles[i] = NULL;
|
||||
}
|
||||
|
||||
nTexLumps = 0;
|
||||
|
@ -31,11 +31,14 @@
|
||||
#include "maintypes.h"
|
||||
#include "quakedef.h"
|
||||
|
||||
// The maximum length of a usermessage name in a network transmission
|
||||
#define MAX_USERMESSAGES_LENGTH 16
|
||||
|
||||
typedef struct _UserMsg
|
||||
{
|
||||
int iMsg;
|
||||
int iSize;
|
||||
char szName[16];
|
||||
char szName[MAX_USERMESSAGES_LENGTH];
|
||||
struct _UserMsg *next;
|
||||
pfnUserMsgHook pfn;
|
||||
} UserMsg;
|
||||
|
@ -359,12 +359,7 @@ void SV_TouchLinks(edict_t *ent, areanode_t *node)
|
||||
if (touch->v.solid != SOLID_TRIGGER)
|
||||
continue;
|
||||
|
||||
if (ent->v.absmin[0] > touch->v.absmax[0]
|
||||
|| ent->v.absmin[1] > touch->v.absmax[1]
|
||||
|| ent->v.absmin[2] > touch->v.absmax[2]
|
||||
|| ent->v.absmax[0] < touch->v.absmin[0]
|
||||
|| ent->v.absmax[1] < touch->v.absmin[1]
|
||||
|| ent->v.absmax[2] < touch->v.absmin[2])
|
||||
if (!BoundsIntersect(ent->v.absmin, ent->v.absmax, touch->v.absmin, touch->v.absmax))
|
||||
continue;
|
||||
|
||||
// check brush triggers accuracy
|
||||
@ -647,12 +642,7 @@ int SV_LinkContents(areanode_t *node, const vec_t *pos)
|
||||
if (Mod_GetType(touch->v.modelindex) != mod_brush)
|
||||
continue;
|
||||
|
||||
if (pos[0] > touch->v.absmax[0]
|
||||
|| pos[1] > touch->v.absmax[1]
|
||||
|| pos[2] > touch->v.absmax[2]
|
||||
|| pos[0] < touch->v.absmin[0]
|
||||
|| pos[1] < touch->v.absmin[1]
|
||||
|| pos[2] < touch->v.absmin[2])
|
||||
if (!BoundsIntersect(pos, pos, touch->v.absmin, touch->v.absmax))
|
||||
continue;
|
||||
|
||||
int contents = touch->v.skin;
|
||||
@ -1190,13 +1180,15 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
||||
if (touch->v.solid == SOLID_TRIGGER)
|
||||
Sys_Error("%s: Trigger in clipping list", __func__);
|
||||
|
||||
#ifndef REHLDS_OPT_PEDANTIC
|
||||
if (gNewDLLFunctions.pfnShouldCollide && !gNewDLLFunctions.pfnShouldCollide(touch, clip->passedict))
|
||||
#ifdef REHLDS_FIXES
|
||||
// https://github.com/dreamstalker/rehlds/issues/46
|
||||
continue;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
#endif // REHLDS_FIXES
|
||||
#endif // REHLDS_OPT_PEDANTIC
|
||||
|
||||
// monsterclip filter
|
||||
if (touch->v.solid == SOLID_BSP)
|
||||
@ -1214,12 +1206,7 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
||||
if (clip->ignoretrans && touch->v.rendermode != kRenderNormal && !(touch->v.flags & FL_WORLDBRUSH))
|
||||
continue;
|
||||
|
||||
if (clip->boxmins[0] > touch->v.absmax[0]
|
||||
|| clip->boxmins[1] > touch->v.absmax[1]
|
||||
|| clip->boxmins[2] > touch->v.absmax[2]
|
||||
|| clip->boxmaxs[0] < touch->v.absmin[0]
|
||||
|| clip->boxmaxs[1] < touch->v.absmin[1]
|
||||
|| clip->boxmaxs[2] < touch->v.absmin[2])
|
||||
if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|
||||
continue;
|
||||
|
||||
if (touch->v.solid != SOLID_SLIDEBOX
|
||||
@ -1248,6 +1235,16 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
|
||||
continue; // don't clip against owner
|
||||
}
|
||||
|
||||
#ifdef REHLDS_OPT_PEDANTIC
|
||||
if (gNewDLLFunctions.pfnShouldCollide && !gNewDLLFunctions.pfnShouldCollide(touch, clip->passedict))
|
||||
#ifdef REHLDS_FIXES
|
||||
// https://github.com/dreamstalker/rehlds/issues/46
|
||||
continue;
|
||||
#else
|
||||
return;
|
||||
#endif // REHLDS_FIXES
|
||||
#endif // REHLDS_OPT_PEDANTIC
|
||||
|
||||
trace_t trace;
|
||||
if (touch->v.flags & FL_MONSTER)
|
||||
trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end);
|
||||
@ -1298,12 +1295,7 @@ void SV_ClipToWorldbrush(areanode_t *node, moveclip_t *clip)
|
||||
if (!(touch->v.flags & FL_WORLDBRUSH))
|
||||
continue;
|
||||
|
||||
if (clip->boxmins[0] > touch->v.absmax[0]
|
||||
|| clip->boxmins[1] > touch->v.absmax[1]
|
||||
|| clip->boxmins[2] > touch->v.absmax[2]
|
||||
|| clip->boxmaxs[0] < touch->v.absmin[0]
|
||||
|| clip->boxmaxs[1] < touch->v.absmin[1]
|
||||
|| clip->boxmaxs[2] < touch->v.absmin[2])
|
||||
if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|
||||
continue;
|
||||
|
||||
if (clip->trace.allsolid)
|
||||
|
@ -679,7 +679,7 @@ void Cache_Force_Flush()
|
||||
|
||||
void Cache_Flush()
|
||||
{
|
||||
if (g_pcl.maxclients <= 1 || allow_cheats)
|
||||
if (g_pcl.maxclients <= 1 || sv_cheats.value)
|
||||
{
|
||||
Cache_Force_Flush();
|
||||
}
|
||||
|
@ -119,6 +119,7 @@
|
||||
<ClCompile Include="..\rehlds\FlightRecorderImpl.cpp" />
|
||||
<ClCompile Include="..\rehlds\flight_recorder.cpp" />
|
||||
<ClCompile Include="..\rehlds\main.cpp" />
|
||||
<ClCompile Include="..\rehlds\rehlds_messagemngr_impl.cpp" />
|
||||
<ClCompile Include="..\rehlds\rehlds_api_impl.cpp" />
|
||||
<ClCompile Include="..\rehlds\rehlds_interfaces_impl.cpp" />
|
||||
<ClCompile Include="..\rehlds\hookchains_impl.cpp" />
|
||||
@ -386,6 +387,7 @@
|
||||
<ClInclude Include="..\public\rehlds\eiface.h" />
|
||||
<ClInclude Include="..\public\rehlds\FlightRecorder.h" />
|
||||
<ClInclude Include="..\public\rehlds\hookchains.h" />
|
||||
<ClInclude Include="..\public\rehlds\IMessageManager.h" />
|
||||
<ClInclude Include="..\public\rehlds\keydefs.h" />
|
||||
<ClInclude Include="..\public\rehlds\maintypes.h" />
|
||||
<ClInclude Include="..\public\rehlds\model.h" />
|
||||
@ -439,6 +441,7 @@
|
||||
<ClInclude Include="..\rehlds\FlightRecorderImpl.h" />
|
||||
<ClInclude Include="..\rehlds\flight_recorder.h" />
|
||||
<ClInclude Include="..\rehlds\hookchains_impl.h" />
|
||||
<ClInclude Include="..\rehlds\rehlds_messagemngr_impl.h" />
|
||||
<ClInclude Include="..\rehlds\platform.h" />
|
||||
<ClInclude Include="..\rehlds\precompiled.h" />
|
||||
<ClInclude Include="..\rehlds\RehldsRuntimeConfig.h" />
|
||||
@ -463,6 +466,7 @@
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\version\msvc\version.vcxproj">
|
||||
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
@ -341,6 +341,9 @@
|
||||
<ClCompile Include="..\testsuite\memory.cpp">
|
||||
<Filter>testsuite</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\rehlds\rehlds_messagemngr_impl.cpp">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\version\version.h">
|
||||
@ -1060,5 +1063,11 @@
|
||||
<ClInclude Include="..\testsuite\memory.h">
|
||||
<Filter>testsuite</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\rehlds\rehlds_messagemngr_impl.h">
|
||||
<Filter>rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\rehlds\IMessageManager.h">
|
||||
<Filter>public\rehlds</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -184,7 +184,7 @@ typedef struct playermove_s
|
||||
|
||||
char physinfo[ MAX_PHYSINFO_STRING ]; // Physics info string
|
||||
|
||||
struct movevars_s *_movevars;
|
||||
struct movevars_s *movevars;
|
||||
vec3_t player_mins[MAX_MAP_HULLS];
|
||||
vec3_t player_maxs[MAX_MAP_HULLS];
|
||||
|
||||
|
337
rehlds/public/rehlds/IMessageManager.h
Normal file
337
rehlds/public/rehlds/IMessageManager.h
Normal file
@ -0,0 +1,337 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Interface for defining message parameters and behavior for a individual message object
|
||||
*/
|
||||
class IMessage
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The parameter types for a message
|
||||
*/
|
||||
enum class ParamType : uint8
|
||||
{
|
||||
Byte,
|
||||
Char,
|
||||
Short,
|
||||
Long,
|
||||
Angle,
|
||||
Coord,
|
||||
String,
|
||||
Entity,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Blocking behavior types for messages
|
||||
*/
|
||||
enum class BlockType : uint8
|
||||
{
|
||||
Not, // Not a block
|
||||
Once, // Block once
|
||||
Set // Set block
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Message destinations
|
||||
*/
|
||||
enum class Dest : uint8
|
||||
{
|
||||
BROADCAST, // Unreliable to all
|
||||
ONE, // Reliable to one (msg_entity)
|
||||
ALL, // Reliable to all
|
||||
INIT, // Write to the init string
|
||||
PVS, // Ents in PVS of org
|
||||
PAS, // Ents in PAS of org
|
||||
PVS_R, // Reliable to PVS
|
||||
PAS_R, // Reliable to PAS
|
||||
ONE_UNRELIABLE, // Send to one client, but don't put in reliable stream, put in unreliable datagram
|
||||
SPEC, // Sends to all spectator proxies
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Data types for message data
|
||||
*/
|
||||
enum class DataType : uint8
|
||||
{
|
||||
Any, // Any part of the message
|
||||
Dest, // Destination of the message
|
||||
Index, // Index of the message
|
||||
Origin, // Origin of the message
|
||||
Edict, // Pointer to the edict of the recipient client
|
||||
Param, // Parameter of the message
|
||||
Max
|
||||
};
|
||||
|
||||
virtual ~IMessage() = default;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of parameters in the message
|
||||
* @return The number of parameters
|
||||
*/
|
||||
virtual int getParamCount() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the type of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @return The type of the parameter
|
||||
*/
|
||||
virtual ParamType getParamType(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the integer value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @return The integer value of the parameter
|
||||
*/
|
||||
virtual int getParamInt(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the float value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @return The float value of the parameter
|
||||
*/
|
||||
virtual float getParamFloat(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the string value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @return The string value of the parameter
|
||||
*/
|
||||
virtual const char* getParamString(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the integer value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @param value The integer value to set
|
||||
*/
|
||||
virtual void setParamInt(size_t index, int value) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the float value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @param value The float value to set
|
||||
*/
|
||||
virtual void setParamFloat(size_t index, float value) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the vector value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @param pos The vector value to set
|
||||
*/
|
||||
virtual void setParamVec(size_t index, const float *pos) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the string value of the parameter at the given index
|
||||
* @param index The index of the parameter
|
||||
* @param string The string value to set
|
||||
*/
|
||||
virtual void setParamString(size_t index, const char *string) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the destination of the message
|
||||
* @return The destination of the message
|
||||
*/
|
||||
virtual Dest getDest() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the index of the message
|
||||
* @return The index of the message
|
||||
*/
|
||||
virtual int getId() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the origin of the message
|
||||
* @return The origin of the message
|
||||
*/
|
||||
virtual const float* getOrigin() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the edict associated with the message
|
||||
* @return The edict associated with the message
|
||||
*/
|
||||
virtual struct edict_s* getEdict() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Checks if the specified type of message data has been modified
|
||||
*
|
||||
* This function allows you to check if any part of the message data, such as its
|
||||
* destination, type, origin, edict, or any specific parameter, has been modified
|
||||
*
|
||||
* @param type The type of the data to check for modification
|
||||
* This can be one of the following:
|
||||
* - DataType::Any: Check if any part of the message has been modified
|
||||
* - DataType::Dest: Check if the destination has been modified
|
||||
* - DataType::Index: Check if the message ID has been modified
|
||||
* - DataType::Origin: Check if the origin has been modified
|
||||
* - DataType::Edict: Check if the edict pointer has been modified
|
||||
* - DataType::Param: Check if a specific parameter has been modified
|
||||
*
|
||||
* @param index The index of the parameter to check for modification (used only when type is DataType::Param)
|
||||
* Default value is -1, which means the parameter index is not applicable
|
||||
*
|
||||
* @return True if the specified data type has been modified, false otherwise
|
||||
*/
|
||||
virtual bool isDataModified(DataType type = DataType::Any, size_t index = -1) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Resets a specific type of message data to its original value
|
||||
*
|
||||
* @param type The type of data to reset to its original value
|
||||
* This can be one of the following:
|
||||
* - DataType::Any: Reset all modified message data to its original values
|
||||
* - DataType::Dest: Reset the destination to its original value
|
||||
* - DataType::Index: Reset the message ID to its original value
|
||||
* - DataType::Origin: Reset the origin to its original value
|
||||
* - DataType::Edict: Reset the edict pointer of the recipient client to its original value
|
||||
* - DataType::Param: Reset a specific parameter to its original value
|
||||
*
|
||||
* @param index The index of the parameter to reset (used only when type is DataType::Param)
|
||||
* Default value is -1, which means the parameter index is not applicable
|
||||
*
|
||||
* @return True if the modified data type was reset, false otherwise
|
||||
*/
|
||||
virtual bool resetModifiedData(DataType type = DataType::Any, size_t index = -1) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the destination of the message
|
||||
*/
|
||||
virtual void setDest(Dest dest) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the index of the message
|
||||
*/
|
||||
virtual void setId(int msg_id) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the origin of the message
|
||||
*/
|
||||
virtual void setOrigin(const float *origin) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the edict associated with the message
|
||||
*/
|
||||
virtual void setEdict(struct edict_s *pEdict) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original destination of the message before any modifications
|
||||
* @return The original destination of the message
|
||||
*/
|
||||
virtual Dest getOriginalDest() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original type of the message before any modifications
|
||||
* @return The original type of the message
|
||||
*/
|
||||
virtual int getOriginalId() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original origin of the message before any modifications
|
||||
* @return The original origin of the message
|
||||
*/
|
||||
virtual const float* getOriginalOrigin() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original edict associated with the message before any modifications
|
||||
* @return The original edict associated with the message
|
||||
*/
|
||||
virtual struct edict_s* getOriginalEdict() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original integer value of the parameter at the given index before any modifications
|
||||
* @param index The index of the parameter
|
||||
* @return The original integer value of the parameter
|
||||
*/
|
||||
virtual int getOriginalParamInt(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original float value of the parameter at the given index before any modifications
|
||||
* @param index The index of the parameter
|
||||
* @return The original float value of the parameter
|
||||
*/
|
||||
virtual float getOriginalParamFloat(size_t index) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the original string value of the parameter at the given index before any modifications
|
||||
* @param index The index of the parameter
|
||||
* @return The original string value of the parameter
|
||||
*/
|
||||
virtual const char* getOriginalParamString(size_t index) const = 0;
|
||||
|
||||
// This must be the last virtual function in class
|
||||
#ifdef REHLDS_SELF
|
||||
// Set the copyback buffer for the message
|
||||
virtual void setCopybackBuffer(struct sizebuf_s *pbuf) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define MESSAGEMNGR_VERSION_MAJOR 2
|
||||
#define MESSAGEMNGR_VERSION_MINOR 0
|
||||
|
||||
/**
|
||||
* @brief Interface manages hooks and blocking behavior game messages
|
||||
*/
|
||||
class IMessageManager
|
||||
{
|
||||
public:
|
||||
using hookfunc_t = void (*)(IVoidHookChain<IMessage *> *chain, IMessage *msg);
|
||||
|
||||
virtual ~IMessageManager() = default;
|
||||
|
||||
/**
|
||||
* @brief Returns the major version of the MessageManager
|
||||
* @return The major version
|
||||
*/
|
||||
virtual int getMajorVersion() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the minor version of the MessageManager
|
||||
* @return The minor version
|
||||
*/
|
||||
virtual int getMinorVersion() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns the blocking behavior for the given message type
|
||||
* @param msg_id The message type
|
||||
* @return The blocking behavior for the given message type
|
||||
*/
|
||||
virtual IMessage::BlockType getMessageBlock(int msg_id) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the blocking behavior for the given message type
|
||||
* @param msg_id The message type
|
||||
* @param blockType The blocking behavior to set
|
||||
*/
|
||||
virtual void setMessageBlock(int msg_id, IMessage::BlockType blockType) = 0;
|
||||
|
||||
/**
|
||||
* @brief Registers a hook function for the given message type
|
||||
* @param msg_id The message type to register the hook for
|
||||
* @param handler The hook function to register
|
||||
* @param priority The priority of the hook function (see enum HookChainPriority)
|
||||
*/
|
||||
virtual void registerHook(int msg_id, hookfunc_t handler, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
|
||||
/**
|
||||
* @brief Unregisters a hook function for the given message type
|
||||
* @param msg_id The message type to unregister the hook for
|
||||
* @param handler The hook function to unregister
|
||||
*/
|
||||
virtual void unregisterHook(int msg_id, hookfunc_t handler) = 0;
|
||||
};
|
@ -32,6 +32,7 @@
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
|
||||
#define MAX_MAP_HULLS 4
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
|
||||
#define CONTENTS_ORIGIN -7 // removed at csg time
|
||||
#define CONTENTS_CLIP -8 // changed to contents_solid
|
||||
|
@ -67,4 +67,12 @@ typedef enum sv_delta_s
|
||||
sv_packet_delta,
|
||||
} sv_delta_t;
|
||||
|
||||
// From engine/server.h
|
||||
typedef enum server_state_e
|
||||
{
|
||||
ss_dead = 0,
|
||||
ss_loading = 1,
|
||||
ss_active = 2,
|
||||
} server_state_t;
|
||||
|
||||
#endif // MAINTYPES_H
|
||||
|
@ -144,6 +144,13 @@ struct msurface_s
|
||||
// surface generation data
|
||||
struct surfcache_s *cachespots[MIPLEVELS];
|
||||
|
||||
// Maximum s/t texture size on the surface
|
||||
#if defined(GLQUAKE) || defined(SWDS)
|
||||
#define MAX_SURFACE_TEXTURE_SIZE 512
|
||||
#else
|
||||
#define MAX_SURFACE_TEXTURE_SIZE 256 // Software rendering is limited to 256
|
||||
#endif
|
||||
|
||||
short texturemins[2]; // smallest s/t position on the surface.
|
||||
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
|
||||
|
||||
|
@ -31,13 +31,14 @@
|
||||
#include "rehlds_interfaces.h"
|
||||
#include "hookchains.h"
|
||||
#include "FlightRecorder.h"
|
||||
#include "IMessageManager.h"
|
||||
#include "interface.h"
|
||||
#include "model.h"
|
||||
#include "ObjectList.h"
|
||||
#include "pr_dlls.h"
|
||||
|
||||
#define REHLDS_API_VERSION_MAJOR 3
|
||||
#define REHLDS_API_VERSION_MINOR 12
|
||||
#define REHLDS_API_VERSION_MINOR 14
|
||||
|
||||
//Steam_NotifyClientConnect hook
|
||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||
@ -255,6 +256,14 @@ typedef IVoidHookChainRegistry<resourcetype_t, const char *, int, unsigned char,
|
||||
typedef IVoidHookChain<const char *> IRehldsHook_SV_ClientPrintf;
|
||||
typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf;
|
||||
|
||||
//SV_AllowPhysent hook
|
||||
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
|
||||
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_SV_AllowPhysent;
|
||||
|
||||
//SV_SendResources hook
|
||||
typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_SendResources;
|
||||
typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_SendResources;
|
||||
|
||||
class IRehldsHookchains {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -313,6 +322,8 @@ public:
|
||||
virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0;
|
||||
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
|
||||
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
|
||||
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
|
||||
virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources() = 0;
|
||||
};
|
||||
|
||||
struct RehldsFuncs_t {
|
||||
@ -436,6 +447,7 @@ public:
|
||||
virtual IRehldsServerStatic* GetServerStatic() = 0;
|
||||
virtual IRehldsServerData* GetServerData() = 0;
|
||||
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
|
||||
virtual IMessageManager *GetMessageManager() = 0;
|
||||
};
|
||||
|
||||
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
|
||||
|
@ -36,6 +36,7 @@ class IGameClient;
|
||||
|
||||
#include "common_rehlds.h"
|
||||
#include "userid_rehlds.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
#ifdef REHLDS_SELF
|
||||
#include "server.h"
|
||||
|
@ -90,3 +90,7 @@ void AbstractHookChainRegistry::removeHook(void* hookFunc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int AbstractHookChainRegistry::getCount() const {
|
||||
return m_NumHooks;
|
||||
}
|
||||
|
@ -109,10 +109,11 @@ protected:
|
||||
|
||||
protected:
|
||||
void addHook(void* hookFunc, int priority);
|
||||
bool findHook(void* hookFunc) const;
|
||||
void removeHook(void* hookFunc);
|
||||
|
||||
public:
|
||||
int getCount() const;
|
||||
bool findHook(void* hookFunc) const;
|
||||
AbstractHookChainRegistry();
|
||||
};
|
||||
|
||||
@ -132,9 +133,14 @@ public:
|
||||
EXT_FUNC virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
|
||||
EXT_FUNC virtual void unregisterHook(hookfunc_t hook) {
|
||||
removeHook((void*)hook);
|
||||
}
|
||||
|
||||
bool isEmpty() const {
|
||||
return getCount() == 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ...t_args>
|
||||
@ -157,4 +163,8 @@ public:
|
||||
EXT_FUNC virtual void unregisterHook(hookfunc_t hook) {
|
||||
removeHook((void*)hook);
|
||||
}
|
||||
|
||||
bool isEmpty() const {
|
||||
return getCount() == 0;
|
||||
}
|
||||
};
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "rehlds_api_impl.h"
|
||||
#include "FlightRecorderImpl.h"
|
||||
#include "flight_recorder.h"
|
||||
#include "rehlds_messagemngr_impl.h"
|
||||
#include "rehlds_security.h"
|
||||
|
||||
#include "dlls/cdll_dll.h"
|
||||
|
@ -52,7 +52,9 @@ char* EXT_FUNC GetClientFallback_api() {
|
||||
}
|
||||
|
||||
int* EXT_FUNC GetAllowCheats_api() {
|
||||
return &allow_cheats;
|
||||
static int sv_cheats_stub = 0;
|
||||
Con_Printf("WARNING! allow_cheats marked as deprecated! Use sv_cheats cvar directly!\n");
|
||||
return &sv_cheats_stub;
|
||||
}
|
||||
|
||||
bool EXT_FUNC GSBSecure_api() {
|
||||
@ -456,6 +458,16 @@ void EXT_FUNC RemoveCvarListener_api(const char *var_name, cvar_callback_t func)
|
||||
}
|
||||
}
|
||||
|
||||
void EXT_FUNC SV_SetMoveVars_api()
|
||||
{
|
||||
SV_SetMoveVars(&sv_movevars);
|
||||
}
|
||||
|
||||
void EXT_FUNC SV_WriteMovevarsToClient_api(sizebuf_t *message)
|
||||
{
|
||||
SV_WriteMovevarsToClient(message, &sv_movevars);
|
||||
}
|
||||
|
||||
CRehldsServerStatic g_RehldsServerStatic;
|
||||
CRehldsServerData g_RehldsServerData;
|
||||
CRehldsHookchains g_RehldsHookchains;
|
||||
@ -473,8 +485,8 @@ RehldsFuncs_t g_RehldsApiFuncs =
|
||||
&SV_CheckChallenge_api,
|
||||
&SV_SendUserReg,
|
||||
&SV_WriteDeltaDescriptionsToClient,
|
||||
&SV_SetMoveVars,
|
||||
&SV_WriteMovevarsToClient,
|
||||
&SV_SetMoveVars_api,
|
||||
&SV_WriteMovevarsToClient_api,
|
||||
&GetClientFallback_api,
|
||||
&GetAllowCheats_api,
|
||||
&GSBSecure_api,
|
||||
@ -567,7 +579,7 @@ bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, in
|
||||
bool bSendPAS = (channel != CHAN_STATIC && !(flags & SND_FL_STOP) && !(emitFlags & SND_EMIT2_NOPAS));
|
||||
vec3_t origin = {0, 0, 0};
|
||||
|
||||
if (entity && entity != g_psv.edicts)
|
||||
if ((!pOrigin || !(emitFlags & SND_EMIT2_USE_ORIGIN)) && entity && entity != g_psv.edicts)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
origin[i] = (entity->v.maxs[i] + entity->v.mins[i]) * 0.5f + entity->v.origin[i];
|
||||
@ -879,6 +891,14 @@ IRehldsHookRegistry_SV_ClientPrintf* CRehldsHookchains::SV_ClientPrintf(){
|
||||
return &m_SV_ClientPrintf;
|
||||
}
|
||||
|
||||
IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() {
|
||||
return &m_SV_AllowPhysent;
|
||||
}
|
||||
|
||||
IRehldsHookRegistry_SV_SendResources* CRehldsHookchains::SV_SendResources() {
|
||||
return &m_SV_SendResources;
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||
{
|
||||
return REHLDS_API_VERSION_MAJOR;
|
||||
@ -907,6 +927,10 @@ IRehldsServerData* EXT_FUNC CRehldsApi::GetServerData() {
|
||||
return &g_RehldsServerData;
|
||||
}
|
||||
|
||||
IMessageManager* EXT_FUNC CRehldsApi::GetMessageManager() {
|
||||
return &MessageManager();
|
||||
}
|
||||
|
||||
IRehldsFlightRecorder* EXT_FUNC CRehldsApi::GetFlightRecorder() {
|
||||
return g_FlightRecorder;
|
||||
}
|
||||
|
@ -250,6 +250,14 @@ typedef IVoidHookChainRegistryImpl<resourcetype_t, const char*, int, unsigned ch
|
||||
typedef IVoidHookChainImpl<const char*> CRehldsHook_SV_ClientPrintf;
|
||||
typedef IVoidHookChainRegistryImpl<const char*> CRehldsHookRegistry_SV_ClientPrintf;
|
||||
|
||||
//SV_AllowPhysent hook
|
||||
typedef IHookChainImpl<bool, edict_t*, edict_t*> CRehldsHook_SV_AllowPhysent;
|
||||
typedef IHookChainRegistryImpl<bool, edict_t*, edict_t*> CRehldsHookRegistry_SV_AllowPhysent;
|
||||
|
||||
//SV_SendResources hook
|
||||
typedef IVoidHookChainImpl<sizebuf_t *> CRehldsHook_SV_SendResources;
|
||||
typedef IVoidHookChainRegistryImpl<sizebuf_t *> CRehldsHookRegistry_SV_SendResources;
|
||||
|
||||
class CRehldsHookchains : public IRehldsHookchains {
|
||||
public:
|
||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||
@ -306,6 +314,8 @@ public:
|
||||
CRehldsHookRegistry_EV_Precache m_EV_Precache;
|
||||
CRehldsHookRegistry_SV_AddResource m_SV_AddResource;
|
||||
CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf;
|
||||
CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent;
|
||||
CRehldsHookRegistry_SV_SendResources m_SV_SendResources;
|
||||
|
||||
public:
|
||||
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||
@ -362,6 +372,8 @@ public:
|
||||
EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent();
|
||||
EXT_FUNC virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources();
|
||||
};
|
||||
|
||||
extern CRehldsHookchains g_RehldsHookchains;
|
||||
@ -379,6 +391,7 @@ public:
|
||||
virtual IRehldsServerStatic* GetServerStatic();
|
||||
virtual IRehldsServerData* GetServerData();
|
||||
virtual IRehldsFlightRecorder* GetFlightRecorder();
|
||||
virtual IMessageManager* GetMessageManager();
|
||||
};
|
||||
|
||||
extern sizebuf_t* GetNetMessage_api();
|
||||
|
@ -530,6 +530,15 @@ netchan_t* EXT_FUNC CNetChan::GetChan()
|
||||
return m_pNetChan;
|
||||
}
|
||||
|
||||
void CNetChan::Clear()
|
||||
{
|
||||
for (int i = 0; i < MAX_STREAMS; i++)
|
||||
{
|
||||
for (int j = 0; j < NET_DECOMPRESS_MAX_TIMES; j++)
|
||||
m_FragStats[i].decompress_failure_times[j] = 0;
|
||||
m_FragStats[i].num_decompress_failures = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EXT_FUNC CRehldsServerStatic::GetMaxClients()
|
||||
|
@ -30,6 +30,16 @@
|
||||
#include "rehlds_interfaces.h"
|
||||
#include "server.h"
|
||||
|
||||
const int NET_DECOMPRESS_MAX_TIMES = 10;
|
||||
|
||||
struct FragStats_t
|
||||
{
|
||||
float decompress_failure_times[NET_DECOMPRESS_MAX_TIMES];
|
||||
|
||||
// Count of abnormal fragment decompressions in a time window
|
||||
int num_decompress_failures;
|
||||
};
|
||||
|
||||
class CNetChan : public INetChan
|
||||
{
|
||||
private:
|
||||
@ -38,6 +48,10 @@ private:
|
||||
#ifdef REHLDS_FIXES
|
||||
uint8_t m_messageBuffer[NET_MAX_PAYLOAD];
|
||||
#endif
|
||||
|
||||
// Stats for decompression of incoming fragments
|
||||
FragStats_t m_FragStats[MAX_STREAMS];
|
||||
|
||||
public:
|
||||
CNetChan(netchan_t* chan);
|
||||
|
||||
@ -46,10 +60,13 @@ public:
|
||||
|
||||
virtual netchan_t* GetChan();
|
||||
|
||||
void Clear();
|
||||
|
||||
public:
|
||||
#ifdef REHLDS_FIXES
|
||||
uint8_t* GetExtendedMessageBuffer() { return m_messageBuffer; };
|
||||
#endif
|
||||
FragStats_t &GetFragStats(int stream) { return m_FragStats[stream]; };
|
||||
};
|
||||
|
||||
|
||||
@ -247,6 +264,9 @@ public:
|
||||
uint8_t* GetExtendedMessageBuffer() { return m_NetChan.GetExtendedMessageBuffer(); };
|
||||
#endif
|
||||
|
||||
void NetchanClear() { m_NetChan.Clear(); }
|
||||
FragStats_t &GetFragStats(int stream) { return m_NetChan.GetFragStats(stream); };
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
void SetupLocalGameTime() { m_localGameTimeBase = g_psv.time; }
|
||||
double GetLocalGameTime() const { return g_psv.time - m_localGameTimeBase; }
|
||||
|
1085
rehlds/rehlds/rehlds_messagemngr_impl.cpp
Normal file
1085
rehlds/rehlds/rehlds_messagemngr_impl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
183
rehlds/rehlds/rehlds_messagemngr_impl.h
Normal file
183
rehlds/rehlds/rehlds_messagemngr_impl.h
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IMessageManager.h"
|
||||
#include "hookchains.h"
|
||||
|
||||
#include <memory> // std::unique_ptr
|
||||
#include <algorithm> // std::move
|
||||
|
||||
/**
|
||||
* @brief Implementation interface manages hooks and blocking behavior game messages
|
||||
*/
|
||||
class MessageManagerImpl: public IMessageManager
|
||||
{
|
||||
public:
|
||||
|
||||
void Init();
|
||||
|
||||
MessageManagerImpl();
|
||||
~MessageManagerImpl() = default;
|
||||
|
||||
/**
|
||||
* @brief Returns the major version of the MessageManager
|
||||
* @return The major version
|
||||
*/
|
||||
int getMajorVersion() const { return MESSAGEMNGR_VERSION_MAJOR; }
|
||||
|
||||
/**
|
||||
* @brief Returns the minor version of the MessageManager
|
||||
* @return The minor version
|
||||
*/
|
||||
int getMinorVersion() const { return MESSAGEMNGR_VERSION_MINOR; }
|
||||
|
||||
/**
|
||||
* @brief Returns the blocking behavior for the given message type
|
||||
* @param msg_id The message type
|
||||
* @return The blocking behavior for the given message type
|
||||
*/
|
||||
IMessage::BlockType getMessageBlock(int msg_id) const;
|
||||
|
||||
/**
|
||||
* @brief Sets the blocking behavior for the given message type
|
||||
* @param msg_id The message type
|
||||
* @param blockType The blocking behavior to set
|
||||
*/
|
||||
void setMessageBlock(int msg_id, IMessage::BlockType blockType);
|
||||
|
||||
/**
|
||||
* @brief Registers a hook function for the given message type
|
||||
* @param msg_id The message type to register the hook for
|
||||
* @param handler The hook function to register
|
||||
* @param priority The priority of the hook function (see enum HookChainPriority)
|
||||
*/
|
||||
void registerHook(int msg_id, hookfunc_t handler, int priority = HC_PRIORITY_DEFAULT);
|
||||
|
||||
/**
|
||||
* @brief Unregisters a hook function for the given message type
|
||||
* @param msg_id The message type to unregister the hook for
|
||||
* @param handler The hook function to unregister
|
||||
*/
|
||||
void unregisterHook(int msg_id, hookfunc_t handler);
|
||||
|
||||
private:
|
||||
friend void PF_MessageBegin_Intercept(int msg_dest, int msg_id, const float *pOrigin, edict_t *ed);
|
||||
friend void PF_MessageEnd_Intercept();
|
||||
friend void PF_WriteByte_Intercept(int iValue);
|
||||
friend void PF_WriteChar_Intercept(int iValue);
|
||||
friend void PF_WriteShort_Intercept(int iValue);
|
||||
friend void PF_WriteLong_Intercept(int iValue);
|
||||
friend void PF_WriteAngle_Intercept(float flValue);
|
||||
friend void PF_WriteCoord_Intercept(float flValue);
|
||||
friend void PF_WriteString_Intercept(const char *sz);
|
||||
friend void PF_WriteEntity_Intercept(int iValue);
|
||||
|
||||
bool MessageBegin(int msg_dest, int msg_id, const float *pOrigin, edict_t *ed);
|
||||
bool MessageEnd();
|
||||
|
||||
private:
|
||||
bool WriteParam(IMessage::ParamType type, bool sign = false, size_t length = -1);
|
||||
|
||||
bool m_inblock; // Flag indicating whether a message block is currently active
|
||||
bool m_inhook; // Flag indicating whether a message hook is currently active
|
||||
|
||||
/**
|
||||
* @brief The fixed-size memory pool holds a list of free objects
|
||||
* @tparam T The type of objects stored in the stack
|
||||
* @tparam MAX The maximum size of the stack
|
||||
*/
|
||||
template <typename T, size_t MAX>
|
||||
class MessagePool
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<T> acquire()
|
||||
{
|
||||
if (_size > 0)
|
||||
return std::move(_freeObjects[--_size]); // reusing
|
||||
return std::make_unique<T>(); // initialize constructor for new element
|
||||
}
|
||||
|
||||
void release(std::unique_ptr<T> obj)
|
||||
{
|
||||
if (_size < MAX)
|
||||
_freeObjects[_size++] = std::move(obj);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
while (_size > 0)
|
||||
_freeObjects[--_size].reset();
|
||||
}
|
||||
|
||||
private:
|
||||
size_t _size{0u};
|
||||
std::unique_ptr<T> _freeObjects[MAX]{};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Helper a templated MessageStack class to manage a stack of Message objects with fixed size
|
||||
* @tparam T The type of objects stored in the stack
|
||||
* @tparam MAX The maximum size of the stack
|
||||
*/
|
||||
template <typename T, size_t MAX>
|
||||
class MessageStack
|
||||
{
|
||||
public:
|
||||
MessageStack(MessagePool<T, MAX> &pool) : _pool(pool) {}
|
||||
|
||||
T &push()
|
||||
{
|
||||
std::unique_ptr<T> msg = _pool.acquire();
|
||||
_activeObjects[_size++] = std::move(msg);
|
||||
return *_activeObjects[_size - 1];
|
||||
}
|
||||
|
||||
void pop()
|
||||
{
|
||||
if (_size > 0)
|
||||
_pool.release(std::move(_activeObjects[--_size]));
|
||||
}
|
||||
|
||||
size_t size() const { return _size; }
|
||||
size_t max_size() const { return MAX; }
|
||||
|
||||
const T &top() const { return *_activeObjects[_size - 1]; }
|
||||
T &top() { return *_activeObjects[_size - 1]; }
|
||||
|
||||
private:
|
||||
size_t _size{0u};
|
||||
std::unique_ptr<T> _activeObjects[MAX]{};
|
||||
MessagePool<T, MAX> &_pool;
|
||||
};
|
||||
|
||||
static const size_t MAX_MSGSTACK = 16; // The maximum size of the message stack, 16 it should be enough
|
||||
MessagePool<class MessageImpl, MAX_MSGSTACK> m_pool; // A fixed-size memory pool stack for reusable
|
||||
MessageStack<class MessageImpl, MAX_MSGSTACK> m_stack;
|
||||
|
||||
using HookRegistry_t = IVoidHookChainRegistryImpl<IMessage *>;
|
||||
HookRegistry_t *m_hooks[MAX_USERMESSAGES]{};
|
||||
|
||||
IMessage::BlockType m_blocks[MAX_USERMESSAGES]{}; // The array of blocking behaviors for each message type
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The singleton instance of the MessageManager
|
||||
*/
|
||||
extern MessageManagerImpl &MessageManager();
|
@ -13,7 +13,9 @@ void check_size() {
|
||||
|
||||
|
||||
void checkSizesStatic() {
|
||||
CHECK_TYPE_SIZE(client_t, 0x5018, 0x4EF4);
|
||||
// CHECK_TYPE_SIZE(client_t, 0x5018, 0x4EF4);
|
||||
CHECK_TYPE_SIZE(userfilter_t, 0x20, 0x18);
|
||||
#ifndef REHLDS_FIXES
|
||||
CHECK_TYPE_SIZE(CSteam3Server, 0x90, 0xA8);
|
||||
#endif
|
||||
}
|
||||
|
@ -6,5 +6,5 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 12
|
||||
#define VERSION_MINOR 14
|
||||
#define VERSION_MAINTENANCE 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user