diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5e9f100 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,300 @@ +name: C/C++ CI + +on: + push: + branches: [master] + paths-ignore: + - '**.md' + + pull_request: + types: [opened, reopened, synchronize] + release: + types: [published] + +jobs: + windows: + name: 'Windows' + runs-on: windows-latest + + env: + solution: 'msvc/ReHLDS.sln' + buildPlatform: 'Win32' + buildRelease: 'Release' + buildReleasePlay: 'Release Play' + buildTest: 'Test Fixes' + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build and Run unittests + run: | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTest }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + .\"msvc\Test Fixes\swds.exe" + If ($LASTEXITCODE -ne 0 -And + $LASTEXITCODE -ne 3) + {[Environment]::Exit(1)} + shell: "pwsh" + + - name: Build + run: | + 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: Move files + run: | + mkdir publish\debug + mkdir publish\tests + mkdir publish\bin\win32\valve\dlls + move "msvc\${{ env.buildReleasePlay }}\swds.dll" publish\tests\swds.dll + move msvc\${{ env.buildRelease }}\hlds.exe publish\bin\win32\hlds.exe + move msvc\${{ env.buildRelease }}\hltv.exe publish\bin\win32\hltv.exe + move msvc\${{ env.buildRelease }}\swds.dll publish\bin\win32\swds.dll + move msvc\${{ env.buildRelease }}\core.dll publish\bin\win32\core.dll + move msvc\${{ env.buildRelease }}\proxy.dll publish\bin\win32\proxy.dll + move msvc\${{ env.buildRelease }}\demoplayer.dll publish\bin\win32\demoplayer.dll + move msvc\${{ env.buildRelease }}\filesystem_stdio.dll publish\bin\win32\filesystem_stdio.dll + move msvc\${{ env.buildRelease }}\director.dll publish\bin\win32\valve\dlls\director.dll + move msvc\${{ env.buildRelease }}\hlds.pdb publish\debug\hlds.pdb + move msvc\${{ env.buildRelease }}\hltv.pdb publish\debug\hltv.pdb + move msvc\${{ env.buildRelease }}\swds.pdb publish\debug\swds.pdb + move msvc\${{ env.buildRelease }}\core.pdb publish\debug\core.pdb + move msvc\${{ env.buildRelease }}\proxy.pdb publish\debug\proxy.pdb + move msvc\${{ env.buildRelease }}\demoplayer.pdb publish\debug\demoplayer.pdb + move msvc\${{ env.buildRelease }}\filesystem_stdio.pdb publish\debug\filesystem_stdio.pdb + move msvc\${{ env.buildRelease }}\director.pdb publish\debug\director.pdb + + - name: Deploy artifacts + uses: actions/upload-artifact@v2 + with: + name: win32 + path: publish/* + + testdemos: + name: 'Test demos' + runs-on: ubuntu-latest + container: s1lentq/testdemos:latest + needs: [windows] + + env: + WINEDEBUG: -all + WINEDLLOVERRIDES: mshtml= + + defaults: + run: + shell: bash + working-directory: ../../../opt/HLDS + + steps: + - name: Deploying windows artifacts + uses: actions/download-artifact@v2 + with: + name: win32 + + - name: Play demos + 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 + + linux: + name: 'Linux' + runs-on: ubuntu-latest + container: s1lentq/linux86buildtools:latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Build and Run unittests + run: | + rm -rf build && CC=icc CXX=icpc 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=$? + while read line; do + if [[ ${line} == *"Warning in test"* ]] ; then + echo -e "\e[2;38m$line" + elif [[ ${line} == *"Failure in test"* ]] ; then + echo -e "\e[1;31m$line" + else + echo -e "\e[0;33m$line" + fi + done <<< $(cat result.log) + + if [ $retVal -ne 0 ] && [ $retVal -ne 3 ]; then + echo -e "\e[30;41mExit code: $retVal\e[0m" + exit 1 # Unittest failed + else + echo -e "\e[30;43mExit code: $retVal\e[0m" + fi + shell: bash + + - name: Build using Intel C++ Compiler + run: | + rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8 + + - name: Prepare HLSDK + run: | + mkdir -p publish/hlsdk + rsync -a rehlds/common/ publish/hlsdk/common/ + rsync -a rehlds/dlls/ publish/hlsdk/dlls/ + rsync -a rehlds/pm_shared/ publish/hlsdk/pm_shared/ + rsync -a rehlds/public/ publish/hlsdk/public/ --exclude rehlds/ + rsync -a rehlds/public/rehlds/ publish/hlsdk/engine + + - name: Move files + run: | + mkdir -p publish/bin/linux32/valve/dlls + mv build/rehlds/engine_i486.so publish/bin/linux32/engine_i486.so + mv rehlds/version/appversion.h publish/appversion.h + mv build/rehlds/dedicated/hlds_linux publish/bin/linux32/hlds_linux + mv build/rehlds/HLTV/Console/hltv publish/bin/linux32/hltv + mv build/rehlds/HLTV/Core/core.so publish/bin/linux32/core.so + mv build/rehlds/HLTV/Proxy/proxy.so publish/bin/linux32/proxy.so + mv build/rehlds/HLTV/DemoPlayer/demoplayer.so publish/bin/linux32/demoplayer.so + mv build/rehlds/HLTV/Director/director.so publish/bin/linux32/valve/dlls/director.so + mv build/rehlds/filesystem/FileSystem_Stdio/filesystem_stdio.so publish/bin/linux32/filesystem_stdio.so + + - name: Run GLIBC/ABI version compat test + run: | + binaries=( + "publish/bin/linux32/engine_i486.so" + "publish/bin/linux32/hlds_linux" + "publish/bin/linux32/hltv" + "publish/bin/linux32/core.so" + "publish/bin/linux32/proxy.so" + "publish/bin/linux32/demoplayer.so" + "publish/bin/linux32/valve/dlls/director.so" + "publish/bin/linux32/filesystem_stdio.so" + ) + bash ./rehlds/version/glibc_test.sh ${binaries[@]} + if [[ $? -ne 0 ]]; then + exit 1 # Assertion failed + fi + shell: bash + + - name: Deploy artifacts + uses: actions/upload-artifact@v2 + 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 + needs: [windows, testdemos, linux] + + steps: + - name: Deploying linux artifacts + uses: actions/download-artifact@v2 + with: + name: linux32 + + - name: Deploying windows artifacts + uses: actions/download-artifact@v2 + with: + name: win32 + + - name: Reading appversion.h + run: | + if [ -e appversion.h ]; then + APP_VERSION=$(cat appversion.h | grep -wi '#define APP_VERSION_STRD' | sed -e 's/#define APP_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') + if [ $? -ne 0 ]; then + APP_VERSION="" + else + # Remove quotes + APP_VERSION=$(echo $APP_VERSION | xargs) + echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV + fi + fi + rm -f appversion.h + + - name: 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/ + 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -aoa rehlds-dbg-${{ env.APP_VERSION }}.7z debug/ + + - name: Publish artifacts + uses: softprops/action-gh-release@v1 + id: publish-job + if: | + startsWith(github.ref, 'refs/tags/') && + steps.packaging-job.outcome == 'success' + with: + files: | + *.zip + *.7z + 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 diff --git a/.gitignore b/.gitignore index 574a0f2..62b7799 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ **/build -**/.gradle -.idea *.iml *.bat *.log *.lnk +*.aps **/msvc/Debug* **/msvc/Release* **/msvc/Tests @@ -21,6 +20,3 @@ **/msvc/ipch rehlds/version/appversion.h -rehlds/_rehldsTestImg -rehlds/_dev -publish diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bf5cea6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) +project(rehlds CXX) + +if (WIN32) + message(FATAL_ERROR "CMakeLists.txt Windows platform isn't supported yet. Use msvc/ReHLDS.sln instead it!") +endif() + +add_custom_target(appversion DEPENDS + COMMAND "${PROJECT_SOURCE_DIR}/rehlds/version/appversion.sh" "${PROJECT_SOURCE_DIR}" +) + +add_subdirectory(rehlds) + +if (NOT CMAKE_BUILD_TYPE MATCHES Unittests) + add_subdirectory(rehlds/dedicated) + add_subdirectory(rehlds/filesystem) + add_subdirectory(rehlds/HLTV) +endif() diff --git a/README.md b/README.md index a728d7d..52e965c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# Rehlds [![Build Status](http://teamcity.rehlds.org/app/rest/builds/buildType:(id:Rehlds_Publish)/statusIcon)](http://teamcity.rehlds.org/viewType.html?buildTypeId=Rehlds_Publish&guest=1) [![Download](https://camo.githubusercontent.com/65c70643ec7b40eea50971003624c2fb04d8d375/687474703a2f2f7265686c64732e6f72672f76657273696f6e2f7265686c64732e737667)](http://teamcity.rehlds.org/guestAuth/downloadArtifacts.html?buildTypeId=Rehlds_Publish&buildId=lastSuccessful) - +# ReHLDS [![C/C++ CI](https://github.com/dreamstalker/rehlds/actions/workflows/build.yml/badge.svg)](https://github.com/dreamstalker/rehlds/actions/workflows/build.yml) [![Download](https://camo.githubusercontent.com/7ab483250adb4037b26e9575331218ee51108190d0938b7836d32f1209ccf907/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f647265616d7374616c6b65722f7265686c64732e737667)](https://github.com/dreamstalker/rehlds/releases/latest) [![Downloads](https://camo.githubusercontent.com/d37654956d99bb9fb7a348fdac39b214d6ae14a7cfb9f96bf873c6b46cdf9ef6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f647265616d7374616c6b65722f7265686c64732f746f74616c3f636f6c6f723d696d706f7274616e74)]() [![Percentage of issues still open](http://isitmaintained.com/badge/open/dreamstalker/rehlds.svg)](http://isitmaintained.com/project/dreamstalker/rehlds "Percentage of issues still open") [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ReHLDS Reverse-engineered (and bugfixed) HLDS ## What is this? @@ -7,7 +6,7 @@ ReHLDS is a result of reverse engineering of original HLDS (build 6152/6153) usi Along with reverse engineering, a lot of defects and (potential) bugs were found and fixed -You can try play on one of the servers that using rehlds: http://www.gametracker.com/search/?search_by=server_variable&search_by2=sv_version +You can try play on one of the servers that using rehlds: [Game Tracker](http://www.gametracker.com/search/?search_by=server_variable&search_by2=sv_version) ## Goals of the project ## 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. -
Warning! Rehlds is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool. +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. +
Warning! ReHLDS is not compatible with an old 5xxx or below platforms downloaded by hldsupdatetool. -Compiled binaries are available here: http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/rehlds/rehlds/ +## Downloads +* [Release builds](https://github.com/dreamstalker/rehlds/releases) +* [Dev builds](https://github.com/dreamstalker/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. +ReHLDS binaries require `SSE`, `SSE2` and `SSE3` instruction sets to run and can benefit from `SSE4.1` and `SSE4.2` -Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' - - -Warning! 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. +Warning! 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. ## Configuring -Bugfixed version of rehlds contains an additional cvars: +
+Click to expand +
## Commands -Bugfixed version of rehlds contains an additional commands: ## Build instructions -There are several software requirements for building rehlds: -
    -
  1. Java Development Kit (JDK) 7+ (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
  2. -
  3. For Windows: Visual Studio 2013 and later
  4. -
  5. For Linux: Intel C++ Compiler 13 and later or GCC 4.9.2 or later (some earlier versions might work too)
  6. -
- ### Checking requirements -#### JDK version -Windows
> %JAVA_HOME%\bin\javac -version
-javac 1.8.0_25
+There are several software requirements for building rehlds:
+
+#### Windows
+
+Visual Studio 2015 (C++14 standard) and later
 
-Linux -
$ javac -version
-javac 1.7.0_65
-
- -#### Visual Studio -Help -> About - -#### ICC -
$ icc --version
-icc (ICC) 15.0.1 20141023
-
- -#### GCC -
$ gcc --version
-gcc (Debian 4.9.2-10) 4.9.2
+#### Linux
+
+cmake >= 3.10
+GCC >= 4.9.2 (Optional)
+ICC >= 15.0.1 20141023 (Optional)
+LLVM (Clang) >= 6.0 (Optional)
 
### Building -On Windows: -
gradlew --max-workers=1 clean buildRelease
-* For faster building without unit tests use this:exclamation: -
gradlew --max-workers=1 clean buildFixes
-NOTE: You can also use `Visual Studio` to build, just select from the solution configurations list `Release Swds` or `Debug Swds`
-On Linux (ICC): -
./gradlew --max-workers=1 clean buildRelease
-* For faster building without unit tests use this:exclamation: -
./gradlew --max-workers=1 clean buildFixes
+#### Windows +Use `Visual Studio` to build, open `msvc/ReHLDS.sln` and just select from the solution configurations list `Release Swds` or `Debug Swds` -On Linux (GCC): -
./gradlew --max-workers=1 -PuseGcc clean buildRelease
-* For faster building without unit tests use this:exclamation: -
./gradlew --max-workers=1 -PuseGcc clean buildFixes
+#### Linux -Also there is a task `buildEngine`, it builds only engine, without other parts of the project.
-Compiled binaries will be placed in the rehlds/build/binaries/ directory +* Optional options using `build.sh --compiler=[gcc] --jobs=[N] -D[option]=[ON or OFF]` (without square brackets) + +
+-c=|--compiler=[icc|gcc|clang]  - Select preferred C/C++ compiler to build
+-j=|--jobs=[N]                  - Specifies the number of jobs (commands) to run simultaneously (For faster building)
+
+Definitions (-D)
+DEBUG                           - Enables debugging mode
+USE_STATIC_LIBSTDC              - Enables static linking library libstdc++
+
+ +* ICC
./build.sh --compiler=intel
+* LLVM (Clang)
./build.sh --compiler=clang
+* GCC
./build.sh --compiler=gcc
+ +##### Checking build environment (Debian / Ubuntu) + +
+Click to expand + +
    +
  • +Installing required packages +
    +sudo dpkg --add-architecture i386
    +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
    +
    +
  • + +
  • +Select the preferred C/C++ Compiler installation +
    +1) sudo apt-get install -y gcc g++
    +2) sudo apt-get install -y clang
    +
    +
  • +
+
## How can I help the project? Just install it on your game server and report problems you faced. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4ac20c5..0000000 --- a/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -import versioning.GitVersioner -import versioning.RehldsVersionInfo -import org.joda.time.DateTime - -apply plugin: 'maven-publish' -apply from: 'shared.gradle' -group = 'rehlds' - -apply plugin: 'idea' - -idea { - project { - languageLevel = 'JDK_1_7' - } -} - -def gitInfo = GitVersioner.versionForDir(project.rootDir) -RehldsVersionInfo versionInfo -if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') { - def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ - if (!m.find()) { - throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") - } - - versionInfo = new RehldsVersionInfo( - majorVersion: m.group(1) as int, - minorVersion: m.group(2) as int, - maintenanceVersion: m.group(4) ? (m.group(4) as int) : null, - localChanges: gitInfo.localChanges, - commitDate: gitInfo.commitDate, - commitSHA: gitInfo.commitSHA, - commitURL: gitInfo.commitURL - ) -} else { - versionInfo = new RehldsVersionInfo( - majorVersion: project.majorVersion as int, - minorVersion: project.minorVersion as int, - maintenanceVersion: project.maintenanceVersion as int, - suffix: 'dev', - localChanges: gitInfo ? gitInfo.localChanges : true, - commitDate: gitInfo ? gitInfo.commitDate : new DateTime(), - commitSHA: gitInfo ? gitInfo.commitSHA : "", - commitURL: gitInfo ? gitInfo.commitURL : "", - commitCount: gitInfo ? (gitInfo.commitCount as int) : null - ) -} - -project.ext.rehldsVersionInfo = versionInfo -project.version = versionInfo.asMavenVersion() - -apply from: 'publish.gradle' - -task wrapper(type: Wrapper) { - gradleVersion = '2.4' -} diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..876b458 --- /dev/null +++ b/build.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +main() +{ + CC=gcc + CXX=g++ + + if [[ "$*" =~ "--help" ]]; then + help + exit 0; + fi + + n=0 + args=() + for i in "$@" + do + case $i in + -j=*|--jobs=*) + jobs="-j${i#*=}" + shift + ;; + -c=*|--compiler=*) + C="${i#*=}" + shift + ;; + *) + args[$n]="$i" + ((++n)) + ;; + esac + done + + case "$C" in + ("intel"|"icc") CC=icc CXX=icpc ;; + ("gcc"|"g++") CC=gcc CXX=g++ ;; + ("clang|llvm") CC=clang CXX=clang++ ;; + *) + ;; + esac + + rm -rf build + mkdir build + pushd build &> /dev/null + CC=$CC CXX=$CXX cmake ${args[@]} .. + make ${jobs} + popd > /dev/null +} + +help() +{ + printf "Usage: ./build.sh \n\n" + printf " -c= | --compiler= - Select preferred C/C++ compiler to build\n" + printf " -j= | --jobs= - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n" +} + +# Initialize +main $* + +# Exit normally +exit 0 diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index e206d80..0000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -apply plugin: 'groovy' - -repositories { - //mavenLocal() - mavenCentral() - maven { - url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/' - } - maven { - url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-snapshots/' - } - maven { - url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/' - } -} - -dependencies { - compile gradleApi() - compile localGroovy() - compile 'commons-io:commons-io:2.4' - compile 'commons-lang:commons-lang:2.6' - compile 'joda-time:joda-time:2.7' - - compile 'org.doomedsociety.gradlecpp:gradle-cpp-plugin:1.2' - compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r' - compile 'org.apache.velocity:velocity:1.7' -} diff --git a/buildSrc/src/main/groovy/dirsync/builder/FileSystemTreeBuilder.groovy b/buildSrc/src/main/groovy/dirsync/builder/FileSystemTreeBuilder.groovy deleted file mode 100644 index dad66d7..0000000 --- a/buildSrc/src/main/groovy/dirsync/builder/FileSystemTreeBuilder.groovy +++ /dev/null @@ -1,58 +0,0 @@ -package dirsync.builder - -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode -import groovy.transform.CompileStatic - -class FileSystemTreeBuilder { - - @CompileStatic - private static FileNode buildNodeForFile(File file, DirectoryNode parent) { - if (parent.getChildren(file.name)) { - throw new RuntimeException("Parent dir ${parent.name} already contains child node ${file.name}"); - } - - return new FileNode( - name: file.name, - lastModifiedDate: file.lastModified(), - data: file, - parent: parent, - size: file.size() - ); - } - - @CompileStatic - private static DirectoryNode buildNodeForDirectoryRecursive(File dir, DirectoryNode parent) { - if (!dir.isDirectory()) { - throw new RuntimeException("File ${dir.absolutePath} is not a directory") - } - - if (parent != null && parent.getChildren(dir.name)) { - throw new RuntimeException("Parent dir ${parent.name} already contains child node ${dir.name}"); - } - - DirectoryNode thisNode = new DirectoryNode( - name: dir.name, - lastModifiedDate: dir.lastModified(), - data: dir, - parent: parent - ); - - dir.eachFile { File f -> - if (f.isDirectory()) { - thisNode.childNodes[f.name] = buildNodeForDirectoryRecursive(f, thisNode) - } else { - thisNode.childNodes[f.name] = buildNodeForFile(f, thisNode) - } - } - - return thisNode; - } - - static DirectoryNode buildFileSystemTree(File rootDir) { - def root = buildNodeForDirectoryRecursive(rootDir, null); - PostBuildPass.doPostBuild(root) - - return root - } -} diff --git a/buildSrc/src/main/groovy/dirsync/builder/FileTreeMerger.groovy b/buildSrc/src/main/groovy/dirsync/builder/FileTreeMerger.groovy deleted file mode 100644 index 9251e2f..0000000 --- a/buildSrc/src/main/groovy/dirsync/builder/FileTreeMerger.groovy +++ /dev/null @@ -1,60 +0,0 @@ -package dirsync.builder - -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode - -class FileTreeMerger { - - private static void mergeContentsRecursive(DirectoryNode newParent, DirectoryNode toMerge) { - toMerge.childNodes.each { cn -> - def node = cn.value - def existingNode = newParent.childNodes[node.name] - if (existingNode) { - if (!(existingNode instanceof DirectoryNode) || !(node instanceof DirectoryNode)) - throw new RuntimeException("Failed to merge non-directory nodes ${node.fullPath}") - - def existingDirNode = existingNode as DirectoryNode - def dirNode = node as DirectoryNode - - existingDirNode.lastModifiedDate = Math.max(existingDirNode.lastModifiedDate, dirNode.lastModifiedDate) - mergeContentsRecursive(existingDirNode, dirNode) - } else { - if (node instanceof DirectoryNode) { - def dirNode = node as DirectoryNode - def newNode = new DirectoryNode( - name: dirNode.name, - data: dirNode.data, - parent: newParent, - lastModifiedDate: dirNode.lastModifiedDate - ) - newParent.childNodes[node.name] = newNode - - mergeContentsRecursive(newNode, dirNode) - } else { - FileNode fileNode = node as FileNode - FileNode newNode = new FileNode( - name: fileNode.name, - data: fileNode.data, - parent: newParent, - lastModifiedDate: fileNode.lastModifiedDate, - size: fileNode.size - ) - - newParent.childNodes[node.name] = newNode - } - } - } - } - - public static DirectoryNode mergeTrees(DirectoryNode tree1, DirectoryNode tree2) { - DirectoryNode newRoot = new DirectoryNode( - name: tree1.name ?: tree2.name - ) - - mergeContentsRecursive(newRoot, tree1) - mergeContentsRecursive(newRoot, tree2) - PostBuildPass.doPostBuild(newRoot) - - return newRoot - } -} diff --git a/buildSrc/src/main/groovy/dirsync/builder/PostBuildPass.groovy b/buildSrc/src/main/groovy/dirsync/builder/PostBuildPass.groovy deleted file mode 100644 index 6dc41aa..0000000 --- a/buildSrc/src/main/groovy/dirsync/builder/PostBuildPass.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package dirsync.builder - -import dirsync.model.tree.DirectoryNode - -class PostBuildPass { - - private static void postProcessRecursive(DirectoryNode dir) { - dir.childNodes.each { cne -> - def childNode = cne.value - childNode.fullPath = dir.fullPath ? dir.fullPath + '/' + childNode.name : childNode.name - if (childNode instanceof DirectoryNode) { - def childDirNode = childNode as DirectoryNode - postProcessRecursive(childDirNode) - } - } - } - - static void doPostBuild(DirectoryNode root) { - root.fullPath = '' - postProcessRecursive(root) - } -} diff --git a/buildSrc/src/main/groovy/dirsync/builder/ZipTreeBuilder.groovy b/buildSrc/src/main/groovy/dirsync/builder/ZipTreeBuilder.groovy deleted file mode 100644 index 94e6ffe..0000000 --- a/buildSrc/src/main/groovy/dirsync/builder/ZipTreeBuilder.groovy +++ /dev/null @@ -1,53 +0,0 @@ -package dirsync.builder - -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode -import dirsync.model.tree.ZipData - -import java.util.zip.ZipFile - -class ZipTreeBuilder { - static DirectoryNode buildForZipArchive(String zipArchive, ZipFile zf) { - DirectoryNode root = new DirectoryNode<>() - - zf.entries().each { ze -> - def path = ze.name.replace('\\', '/') - if (path.endsWith('/')) - path = path.substring(0, path.length() - 1) - - def parentPath = path.contains('/') ? path.substring(0, path.lastIndexOf('/')) : '' - def childPath = path.contains('/') ? path.substring(path.lastIndexOf('/') + 1) : path - - def parentNode = (DirectoryNode) root.getByPath(parentPath) - if (parentNode == null) - throw new RuntimeException("Error reading ${zipArchive}: could not find parent path ${parentPath} for path ${path}") - - def childNode = parentNode.getChildren(childPath) - if (childNode) - throw new RuntimeException("Error reading ${zipArchive}: duplicate path ${path}") - - if (ze.directory) { - childNode = new DirectoryNode( - name: childPath, - lastModifiedDate: ze.time, - data: new ZipData(zipEntryName: ze.name, zipArchiveName: zipArchive), - parent: parentNode - ); - } else { - childNode = new FileNode( - name: childPath, - lastModifiedDate: ze.time, - data: new ZipData(zipEntryName: ze.name, zipArchiveName: zipArchive), - parent: parentNode, - size: ze.size - ); - } - parentNode.childNodes[childPath] = childNode - - //println '' + ze.directory + ' ' + ze.name + ' ' + parentPath + ' ' + childPath - } - - PostBuildPass.doPostBuild(root) - return root - } -} diff --git a/buildSrc/src/main/groovy/dirsync/merger/FileTreeComparator.groovy b/buildSrc/src/main/groovy/dirsync/merger/FileTreeComparator.groovy deleted file mode 100644 index 89b0c76..0000000 --- a/buildSrc/src/main/groovy/dirsync/merger/FileTreeComparator.groovy +++ /dev/null @@ -1,97 +0,0 @@ -package dirsync.merger - -import dirsync.model.synccmd.AbstractSyncCmd -import dirsync.model.synccmd.CopyDirCmd -import dirsync.model.synccmd.CopyFileCmd -import dirsync.model.synccmd.DeleteDirCmd -import dirsync.model.synccmd.DeleteFileCmd -import dirsync.model.synccmd.ReplaceFileCmd -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode -import groovy.transform.TypeChecked - -@TypeChecked -class FileTreeComparator { - - private static void mergeDirsRecursive(DirectoryNode left, DirectoryNode right, List> diffs) { - - // left => right - left.childNodes.each { le -> - def leftNode = le.value - def rightNode = right.childNodes[leftNode.name] - - if (rightNode == null) { - switch (leftNode) { - case DirectoryNode: - def leftDirNode = leftNode as DirectoryNode - diffs << new CopyDirCmd<>(src: leftDirNode, dstParentDir: right) - break - - case FileNode: - def leftFileNode = leftNode as FileNode - diffs << new CopyFileCmd<>(src: leftFileNode, dstDir: right) - break - - default: - throw new RuntimeException("Invalid node class ${leftNode.class.name}") - } - - return - } - - if (rightNode.class != leftNode.class) { - throw new RuntimeException("node classes mismatch: ${leftNode.class.name} != ${rightNode.class.name}") - } - - switch (rightNode) { - case DirectoryNode: - def leftDirNode = leftNode as DirectoryNode - def rightDirNode = rightNode as DirectoryNode - mergeDirsRecursive(leftDirNode, rightDirNode, diffs) - break - - case FileNode: - def leftFileNode = leftNode as FileNode - def rightFileNode = rightNode as FileNode - if (leftFileNode.size != rightFileNode.size || leftFileNode.lastModifiedDate != rightFileNode.lastModifiedDate) { - diffs << new ReplaceFileCmd<>(src: leftFileNode, dst: rightFileNode) - } - break - - default: - throw new RuntimeException("Invalid node class ${rightNode.class.name}") - } - } // ~left => right - - //right => left - right.childNodes.each { re -> - def rightNode = re.value - def leftNode = left.childNodes[rightNode.name] - - if (leftNode != null) { - return //already processed in left => right - } - - switch (rightNode) { - case DirectoryNode: - def rightDirNode = rightNode as DirectoryNode - diffs << new DeleteDirCmd<>(dirNode: rightDirNode) - break - - case FileNode: - def rightFileNode = rightNode as FileNode - diffs << new DeleteFileCmd<>(node: rightFileNode) - break - - default: - throw new RuntimeException("Invalid node class ${rightNode.class.name}") - } - } // ~right => left - } - - static List> mergeTrees(DirectoryNode leftRoot, DirectoryNode rightRoot) { - List> res = [] - mergeDirsRecursive(leftRoot, rightRoot, res) - return res - } -} diff --git a/buildSrc/src/main/groovy/dirsync/merger/FileTreeDiffApplier.groovy b/buildSrc/src/main/groovy/dirsync/merger/FileTreeDiffApplier.groovy deleted file mode 100644 index 59fe4b6..0000000 --- a/buildSrc/src/main/groovy/dirsync/merger/FileTreeDiffApplier.groovy +++ /dev/null @@ -1,103 +0,0 @@ -package dirsync.merger - -import dirsync.model.synccmd.AbstractSyncCmd -import dirsync.model.synccmd.CopyDirCmd -import dirsync.model.synccmd.CopyFileCmd -import dirsync.model.synccmd.DeleteDirCmd -import dirsync.model.synccmd.DeleteFileCmd -import dirsync.model.synccmd.ReplaceFileCmd -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode -import dirsync.model.tree.TreePhysMapper -import groovy.transform.TypeChecked -import org.apache.commons.io.IOUtils - -@TypeChecked -public class FileTreeDiffApplier { - - static void copyDirRecursive(DirectoryNode src, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - dstMapper.createDirectory(src.fullPath) - src.childNodes.each { ce -> - def childNode = ce.value - def childPath = childNode.fullPath - switch (childNode) { - case FileNode: - srcMapper.fileContent(childNode.data).withStream { InputStream inStream -> - dstMapper.createFile(childPath).withStream { OutputStream outStream -> - IOUtils.copy(inStream, outStream) - } - - dstMapper.setFileLastUpdatedDate(childPath, childNode.lastModifiedDate) - } - break; - - case DirectoryNode: - copyDirRecursive(childNode as DirectoryNode, srcMapper, dstMapper) - break; - - default: - throw new RuntimeException("Invalid node class: ${childNode.class.name}") - } - } - } - - static void handleCopyFile(CopyFileCmd fileCopy, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - def dstPath = fileCopy.dstDir.fullPath ? fileCopy.dstDir.fullPath + '/' + fileCopy.src.name : fileCopy.src.name - srcMapper.fileContent(fileCopy.src.data).withStream { InputStream inStream -> - dstMapper.createFile(dstPath).withStream { OutputStream outStream -> - IOUtils.copy(inStream, outStream) - } - - dstMapper.setFileLastUpdatedDate(dstPath, fileCopy.src.lastModifiedDate) - } - } - - static void handleDeleteDir(DeleteDirCmd delDir, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - dstMapper.removeDirectory(delDir.dirNode.fullPath) - } - - static void handleDeleteFile(DeleteFileCmd delFile, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - dstMapper.removeFile(delFile.node.fullPath) - } - - static void handleReplaceFile(ReplaceFileCmd replaceFile, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - dstMapper.removeFile(replaceFile.dst.fullPath) - srcMapper.fileContent(replaceFile.src.data).withStream { InputStream inStream -> - dstMapper.createFile(replaceFile.dst.fullPath).withStream { OutputStream outStream -> - IOUtils.copy(inStream, outStream) - } - - dstMapper.setFileLastUpdatedDate(replaceFile.dst.fullPath, replaceFile.src.lastModifiedDate) - } - } - - static void applyDiffs(List> diffs, TreePhysMapper srcMapper, TreePhysMapper dstMapper) { - diffs.each { diff -> - switch (diff) { - case CopyDirCmd: - def copyDir = diff as CopyDirCmd - copyDirRecursive(copyDir.src, srcMapper, dstMapper) - break - - case CopyFileCmd: - handleCopyFile(diff as CopyFileCmd, srcMapper, dstMapper) - break - - case DeleteDirCmd: - handleDeleteDir(diff as DeleteDirCmd, srcMapper, dstMapper) - break - - case DeleteFileCmd: - handleDeleteFile(diff as DeleteFileCmd, srcMapper, dstMapper) - break - - case ReplaceFileCmd: - handleReplaceFile(diff as ReplaceFileCmd, srcMapper, dstMapper) - break - - default: - throw new RuntimeException("Invalid diff command ${diff.class.name}") - } - } - } -} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/AbstractSyncCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/AbstractSyncCmd.groovy deleted file mode 100644 index 6351762..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/AbstractSyncCmd.groovy +++ /dev/null @@ -1,4 +0,0 @@ -package dirsync.model.synccmd - -class AbstractSyncCmd { -} diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyDirCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyDirCmd.groovy deleted file mode 100644 index bead311..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyDirCmd.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package dirsync.model.synccmd - -import dirsync.model.tree.DirectoryNode - -class CopyDirCmd extends AbstractSyncCmd { - DirectoryNode src - DirectoryNode dstParentDir -} diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyFileCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyFileCmd.groovy deleted file mode 100644 index 2f25866..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/CopyFileCmd.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package dirsync.model.synccmd - -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FileNode - -class CopyFileCmd extends AbstractSyncCmd { - FileNode src - DirectoryNode dstDir -} diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteDirCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteDirCmd.groovy deleted file mode 100644 index 2103c7a..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteDirCmd.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package dirsync.model.synccmd - -import dirsync.model.tree.DirectoryNode - -class DeleteDirCmd extends AbstractSyncCmd { - DirectoryNode dirNode -} diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteFileCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteFileCmd.groovy deleted file mode 100644 index 66a87e2..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/DeleteFileCmd.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package dirsync.model.synccmd - -import dirsync.model.tree.FileNode - -class DeleteFileCmd extends AbstractSyncCmd { - FileNode node -} diff --git a/buildSrc/src/main/groovy/dirsync/model/synccmd/ReplaceFileCmd.groovy b/buildSrc/src/main/groovy/dirsync/model/synccmd/ReplaceFileCmd.groovy deleted file mode 100644 index 3da6dd0..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/synccmd/ReplaceFileCmd.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package dirsync.model.synccmd - -import dirsync.model.tree.FileNode - -class ReplaceFileCmd extends AbstractSyncCmd { - FileNode src - FileNode dst -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/AbstractFileTreeNode.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/AbstractFileTreeNode.groovy deleted file mode 100644 index 68ae342..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/AbstractFileTreeNode.groovy +++ /dev/null @@ -1,27 +0,0 @@ -package dirsync.model.tree - -import groovy.transform.CompileStatic - -@CompileStatic -abstract class AbstractFileTreeNode { - DirectoryNode parent - String name - String fullPath - long lastModifiedDate - T data - - boolean equals(o) { - if (this.is(o)) return true - if (getClass() != o.class) return false - - AbstractFileTreeNode that = (AbstractFileTreeNode) o - - if (name != that.name) return false - - return true - } - - int hashCode() { - return (name != null ? name.hashCode() : 0) - } -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/DirectoryNode.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/DirectoryNode.groovy deleted file mode 100644 index 2062c1d..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/DirectoryNode.groovy +++ /dev/null @@ -1,42 +0,0 @@ -package dirsync.model.tree - -import groovy.transform.CompileStatic - -@CompileStatic -class DirectoryNode extends AbstractFileTreeNode { - Map> childNodes = new HashMap<>() - - AbstractFileTreeNode getChildren(String name) { - return childNodes[name]; - } - - AbstractFileTreeNode getChildren(String[] names, int idx) { - if (idx == names.length) - return this - - AbstractFileTreeNode c = childNodes[names[idx]] - if (c == null) - return null - - if (c instanceof DirectoryNode) { - def d = (DirectoryNode) c; - return d.getChildren(names, idx + 1) - } - - return null; - } - - AbstractFileTreeNode getByPath(String path) { - path = path.replace('\\', '/') - if (path.endsWith('/')) - path = path.substring(0, path.length() - 1) - - if (path.empty) { - return this - } - - String[] components = path.split('/') - return getChildren(components, 0) - } - -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/FSMapper.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/FSMapper.groovy deleted file mode 100644 index 95cf3c0..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/FSMapper.groovy +++ /dev/null @@ -1,50 +0,0 @@ -package dirsync.model.tree - -class FSMapper extends TreePhysMapper { - final File root - - FSMapper(File root) { - this.root = root - } - - @Override - InputStream fileContent(File file) { - return file.newDataInputStream() - } - - @Override - void createDirectory(String dir) { - def target = new File(root, dir) - if (!target.mkdirs()) { - throw new RuntimeException("Failed to create directory ${target.absolutePath}") - } - } - - @Override - void removeDirectory(String dir) { - def target = new File(root, dir) - if (!target.deleteDir()) { - throw new RuntimeException("Failed to delete directory ${target.absolutePath}") - } - } - - @Override - void removeFile(String path) { - def target = new File(root, path) - if (!target.delete()) { - throw new RuntimeException("Failed to delete file ${target.absolutePath}") - } - } - - @Override - OutputStream createFile(String path) { - def target = new File(root, path) - return target.newOutputStream() - } - - @Override - void setFileLastUpdatedDate(String path, long date) { - def target = new File(root, path) - target.setLastModified(date) - } -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/FileNode.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/FileNode.groovy deleted file mode 100644 index d34591e..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/FileNode.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package dirsync.model.tree - -import groovy.transform.CompileStatic - -@CompileStatic -class FileNode extends AbstractFileTreeNode { - long size -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/TreePhysMapper.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/TreePhysMapper.groovy deleted file mode 100644 index 2c60d66..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/TreePhysMapper.groovy +++ /dev/null @@ -1,11 +0,0 @@ -package dirsync.model.tree - -abstract class TreePhysMapper { - abstract InputStream fileContent(T file) - abstract void createDirectory(String dir) - abstract void removeDirectory(String dir) - abstract void removeFile(String path) - abstract OutputStream createFile(String path) - - abstract void setFileLastUpdatedDate(String path, long date) -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/ZipData.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/ZipData.groovy deleted file mode 100644 index 6e89d34..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/ZipData.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package dirsync.model.tree - -import groovy.transform.CompileStatic - -@CompileStatic -class ZipData { - String zipEntryName - String zipArchiveName -} diff --git a/buildSrc/src/main/groovy/dirsync/model/tree/ZipTreeMapper.groovy b/buildSrc/src/main/groovy/dirsync/model/tree/ZipTreeMapper.groovy deleted file mode 100644 index 9b0126c..0000000 --- a/buildSrc/src/main/groovy/dirsync/model/tree/ZipTreeMapper.groovy +++ /dev/null @@ -1,72 +0,0 @@ -package dirsync.model.tree - -import dirsync.builder.FileTreeMerger -import dirsync.builder.ZipTreeBuilder -import sun.reflect.generics.reflectiveObjects.NotImplementedException - -import java.util.zip.ZipFile - -public class ZipTreeMapper extends TreePhysMapper implements Closeable { - Map zipArchives = [:] - - void addZipArchive(String zipArchive) { - zipArchives[zipArchive] = new ZipFile(zipArchive) - } - - DirectoryNode buildFileTree() { - def root = new DirectoryNode() - zipArchives.each { ze -> - def zipTree = ZipTreeBuilder.buildForZipArchive(ze.key, ze.value) - root = FileTreeMerger.mergeTrees(root, zipTree) - } - - return root - } - - @Override - void close() throws IOException { - zipArchives.each { ze -> - try { ze.value.close() } catch (Exception ignored) { } - } - } - - @Override - InputStream fileContent(ZipData file) { - def archive = zipArchives[file.zipArchiveName] - if (!archive) { - throw new RuntimeException("Archive ${file.zipArchiveName} is not loaded"); - } - - def zipEntry = archive.getEntry(file.zipEntryName) - if (!zipEntry) { - throw new RuntimeException("File ${file.zipEntryName} not found in archive ${file.zipArchiveName}"); - } - - return archive.getInputStream(zipEntry) - } - - @Override - void createDirectory(String dir) { - throw new NotImplementedException() - } - - @Override - void removeDirectory(String dir) { - throw new NotImplementedException() - } - - @Override - void removeFile(String path) { - throw new NotImplementedException() - } - - @Override - OutputStream createFile(String path) { - throw new NotImplementedException() - } - - @Override - void setFileLastUpdatedDate(String path, long date) { - throw new NotImplementedException() - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/CppUnitTestExtension.groovy b/buildSrc/src/main/groovy/gradlecpp/CppUnitTestExtension.groovy deleted file mode 100644 index fe94d87..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/CppUnitTestExtension.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package gradlecpp - -import org.gradle.api.Project -import org.gradle.nativeplatform.NativeBinarySpec - -class CppUnitTestExtension { - Project _project - - CppUnitTestExtension(Project p) { - _project = p - } - - void eachTestExecutable(Closure action) { - _project.binaries.each { NativeBinarySpec bin -> - if (!bin.hasProperty('cppUnitTestsExecutable')) return - action(bin) - } - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/CppUnitTestPlugin.groovy b/buildSrc/src/main/groovy/gradlecpp/CppUnitTestPlugin.groovy deleted file mode 100644 index 3616c90..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/CppUnitTestPlugin.groovy +++ /dev/null @@ -1,256 +0,0 @@ -package gradlecpp - -import gradlecpp.teamcity.TeamCityIntegration -import org.gradle.api.Action -import org.gradle.api.GradleException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.internal.project.AbstractProject -import org.gradle.model.internal.core.DirectNodeModelAction -import org.gradle.model.internal.core.ModelActionRole -import org.gradle.model.internal.core.ModelPath -import org.gradle.model.internal.core.ModelReference -import org.gradle.model.internal.core.MutableModelNode -import org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor -import org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor -import org.gradle.model.internal.registry.ModelRegistry -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.internal.AbstractNativeBinarySpec - -import org.doomedsociety.gradlecpp.GradleCppUtils - -class CppUnitTestPlugin implements Plugin { - - private static class TestExecStatus { - boolean successful - boolean warning - int exitCode - String output - long durationMsec - String cmdLine - String execDir - } - - static void onBinariesCreated(Project p, String desc, Closure action) { - ModelRegistry mr = (p as AbstractProject).getModelRegistry() - def modelPath = ModelPath.path("binaries") - ModelRuleDescriptor ruleDescriptor = new SimpleModelRuleDescriptor(desc); - - mr.configure(ModelActionRole.Finalize, DirectNodeModelAction.of(ModelReference.of(modelPath), ruleDescriptor, new Action() { - @Override - void execute(MutableModelNode node) { - action() - } - })) - } - - @Override - void apply(Project project) { - project.extensions.create('cppUnitTest', CppUnitTestExtension, project) - onBinariesCreated(project, 'CppUnitTestPlugin::AttachUnitTest', { - processCppUnitTests(project) - }) - } - - - - /** - * Attaches test tasks to C/C++ libraries build tasks - */ - static void processCppUnitTests(Project p) { - //println "processCppUnitTests::afterEvaluate on ${p.name}: project type is ${p.projectType}" - - p.binaries.all { NativeBinarySpec bin -> - if (!(bin.component instanceof NativeLibrarySpec)) { - return - } - - def testComponentName = bin.component.name + '_tests' - Collection testCandidates = p.binaries.matching { it.component.name == testComponentName && bin.buildType == it.buildType && bin.flavor == it.flavor } - if (testCandidates.size() > 1) { - throw new GradleException("Found >1 test candidates for library ${bin.component.name} in project ${p}: ${testCandidates}") - } else if (!testCandidates.empty) { - def testBinary = testCandidates.first() - GradleCppUtils.onTasksCreated(p, 'CppUnitTestPlugin::AttachUnitTestTask', { - attachTestTaskToCppLibrary(bin, testBinary) - }) - String testTaskName = bin.namingScheme.getTaskName('unitTest') - bin.ext.cppUnitTestTask = testTaskName - } else { - throw new GradleException("No tests found for library ${bin.component.name} in project ${p}") - } - } - - } - - static TestExecStatus runTestExecutable(NativeBinarySpec testSubject, String executable, List params, String phase, int timeout) { - def execFile = new File(executable) - def outDir = new File(testSubject.buildTask.project.buildDir, "tests/${testSubject.name}/run") - outDir.mkdirs() - - def outPath = new File(outDir, "${phase}.log") - - def cmdParams = []; - cmdParams << execFile.absolutePath - cmdParams.addAll(params) - - def execDir = execFile.parentFile - def pb = new ProcessBuilder(cmdParams).redirectErrorStream(true).directory(execDir) - if (!GradleCppUtils.windows) { - pb.environment().put('LD_LIBRARY_PATH', '.') - } - - - def sout = new StringBuffer() - - long startTime = System.currentTimeMillis() - def p = pb.start() - p.consumeProcessOutput(sout, sout) - - p.waitForOrKill(timeout * 1000) - long endTime = System.currentTimeMillis() - - int exitVal = p.exitValue() - - outPath.withWriter('UTF-8') { writer -> - writer.write(sout.toString()) - } - - return new TestExecStatus( - exitCode: exitVal, - successful: (exitVal == 0 || exitVal == 3), - warning: (exitVal == 3), - output: sout.toString(), - durationMsec: endTime - startTime, - cmdLine: cmdParams.join(' '), - execDir: execDir.absolutePath - ) - } - - static void dumpTestExecStatus(TestExecStatus stat) { - if (!stat) { - println "Execution of test executable failed" - } - - println "Test executable command: ${stat.cmdLine}" - println "Test executable run directury: ${stat.execDir}" - println "Test executable exit code: ${stat.exitCode}" - println "Test executable output BEGIN" - println stat.output - println "Test executable output END" - } - - static void attachTestTaskToCppLibrary(NativeBinarySpec libBin, NativeBinarySpec testExecBin) { - Project p = libBin.buildTask.project - - def libBinImpl = libBin as AbstractNativeBinarySpec - def libLinkTask = GradleCppUtils.getLinkTask(libBin) - def testExecLinkTask = GradleCppUtils.getLinkTask(testExecBin) - - // collect all output files from library and test executable - def depFiles = [] - depFiles.addAll(libLinkTask.outputs.files.files) - depFiles.addAll(testExecLinkTask.outputs.files.files) - - //create 'tests' task - def testTaskName = libBinImpl.namingScheme.getTaskName('unitTest') - def testTask = p.task(testTaskName, { Task testTask -> - - //output dir - def testResDir = new File(p.buildDir, "tests/${libBin.name}") - - //inputs/outputs for up-to-date check - testTask.outputs.dir testResDir - testTask.inputs.files depFiles - - //dependencies on library and test executable - testTask.dependsOn libLinkTask - testTask.dependsOn testExecLinkTask - - // binary build depends on unit test - libBin.buildTask.dependsOn testTask - - // extra project-specific dependencies - def testDepsTask = p.tasks.findByName('testDeps') - if (testDepsTask != null) { - testTask.dependsOn testDepsTask - } - - // task actions - testTask.doLast { - - //temporary file that store info about all tests (XML) - File allTests = File.createTempFile('j4s-testinfo', 'data') - allTests.deleteOnExit() - - //fill file with test info - print "Fetching test info..." - def getTestsStatus = runTestExecutable(libBin, testExecBin.executableFile.absolutePath, ['-writeTestInfo', allTests.absolutePath], '__getTests', 5000) - if (!getTestsStatus.successful) { - println " Failed" - dumpTestExecStatus(getTestsStatus) - throw new GradleException("Unable to fetch test names") - } - println " OK" - getTestsStatus = null // allow GC to collect it - - // parse the test info file - def root = new XmlSlurper().parse(allTests) - - // run all tests - println "Running ${root.test.size()} tests..." - TeamCityIntegration.suiteStarted("unitTests.${libBin.name}") - int failCount = 0; - int warnCount = 0; - root.test.list().each { testInfo -> - def testName = '' + testInfo.@name.text() - def testGroup = '' + testInfo.@group.text() - def testTimeout = ('' + testInfo.@timeout.text()) as int - - if (!TeamCityIntegration.writeOutput) { - print " ${testGroup}-${testName}..." - System.out.flush() - } - - TeamCityIntegration.testStarted("${testGroup}-${testName}") - def testExecStatus = runTestExecutable(libBin, testExecBin.executableFile.absolutePath, ['-runTest', testGroup, testName], "${testGroup}-${testName}", testTimeout) - if (!testExecStatus.successful) { - if (!TeamCityIntegration.writeOutput) { - println " Failed" - } - - TeamCityIntegration.testFailed("${testGroup}-${testName}", "test executable return code is ${testExecStatus.exitCode}", "test executable return code is ${testExecStatus.exitCode}") - dumpTestExecStatus(testExecStatus) - failCount++ - } else { - if (!TeamCityIntegration.writeOutput) { - - if (testExecStatus.warning) { - println " WARNING" - dumpTestExecStatus(testExecStatus) - warnCount++ - } - else - println " OK" - } - } - - TeamCityIntegration.testStdOut("${testGroup}-${testName}", testExecStatus.output) - TeamCityIntegration.testFinished("${testGroup}-${testName}", testExecStatus.durationMsec) - - } - TeamCityIntegration.suiteFinished("unitTests.${libBin.name}") - - if (failCount) { - throw new GradleException("CPP unit tests: ${failCount} tests failed"); - } - - else if (warnCount) { - println "CPP unit tests: ${warnCount} tests warnings"; - } - } - }) - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestPlugin.groovy b/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestPlugin.groovy deleted file mode 100644 index efc98ca..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestPlugin.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package gradlecpp - -import org.gradle.api.Plugin -import org.gradle.api.Project - -class RehldsPlayTestPlugin implements Plugin { - @Override - void apply(Project project) { - project.configurations { - rehlds_playtest_image - } - - project.dependencies { - rehlds_playtest_image 'rehlds.testimg:testimg:0.2' - } - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestTask.groovy b/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestTask.groovy deleted file mode 100644 index bc5d890..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/RehldsPlayTestTask.groovy +++ /dev/null @@ -1,80 +0,0 @@ -package gradlecpp - -import gradlecpp.teamcity.TeamCityIntegration -import org.apache.commons.lang.SystemUtils -import org.gradle.api.DefaultTask -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.TaskAction -import org.gradle.nativeplatform.NativeBinarySpec -import rehlds.testdemo.RehldsDemoRunner -import rehlds.testdemo.RehldsTestParser - -class RehldsPlayTestTask extends DefaultTask { - - def FileCollection testDemos - def Closure postExtractAction - def File rehldsImageRoot - def File rehldsTestLogs - def NativeBinarySpec testFor - - @TaskAction - def doPlay() { - if (!SystemUtils.IS_OS_WINDOWS) { - return - } - - if (!testDemos) { - println 'RehldsPlayTestTask: no demos attached to the testDemos property' - } - - rehldsImageRoot.mkdirs() - rehldsTestLogs.mkdirs() - - def demoRunner = new RehldsDemoRunner(this.project.configurations.rehlds_playtest_image.getFiles(), rehldsImageRoot, postExtractAction) - - println "Preparing engine..." - demoRunner.prepareEngine() - - println "Running ${testDemos.getFiles().size()} ReHLDS test demos..." - - TeamCityIntegration.suiteStarted("rehldsDemo.${testFor.name}") - int failCount = 0; - testDemos.getFiles().each { f -> - def testInfo = RehldsTestParser.parseTestInfo(f) - TeamCityIntegration.testStarted(testInfo.testName) - - if (!TeamCityIntegration.writeOutput) { - print "Running ReHLDS test demo ${testInfo.testName} " - System.out.flush() - } - - - def testRes = demoRunner.runTest(testInfo, rehldsTestLogs) - - if (testRes.success) { - if (!TeamCityIntegration.writeOutput) { - println ' OK' - } - } else { - - TeamCityIntegration.testFailed(testInfo.testName, "Exit code: ${testRes.returnCode}", "Exit code: ${testRes.returnCode}") - if (!TeamCityIntegration.writeOutput) { - println ' Failed' - println "ReHLDS testdemo ${testInfo.testName} playback failed. Exit status is ${testRes.returnCode}." - println "Dumping console output:" - println testRes.hldsConsoleOutput - } - - failCount++ - } - - TeamCityIntegration.testStdOut(testInfo.testName, testRes.hldsConsoleOutput) - TeamCityIntegration.testFinished(testInfo.testName, testRes.duration) - } - TeamCityIntegration.suiteFinished("rehldsDemo.${testFor.name}") - - if (failCount) { - throw new RuntimeException("Rehlds testdemos: failed ${failCount} tests") - } - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy b/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy deleted file mode 100644 index 55eca36..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package gradlecpp - -import org.apache.velocity.Template -import org.apache.velocity.VelocityContext -import org.apache.velocity.app.Velocity - -class VelocityUtils { - - static { - Properties p = new Properties(); - - p.setProperty("resource.loader", "class"); - p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); - p.setProperty("class.resource.loader.path", ""); - - p.setProperty("input.encoding", "UTF-8"); - p.setProperty("output.encoding", "UTF-8"); - - Velocity.init(p); - } - - static String renderTemplate(File tplFile, Map ctx) { - Template tpl = Velocity.getTemplate(tplFile.absolutePath) - if (!tpl) { - throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found") - } - - def velocityContext = new VelocityContext(ctx) - def sw = new StringWriter() - tpl.merge(velocityContext, sw) - - return sw.toString() - } -} diff --git a/buildSrc/src/main/groovy/gradlecpp/teamcity/TeamCityIntegration.groovy b/buildSrc/src/main/groovy/gradlecpp/teamcity/TeamCityIntegration.groovy deleted file mode 100644 index fd532c5..0000000 --- a/buildSrc/src/main/groovy/gradlecpp/teamcity/TeamCityIntegration.groovy +++ /dev/null @@ -1,84 +0,0 @@ -package gradlecpp.teamcity - -import groovy.transform.CompileStatic - - -class TeamCityIntegration { - - static final String flowId = System.getenv('TEAMCITY_PROCESS_FLOW_ID') - static final boolean underTeamcity = System.getenv('TEAMCITY_PROJECT_NAME') - static boolean writeOutput = underTeamcity - - @CompileStatic - private static String escape(String s) { - StringBuilder sb = new StringBuilder((int)(s.length() * 1.2)); - for (char c in s.chars) { - switch (c) { - case '\n': sb.append('|n'); break; - case '\r': sb.append('|r'); break; - case '\'': sb.append('|\''); break; - case '|': sb.append('||'); break; - case ']': sb.append('|]'); break; - default: sb.append(c); - } - } - - return sb.toString() - } - - @CompileStatic - static void writeMessage(String name, Map params) { - if (!writeOutput) return - StringBuilder sb = new StringBuilder() - sb.append('##teamcity[').append(name) - params.each { e -> - if (e.value != null) { - sb.append(' ').append('' + e.key).append('=\'').append(escape('' + e.value)).append('\'') - } - } - sb.append(']') - - println sb.toString() - } - - static void suiteStarted(String suiteName) { - writeMessage('testSuiteStarted', [name: suiteName, flowId: flowId ?: null]) - } - - static void suiteFinished(String suiteName) { - writeMessage('testSuiteFinished', [name: suiteName, flowId: flowId ?: null]) - } - - static void testStarted(String testName) { - writeMessage('testStarted', [name: testName, flowId: flowId ?: null]) - } - - static void testStdOut(String testName, String output) { - writeMessage('testStdOut', [name: testName, out: output, flowId: flowId ?: null]) - } - - static void testFinished(String testName, long durationMs) { - writeMessage('testFinished', [ - name: testName, - flowId: flowId ?: null, - duration: (durationMs >= 0) ? durationMs : null - ]) - } - - static void testFailed(String testName, String message, String details) { - writeMessage('testFailed', [ - name: testName, - flowId: flowId ?: null, - message: message, - details: details - ]) - } - - static void testIgnored(String testName, String message) { - writeMessage('testIgnored', [ - name: testName, - flowId: flowId ?: null, - message: message, - ]) - } -} diff --git a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsDemoRunner.groovy b/buildSrc/src/main/groovy/rehlds/testdemo/RehldsDemoRunner.groovy deleted file mode 100644 index 213a3db..0000000 --- a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsDemoRunner.groovy +++ /dev/null @@ -1,81 +0,0 @@ -package rehlds.testdemo - -import dirsync.builder.FileSystemTreeBuilder -import dirsync.merger.FileTreeComparator -import dirsync.merger.FileTreeDiffApplier -import dirsync.model.tree.DirectoryNode -import dirsync.model.tree.FSMapper -import dirsync.model.tree.ZipData -import dirsync.model.tree.ZipTreeMapper - -class RehldsDemoRunner { - ZipTreeMapper rehldsImage = new ZipTreeMapper() - File rootDir - DirectoryNode engineImageTree - Closure postExtract - - static class TestResult { - boolean success - int returnCode - String hldsConsoleOutput - long duration - } - - RehldsDemoRunner(Collection engineImageZips, File rootDir, Closure postExtract) { - this.rootDir = rootDir - engineImageZips.each { f -> - rehldsImage.addZipArchive(f.absolutePath) - } - engineImageTree = rehldsImage.buildFileTree() - this.postExtract = postExtract - } - - void prepareEngine() { - def existingTree = FileSystemTreeBuilder.buildFileSystemTree(rootDir) - def cmds = FileTreeComparator.mergeTrees(engineImageTree, existingTree) - - FSMapper fsMapper = new FSMapper(rootDir) - FileTreeDiffApplier.applyDiffs(cmds, rehldsImage, fsMapper) - if (postExtract != null) { - postExtract.run() - } - } - - TestResult runTest(RehldsTestInfo info, File testLogDir) { - long startTime = System.currentTimeMillis() - prepareEngine() - - def outPath = new File(testLogDir, "${info.testName}_run.log") - - def cmdParams = [] - cmdParams << new File(rootDir, 'hlds.exe').absolutePath - cmdParams.addAll(info.hldsArgs) - if (info.rehldsExtraArgs) { - cmdParams.addAll(info.rehldsExtraArgs) - } - cmdParams << '--rehlds-test-play' << info.testBinFile.absolutePath - - def pb = new ProcessBuilder(cmdParams).redirectErrorStream(true).directory(rootDir) - def sout = new StringBuffer() - - - def p = pb.start() - p.consumeProcessOutput(sout, sout) - - p.waitForOrKill(info.timeoutSeconds * 1000) - int exitVal = p.exitValue() - - outPath.withWriter('UTF-8') { writer -> - writer.write(sout.toString()) - } - - long endTime = System.currentTimeMillis() - - return new TestResult( - success: (exitVal == 777), - returnCode: exitVal, - hldsConsoleOutput: sout.toString(), - duration: endTime - startTime - ) - } -} diff --git a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestInfo.groovy b/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestInfo.groovy deleted file mode 100644 index e4a218d..0000000 --- a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestInfo.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package rehlds.testdemo - -class RehldsTestInfo { - String testName - List hldsArgs - String rehldsExtraArgs - int timeoutSeconds - File testBinFile -} diff --git a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestParser.groovy b/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestParser.groovy deleted file mode 100644 index 74b24df..0000000 --- a/buildSrc/src/main/groovy/rehlds/testdemo/RehldsTestParser.groovy +++ /dev/null @@ -1,63 +0,0 @@ -package rehlds.testdemo - -import groovy.util.slurpersupport.GPathResult -import org.apache.commons.io.IOUtils - -import java.util.zip.ZipFile - -class RehldsTestParser { - static final String REHLDS_TEST_METAINFO_FILE = 'rehlds_test_metainfo.xml' - - static RehldsTestInfo parseTestInfo(File testArchive) { - def zf = new ZipFile(testArchive); - try { - def metaInfoEntry = zf.getEntry(REHLDS_TEST_METAINFO_FILE) - if (metaInfoEntry == null) { - throw new RuntimeException("Unable to open ${REHLDS_TEST_METAINFO_FILE} in ${testArchive.absolutePath}") - } - - GPathResult metaInfo = null - zf.getInputStream(metaInfoEntry).withStream { InputStream ins -> - metaInfo = new XmlSlurper().parse(ins) - } - - RehldsTestInfo testInfo = new RehldsTestInfo( - testName: metaInfo.name.text(), - hldsArgs: metaInfo.runArgs.arg.list().collect { it.text().trim() }, - timeoutSeconds: metaInfo.timeout.text() as int - ) - - //validate testInfo - if (!testInfo.testName) { - throw new RuntimeException("Error parsing ${testArchive.absolutePath}: test name is not specified") - } - - if (!testInfo.hldsArgs) { - throw new RuntimeException("Error parsing ${testArchive.absolutePath}: run arguments are not specified") - } - - if (testInfo.timeoutSeconds <= 0) { - throw new RuntimeException("Error parsing ${testArchive.absolutePath}: bad timeout") - } - - def testBinName = testInfo.testName + '.bin' - def testBinEntry = zf.getEntry(testBinName) - if (testBinEntry == null) { - throw new RuntimeException("Error parsing ${testArchive.absolutePath}: test binary ${testBinName} not found inside archive") - } - - testInfo.testBinFile = File.createTempFile(testBinName, 'rehlds') - testInfo.testBinFile.deleteOnExit() - zf.getInputStream(testBinEntry).withStream { InputStream ins -> - testInfo.testBinFile.withOutputStream { OutputStream os -> - IOUtils.copy(ins, os) - } - } - - return testInfo - } finally { - try { zf.close() } catch (Exception ignored) { } - } - - } -} diff --git a/buildSrc/src/main/groovy/versioning/GitInfo.groovy b/buildSrc/src/main/groovy/versioning/GitInfo.groovy deleted file mode 100644 index 7532e0b..0000000 --- a/buildSrc/src/main/groovy/versioning/GitInfo.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package versioning - -import groovy.transform.CompileStatic -import groovy.transform.TypeChecked -import org.joda.time.DateTime - -@CompileStatic @TypeChecked -class GitInfo { - boolean localChanges - DateTime commitDate - String branch - String tag - String commitSHA - String commitURL - Integer commitCount -} diff --git a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy deleted file mode 100644 index 8370411..0000000 --- a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy +++ /dev/null @@ -1,126 +0,0 @@ -package versioning - -import java.util.Set; - -import groovy.transform.CompileStatic -import groovy.transform.TypeChecked -import org.eclipse.jgit.api.Git -import org.eclipse.jgit.api.Status; -import org.eclipse.jgit.lib.ObjectId -import org.eclipse.jgit.lib.Repository -import org.eclipse.jgit.lib.StoredConfig -import org.eclipse.jgit.revwalk.RevCommit -import org.eclipse.jgit.revwalk.RevWalk -import org.eclipse.jgit.storage.file.FileRepositoryBuilder -import org.joda.time.DateTime -import org.joda.time.DateTimeZone - -@CompileStatic @TypeChecked -class GitVersioner { - - static GitInfo versionForDir(String dir) { - versionForDir(new File(dir)) - } - static int getCountCommit(Repository repo) { - Iterable commits = Git.wrap(repo).log().call() - int count = 0; - commits.each { - count++; - } - - return count; - } - static String prepareUrlToCommits(String url) { - if (url == null) { - // default remote url - return "https://github.com/dreamstalker/rehlds/commit/"; - } - - StringBuilder sb = new StringBuilder(); - String childPath; - int pos = url.indexOf('@'); - if (pos != -1) { - childPath = url.substring(pos + 1, url.lastIndexOf('.git')).replace(':', '/'); - sb.append('https://'); - } else { - pos = url.lastIndexOf('.git'); - childPath = (pos == -1) ? url : url.substring(0, pos); - } - - // support for different links to history of commits - if (url.indexOf('bitbucket.org') != -1) { - sb.append(childPath).append('/commits/'); - } else { - sb.append(childPath).append('/commit/'); - } - return sb.toString(); - } - // check uncommited changes - static boolean getUncommittedChanges(Repository repo) { - Git git = new Git(repo); - Status status = git.status().call(); - - Set uncommittedChanges = status.getUncommittedChanges(); - for(String uncommitted : uncommittedChanges) { - return true; - } - - return false; - } - static GitInfo versionForDir(File dir) { - FileRepositoryBuilder builder = new FileRepositoryBuilder() - Repository repo = builder.setWorkTree(dir) - .findGitDir() - .build() - - ObjectId head = repo.resolve('HEAD') - if (!head) { - return null - } - - final StoredConfig cfg = repo.getConfig(); - - def commit = new RevWalk(repo).parseCommit(head) - if (!commit) { - throw new RuntimeException("Can't find last commit.") - } - - def localChanges = getUncommittedChanges(repo); - def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC); - if (localChanges) { - commitDate = new DateTime(); - } - - def branch = repo.getBranch() - - String url = null; - String remote_name = cfg.getString("branch", branch, "remote"); - - if (remote_name == null) { - for (String remotes : cfg.getSubsections("remote")) { - if (url != null) { - println 'Found a second remote: (' + remotes + '), url: (' + cfg.getString("remote", remotes, "url") + ')' - continue; - } - - url = cfg.getString("remote", remotes, "url"); - } - } else { - url = cfg.getString("remote", remote_name, "url"); - } - - String commitURL = prepareUrlToCommits(url); - String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key - String commitSHA = commit.getId().abbreviate(7).name(); - - return new GitInfo( - localChanges: localChanges, - commitDate: commitDate, - branch: branch, - tag: tag, - commitSHA: commitSHA, - commitURL: commitURL, - commitCount: getCountCommit(repo) - ) - } -} diff --git a/buildSrc/src/main/groovy/versioning/RehldsVersionInfo.groovy b/buildSrc/src/main/groovy/versioning/RehldsVersionInfo.groovy deleted file mode 100644 index ae0da00..0000000 --- a/buildSrc/src/main/groovy/versioning/RehldsVersionInfo.groovy +++ /dev/null @@ -1,56 +0,0 @@ -package versioning - -import groovy.transform.CompileStatic -import groovy.transform.ToString -import groovy.transform.TypeChecked -import org.joda.time.format.DateTimeFormat -import org.joda.time.DateTime - -@CompileStatic @TypeChecked -@ToString(includeNames = true) -class RehldsVersionInfo { - int majorVersion - int minorVersion - Integer maintenanceVersion - String suffix - - boolean localChanges - DateTime commitDate - String commitSHA - String commitURL - Integer commitCount - - String asMavenVersion(boolean extra = true) { - StringBuilder sb = new StringBuilder() - sb.append(majorVersion).append('.' + minorVersion); - if (maintenanceVersion != null) { - sb.append('.' + maintenanceVersion); - } - - if (commitCount != null) { - sb.append('.' + commitCount) - } - - if (extra && suffix) { - sb.append('-' + suffix) - } - - // do mark for this build like a modified version - if (extra && localChanges) { - sb.append('+m'); - } - - return sb.toString() - } - String asCommitDate() { - String pattern = "MMM d yyyy"; - if (commitDate.getDayOfMonth() >= 10) { - pattern = "MMM d yyyy"; - } - - return DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH).print(commitDate); - } - String asCommitTime() { - return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate); - } -} diff --git a/buildSrc/src/test/groovy/dirsync/builder/ZipTreeBuilderTest.groovy b/buildSrc/src/test/groovy/dirsync/builder/ZipTreeBuilderTest.groovy deleted file mode 100644 index a6d3c99..0000000 --- a/buildSrc/src/test/groovy/dirsync/builder/ZipTreeBuilderTest.groovy +++ /dev/null @@ -1,44 +0,0 @@ -package dirsync.builder - -import org.junit.Test - -import java.io.File - -import dirsync.builder.ZipTreeBuilder - -import java.util.zip.ZipEntry -import java.util.zip.ZipFile -import java.util.zip.ZipOutputStream; - -import static org.junit.Assert.*; - -class ZipTreeBuilderTest { - - @Test - void test1() { - File zipFile = File.createTempFile('ZipTreeBuilderTest', 'zip') - zipFile.deleteOnExit() - - new ZipOutputStream(zipFile.newDataOutputStream()).withStream { ZipOutputStream zos -> - zos.putNextEntry(new ZipEntry('aRootFile1.txt')) - zos.write(65) //'A' - - zos.putNextEntry(new ZipEntry('dir1/')) - zos.putNextEntry(new ZipEntry('dir1/dir2/')) - - zos.putNextEntry(new ZipEntry('dir1/dir2/d1d2f1.txt')) - zos.write(65); zos.write(66) //'AB' - - zos.putNextEntry(new ZipEntry('dir1/d1f1.txt')) - zos.write(65); zos.write(66); zos.write(67) //'ABC' - - zos.putNextEntry(new ZipEntry('zRootFile2.txt')) - zos.write(65); zos.write(66); zos.write(67); zos.write(68) //'ABCD' - } - - ZipFile zf = new ZipFile(zipFile.absolutePath) - def tree = ZipTreeBuilder.buildForZipArchive(zipFile.absolutePath, zf) - - assert tree.childNodes.size() == 3 - } -} \ No newline at end of file diff --git a/dep/bzip2/CMakeLists.txt b/dep/bzip2/CMakeLists.txt new file mode 100644 index 0000000..50e77a6 --- /dev/null +++ b/dep/bzip2/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.1) +project(bzip2 C) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g0 -O1 -fno-stack-protector") + +set(BZIP2_SRCS + "src/blocksort.c" + "src/bzlib.c" + "src/compress.c" + "src/crctable.c" + "src/decompress.c" + "src/huffman.c" + "src/precompiled.c" + "src/randtable.c" + "src/bzlib_private.h" +) + +include_directories( + "include" +) + +add_library(bzip2 STATIC ${BZIP2_SRCS}) +set_target_properties(bzip2 PROPERTIES + COMPILE_FLAGS "-m32" +) diff --git a/dep/bzip2/build.gradle b/dep/bzip2/build.gradle deleted file mode 100644 index 09fef5a..0000000 --- a/dep/bzip2/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - - -apply plugin: 'c' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -void setupToolchain(NativeBinarySpec b) { - def cfg = rootProject.createToolchainConfig(b) - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'bzlib_private.h', - pchSourceSet: 'bz2_pch' - ) - } - - ToolchainConfigUtils.apply(project, cfg, b) -} - -model { - buildTypes { - debug - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - bzip2(NativeLibrarySpec) { - targetPlatform 'x86' - - sources { - bz2_main(CSourceSet) { - source { - srcDir "src" - include "**/*.c" - exclude "precompiled.c" - } - exportedHeaders { - srcDir "include" - } - } - - bz2_pch(CSourceSet) { - source { - srcDir "src" - include "precompiled.c" - } - exportedHeaders { - srcDir "include" - } - } - } - - binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } - } - } -} diff --git a/dep/bzip2/msvc/bzip2.vcxproj b/dep/bzip2/msvc/bzip2.vcxproj index 55fab7d..d11db95 100644 --- a/dep/bzip2/msvc/bzip2.vcxproj +++ b/dep/bzip2/msvc/bzip2.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -39,16 +35,6 @@ true Unicode - - StaticLibrary - false - v120 - v140 - v141 - v142 - true - Unicode - @@ -58,9 +44,6 @@ - - - @@ -97,25 +80,6 @@ true - - - Level3 - Use - MaxSpeed - true - true - _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(ProjectDir)..\include\ - MultiThreaded - bzlib_private.h - - - Windows - true - true - true - - @@ -129,7 +93,6 @@ Create Create - Create diff --git a/dep/cppunitlite/CMakeLists.txt b/dep/cppunitlite/CMakeLists.txt new file mode 100644 index 0000000..10047e7 --- /dev/null +++ b/dep/cppunitlite/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.1) +project(cppunitlite CXX) + +add_library(cppunitlite STATIC) + +target_sources(cppunitlite PRIVATE + src/Test.cpp + src/TestResult.cpp + src/TestRegistry.cpp + src/Assertions.cpp + src/MainAdapter.cpp +) + +target_include_directories(cppunitlite PRIVATE + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/include" +) + +target_compile_definitions(cppunitlite PRIVATE + _GLIBCXX_USE_CXX11_ABI=0 +) + +target_compile_options(cppunitlite PRIVATE + -m32 +) diff --git a/dep/cppunitlite/build.gradle b/dep/cppunitlite/build.gradle deleted file mode 100644 index bae46b8..0000000 --- a/dep/cppunitlite/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -void setupToolchain(NativeBinarySpec b) { - def cfg = rootProject.createToolchainConfig(b) - - ToolchainConfigUtils.apply(project, cfg, b) -} - -model { - buildTypes { - debug - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - cppunitlite(NativeLibrarySpec) { - targetPlatform 'x86' - - sources { - cppul_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - } - - exportedHeaders { - srcDir "include" - } - } - } - - - binaries.all { NativeBinarySpec b -> - project.setupToolchain(b) - } - } - } -} - diff --git a/dep/cppunitlite/include/cppunitlite/GradleAdapter.h b/dep/cppunitlite/include/cppunitlite/MainAdapter.h similarity index 88% rename from dep/cppunitlite/include/cppunitlite/GradleAdapter.h rename to dep/cppunitlite/include/cppunitlite/MainAdapter.h index 739fdaf..85ba4bf 100644 --- a/dep/cppunitlite/include/cppunitlite/GradleAdapter.h +++ b/dep/cppunitlite/include/cppunitlite/MainAdapter.h @@ -1,6 +1,6 @@ #pragma once -class GradleAdapter { +class MainAdapter { public: int writeAllTestsInfoToFile(const char* fname); int runTest(const char* groupName, const char* testName); diff --git a/dep/cppunitlite/include/cppunitlite/Test.h b/dep/cppunitlite/include/cppunitlite/Test.h index 2f153d2..f6f977e 100644 --- a/dep/cppunitlite/include/cppunitlite/Test.h +++ b/dep/cppunitlite/include/cppunitlite/Test.h @@ -20,7 +20,7 @@ public: void setNext(Test *test); Test *getNext () const; void run(TestResult& result); - + const char* getName() { return name_.c_str(); } @@ -28,7 +28,7 @@ public: const char* getGroup() { return group_.c_str(); } - + int getTimeout() { return timeout_; } @@ -47,7 +47,7 @@ protected: { public: testGroup##testName##Test () : Test (#testName , #testGroup , testTimeout) {} \ void runInternal (); } \ testGroup##testName##Instance; \ - void testGroup##testName##Test::runInternal() + void testGroup##testName##Test::runInternal() diff --git a/dep/cppunitlite/msvc/cppunitlite.vcxproj b/dep/cppunitlite/msvc/cppunitlite.vcxproj index b44933d..45afe06 100644 --- a/dep/cppunitlite/msvc/cppunitlite.vcxproj +++ b/dep/cppunitlite/msvc/cppunitlite.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -17,7 +13,7 @@ - + @@ -25,7 +21,7 @@ - + @@ -55,16 +51,6 @@ true MultiByte - - StaticLibrary - false - v120 - v140 - v141 - v142 - true - MultiByte - @@ -74,9 +60,6 @@ - - - @@ -115,26 +98,6 @@ true - - - Level3 - - - MaxSpeed - true - true - WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - $(ProjectDir)..\include\ - false - - - Windows - true - true - true - - diff --git a/dep/cppunitlite/msvc/cppunitlite.vcxproj.filters b/dep/cppunitlite/msvc/cppunitlite.vcxproj.filters index 47c9cd0..7ef1fd0 100644 --- a/dep/cppunitlite/msvc/cppunitlite.vcxproj.filters +++ b/dep/cppunitlite/msvc/cppunitlite.vcxproj.filters @@ -27,7 +27,7 @@ include - + include @@ -44,7 +44,7 @@ src - + src diff --git a/dep/cppunitlite/src/GradleAdapter.cpp b/dep/cppunitlite/src/MainAdapter.cpp similarity index 86% rename from dep/cppunitlite/src/GradleAdapter.cpp rename to dep/cppunitlite/src/MainAdapter.cpp index 42917b9..440553c 100644 --- a/dep/cppunitlite/src/GradleAdapter.cpp +++ b/dep/cppunitlite/src/MainAdapter.cpp @@ -2,11 +2,11 @@ #include #include -#include "cppunitlite/GradleAdapter.h" +#include "cppunitlite/MainAdapter.h" #include "cppunitlite/Test.h" #include "cppunitlite/TestRegistry.h" -int GradleAdapter::writeAllTestsInfoToFile(const char* fname) { +int MainAdapter::writeAllTestsInfoToFile(const char* fname) { FILE* outFile = fopen(fname, "w"); if (outFile == NULL) { return 1; @@ -33,7 +33,7 @@ int GradleAdapter::writeAllTestsInfoToFile(const char* fname) { return 0; } -int GradleAdapter::runTest(const char* groupName, const char* testName) { +int MainAdapter::runTest(const char* groupName, const char* testName) { Test* curTest = TestRegistry::getFirstTest(); while (curTest != NULL) { if (!strcmp(groupName, curTest->getGroup()) && !strcmp(testName, curTest->getName())) { @@ -61,7 +61,7 @@ int GradleAdapter::runTest(const char* groupName, const char* testName) { } } -int GradleAdapter::runGroup(const char* groupName) { +int MainAdapter::runGroup(const char* groupName) { Test* curTest = TestRegistry::getFirstTest(); int ranTests = 0; int warnTest = 0; @@ -101,7 +101,7 @@ int GradleAdapter::runGroup(const char* groupName) { return 0; } -int GradleAdapter::runAllTests() { +int MainAdapter::runAllTests() { Test* curTest = TestRegistry::getFirstTest(); int ranTests = 0; int warnTest = 0; @@ -131,7 +131,7 @@ int GradleAdapter::runAllTests() { return 0; } -int GradleAdapter::testsEntryPoint(int argc, char* argv[]) { +int MainAdapter::testsEntryPoint(int argc, char* argv[]) { if (argc < 2 || !strcmp(argv[1], "-all")) { return runAllTests(); } diff --git a/dep/cppunitlite/src/Test.cpp b/dep/cppunitlite/src/Test.cpp index 216aec8..8ad852f 100644 --- a/dep/cppunitlite/src/Test.cpp +++ b/dep/cppunitlite/src/Test.cpp @@ -5,10 +5,11 @@ #include "cppunitlite/Failure.h" #include +#include #include -Test::Test (const char* testName, const char* testGroup, int timeout) +Test::Test (const char* testName, const char* testGroup, int timeout) : name_ (testName), group_ (testGroup), timeout_(timeout) { next_ = NULL; @@ -23,13 +24,14 @@ Test *Test::getNext() const void Test::setNext(Test *test) -{ +{ next_ = test; } void Test::run(TestResult &result) { try { runInternal(); + std::cout << "Test::run() > " << group_ << "::" << name_ << " Passed" << std::endl; } catch (TestFailException &e) { result.addFailure(Failure(e, name_)); } catch (std::exception &e) { diff --git a/flightrec/decoder/build.gradle b/flightrec/decoder/build.gradle deleted file mode 100644 index 707f713..0000000 --- a/flightrec/decoder/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -apply plugin: 'java' -apply plugin: 'groovy' - -group = 'org.rehlds.flightrec' -version = rootProject.version - -sourceCompatibility = '1.7' -targetCompatibility = '1.7' - -repositories { - mavenCentral() -} - -dependencies { - testCompile 'org.codehaus.groovy:groovy-all:2.4.5' - testCompile "junit:junit:4.12" - compile project(':flightrec/decoder_api') -} - -task uberjar(type: Jar, dependsOn: ['check', ':flightrec/decoder_api:build']) { - from files(sourceSets.main.output.classesDir) - from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } - exclude('META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.LIST') //exclude all signing stuff - - manifest { - attributes 'Main-Class': 'org.rehlds.flightrec.main.FlightRecorder' - attributes 'Implementation-Vendor': 'Sun Microsystems, Inc' - attributes 'Implementation-Title': 'Java Runtime Environment' - attributes 'Implementation-Version': '1.7.0' - } -} - -tasks.withType(AbstractCompile) { - options.encoding = 'UTF-8' -} diff --git a/flightrec/decoder/pub/decoder.bat b/flightrec/decoder/pub/decoder.bat deleted file mode 100644 index 813a720..0000000 --- a/flightrec/decoder/pub/decoder.bat +++ /dev/null @@ -1,47 +0,0 @@ -@if "%DEBUG%" == "" @echo off -setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -set CMD_LINE_ARGS=%* -"%JAVA_EXE%" -jar "%DIRNAME%/decoder.jar" %CMD_LINE_ARGS% - -:end -goto mainEnd - -:fail -exit /b 1 - -:mainEnd -endlocal diff --git a/flightrec/decoder/pub/extDecoders/.keep b/flightrec/decoder/pub/extDecoders/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/flightrec/decoder/src/main/java/com/google/cloud/Crc32c.java b/flightrec/decoder/src/main/java/com/google/cloud/Crc32c.java deleted file mode 100644 index 28f898a..0000000 --- a/flightrec/decoder/src/main/java/com/google/cloud/Crc32c.java +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2011 Google Inc. All rights reserved. - -package com.google.cloud; - -import java.util.zip.Checksum; - -/** - * This class generates a CRC32C checksum, defined by rfc3720 section B.4. - * - * - */ -public final class Crc32c implements Checksum { - - private static final long[] CRC_TABLE = { - 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, - 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, - 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, - 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, - 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, - 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, - 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, - 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, - 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, - 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, - 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, - 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, - 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, - 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, - 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, - 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, - 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, - 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, - 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, - 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, - 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, - 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, - 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, - 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, - 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, - 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, - 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, - 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, - 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, - 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, - 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, - 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, - 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, - 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, - 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, - 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, - 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, - 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, - 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, - 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, - 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, - 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, - 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, - 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, - 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, - 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, - 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, - 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, - 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, - 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, - 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, - 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, - 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, - 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, - 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, - 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, - 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, - 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, - 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, - 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, - 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, - 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, - 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, - 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351 - }; - - private static final long LONG_MASK = 0xffffffffL; - private static final long BYTE_MASK = 0xff; - - private long crc; - - public Crc32c() { - crc = 0; - } - - /** - * Updates the checksum with a new byte. - * @param b the new byte. - */ - @Override - public void update(int b) { - long newCrc = crc; - newCrc = updateByte((byte) b, newCrc); - crc = newCrc; - } - - /** - * Updates the checksum with an array of bytes. - * @param bArray the array of bytes. - * @param off the offset into the array where the update should begin. - * @param len the length of data to examine. - */ - @Override - public void update(byte[] bArray, int off, int len) { - long newCrc = crc; - for (int i = off; i < off + len; i++) { - newCrc = updateByte(bArray[i], newCrc); - } - crc = newCrc; - } - - public void update(byte[] bArray) { - update(bArray, 0, bArray.length); - } - - /** - * Returns the value of the checksum. - * @return the long representation of the checksum (high bits set to zero). - */ - @Override - public long getValue() { - return crc; - } - - /** - * Returns the value of the checksum. - * @return the 4-byte array representation of the checksum in network byte order (big endian). - */ - public byte[] getValueAsBytes() { - long value = crc; - byte[] result = new byte[4]; - for (int i = 3; i >= 0; i--) { - result[i] = (byte) (value & 0xffL); - value >>= 8; - } - return result; - } - - /** - * Resets the crc. - */ - @Override - public void reset() { - crc = 0; - } - - private long updateByte(byte newByte, long crc) { - byte b = (byte) (newByte & BYTE_MASK); - int index = (int) ((crc ^ b) & BYTE_MASK); - return (CRC_TABLE[index] ^ (crc >> 8)) & LONG_MASK; - } -} \ No newline at end of file diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/Consts.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/Consts.java deleted file mode 100644 index 7c307ee..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/Consts.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.rehlds.flightrec; - -public class Consts { - public final static String META_HEADER_SIG_STR = "REHLDS_FLIGHTREC_META"; - public final static String DATA_HEADER_SIG_STR = "REHLDS_FLIGHTREC_DATA"; - - public static byte[] META_HEADER_SIG_BYTES = (META_HEADER_SIG_STR + META_HEADER_SIG_STR + META_HEADER_SIG_STR + ":").getBytes(); - public static byte[] DATA_HEADER_SIG_BYTES = (DATA_HEADER_SIG_STR + DATA_HEADER_SIG_STR + DATA_HEADER_SIG_STR + ":").getBytes(); - - public static int META_HEADER_SIZE = 128; - public static int DATA_HEADER_SIZE = 128; - - public static int MAX_HEADER_SIZE = Math.max(META_HEADER_SIZE, DATA_HEADER_SIZE); -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV1Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV1Decoder.java deleted file mode 100644 index a02ef7b..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV1Decoder.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class AllocEntPrivateDataV1Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "AllocEntPrivateData", 1, false); - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - long ptr = sb.readUInt32(); - return DecodedExtraData.create("pPrivData", "0x" + Long.toHexString(ptr)); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV2Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV2Decoder.java deleted file mode 100644 index 42f89dd..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/AllocEntPrivateDataV2Decoder.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class AllocEntPrivateDataV2Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "AllocEntPrivateData", 2, false); - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - long ptr = sb.readUInt32(); - long size = sb.readUInt32(); - return DecodedExtraData.create("pPrivData", "0x" + Long.toHexString(ptr), "size", "" + size); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV1Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV1Decoder.java deleted file mode 100644 index e013329..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV1Decoder.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class FrameV1Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "Frame", 1, true); - } - - DecodedExtraData decodeStart(UtilSizeBuf sb) { - double startTime = sb.readDouble(); - return DecodedExtraData.create("startTime", "" + startTime); - } - - DecodedExtraData decodeEnd(UtilSizeBuf sb) { - return DecodedExtraData.EMPTY; - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - return msg.isEnterMessage() ? decodeStart(sb) : decodeEnd(sb); - } - -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV2Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV2Decoder.java deleted file mode 100644 index d731005..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FrameV2Decoder.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class FrameV2Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "Frame", 2, true); - } - - DecodedExtraData decodeStart(UtilSizeBuf sb) { - long frameId = sb.readInt64(); - double startTime = sb.readDouble(); - return DecodedExtraData.create("frameId", "" + frameId, "startTime", "" + startTime); - } - - DecodedExtraData decodeEnd(UtilSizeBuf sb) { - long frameId = sb.readInt64(); - return DecodedExtraData.create("frameId", "" + frameId); - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - return msg.isEnterMessage() ? decodeStart(sb) : decodeEnd(sb); - } - -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FreeEntPrivateDataV1Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FreeEntPrivateDataV1Decoder.java deleted file mode 100644 index b306e92..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/FreeEntPrivateDataV1Decoder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class FreeEntPrivateDataV1Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "FreeEntPrivateData", 1, false); - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - long ptr = sb.readUInt32(); - return DecodedExtraData.create("pPrivData", "0x" + Long.toHexString(ptr)); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/LogV1Decoder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/LogV1Decoder.java deleted file mode 100644 index 8925cd2..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/LogV1Decoder.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.DecodedExtraData; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.api.MessageDecoder; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class LogV1Decoder implements MessageDecoder { - @Override - public FlightrecMessageType getMessageType() { - return new FlightrecMessageType("rehlds", "Log", 1, false); - } - - @Override - public DecodedExtraData decode(FlightrecMessage msg) { - UtilSizeBuf sb = msg.getDataSizebuf(); - String prefix = sb.readString(); - String message = sb.readString(); - return DecodedExtraData.create("prefix", prefix, "message", message); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/RehldsDecodersModule.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/RehldsDecodersModule.java deleted file mode 100644 index 2292281..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/decoders/rehlds/RehldsDecodersModule.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.rehlds.flightrec.decoders.rehlds; - -import org.rehlds.flightrec.api.SimpleDecoderModule; - -public class RehldsDecodersModule extends SimpleDecoderModule { - - public RehldsDecodersModule() { - super("Rehlds decoders (built-in)", "0.2"); - registerDecoder(new FrameV1Decoder()); - registerDecoder(new FreeEntPrivateDataV1Decoder()); - registerDecoder(new AllocEntPrivateDataV1Decoder()); - - registerDecoder(new FrameV2Decoder()); - - registerDecoder(new LogV1Decoder()); - registerDecoder(new AllocEntPrivateDataV2Decoder()); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FileScanResult.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FileScanResult.java deleted file mode 100644 index ed91a5a..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FileScanResult.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.rehlds.flightrec.filescan; - -import java.util.ArrayList; -import java.util.List; - -public class FileScanResult { - public List metaHeaders = new ArrayList<>(); - public List dataHeaders = new ArrayList<>(); -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FlightRecFileScanner.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FlightRecFileScanner.java deleted file mode 100644 index e67f5cb..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/FlightRecFileScanner.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.rehlds.flightrec.filescan; - -import com.google.cloud.Crc32c; -import org.rehlds.flightrec.api.util.UtilByteBuffer; -import org.rehlds.flightrec.api.util.UtilSizeBuf; -import static org.rehlds.flightrec.Consts.*; - -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.Arrays; -import java.util.List; - - - -public class FlightRecFileScanner { - RandomAccessFile file; - long fileLen; - FileScanResult scanRes = new FileScanResult(); - - private byte readBuf[] = new byte[65536]; - private byte header[] = new byte[MAX_HEADER_SIZE]; - private UtilSizeBuf headerSBuf = new UtilSizeBuf("header", new UtilByteBuffer(header), 0, header.length); - - private FlightRecFileScanner(RandomAccessFile file) throws IOException { - this.file = file; - this.fileLen = file.length(); - } - - private void examineHeader(byte[] data, int size, int pos) throws IOException { - if (pos + MAX_HEADER_SIZE < size) { - System.arraycopy(data, pos, header, 0, MAX_HEADER_SIZE); - } else { - return; //will be read in next iteration - } - - headerSBuf.reset(); - String matchedType = null; - if (Arrays.equals(META_HEADER_SIG_BYTES, Arrays.copyOfRange(header, 0, META_HEADER_SIG_BYTES.length))) { - matchedType = META_HEADER_SIG_STR; - headerSBuf.skip(META_HEADER_SIG_BYTES.length); - } else if (Arrays.equals(DATA_HEADER_SIG_BYTES, Arrays.copyOfRange(header, 0, DATA_HEADER_SIG_BYTES.length))) { - matchedType = DATA_HEADER_SIG_STR; - headerSBuf.skip(DATA_HEADER_SIG_BYTES.length); - } - - if (matchedType == null) { - return; - } - - List resList = (matchedType.equals(META_HEADER_SIG_STR)) ? scanRes.metaHeaders : scanRes.dataHeaders; - int version = headerSBuf.readInt32(); - int allocSize = headerSBuf.readInt32(); - - Crc32c crc32 = new Crc32c(); - crc32.update(header, 0, headerSBuf.tell()); - long calculatedChecksum = crc32.getValue(); - long bufChecksum = headerSBuf.readUInt32(); - - if (calculatedChecksum != bufChecksum) { - resList.add(new HeaderScanResult(file.getFilePointer() - size + pos, allocSize, false, "Checksum mismatch", version)); - return; - } - - long endPos = file.getFilePointer() - size + pos + allocSize; - if (endPos > file.length()) { - resList.add(new HeaderScanResult(file.getFilePointer() - size + pos, allocSize, false, "Regions partially lays outside the file", version)); - return; - } - resList.add(new HeaderScanResult(file.getFilePointer() - size + pos, allocSize, true, null, version)); - } - - private void scanForHeaders(byte[] data, int size) throws IOException { - int maxHeaderSize = Math.max(META_HEADER_SIG_STR.length(), DATA_HEADER_SIG_STR.length()); - for (int i = 0; i < size - maxHeaderSize; i++) { - if (data[i + 15] == META_HEADER_SIG_BYTES[15] && data[i + 16] == META_HEADER_SIG_BYTES[16] && data[i + 17] == META_HEADER_SIG_BYTES[17] && data[i + 18] == META_HEADER_SIG_BYTES[18]) { - examineHeader(data, size, i); - } else if (data[i + 15] == DATA_HEADER_SIG_BYTES[15] && data[i + 16] == DATA_HEADER_SIG_BYTES[16] && data[i + 17] == DATA_HEADER_SIG_BYTES[17] && data[i + 18] == DATA_HEADER_SIG_BYTES[18]) { - examineHeader(data, size, i); - } - } - } - - private void doScan() throws IOException { - file.seek(0); - int read; - - while (-1 != (read = file.read(readBuf))) { - scanForHeaders(readBuf, read); - if (read == readBuf.length) { - file.seek(file.getFilePointer() - MAX_HEADER_SIZE * 2); - } - } - } - - public static FileScanResult scan(RandomAccessFile file) throws IOException { - FlightRecFileScanner scanner = new FlightRecFileScanner(file); - scanner.doScan(); - return scanner.scanRes; - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/HeaderScanResult.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/HeaderScanResult.java deleted file mode 100644 index 46e93c4..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/filescan/HeaderScanResult.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.rehlds.flightrec.filescan; - -public class HeaderScanResult { - public long pos; - public int len; - public boolean valid; - public String error; - public int version; - - public HeaderScanResult(long pos, int len, boolean valid, String error, int version) { - this.pos = pos; - this.len = len; - this.valid = valid; - this.error = error; - this.version = version; - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/DataHeader.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/DataHeader.java deleted file mode 100644 index c0b961f..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/DataHeader.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.rehlds.flightrec.logparser; - -public class DataHeader { - public int prevItrLastPos; - - public DataHeader(int prevItrLastPos) { - this.prevItrLastPos = prevItrLastPos; - } - - public DataHeader() { - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/FlightLogParser.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/FlightLogParser.java deleted file mode 100644 index cde2e84..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/FlightLogParser.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.rehlds.flightrec.logparser; - -import org.rehlds.flightrec.api.EntranceKind; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageDef; -import org.rehlds.flightrec.api.FlightrecMessageType; -import org.rehlds.flightrec.filescan.HeaderScanResult; -import org.rehlds.flightrec.api.util.UtilByteBuffer; -import org.rehlds.flightrec.api.util.UtilSizeBuf; -import static org.rehlds.flightrec.Consts.*; - -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.*; - -public class FlightLogParser { - UtilByteBuffer metaRegion; - UtilByteBuffer dataRegion; - - MetaHeader metaHeader; - RecorderState recorderState; - DataHeader dataHeader; - - Map msgTypes = new HashMap<>(); - List messages = new ArrayList<>(); - - void parseMessageDefinition(UtilSizeBuf sbuf) { - int msgId = sbuf.readUInt16(); - String module = sbuf.readString(); - String messageName = sbuf.readString(); - long msgVersion = sbuf.readUInt32(); - boolean inOut = sbuf.readBool(); - - FlightrecMessageDef msgDef = new FlightrecMessageDef(module, messageName, msgVersion, inOut, msgId); - - if (msgTypes.containsKey(msgId)) { - System.out.println("Duplicate message id: " + msgTypes.get(msgId) + " and " + msgDef); - } - - msgTypes.put(msgId, msgDef.msgType); - } - - void parseMetaRegion() { - metaHeader = new MetaHeader(); - UtilSizeBuf metaSBuf = new UtilSizeBuf("meta region", metaRegion); - metaSBuf.skip(META_HEADER_SIG_BYTES.length); //skip signature - metaSBuf.readInt32(); //version - metaSBuf.readInt32(); //allocSize - metaSBuf.readInt32(); //checksum - metaHeader.numDefinitions = metaSBuf.readInt32(); - metaHeader.metaRegionPos = metaSBuf.readInt32(); - - recorderState = new RecorderState(); - recorderState.wpos = metaSBuf.readInt32(); - recorderState.lastMsgBeginPos = metaSBuf.readInt32(); - recorderState.curMessage = metaSBuf.readUInt16(); - - metaSBuf = new UtilSizeBuf("meta region defs", metaRegion, META_HEADER_SIZE, metaHeader.metaRegionPos); - for (int i = 0; i < metaHeader.numDefinitions; i++) { - int defKind = metaSBuf.readUInt8(); - switch (defKind) { - case 1: //MRT_MESSAGE_DEF - parseMessageDefinition(metaSBuf); - break; - - default: - throw new RuntimeException("Invalid meta definition type" + defKind); - } - } - - dataHeader = new DataHeader(); - dataHeader.prevItrLastPos = dataRegion.readInt32(DATA_HEADER_SIG_BYTES.length + 12); - } - - public FlightLogParser(UtilByteBuffer metaRegion, UtilByteBuffer dataRegion) { - this.metaRegion = metaRegion; - this.dataRegion = dataRegion; - } - - void doParseMessage(UtilSizeBuf msg) { - int opc = msg.readUInt16(); - boolean entrance = (0 != (opc & 0x8000)); - opc &= 0x7FFF; - - FlightrecMessageType msgType = msgTypes.get(opc); - if (msgType == null) { - throw new RuntimeException("Invalid message opcode @" + Long.toHexString(msg.getAbsoluteCurrentPos() - 2) + ": " + opc); - } - - EntranceKind entranceKind; - if (msgType.inout) { - entranceKind = entrance ? EntranceKind.ENTRANCE_ENTER : EntranceKind.ENTRANCE_LEAVE; - } else { - entranceKind = EntranceKind.ENTRANCE_UNUSED; - } - - FlightrecMessage flMsg = new FlightrecMessage(msgType, entranceKind, msg.getBuffer(), msg.getAbsoluteCurrentPos(), msg.getMaxSize() - 2); - messages.add(flMsg); - } - - void parseMessage(UtilSizeBuf msg) { - int startPos = msg.getStartPos(); - try { - doParseMessage(msg); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Error while parsing message @" + startPos); - } - } - - List parse() { - parseMetaRegion(); - - UtilByteBuffer flightData = dataRegion.cutLeft(DATA_HEADER_SIZE); - - boolean flippedToEnd = false; - - /* - Each message has following layout: - Opcode [2 bytes] - Data [0+ bytes] - Length of opcode + data [2 bytes] - */ - int curMsgPos = (recorderState.curMessage == 0) ? recorderState.wpos : recorderState.lastMsgBeginPos; - curMsgPos -= 2; //position of the Length field of the message - - UtilSizeBuf msg = new UtilSizeBuf("flightrec_message", flightData, 0, 0); - - while (true) { - if (flippedToEnd && curMsgPos <= recorderState.wpos) - break; - - if (curMsgPos <= 0) { //move read pointer to the end of the data region - if (dataHeader.prevItrLastPos == -1) //wpos never reached end of the region - break; - - curMsgPos = dataHeader.prevItrLastPos - 2; - flippedToEnd = true; - continue; - } - - int msgLen = flightData.readUInt16(curMsgPos); - int msgStartPos = curMsgPos - msgLen; - if (msgStartPos < 0) { - throw new RuntimeException("Corrupted data region; read msgLen=" + msgLen + " at " + curMsgPos + ", but it is too large (startPos < 0)"); - } - - if (flippedToEnd && msgStartPos < recorderState.wpos) { - break; - } - - msg.init(msgStartPos, msgLen); - parseMessage(msg); - - curMsgPos = msgStartPos - 2; - } - - return messages; - } - - public static List doParse(RandomAccessFile f, HeaderScanResult metaHeader, HeaderScanResult dataHeader) throws IOException { - //read regions to byte buffers - f.seek(metaHeader.pos); - byte[] metaRegionData = new byte[metaHeader.len]; - f.readFully(metaRegionData); - - f.seek(dataHeader.pos); - byte[] dataRegionData = new byte[dataHeader.len]; - f.readFully(dataRegionData); - - UtilByteBuffer metaRegion = new UtilByteBuffer(metaRegionData); - UtilByteBuffer dataRegion = new UtilByteBuffer(dataRegionData); - - List res = new FlightLogParser(metaRegion, dataRegion).parse(); - Collections.reverse(res); - return res; - } -} - diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/LogParsingException.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/LogParsingException.java deleted file mode 100644 index bd65f3d..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/LogParsingException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.rehlds.flightrec.logparser; - -public class LogParsingException extends RuntimeException { - - public LogParsingException(String message) { - super(message); - } - - public LogParsingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/MetaHeader.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/MetaHeader.java deleted file mode 100644 index 19b3eba..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/MetaHeader.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.rehlds.flightrec.logparser; - -public class MetaHeader { - public int numDefinitions; - public int metaRegionPos; - - public MetaHeader(int numMessages, int metaRegionPos) { - this.numDefinitions = numMessages; - this.metaRegionPos = metaRegionPos; - } - - public MetaHeader() { - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/RecorderState.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/RecorderState.java deleted file mode 100644 index a965b64..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logparser/RecorderState.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.rehlds.flightrec.logparser; - -public class RecorderState { - public int wpos; - public int lastMsgBeginPos; - public int curMessage; - - public RecorderState(int wpos, int lastMsgBeginPos, int curMessage) { - this.wpos = wpos; - this.lastMsgBeginPos = lastMsgBeginPos; - this.curMessage = curMessage; - } - - public RecorderState() { - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/FlightLogTreeBuilder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/FlightLogTreeBuilder.java deleted file mode 100644 index d7332af..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/FlightLogTreeBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.rehlds.flightrec.logtree; - -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.api.FlightrecMessageType; - -import java.util.List; - -public class FlightLogTreeBuilder { - LogTreeNodeComplex rootNode = new LogTreeNodeComplex(null, null, null); - LogTreeNodeComplex currentNode = rootNode; - - void handleEnterMessage(FlightrecMessage msg) { - LogTreeNodeComplex n = new LogTreeNodeComplex(currentNode, msg, null); - currentNode.addChild(n); - currentNode = n; - } - - void handleLeaveMessage(FlightrecMessage msg) { - if (currentNode == rootNode) { - currentNode.leaveMsg = msg; - rootNode = new LogTreeNodeComplex(null, null, null); - rootNode.addChild(currentNode); - currentNode.setParent(rootNode); - currentNode = rootNode; - return; - } - - if (currentNode.enterMsg != null) { - FlightrecMessageType startType = currentNode.enterMsg.messageType; - FlightrecMessageType endType = msg.messageType; - if (!startType.equals(endType)) { - throw new RuntimeException("Closing message @" + Long.toHexString(msg.rawDataPos) + " has invalid type " + endType + "; expected " + startType); - } - } - - currentNode.leaveMsg = msg; - currentNode = currentNode.parent; - } - - void handleSimpleMessage(FlightrecMessage msg) { - LogTreeNodeLeaf leafNode = new LogTreeNodeLeaf(currentNode, msg); - currentNode.addChild(leafNode); - } - - void doBuildLogTree(List messages) { - for (FlightrecMessage msg : messages) { - switch (msg.entranceKind) { - case ENTRANCE_ENTER: - handleEnterMessage(msg); - break; - - case ENTRANCE_LEAVE: - handleLeaveMessage(msg); - break; - - case ENTRANCE_UNUSED: - handleSimpleMessage(msg); - break; - - default: - throw new RuntimeException("Invalid exntrance kind"); - } - } - } - - - public static LogTreeNodeComplex buildTree(List messages) { - FlightLogTreeBuilder builder = new FlightLogTreeBuilder(); - builder.doBuildLogTree(messages); - return builder.rootNode; - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNode.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNode.java deleted file mode 100644 index de6d14f..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNode.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.rehlds.flightrec.logtree; - -import java.util.List; - -public abstract class LogTreeNode { - LogTreeNodeComplex parent; - - protected LogTreeNode(LogTreeNodeComplex parent) { - this.parent = parent; - } - - abstract List getChildren(); - - LogTreeNodeComplex getParent() { - return parent; - } - - public void setParent(LogTreeNodeComplex parent) { - this.parent = parent; - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeComplex.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeComplex.java deleted file mode 100644 index 3f99094..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeComplex.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.rehlds.flightrec.logtree; - -import org.rehlds.flightrec.api.FlightrecMessage; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class LogTreeNodeComplex extends LogTreeNode { - public FlightrecMessage enterMsg; - public FlightrecMessage leaveMsg; - - public LogTreeNodeComplex(LogTreeNodeComplex parent, FlightrecMessage enterMsg, FlightrecMessage leaveMsg) { - super(parent); - this.enterMsg = enterMsg; - this.leaveMsg = leaveMsg; - } - - List children = Collections.emptyList(); - - - - @Override - public List getChildren() { - return children; - } - - public void addChild(LogTreeNode node) { - if (children.isEmpty()) { - children = new ArrayList<>(); - } - - children.add(node); - } - -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeLeaf.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeLeaf.java deleted file mode 100644 index bfdb6ca..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/logtree/LogTreeNodeLeaf.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.rehlds.flightrec.logtree; - -import org.rehlds.flightrec.api.FlightrecMessage; - -import java.util.Collections; -import java.util.List; - -public class LogTreeNodeLeaf extends LogTreeNode { - public FlightrecMessage msg; - - public LogTreeNodeLeaf(LogTreeNodeComplex parent, FlightrecMessage msg) { - super(parent); - this.msg = msg; - } - - @Override - List getChildren() { - return Collections.emptyList(); - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/FlightRecorder.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/FlightRecorder.java deleted file mode 100644 index f6fd5cc..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/FlightRecorder.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.rehlds.flightrec.main; - -import org.rehlds.flightrec.api.DecoderModule; -import org.rehlds.flightrec.api.FlightrecMessage; -import org.rehlds.flightrec.decoders.rehlds.RehldsDecodersModule; -import org.rehlds.flightrec.filescan.FileScanResult; -import org.rehlds.flightrec.filescan.FlightRecFileScanner; -import org.rehlds.flightrec.filescan.HeaderScanResult; -import org.rehlds.flightrec.logtree.FlightLogTreeBuilder; -import org.rehlds.flightrec.logtree.LogTreeNodeComplex; -import org.rehlds.flightrec.logparser.FlightLogParser; -import org.rehlds.flightrec.textlogwriter.TextLogWriter; -import org.rehlds.flightrec.util.JarUtils; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.*; - -public class FlightRecorder { - RunConfig cfg; - List decoderModules = new ArrayList<>(); - - public FlightRecorder(RunConfig cfg) { - this.cfg = cfg; - } - - private boolean checkConfig() { - if (cfg.dumpFile == null) { - System.out.println("Dump file is not selected, please use --dump-file parameter to specify it"); - return false; - } - - if (cfg.outFile == null) { - cfg.outFile = new File(cfg.dumpFile.getAbsolutePath() + ".flog"); - } - - return true; - } - - private List scanFile(RandomAccessFile f) throws IOException { - FileScanResult scanResult = FlightRecFileScanner.scan(f); - - System.out.println("Dump file scan results: "); - for (HeaderScanResult hdr : scanResult.metaHeaders) { - System.out.print(String.format("\tMeta header @ 0x%08X; len=%d; version=%d; valid=%s", hdr.pos, hdr.len, hdr.version, "" + (hdr.error == null))); - if (hdr.error != null) { - System.out.print("; error: " + hdr.error); - } - System.out.println(); - } - for (HeaderScanResult hdr : scanResult.dataHeaders) { - System.out.print(String.format("\tData header @ 0x%08X; len=%d; version=%d; valid=%s", hdr.pos, hdr.len, hdr.version, "" + (hdr.error == null))); - if (hdr.error != null) { - System.out.print("; error: " + hdr.error); - } - System.out.println(); - } - - HeaderScanResult validMetaHeader = null; - HeaderScanResult validDataHeader = null; - - for (HeaderScanResult metaHeader : scanResult.metaHeaders) { - if (metaHeader.error != null) { - continue; - } - - if (validMetaHeader != null) { - System.out.println("Multiple meta headers found, exiting"); - return null; - } - - validMetaHeader = metaHeader; - } - - for (HeaderScanResult dataHeader : scanResult.dataHeaders) { - if (dataHeader.error != null) { - continue; - } - - if (validDataHeader != null) { - System.out.println("Multiple data headers found, exiting"); - return null; - } - - validDataHeader = dataHeader; - } - - if (validMetaHeader == null) { - System.out.println("Meta header not found, exiting"); - return null; - } - - if (validDataHeader == null) { - System.out.println("Data header not found, exiting"); - return null; - } - - return FlightLogParser.doParse(f, validMetaHeader, validDataHeader); - } - - private LogTreeNodeComplex buildTree(List messages) { - return FlightLogTreeBuilder.buildTree(messages); - } - - private boolean writeOutputFile(LogTreeNodeComplex logTreeRoot) { - TextLogWriter.decodeAndWrite(logTreeRoot, cfg.outFile, decoderModules); - System.out.println("Written decoded log to '" + cfg.outFile.getAbsolutePath() + ";"); - return true; - } - - public boolean run() { - registerBuiltinDecoders(); - loadExternalDecoders(); - - if (!checkConfig()) { - return false; - } - - List messages; - try(RandomAccessFile f = new RandomAccessFile(cfg.dumpFile, "r")) { - messages = scanFile(f); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - - if (messages == null) { - return false; - } - - System.out.println("Read " + messages.size() + " messages from '" + cfg.dumpFile.getAbsolutePath() + "'"); - LogTreeNodeComplex treeRootNode = buildTree(messages); - if (treeRootNode == null) { - return false; - } - - if (!writeOutputFile(treeRootNode)) { - return false; - } - - return true; - } - - private void loadExternalDecoders() { - File f = JarUtils.getJarFileOfClass(FlightRecorder.class); - if (f == null) { - System.out.println("Could not locate main JAR, external decoders will not be loaded"); - return; - } - - File extDir = new File(f.getParentFile(), "extDecoders"); - if (!extDir.exists() || !extDir.isDirectory()) { - System.out.println("Directory '" + extDir.getAbsolutePath() + "' doesn't exist"); - } - - File[] jarFiles = extDir.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().toLowerCase().endsWith(".jar"); - } - }); - - ArrayList jarUrls = new ArrayList<>(); - for (File jf : jarFiles) { - try { - jarUrls.add(jf.toURI().toURL()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - URLClassLoader extDecodersClassloader = new URLClassLoader(jarUrls.toArray(new URL[jarUrls.size()]), this.getClass().getClassLoader()); - ServiceLoader srvLoader = ServiceLoader.load(DecoderModule.class, extDecodersClassloader); - for (DecoderModule decoderModule : srvLoader) { - System.out.println("Loaded external decoder module " + decoderModule.getDescription() + " version " + decoderModule.getVersion()); - decoderModules.add(decoderModule); - } - } - - private void registerBuiltinDecoders() { - decoderModules.add(new RehldsDecodersModule()); - } - - public static void main(String args[]) { - RunConfig cfg; - try { - cfg = parseArgs(args); - } catch (IllegalArgumentException e) { - System.out.println(e.getMessage()); - return; - } - - new FlightRecorder(cfg).run(); - } - - private static RunConfig parseArgs(String args[]) { - RunConfig cfg = new RunConfig(); - for (int i = 0; i < args.length; i++) { - String a = args[i]; - - if ("--dump-file".equals(a)) { - if (i + 1 >= args.length) { - throw new IllegalArgumentException("--dump-file should be followed by file name"); - } - i++; - cfg.dumpFile = new File(args[i]); - continue; - } - - if ("--out-file".equals(a)) { - if (i + 1 >= args.length) { - throw new IllegalArgumentException("--out-file should be followed by file name"); - } - i++; - cfg.outFile = new File(args[i]); - continue; - } - - throw new IllegalArgumentException("Invalid command line parameter: '" + a + "'"); - } - - return cfg; - } - -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/RunConfig.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/RunConfig.java deleted file mode 100644 index 191dd33..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/main/RunConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.rehlds.flightrec.main; - -import java.io.File; - -public class RunConfig { - public File dumpFile; - public File outFile; -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/textlogwriter/TextLogWriter.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/textlogwriter/TextLogWriter.java deleted file mode 100644 index 31effe8..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/textlogwriter/TextLogWriter.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.rehlds.flightrec.textlogwriter; - -import org.rehlds.flightrec.api.*; -import org.rehlds.flightrec.logtree.LogTreeNode; -import org.rehlds.flightrec.logtree.LogTreeNodeComplex; -import org.rehlds.flightrec.logtree.LogTreeNodeLeaf; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class TextLogWriter { - Writer writer; - List decoderModules; - - int indent; - HashMap indents = new HashMap<>(); - Map decodersByMsgType = new HashMap<>(); - - public TextLogWriter(Writer writer, List decoderModules) { - this.writer = writer; - this.decoderModules = decoderModules; - } - - MessageDecoder lookupDecoder(FlightrecMessageType msgType) { - for (DecoderModule dm : decoderModules) { - MessageDecoder d = dm.lookupDecoder(msgType); - if (d != null) { - return d; - } - } - - return null; - } - - MessageDecoder getDecoder(FlightrecMessage message) { - FlightrecMessageType msgType = message.messageType; - if (!decodersByMsgType.containsKey(msgType)) { - decodersByMsgType.put(msgType, lookupDecoder(msgType)); - } - - return decodersByMsgType.get(msgType); - } - - DecodedExtraData tryDecode(FlightrecMessage message) { - MessageDecoder decoder = getDecoder(message); - if (decoder == null) { - return null; - } - return decoder.decode(message); - } - - String escapeString(String s) { - return s.replace("\"", "\\\"") - .replace("'", "\\'") - .replace("\n", "\\n") - .replace("\r", "\\r"); - } - - String generateIndent() { - String res = indents.get(indent); - if (res != null) { - return res; - } - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < indent; i++) { - sb.append(" "); - } - - res = sb.toString(); - indents.put(indent, res); - return res; - } - - void writeExtraData(StringBuilder sb, DecodedExtraData extraData) { - boolean first = true; - for (ImmutablePair kv : extraData.data) { - if (first) { - first = false; - } else { - sb.append(", "); - } - sb.append(kv.first).append(": '").append(escapeString(kv.second)).append("'"); - } - } - - String prepareMessageText(FlightrecMessage msg) { - StringBuilder sb = new StringBuilder(); - sb.append(generateIndent()); - - switch (msg.entranceKind) { - case ENTRANCE_ENTER: - sb.append(">>"); - break; - - case ENTRANCE_LEAVE: - sb.append("<<"); - break; - - case ENTRANCE_UNUSED: - sb.append("--"); - break; - - default: - throw new RuntimeException("Invalid entrance kind " + msg.entranceKind); - } - - FlightrecMessageType msgType = msg.messageType; - sb.append(" ").append(msgType.module).append(".").append(msgType.message).append(":").append(msgType.version).append(" "); - - DecodedExtraData extraData = tryDecode(msg); - if (extraData != null) { - writeExtraData(sb, extraData); - } else { - sb.append("undecoded["); - boolean firstByte = true; - for (int i = msg.rawDataPos; i < msg.rawDataLen + msg.rawDataPos; i++) { - if (firstByte) { - firstByte = false; - } else { - sb.append(" "); - } - sb.append(String.format("%02X", msg.rawData[i] & 0xFF)); - } - sb.append("]"); - } - - sb.append("\n"); - return sb.toString(); - } - - void writeMessage(FlightrecMessage msg) throws IOException { - String text = prepareMessageText(msg); - writer.write(text); - } - - void writeLeafNode(LogTreeNodeLeaf node) throws IOException { - writeMessage(node.msg); - } - - void writeComplexNode(LogTreeNodeComplex node) throws IOException { - if (node.enterMsg != null) { - writeMessage(node.enterMsg); - } else { - writer.write(generateIndent() + ">> [Unknown]\n"); - } - - indent++; - writeNodes(node.getChildren()); - indent--; - - if (node.leaveMsg != null) { - writeMessage(node.leaveMsg); - } else { - writer.write(generateIndent() + "<< [Unknown]\n"); - } - } - - void writeNodes(List nodes) throws IOException { - for (LogTreeNode node : nodes) { - if (node instanceof LogTreeNodeComplex) { - writeComplexNode((LogTreeNodeComplex) node); - } else if (node instanceof LogTreeNodeLeaf) { - writeLeafNode((LogTreeNodeLeaf) node); - } else { - throw new RuntimeException("Invalid node class " + node.getClass().getName()); - } - } - } - - - public static void decodeAndWrite(LogTreeNodeComplex rootNode, File outFile, List decoderModules) { - try (FileWriter fw = new FileWriter(outFile)) { - TextLogWriter logWriter = new TextLogWriter(fw, decoderModules); - logWriter.writeNodes(rootNode.getChildren()); - } catch (IOException e) { - throw new RuntimeException("Failed to open/write file '" + outFile + "': " + e.getMessage(), e); - } - } -} diff --git a/flightrec/decoder/src/main/java/org/rehlds/flightrec/util/JarUtils.java b/flightrec/decoder/src/main/java/org/rehlds/flightrec/util/JarUtils.java deleted file mode 100644 index 41d062a..0000000 --- a/flightrec/decoder/src/main/java/org/rehlds/flightrec/util/JarUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.rehlds.flightrec.util; - -import java.io.File; -import java.net.URL; - -public class JarUtils { - public static File getJarFileOfClass(Class c) { - String classFileName = c.getName().replace('.', '/') + ".class"; - ClassLoader classLoader = c.getClassLoader(); - if (classLoader == null) { - classLoader = JarUtils.class.getClassLoader(); - } - URL url = classLoader.getResource(classFileName); - if (url == null) { - return null; - } - - String strUrl = url.toString(); - if (!strUrl.startsWith("jar:file:/")) { - return null; - } - - int jarSeparator = strUrl.indexOf('!'); - if (jarSeparator == -1) { - return null; - } - - String jarFilePath = strUrl.substring("jar:file:/".length(), jarSeparator); - return new File(jarFilePath); - } -} diff --git a/flightrec/decoder/src/test/groovy/org/rehlds/flightrec/logtree/FlightLogTreeBuilderTest.groovy b/flightrec/decoder/src/test/groovy/org/rehlds/flightrec/logtree/FlightLogTreeBuilderTest.groovy deleted file mode 100644 index 40edd56..0000000 --- a/flightrec/decoder/src/test/groovy/org/rehlds/flightrec/logtree/FlightLogTreeBuilderTest.groovy +++ /dev/null @@ -1,181 +0,0 @@ -package org.rehlds.flightrec.logtree - -import org.junit.Test -import org.rehlds.flightrec.api.EntranceKind -import org.rehlds.flightrec.api.FlightrecMessage -import org.rehlds.flightrec.api.FlightrecMessageType - -class FlightLogTreeBuilderTest { - static final FlightrecMessageType hierarchyMsgType1 = new FlightrecMessageType('test', 'hmsg1', 1, true); - static final FlightrecMessageType hierarchyMsgType2 = new FlightrecMessageType('test', 'hmsg1', 1, true); - static final FlightrecMessageType flatMsgType1 = new FlightrecMessageType('test', 'flatmsg1', 1, true); - static final FlightrecMessageType flatMsgType2 = new FlightrecMessageType('test', 'flatmsg2', 1, true); - - static FlightrecMessage enterMsg(FlightrecMessageType type) { - return new FlightrecMessage(type, EntranceKind.ENTRANCE_ENTER, null, 0, 0); - } - - static FlightrecMessage leaveMsg(FlightrecMessageType type) { - return new FlightrecMessage(type, EntranceKind.ENTRANCE_LEAVE, null, 0, 0); - } - - static FlightrecMessage flatMsg(FlightrecMessageType type) { - return new FlightrecMessage(type, EntranceKind.ENTRANCE_UNUSED, null, 0, 0); - } - - @Test - void 'decode 2 flat messages'() { - def messages = [flatMsg(flatMsgType1), flatMsg(flatMsgType2)] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - assert rootNode.children[0].msg == messages[0]; - assert rootNode.children[1].msg == messages[1]; - - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - } - - @Test - void 'decode 2 empty hierarchy msgs'() { - def messages = [ - enterMsg(hierarchyMsgType1), leaveMsg(hierarchyMsgType1), - enterMsg(hierarchyMsgType2), leaveMsg(hierarchyMsgType2) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - - rootNode.children[0].enterMsg == messages[0] - rootNode.children[0].leaveMsg == messages[1] - assert rootNode.children[0].children.empty - - rootNode.children[1].enterMsg == messages[2] - rootNode.children[1].leaveMsg == messages[3] - assert rootNode.children[1].children.empty - - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - } - - @Test - void 'decode 2 hierarchy messages with flat payload'() { - def messages = [ - enterMsg(hierarchyMsgType1), flatMsg(flatMsgType1), leaveMsg(hierarchyMsgType1), - enterMsg(hierarchyMsgType2), flatMsg(flatMsgType2), leaveMsg(hierarchyMsgType2) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - - rootNode.children[0].enterMsg == messages[0] - rootNode.children[0].leaveMsg == messages[2] - assert rootNode.children[0].children.size() == 1 - assert rootNode.children[0].children[0].msg == messages[1] - - rootNode.children[1].enterMsg == messages[3] - rootNode.children[1].leaveMsg == messages[5] - assert rootNode.children[1].children.size() == 1 - assert rootNode.children[1].children[0].msg == messages[4] - - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - } - - @Test - void 'decode hierarchical message with mixed payload'() { - def messages = [ - flatMsg(flatMsgType2), - enterMsg(hierarchyMsgType1), - flatMsg(flatMsgType1), - enterMsg(hierarchyMsgType2), - flatMsg(flatMsgType2), - leaveMsg(hierarchyMsgType2), - flatMsg(flatMsgType2), - leaveMsg(hierarchyMsgType1), - flatMsg(flatMsgType1) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 3 - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - - assert rootNode.children[0].msg == messages[0] - assert rootNode.children[2].msg == messages[8] - - assert rootNode.children[1].enterMsg == messages[1] - assert rootNode.children[1].leaveMsg == messages[7] - assert rootNode.children[1].children.size() == 3 - - assert rootNode.children[1].children[0].msg == messages[2] - assert rootNode.children[1].children[2].msg == messages[6] - - assert rootNode.children[1].children[1].enterMsg == messages[3] - assert rootNode.children[1].children[1].leaveMsg == messages[5] - assert rootNode.children[1].children[1].children.size() == 1 - - assert rootNode.children[1].children[1].children[0].msg == messages[4] - } - - @Test - void 'decode hierarchical msg with flat payload and missing start'() { - def messages = [ - flatMsg(flatMsgType1), - leaveMsg(hierarchyMsgType1), - flatMsg(flatMsgType2) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - - assert rootNode.children[0].enterMsg == null - assert rootNode.children[0].leaveMsg == messages[1] - assert rootNode.children[0].children.size() == 1 - assert rootNode.children[0].children[0].msg == messages[0] - - assert rootNode.children[1].msg == messages[2] - } - - @Test - void 'decode empty hierarchical msg with missing start'() { - def messages = [ - leaveMsg(hierarchyMsgType1), - flatMsg(flatMsgType2) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - - assert rootNode.children[0].enterMsg == null - assert rootNode.children[0].leaveMsg == messages[0] - assert rootNode.children[0].children.empty - - assert rootNode.children[1].msg == messages[1] - } - - @Test - void 'decode hierarchical msg with flat payload and missing end'() { - def messages = [ - flatMsg(flatMsgType1), - enterMsg(hierarchyMsgType1), - flatMsg(flatMsgType2) - ] - def rootNode = FlightLogTreeBuilder.buildTree(messages) - - assert rootNode.children.size() == 2 - assert rootNode.enterMsg == null - assert rootNode.leaveMsg == null - - assert rootNode.children[0].msg == messages[0] - - assert rootNode.children[1].enterMsg == messages[1] - assert rootNode.children[1].leaveMsg == null - assert rootNode.children[1].children.size() == 1 - assert rootNode.children[1].children[0].msg == messages[2] - } -} diff --git a/flightrec/decoder/src/test/java/com/google/cloud/Crc32cTest.java b/flightrec/decoder/src/test/java/com/google/cloud/Crc32cTest.java deleted file mode 100644 index 51328da..0000000 --- a/flightrec/decoder/src/test/java/com/google/cloud/Crc32cTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.google.cloud; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class Crc32cTest { - - static class TestData { - public String src; - public long hash; - - TestData(String src, long hash) { - this.src = src; - this.hash = hash; - } - } - - @Test - public void testCrc32c() { - TestData testData[] = { - new TestData("a", 0x93AD1061L), - new TestData("ab", 0x13C35EE4L), - new TestData("abc", 0x562F9CCDL), - new TestData("abcd", 0xDAAF41F6L), - new TestData("abcde", 0x8122A0A2L), - new TestData("abcdef", 0x0496937BL), - new TestData("abcdefg", 0x5D199E2CL), - new TestData("abcdefgh", 0x86BC933DL), - new TestData("abcdefghi", 0x9639F15FL), - new TestData("abcdefghij", 0x0584645CL), - }; - - for (TestData t : testData) { - Crc32c crc32c = new Crc32c(); - crc32c.update(t.src.getBytes()); - long cksum = crc32c.getValue(); - - assertEquals(t.hash, cksum); - } - } - -} \ No newline at end of file diff --git a/flightrec/decoder_api/build.gradle b/flightrec/decoder_api/build.gradle deleted file mode 100644 index 3ec5e22..0000000 --- a/flightrec/decoder_api/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -apply plugin: 'java' -apply plugin: 'maven-publish' - -group = 'org.rehlds.flightrec' -version = rootProject.version - -sourceCompatibility = '1.7' -targetCompatibility = '1.7' - -repositories { - mavenCentral() -} - -dependencies { - testCompile "junit:junit:4.12" -} - -publishing { - publications { - maven(MavenPublication) { - version project.version - artifactId 'decoder-api' - artifact jar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = DELEGATE_FIRST - name 'decoder-api' - description project.description - //url github - //scm { - // url "${github}.git" - // connection "scm:git:${github}.git" - //} - /* - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - developers { - developer { - id 'dreamstalker' - name 'dreamstalker' - } - } - */ - } - } - } - } -} - -publishing { - repositories { - maven { - if (project.version.contains('dev')) { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" - } else { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" - } - credentials { - username rootProject.repoCreds.getProperty('username') - password rootProject.repoCreds.getProperty('password') - } - } - } -} - -tasks.withType(AbstractCompile) { - options.encoding = 'UTF-8' -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecodedExtraData.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecodedExtraData.java deleted file mode 100644 index a5564a5..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecodedExtraData.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.rehlds.flightrec.api; - -public class DecodedExtraData { - public ImmutablePair[] data; - - public DecodedExtraData(ImmutablePair[] data) { - this.data = data; - } - - public static final DecodedExtraData EMPTY = new DecodedExtraData(new ImmutablePair[0]); - - public static DecodedExtraData create(String... args) { - if ((args.length % 2) == 1) { - throw new RuntimeException("DecodedExtraData.create: number of arguments must be even"); - } - - int numPairs = args.length / 2; - DecodedExtraData res = new DecodedExtraData(new ImmutablePair[numPairs]); - - for (int i = 0; i < numPairs; i++) { - res.data[i] = new ImmutablePair<>(args[i * 2], args[i * 2 + 1]); - } - - return res; - } - - -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecoderModule.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecoderModule.java deleted file mode 100644 index 3ed144a..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/DecoderModule.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.rehlds.flightrec.api; - -public interface DecoderModule { - public MessageDecoder lookupDecoder(FlightrecMessageType msgType); - public String getDescription(); - public String getVersion(); -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/EntranceKind.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/EntranceKind.java deleted file mode 100644 index 9f96aa2..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/EntranceKind.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.rehlds.flightrec.api; - -public enum EntranceKind { - ENTRANCE_ENTER, - ENTRANCE_LEAVE, - ENTRANCE_UNUSED, -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessage.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessage.java deleted file mode 100644 index 6d3011d..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessage.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.rehlds.flightrec.api; - -import org.rehlds.flightrec.api.util.UtilByteBuffer; -import org.rehlds.flightrec.api.util.UtilSizeBuf; - -public class FlightrecMessage { - public final FlightrecMessageType messageType; - public final EntranceKind entranceKind; - - public final byte[] rawData; - public final int rawDataPos; - public final int rawDataLen; - - DecodedExtraData decodedData; - - public FlightrecMessage(FlightrecMessageType messageType, EntranceKind entranceKind, byte[] rawData, int rawDataOffset, int rawDataLen) { - this.messageType = messageType; - this.entranceKind = entranceKind; - this.rawData = rawData; - this.rawDataPos = rawDataOffset; - this.rawDataLen = rawDataLen; - } - - public UtilSizeBuf getDataSizebuf() { - return new UtilSizeBuf("msg: '" + messageType + "' @" + rawDataPos, new UtilByteBuffer(rawData), rawDataPos, rawDataLen); - } - - public boolean isEnterMessage() { - return (entranceKind == EntranceKind.ENTRANCE_ENTER); - } - - public boolean isLeaveMessage() { - return (entranceKind == EntranceKind.ENTRANCE_LEAVE); - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageDef.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageDef.java deleted file mode 100644 index 4c40a48..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageDef.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.rehlds.flightrec.api; - -public class FlightrecMessageDef { - public final FlightrecMessageType msgType; - public final int opcode; - - public FlightrecMessageDef(String module, String message, long version, boolean inout, int opcode) { - msgType = new FlightrecMessageType(module, message, version, inout); - this.opcode = opcode; - } - - @Override - public String toString() { - return "FlightrecMessageDef{" + - "module='" + msgType.module + '\'' + - ", message='" + msgType.message + '\'' + - ", version=" + msgType.version + - ", inout=" + msgType.inout + - ", opcode=" + opcode + - '}'; - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageType.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageType.java deleted file mode 100644 index 102cc49..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/FlightrecMessageType.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.rehlds.flightrec.api; - -public class FlightrecMessageType { - public final String module; - public final String message; - public final long version; - public final boolean inout; - - public FlightrecMessageType(String module, String message, long version, boolean inout) { - this.module = module; - this.message = message; - this.version = version; - this.inout = inout; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - FlightrecMessageType that = (FlightrecMessageType) o; - - if (inout != that.inout) return false; - if (version != that.version) return false; - if (!message.equals(that.message)) return false; - if (!module.equals(that.module)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = module.hashCode(); - result = 31 * result + message.hashCode(); - result = 31 * result + (int) (version ^ (version >>> 32)); - result = 31 * result + (inout ? 1 : 0); - return result; - } - - @Override - public String toString() { - return "FlightrecMessageType{" + - "module='" + module + '\'' + - ", message='" + message + '\'' + - ", version=" + version + - ", inout=" + inout + - '}'; - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/ImmutablePair.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/ImmutablePair.java deleted file mode 100644 index ed6f7ef..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/ImmutablePair.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.rehlds.flightrec.api; - -public class ImmutablePair { - public final T first; - public final U second; - - public ImmutablePair(T first, U second) { - this.first = first; - this.second = second; - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/MessageDecoder.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/MessageDecoder.java deleted file mode 100644 index 69d3f51..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/MessageDecoder.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.rehlds.flightrec.api; - -public interface MessageDecoder { - FlightrecMessageType getMessageType(); - DecodedExtraData decode(FlightrecMessage msg); -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/SimpleDecoderModule.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/SimpleDecoderModule.java deleted file mode 100644 index a1c3ead..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/SimpleDecoderModule.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.rehlds.flightrec.api; - -import java.util.HashMap; -import java.util.Map; - -public class SimpleDecoderModule implements DecoderModule { - Map decoders = new HashMap<>(); - - public final String description; - public final String version; - - public SimpleDecoderModule(String description, String version) { - this.description = description; - this.version = version; - } - - @Override - public MessageDecoder lookupDecoder(FlightrecMessageType msgType) { - return decoders.get(msgType); - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getVersion() { - return version; - } - - public void registerDecoder(MessageDecoder msgDecoder) { - decoders.put(msgDecoder.getMessageType(), msgDecoder); - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/Globals.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/Globals.java deleted file mode 100644 index ba583b7..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/Globals.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.rehlds.flightrec.api.util; - -import java.nio.charset.Charset; - -public class Globals { - public static final Charset UTF8 = Charset.forName("UTF-8"); - -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/SizebufOverflowException.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/SizebufOverflowException.java deleted file mode 100644 index ad4ec97..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/SizebufOverflowException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.rehlds.flightrec.api.util; - -public class SizebufOverflowException extends RuntimeException { - public final String sizebufName; - - public SizebufOverflowException(String sizebufName) { - super(sizebufName + " overflowed"); - this.sizebufName = sizebufName; - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilByteBuffer.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilByteBuffer.java deleted file mode 100644 index aa76d21..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilByteBuffer.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.rehlds.flightrec.api.util; - -public class UtilByteBuffer { - byte data[]; - - public UtilByteBuffer(byte[] data) { - this.data = data; - } - - public byte[] getData() { - return data; - } - - public UtilByteBuffer cutLeft(int newStart) { - byte[] newData = new byte[data.length - newStart]; - System.arraycopy(data, newStart, newData, 0, data.length - newStart); - return new UtilByteBuffer(newData); - } - - public int getDataLength() { - return data.length; - } - - public int readUInt8(int pos) { - return data[pos] & 0xFF; - } - - public boolean readBool(int pos) { - return data[pos] != 0; - } - - public int readUInt16(int pos) { - return (data[pos] & 0xFF) | ((data[pos + 1] & 0xFF) << 8); - } - - public long readUInt32(int pos) { - return (data[pos] & 0xFF) | ((data[pos + 1] & 0xFF) << 8) | ((data[pos + 2] & 0xFF) << 16) | ((long)(data[pos + 3] & 0xFF) << 24); - } - - public int readInt32(int pos) { - return (data[pos] & 0xFF) | ((data[pos + 1] & 0xFF) << 8) | ((data[pos + 2] & 0xFF) << 16) | ((data[pos + 3] & 0xFF) << 24); - } - - public long readInt64(int pos) { - long lowBits = readUInt32(pos); - long highBits = readUInt32(pos + 4); - - return lowBits | (highBits << 32); - } - - public double readDouble(int pos) { - long bits = readInt64(pos); - return Double.longBitsToDouble(bits); - } - - public float readFloat(int pos) { - int bits = readInt32(pos); - return Float.intBitsToFloat(bits); - } - - public String readString(int pos) { - return readString(pos, data.length - pos, true); - } - - public String readString(int pos, int maxSize, boolean errorOnMaxSizeHit) { - int iMax = Math.min(data.length, pos + maxSize); - for (int i = pos; i < iMax; i++) { - if (data[i] == 0) { - return new String(data, pos, i - pos, Globals.UTF8); - } - } - - if (errorOnMaxSizeHit) { - return null; - } - - return new String(data, pos, iMax - pos, Globals.UTF8); - } -} diff --git a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilSizeBuf.java b/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilSizeBuf.java deleted file mode 100644 index d8e52a7..0000000 --- a/flightrec/decoder_api/src/main/java/org/rehlds/flightrec/api/util/UtilSizeBuf.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.rehlds.flightrec.api.util; - -public class UtilSizeBuf { - String name; - UtilByteBuffer buf; - int startPos; - int maxSize; - int curPos; - - public UtilSizeBuf(String name, UtilByteBuffer buf, int startPos, int maxSize) { - this.name = name; - this.buf = buf; - this.startPos = startPos; - this.maxSize = maxSize; - curPos = 0; - } - - public UtilSizeBuf(String name, UtilByteBuffer buf) { - this(name, buf, 0, buf.getDataLength()); - } - - public void init(int startPos, int maxSize) { - this.startPos = startPos; - this.maxSize = maxSize; - curPos = 0; - } - - public void reset() { - this.curPos = 0; - } - - public int tell() { - return curPos; - } - - public int getAbsoluteCurrentPos() { - return curPos + startPos; - } - - public void skip(int count) { - if (curPos + count > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - curPos += count; - } - - public int readUInt8() { - if (curPos + 1 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos++; - return buf.readUInt8(pos + this.startPos); - } - - public boolean readBool() { - if (curPos + 1 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos++; - return buf.readBool(pos + this.startPos); - } - - public int readUInt16() { - if (curPos + 2 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 2; - return buf.readUInt16(pos + this.startPos); - } - - public long readUInt32() { - if (curPos + 4 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 4; - return buf.readUInt32(pos + this.startPos); - } - - public int readInt32() { - if (curPos + 4 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 4; - return buf.readInt32(pos + this.startPos); - } - - public long readInt64() { - if (curPos + 8 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 8; - return buf.readInt64(pos + this.startPos); - } - - public double readDouble() { - if (curPos + 8 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 8; - return buf.readDouble(pos + this.startPos); - } - - public float readFloat() { - if (curPos + 4 > maxSize) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - int pos = curPos; - curPos += 4; - return buf.readFloat(pos + this.startPos); - } - - public String readString() { - String s = buf.readString(curPos + this.startPos); - if (s == null) { - curPos = maxSize; - throw new SizebufOverflowException(name); - } - - curPos += s.getBytes(Globals.UTF8).length + 1; - return s; - } - - public int getStartPos() { - return startPos; - } - - public int getMaxSize() { - return maxSize; - } - - public byte[] getBuffer() { - return buf.getData(); - } -} diff --git a/flightrec/decoder_api/src/test/java/org/rehlds/flightrec/util/UtilByteBufferTest.java b/flightrec/decoder_api/src/test/java/org/rehlds/flightrec/util/UtilByteBufferTest.java deleted file mode 100644 index 22ed565..0000000 --- a/flightrec/decoder_api/src/test/java/org/rehlds/flightrec/util/UtilByteBufferTest.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.rehlds.flightrec.util; - -import org.junit.Test; -import org.rehlds.flightrec.api.util.UtilByteBuffer; - -import static org.junit.Assert.*; - -public class UtilByteBufferTest { - - @Test - public void testReadUInt8() throws Exception { - byte data[] = { 0x10, 0x00, 0x7F, (byte)0x80, (byte)0xFF }; - UtilByteBuffer bb = new UtilByteBuffer(data); - - assertEquals(0x10, bb.readUInt8(0)); - assertEquals(0x00, bb.readUInt8(1)); - assertEquals(0x7F, bb.readUInt8(2)); - assertEquals(0x80, bb.readUInt8(3)); - assertEquals(0xFF, bb.readUInt8(4)); - } - - @Test - public void testReadUInt16() throws Exception { - byte data[] = { 0x10, 0x00, 0x7F, (byte)0x80, (byte)0xFF, 0x00 }; - UtilByteBuffer bb = new UtilByteBuffer(data); - - assertEquals(0x10, bb.readUInt16(0)); - assertEquals(0x7F00, bb.readUInt16(1)); - assertEquals(0x807F, bb.readUInt16(2)); - assertEquals(0xFF80, bb.readUInt16(3)); - assertEquals(0x00FF, bb.readUInt16(4)); - } - - @Test - public void testReadUInt32() throws Exception { - byte data[] = { 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, (byte)0xFF, 0x00, 0x00, 0x00 }; - UtilByteBuffer bb = new UtilByteBuffer(data); - assertEquals(0x10000000, bb.readUInt32(0)); - assertEquals(0x100000, bb.readUInt32(1)); - assertEquals(0x1000, bb.readUInt32(2)); - assertEquals(0x10, bb.readUInt32(3)); - assertEquals(0x0, bb.readUInt32(4)); - assertEquals(0x7F000000, bb.readUInt32(5)); - assertEquals(0x7F0000, bb.readUInt32(6)); - assertEquals(0x7F00, bb.readUInt32(7)); - assertEquals(0x7F, bb.readUInt32(8)); - assertEquals(0xFF000000L, bb.readUInt32(9)); - assertEquals(0xFF0000, bb.readUInt32(10)); - assertEquals(0xFF00, bb.readUInt32(11)); - assertEquals(0xFF, bb.readUInt32(12)); - } - - @Test - public void testReadInt32() throws Exception { - byte data[] = { 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, (byte)0xFF, 0x00, 0x00, 0x00 }; - UtilByteBuffer bb = new UtilByteBuffer(data); - assertEquals(0x10000000, bb.readInt32(0)); - assertEquals(0x100000, bb.readInt32(1)); - assertEquals(0x1000, bb.readInt32(2)); - assertEquals(0x10, bb.readInt32(3)); - - assertEquals(0x0, bb.readInt32(4)); - - assertEquals(0x7F000000, bb.readInt32(5)); - assertEquals(0x7F0000, bb.readInt32(6)); - assertEquals(0x7F00, bb.readInt32(7)); - assertEquals(0x7F, bb.readInt32(8)); - - assertEquals((int)0xFF000000, bb.readInt32(9)); - assertEquals(0xFF0000, bb.readInt32(10)); - assertEquals(0xFF00, bb.readInt32(11)); - assertEquals(0xFF, bb.readInt32(12)); - } - - @Test - public void testReadInt64() throws Exception { - byte data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - UtilByteBuffer bb = new UtilByteBuffer(data); - assertEquals(0x1000000000000000L, bb.readInt64(0)); - assertEquals(0x10000000000000L, bb.readInt64(1)); - assertEquals(0x100000000000L, bb.readInt64(2)); - assertEquals(0x1000000000L, bb.readInt64(3)); - assertEquals(0x10000000L, bb.readInt64(4)); - assertEquals(0x100000L, bb.readInt64(5)); - assertEquals(0x1000L, bb.readInt64(6)); - assertEquals(0x10L, bb.readInt64(7)); - - assertEquals(0x00L, bb.readInt64(8)); - - assertEquals(0x7F00000000000000L, bb.readInt64(9)); - assertEquals(0x7F000000000000L, bb.readInt64(10)); - assertEquals(0x7F0000000000L, bb.readInt64(11)); - assertEquals(0x7F00000000L, bb.readInt64(12)); - assertEquals(0x7F000000L, bb.readInt64(13)); - assertEquals(0x7F0000L, bb.readInt64(14)); - assertEquals(0x7F00L, bb.readInt64(15)); - assertEquals(0x7FL, bb.readInt64(16)); - - assertEquals(0xFF00000000000000L, bb.readInt64(17)); - assertEquals(0xFF000000000000L, bb.readInt64(18)); - assertEquals(0xFF0000000000L, bb.readInt64(19)); - assertEquals(0xFF00000000L, bb.readInt64(20)); - assertEquals(0xFF000000L, bb.readInt64(21)); - assertEquals(0xFF0000L, bb.readInt64(22)); - assertEquals(0xFF00L, bb.readInt64(23)); - assertEquals(0xFFL, bb.readInt64(24)); - } - - @Test - public void testReadString() throws Exception { - byte data[] = { 0x00, 0x41, 0x00, 0x41, 0x42, 0x00, 0x50, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x69, 0x74, (byte)0xC3, (byte)0xA9, 0x00, 0x41, 0x42 }; - UtilByteBuffer bb = new UtilByteBuffer(data); - - assertEquals("", bb.readString(0)); - assertEquals("A", bb.readString(1)); - assertEquals("", bb.readString(2)); - assertEquals("AB", bb.readString(3)); - assertEquals("Publicité", bb.readString(6)); - assertNull(bb.readString(17)); - - assertEquals("Public", bb.readString(6, 6, false)); - assertNull(bb.readString(6, 6, true)); - - assertEquals("AB", bb.readString(17, 2, false)); - assertNull(bb.readString(17, 2, true)); - } -} \ No newline at end of file diff --git a/getucrtinfo.bat b/getucrtinfo.bat deleted file mode 100644 index 35911fa..0000000 --- a/getucrtinfo.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -call "%VS140COMNTOOLS%vcvarsqueryregistry.bat" -echo %UniversalCRTSdkDir% -echo %UCRTVersion% diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 2743145..0000000 --- a/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -majorVersion=3 -minorVersion=7 -maintenanceVersion=0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 175c642..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index af80948..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sat Jun 06 16:31:05 BRT 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/msvc/ReHLDS.sln b/msvc/ReHLDS.sln index 6a01e76..961494f 100644 --- a/msvc/ReHLDS.sln +++ b/msvc/ReHLDS.sln @@ -7,21 +7,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReHLDS", "..\rehlds\msvc\Re ProjectSection(ProjectDependencies) = postProject {792DF067-9904-4579-99B9-46C17277ADE3} = {792DF067-9904-4579-99B9-46C17277ADE3} {CEB94F7C-E459-4673-AABB-36E2074396C0} = {CEB94F7C-E459-4673-AABB-36E2074396C0} + {6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppunitlite", "..\dep\cppunitlite\msvc\cppunitlite.vcxproj", "{CEB94F7C-E459-4673-AABB-36E2074396C0}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\dep\bzip2\msvc\bzip2.vcxproj", "{792DF067-9904-4579-99B9-46C17277ADE3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gradle", "gradle", "{FFC337A9-D58C-4D62-B8BB-A54DD4E4DF41}" - ProjectSection(SolutionItems) = preProject - ..\build.gradle = ..\build.gradle - ..\gradle.properties = ..\gradle.properties - ..\settings.gradle = ..\settings.gradle - ..\shared.gradle = ..\shared.gradle - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dedicated", "..\rehlds\dedicated\msvc\dedicated.vcxproj", "{D49883F3-5C5C-4B9F-B9C7-B31518F228D4}" + ProjectSection(ProjectDependencies) = postProject + {6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06} + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D2516ABB-21F2-4393-8CC9-2BD2D3316CD6}" ProjectSection(SolutionItems) = preProject @@ -29,6 +25,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Console", "..\rehlds\HLTV\Console\msvc\Console.vcxproj", "{D5CAB879-D54F-456F-8592-31D549CFD1D8}" + ProjectSection(ProjectDependencies) = postProject + {6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "..\rehlds\HLTV\Core\msvc\Core.vcxproj", "{52F752EA-73D1-422D-B805-17EF1FB20E09}" EndProject @@ -40,6 +39,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proxy", "..\rehlds\HLTV\Pro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filesystem_stdio", "..\rehlds\filesystem\FileSystem_Stdio\msvc\filesystem_stdio.vcxproj", "{A428392F-52FB-489E-87D8-623528C7F4F9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "version", "..\rehlds\version\msvc\version.vcxproj", "{6973DCA5-253C-4D84-B51E-187E035EAE06}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Play|Win32 = Debug Play|Win32 @@ -70,10 +71,10 @@ Global {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.Build.0 = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.ActiveCfg = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.Build.0 = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.Build.0 = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.ActiveCfg = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.Build.0 = Release|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.Build.0 = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.ActiveCfg = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.Build.0 = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug Play|Win32.ActiveCfg = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug Play|Win32.Build.0 = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -82,96 +83,83 @@ Global {792DF067-9904-4579-99B9-46C17277ADE3}.Release Play|Win32.Build.0 = Release|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Release|Win32.ActiveCfg = Release|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Release|Win32.Build.0 = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.Build.0 = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.ActiveCfg = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.Build.0 = Release|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.Build.0 = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.ActiveCfg = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug Play|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug|Win32.ActiveCfg = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release Play|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release Play|Win32.Build.0 = Release|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release|Win32.ActiveCfg = Release|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release|Win32.Build.0 = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.Build.0 = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.Build.0 = Release|Win32 + {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.ActiveCfg = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug Play|Win32.Build.0 = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug|Win32.ActiveCfg = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug|Win32.Build.0 = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release Play|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release Play|Win32.Build.0 = Release|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release|Win32.ActiveCfg = Release|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release|Win32.Build.0 = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.Build.0 = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.Build.0 = Release|Win32 + {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.ActiveCfg = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug Play|Win32.Build.0 = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug|Win32.ActiveCfg = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug|Win32.Build.0 = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release Play|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release Play|Win32.Build.0 = Release|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release|Win32.ActiveCfg = Release|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release|Win32.Build.0 = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.Build.0 = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.Build.0 = Release|Win32 + {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.ActiveCfg = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug Play|Win32.Build.0 = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug|Win32.ActiveCfg = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug|Win32.Build.0 = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release Play|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release Play|Win32.Build.0 = Release|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release|Win32.ActiveCfg = Release|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release|Win32.Build.0 = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.Build.0 = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.Build.0 = Release|Win32 + {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.ActiveCfg = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug Play|Win32.Build.0 = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug|Win32.ActiveCfg = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug|Win32.Build.0 = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release Play|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release Play|Win32.Build.0 = Release|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release|Win32.ActiveCfg = Release|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release|Win32.Build.0 = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.Build.0 = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.Build.0 = Release|Win32 + {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.ActiveCfg = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug Play|Win32.Build.0 = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug|Win32.ActiveCfg = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug|Win32.Build.0 = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release Play|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release Play|Win32.Build.0 = Release|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release|Win32.ActiveCfg = Release|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release|Win32.Build.0 = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.Build.0 = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.Build.0 = Release|Win32 + {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.ActiveCfg = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug Play|Win32.Build.0 = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug|Win32.ActiveCfg = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug|Win32.Build.0 = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release Play|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Release Play|Win32.Build.0 = Release|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release|Win32.ActiveCfg = Release|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release|Win32.Build.0 = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.Build.0 = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|Win32.Build.0 = Release|Win32 + {A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|Win32.ActiveCfg = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug Play|Win32.ActiveCfg = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug Play|Win32.Build.0 = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug|Win32.ActiveCfg = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug|Win32.Build.0 = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Release Play|Win32.ActiveCfg = Release|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Release Play|Win32.Build.0 = Release|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Release|Win32.ActiveCfg = Release|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Release|Win32.Build.0 = Release|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Test Fixes|Win32.Build.0 = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Tests|Win32.ActiveCfg = Debug|Win32 + {6973DCA5-253C-4D84-B51E-187E035EAE06}.Tests|Win32.Build.0 = Debug|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3225EDB9-2B71-42E4-99DB-ED6E6E2A2EC6} + EndGlobalSection EndGlobal diff --git a/publish.gradle b/publish.gradle deleted file mode 100644 index 995e92f..0000000 --- a/publish.gradle +++ /dev/null @@ -1,186 +0,0 @@ -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.apache.commons.io.FilenameUtils - -void _copyFileToDir(String from, String to) { - if (!project.file(from).exists()) { - println 'WARNING: Could not find: ' + from; - return; - } - - if (!project.file(to).exists()) { - project.file(to).mkdirs(); - } - - def dst = new File(project.file(to), FilenameUtils.getName(from)) - GradleCppUtils.copyFile(project.file(from), dst, false) -} - -void _copyFile(String from, String to) { - if (!project.file(from).exists()) { - println 'WARNING: Could not find: ' + from; - return; - } - - GradleCppUtils.copyFile(project.file(from), project.file(to), false) -} - -task publishPrepareFiles { - dependsOn ':flightrec/decoder:uberjar' - doLast { - def pubRootDir = project.file('publish/publishRoot') - if (pubRootDir.exists()) { - if (!pubRootDir.deleteDir()) { - throw new RuntimeException("Failed to delete ${pubRootDir}") - } - } - - pubRootDir.mkdirs() - project.file('publish/publishRoot/bin/win32/valve/dlls').mkdirs() - project.file('publish/publishRoot/bin/linux32/valve/dlls').mkdirs() - - // bugfixed binaries - _copyFile('publish/releaseRehldsFixes/swds.dll', 'publish/publishRoot/bin/win32/swds.dll') - _copyFile('publish/releaseRehldsFixes/engine_i486.so', 'publish/publishRoot/bin/linux32/engine_i486.so') - - // dedicated binaries - _copyFile('publish/hlds.exe', 'publish/publishRoot/bin/win32/hlds.exe') - _copyFile('publish/hlds_linux', 'publish/publishRoot/bin/linux32/hlds_linux') - - // HLTV binaries - _copyFile('publish/hltv.exe', 'publish/publishRoot/bin/win32/hltv.exe') - _copyFile('publish/hltv', 'publish/publishRoot/bin/linux32/hltv') - - _copyFile('publish/core.dll', 'publish/publishRoot/bin/win32/core.dll') - _copyFile('publish/core.so', 'publish/publishRoot/bin/linux32/core.so') - - _copyFile('publish/proxy.dll', 'publish/publishRoot/bin/win32/proxy.dll') - _copyFile('publish/proxy.so', 'publish/publishRoot/bin/linux32/proxy.so') - - _copyFile('publish/demoplayer.dll', 'publish/publishRoot/bin/win32/demoplayer.dll') - _copyFile('publish/demoplayer.so', 'publish/publishRoot/bin/linux32/demoplayer.so') - - _copyFile('publish/director.dll', 'publish/publishRoot/bin/win32/valve/dlls/director.dll') - _copyFile('publish/director.so', 'publish/publishRoot/bin/linux32/valve/dlls/director.so') - - // FileSystem binaries - _copyFile('publish/filesystem_stdio.dll', 'publish/publishRoot/bin/win32/filesystem_stdio.dll') - _copyFile('publish/filesystem_stdio.so', 'publish/publishRoot/bin/linux32/filesystem_stdio.so') - - // hlsdk - project.file('publish/publishRoot/hlsdk').mkdirs() - copy { - from 'rehlds/common' - into 'publish/publishRoot/hlsdk/common' - } - copy { - from 'rehlds/dlls' - into 'publish/publishRoot/hlsdk/dlls' - } - copy { - from 'rehlds/pm_shared' - into 'publish/publishRoot/hlsdk/pm_shared' - } - copy { - from 'rehlds/public' - into 'publish/publishRoot/hlsdk/public' - exclude '**/rehlds/*' - } - copy { - from 'rehlds/public/rehlds' - into 'publish/publishRoot/hlsdk/engine' - } - - // flightrecorder - def flightRecJarTask = project(':flightrec/decoder').tasks.getByName('uberjar') - println flightRecJarTask - println flightRecJarTask.class.name - File flightRecJarFile = flightRecJarTask.archivePath - project.file('publish/publishRoot/flighrec').mkdirs() - GradleCppUtils.copyFile(flightRecJarFile, project.file('publish/publishRoot/flighrec/decoder.jar'), false) - copy { - from new File(project(':flightrec/decoder').projectDir, 'pub') - into 'publish/publishRoot/flighrec' - } - } -} - -task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { - baseName = "rehlds-dist-${project.version}" - destinationDir file('publish') - from 'publish/publishRoot' -} - -publishing { - publications { - maven(MavenPublication) { - version project.version - artifact publishPackage - - pom.withXml { - asNode().children().last() + { - resolveStrategy = DELEGATE_FIRST - name project.name - description project.description - properties { - commitDate project.ext.rehldsVersionInfo.commitDate - commitSHA project.ext.rehldsVersionInfo.commitSHA - } - - //url github - //scm { - // url "${github}.git" - // connection "scm:git:${github}.git" - //} - /* - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - developers { - developer { - id 'dreamstalker' - name 'dreamstalker' - } - } - */ - } - } - } - } -} - -Properties repoCreds = new Properties() -project.ext.repoCreds = repoCreds -if (file('repo_creds.properties').exists()) { - println 'Loading maven repo credentials' - file('repo_creds.properties').withReader('UTF-8', { Reader r -> - repoCreds.load(r) - }) -} - -publishing { - repositories { - maven { - if (project.version.contains('dev')) { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" - } else { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" - } - credentials { - username repoCreds.getProperty('username') - password repoCreds.getProperty('password') - } - } - } -} - -task doPublish { - dependsOn 'publishPackage' - if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) { - dependsOn 'publish' - dependsOn ':flightrec/decoder_api:publish' - } -} diff --git a/rehlds/CMakeLists.txt b/rehlds/CMakeLists.txt new file mode 100644 index 0000000..a9b371b --- /dev/null +++ b/rehlds/CMakeLists.txt @@ -0,0 +1,302 @@ +#---------------------------------------- +# 1. Preparing build: +# rm -rf build +# mkdir build && cd build +# +# 2. Select compiler and build it +# - Compile with Clang: +# CC="clang" CXX="clang++" cmake .. +# make +# +# - Compile with Intel C++ Compiler: +# CC="icc" CXX="icpc" cmake .. +# make +# +# - Compile with GCC Compiler: +# cmake .. +# make +#---------------------------------------- + +cmake_minimum_required(VERSION 3.1) +project(engine CXX) + +option(DEBUG "Build with debug information." OFF) +option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -rdynamic -fPIC options +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-rtti -fno-exceptions") + +# Remove noxref code and data +set(COMPILE_FLAGS "${COMPILE_FLAGS} -ffunction-sections -fdata-sections") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + # -fp-model=precise + # ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations + # https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html#fp-model-fp_GUID-99936BBA-1508-4E9F-AC09-FA98613CE2F5 + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -fp-model=precise\ + -fasm-blocks\ + -Qoption,cpp,--treat_func_as_string_literal_cpp") + + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3\ + -fpermissive -fno-sized-deallocation\ + -Wno-unknown-pragmas -Wno-invalid-offsetof\ + -Wno-unused-variable -Wno-unused-result -Wno-unused-function -Wno-delete-non-virtual-dtor\ + -Wno-write-strings -Wno-format\ + -Wno-sign-compare -Wno-strict-aliasing -Wno-ignored-attributes") + + # Check if not Clang compiler + if (NOT "$ENV{CXX}" MATCHES "clang") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fno-plt -Wno-unused-but-set-variable") + + # GCC >= 8.3 + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation -Wno-class-memaccess") + endif() + endif() +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +if (NOT DEBUG) + set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}" + "${PROJECT_SOURCE_DIR}/engine" + "${PROJECT_SOURCE_DIR}/common" + "${PROJECT_SOURCE_DIR}/pm_shared" + "${PROJECT_SOURCE_DIR}/rehlds" + "${PROJECT_SOURCE_DIR}/testsuite" + "${PROJECT_SOURCE_DIR}/unittests" +) + +set(PROJECT_BZIP2_DIR + "${PROJECT_SOURCE_DIR}/../dep/bzip2/include" +) + +set(PROJECT_CPPUNITLITE_DIR + "${PROJECT_SOURCE_DIR}/../dep/cppunitlite/include" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/public" + "${PROJECT_SOURCE_DIR}/public/rehlds" +) + +set(ENGINE_SRCS + engine/sv_main.cpp + engine/sv_user.cpp + engine/sv_phys.cpp + engine/sv_move.cpp + engine/sv_pmove.cpp + engine/sv_log.cpp + engine/sv_remoteaccess.cpp + engine/sv_steam3.cpp + engine/sv_upld.cpp + engine/sys_dll.cpp + engine/sys_dll2.cpp + engine/sys_engine.cpp + engine/sys_linuxwind.cpp + engine/SystemWrapper.cpp + engine/host.cpp + engine/host_cmd.cpp + engine/net_chan.cpp + engine/net_ws.cpp + engine/pmove.cpp + engine/pmovetst.cpp + engine/pr_cmds.cpp + engine/pr_edict.cpp + engine/wad.cpp + engine/model.cpp + engine/world.cpp + engine/zone.cpp + engine/cmd.cpp + engine/cmodel.cpp + engine/com_custom.cpp + engine/common.cpp + engine/crc.cpp + engine/cvar.cpp + engine/decals.cpp + engine/delta.cpp + engine/delta_jit.cpp + engine/ed_strpool.cpp + engine/filesystem.cpp + engine/filesystem_internal.cpp + engine/hashpak.cpp + engine/info.cpp + engine/ipratelimit.cpp + engine/l_studio.cpp + engine/textures.cpp + engine/tmessage.cpp + engine/traceinit.cpp + engine/unicode_strtools.cpp + engine/buildnum.cpp + engine/mathlib.cpp + engine/mathlib_sse.cpp + engine/md5.cpp + engine/mem.cpp + engine/module.cpp + engine/r_studio.cpp + engine/vid_null.cpp + engine/cl_null.cpp + engine/snd_null.cpp + engine/sse_mathfun.cpp + engine/public_amalgamation.cpp + rehlds/flight_recorder.cpp + rehlds/FlightRecorderImpl.cpp + rehlds/hookchains_impl.cpp + rehlds/main.cpp + rehlds/platform.cpp + rehlds/public_amalgamation.cpp + rehlds/rehlds_api_impl.cpp + rehlds/rehlds_interfaces_impl.cpp + rehlds/rehlds_security.cpp +) + +set(UNITTESTS_SRCS + unittests/common_tests.cpp + unittests/crc32c_tests.cpp + unittests/delta_tests.cpp + unittests/info_tests.cpp + unittests/mathlib_tests.cpp + unittests/rehlds_tests_shared.cpp + unittests/rehlds_tests_shared.h + unittests/security_tests.cpp + unittests/struct_offsets_tests.cpp + unittests/TestRunner.cpp + unittests/tmessage_tests.cpp + unittests/unicode_tests.cpp +) + +set(COMMON_SRCS + "common/BaseSystemModule.cpp" + "common/ObjectList.cpp" + "common/TokenLine.cpp" +) + +set(PUBLIC_SRCS + "public/tier0/dbg.cpp" + "public/registry.cpp" + "public/steamid.cpp" + "public/utlbuffer.cpp" +) + +if (CMAKE_BUILD_TYPE MATCHES Unittests) + if (NOT TARGET cppunitlite) + add_subdirectory(../dep/cppunitlite cppunitlite) + endif() + + set(LINK_FLAGS "${LINK_FLAGS} -no-pie -Wl,--no-export-dynamic") + add_executable(engine ${appversion.sh} ${ENGINE_SRCS}) + target_link_libraries(engine PRIVATE cppunitlite) +else() + add_library(engine SHARED ${appversion.sh} ${ENGINE_SRCS}) +endif() + +if (NOT TARGET bzip2) + add_subdirectory(../dep/bzip2 bzip2) +endif() + +if (NOT TARGET appversion) + add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}/..") +endif() + +add_dependencies(engine appversion) + +target_include_directories(engine PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_BZIP2_DIR} + ${PROJECT_CPPUNITLITE_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(engine PRIVATE + SWDS + REHLDS_JIT + REHLDS_SSE + REHLDS_FIXES + REHLDS_CHECKS + REHLDS_API + REHLDS_SELF + REHLDS_OPT_PEDANTIC + HAVE_OPT_STRTOOLS + USE_BREAKPAD_HANDLER + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _unlink=unlink + _vsnprintf=vsnprintf + _vsnwprintf=vswprintf + + $<$: + REHLDS_UNIT_TESTS REHLDS_SSE REHLDS_JIT> +) + +target_sources(engine PRIVATE + ${COMMON_SRCS} + ${PUBLIC_SRCS} + + $<$: + ${UNITTESTS_SRCS}> +) + +target_link_libraries(engine PRIVATE + dl + rt + m + aelf32 + bzip2 + steam_api +) + +if (USE_STATIC_LIBSTDC) + target_compile_definitions(engine PRIVATE BUILD_STATIC_LIBSTDC) + set(LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++") +endif() + +set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-rpath,'$ORIGIN/.' \ + -L${PROJECT_SOURCE_DIR}/lib/linux32") + +set_target_properties(engine PROPERTIES + OUTPUT_NAME engine_i486 + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/CMakeLists.txt b/rehlds/HLTV/CMakeLists.txt new file mode 100644 index 0000000..abfaf71 --- /dev/null +++ b/rehlds/HLTV/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(HLTV CXX) + +add_subdirectory(Console) +add_subdirectory(Core) +add_subdirectory(Proxy) +add_subdirectory(DemoPlayer) +add_subdirectory(Director) diff --git a/rehlds/HLTV/Console/CMakeLists.txt b/rehlds/HLTV/Console/CMakeLists.txt new file mode 100644 index 0000000..fae3e05 --- /dev/null +++ b/rehlds/HLTV/Console/CMakeLists.txt @@ -0,0 +1,122 @@ +cmake_minimum_required(VERSION 3.1) +project(hltv CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -rdynamic -fPIC options +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +set(LINK_FLAGS "${LINK_FLAGS} -no-pie -Wl,--no-export-dynamic") + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${COMPILE_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3 -flto\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result -Wno-unknown-pragmas -Wno-write-strings") + + # Check if not Clang compiler AND GCC >= 8.3 + if (NOT "$ENV{CXX}" MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation") + endif() +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../.." + "${PROJECT_SOURCE_DIR}/../../engine" + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(HLTV_SRCS + "src/System.cpp" + "src/public_amalgamation.cpp" +) + +set(COMMON_SRCS + "../../common/BaseSystemModule.cpp" + "../../common/TokenLine.cpp" + "../../common/ObjectList.cpp" + "../../common/textconsole.cpp" + "../../common/TextConsoleUnix.cpp" + "../../common/minidump.cpp" + "../../HLTV/common/random.cpp" + "../../HLTV/common/common.cpp" + "../../engine/mem.cpp" +) + +if (NOT TARGET appversion) + add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/../../version/appversion.sh" "${PROJECT_SOURCE_DIR}/../../..") +endif() + +add_executable(hltv ${appversion.sh} ${HLTV_SRCS}) +add_dependencies(hltv appversion) + +target_include_directories(hltv PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(hltv PRIVATE + LAUNCHER_FIXES + _CONSOLE + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(hltv PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(hltv PRIVATE + dl +) + +set_target_properties(hltv PROPERTIES + OUTPUT_NAME hltv + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/Console/build.gradle b/rehlds/HLTV/Console/build.gradle deleted file mode 100644 index 7d07df5..0000000 --- a/rehlds/HLTV/Console/build.gradle +++ /dev/null @@ -1,173 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeExecutableSpec -import org.gradle.nativeplatform.NativeExecutableBinarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: 'windows-resources' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -List getRcCompileTasks(NativeBinarySpec binary) -{ - def linkTask = GradleCppUtils.getLinkTask(binary) - def res = linkTask.taskDependencies.getDependencies(linkTask).findAll { Task t -> t instanceof WindowsResourceCompile } - return res as List -} - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds'); - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'LAUNCHER_FIXES', '_CONSOLE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'hltv_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS'); - - cfg.linkerOptions.args('/SUBSYSTEM:WINDOWS,5.01'); - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF', '/GR-' - cfg.extraLibs "user32.lib" - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'hltv_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.linkerOptions.args '-no-pie' - cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions' - cfg.extraLibs 'dl' - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - hltv(NativeExecutableSpec) { - targetPlatform 'x86' - baseName 'hltv' - - sources { - hltv_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - } - hltv_common(CppSourceSet) { - source { - srcDirs "../../common", "../common" - - // common - include "BaseSystemModule.cpp" - include "ObjectList.cpp" - include "TokenLine.cpp" - include "textconsole.cpp" - include "minidump.cpp" - if (GradleCppUtils.windows) { - include "TextConsoleWin32.cpp" - } - else { - include "TextConsoleUnix.cpp" - } - - // HLTV common - include "random.cpp" - include "common.cpp" - } - } - hltv_engine(CppSourceSet) { - source { - srcDir "../../engine" - include "mem.cpp" - } - } - hltv_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - } - } - - rc { - source { - srcDir "msvc" - include "hltv.rc" - } - exportedHeaders { - srcDirs "msvc" - } - } - } - - binaries.all { - NativeExecutableBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFixes { - dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} diff --git a/rehlds/HLTV/Console/msvc/Console.vcxproj b/rehlds/HLTV/Console/msvc/Console.vcxproj index cdeb0e3..ec6f883 100644 --- a/rehlds/HLTV/Console/msvc/Console.vcxproj +++ b/rehlds/HLTV/Console/msvc/Console.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -34,62 +30,50 @@ Use Use - Use Use Use - Use Use Use - Use Use Use - Use Use Use - Use Use Use - Use Use - Use Use Use - Use Use Use Use - Use Create - Create Create Use - Use Use Use - Use Use @@ -99,6 +83,11 @@ + + + {6973dca5-253c-4d84-b51e-187e035eae06} + + {D5CAB879-D54F-456F-8592-31D549CFD1D8} Win32Proj @@ -125,16 +114,6 @@ true MultiByte - - Application - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -146,9 +125,6 @@ - - - true @@ -158,10 +134,6 @@ false hltv - - false - hltv - Use @@ -223,39 +195,7 @@ build.always.run - - - Level3 - Use - Disabled - true - true - HLTV;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)\..\src;$(ProjectDir)\..\..\;$(ProjectDir)\..\..\..\;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;%(AdditionalIncludeDirectories) - precompiled.h - MultiThreaded - - - Windows - true - true - true - user32.lib;%(AdditionalDependencies) - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - - + \ No newline at end of file diff --git a/rehlds/HLTV/Console/src/System.cpp b/rehlds/HLTV/Console/src/System.cpp index 54db254..9aa184a 100644 --- a/rehlds/HLTV/Console/src/System.cpp +++ b/rehlds/HLTV/Console/src/System.cpp @@ -48,7 +48,7 @@ char *System::GetBaseDir() return COM_GetBaseDir(); } -void Sys_Printf(char *fmt, ...) +void Sys_Printf(const char *fmt, ...) { // Dump text to debugging console. va_list argptr; @@ -151,49 +151,57 @@ bool System::RegisterCommand(char *name, ISystemModule *module, int commandID) return true; } -void System::ExecuteString(char *commands) +void System::ExecuteString(const char *commands) { if (!commands || !commands[0]) return; - int size = 0; - char singleCmd[256] = ""; - bool quotes = false; - char *p = singleCmd; - char *c = commands; + // Remove format characters to block format string attacks + COM_RemoveEvilChars(const_cast(commands)); - COM_RemoveEvilChars(c); - while (true) + bool bInQuote = false; + + char *pszDest; + char singleCmd[256] = {0}; + + const char *pszSource = commands; + while (*pszSource) { - *p = *c; + // Parse out single commands and execute them + pszDest = singleCmd; - if (++size >= sizeof(singleCmd)) + unsigned int i; + for (i = 0; i < ARRAYSIZE(singleCmd); i++) { - DPrintf("WARNING! System::ExecuteString: Command token too long.\n"); - break; + const char c = *pszSource; + + if (c == '"') + { + bInQuote = !bInQuote; + } + else if ((c == ';' && !bInQuote) || !c) + { + // End of command and not in a quoted string + break; + } + + *pszDest++ = c; + pszSource++; } - if (*c == '"') - quotes = !quotes; - - if ((*c != ';' || quotes) && *c) + if (i >= ARRAYSIZE(singleCmd)) { - ++p; - } - else - { - *p = '\0'; - - char *cmd = singleCmd; - while (*cmd == ' ') { cmd++; } - - DispatchCommand(cmd); - p = singleCmd; - size = 0; + Printf("WARNING! System::ExecuteString: Command token too long.\n"); + return; } - if (!*c++) - break; + *pszDest = '\0'; + + char *pszCmd = singleCmd; + while (*pszCmd == ' ') + pszCmd++; // skip leading whitespaces + + DispatchCommand(pszCmd); } } @@ -226,7 +234,7 @@ ISystemModule *System::FindModule(char *type, char *name) while (module) { if (Q_stricmp(type, module->GetType()) == 0 - && (!name || Q_stricmp(name, module->GetType()) == 0)) { + && (!name || Q_stricmp(name, module->GetName()) == 0)) { return module; } @@ -887,7 +895,7 @@ void System::UpdateTime() m_SystemTime = m_Counter.GetCurTime(); } -char *System::GetInput() +const char *System::GetInput() { return m_Console.GetLine(); } diff --git a/rehlds/HLTV/Console/src/System.h b/rehlds/HLTV/Console/src/System.h index 7d3c560..01ab9e3 100644 --- a/rehlds/HLTV/Console/src/System.h +++ b/rehlds/HLTV/Console/src/System.h @@ -57,7 +57,7 @@ public: Panel *GetPanel(); bool RegisterCommand(char *name, ISystemModule *module, int commandID); void GetCommandMatches(char *string, ObjectList *pMatchList); - void ExecuteString(char *commands); + void ExecuteString(const char *commands); void ExecuteFile(char *filename); void Errorf(char *fmt, ...); char *CheckParam(char *param); @@ -102,7 +102,7 @@ protected: bool DispatchCommand(char *command); void ExecuteCommandLine(); void UpdateTime(); - char *GetInput(); + const char *GetInput(); bool StartVGUI(); void StopVGUI(); void SetName(char *newName); @@ -183,4 +183,4 @@ private: extern System gSystem; -void Sys_Printf(char *fmt, ...); +void Sys_Printf(const char *fmt, ...); diff --git a/rehlds/HLTV/Console/src/public_amalgamation.cpp b/rehlds/HLTV/Console/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/HLTV/Console/src/public_amalgamation.cpp +++ b/rehlds/HLTV/Console/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/HLTV/Core/CMakeLists.txt b/rehlds/HLTV/Core/CMakeLists.txt new file mode 100644 index 0000000..94c45e1 --- /dev/null +++ b/rehlds/HLTV/Core/CMakeLists.txt @@ -0,0 +1,145 @@ +cmake_minimum_required(VERSION 3.1) +project(core CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} -mtune=generic -msse3 -flto\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\ + -Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing") + + # Check Clang compiler + if ("$ENV{CXX}" MATCHES "clang") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-unused-private-field") + else() + # GCC >= 8.3 + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation") + endif() + endif() +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" +) + +set(PROJECT_BZIP2_DIR + "${PROJECT_SOURCE_DIR}/../../../dep/bzip2/include" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../.." + "${PROJECT_SOURCE_DIR}/../../engine" + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../pm_shared" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(CORE_SRCS + "src/BSPModel.cpp" + "src/Delta.cpp" + "src/NetSocket.cpp" + "src/Network.cpp" + "src/Server.cpp" + "src/World.cpp" + "src/public_amalgamation.cpp" +) + +set(COMMON_SRCS + "../../common/BaseSystemModule.cpp" + "../../common/ObjectDictionary.cpp" + "../../common/ObjectList.cpp" + "../../common/TokenLine.cpp" + "../../HLTV/common/BitBuffer.cpp" + "../../HLTV/common/byteorder.cpp" + "../../HLTV/common/common.cpp" + "../../HLTV/common/DemoFile.cpp" + "../../HLTV/common/DirectorCmd.cpp" + "../../HLTV/common/InfoString.cpp" + "../../HLTV/common/mathlib.cpp" + "../../HLTV/common/md5.cpp" + "../../HLTV/common/munge.cpp" + "../../HLTV/common/NetAddress.cpp" + "../../HLTV/common/NetChannel.cpp" + "../../HLTV/common/random.cpp" + "../../engine/mem.cpp" +) + +add_library(core SHARED ${CORE_SRCS}) + +target_include_directories(core PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_BZIP2_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(core PRIVATE + HLTV + HLTV_FIXES + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(core PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(core PRIVATE + dl + m + bzip2 +) + +if (NOT TARGET bzip2) + add_subdirectory(../../../dep/bzip2 lib) +endif() + +set_target_properties(core PROPERTIES + OUTPUT_NAME core + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/Core/build.gradle b/rehlds/HLTV/Core/build.gradle deleted file mode 100644 index 0f3c129..0000000 --- a/rehlds/HLTV/Core/build.gradle +++ /dev/null @@ -1,186 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -project.ext.dep_bzip2 = project(':dep/bzip2') - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared'); - cfg.projectInclude(dep_bzip2, '/include') - - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'HLTV_FIXES', 'CORE_MODULE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'core_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF' - cfg.extraLibs "ws2_32.lib", "psapi.lib" - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'core_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.compilerOptions.args '-fno-exceptions' - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - core(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'core' - - sources { - core_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - - lib project: ':dep/bzip2', library: 'bzip2', linkage: 'static' - } - - core_common(CppSourceSet) { - source { - srcDirs "../../common", "../common" - - // common - include "BaseSystemModule.cpp" - include "ObjectDictionary.cpp" - include "ObjectList.cpp" - include "TokenLine.cpp" - - // HLTV common - include "BitBuffer.cpp" - include "byteorder.cpp" - include "common.cpp" - include "DemoFile.cpp" - include "DirectorCmd.cpp" - include "InfoString.cpp" - include "mathlib.cpp" - include "md5.cpp" - include "munge.cpp" - include "NetAddress.cpp" - include "NetChannel.cpp" - include "random.cpp" - } - } - - core_engine(CppSourceSet) { - source { - srcDir "../../engine" - include "mem.cpp" - } - } - - core_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - - lib project: ':dep/bzip2', library: 'bzip2', linkage: 'static' - } - } - } - - binaries.all { - NativeBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -build.finalizedBy(buildFinalize); -buildFixes.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -// prevent static lib building -binaries.withType(StaticLibraryBinarySpec) { binary -> - buildable = false -} diff --git a/rehlds/HLTV/Core/msvc/Core.vcxproj b/rehlds/HLTV/Core/msvc/Core.vcxproj index 21d4a79..b40addc 100644 --- a/rehlds/HLTV/Core/msvc/Core.vcxproj +++ b/rehlds/HLTV/Core/msvc/Core.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -39,16 +35,6 @@ true MultiByte - - DynamicLibrary - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -60,9 +46,6 @@ - - - true @@ -71,9 +54,6 @@ false - - false - Use @@ -142,62 +122,12 @@ build.always.run - - - Level3 - Use - MaxSpeed - true - true - HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;CORE_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - $(ProjectDir)\..\src;$(ProjectDir)\..\..\;$(ProjectDir)\..\..\..\;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;$(ProjectDir)\..\..\..\pm_shared;$(ProjectDir)\..\..\..\..\dep\bzip2\include;%(AdditionalIncludeDirectories) - precompiled.h - MultiThreaded - true - - - Windows - true - true - true - psapi.lib;ws2_32.lib;%(AdditionalDependencies) - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - - - true - true - true - - - true - true - true - - - true - true - true - @@ -214,58 +144,44 @@ Use precompiled.h Use - Use precompiled.h - precompiled.h Use precompiled.h Use - Use precompiled.h - precompiled.h Use precompiled.h Use - Use precompiled.h - precompiled.h Use precompiled.h Use - Use precompiled.h - precompiled.h Create precompiled.h Create - Create precompiled.h - precompiled.h Use precompiled.h Use - Use precompiled.h - precompiled.h Use precompiled.h Use - Use precompiled.h - precompiled.h @@ -274,16 +190,6 @@ - - true - true - true - - - true - true - true - diff --git a/rehlds/HLTV/Core/msvc/Core.vcxproj.filters b/rehlds/HLTV/Core/msvc/Core.vcxproj.filters index 1a7689c..13f76ef 100644 --- a/rehlds/HLTV/Core/msvc/Core.vcxproj.filters +++ b/rehlds/HLTV/Core/msvc/Core.vcxproj.filters @@ -10,9 +10,6 @@ {664fe3c6-46ae-4fa5-bf0c-f70873228f5e} - - {fb482bcd-a131-4e66-be87-c7b0ffe6a4cf} - {0997bc0d-a67f-47eb-abc1-3c7ebb128beb} @@ -78,12 +75,6 @@ src - - src\hookers - - - src\hookers - common @@ -99,9 +90,6 @@ HLTV\common - - src\hookers - engine @@ -164,9 +152,6 @@ src - - src\hookers - common @@ -182,9 +167,6 @@ HLTV\common - - src\hookers - engine diff --git a/rehlds/HLTV/Core/src/BSPModel.cpp b/rehlds/HLTV/Core/src/BSPModel.cpp index 72ff7a2..15f091d 100644 --- a/rehlds/HLTV/Core/src/BSPModel.cpp +++ b/rehlds/HLTV/Core/src/BSPModel.cpp @@ -724,7 +724,12 @@ bool BSPModel::LoadFromBuffer(unsigned int *buffer, int length, const char *name header = (dheader_t *)buffer; i = _LittleLong(header->version); - if (i != HLBSP_VERSION) { + if ( +#ifdef HLTV_FIXES + i != Q1BSP_VERSION && +#endif + i != HLBSP_VERSION) + { m_System->Errorf("BSPModel::LoadFromBuffer: %s has wrong version number (%i should be %i)\n", m_model.name, i, HLBSP_VERSION); } diff --git a/rehlds/HLTV/Core/src/Delta.cpp b/rehlds/HLTV/Core/src/Delta.cpp index a1e5d75..fc66263 100644 --- a/rehlds/HLTV/Core/src/Delta.cpp +++ b/rehlds/HLTV/Core/src/Delta.cpp @@ -28,8 +28,6 @@ #include "precompiled.h" -#ifndef HOOK_HLTV - delta_t *Delta::m_EntityDelta = nullptr; delta_t *Delta::m_PlayerDelta = nullptr; delta_t *Delta::m_ClientDelta = nullptr; @@ -42,13 +40,13 @@ delta_t *Delta::m_CustomentityDelta = nullptr; delta_description_t Delta::m_MetaDescription[] = { - { DT_INTEGER, DELTA_D_DEF(fieldType), 1, 32, 1.0, 1.0, 0, 0, 0 }, - { DT_STRING, DELTA_D_DEF(fieldName), 1, 1, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldOffset), 1, 16, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldSize), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(significant_bits), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(premultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(postmultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 }, + { DT_INTEGER, DELTA_D_DEF(fieldType), 1, 32, 1.0, 1.0, 0, {0, 0} }, + { DT_STRING, DELTA_D_DEF(fieldName), 1, 1, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(fieldOffset), 1, 16, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(fieldSize), 1, 8, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(significant_bits), 1, 8, 1.0, 1.0, 0, {0, 0} }, + { DT_FLOAT, DELTA_D_DEF(premultiply), 1, 32, 4000.0, 1.0, 0, {0, 0} }, + { DT_FLOAT, DELTA_D_DEF(postmultiply), 1, 32, 4000.0, 1.0, 0, {0, 0} }, }; delta_t Delta::m_MetaDelta[] = @@ -453,7 +451,7 @@ void Delta::MarkSendFields(unsigned char *from, unsigned char *to, delta_t *pFie st2 = (char *)&to[pTest->fieldOffset]; // Not sure why it is case insensitive, but it looks so - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) { + if (!((!*st1 && !*st2) || (*st1 && *st2 && !Q_stricmp(st1, st2)))) { pTest->flags |= FDT_MARK; } break; @@ -972,7 +970,7 @@ int Delta::TestDelta(unsigned char *from, unsigned char *to, delta_t *pFields) st2 = (char *)&to[pTest->fieldOffset]; // Not sure why it is case insensitive, but it looks so - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) + if (!((!*st1 && !*st2) || (*st1 && *st2 && !Q_stricmp(st1, st2)))) { different = true; length = Q_strlen(st2) * 8; @@ -1510,5 +1508,3 @@ void Delta::SetLargeTimeBufferSize(bool bigBuffers) { m_LargeTime_Buffers = bigBuffers; } - -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/Delta.h b/rehlds/HLTV/Core/src/Delta.h index 17a540a..56fb3e4 100644 --- a/rehlds/HLTV/Core/src/Delta.h +++ b/rehlds/HLTV/Core/src/Delta.h @@ -95,10 +95,6 @@ typedef struct delta_s delta_description_t *pdd; } delta_t; -#include "hookers/HLTV/Core/DeltaEx.h" - -#ifndef HOOK_HLTV - class Delta { public: void Init(IBaseSystem *system); @@ -204,5 +200,3 @@ private: double m_Time; bool m_LargeTime_Buffers; }; - -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/Network.cpp b/rehlds/HLTV/Core/src/Network.cpp index cf087d1..d089d2e 100644 --- a/rehlds/HLTV/Core/src/Network.cpp +++ b/rehlds/HLTV/Core/src/Network.cpp @@ -449,6 +449,4 @@ IBaseInterface *CreateNetwork() return (IBaseInterface *)pNetwork; } -#ifndef HOOK_HLTV EXPOSE_INTERFACE_FN(CreateNetwork, Network, NETWORK_INTERFACE_VERSION); -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/Server.cpp b/rehlds/HLTV/Core/src/Server.cpp index 05c0cf1..a2dc5d1 100644 --- a/rehlds/HLTV/Core/src/Server.cpp +++ b/rehlds/HLTV/Core/src/Server.cpp @@ -2411,6 +2411,4 @@ IBaseInterface *CreateServer() return (IBaseInterface *)pServer; } -#ifndef HOOK_HLTV EXPOSE_INTERFACE_FN(CreateServer, Server, SERVER_INTERFACE_VERSION); -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/World.cpp b/rehlds/HLTV/Core/src/World.cpp index 8fb764f..b355420 100644 --- a/rehlds/HLTV/Core/src/World.cpp +++ b/rehlds/HLTV/Core/src/World.cpp @@ -1208,11 +1208,12 @@ void World::ClearEntityCache() { if (m_DeltaCache) { - for (int i = 0; i < m_MaxCacheIndex; i++) { + for (int i = 0; i < m_MaxCacheIndex; i++) + { + m_DeltaCache[i].seqNr = 0; + m_DeltaCache[i].deltaNr = 0; m_DeltaCache[i].buffer.Free(); } - - Q_memset(m_DeltaCache, 0, sizeof(deltaCache_t) * m_MaxCacheIndex); } if (m_FrameCache) { @@ -2337,7 +2338,6 @@ IBaseInterface *CreateWorld() return (IBaseInterface *)pWorld; } -#ifndef HOOK_HLTV bool World::IsDeltaEncoder() const { if (Delta::m_CustomentityDelta @@ -2378,4 +2378,3 @@ delta_t *World::GetWeaponDelta() const { } EXPOSE_INTERFACE_FN(CreateWorld, World, WORLD_INTERFACE_VERSION); -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/World.h b/rehlds/HLTV/Core/src/World.h index 09e98dd..b84b99a 100644 --- a/rehlds/HLTV/Core/src/World.h +++ b/rehlds/HLTV/Core/src/World.h @@ -252,7 +252,7 @@ protected: int m_MaxInstanced_BaseLine; -#if defined(HLTV_FIXES) && !defined(HOOK_HLTV) +#if defined(HLTV_FIXES) char m_Lightstyles[MAX_LIGHTSTYLES][64]; #else char m_Lightstyles[MAX_LIGHTSTYLES][65]; @@ -303,13 +303,7 @@ protected: char m_HostName[255]; NetAddress m_GameServerAddress; - -#ifdef HOOK_HLTV - static DeltaWrapper m_Delta; -#else Delta m_Delta; -#endif // HOOK_HLTV - }; extern char g_DownloadURL[128]; diff --git a/rehlds/HLTV/Core/src/precompiled.h b/rehlds/HLTV/Core/src/precompiled.h index c331350..6c5c428 100644 --- a/rehlds/HLTV/Core/src/precompiled.h +++ b/rehlds/HLTV/Core/src/precompiled.h @@ -10,9 +10,6 @@ #include "mem.h" #include "common.h" -// Hooks stuff -#include "hookers/HLTV/Core/hooklist.h" - #include "common/md5.h" #include "common/random.h" #include "common/byteorder.h" diff --git a/rehlds/HLTV/Core/src/public_amalgamation.cpp b/rehlds/HLTV/Core/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/HLTV/Core/src/public_amalgamation.cpp +++ b/rehlds/HLTV/Core/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/HLTV/DemoPlayer/CMakeLists.txt b/rehlds/HLTV/DemoPlayer/CMakeLists.txt new file mode 100644 index 0000000..27feb5e --- /dev/null +++ b/rehlds/HLTV/DemoPlayer/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.1) +project(demoplayer CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3 -flto\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result -Wno-unknown-pragmas\ + -Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing") +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../.." + "${PROJECT_SOURCE_DIR}/../../engine" + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../pm_shared" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(DEMOPLAYER_SRCS + "src/DemoPlayer.cpp" + "src/public_amalgamation.cpp" +) + +set(COMMON_SRCS + "../../common/BaseSystemModule.cpp" + "../../common/ObjectDictionary.cpp" + "../../common/ObjectList.cpp" + "../../common/TokenLine.cpp" + "../../HLTV/common/BitBuffer.cpp" + "../../HLTV/common/byteorder.cpp" + "../../HLTV/common/common.cpp" + "../../HLTV/common/DirectorCmd.cpp" + "../../HLTV/common/mathlib.cpp" + "../../engine/mem.cpp" +) + +add_library(demoplayer SHARED ${DEMOPLAYER_SRCS}) + +target_include_directories(demoplayer PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(demoplayer PRIVATE + HLTV + HLTV_FIXES + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(demoplayer PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(demoplayer PRIVATE + dl + m +) + +set_target_properties(demoplayer PROPERTIES + OUTPUT_NAME demoplayer + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/DemoPlayer/build.gradle b/rehlds/HLTV/DemoPlayer/build.gradle deleted file mode 100644 index 65629d2..0000000 --- a/rehlds/HLTV/DemoPlayer/build.gradle +++ /dev/null @@ -1,171 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/..', '/../..', '/src', '/../common', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared'); - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'HLTV_FIXES', 'DEMOPLAYER_MODULE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'demoplayer_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF' - cfg.extraLibs "psapi.lib" - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'demoplayer_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.compilerOptions.args '-fno-exceptions' - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - demoplayer(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'demoplayer' - - sources { - demoplayer_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - } - - demoplayer_common(CppSourceSet) { - source { - srcDirs "/../../common", "/../common" - - // common - include "BaseSystemModule.cpp" - include "ObjectDictionary.cpp" - include "ObjectList.cpp" - include "TokenLine.cpp" - - // HLTV common - include "BitBuffer.cpp" - include "byteorder.cpp" - include "common.cpp" - include "DirectorCmd.cpp" - include "mathlib.cpp" - } - } - - demoplayer_engine(CppSourceSet) { - source { - srcDir "../../engine" - include "mem.cpp" - } - } - - demoplayer_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - } - } - } - - binaries.all { - NativeBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -build.finalizedBy(buildFinalize); -buildFixes.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -// prevent static lib building -binaries.withType(StaticLibraryBinarySpec) { binary -> - buildable = false -} diff --git a/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj b/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj index 515fd01..118d3c2 100644 --- a/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj +++ b/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -20,16 +16,6 @@ - - true - true - true - - - true - true - true - @@ -39,7 +25,6 @@ Create Create - Create @@ -49,11 +34,6 @@ - - true - true - true - @@ -88,16 +68,6 @@ true MultiByte - - DynamicLibrary - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -109,9 +79,6 @@ - - - true @@ -119,9 +86,6 @@ false - - false - Use @@ -184,40 +148,6 @@ build.always.run - - - Level3 - Use - MaxSpeed - true - true - HOOK_HLTV;HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;DEMOPLAYER_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitiHOOons) - precompiled.h - $(ProjectDir)\..\src;$(ProjectDir)\..\..\;$(ProjectDir)\..\..\..\;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;$(ProjectDir)\..\..\..\pm_shared;%(AdditionalIncludeDirectories) - MultiThreaded - true - - - Windows - true - true - true - psapi.lib;%(AdditionalDependencies) - false - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - diff --git a/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj.filters b/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj.filters index 9d7f4cd..267f18a 100644 --- a/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj.filters +++ b/rehlds/HLTV/DemoPlayer/msvc/DemoPlayer.vcxproj.filters @@ -10,9 +10,6 @@ {ca1c7722-8e65-480d-9e3c-34f7f2524372} - - {1f62aa80-c3f7-4f97-a93e-5b67b153a751} - {8712d29d-6fec-42fb-9f6e-5618302f3203} @@ -45,12 +42,6 @@ HLTV\common - - src\hookers - - - src\hookers - common @@ -89,9 +80,6 @@ HLTV\common - - src\hookers - common diff --git a/rehlds/HLTV/DemoPlayer/src/DemoPlayer.h b/rehlds/HLTV/DemoPlayer/src/DemoPlayer.h index c1eea62..1c41706 100644 --- a/rehlds/HLTV/DemoPlayer/src/DemoPlayer.h +++ b/rehlds/HLTV/DemoPlayer/src/DemoPlayer.h @@ -172,7 +172,6 @@ private: unsigned int m_Outgoing_sequence; }; -#ifndef HOOK_HLTV // Use this to expose a singleton interface. This creates the global variable for you automatically. #define EXPOSE_SINGLE_INTERFACE2(className, interfaceName, versionName) \ static className __g_##className##_singleton;\ @@ -180,4 +179,3 @@ private: static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); EXPOSE_SINGLE_INTERFACE2(DemoPlayer, IDemoPlayer, DEMOPLAYER_INTERFACE_VERSION); -#endif // HOOK_HLTV diff --git a/rehlds/HLTV/DemoPlayer/src/precompiled.h b/rehlds/HLTV/DemoPlayer/src/precompiled.h index 440fa0e..b2203a8 100644 --- a/rehlds/HLTV/DemoPlayer/src/precompiled.h +++ b/rehlds/HLTV/DemoPlayer/src/precompiled.h @@ -18,6 +18,3 @@ #include "common/DemoFile.h" #include "DemoPlayer.h" - -// Hooks stuff -#include "hookers/HLTV/DemoPlayer/hooklist.h" diff --git a/rehlds/HLTV/DemoPlayer/src/public_amalgamation.cpp b/rehlds/HLTV/DemoPlayer/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/HLTV/DemoPlayer/src/public_amalgamation.cpp +++ b/rehlds/HLTV/DemoPlayer/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/HLTV/Director/CMakeLists.txt b/rehlds/HLTV/Director/CMakeLists.txt new file mode 100644 index 0000000..7f88945 --- /dev/null +++ b/rehlds/HLTV/Director/CMakeLists.txt @@ -0,0 +1,120 @@ +cmake_minimum_required(VERSION 3.1) +project(director CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3 -flto\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result -Wno-unknown-pragmas\ + -Wno-write-strings -Wno-strict-aliasing") +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../.." + "${PROJECT_SOURCE_DIR}/../../engine" + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../pm_shared" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(DIRECTOR_SRCS + "src/Director.cpp" + "src/public_amalgamation.cpp" +) + +set(COMMON_SRCS + "../../common/BaseSystemModule.cpp" + "../../common/ObjectDictionary.cpp" + "../../common/ObjectList.cpp" + "../../common/TokenLine.cpp" + "../../HLTV/common/BitBuffer.cpp" + "../../HLTV/common/byteorder.cpp" + "../../HLTV/common/common.cpp" + "../../HLTV/common/DirectorCmd.cpp" + "../../HLTV/common/mathlib.cpp" + "../../HLTV/common/random.cpp" + "../../engine/mem.cpp" +) + +add_library(director SHARED ${DIRECTOR_SRCS}) + +target_include_directories(director PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(director PRIVATE + HLTV + HLTV_FIXES + DIRECTOR_MODULE + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(director PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(director PRIVATE + dl + m +) + +set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-rpath,'$ORIGIN/.' \ + -L${PROJECT_SOURCE_DIR}/../../lib/linux32") + +set_target_properties(director PROPERTIES + OUTPUT_NAME director + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/Director/build.gradle b/rehlds/HLTV/Director/build.gradle deleted file mode 100644 index 213fbbd..0000000 --- a/rehlds/HLTV/Director/build.gradle +++ /dev/null @@ -1,171 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared'); - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'HLTV_FIXES', 'DIRECTOR_MODULE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'director_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF' - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'director_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++0x' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.compilerOptions.args '-fno-exceptions' - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - director(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'director' - - sources { - director_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - } - - director_common(CppSourceSet) { - source { - srcDirs "../../common", "../common" - - // common - include "BaseSystemModule.cpp" - include "ObjectDictionary.cpp" - include "ObjectList.cpp" - include "TokenLine.cpp" - - // HLTV common - include "BitBuffer.cpp" - include "byteorder.cpp" - include "common.cpp" - include "DirectorCmd.cpp" - include "mathlib.cpp" - include "random.cpp" - } - } - - director_engine(CppSourceSet) { - source { - srcDir "../../engine" - include "mem.cpp" - } - } - - director_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - } - } - } - - binaries.all { - NativeBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -build.finalizedBy(buildFinalize); -buildFixes.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -// prevent static lib building -binaries.withType(StaticLibraryBinarySpec) { binary -> - buildable = false -} diff --git a/rehlds/HLTV/Director/msvc/Director.vcxproj b/rehlds/HLTV/Director/msvc/Director.vcxproj index 76cf66d..3f8a675 100644 --- a/rehlds/HLTV/Director/msvc/Director.vcxproj +++ b/rehlds/HLTV/Director/msvc/Director.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -39,16 +35,6 @@ true MultiByte - - DynamicLibrary - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -60,9 +46,6 @@ - - - true @@ -70,9 +53,6 @@ false - - false - Use @@ -135,39 +115,6 @@ Automatic deployment script - - - Level3 - Use - MaxSpeed - true - true - HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;DIRECTOR_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)\..\..\;$(ProjectDir)\..\src;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;$(ProjectDir)\..\..\..\pm_shared;%(AdditionalIncludeDirectories) - precompiled.h - MultiThreaded - true - - - Windows - true - true - true - %(AdditionalDependencies) - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - @@ -184,7 +131,6 @@ Create Create - Create diff --git a/rehlds/HLTV/Director/src/Director.cpp b/rehlds/HLTV/Director/src/Director.cpp index eae4092..2787de3 100644 --- a/rehlds/HLTV/Director/src/Director.cpp +++ b/rehlds/HLTV/Director/src/Director.cpp @@ -49,7 +49,7 @@ bool Director::Init(IBaseSystem *system, int serial, char *name) m_slowMotion = 0.5f; for (int i = 0; i < MAX_WORLD_HISTORY; i++) { - m_gaussFilter[i] = 1.0f / exp((i * i) / 10000.0f); + m_gaussFilter[i] = 1.0f / expf((i * i) / 10000.0f); } m_World = nullptr; @@ -370,9 +370,9 @@ float Director::AddBestGenericCut() int seqNrMod = m_nextCutSeqnr % m_historyLength; float sumTarget2Rank[MAX_CLIENTS]; - float bestTarget2Rank, bestRank = 0; + float bestTarget2Rank, bestRank = 0.0f; float targetRankSum = 0; - int newTarget, newTarget2; + int newTarget = 0, newTarget2 = 0; int bestTarget2; for (int i = 0; i < MAX_CLIENTS; i++) diff --git a/rehlds/HLTV/Director/src/public_amalgamation.cpp b/rehlds/HLTV/Director/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/HLTV/Director/src/public_amalgamation.cpp +++ b/rehlds/HLTV/Director/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/HLTV/Proxy/CMakeLists.txt b/rehlds/HLTV/Proxy/CMakeLists.txt new file mode 100644 index 0000000..550e049 --- /dev/null +++ b/rehlds/HLTV/Proxy/CMakeLists.txt @@ -0,0 +1,156 @@ +cmake_minimum_required(VERSION 3.1) +project(proxy CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3 -flto\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\ + -Wno-write-strings -Wno-strict-aliasing") + + # Check Clang compiler + if ("$ENV{CXX}" MATCHES "clang") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-unused-private-field") + else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fno-plt") + + # GCC >= 8.3 + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation") + endif() + endif() +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" + "${PROJECT_SOURCE_DIR}/../Director/src" +) + +set(PROJECT_BZIP2_DIR + "${PROJECT_SOURCE_DIR}/../../../dep/bzip2/include" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../.." + "${PROJECT_SOURCE_DIR}/../../engine" + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../pm_shared" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(PROXY_SRCS + "src/Proxy.cpp" + "src/Status.cpp" + "src/Master.cpp" + "src/ProxyClient.cpp" + "src/DemoClient.cpp" + "src/FakeClient.cpp" + "src/public_amalgamation.cpp" + "../Director/src/Director.cpp" +) + +set(COMMON_SRCS + "../../common/BaseSystemModule.cpp" + "../../common/ObjectDictionary.cpp" + "../../common/ObjectList.cpp" + "../../common/TokenLine.cpp" + "../../HLTV/common/BaseClient.cpp" + "../../HLTV/common/BitBuffer.cpp" + "../../HLTV/common/byteorder.cpp" + "../../HLTV/common/common.cpp" + "../../HLTV/common/DemoFile.cpp" + "../../HLTV/common/DirectorCmd.cpp" + "../../HLTV/common/InfoString.cpp" + "../../HLTV/common/mathlib.cpp" + "../../HLTV/common/md5.cpp" + "../../HLTV/common/munge.cpp" + "../../HLTV/common/NetAddress.cpp" + "../../HLTV/common/NetChannel.cpp" + "../../HLTV/common/random.cpp" + "../../engine/mem.cpp" +) + +add_library(proxy SHARED ${PROXY_SRCS}) + +target_include_directories(proxy PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_BZIP2_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(proxy PRIVATE + HLTV + HLTV_FIXES + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(proxy PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(proxy PRIVATE + dl + m + bzip2 + steam_api +) + +if (NOT TARGET bzip2) + add_subdirectory(../../../dep/bzip2 lib) +endif() + +set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-rpath,'$ORIGIN/.' \ + -L${PROJECT_SOURCE_DIR}/../../lib/linux32") + +set_target_properties(proxy PROPERTIES + OUTPUT_NAME proxy + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/HLTV/Proxy/build.gradle b/rehlds/HLTV/Proxy/build.gradle deleted file mode 100644 index 92e2deb..0000000 --- a/rehlds/HLTV/Proxy/build.gradle +++ /dev/null @@ -1,198 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -project.ext.dep_bzip2 = project(':dep/bzip2') - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/..', '/../..', '/src', '/../Director/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared'); - cfg.projectInclude(dep_bzip2, '/include') - - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'HLTV_FIXES', 'PROXY_MODULE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'proxy_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF' - cfg.projectLibpath(project, '/../../lib') - cfg.extraLibs "steam_api.lib", "psapi.lib", "ws2_32.lib" - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'proxy_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.compilerOptions.args '-fno-exceptions' - cfg.projectLibpath(project, '/../../lib/linux32') - cfg.extraLibs "steam_api" - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - proxy(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'proxy' - - sources { - proxy_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - - lib project: ':dep/bzip2', library: 'bzip2', linkage: 'static' - } - - proxy_common(CppSourceSet) { - source { - srcDirs "../../common", "../common" - - // common - include "BaseSystemModule.cpp" - include "ObjectDictionary.cpp" - include "ObjectList.cpp" - include "TokenLine.cpp" - - // HLTV common - include "BaseClient.cpp" - include "BitBuffer.cpp" - include "byteorder.cpp" - include "common.cpp" - include "DemoFile.cpp" - include "DirectorCmd.cpp" - include "InfoString.cpp" - include "mathlib.cpp" - include "md5.cpp" - include "munge.cpp" - include "NetAddress.cpp" - include "NetChannel.cpp" - include "random.cpp" - } - } - - proxy_engine(CppSourceSet) { - source { - srcDir "../../engine" - include "mem.cpp" - } - } - - proxy_director(CppSourceSet) { - source { - srcDir "../Director/src" - include "Director.cpp" - } - } - - proxy_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - - lib project: ':dep/bzip2', library: 'bzip2', linkage: 'static' - } - } - } - - binaries.all { - NativeBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -build.finalizedBy(buildFinalize); -buildFixes.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -// prevent static lib building -binaries.withType(StaticLibraryBinarySpec) { binary -> - buildable = false -} diff --git a/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj b/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj index a5324d2..0690222 100644 --- a/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj +++ b/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj @@ -5,10 +5,6 @@ Debug Win32 - - Release Swds - Win32 - Release Win32 @@ -20,264 +16,187 @@ - - - - - - - - - - true - true - true - - - true - true - true - Use - Use Use - - Use - Use Use - - - - - - Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - - - - - Use - Use Use - - Use - Use Use - - - - Create Create - Create Use - Use Use - - Use - Use Use - - Use - Use Use - - Use - Use Use - - @@ -286,11 +205,6 @@ - - true - true - true - @@ -344,16 +258,6 @@ true MultiByte - - DynamicLibrary - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -365,9 +269,6 @@ - - - true @@ -377,10 +278,6 @@ false proxy - - false - proxy - Use @@ -456,49 +353,6 @@ Automatic deployment script - - - Level3 - Use - MaxSpeed - true - true - HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;PROXY_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)\..\src;$(ProjectDir)\..\..\;$(ProjectDir)\..\..\..\;$(ProjectDir)\..\..\Director\src;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;$(ProjectDir)\..\..\..\pm_shared;$(ProjectDir)\..\..\..\..\dep\bzip2\include;%(AdditionalIncludeDirectories) - precompiled.h - MultiThreaded - true - false - - - Windows - true - true - true - psapi.lib;ws2_32.lib;steam_api.lib;%(AdditionalDependencies) - $(ProjectDir)../../../lib - - - - - - - - - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - diff --git a/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj.filters b/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj.filters index 5f80d89..71264ae 100644 --- a/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj.filters +++ b/rehlds/HLTV/Proxy/msvc/Proxy.vcxproj.filters @@ -10,9 +10,6 @@ {feda00f0-7c09-4c63-b5a1-e4fbcdfc6b69} - - {199d99ef-8924-48fc-8c8a-2859f8d40c82} - {1777708a-8593-40c0-8caa-9154180854dc} @@ -84,12 +81,6 @@ HLTV\common - - src\hookers - - - src\hookers - src @@ -173,9 +164,6 @@ HLTV\common - - src\hookers - common diff --git a/rehlds/HLTV/Proxy/src/Proxy.cpp b/rehlds/HLTV/Proxy/src/Proxy.cpp index cb842f4..c876415 100644 --- a/rehlds/HLTV/Proxy/src/Proxy.cpp +++ b/rehlds/HLTV/Proxy/src/Proxy.cpp @@ -80,11 +80,10 @@ Proxy::LocalCommandID_s Proxy::m_LocalCmdReg[] = { { "maxloss", CMD_ID_MAXLOSS, &Proxy::CMD_MaxLoss }, { "protocol", CMD_ID_PROTOCOL, &Proxy::CMD_Protocol }, { "region", CMD_ID_REGION, &Proxy::CMD_Region }, + { "chatdelay", CMD_ID_CHATDELAY, &Proxy::CMD_ChatDelay }, }; -#ifndef HOOK_HLTV EXPOSE_SINGLE_INTERFACE(Proxy, IProxy, PROXY_INTERFACE_VERSION); -#endif // HOOK_HLTV bool Proxy::Init(IBaseSystem *system, int serial, char *name) { @@ -188,6 +187,7 @@ bool Proxy::Init(IBaseSystem *system, int serial, char *name) m_MaxClients = 128; m_MaxQueries = 100; m_Region = 255; + m_ChatDelay = 6; const int maxRouteAblePacketSize = 1400; m_InfoInfo.Resize(maxRouteAblePacketSize); @@ -208,7 +208,13 @@ bool Proxy::Init(IBaseSystem *system, int serial, char *name) Q_memset(m_LastRconCommand, 0, sizeof(m_LastRconCommand)); Q_memset(m_OffLineText, 0, sizeof(m_OffLineText)); Q_memset(m_SignonCommands, 0, sizeof(m_SignonCommands)); - Q_memset(m_Challenges, 0, sizeof(m_Challenges)); + + for (int i = 0; i < MAX_CHALLENGES; i++) + { + m_Challenges[i].adr.Clear(); + m_Challenges[i].challenge = 0; + m_Challenges[i].time = 0.0f; + } m_LoopCommands.Init(); m_BannList.Init(); @@ -834,10 +840,10 @@ void Proxy::Broadcast(byte *data, int length, int groupType, bool isReliable) while (client) { if (client->IsActive() - && ((groupType & GROUP_CLIENT) && client->GetClientType() == TYPE_CLIENT) - || ((groupType & GROUP_PROXY) && client->GetClientType() == TYPE_PROXY) - || ((groupType & GROUP_VOICE) && client->IsHearingVoices()) - || ((groupType & GROUP_CHAT) && client->HasChatEnabled())) + && (((groupType & GROUP_CLIENT) && client->GetClientType() == TYPE_CLIENT) + || ((groupType & GROUP_PROXY) && client->GetClientType() == TYPE_PROXY) + || ((groupType & GROUP_VOICE) && client->IsHearingVoices()) + || ((groupType & GROUP_CHAT) && client->HasChatEnabled()))) { client->Send(data, length, isReliable); } @@ -964,7 +970,7 @@ void Proxy::CMD_Name(char *cmdLine) } char name[MAX_NAME]; - int len = Q_strlen(params.GetToken(1)); + unsigned int len = Q_strlen(params.GetToken(1)); if (len > sizeof(name) - 1) { m_System->Printf("Invalid name length.\n"); return; @@ -2774,3 +2780,28 @@ const char *Proxy::GetDescription() return "Private Server"; } + +void Proxy::CMD_ChatDelay(char *cmdLine) +{ + enum { param_ChatDelay = 1 }; + + TokenLine params(cmdLine); + if (params.CountToken() != 2) + { + m_System->Printf("Syntax: chatdelay \n"); + m_System->Printf("Current clients chat delay is %i.\n", GetChatDelay()); + return; + } + + SetChatDelay(Q_atoi(params.GetToken(param_ChatDelay))); +} + +void Proxy::SetChatDelay(int delay) +{ + m_ChatDelay = delay; +} + +int Proxy::GetChatDelay() const +{ + return m_ChatDelay; +} diff --git a/rehlds/HLTV/Proxy/src/Proxy.h b/rehlds/HLTV/Proxy/src/Proxy.h index a7ab781..d8fb4fd 100644 --- a/rehlds/HLTV/Proxy/src/Proxy.h +++ b/rehlds/HLTV/Proxy/src/Proxy.h @@ -130,6 +130,8 @@ public: EXT_FUNC int GetDispatchMode(); EXT_FUNC unsigned char GetRegion(); EXT_FUNC bool WriteSignonData(int type, BitBuffer *stream); + EXT_FUNC void SetChatDelay(int delay); + EXT_FUNC int GetChatDelay() const; void ReconnectClients(); void ExecuteRcon(NetAddress *from, char *command); @@ -229,7 +231,8 @@ private: CMD_ID_CLEARBANNS, CMD_ID_MAXLOSS, CMD_ID_PROTOCOL, - CMD_ID_REGION + CMD_ID_REGION, + CMD_ID_CHATDELAY }; void CMD_Rcon(char *cmdLine); @@ -284,6 +287,7 @@ private: void CMD_MaxLoss(char *cmdLine); void CMD_Protocol(char *cmdLine); void CMD_Region(char *cmdLine); + void CMD_ChatDelay(char *cmdLine); struct LocalCommandID_s { char *name; @@ -373,6 +377,7 @@ protected: float m_CurrentLoss; ObjectList m_BannList; unsigned char m_Region; + int m_ChatDelay; textmessage_t m_LocalMessage; textmessage_t m_CommentatorMessage; diff --git a/rehlds/HLTV/Proxy/src/ProxyClient.cpp b/rehlds/HLTV/Proxy/src/ProxyClient.cpp index 40bd5b3..2e47233 100644 --- a/rehlds/HLTV/Proxy/src/ProxyClient.cpp +++ b/rehlds/HLTV/Proxy/src/ProxyClient.cpp @@ -86,6 +86,11 @@ bool ProxyClient::ProcessStringCmd(char *string) return true; } + if (!cmdLine.CountToken()) { + m_System->DPrintf("WARNING! ProxyClient::ProcessStringCmd: invalid command string.\n"); + return false; + } + char *cmd = cmdLine.GetToken(0); for (auto& local_cmd : m_LocalCmdReg) { @@ -126,7 +131,7 @@ void ProxyClient::CMD_Say(TokenLine *cmd) return; } - if (m_SystemTime >= m_LastChatTime + 6) { + if (m_SystemTime >= m_LastChatTime + m_Proxy->GetChatDelay()) { m_Proxy->ChatSpectator(m_ClientName, chatText); m_LastChatTime = float(m_SystemTime); return; diff --git a/rehlds/HLTV/Proxy/src/precompiled.h b/rehlds/HLTV/Proxy/src/precompiled.h index a3065cf..a6ee104 100644 --- a/rehlds/HLTV/Proxy/src/precompiled.h +++ b/rehlds/HLTV/Proxy/src/precompiled.h @@ -18,9 +18,6 @@ #include "common/net_internal.h" #include "common/mathlib_internal.h" -// Hooks stuff -#include "hookers/HLTV/Proxy/hooklist.h" - #include "common/DirectorCmd.h" #include "common/NetAddress.h" #include "common/NetChannel.h" diff --git a/rehlds/HLTV/Proxy/src/public_amalgamation.cpp b/rehlds/HLTV/Proxy/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/HLTV/Proxy/src/public_amalgamation.cpp +++ b/rehlds/HLTV/Proxy/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/HLTV/README.md b/rehlds/HLTV/README.md index 48da8c5..f7b7814 100644 --- a/rehlds/HLTV/README.md +++ b/rehlds/HLTV/README.md @@ -1,15 +1,5 @@ ## Half-Life TV for Goldsrc based games HLTV Launcher -### Building -On Windows: -
gradlew --max-workers=1 clean rehlds/HLTV:build
- -On Linux (ICC): -
./gradlew --max-workers=1 clean rehlds/HLTV:build
- -On Linux (GCC): -
./gradlew --max-workers=1 -PuseGcc clean rehlds/HLTV:build
- Compiled binaries will be placed in each project rehlds/HLTV/**/binaries/ directory ### Overview diff --git a/rehlds/HLTV/build.gradle b/rehlds/HLTV/build.gradle deleted file mode 100644 index 8f08d31..0000000 --- a/rehlds/HLTV/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -evaluationDependsOn(':rehlds/HLTV/Console'); -evaluationDependsOn(':rehlds/HLTV/Core'); -evaluationDependsOn(':rehlds/HLTV/DemoPlayer'); -evaluationDependsOn(':rehlds/HLTV/Director'); -evaluationDependsOn(':rehlds/HLTV/Proxy'); - -task build { - dependsOn project(':rehlds/HLTV/Console').tasks.build, - project(':rehlds/HLTV/Core').tasks.build, - project(':rehlds/HLTV/DemoPlayer').tasks.build, - project(':rehlds/HLTV/Director').tasks.build, - project(':rehlds/HLTV/Proxy').tasks.build -} diff --git a/rehlds/HLTV/common/BaseClient.cpp b/rehlds/HLTV/common/BaseClient.cpp index 5d4966f..9f10489 100644 --- a/rehlds/HLTV/common/BaseClient.cpp +++ b/rehlds/HLTV/common/BaseClient.cpp @@ -266,6 +266,11 @@ bool BaseClient::ProcessStringCmd(char *string) return false; } + if (!cmdLine.CountToken()) { + m_System->DPrintf("WARNING! BaseClient::ProcessStringCmd: invalid command string.\n"); + return false; + } + char *cmd = cmdLine.GetToken(0); for (auto& local_cmd : m_LocalCmdReg) { @@ -320,6 +325,10 @@ void BaseClient::CMD_SetInfo(TokenLine *cmd) return; } + if (cmd->GetToken(1)[0] == '*') { + return; + } + m_Userinfo.SetValueForKey(cmd->GetToken(1), cmd->GetToken(2)); UpdateUserInfo(); } diff --git a/rehlds/HLTV/common/BitBuffer.cpp b/rehlds/HLTV/common/BitBuffer.cpp index f730896..89bf0fc 100644 --- a/rehlds/HLTV/common/BitBuffer.cpp +++ b/rehlds/HLTV/common/BitBuffer.cpp @@ -67,15 +67,15 @@ const uint32 INVBITTABLE[] = 0xFFFFFFFF, }; -BitBuffer::BitBuffer() : m_Data(nullptr), +BitBuffer::BitBuffer() : + m_Overflowed(false), + m_Data(nullptr), m_CurByte(nullptr), m_CurBit(0), m_MaxSize(0), - m_Overflowed(false), m_LittleEndian(false), m_OwnData(false) { - ; } BitBuffer::BitBuffer(void *newData, unsigned int size) @@ -345,7 +345,8 @@ void BitBuffer::WriteBuf(BitBuffer *buf, int length) char *BitBuffer::ReadString() { - int c = 0, l = 0; + int c = 0; + unsigned int l = 0; static char string[8192]; while ((c = ReadChar(), c) && c != -1 && l < sizeof(string) - 1) { @@ -358,7 +359,8 @@ char *BitBuffer::ReadString() char *BitBuffer::ReadStringLine() { - int c = 0, l = 0; + int c = 0; + unsigned int l = 0; static char string[2048]; while ((c = ReadChar(), c) && c != '\n' && c != -1 && l < sizeof(string) - 1) { diff --git a/rehlds/HLTV/common/DemoFile.cpp b/rehlds/HLTV/common/DemoFile.cpp index f3ddbee..d955248 100644 --- a/rehlds/HLTV/common/DemoFile.cpp +++ b/rehlds/HLTV/common/DemoFile.cpp @@ -29,10 +29,10 @@ #include "precompiled.h" DemoFile::DemoFile() : - m_FileSystem(nullptr), m_FileHandle(FILESYSTEM_INVALID_HANDLE), m_DemoChannel(nullptr), - m_Entries(nullptr) + m_Entries(nullptr), + m_FileSystem(nullptr) { Reset(); } @@ -545,6 +545,8 @@ void DemoFile::ReadDemoPacket(BitBuffer *demoData, demo_info_t *demoInfo) case DemoCmd::PayLoad: demoData->WriteLong(msglen); break; + default: + break; } demoData->WriteBuf(msgbuf, msglen); diff --git a/rehlds/HLTV/common/DirectorCmd.cpp b/rehlds/HLTV/common/DirectorCmd.cpp index 6ee3de1..2f8e32c 100644 --- a/rehlds/HLTV/common/DirectorCmd.cpp +++ b/rehlds/HLTV/common/DirectorCmd.cpp @@ -583,7 +583,7 @@ void DirectorCmd::WriteToStream(BitBuffer *stream) } } -char *DirectorCmd::ToString() +const char *DirectorCmd::ToString() { int i1, i2, i3; float f1, f2, f3, f4; @@ -592,7 +592,7 @@ char *DirectorCmd::ToString() char *t1 = m_CMD_Name[m_Type]; char t2[1024]; - static char s[1024]; + static char s[2048]; Q_memset(s, 0, sizeof(s)); switch (m_Type) diff --git a/rehlds/HLTV/common/DirectorCmd.h b/rehlds/HLTV/common/DirectorCmd.h index 88e5101..3d25af7 100644 --- a/rehlds/HLTV/common/DirectorCmd.h +++ b/rehlds/HLTV/common/DirectorCmd.h @@ -40,7 +40,7 @@ public: void Copy(DirectorCmd *cmd); void Resize(int size); void FromString(char *string); - char *ToString(); + const char *ToString(); void WriteToStream(BitBuffer *stream); bool ReadFromStream(BitBuffer *stream); int GetType(); diff --git a/rehlds/HLTV/common/InfoString.cpp b/rehlds/HLTV/common/InfoString.cpp index 070206e..9e0bc03 100644 --- a/rehlds/HLTV/common/InfoString.cpp +++ b/rehlds/HLTV/common/InfoString.cpp @@ -28,8 +28,9 @@ #include "precompiled.h" -InfoString::InfoString(char *string, unsigned int maxSize) - : m_String(nullptr), m_MaxSize(0) +InfoString::InfoString(char *string, unsigned int maxSize) : + m_MaxSize(0), + m_String(nullptr) { unsigned int len = Q_strlen(string) + 1; if (len < maxSize) { @@ -40,19 +41,22 @@ InfoString::InfoString(char *string, unsigned int maxSize) SetString(string); } -InfoString::InfoString() - : m_String(nullptr), m_MaxSize(0) +InfoString::InfoString() : + m_MaxSize(0), + m_String(nullptr) { } -InfoString::InfoString(unsigned int maxSize) - : m_String(nullptr), m_MaxSize(0) +InfoString::InfoString(unsigned int maxSize) : + m_MaxSize(0), + m_String(nullptr) { SetMaxSize(maxSize); } -InfoString::InfoString(char *string) - : m_String(nullptr), m_MaxSize(0) +InfoString::InfoString(char *string) : + m_MaxSize(0), + m_String(nullptr) { unsigned int len = Q_strlen(string) + 1; if (len < MAX_INFO_LEN) { diff --git a/rehlds/HLTV/common/NetAddress.cpp b/rehlds/HLTV/common/NetAddress.cpp index 2ee99c0..089af9d 100644 --- a/rehlds/HLTV/common/NetAddress.cpp +++ b/rehlds/HLTV/common/NetAddress.cpp @@ -28,9 +28,11 @@ #include "precompiled.h" -NetAddress::NetAddress() : - m_Port(0), m_IP(), m_String() +NetAddress::NetAddress() { + m_Port = 0; + Q_memset(m_IP, 0, sizeof(m_IP)); + Q_memset(m_String, 0, sizeof(m_String)); } void NetAddress::SetPort(int16 port) diff --git a/rehlds/HLTV/common/common.cpp b/rehlds/HLTV/common/common.cpp index 84916cf..0da0ef4 100644 --- a/rehlds/HLTV/common/common.cpp +++ b/rehlds/HLTV/common/common.cpp @@ -220,7 +220,7 @@ char *COM_FileExtension(char *in) #else // #ifdef HLTV_FIXES static char exten[MAX_PATH]; char *c, *d = nullptr; - int i; + unsigned int i; // Search for the first dot after the last path separator c = in; @@ -537,7 +537,7 @@ void NORETURN HLTV_SysError(const char *fmt, ...) fprintf(fl, "%s\n", string); fclose(fl); - int *null = 0; + volatile int *null = 0; *null = 0; exit(-1); } diff --git a/rehlds/HLTV/common/mathlib.cpp b/rehlds/HLTV/common/mathlib.cpp index fb8e5ab..813c450 100644 --- a/rehlds/HLTV/common/mathlib.cpp +++ b/rehlds/HLTV/common/mathlib.cpp @@ -306,8 +306,7 @@ float RadiusFromBounds(const vec_t *mins, const vec_t *maxs) for (int i = 0; i < 3; i++) { float fmin = fabs(mins[i]); - float fmax = fabs(mins[i]); - + float fmax = fabs(maxs[i]); if (fmin > fmax) corner[i] = fmin; else diff --git a/rehlds/build.gradle b/rehlds/build.gradle deleted file mode 100644 index e36ea4d..0000000 --- a/rehlds/build.gradle +++ /dev/null @@ -1,425 +0,0 @@ -import gradlecpp.RehldsPlayTestPlugin -import gradlecpp.RehldsPlayTestTask -import gradlecpp.VelocityUtils - -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.doomedsociety.gradlecpp.LazyNativeDepSet -import org.doomedsociety.gradlecpp.cfg.ToolchainConfig -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet -import org.doomedsociety.gradlecpp.msvc.FloatingPointModel -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.gradle.language.cpp.CppSourceSet -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeExecutableSpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.SharedLibraryBinarySpec -import rehlds.testdemo.RehldsDemoRunner -import versioning.RehldsVersionInfo -import org.apache.commons.io.FilenameUtils - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin -apply plugin: RehldsPlayTestPlugin -apply plugin: gradlecpp.CppUnitTestPlugin - -repositories { - maven { - url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/' - } -} - -configurations { - rehlds_tests -} - -dependencies { - rehlds_tests 'rehlds.testdemos:hl-phys-single1:1.1' - rehlds_tests 'rehlds.testdemos:crossfire-1-multiplayer-1:1.1' - rehlds_tests 'rehlds.testdemos:cstrike-muliplayer-1:1.1' - rehlds_tests 'rehlds.testdemos:shooting-hl-1:1.1' -} - -project.ext.dep_bzip2 = project(':dep/bzip2') -project.ext.dep_cppunitlite = project(':dep/cppunitlite') - -void createIntergrationTestTask(NativeBinarySpec b) { - boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') - - if (!(b instanceof SharedLibraryBinarySpec)) return - if (!GradleCppUtils.windows) return - if (rehldsFixes) return - - def libLinkTask = GradleCppUtils.getLinkTask(b) - String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null - - def depFiles = [] - depFiles.addAll(libLinkTask.outputs.files.files) - - def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RehldsPlayTestTask) - demoItgTestTask.with { - rehldsImageRoot = new File(project.projectDir, '_rehldsTestImg') - rehldsTestLogs = new File(this.project.buildDir, "_rehldsTestLogs/${b.name}") - testDemos = project.configurations.rehlds_tests - testFor = b - - //inputs/outputs for up-to-date check - inputs.files depFiles - inputs.files testDemos.files - outputs.dir rehldsTestLogs - - //dependencies on library and test executable - dependsOn libLinkTask - if (unitTestTask) { - dependsOn unitTestTask - } - - postExtractAction { - def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b) - GradleCppUtils.copyFile(binaryOutFile, new File(rehldsImageRoot, binaryOutFile.name), true) - } - } - - b.buildTask.dependsOn demoItgTestTask -} - -void setupUnitTests(NativeBinarySpec bin) { - boolean unitTestExecutable = bin.component.name.endsWith('_tests') - if (!unitTestExecutable) return - - GradleCppUtils.getLinkTask(bin).doLast { - String srcPath = '' + projectDir + (GradleCppUtils.windows ? '/lib/steam_api.dll' : '/lib/linux32/libsteam_api.so') - String dstPath = bin.executableFile.parent + (GradleCppUtils.windows ? '/steam_api.dll' : '/libsteam_api.so') - GradleCppUtils.copyFile(srcPath, dstPath, true) - } -} - -void postEvaluate(NativeBinarySpec b) { - - // attach generateAppVersion task to all 'compile source' tasks - GradleCppUtils.getCompileTasks(b).each { Task t -> - t.dependsOn project.generateAppVersion - } - - setupUnitTests(b) - createIntergrationTestTask(b) -} - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - boolean unitTestExecutable = b.component.name.endsWith('_tests') - boolean swdsLib = b.name.toLowerCase().contains('swds') - boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') - boolean release = b.buildType.name.toLowerCase() == 'release'; - - ToolchainConfig cfg = rootProject.createToolchainConfig(b) - cfg.projectInclude(project, '', '/public/rehlds', '/engine', '/common', '/pm_shared', '/rehlds', '/testsuite', '/hookers', '/public') - cfg.projectInclude(dep_bzip2, '/include') - - if (unitTestExecutable) { - cfg.projectInclude(dep_cppunitlite, '/include') - b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true) - } - b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true) - - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'SWDS', 'REHLDS_SELF', 'REHLDS_OPT_PEDANTIC', 'REHLDS_API' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'rehlds_pch' - ) - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - if (!rehldsFixes) { - cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE - cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED - } else { - cfg.compilerOptions.args '/Oi', '/GF', '/GR-', '/GS-' - } - if (swdsLib) { - cfg.linkerOptions.randomizedBaseAddress = false - cfg.linkerOptions.baseAddress = '0x4970000' - } - cfg.projectLibpath(project, '/lib') - cfg.extraLibs 'steam_api.lib', 'psapi.lib', 'ws2_32.lib', 'kernel32.lib', 'user32.lib', 'advapi32.lib', 'libacof32.lib' - } else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'rehlds_pch' - ) - } - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_strdup': 'strdup', - '_unlink': 'unlink', - '_vsnprintf': 'vsnprintf', - '_vsnwprintf' : 'vswprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - cfg.compilerOptions.args '-ffunction-sections', '-fdata-sections' // Remove unused code and data - cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions' - - cfg.linkerOptions.args '-Wl,--version-script=../version_script.lds', '-Wl,--gc-sections' - - cfg.projectLibpath(project, '/lib/linux32') - cfg.extraLibs 'rt', 'dl', 'm', 'steam_api', 'aelf32' - } - - if (unitTestExecutable) { - cfg.singleDefines 'REHLDS_UNIT_TESTS', 'REHLDS_SSE', 'REHLDS_JIT' - } - - if (rehldsFixes) { - cfg.singleDefines 'REHLDS_FIXES', 'REHLDS_SSE', 'REHLDS_JIT', 'REHLDS_CHECKS', 'HAVE_OPT_STRTOOLS' - } - - if (!release) { - cfg.singleDefines 'REHLDS_FLIGHT_REC' - } - - ToolchainConfigUtils.apply(project, cfg, b) - - GradleCppUtils.onTasksCreated(project, 'postEvaluate', { - postEvaluate(b) - }) -} - -class RehldsSrc { - static void rehlds_src(def h) { - h.rehlds_engine(CppSourceSet) { - source { - srcDirs "engine", "rehlds", "version" - if (GradleCppUtils.windows) srcDirs "testsuite" - - include "**/*.cpp" - exclude "precompiled.cpp" - } - } - h.rehlds_public(CppSourceSet) { - source { - srcDirs "public" - include "registry.cpp", "steamid.cpp", "utlbuffer.cpp", "tier0/dbg.cpp" - } - } - h.rehlds_memory(CppSourceSet) { - source { - srcDirs "hookers" - include "memory.cpp" - } - } - h.rehlds_common(CppSourceSet) { - source { - srcDirs "common" - include "BaseSystemModule.cpp", "ObjectList.cpp", "TokenLine.cpp" - } - } - } - - static void rehlds_pch(def h) { - h.rehlds_pch(CppSourceSet) { - source { - srcDirs "rehlds" - include "precompiled.cpp" - } - } - } - - static void rehlds_swds_main_src(def h) { - h.rehlds_swds_main_src(CppSourceSet) { - source { - srcDir "hookers" - include "engine/main_swds.cpp" - } - } - } - - static void rehlds_tests_src(def h) { - h.rehlds_tests_src(CppSourceSet) { - source { - srcDir "unittests" - include "**/*.cpp" - } - } - } -} - -model { - buildTypes { - debug - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - flavors { - rehldsNofixes - rehldsFixes - } - - components { - rehlds_swds_engine(NativeLibrarySpec) { - targetPlatform 'x86' - baseName GradleCppUtils.windows ? 'swds' : 'engine_i486' - - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_swds_main_src(it) - } - - binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } - } - - rehlds_swds_engine_tests(NativeExecutableSpec) { - targetPlatform 'x86' - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_tests_src(it) - } - - binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { - SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'rehldsFixes' && blib.component.name == 'rehlds_swds_engine' - } -} - -task buildEngine { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { - SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'rehldsFixes' && blib.component.name == 'rehlds_swds_engine' - } -} - -buildFixes.finalizedBy(buildFinalize); -buildEngine.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -gradle.taskGraph.whenReady { graph -> - if (!graph.hasTask(buildFixes) && !graph.hasTask(buildEngine)) { - return; - } - - // skip all tasks with the matched substrings in the name like "test" - def tasks = graph.getAllTasks(); - tasks.findAll { it.name.toLowerCase().contains("test") }.each { task -> - task.enabled = false; - } -} - -task prepareDevEnvTests { - def rehldsTests = new File(project.projectDir, '_dev/testDemos') - - inputs.files configurations.rehlds_tests.files - outputs.dir rehldsTests - - doLast { - rehldsTests.mkdirs() - configurations.rehlds_tests.files.each { File f -> - def t = zipTree(f) - copy { - into new File(rehldsTests, FilenameUtils.getBaseName(f.absolutePath)) - from t - } - } - } -} - -task prepareDevEnvEngine << { - ['_dev/rehlds', '_dev/rehlds_swds'].each { engineDir -> - def rehldsImage = new File(project.projectDir, engineDir) - rehldsImage.mkdirs() - def demoRunner = new RehldsDemoRunner(project.configurations.rehlds_playtest_image.getFiles(), rehldsImage, null) - demoRunner.prepareEngine() - } -} - -task prepareDevEnv { - dependsOn prepareDevEnvEngine, prepareDevEnvTests -} - -tasks.clean.doLast { - project.file('version/appversion.h').delete() -} - -task generateAppVersion { - RehldsVersionInfo verInfo = (RehldsVersionInfo) rootProject.rehldsVersionInfo - - def tplFile = project.file('version/appversion.vm') - def renderedFile = project.file('version/appversion.h') - - // check to up-to-date - inputs.file tplFile - inputs.file project.file('gradle.properties') - outputs.file renderedFile - - // this will ensure that this task is redone when the versions change - inputs.property('version', rootProject.version) - inputs.property('commitDate', verInfo.asCommitDate()) - - println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']"; - - doLast { - - def templateCtx = [ - verInfo : verInfo - ] - - def content = VelocityUtils.renderTemplate(tplFile, templateCtx) - renderedFile.delete() - renderedFile.write(content, 'utf-8') - - println 'The current ReHLDS maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')'; - } -} diff --git a/rehlds/common/IBaseSystem.h b/rehlds/common/IBaseSystem.h index 9f50fe3..9b0f687 100644 --- a/rehlds/common/IBaseSystem.h +++ b/rehlds/common/IBaseSystem.h @@ -74,7 +74,7 @@ public: virtual bool RegisterCommand(char *name, ISystemModule *module, int commandID) = 0; virtual void GetCommandMatches(char *string, ObjectList *pMatchList) = 0; - virtual void ExecuteString(char *commands) = 0; + virtual void ExecuteString(const char *commands) = 0; virtual void ExecuteFile(char *filename) = 0; virtual void Errorf(char *fmt, ...) = 0; diff --git a/rehlds/common/TextConsoleUnix.cpp b/rehlds/common/TextConsoleUnix.cpp index 32671ae..90af60c 100644 --- a/rehlds/common/TextConsoleUnix.cpp +++ b/rehlds/common/TextConsoleUnix.cpp @@ -133,7 +133,7 @@ int CTextConsoleUnix::kbhit() return select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv) != -1 && FD_ISSET(STDIN_FILENO, &rfds); } -char *CTextConsoleUnix::GetLine() +const char *CTextConsoleUnix::GetLine() { // early return for 99.999% case :) if (!kbhit()) @@ -273,7 +273,7 @@ char *CTextConsoleUnix::GetLine() return NULL; } -void CTextConsoleUnix::PrintRaw(char *pszMsg, int nChars) +void CTextConsoleUnix::PrintRaw(const char *pszMsg, int nChars) { if (nChars == 0) { @@ -288,7 +288,7 @@ void CTextConsoleUnix::PrintRaw(char *pszMsg, int nChars) } } -void CTextConsoleUnix::Echo(char *pszMsg, int nChars) +void CTextConsoleUnix::Echo(const char *pszMsg, int nChars) { if (nChars == 0) { diff --git a/rehlds/common/TextConsoleUnix.h b/rehlds/common/TextConsoleUnix.h index b40cbc4..bc14575 100644 --- a/rehlds/common/TextConsoleUnix.h +++ b/rehlds/common/TextConsoleUnix.h @@ -44,9 +44,9 @@ public: bool Init(IBaseSystem *system = nullptr); void ShutDown(); - void PrintRaw(char *pszMsg, int nChars = 0); - void Echo(char *pszMsg, int nChars = 0); - char *GetLine(); + void PrintRaw(const char *pszMsg, int nChars = 0); + void Echo(const char *pszMsg, int nChars = 0); + const char *GetLine(); int GetWidth(); private: diff --git a/rehlds/common/TextConsoleWin32.cpp b/rehlds/common/TextConsoleWin32.cpp index aeaefb3..1ac38f3 100644 --- a/rehlds/common/TextConsoleWin32.cpp +++ b/rehlds/common/TextConsoleWin32.cpp @@ -111,7 +111,7 @@ void CTextConsoleWin32::SetVisible(bool visible) m_ConsoleVisible = visible; } -char *CTextConsoleWin32::GetLine() +const char *CTextConsoleWin32::GetLine() { while (true) { @@ -203,7 +203,7 @@ char *CTextConsoleWin32::GetLine() return nullptr; } -void CTextConsoleWin32::PrintRaw(char *pszMsg, int nChars) +void CTextConsoleWin32::PrintRaw(const char *pszMsg, int nChars) { #ifdef LAUNCHER_FIXES char outputStr[2048]; @@ -225,7 +225,7 @@ void CTextConsoleWin32::PrintRaw(char *pszMsg, int nChars) #endif } -void CTextConsoleWin32::Echo(char *pszMsg, int nChars) +void CTextConsoleWin32::Echo(const char *pszMsg, int nChars) { PrintRaw(pszMsg, nChars); } @@ -245,7 +245,7 @@ int CTextConsoleWin32::GetWidth() return nWidth; } -void CTextConsoleWin32::SetStatusLine(char *pszStatus) +void CTextConsoleWin32::SetStatusLine(const char *pszStatus) { Q_strncpy(statusline, pszStatus, sizeof(statusline) - 1); statusline[sizeof(statusline) - 2] = '\0'; @@ -269,7 +269,7 @@ void CTextConsoleWin32::UpdateStatus() WriteConsoleOutputCharacter(houtput, statusline, 80, coord, &dwWritten); } -void CTextConsoleWin32::SetTitle(char *pszTitle) +void CTextConsoleWin32::SetTitle(const char *pszTitle) { SetConsoleTitle(pszTitle); } diff --git a/rehlds/common/TextConsoleWin32.h b/rehlds/common/TextConsoleWin32.h index 656110e..70ba857 100644 --- a/rehlds/common/TextConsoleWin32.h +++ b/rehlds/common/TextConsoleWin32.h @@ -39,13 +39,13 @@ public: bool Init(IBaseSystem *system = nullptr); void ShutDown(); - void SetTitle(char *pszTitle); - void SetStatusLine(char *pszStatus); + void SetTitle(const char *pszTitle); + void SetStatusLine(const char *pszStatus); void UpdateStatus(); - void PrintRaw(char * pszMsz, int nChars = 0); - void Echo(char * pszMsz, int nChars = 0); - char *GetLine(); + void PrintRaw(const char *pszMsz, int nChars = 0); + void Echo(const char *pszMsz, int nChars = 0); + const char *GetLine(); int GetWidth(); void SetVisible(bool visible); diff --git a/rehlds/common/commandline.cpp b/rehlds/common/commandline.cpp index 9be292c..4fc4970 100644 --- a/rehlds/common/commandline.cpp +++ b/rehlds/common/commandline.cpp @@ -61,7 +61,6 @@ char *CopyString(const char *src) void CCommandLine::CreateCmdLine(int argc, const char *argv[]) { char cmdline[4096] = ""; - const int MAX_CHARS = sizeof(cmdline) - 1; for (int i = 0; i < argc; ++i) { @@ -88,7 +87,10 @@ void CCommandLine::LoadParametersFromFile(const char *&pSrc, char *&pDst, int ma // Suck out the file name char szFileName[ MAX_PATH ]; char *pOut; + +#if 0 char *pDestStart = pDst; +#endif // Skip the @ sign pSrc++; @@ -342,7 +344,7 @@ const char *CCommandLine::CheckParm(const char *psz, char **ppszValue) const sz[i] = p2[i]; i++; - } while (i < sizeof(sz)); + } while ((unsigned)i < sizeof(sz)); sz[i] = '\0'; *ppszValue = sz; diff --git a/rehlds/common/stdc++compat.cpp b/rehlds/common/stdc++compat.cpp index 6177fee..1937b9b 100644 --- a/rehlds/common/stdc++compat.cpp +++ b/rehlds/common/stdc++compat.cpp @@ -1,15 +1,23 @@ #include +#include -#if !defined(_WIN32) -void NORETURN Sys_Error(const char *error, ...); +#if !defined(_WIN32) && !defined(BUILD_STATIC_LIBSTDC) // if build with static libstdc++ then ignore // This file adds the necessary compatibility tricks to avoid symbols with // version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with libstdc++ 4.6.1. namespace std { + +#if __cpp_exceptions + logic_error::logic_error(const char *__arg) : exception(), _M_msg(__arg) {} + out_of_range::out_of_range(const char *__arg) : logic_error(__arg) {} + out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {} +#endif // #if __cpp_exceptions + // We shouldn't be throwing exceptions at all, but it sadly turns out we call STL (inline) functions that do. void __throw_out_of_range_fmt(const char *fmt, ...) { + #if __cpp_exceptions va_list ap; char buf[1024]; // That should be big enough. @@ -18,16 +26,43 @@ namespace std buf[sizeof(buf) - 1] = '\0'; va_end(ap); - Sys_Error(buf); + throw std::out_of_range(buf); + #else + abort(); + #endif } }; // namespace std -// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, -// but that's equivalent, version-wise. Those calls are added by the compiler +// Was added in GCC 4.9 +// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, but that's equivalent, version-wise. +// Those calls are added by the compiler // itself on `new Class[n]` calls. extern "C" void __cxa_throw_bad_array_new_length() { - Sys_Error("Bad array new length."); +#if __cpp_exceptions + throw std::bad_array_new_length(); +#else + abort(); +#endif } + +#if defined(__INTEL_COMPILER) && __cplusplus >= 201402L +// This operator delete sized deallocations was added in c++14 +// and required at least not less than CXXABI_1.3.9 +// we should to keep CXXABI_1.3.8 for binary compatibility with oldest libstdc++. +// GCC and Clang allow to compile C++14 code with -fno-sized-deallocation to disable the new feature, but ICC isn't allow +// so that our C++14 library code would never call that version of operator delete, +// for ICC compiler we must override those operators for static linking to the library. +void operator delete[](void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} + +void operator delete(void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} +#endif + #endif // !defined(_WIN32) diff --git a/rehlds/common/textconsole.cpp b/rehlds/common/textconsole.cpp index 45d13d7..b996eec 100644 --- a/rehlds/common/textconsole.cpp +++ b/rehlds/common/textconsole.cpp @@ -74,7 +74,7 @@ void CTextConsole::ShutDown() ; } -void CTextConsole::Print(char *pszMsg) +void CTextConsole::Print(const char *pszMsg) { if (m_nConsoleTextLen) { @@ -264,7 +264,7 @@ void CTextConsole::ReceiveStandardChar(const char ch) int nCount; // If the line buffer is maxed out, ignore this char - if (m_nConsoleTextLen >= (sizeof(m_szConsoleText) - 2)) + if ((unsigned)m_nConsoleTextLen >= (sizeof(m_szConsoleText) - 2)) { return; } diff --git a/rehlds/common/textconsole.h b/rehlds/common/textconsole.h index 9d1b67e..d9d673b 100644 --- a/rehlds/common/textconsole.h +++ b/rehlds/common/textconsole.h @@ -39,16 +39,16 @@ public: virtual bool Init(IBaseSystem *system = nullptr); virtual void ShutDown(); - virtual void Print(char *pszMsg); + virtual void Print(const char *pszMsg); - virtual void SetTitle(char *pszTitle) {} - virtual void SetStatusLine(char *pszStatus) {} + virtual void SetTitle(const char *pszTitle) {} + virtual void SetStatusLine(const char *pszStatus) {} virtual void UpdateStatus() {} // Must be provided by children - virtual void PrintRaw(char *pszMsg, int nChars = 0) = 0; - virtual void Echo(char *pszMsg, int nChars = 0) = 0; - virtual char *GetLine() = 0; + virtual void PrintRaw(const char *pszMsg, int nChars = 0) = 0; + virtual void Echo(const char *pszMsg, int nChars = 0) = 0; + virtual const char *GetLine() = 0; virtual int GetWidth() = 0; virtual void SetVisible(bool visible); @@ -92,4 +92,4 @@ protected: #include "TextConsoleUnix.h" #endif // defined(_WIN32) -void Sys_Printf(char *fmt, ...); +void Sys_Printf(const char *fmt, ...); diff --git a/rehlds/dedicated/CMakeLists.txt b/rehlds/dedicated/CMakeLists.txt new file mode 100644 index 0000000..936734c --- /dev/null +++ b/rehlds/dedicated/CMakeLists.txt @@ -0,0 +1,122 @@ +cmake_minimum_required(VERSION 3.1) +project(hlds CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -rdynamic -fPIC options +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +set(LINK_FLAGS "${LINK_FLAGS} -no-pie -Wl,--no-export-dynamic") + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${COMPILE_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3\ + -fpermissive -fno-sized-deallocation\ + -Wno-unused-result") + + # Check if not Clang compiler AND GCC >= 8.3 + if (NOT "$ENV{CXX}" MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation") + endif() +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../" +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../engine" + "${PROJECT_SOURCE_DIR}/../common" + "${PROJECT_SOURCE_DIR}/../public" + "${PROJECT_SOURCE_DIR}/../public/rehlds" +) + +set(DEDICATED_SRCS + "src/dbg.cpp" + "src/dedicated_exports.cpp" + "src/public_amalgamation.cpp" + "src/sys_ded.cpp" + "src/sys_linux.cpp" + "src/vgui/vguihelpers.cpp" +) + +set(COMMON_SRCS + "../common/textconsole.cpp" + "../common/TextConsoleUnix.cpp" + "../common/SteamAppStartUp.cpp" + "../common/ObjectList.cpp" + "../common/commandline.cpp" + "../common/minidump.cpp" + "../engine/mem.cpp" +) + +if (NOT TARGET appversion) + add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/../version/appversion.sh" "${PROJECT_SOURCE_DIR}/../..") +endif() + +add_executable(hlds ${appversion.sh} ${DEDICATED_SRCS}) +add_dependencies(hlds appversion) + +target_include_directories(hlds PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(hlds PRIVATE + LAUNCHER_FIXES + _CONSOLE + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _stricmp=strcasecmp + _strnicmp=strncasecmp + _strdup=strdup + _vsnprintf=vsnprintf +) + +target_sources(hlds PRIVATE + ${COMMON_SRCS} +) + +target_link_libraries(hlds PRIVATE + dl +) + +set_target_properties(hlds PROPERTIES + OUTPUT_NAME hlds_linux + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/dedicated/README.md b/rehlds/dedicated/README.md index 63a472a..86a4d6c 100644 --- a/rehlds/dedicated/README.md +++ b/rehlds/dedicated/README.md @@ -2,15 +2,3 @@ ## What is this? Dedicated Server Launcher for Goldsrc based games - -### Building -On Windows: -
gradlew --max-workers=1 clean rehlds/dedicated:build
- -On Linux (ICC): -
./gradlew --max-workers=1 clean rehlds/dedicated:build
- -On Linux (GCC): -
./gradlew --max-workers=1 -PuseGcc clean rehlds/dedicated:build
- -Compiled binaries will be placed in the rehlds/dedicated/build/binaries/ directory diff --git a/rehlds/dedicated/build.gradle b/rehlds/dedicated/build.gradle deleted file mode 100644 index d5092e4..0000000 --- a/rehlds/dedicated/build.gradle +++ /dev/null @@ -1,173 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeExecutableSpec -import org.gradle.nativeplatform.NativeExecutableBinarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: 'windows-resources' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -List getRcCompileTasks(NativeBinarySpec binary) -{ - def linkTask = GradleCppUtils.getLinkTask(binary) - def res = linkTask.taskDependencies.getDependencies(linkTask).findAll { Task t -> t instanceof WindowsResourceCompile } - return res as List -} - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/src', '/../engine', '/../common', '/../public', '/../public/rehlds', '/../'); - - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'LAUNCHER_FIXES', '_CONSOLE' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'dedicated_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS'); - - cfg.linkerOptions.args('/SUBSYSTEM:WINDOWS,5.01'); - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF', '/GR-'; - cfg.extraLibs "ws2_32.lib", "winmm.lib", "user32.lib", "advapi32.lib", "shell32.lib" - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'dedicated_pch' - ); - } - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.linkerOptions.args '-no-pie' - cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions' - cfg.extraLibs 'dl' - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - dedicated(NativeExecutableSpec) { - targetPlatform 'x86' - baseName GradleCppUtils.windows ? 'hlds' : 'hlds_linux' - - sources { - dedicated_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - if (GradleCppUtils.windows) { - exclude "sys_linux.cpp" - } else { - exclude "sys_window.cpp", "conproc.cpp" - } - } - exportedHeaders { - srcDirs "vgui" - } - } - dedicated_common(CppSourceSet) { - source { - srcDir "../common" - include "ObjectList.cpp" - include "SteamAppStartUp.cpp" - include "textconsole.cpp" - include "commandline.cpp" - include "minidump.cpp" - if (GradleCppUtils.windows) { - include "TextConsoleWin32.cpp" - } - else { - include "TextConsoleUnix.cpp" - } - } - } - dedicated_engine(CppSourceSet) { - source { - srcDir "../engine" - include "mem.cpp" - } - } - dedicated_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - } - } - rc { - source { - srcDir "msvc" - include "dedicated.rc" - } - exportedHeaders { - srcDirs "msvc" - } - } - } - - binaries.all { - NativeExecutableBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFixes { - dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} diff --git a/rehlds/dedicated/msvc/dedicated.vcxproj b/rehlds/dedicated/msvc/dedicated.vcxproj index 96c4544..327d295 100644 --- a/rehlds/dedicated/msvc/dedicated.vcxproj +++ b/rehlds/dedicated/msvc/dedicated.vcxproj @@ -5,10 +5,6 @@ Debug Win32
- - Release Swds - Win32 - Release Win32 @@ -40,16 +36,6 @@ true MultiByte - - Application - false - v120_xp - v140_xp - v141_xp - v142 - true - MultiByte - @@ -59,9 +45,6 @@ - - - true @@ -71,10 +54,6 @@ false hlds - - false - hlds - Use @@ -91,12 +70,6 @@ true ws2_32.lib;winmm.lib;%(AdditionalDependencies) - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - - - Setup version from Git revision - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") @@ -136,57 +109,6 @@ true ws2_32.lib;winmm.lib;%(AdditionalDependencies) - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - - - Setup version from Git revision - - - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") - - - Automatic deployment script - - - echo Empty Action - Force build to run Pre-Build event - build.always.run - build.always.run - - - - - Level3 - Use - Full - true - true - WIN32;LAUNCHER_FIXES;NDEBUG;DEDICATED;_CRT_SECURE_NO_WARNINGS;USE_BREAKPAD_HANDLER;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..\src;$(ProjectDir)..\..\;$(ProjectDir)..\..\common;$(ProjectDir)..\..\engine;$(ProjectDir)..\..\public;$(ProjectDir)..\..\public\rehlds;%(AdditionalIncludeDirectories) - MultiThreaded - false - StreamingSIMDExtensions2 - - - AnySuitable - true - true - precompiled.h - - - Windows - true - true - true - ws2_32.lib;winmm.lib;%(AdditionalDependencies) - - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - - - Setup version from Git revision - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") @@ -208,7 +130,6 @@ true true - true @@ -230,7 +151,6 @@ true true - true @@ -239,14 +159,12 @@ Create Create - Create true true - true @@ -254,7 +172,12 @@ + + + {6973dca5-253c-4d84-b51e-187e035eae06} + + - + \ No newline at end of file diff --git a/rehlds/dedicated/src/dedicated_exports.cpp b/rehlds/dedicated/src/dedicated_exports.cpp index f248d9c..060e007 100644 --- a/rehlds/dedicated/src/dedicated_exports.cpp +++ b/rehlds/dedicated/src/dedicated_exports.cpp @@ -30,12 +30,12 @@ class CDedicatedExports: public IDedicatedExports { public: - EXT_FUNC void Sys_Printf(char *text); + EXT_FUNC void Sys_Printf(const char *text); }; EXPOSE_SINGLE_INTERFACE(CDedicatedExports, IDedicatedExports, VENGINE_DEDICATEDEXPORTS_API_VERSION); -void CDedicatedExports::Sys_Printf(char *text) +void CDedicatedExports::Sys_Printf(const char *text) { ::Sys_Printf_Safe(text); } diff --git a/rehlds/dedicated/src/isys.h b/rehlds/dedicated/src/isys.h index e973916..fc4a0fe 100644 --- a/rehlds/dedicated/src/isys.h +++ b/rehlds/dedicated/src/isys.h @@ -36,18 +36,18 @@ public: virtual bool GetExecutableName(char *out) = 0; virtual void ErrorMessage(int level, const char *msg) = 0; - virtual void WriteStatusText(char *szText) = 0; + virtual void WriteStatusText(const char *szText) = 0; virtual void UpdateStatus(int force) = 0; - virtual long LoadLibrary(char *lib) = 0; + virtual long LoadLibrary(const char *lib) = 0; virtual void FreeLibrary(long library) = 0; virtual bool CreateConsoleWindow(void) = 0; virtual void DestroyConsoleWindow(void) = 0; - virtual void ConsoleOutput(char *string) = 0; - virtual char *ConsoleInput(void) = 0; - virtual void Printf(char *fmt, ...) = 0; + virtual void ConsoleOutput(const char *string) = 0; + virtual const char *ConsoleInput(void) = 0; + virtual void Printf(const char *fmt, ...) = 0; }; extern ISys *sys; diff --git a/rehlds/dedicated/src/public_amalgamation.cpp b/rehlds/dedicated/src/public_amalgamation.cpp index 1fc308c..5047b3e 100644 --- a/rehlds/dedicated/src/public_amalgamation.cpp +++ b/rehlds/dedicated/src/public_amalgamation.cpp @@ -1,3 +1,4 @@ #include "precompiled.h" #include "interface.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/dedicated/src/sys_ded.cpp b/rehlds/dedicated/src/sys_ded.cpp index df0cfea..eae9147 100644 --- a/rehlds/dedicated/src/sys_ded.cpp +++ b/rehlds/dedicated/src/sys_ded.cpp @@ -40,7 +40,7 @@ CSysModule *g_pFileSystemModule = nullptr; CreateInterfaceFn g_FilesystemFactoryFn; -void Sys_Printf_Safe(char *text) +void Sys_Printf_Safe(const char *text) { if (sys) { @@ -48,7 +48,7 @@ void Sys_Printf_Safe(char *text) } } -void Sys_Printf(char *fmt, ...) +void Sys_Printf(const char *fmt, ...) { // Dump text to debugging console. va_list argptr; @@ -76,7 +76,7 @@ void ProcessConsoleInput() if (!engineAPI) return; - char *inputLine = console.GetLine(); + const char *inputLine = console.GetLine(); if (inputLine) { char szBuf[256]; @@ -85,7 +85,7 @@ void ProcessConsoleInput() } } -char *UTIL_GetBaseDir() +const char *UTIL_GetBaseDir() { return "."; } diff --git a/rehlds/dedicated/src/sys_ded.h b/rehlds/dedicated/src/sys_ded.h index 17603e9..b0912f8 100644 --- a/rehlds/dedicated/src/sys_ded.h +++ b/rehlds/dedicated/src/sys_ded.h @@ -38,5 +38,5 @@ extern CreateInterfaceFn g_FilesystemFactoryFn; int RunEngine(); int StartServer(char* cmdline); -void Sys_Printf_Safe(char *text); -void Sys_Printf(char *fmt, ...); +void Sys_Printf_Safe(const char *text); +void Sys_Printf(const char *fmt, ...); diff --git a/rehlds/dedicated/src/sys_linux.cpp b/rehlds/dedicated/src/sys_linux.cpp index 5a0cf11..814eb18 100644 --- a/rehlds/dedicated/src/sys_linux.cpp +++ b/rehlds/dedicated/src/sys_linux.cpp @@ -37,18 +37,18 @@ public: bool GetExecutableName(char *out) override; NORETURN void ErrorMessage(int level, const char *msg) override; - void WriteStatusText(char *szText) override; + void WriteStatusText(const char *szText) override; void UpdateStatus(int force) override; - long LoadLibrary(char *lib) override; + long LoadLibrary(const char *lib) override; void FreeLibrary(long library) override; bool CreateConsoleWindow() override; void DestroyConsoleWindow() override; - void ConsoleOutput(char *string) override; - char *ConsoleInput() override; - void Printf(char *fmt, ...) override; + void ConsoleOutput(const char *string) override; + const char *ConsoleInput() override; + void Printf(const char *fmt, ...) override; }; CSys g_Sys; @@ -206,7 +206,7 @@ void CSys::ErrorMessage(int level, const char *msg) exit(-1); } -void CSys::WriteStatusText(char *szText) +void CSys::WriteStatusText(const char *szText) { } @@ -214,7 +214,7 @@ void CSys::UpdateStatus(int force) { } -long CSys::LoadLibrary(char *lib) +long CSys::LoadLibrary(const char *lib) { char cwd[1024]; char absolute_lib[1024]; @@ -258,18 +258,18 @@ void CSys::DestroyConsoleWindow() } // Print text to the dedicated console -void CSys::ConsoleOutput(char *string) +void CSys::ConsoleOutput(const char *string) { printf("%s", string); fflush(stdout); } -char *CSys::ConsoleInput() +const char *CSys::ConsoleInput() { return console.GetLine(); } -void CSys::Printf(char *fmt, ...) +void CSys::Printf(const char *fmt, ...) { // Dump text to debugging console. va_list argptr; diff --git a/rehlds/dedicated/src/sys_window.cpp b/rehlds/dedicated/src/sys_window.cpp index aa09d5f..02661d7 100644 --- a/rehlds/dedicated/src/sys_window.cpp +++ b/rehlds/dedicated/src/sys_window.cpp @@ -37,18 +37,18 @@ public: bool GetExecutableName(char *out) override; void ErrorMessage(int level, const char *msg) override; - void WriteStatusText(char *szText) override; + void WriteStatusText(const char *szText) override; void UpdateStatus(int force) override; - long LoadLibrary(char *lib) override; + long LoadLibrary(const char *lib) override; void FreeLibrary(long library) override; bool CreateConsoleWindow() override; void DestroyConsoleWindow() override; - void ConsoleOutput(char *string) override; - char *ConsoleInput() override; - void Printf(char *fmt, ...) override; + void ConsoleOutput(const char *string) override; + const char *ConsoleInput() override; + void Printf(const char *fmt, ...) override; }; CSys g_Sys; @@ -60,10 +60,16 @@ CSys::CSys() WORD version = MAKEWORD(2, 0); WSADATA wsaData; WSAStartup(version, &wsaData); + + // Request 1ms resolution for windows timer + timeBeginPeriod(1); } CSys::~CSys() { + // Clear previously set timer resolution + timeEndPeriod(1); + WSACleanup(); sys = nullptr; } @@ -87,7 +93,7 @@ void CSys::ErrorMessage(int level, const char *msg) PostQuitMessage(0); } -void CSys::WriteStatusText(char *szText) +void CSys::WriteStatusText(const char *szText) { SetConsoleTitle(szText); } @@ -119,7 +125,7 @@ void CSys::UpdateStatus(int force) console.UpdateStatus(); } -long CSys::LoadLibrary(char *lib) +long CSys::LoadLibrary(const char *lib) { void *hDll = ::LoadLibrary(lib); return (long)hDll; @@ -154,7 +160,7 @@ void CSys::DestroyConsoleWindow() DeinitConProc(); } -void CSys::ConsoleOutput(char *string) +void CSys::ConsoleOutput(const char *string) { if (g_bVGui) { @@ -166,12 +172,12 @@ void CSys::ConsoleOutput(char *string) } } -char *CSys::ConsoleInput() +const char *CSys::ConsoleInput() { return console.GetLine(); } -void CSys::Printf(char *fmt, ...) +void CSys::Printf(const char *fmt, ...) { // Dump text to debugging console. va_list argptr; diff --git a/rehlds/engine/SystemWrapper.cpp b/rehlds/engine/SystemWrapper.cpp index 83aa088..f20168f 100644 --- a/rehlds/engine/SystemWrapper.cpp +++ b/rehlds/engine/SystemWrapper.cpp @@ -54,7 +54,7 @@ BOOL SystemWrapper_LoadModule(char *interfacename, char *library, char *instance return FALSE; } -void SystemWrapper_ExecuteString(char *command) +void SystemWrapper_ExecuteString(const char *command) { gSystemWrapper.ExecuteString(command); } @@ -234,7 +234,7 @@ void SystemWrapper::CMD_UnloadModule(char *cmdLine) SystemWrapper::library_t *SystemWrapper::GetLibrary(char *name) { - char fixedname[MAX_PATH]; + char fixedname[MAX_PATH-4]; // reserve for extension so/dll Q_strlcpy(fixedname, name); COM_FixSlashes(fixedname); @@ -550,49 +550,57 @@ bool SystemWrapper::RemoveModule(ISystemModule *module) return false; } -void SystemWrapper::ExecuteString(char *commands) +void SystemWrapper::ExecuteString(const char *commands) { if (!commands || !commands[0]) return; - int size = 0; - char singleCmd[256] = ""; - bool quotes = false; - char *p = singleCmd; - char *c = commands; + // Remove format characters to block format string attacks + COM_RemoveEvilChars(const_cast(commands)); - COM_RemoveEvilChars(c); - while (true) + bool bInQuote = false; + + char *pszDest; + char singleCmd[256] = {0}; + + const char *pszSource = commands; + while (*pszSource) { - *p = *c; + // Parse out single commands and execute them + pszDest = singleCmd; - if (++size >= sizeof(singleCmd)) + unsigned int i; + for (i = 0; i < ARRAYSIZE(singleCmd); i++) { - DPrintf("WARNING! System::ExecuteString: Command token too long.\n"); - break; + const char c = *pszSource; + + if (c == '"') + { + bInQuote = !bInQuote; + } + else if ((c == ';' && !bInQuote) || !c) + { + // End of command and not in a quoted string + break; + } + + *pszDest++ = c; + pszSource++; } - if (*c == '"') - quotes = !quotes; - - if ((*c != ';' || quotes) && *c) + if (i >= ARRAYSIZE(singleCmd)) { - ++p; - } - else - { - *p = '\0'; - - char *cmd = singleCmd; - while (*cmd == ' ') { cmd++; } - - DispatchCommand(cmd); - p = singleCmd; - size = 0; + Printf("WARNING! System::ExecuteString: Command token too long.\n"); + return; } - if (!*c++) - break; + *pszDest = '\0'; + + char *pszCmd = singleCmd; + while (*pszCmd == ' ') + pszCmd++; // skip leading whitespaces + + DispatchCommand(pszCmd); } } @@ -699,7 +707,7 @@ void EngineWrapper::DemoUpdateClientData(client_data_t *cdat) void EngineWrapper::CL_QueueEvent(int flags, int index, float delay, event_args_t *pargs) { #ifndef SWDS - CL_QueueEvent(flags, index, delay, pargs); + ::CL_QueueEvent(flags, index, delay, pargs); #endif // SWDS } @@ -713,14 +721,14 @@ void EngineWrapper::HudWeaponAnim(int iAnim, int body) void EngineWrapper::CL_DemoPlaySound(int channel, char *sample, float attenuation, float volume, int flags, int pitch) { #ifndef SWDS - CL_DemoPlaySound(channel, sample, attenuation, volume, flags, pitch); + ::CL_DemoPlaySound(channel, sample, attenuation, volume, flags, pitch); #endif // SWDS } void EngineWrapper::ClientDLL_ReadDemoBuffer(int size, unsigned char *buffer) { #ifndef SWDS - ClientDLL_ReadDemoBuffer(); + ::ClientDLL_ReadDemoBuffer(); #endif // SWDS } @@ -741,7 +749,7 @@ char *EngineWrapper::GetStatusLine() void EngineWrapper::Cbuf_AddText(char *text) { - Cbuf_AddText(text); + ::Cbuf_AddText(text); } #ifdef REHLDS_FIXES diff --git a/rehlds/engine/SystemWrapper.h b/rehlds/engine/SystemWrapper.h index 9cbcb7c..fd5c5fc 100644 --- a/rehlds/engine/SystemWrapper.h +++ b/rehlds/engine/SystemWrapper.h @@ -93,7 +93,7 @@ public: EXT_FUNC Panel *GetPanel(); EXT_FUNC bool RegisterCommand(char *name, ISystemModule *module, int commandID); EXT_FUNC void GetCommandMatches(char *string, ObjectList *pMatchList); - EXT_FUNC void ExecuteString(char *commands); + EXT_FUNC void ExecuteString(const char *commands); EXT_FUNC void ExecuteFile(char *filename); EXT_FUNC void Errorf(char *fmt, ...); EXT_FUNC char *CheckParam(char *param); @@ -146,7 +146,7 @@ void SystemWrapper_Init(); void SystemWrapper_ShutDown(); void SystemWrapper_RunFrame(double time); BOOL SystemWrapper_LoadModule(char *interfacename, char *library, char *instancename = nullptr); -void SystemWrapper_ExecuteString(char *command); +void SystemWrapper_ExecuteString(const char *command); void SystemWrapper_CommandForwarder(); int COM_BuildNumber(); diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 808d583..7dcf76c 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -164,8 +164,9 @@ void Cbuf_Execute(void) { int i; char *text; - char line[MAX_CMD_LINE]; + char line[MAX_CMD_LINE] = {0}; int quotes; + bool commented; while (cmd_text.cursize) { @@ -173,12 +174,21 @@ void Cbuf_Execute(void) text = (char *)cmd_text.data; quotes = 0; + commented = false; + +#ifdef REHLDS_FIXES + if (cmd_text.cursize > 1 && text[0] == '/' && text[1] == '/') + commented = true; +#endif + for (i = 0; i < cmd_text.cursize; i++) { if (text[i] == '"') quotes++; - if (!(quotes & 1) && text[i] == ';') - break; // don't break if inside a quoted string + + if (!(quotes & 1) && !commented && text[i] == ';') + break; // don't break if inside a quoted or commented out strings + if (text[i] == '\n') break; } @@ -491,7 +501,7 @@ void Cmd_Alias_f(void) // Gather arguments into one string cmd[0] = 0; c = Cmd_Argc(); - for (i = 2; i <= c; i++) + for (i = 2; i < c; i++) { Q_strncat(cmd, Cmd_Argv(i), MAX_CMD_LINE - 2 - Q_strlen(cmd)); // always have a space for \n or ' ' and \0 diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index c68a11c..c9f07a6 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -1033,10 +1033,24 @@ float MSG_ReadFloat(void) { float f; + union + { + unsigned char b[4]; + float f; + int l; + } dat; + if (msg_readcount + 4 <= net_message.cursize) { - f = *((float*)LittleLong(*(int *)&net_message.data[msg_readcount])); + dat.b[0] = net_message.data[msg_readcount]; + dat.b[1] = net_message.data[msg_readcount + 1]; + dat.b[2] = net_message.data[msg_readcount + 2]; + dat.b[3] = net_message.data[msg_readcount + 3]; msg_readcount += 4; + + dat.l = LittleLong(dat.l); + + return dat.f; } else { @@ -1150,6 +1164,22 @@ void SZ_Clear(sizebuf_t *buf) buf->cursize = 0; } +qboolean SZ_HasSpaceToRead(const sizebuf_t *buf, int length) +{ + if ((msg_readcount + length) > buf->maxsize) + return FALSE; + + return TRUE; +} + +qboolean SZ_HasSomethingToRead(const sizebuf_t *buf, int length) +{ + if ((msg_readcount + length) > buf->cursize) + return FALSE; + + return TRUE; +} + void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) { void *data; @@ -2266,23 +2296,35 @@ void COM_ListMaps(char *pszSubString) while (findfn != NULL) { - Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn); - FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir)); - - if (strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen))) + if (Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn) < ARRAYSIZE(curDir)) { - Q_memset(&header, 0, sizeof(dheader_t)); - Q_sprintf(pFileName, "maps/%s", findfn); + FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir)); - fp = FS_Open(pFileName, "rb"); - - if (fp) + if (Q_strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen))) { - FS_Read(&header, sizeof(dheader_t), 1, fp); - FS_Close(fp); - } + if (Q_snprintf(pFileName, ARRAYSIZE(pFileName), "maps/%s", findfn) < ARRAYSIZE(pFileName)) + { + Q_memset(&header, 0, sizeof(dheader_t)); - COM_CheckPrintMap(&header, findfn, bShowOutdated != 0); + fp = FS_Open(pFileName, "rb"); + + if (fp) + { + FS_Read(&header, sizeof(dheader_t), 1, fp); + FS_Close(fp); + } + + COM_CheckPrintMap(&header, findfn, bShowOutdated != 0); + } + else + { + Con_Printf("Map name too long: %s\n", findfn); + } + } + } + else + { + Con_Printf("Map name too long: %s\n", findfn); } findfn = Sys_FindNext(NULL); @@ -2367,7 +2409,7 @@ void EXT_FUNC COM_GetGameDir(char *szGameDir) { if (szGameDir) { - Q_snprintf(szGameDir, MAX_PATH - 1 , "%s", com_gamedir); + Q_snprintf(szGameDir, MAX_PATH, "%s", com_gamedir); } } diff --git a/rehlds/engine/common.h b/rehlds/engine/common.h index 2d81b3f..22d07e9 100644 --- a/rehlds/engine/common.h +++ b/rehlds/engine/common.h @@ -159,6 +159,8 @@ void MSG_ReadUsercmd(usercmd_t *to, usercmd_t *from); void SZ_Alloc(const char *name, sizebuf_t *buf, int startsize); void SZ_Clear(sizebuf_t *buf); +qboolean SZ_HasSpaceToRead(const sizebuf_t *buf, int length); +qboolean SZ_HasSomethingToRead(const sizebuf_t *buf, int length); void *SZ_GetSpace(sizebuf_t *buf, int length); void SZ_Write(sizebuf_t *buf, const void *data, int length); void SZ_Print(sizebuf_t *buf, const char *data); diff --git a/rehlds/engine/crc.cpp b/rehlds/engine/crc.cpp index 6bb1f32..df6f52b 100644 --- a/rehlds/engine/crc.cpp +++ b/rehlds/engine/crc.cpp @@ -227,7 +227,11 @@ int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName) return 0; } i = LittleLong(header.version); - if (i != HLBSP_VERSION) + if ( +#ifdef REHLDS_FIXES + i != Q1BSP_VERSION && +#endif + i != HLBSP_VERSION) { Con_Printf("Map [%s] has incorrect BSP version (%i should be %i).\n", pszFileName, i, HLBSP_VERSION); FS_Close(fp); diff --git a/rehlds/engine/cvar.cpp b/rehlds/engine/cvar.cpp index 37d18ed..9285fa2 100644 --- a/rehlds/engine/cvar.cpp +++ b/rehlds/engine/cvar.cpp @@ -430,11 +430,9 @@ NOXREF void Cvar_RemoveHudCvars(void) const char *Cvar_IsMultipleTokens(const char *varname) { static char firstToken[516]; - int tokens; char *name; firstToken[0] = 0; - tokens = 0; name = (char *)varname; name = COM_Parse(name); diff --git a/rehlds/engine/decals.cpp b/rehlds/engine/decals.cpp index ff382ea..975d7f9 100644 --- a/rehlds/engine/decals.cpp +++ b/rehlds/engine/decals.cpp @@ -538,15 +538,17 @@ void Decal_Init(void) for (i = 0; i < ARRAYSIZE(pszPathID); i++) { hfile = FS_OpenPathID("decals.wad", "rb", pszPathID[i]); -#ifdef REHLDS_FIXES + if (!hfile) + { +#ifdef REHLDS_FIXES if (found || i < ARRAYSIZE(pszPathID) - 1) continue; - else #else - if (i == 0 && !hfile) + if (i == 0) #endif - Sys_Error("%s: Couldn't find '%s' in \"%s\" search path\n", __func__, "decals.wad", pszPathID[i]); + Sys_Error("%s: Couldn't find '%s' in \"%s\" search path\n", __func__, "decals.wad", pszPathID[i]); + } #ifdef REHLDS_FIXES found = true; diff --git a/rehlds/engine/delta.cpp b/rehlds/engine/delta.cpp index 6f81baf..5a63b08 100644 --- a/rehlds/engine/delta.cpp +++ b/rehlds/engine/delta.cpp @@ -82,13 +82,13 @@ static delta_definition_t g_DeltaDataDefinition[] = static delta_description_t g_MetaDescription[] = { - { DT_INTEGER, DELTA_D_DEF(fieldType), 1, 32, 1.0, 1.0, 0, 0, 0 }, - { DT_STRING, DELTA_D_DEF(fieldName), 1, 1, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldOffset), 1, 16, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldSize), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(significant_bits), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(premultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(postmultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 }, + { DT_INTEGER, DELTA_D_DEF(fieldType), 1, 32, 1.0, 1.0, 0, {0, 0} }, + { DT_STRING, DELTA_D_DEF(fieldName), 1, 1, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(fieldOffset), 1, 16, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(fieldSize), 1, 8, 1.0, 1.0, 0, {0, 0} }, + { DT_INTEGER, DELTA_D_DEF(significant_bits), 1, 8, 1.0, 1.0, 0, {0, 0} }, + { DT_FLOAT, DELTA_D_DEF(premultiply), 1, 32, 4000.0, 1.0, 0, {0, 0} }, + { DT_FLOAT, DELTA_D_DEF(postmultiply), 1, 32, 4000.0, 1.0, 0, {0, 0} }, }; delta_t g_MetaDelta[] = @@ -463,7 +463,7 @@ int DELTA_TestDelta(unsigned char *from, unsigned char *to, delta_t *pFields) case DT_STRING: st1 = (char*)&from[pTest->fieldOffset]; st2 = (char*)&to[pTest->fieldOffset]; - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) // Not sure why it is case insensitive, but it looks so + if (!((!*st1 && !*st2) || (*st1 && *st2 && !Q_stricmp(st1, st2)))) // Not sure why it is case insensitive, but it looks so { #ifndef REHLDS_FIXES pTest->flags |= FDT_MARK; @@ -558,7 +558,7 @@ void DELTA_MarkSendFields(unsigned char *from, unsigned char *to, delta_t *pFiel case DT_STRING: st1 = (char*)&from[pTest->fieldOffset]; st2 = (char*)&to[pTest->fieldOffset]; - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) // Not sure why it is case insensitive, but it looks so + if (!((!*st1 && !*st2) || (*st1 && *st2 && !Q_stricmp(st1, st2)))) // Not sure why it is case insensitive, but it looks so pTest->flags |= FDT_MARK; break; default: @@ -1239,7 +1239,7 @@ qboolean DELTA_ParseField(int count, delta_definition_t *pdefinition, delta_link Sys_Error("%s: Expecting fieldname\n", __func__); } - Q_strncpy(pField->delta->fieldName, com_token, 31); + Q_strlcpy(pField->delta->fieldName, com_token); pField->delta->fieldName[31] = 0; pField->delta->fieldOffset = DELTA_FindOffset(count, pdefinition, com_token); @@ -1454,8 +1454,7 @@ qboolean DELTA_ParseDescription(char *name, delta_t **ppdesc, char *pstream) } if (Q_stricmp(com_token, "none")) { - Q_strncpy(source, com_token, sizeof(source)-1); - source[sizeof(source)-1] = 0; + Q_strlcpy(source, com_token); // Parse custom encoder function name pstream = COM_Parse(pstream); @@ -1464,8 +1463,7 @@ qboolean DELTA_ParseDescription(char *name, delta_t **ppdesc, char *pstream) Sys_Error("%s: Expecting encoder\n", __func__); } - Q_strncpy(encoder, com_token, sizeof(encoder)-1); - encoder[sizeof(encoder)-1] = 0; + Q_strlcpy(encoder, com_token); } // Parse fields @@ -1496,7 +1494,7 @@ qboolean DELTA_ParseDescription(char *name, delta_t **ppdesc, char *pstream) if (encoder[0] != 0) { - Q_strncpy((*ppdesc)->conditionalencodename, encoder, sizeof((*ppdesc)->conditionalencodename) - 1); + Q_strlcpy((*ppdesc)->conditionalencodename, encoder); (*ppdesc)->conditionalencodename[sizeof((*ppdesc)->conditionalencodename) - 1] = 0; (*ppdesc)->conditionalencode = 0; } diff --git a/rehlds/engine/filesystem.cpp b/rehlds/engine/filesystem.cpp index 7d01f81..12c4a5a 100644 --- a/rehlds/engine/filesystem.cpp +++ b/rehlds/engine/filesystem.cpp @@ -241,7 +241,7 @@ void CheckLiblistForFallbackDir(const char *pGameDir, bool bLanguage, const char if (bLanguage && pLanguage) { - char baseDir[4096]; + char baseDir[MAX_PATH]; char *tempPtr; Q_snprintf(szTemp, 511, "%s/%s_%s", GetBaseDirectory(), szFallback, pLanguage); @@ -283,7 +283,7 @@ void CheckLiblistForFallbackDir(const char *pGameDir, bool bLanguage, const char if (Q_stricmp(szFallback, "valve")) { - const int BufLen = 128; + const int BufLen = 256; char *szFileName = new char[BufLen]; Q_snprintf(szFileName, BufLen - 1, "Resource/%s_%%language%%.txt", szFallback); @@ -298,7 +298,7 @@ void CheckLiblistForFallbackDir(const char *pGameDir, bool bLanguage, const char int FileSystem_SetGameDirectory(const char *pDefaultDir, const char *pGameDir) { char temp[512]; - char language[256]; + char language[128]; const char *pchLang; g_pFileSystem->RemoveAllSearchPaths(); @@ -474,7 +474,7 @@ int FileSystem_AddFallbackGameDir(const char *pGameDir) return 1; } -int FileSystem_Init(char *basedir, void *voidfilesystemFactory) +int FileSystem_Init(const char *basedir, void *voidfilesystemFactory) { #ifdef REHLDS_CHECKS Q_strncpy(s_pBaseDir, basedir, ARRAYSIZE(s_pBaseDir)); diff --git a/rehlds/engine/filesystem_.h b/rehlds/engine/filesystem_.h index 198cf5b..f171400 100644 --- a/rehlds/engine/filesystem_.h +++ b/rehlds/engine/filesystem_.h @@ -52,5 +52,5 @@ int Host_GetVideoLevel(void); void CheckLiblistForFallbackDir(const char *pGameDir, bool bLanguage, const char *pLanguage, bool bLowViolenceBuild_); int FileSystem_SetGameDirectory(const char *pDefaultDir, const char *pGameDir); int FileSystem_AddFallbackGameDir(const char *pGameDir); -int FileSystem_Init(char *basedir, void *voidfilesystemFactory); +int FileSystem_Init(const char *basedir, void *voidfilesystemFactory); void FileSystem_Shutdown(void); diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index e6e2bf9..f30cfad 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -1041,7 +1041,7 @@ void Host_Version(void) gpszVersionString[sizeof(gpszVersionString) - 1] = 0; if (COM_CheckParm("-steam")) { - char szSteamVersionId[32]; + char szSteamVersionId[16]; FS_GetInterfaceVersion(szSteamVersionId, sizeof(szSteamVersionId) - 1); Q_snprintf(gpszVersionString, sizeof(gpszVersionString), "%s/%s", &com_token[Q_strlen("PatchVersion=")], szSteamVersionId); gpszVersionString[sizeof(gpszVersionString) - 1] = 0; diff --git a/rehlds/engine/host_cmd.cpp b/rehlds/engine/host_cmd.cpp index 9cac571..d76815c 100644 --- a/rehlds/engine/host_cmd.cpp +++ b/rehlds/engine/host_cmd.cpp @@ -377,7 +377,7 @@ void Host_UpdateStats(void) fscanf(pFile, "%d %s %c %d %d %d %d %d %lu %lu \t\t\t%lu %lu %lu %ld %ld %ld %ld %ld %ld %lu \t\t\t%lu %ld %lu %lu %lu %lu %lu %lu %lu %lu \t\t\t%lu %lu %lu %lu %lu %lu", &dummy, statFile, - &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, + (char *)&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &ctime, &stime, &dummy, &dummy, &dummy, &dummy, &dummy, @@ -423,7 +423,12 @@ void GetStatsString(char *buf, int bufSize) for (int i = 0; i < g_psvs.maxclients; i++) { host_client = &g_psvs.clients[i]; - if (!host_client->active && !host_client->connected && !host_client->spawned || host_client->fakeclient) + + // Fake clients are ignored + if (host_client->fakeclient) + continue; + + if (!host_client->active && !host_client->connected && !host_client->spawned) continue; players++; diff --git a/rehlds/engine/iengine.h b/rehlds/engine/iengine.h index 10b30f4..eaa5243 100644 --- a/rehlds/engine/iengine.h +++ b/rehlds/engine/iengine.h @@ -42,7 +42,7 @@ public: virtual ~IEngine() {} - virtual bool Load(bool dedicated, char *basedir, char *cmdline) = 0; + virtual bool Load(bool dedicated, const char *basedir, const char *cmdline) = 0; virtual void Unload() = 0; virtual void SetState(int iState) = 0; virtual int GetState() = 0; diff --git a/rehlds/engine/mathlib_sse.cpp b/rehlds/engine/mathlib_sse.cpp index e99d85a..483a643 100644 --- a/rehlds/engine/mathlib_sse.cpp +++ b/rehlds/engine/mathlib_sse.cpp @@ -46,7 +46,7 @@ const avec4_t deg2rad = (float)M_PI / 180.f }; -const aivec4_t negmask[4] = +const aivec4_t negmask = { 0x80000000, 0x80000000, diff --git a/rehlds/engine/model.cpp b/rehlds/engine/model.cpp index 11b3214..a4581e5 100644 --- a/rehlds/engine/model.cpp +++ b/rehlds/engine/model.cpp @@ -152,7 +152,7 @@ model_t *Mod_FindName(qboolean trackCRC, const char *name) if (mod->needload == NL_UNREFERENCED) { - if (!avail || mod->type != mod_alias && mod->type != mod_studio) + if (!avail || (mod->type != mod_alias && mod->type != mod_studio)) avail = mod; } } @@ -866,10 +866,12 @@ void CalcSurfaceExtents(msurface_t *s) for (j = 0; j < 2; j++) { - val = v->position[0] * tex->vecs[j][0] + - v->position[1] * tex->vecs[j][1] + - v->position[2] * tex->vecs[j][2] + - tex->vecs[j][3]; + // FIXED: loss of floating point + val = v->position[0] * (double)tex->vecs[j][0] + + v->position[1] * (double)tex->vecs[j][1] + + v->position[2] * (double)tex->vecs[j][2] + + (double)tex->vecs[j][3]; + if (val < mins[j]) mins[j] = val; if (val > maxs[j]) @@ -1329,7 +1331,7 @@ void EXT_FUNC Mod_LoadBrushModel_internal(model_t *mod, void *buffer) if (i < mod->numsubmodels - 1) { - char name[10]; + char name[12]; Q_snprintf(name, ARRAYSIZE(name), "*%i", i + 1); loadmodel = Mod_FindName(0, name); diff --git a/rehlds/engine/net_chan.cpp b/rehlds/engine/net_chan.cpp index 28dabdd..5348b5e 100644 --- a/rehlds/engine/net_chan.cpp +++ b/rehlds/engine/net_chan.cpp @@ -412,7 +412,7 @@ void Netchan_Transmit(netchan_t *chan, int length, byte *data) // If it's not in-memory, then we'll need to copy it in frame the file handle. if (pbuf->isfile && !pbuf->isbuffer) { - char compressedfilename[MAX_PATH]; + char compressedfilename[MAX_PATH+5]; // room for extension string FileHandle_t hfile; if (pbuf->iscompressed) { diff --git a/rehlds/engine/net_ws.cpp b/rehlds/engine/net_ws.cpp index 76da8d5..219b73a 100644 --- a/rehlds/engine/net_ws.cpp +++ b/rehlds/engine/net_ws.cpp @@ -873,7 +873,7 @@ qboolean NET_QueuePacket(netsrc_t sock) for (int protocol = 0; protocol < 1; protocol++) #endif // _WIN32 { - SOCKET net_socket; + SOCKET net_socket = INV_SOCK; if (protocol == 0) net_socket = ip_sockets[sock]; diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index be18e51..df82bce 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -312,8 +312,12 @@ void EXT_FUNC PF_ambientsound_I(edict_t *entity, float *pos, const char *samp, f void EXT_FUNC PF_sound_I(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch) { +#ifdef REHLDS_FIXES + if (volume < 0.0f || volume > 1.0f) +#else if (volume < 0.0 || volume > 255.0) - Sys_Error("%s: volume = %i", __func__, volume); +#endif + Sys_Error("%s: volume = %f", __func__, volume); if (attenuation < 0.0 || attenuation > 4.0) Sys_Error("%s: attenuation = %f", __func__, attenuation); if (channel < 0 || channel > 7) @@ -384,7 +388,7 @@ void EXT_FUNC TraceSphere(const float *v1, const float *v2, int fNoMonsters, flo void EXT_FUNC TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr) { - int oldMovetype, oldSolid; + int oldMovetype = MOVETYPE_NONE, oldSolid = SOLID_NOT; if (hullNumber < 0 || hullNumber > 3) hullNumber = 0; @@ -1280,7 +1284,10 @@ void EXT_FUNC EV_Playback(int flags, const edict_t *pInvoker, unsigned short eve continue; } - if (cl == host_client && (flags & FEV_NOTHOST) && cl->lw || (flags & FEV_HOSTONLY) && cl->edict != pInvoker) + if ((flags & FEV_NOTHOST) && cl->lw && cl == host_client) + continue; + + if ((flags & FEV_HOSTONLY) && cl->edict != pInvoker) continue; if (flags & FEV_RELIABLE) diff --git a/rehlds/engine/r_studio.cpp b/rehlds/engine/r_studio.cpp index d841aee..5b12b83 100644 --- a/rehlds/engine/r_studio.cpp +++ b/rehlds/engine/r_studio.cpp @@ -187,9 +187,9 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt) cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3]; - if ((1.0 + cosom) > 0.00000001) + if ((1.0 + cosom) > 0.000001) { - if ((1.0 - cosom) > 0.00000001) + if ((1.0 - cosom) > 0.000001) { omega = acos(cosom); sinom = sin(omega); @@ -785,7 +785,7 @@ hull_t *SV_HullForStudioModel(const edict_t *pEdict, const vec_t *mins, const ve int iBlend; R_StudioPlayerBlend(pseqdesc, &iBlend, angles); - unsigned char blending = (unsigned char)iBlend; + unsigned char blending[2] = { (unsigned char)iBlend, 0 }; unsigned char controller[4] = { 0x7F, 0x7F, 0x7F, 0x7F }; return R_StudioHull( g_psv.models[pEdict->v.modelindex], @@ -795,7 +795,7 @@ hull_t *SV_HullForStudioModel(const edict_t *pEdict, const vec_t *mins, const ve pEdict->v.origin, size, controller, - &blending, + blending, pNumHulls, pEdict, bSkipShield); diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index b94f7c4..d444140 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -241,6 +241,7 @@ typedef struct client_s uint32 m_VoiceStreams[2]; double m_lastvoicetime; int m_sendrescount; + qboolean m_bSentNewResponse; } client_t; enum @@ -376,6 +377,7 @@ extern cvar_t sv_rehlds_userinfo_transmitted_fields; extern cvar_t sv_rehlds_attachedentities_playeranimationspeed_fix; extern cvar_t sv_rehlds_local_gametime; extern cvar_t sv_rehlds_send_mapcycle; +extern cvar_t sv_usercmd_custom_random_seed; #endif extern int sv_playermodel; diff --git a/rehlds/engine/sv_log.cpp b/rehlds/engine/sv_log.cpp index 48e8c43..ccd0fb1 100644 --- a/rehlds/engine/sv_log.cpp +++ b/rehlds/engine/sv_log.cpp @@ -119,7 +119,7 @@ void Log_Open(void) time_t ltime; struct tm *today; char szFileBase[MAX_PATH]; - char szTestFile[MAX_PATH]; + char szTestFile[MAX_PATH+8]; // room for extra string int i; FileHandle_t fp; char *temp; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 3bcca62..74a285f 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -209,6 +209,7 @@ cvar_t sv_rehlds_local_gametime = {"sv_rehlds_local_gametime", "0", 0, 0.0f, nul cvar_t sv_rehlds_send_mapcycle = { "sv_rehlds_send_mapcycle", "0", 0, 0.0f, nullptr }; cvar_t sv_rehlds_maxclients_from_single_ip = { "sv_rehlds_maxclients_from_single_ip", "5", 0, 5.0f, nullptr }; cvar_t sv_use_entity_file = { "sv_use_entity_file", "0", 0, 0.0f, nullptr }; +cvar_t sv_usercmd_custom_random_seed = { "sv_usercmd_custom_random_seed", "0", 0, 0.0f, nullptr }; #endif delta_t *SV_LookupDelta(char *name) @@ -1123,8 +1124,10 @@ void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client) unsigned char *mapcyclelist = COM_LoadFileForMe(mapcyclefile.string, &len); if (mapcyclelist && len) { - // Trim to 8190 (see MSG_ReadString, also 1 less than expected - see READ_STRING in HLSDK), otherwise client will be unable to parse message - mapcyclelist[8190] = 0; + // Trim to 8190 (see MSG_ReadString, also 1 less than expected), otherwise client will be unable to parse message + if (len > 8190) + mapcyclelist[8190] = 0; + MSG_WriteString(msg, (const char *)mapcyclelist); } else @@ -1495,7 +1498,7 @@ void SV_New_f(void) return; } - if (!host_client->active && host_client->spawned) + if ((host_client->hasusrmsgs && host_client->m_bSentNewResponse) || (!host_client->active && host_client->spawned)) { return; } @@ -1534,8 +1537,8 @@ void SV_New_f(void) gEntityInterface.pfnClientDisconnect(ent); } - Q_snprintf(szName, sizeof(szName), host_client->name); - Q_snprintf(szAddress, sizeof(szAddress), NET_AdrToString(host_client->netchan.remote_address)); + Q_snprintf(szName, sizeof(szName), "%s", host_client->name); + Q_snprintf(szAddress, sizeof(szAddress), "%s", NET_AdrToString(host_client->netchan.remote_address)); Q_snprintf(szRejectReason, sizeof(szRejectReason), "Connection rejected by game\n"); // Allow the game dll to reject this client. @@ -1561,6 +1564,7 @@ void SV_New_f(void) } Netchan_CreateFragments(TRUE, &host_client->netchan, &msg); Netchan_FragSend(&host_client->netchan); + host_client->m_bSentNewResponse = TRUE; } void SV_SendRes_f(void) @@ -1653,6 +1657,9 @@ void EXT_FUNC SV_Spawn_f_internal(void) } else { +#ifdef REHLDS_FIXES + host_client->m_bSentNewResponse = FALSE; +#endif SV_New_f(); } } @@ -1808,16 +1815,37 @@ challenge_t g_rg_sv_challenges[MAX_CHALLENGES]; int g_oldest_challenge = 0; #endif +typedef struct challenge_buf_s +{ + uint32_t ip; + uint32_t salt[15]; +} challenge_buf_t; + +challenge_buf_t g_raw_challenge_buf; + +void SV_ChallengesInit() +{ +#ifdef REHLDS_FIXES + static_assert(sizeof(g_raw_challenge_buf) == 64u, "Invalid g_raw_challenge_buf size"); + for (uint32_t& s : g_raw_challenge_buf.salt) + s = __rdtsc() * rand(); +#endif +} + bool EXT_FUNC SV_CheckChallenge_api(const netadr_t &adr, int nChallengeValue) { if (NET_IsLocalAddress(adr)) return TRUE; +#ifdef REHLDS_FIXES + return SV_GetChallenge(adr) == nChallengeValue; +#else for (int i = 0; i < MAX_CHALLENGES; i++) { if (NET_CompareBaseAdr(adr, g_rg_sv_challenges[i].adr)) return nChallengeValue == g_rg_sv_challenges[i].challenge; } return FALSE; +#endif } int SV_CheckChallenge(netadr_t *adr, int nChallengeValue) @@ -1828,6 +1856,10 @@ int SV_CheckChallenge(netadr_t *adr, int nChallengeValue) if (NET_IsLocalAddress(*adr)) return TRUE; +#ifdef REHLDS_FIXES + if (SV_GetChallenge(*adr) == nChallengeValue) + return TRUE; +#else for (int i = 0; i < MAX_CHALLENGES; i++) { if (NET_CompareBaseAdr(net_from, g_rg_sv_challenges[i].adr)) @@ -1840,6 +1872,7 @@ int SV_CheckChallenge(netadr_t *adr, int nChallengeValue) return TRUE; } } +#endif SV_RejectConnection(adr, "No challenge for your address.\n"); return FALSE; } @@ -2031,7 +2064,9 @@ qboolean SV_CheckForDuplicateNames(char *userinfo, qboolean bIsReconnecting, int return changed; char newname[MAX_NAME]; - Q_snprintf(newname, sizeof(newname), "(%d)%-0.*s", ++dupc, 28, rawname); + const int maxLenDupName = MAX_NAME - (sizeof("(d)") - 1); + + Q_snprintf(newname, sizeof(newname), "(%d)%.*s", ++dupc, maxLenDupName - 1, rawname); #ifdef REHLDS_FIXES // Fix possibly incorrectly cut UTF8 chars @@ -2456,6 +2491,7 @@ void EXT_FUNC SV_ConnectClient_internal(void) host_client->fully_connected = FALSE; #ifdef REHLDS_FIXES + host_client->m_bSentNewResponse = FALSE; g_GameClients[host_client - g_psvs.clients]->SetSpawnedOnce(false); #endif // REHLDS_FIXES @@ -2497,6 +2533,15 @@ void SVC_Ping(void) int EXT_FUNC SV_GetChallenge(const netadr_t& adr) { +#ifdef REHLDS_FIXES + uint8_t digest[16]; + g_raw_challenge_buf.ip = *(uint32_t*)adr.ip; + MD5Context_t ctx; + MD5Init(&ctx); + MD5Update(&ctx, (uint8_t *)&g_raw_challenge_buf, sizeof(g_raw_challenge_buf)); + MD5Final(digest, &ctx); + return *(int *)digest & 0x7FFFFFFF; +#else int i; #ifndef REHLDS_OPT_PEDANTIC int oldest = 0; @@ -2538,6 +2583,7 @@ int EXT_FUNC SV_GetChallenge(const netadr_t& adr) } return g_rg_sv_challenges[i].challenge; +#endif } void SVC_GetChallenge(void) @@ -4017,10 +4063,12 @@ void SV_AddToFatPVS(vec_t *org, mnode_t *node) unsigned char* EXT_FUNC SV_FatPVS(float *org) { #ifdef REHLDS_FIXES - fatbytes = gPVSRowBytes; -#else // REHLDS_FIXES - fatbytes = (g_psv.worldmodel->numleafs + 31) >> 3; + if (gPVS) + fatbytes = gPVSRowBytes; + else #endif // REHLDS_FIXES + fatbytes = (g_psv.worldmodel->numleafs + 31) >> 3; + Q_memset(fatpvs, 0, fatbytes); SV_AddToFatPVS(org, g_psv.worldmodel->nodes); return fatpvs; @@ -4072,10 +4120,12 @@ void SV_AddToFatPAS(vec_t *org, mnode_t *node) unsigned char* EXT_FUNC SV_FatPAS(float *org) { #ifdef REHLDS_FIXES - fatpasbytes = gPVSRowBytes; -#else // REHLDS_FIXES - fatpasbytes = (g_psv.worldmodel->numleafs + 31) >> 3; + if (gPAS) + fatpasbytes = gPVSRowBytes; + else #endif // REHLDS_FIXES + fatpasbytes = (g_psv.worldmodel->numleafs + 31) >> 3; + Q_memset(fatpas, 0, fatpasbytes); SV_AddToFatPAS(org, g_psv.worldmodel->nodes); return fatpas; @@ -5423,7 +5473,10 @@ void SV_PropagateCustomizations(void) // For each active player for (i = 0, pHost = g_psvs.clients; i < g_psvs.maxclients; i++, pHost++) { - if (!pHost->active && !pHost->spawned || pHost->fakeclient) + if (pHost->fakeclient) + continue; + + if (!pHost->active && !pHost->spawned) continue; // Send each customization to current player @@ -6552,7 +6605,10 @@ void SV_BanId_f(void) for (int i = 0; i < g_psvs.maxclients; i++) { client_t *cl = &g_psvs.clients[i]; - if (!cl->active && !cl->connected && !cl->spawned || cl->fakeclient) + if (cl->fakeclient) + continue; + + if (!cl->active && !cl->connected && !cl->spawned) continue; if (!Q_stricmp(SV_GetClientIDString(cl), idstring)) @@ -6625,7 +6681,10 @@ void SV_BanId_f(void) for (int i = 0; i < g_psvs.maxclients; i++) { client_t *cl = &g_psvs.clients[i]; - if (!cl->active && !cl->connected && !cl->spawned || cl->fakeclient) + if (cl->fakeclient) + continue; + + if (!cl->active && !cl->connected && !cl->spawned) continue; if (SV_CompareUserID(&cl->network_userid, id)) @@ -7287,7 +7346,10 @@ void SV_KickPlayer(int nPlayerSlot, int nReason) Q_sprintf(rgchT, "%s was automatically disconnected\nfrom this secure server.\n", client->name); for (int i = 0; i < g_psvs.maxclients; i++) { - if (!g_psvs.clients[i].active && !g_psvs.clients[i].spawned || g_psvs.clients[i].fakeclient) + if (g_psvs.clients[i].fakeclient) + continue; + + if (!g_psvs.clients[i].active && !g_psvs.clients[i].spawned) continue; MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_centerprint); @@ -7314,6 +7376,8 @@ void SV_InactivateClients(void) cl->connected = TRUE; cl->spawned = FALSE; cl->fully_connected = FALSE; + cl->hasusrmsgs = FALSE; + cl->m_bSentNewResponse = FALSE; SZ_Clear(&cl->netchan.message); SZ_Clear(&cl->datagram); @@ -7484,7 +7548,7 @@ void SV_BeginFileDownload_f(void) { if (host_client->fully_connected || sv_send_resources.value == 0.0f || - sv_downloadurl.string != NULL && sv_downloadurl.string[0] != 0 && Q_strlen(sv_downloadurl.string) <= 128 && sv_allow_dlfile.value == 0.0f || + (sv_downloadurl.string != NULL && sv_downloadurl.string[0] != 0 && Q_strlen(sv_downloadurl.string) <= 128 && sv_allow_dlfile.value == 0.0f) || Netchan_CreateFileFragments(TRUE, &host_client->netchan, name) == 0) { SV_FailDownload(name); @@ -7960,6 +8024,7 @@ void SV_Init(void) Cvar_RegisterVariable(&sv_rollspeed); Cvar_RegisterVariable(&sv_rollangle); Cvar_RegisterVariable(&sv_use_entity_file); + Cvar_RegisterVariable(&sv_usercmd_custom_random_seed); #endif for (int i = 0; i < MAX_MODELS; i++) @@ -7983,6 +8048,7 @@ void SV_Init(void) PM_Init(&g_svmove); SV_AllocClientFrames(); SV_InitDeltas(); + SV_ChallengesInit(); } void SV_Shutdown(void) @@ -8127,17 +8193,17 @@ typedef struct GameToAppIDMapItem_s } GameToAppIDMapItem_t; GameToAppIDMapItem_t g_GameToAppIDMap[11] = { - 0x0A, "cstrike", - 0x14, "tfc", - 0x1E, "dod", - 0x28, "dmc", - 0x32, "gearbox", - 0x3C, "ricochet", - 0x46, "valve", - 0x50, "czero", - 0x64, "czeror", - 0x82, "bshift", - 0x96, "cstrike_beta", + { 0x0A, "cstrike" }, + { 0x14, "tfc" }, + { 0x1E, "dod" }, + { 0x28, "dmc" }, + { 0x32, "gearbox" }, + { 0x3C, "ricochet" }, + { 0x46, "valve" }, + { 0x50, "czero" }, + { 0x64, "czeror" }, + { 0x82, "bshift" }, + { 0x96, "cstrike_beta" }, }; int GetGameAppID(void) diff --git a/rehlds/engine/sv_move.cpp b/rehlds/engine/sv_move.cpp index 472a135..b327b35 100644 --- a/rehlds/engine/sv_move.cpp +++ b/rehlds/engine/sv_move.cpp @@ -71,7 +71,7 @@ qboolean SV_CheckBottom(edict_t *ent) realcheck: // check it for real... - start[2] = mins[2]; + start[2] = mins[2] + sv_stepsize.value; // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5f; diff --git a/rehlds/engine/sv_phys.cpp b/rehlds/engine/sv_phys.cpp index 8f2be63..8fff595 100644 --- a/rehlds/engine/sv_phys.cpp +++ b/rehlds/engine/sv_phys.cpp @@ -1255,7 +1255,7 @@ void PF_WaterMove(edict_t *pSelf) if (!(flags & (FL_IMMUNE_WATER | FL_GODMODE))) { - if ((flags & FL_SWIM) && (waterlevel < drownlevel) || (waterlevel >= drownlevel)) + if (((flags & FL_SWIM) && waterlevel < drownlevel) || (waterlevel >= drownlevel)) { if (pSelf->v.air_finished < g_psv.time && pSelf->v.pain_finished < g_psv.time) { diff --git a/rehlds/engine/sv_upld.cpp b/rehlds/engine/sv_upld.cpp index 63a266e..e28a0e3 100644 --- a/rehlds/engine/sv_upld.cpp +++ b/rehlds/engine/sv_upld.cpp @@ -173,7 +173,10 @@ void SV_Customization(client_t *pPlayer, resource_t *pResource, qboolean bSkipPl // Send resource to all other active players for (i = 0, pHost = g_psvs.clients; i < g_psvs.maxclients; i++, pHost++) { - if (!pHost->active && !pHost->spawned || pHost->fakeclient) + if (pHost->fakeclient) + continue; + + if (!pHost->active && !pHost->spawned) continue; if (pHost == pPlayer && bSkipPlayer) diff --git a/rehlds/engine/sv_user.cpp b/rehlds/engine/sv_user.cpp index 4535117..5e2c001 100644 --- a/rehlds/engine/sv_user.cpp +++ b/rehlds/engine/sv_user.cpp @@ -28,11 +28,6 @@ #include "precompiled.h" -typedef struct command_s -{ - char *command; -} command_t; - sv_adjusted_positions_t truepositions[MAX_CLIENTS]; qboolean g_balreadymoved; @@ -47,9 +42,9 @@ edict_t *sv_player; qboolean nofind; #if defined(SWDS) && defined(REHLDS_FIXES) -command_t 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", NULL }; #else -command_t 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 }; +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 cvar_t sv_edgefriction = { "edgefriction", "2", FCVAR_SERVER, 0.0f, NULL }; @@ -98,6 +93,15 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient) int c = 0; Q_memset(nullbuffer, 0, sizeof(nullbuffer)); int value = MSG_ReadShort(); + + if (value <= 0 || !SZ_HasSomethingToRead(&net_message, value)) + { + msg_badread = TRUE; + Con_DPrintf("%s: %s:%s invalid length: %d\n", __func__, host_client->name, NET_AdrToString(host_client->netchan.remote_address), value); + SV_DropClient(host_client, FALSE, "Invalid length"); + return; + } + COM_UnMunge(&net_message.data[msg_readcount], value, g_psvs.spawncount); MSG_StartBitReading(&net_message); @@ -311,11 +315,27 @@ int EXT_FUNC SV_TransferConsistencyInfo_internal(void) return c; } +bool EXT_FUNC SV_ShouldSendConsistencyList_mod(IGameClient *cl, bool forceConsistency) +{ + if (g_psvs.maxclients == 1 || g_psv.num_consistency == 0 || cl->IsProxy()) + return false; + + if (!forceConsistency && mp_consistency.value == 0.0f) + return false; + + return true; +} + +bool SV_ShouldSendConsistencyList(client_t *client, bool forceConsistency) +{ + return g_RehldsHookchains.m_SV_ShouldSendConsistencyList.callChain(SV_ShouldSendConsistencyList_mod, GetRehldsApiClient(client), forceConsistency); +} + void SV_SendConsistencyList(sizebuf_t *msg) { host_client->has_force_unmodified = FALSE; - if (g_psvs.maxclients == 1 || mp_consistency.value == 0.0f || g_psv.num_consistency == 0 || host_client->proxy) + if (!SV_ShouldSendConsistencyList(host_client, false)) { MSG_WriteBits(0, 1); return; @@ -544,7 +564,10 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs) if ((check->v.flags & FL_CLIENT) && check->v.health <= 0.0) continue; - if (check->v.mins[2] == 0.0 && check->v.maxs[2] == 1.0 || Length(check->v.size) == 0.0) + if (check->v.mins[2] == 0.0 && check->v.maxs[2] == 1.0) + continue; + + if (Length(check->v.size) == 0.0) continue; fmin = check->v.absmin; @@ -759,6 +782,14 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed) if (!host_client->fakeclient) SV_SetupMove(host_client); +#ifdef REHLDS_FIXES + if (sv_usercmd_custom_random_seed.value) + { + float fltTimeNow = float(Sys_FloatTime() * 1000.0); + random_seed = *reinterpret_cast((char *)&fltTimeNow); + } +#endif + gEntityInterface.pfnCmdStart(sv_player, ucmd, random_seed); frametime = float(ucmd->msec * 0.001); host_client->svtimebase = frametime + host_client->svtimebase; @@ -1015,11 +1046,11 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed) int SV_ValidateClientCommand(char *pszCommand) { - char *p; + const char *p; int i = 0; COM_Parse(pszCommand); - while ((p = clcommands[i].command) != NULL) + while ((p = clcommands[i]) != NULL) { if (!Q_stricmp(com_token, p)) { @@ -1471,31 +1502,44 @@ void SV_EstablishTimeBase(client_t *cl, usercmd_t *cmds, int dropped, int numbac void SV_EstablishTimeBase_internal(client_t *cl, usercmd_t *cmds, int dropped, int numbackup, int numcmds) { - int cmdnum; - double runcmd_time; + int i; + double runcmd_time = 0.0; + double time_at_end = 0.0; + constexpr int MAX_DROPPED_CMDS = 24; - runcmd_time = 0.0; - cmdnum = dropped; - if (dropped < 24) + // If we haven't dropped too many packets, then run some commands + if (dropped < MAX_DROPPED_CMDS) { if (dropped > numbackup) { - cmdnum = dropped - (dropped - numbackup); - runcmd_time = (double)cl->lastcmd.msec * (dropped - numbackup) / 1000.0; + // Con_Printf("%s: lost %i cmds\n", __func__, dropped - numbackup); } - for (; cmdnum > 0; cmdnum--) + int droppedcmds = dropped; + + // Run the last known cmd for each dropped cmd we don't have a backup for + while (droppedcmds > numbackup) { - runcmd_time += cmds[cmdnum - 1 + numcmds].msec / 1000.0; + runcmd_time += cl->lastcmd.msec / 1000.0; + droppedcmds--; + } + + // Now run the "history" commands if we still have dropped packets + while (droppedcmds > 0) + { + int cmdnum = numcmds + droppedcmds - 1; + runcmd_time += cmds[cmdnum].msec / 1000.0; + droppedcmds--; } } - for (; numcmds > 0; numcmds--) + // Now run any new command(s). Go backward because the most recent command is at index 0 + for (i = numcmds - 1; i >= 0; i--) { - runcmd_time += cmds[numcmds - 1].msec / 1000.0; + time_at_end += cmds[i].msec / 1000.0; } - cl->svtimebase = host_frametime + g_psv.time - runcmd_time; + cl->svtimebase = host_frametime + g_psv.time - (time_at_end + runcmd_time); } void SV_ParseMove(client_t *pSenderClient) @@ -1527,6 +1571,15 @@ void SV_ParseMove(client_t *pSenderClient) placeholder = msg_readcount + 1; mlen = MSG_ReadByte(); cbchecksum = MSG_ReadByte(); + + if (mlen <= 0 || !SZ_HasSpaceToRead(&net_message, mlen)) + { + msg_badread = TRUE; + Con_DPrintf("%s: %s:%s invalid length: %d\n", __func__, host_client->name, NET_AdrToString(host_client->netchan.remote_address), mlen); + SV_DropClient(host_client, FALSE, "Invalid length"); + return; + } + COM_UnMunge(&net_message.data[placeholder + 1], mlen, host_client->netchan.incoming_sequence); packetLossByte = MSG_ReadByte(); @@ -1726,7 +1779,7 @@ void SV_ParseCvarValue2(client_t *cl) Con_DPrintf("Cvar query response: name:%s, request ID %d, cvar:%s, value:%s\n", cl->name, requestID, cvarName, value); } -void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, int8 opcode) { +void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, uint8 opcode) { client_t* cl = client->GetClient(); if (opcode < clc_bad || opcode > clc_cvarvalue2) { @@ -1739,6 +1792,12 @@ void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, int8 opcode) { return; } +#ifdef REHLDS_FIXES + // Save current name of the client before a possible kick + char name[32]; + Q_strlcpy(name, host_client->name); +#endif + void(*func)(client_t *) = sv_clcfuncs[opcode].pfnParse; if (func) func(cl); @@ -1746,7 +1805,7 @@ void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, int8 opcode) { #ifdef REHLDS_FIXES if (msg_badread) { - Con_Printf("SV_ReadClientMessage: badread on %s, opcode %s\n", host_client->name, sv_clcfuncs[opcode].pszname); + Con_Printf("SV_ReadClientMessage: badread on %s, opcode %s\n", name, sv_clcfuncs[opcode].pszname); } #endif @@ -1789,6 +1848,12 @@ void SV_ExecuteClientMessage(client_t *cl) return; g_RehldsHookchains.m_HandleNetCommand.callChain(SV_HandleClientMessage_api, apiClient, c); + +#ifdef REHLDS_FIXES + // FIXED: Don't handle remaining packets if got dropclient above + if (!cl->connected && !cl->active && !cl->spawned) + break; +#endif // REHLDS_FIXES } } diff --git a/rehlds/engine/sv_user.h b/rehlds/engine/sv_user.h index 8da3360..e5fa453 100644 --- a/rehlds/engine/sv_user.h +++ b/rehlds/engine/sv_user.h @@ -35,8 +35,6 @@ const int CMD_MAXBACKUP = 64; -typedef struct command_s command_t; - typedef struct sv_adjusted_positions_s { int active; @@ -59,7 +57,6 @@ typedef struct clc_func_s } clc_func_t; extern edict_t *sv_player; -extern command_t clcommands[23]; extern sv_adjusted_positions_t truepositions[MAX_CLIENTS]; extern qboolean g_balreadymoved; diff --git a/rehlds/engine/sys_dll.cpp b/rehlds/engine/sys_dll.cpp index 86d2ae3..fb2a5fb 100644 --- a/rehlds/engine/sys_dll.cpp +++ b/rehlds/engine/sys_dll.cpp @@ -490,7 +490,7 @@ void NORETURN Sys_Error(const char *error, ...) #endif // SWDS //Allahu akbar! - int *null = 0; + volatile int *null = 0; *null = 0; exit(-1); } @@ -770,11 +770,21 @@ const char* EXT_FUNC NameForFunction(uint32 function) return NULL; } -ENTITYINIT EXT_FUNC GetEntityInit(char *pClassName) +ENTITYINIT GetEntityInit_internal(char *pClassName) { return (ENTITYINIT)GetDispatch(pClassName); } +ENTITYINIT EXT_FUNC GetEntityInit_api(char *pClassName) +{ + return g_RehldsHookchains.m_GetEntityInit.callChain(GetEntityInit_internal, pClassName); +} + +ENTITYINIT GetEntityInit(char *pClassName) +{ + return GetEntityInit_api(pClassName); +} + FIELDIOFUNCTION GetIOFunction(char *pName) { return (FIELDIOFUNCTION)GetDispatch(pName); diff --git a/rehlds/engine/sys_dll.h b/rehlds/engine/sys_dll.h index 630235b..228b09a 100644 --- a/rehlds/engine/sys_dll.h +++ b/rehlds/engine/sys_dll.h @@ -120,6 +120,8 @@ uint32 FindNameInTable(extensiondll_t *pDll, const char *pName); NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName); uint32 FunctionFromName(const char *pName); const char *NameForFunction(uint32 function); +ENTITYINIT GetEntityInit_internal(char *pClassName); +ENTITYINIT GetEntityInit_api(char *pClassName); ENTITYINIT GetEntityInit(char *pClassName); FIELDIOFUNCTION GetIOFunction(char *pName); NOBODY void DLL_SetModKey(modinfo_t *pinfo, char *pkey, char *pvalue); diff --git a/rehlds/engine/sys_dll2.cpp b/rehlds/engine/sys_dll2.cpp index 75aee66..3f2b09e 100644 --- a/rehlds/engine/sys_dll2.cpp +++ b/rehlds/engine/sys_dll2.cpp @@ -455,7 +455,7 @@ void Sys_ShowProgressTicks(char *specialProgressMsg) } } -int Sys_InitGame(char *lpOrgCmdLine, char *pBaseDir, void *pwnd, int bIsDedicated) +int Sys_InitGame(const char *lpOrgCmdLine, const char *pBaseDir, void *pwnd, int bIsDedicated) { host_initialized = FALSE; @@ -640,7 +640,7 @@ NOXREF int BuildMapCycleListHints(char **hints) } */ -bool CDedicatedServerAPI::Init(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory) +bool CDedicatedServerAPI::Init(const char *basedir, const char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory) { dedicated_ = (IDedicatedExports *)launcherFactory(VENGINE_DEDICATEDEXPORTS_API_VERSION, NULL); if (!dedicated_) diff --git a/rehlds/engine/sys_dll2.h b/rehlds/engine/sys_dll2.h index 74a247b..1c62ebc 100644 --- a/rehlds/engine/sys_dll2.h +++ b/rehlds/engine/sys_dll2.h @@ -58,7 +58,7 @@ private: char m_OrigCmd[1024]; public: - EXT_FUNC virtual bool Init(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory); + EXT_FUNC virtual bool Init(const char *basedir, const char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory); EXT_FUNC virtual int Shutdown(); EXT_FUNC virtual bool RunFrame(); EXT_FUNC virtual void AddConsoleText(char *text); @@ -93,7 +93,7 @@ NOXREF void Sys_ShutdownLauncherInterface(); void Sys_InitAuthentication(); NOXREF void Sys_ShutdownAuthentication(); void Sys_ShowProgressTicks(char *specialProgressMsg); -int Sys_InitGame(char *lpOrgCmdLine, char *pBaseDir, void *pwnd, int bIsDedicated); +int Sys_InitGame(const char *lpOrgCmdLine, const char *pBaseDir, void *pwnd, int bIsDedicated); void Sys_ShutdownGame(); void ClearIOStates(); diff --git a/rehlds/engine/sys_engine.cpp b/rehlds/engine/sys_engine.cpp index ed10b35..beef432 100644 --- a/rehlds/engine/sys_engine.cpp +++ b/rehlds/engine/sys_engine.cpp @@ -81,7 +81,7 @@ void ForceReloadProfile() } } -bool CEngine::Load(bool dedicated, char *basedir, char *cmdline) +bool CEngine::Load(bool dedicated, const char *basedir, const char *cmdline) { bool success = false; SetState(DLL_ACTIVE); diff --git a/rehlds/engine/sys_engine.h b/rehlds/engine/sys_engine.h index cedb535..805b89f 100644 --- a/rehlds/engine/sys_engine.h +++ b/rehlds/engine/sys_engine.h @@ -56,7 +56,7 @@ public: CEngine(); virtual ~CEngine(); - virtual bool Load(bool dedicated, char *rootDir, char *cmdLine); + virtual bool Load(bool dedicated, const char *rootDir, const char *cmdLine); virtual void Unload(); virtual void SetState(int iState); virtual int GetState(); diff --git a/rehlds/engine/tmessage.cpp b/rehlds/engine/tmessage.cpp index 2e518bc..5bc8a15 100644 --- a/rehlds/engine/tmessage.cpp +++ b/rehlds/engine/tmessage.cpp @@ -44,17 +44,19 @@ const char *gNetworkMessageNames[MAX_NETMESSAGE] = client_textmessage_t gNetworkTextMessage[MAX_NETMESSAGE] = { - 0, // effect - 255, 255, 255, 255, - 255, 255, 255, 255, - -1.0f, // x - -1.0f, // y - 0.0f, // fadein - 0.0f, // fadeout - 0.0f, // holdtime - 0.0f, // fxTime, - NETWORK_MESSAGE1,// pName message name. - gNetworkTextMessageBuffer[0] // pMessage + { + 0, // effect + 255, 255, 255, 255, + 255, 255, 255, 255, + -1.0f, // x + -1.0f, // y + 0.0f, // fadein + 0.0f, // fadeout + 0.0f, // holdtime + 0.0f, // fxTime, + NETWORK_MESSAGE1,// pName message name. + gNetworkTextMessageBuffer[0] // pMessage + } }; char* EXT_FUNC memfgets(unsigned char *pMemFile, int fileSize, int *pFilePos, char *pBuffer, int bufferSize) diff --git a/rehlds/engine/unicode_strtools.cpp b/rehlds/engine/unicode_strtools.cpp index 2bd19bd..818145b 100644 --- a/rehlds/engine/unicode_strtools.cpp +++ b/rehlds/engine/unicode_strtools.cpp @@ -565,22 +565,22 @@ int Q_UChar32ToUTF8(uchar32 uVal, char * pUTF8Out) { else if (uVal <= 0x7FF) { *pUTF8Out = (uVal >> 6) | 0xC0; - pUTF8Out[1] = uVal & 0x3F | 0x80; + pUTF8Out[1] = (uVal & 0x3F) | 0x80; return 2; } else if (uVal <= 0xFFFF) { - *pUTF8Out = (uVal >> 12) | 0xE0; - pUTF8Out[2] = uVal & 0x3F | 0x80; - pUTF8Out[1] = (uVal >> 6) & 0x3F | 0x80; + *pUTF8Out = ((uVal >> 12)) | 0xE0; + pUTF8Out[2] = (uVal & 0x3F) | 0x80; + pUTF8Out[1] = (((uVal >> 6)) & 0x3F) | 0x80; return 3; } else { - *pUTF8Out = (uVal >> 18) & 7 | 0xF0; - pUTF8Out[1] = (uVal >> 12) & 0x3F | 0x80; - pUTF8Out[3] = uVal & 0x3F | 0x80; - pUTF8Out[2] = (uVal >> 6) & 0x3F | 0x80; + *pUTF8Out = ((uVal >> 18) & 7) | 0xF0; + pUTF8Out[1] = ((uVal >> 12) & 0x3F) | 0x80; + pUTF8Out[3] = (uVal & 0x3F) | 0x80; + pUTF8Out[2] = ((uVal >> 6) & 0x3F) | 0x80; return 4; } } @@ -600,7 +600,7 @@ int __cdecl Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out) } else { - pUTF16Out[1] = uVal & 0x3FF | 0xDC00; + pUTF16Out[1] = (uVal & 0x3FF) | 0xDC00; pUTF16Out[0] = ((uVal - 0x10000) >> 10) | 0xD800; return 2; } diff --git a/rehlds/engine/vid_null.cpp b/rehlds/engine/vid_null.cpp index 500eba6..391f09a 100644 --- a/rehlds/engine/vid_null.cpp +++ b/rehlds/engine/vid_null.cpp @@ -71,7 +71,7 @@ void R_InitTextures() { for (int y = 0; y < texSize; y++, dest++) { - if (x < (texSize / 2) == y < (texSize / 2)) + if ((x < (texSize / 2)) == (y < (texSize / 2))) *dest = -1; else *dest = 0; diff --git a/rehlds/filesystem/CMakeLists.txt b/rehlds/filesystem/CMakeLists.txt new file mode 100644 index 0000000..cc26eee --- /dev/null +++ b/rehlds/filesystem/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(rehlds CXX) + +add_subdirectory(FileSystem_Stdio) diff --git a/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt b/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt new file mode 100644 index 0000000..2339aae --- /dev/null +++ b/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt @@ -0,0 +1,108 @@ +cmake_minimum_required(VERSION 3.1) +project(filesystem_stdio CXX) + +option(DEBUG "Build with debug information." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") + set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions") +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3\ + -fpermissive -fno-sized-deallocation\ + -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-result -Wno-unused-function\ + -Wno-write-strings -Wno-sign-compare -Wno-strict-aliasing") + + # Check if not Clang compiler AND GCC >= 8.3 + if (NOT "$ENV{CXX}" MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-class-memaccess") + endif() +endif() + +# NOTE: Don't use IPO or LTO with '--wrap' may make this feature ineffective +set(WRAP_FUNCS_LIST + "scandir" "opendir" "freopen" "fopen" "fopen64" "open" "open64" "creat" + "access" "stat" "lstat" "__xstat" "__lxstat" "__xstat64" "__lxstat64" + "chmod" "chown" "lchown" "unlink" "symlink" "link" "mknod" "mount" + "mkfifo" "rename" "utime" "utimes" "mkdir" "rmdir" +) + +foreach(f ${WRAP_FUNCS_LIST}) + set(LINK_FLAGS "${LINK_FLAGS} -Wl,-wrap,${f}") +endforeach() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/../.." +) + +set(PROJECT_PUBLIC_DIR + "${PROJECT_SOURCE_DIR}/../../common" + "${PROJECT_SOURCE_DIR}/../../public" + "${PROJECT_SOURCE_DIR}/../../public/rehlds" +) + +set(FILESYSTEM_STDIO_SRCS + "src/BaseFileSystem.cpp" + "src/filesystem_helpers.cpp" + "src/FileSystem_Stdio.cpp" + "src/linux_support.cpp" + "src/pathmatch.cpp" + "src/public_amalgamation.cpp" +) + +add_library(filesystem_stdio SHARED ${FILESYSTEM_STDIO_SRCS}) + +target_include_directories(filesystem_stdio PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_PUBLIC_DIR} +) + +target_compile_definitions(filesystem_stdio PRIVATE + _LINUX + LINUX + _GLIBCXX_USE_CXX11_ABI=0 + _strdup=strdup + _stricmp=strcasecmp + _strnicmp=strncasecmp + _vsnprintf=vsnprintf + _snprintf=snprintf + _unlink=unlink +) + +target_link_libraries(filesystem_stdio PRIVATE + dl +) + +set_target_properties(filesystem_stdio PROPERTIES + OUTPUT_NAME filesystem_stdio + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/rehlds/filesystem/FileSystem_Stdio/build.gradle b/rehlds/filesystem/FileSystem_Stdio/build.gradle deleted file mode 100644 index 93910cc..0000000 --- a/rehlds/filesystem/FileSystem_Stdio/build.gradle +++ /dev/null @@ -1,158 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.GradleCppUtils -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeLibrarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply plugin: 'cpp' -apply plugin: IccCompilerPlugin -apply plugin: GccCompilerPlugin - -void setupToolchain(NativeBinarySpec b) { - boolean useGcc = project.hasProperty("useGcc") - def cfg = rootProject.createToolchainConfig(b); - cfg.projectInclude(project, '/../..', '/src', '/../../common', '/../../public', '/../../public/rehlds'); - cfg.singleDefines 'USE_BREAKPAD_HANDLER' - - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'filesystem_pch' - ); - - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - cfg.compilerOptions.args '/Ob2', '/Oi', '/GF' - } - else if (cfg instanceof GccToolchainConfig) { - if (!useGcc) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'filesystem_pch' - ); - } - - cfg.compilerOptions.languageStandard = 'c++11' - cfg.defines([ - '_strdup': 'strdup', - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_vsnprintf': 'vsnprintf', - '_snprintf': 'snprintf', - '_unlink': 'unlink', - ]); - - if (useGcc) { - // Produce code optimized for the most common IA32/AMD64/EM64T processors. - // As new processors are deployed in the marketplace, the behavior of this option will change. - cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto' - } else { - cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp' - } - - cfg.compilerOptions.args '-fno-exceptions' - cfg.compilerOptions.interProceduralOptimizations = false; - cfg.linkerOptions.interProceduralOptimizations = false; - - def funcToWrap = [ - "freopen", "fopen", "fopen64", "open", "open64", "creat", "access", - "stat", "lstat", "scandir", "opendir", "__xstat", "__lxstat", "__xstat64", "__lxstat64", - "chmod", "chown", "lchown", "symlink", "link", "mknod", "mount", "unlink", - "mkfifo", "rename", "utime", "utimes", "mkdir", "rmdir" - ]; - - funcToWrap.each { - cfg.linkerOptions.args "-Wl,-wrap," + it - } - } - - ToolchainConfigUtils.apply(project, cfg, b); -} - -model { - buildTypes { - release - } - - platforms { - x86 { - architecture "x86" - } - } - - toolChains { - visualCpp(VisualCpp) { - } - if (project.hasProperty("useGcc")) { - gcc(Gcc) - } else { - icc(Icc) - } - } - - components { - filesystem(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'filesystem_stdio' - - sources { - filesystem_main(CppSourceSet) { - source { - srcDir "src" - include "**/*.cpp" - exclude "precompiled.cpp" - } - } - - filesystem_pch(CppSourceSet) { - source { - srcDir "src" - include "precompiled.cpp" - } - } - } - - binaries.all { - NativeBinarySpec b -> project.setupToolchain(b) - } - } - } -} - -task buildFinalize << { - if (GradleCppUtils.windows) { - return; - } - - binaries.withType(SharedLibraryBinarySpec) { - def sharedBinary = it.getSharedLibraryFile(); - if (sharedBinary.exists()) { - sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", ""))); - } - } -} - -task buildFixes { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -task buildRelease { - dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && blib.buildType.name == 'release' - } -} - -build.finalizedBy(buildFinalize); -buildFixes.finalizedBy(buildFinalize); -buildRelease.finalizedBy(buildFinalize); - -// prevent static lib building -binaries.withType(StaticLibraryBinarySpec) { binary -> - buildable = false -} diff --git a/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj b/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj index 77a1ecb..a340ff8 100644 --- a/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj +++ b/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj @@ -130,14 +130,6 @@ - - true - true - - - true - true - @@ -156,10 +148,6 @@ - - true - true - diff --git a/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj.filters b/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj.filters index 5f4abdf..c4646a0 100644 --- a/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj.filters +++ b/rehlds/filesystem/FileSystem_Stdio/msvc/filesystem_stdio.vcxproj.filters @@ -4,9 +4,6 @@ {3f7611e3-cf43-4956-a8a1-b6efbcf1a63d} - - {cacc7b07-9ac2-42d5-bba3-14c061a19d11} - @@ -30,12 +27,6 @@ src - - hookers - - - hookers - @@ -50,9 +41,6 @@ src - - hookers - src diff --git a/rehlds/filesystem/FileSystem_Stdio/src/BaseFileSystem.cpp b/rehlds/filesystem/FileSystem_Stdio/src/BaseFileSystem.cpp index 7591428..85c04cb 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/BaseFileSystem.cpp +++ b/rehlds/filesystem/FileSystem_Stdio/src/BaseFileSystem.cpp @@ -1132,8 +1132,8 @@ bool IsWildCardMatch(const char *wildcardString, const char *stringToCheck) // we only want to advance the pointers if we successfully assigned // both of our char variables, so we'll do it here rather than in the // loop condition itself - *stringToCheck++; - *wildcardString++; + stringToCheck++; + wildcardString++; // if this isn't a case-sensitive match, make both chars uppercase wcChar = toupper(wcChar); @@ -1148,7 +1148,7 @@ bool IsWildCardMatch(const char *wildcardString, const char *stringToCheck) // until we've either found a match or the string has // ended if (starMatchesZero) - *stringToCheck--; + stringToCheck--; while (*stringToCheck) { @@ -1501,7 +1501,7 @@ void CBaseFileSystem::Warning(FileWarningLevel_t level, const char *fmt, ...) #ifdef _WIN32 OutputDebugString(warningtext); #else - fprintf(stderr, warningtext); + fprintf(stderr, "%s", warningtext); #endif } } @@ -1654,15 +1654,15 @@ bool CBaseFileSystem::CSearchPath::PackFileLessFunc(CPackFileEntry const &src1, } CBaseFileSystem::CSearchPath::CSearchPath() : - m_PackFiles(0, MAX_ENTRY_PATH, CSearchPath::PackFileLessFunc), m_Path(CUtlSymbol("")), m_bIsMapPath(false), m_bIsPackFile(false), - m_bAllowWrite(true), m_lPackFileTime(0), + m_hPackFile(nullptr), m_nNumPackFiles(0), m_iCurSearchFile(0), - m_hPackFile(nullptr) + m_bAllowWrite(true), + m_PackFiles(0, MAX_ENTRY_PATH, CSearchPath::PackFileLessFunc) { } diff --git a/rehlds/filesystem/FileSystem_Stdio/src/FileSystem_Stdio.cpp b/rehlds/filesystem/FileSystem_Stdio/src/FileSystem_Stdio.cpp index 78d1188..9fde285 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/FileSystem_Stdio.cpp +++ b/rehlds/filesystem/FileSystem_Stdio/src/FileSystem_Stdio.cpp @@ -227,6 +227,4 @@ bool CFileSystem_Stdio::IsAppReadyForOfflinePlay(int appID) return true; } -#ifndef HOOK_FILESYSTEM EXPOSE_SINGLE_INTERFACE(CFileSystem_Stdio, IFileSystem, FILESYSTEM_INTERFACE_VERSION); -#endif // HOOK_FILESYSTEM diff --git a/rehlds/filesystem/FileSystem_Stdio/src/filesystem_helpers.cpp b/rehlds/filesystem/FileSystem_Stdio/src/filesystem_helpers.cpp index 097fd60..67aa18e 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/filesystem_helpers.cpp +++ b/rehlds/filesystem/FileSystem_Stdio/src/filesystem_helpers.cpp @@ -172,7 +172,7 @@ void NORETURN FileSystem_SysError(const char *fmt, ...) fprintf(fl, "%s\n", string); fclose(fl); - int *null = 0; + volatile int *null = 0; *null = 0; exit(-1); } diff --git a/rehlds/filesystem/FileSystem_Stdio/src/pathmatch.cpp b/rehlds/filesystem/FileSystem_Stdio/src/pathmatch.cpp index 9d4f722..20ff233 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/pathmatch.cpp +++ b/rehlds/filesystem/FileSystem_Stdio/src/pathmatch.cpp @@ -769,9 +769,9 @@ extern "C" { return __wrap_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); } - int __wrap_access(const char *pathname, int mode) + WRAP(access, int, const char *pathname, int mode) { - return __real_access(CWrap(pathname, false), mode); + return CALL(access)(CWrap(pathname, false), mode); } WRAP(stat, int, const char *path, struct stat *buf) diff --git a/rehlds/filesystem/FileSystem_Stdio/src/precompiled.h b/rehlds/filesystem/FileSystem_Stdio/src/precompiled.h index 323af5e..db84c63 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/precompiled.h +++ b/rehlds/filesystem/FileSystem_Stdio/src/precompiled.h @@ -33,8 +33,5 @@ #include "interface.h" #include "strtools.h" -// Hooks stuff -#include "hookers/filesystem/hooklist.h" - // FileSystem stuff #include "FileSystem_Stdio.h" diff --git a/rehlds/filesystem/FileSystem_Stdio/src/public_amalgamation.cpp b/rehlds/filesystem/FileSystem_Stdio/src/public_amalgamation.cpp index 1776bc6..6cc63ef 100644 --- a/rehlds/filesystem/FileSystem_Stdio/src/public_amalgamation.cpp +++ b/rehlds/filesystem/FileSystem_Stdio/src/public_amalgamation.cpp @@ -5,3 +5,4 @@ #include "tier0/dbg.cpp" #include "tier0/characterset.cpp" +#include "stdc++compat.cpp" diff --git a/rehlds/filesystem/build.gradle b/rehlds/filesystem/build.gradle deleted file mode 100644 index 3c2d092..0000000 --- a/rehlds/filesystem/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -evaluationDependsOn(':rehlds/filesystem/FileSystem_Stdio'); - -task build { - dependsOn project(':rehlds/filesystem/FileSystem_Stdio').tasks.build -} diff --git a/rehlds/hookers/HLTV/Core/DeltaEx.cpp b/rehlds/hookers/HLTV/Core/DeltaEx.cpp deleted file mode 100644 index 4630e76..0000000 --- a/rehlds/hookers/HLTV/Core/DeltaEx.cpp +++ /dev/null @@ -1,1533 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -#ifdef HOOK_HLTV - -DeltaWrapper World::m_Delta; - -delta_definition_list_t *g_defs; -delta_encoder_t *g_encoders; -delta_registry_t *g_deltaregistry; - -double g_delta_Time; -bool g_large_Time_Buffers; - -delta_t *g_pentitydelta; -delta_t *g_pplayerdelta; -delta_t *g_pcustomentitydelta; -delta_t *g_pclientdelta; -delta_t *g_pweapondelta; -delta_t *g_peventdelta; - -#define DELTA_D_DEF(member) #member, offsetof(delta_description_s, member) -#define DELTA_DEF(structname, member) { #member, offsetof(structname, member) } - -delta_definition_t g_DeltaDataDefinition[] = -{ - DELTA_DEF(delta_description_s, fieldType), - DELTA_DEF(delta_description_s, fieldName), - DELTA_DEF(delta_description_s, fieldOffset), - DELTA_DEF(delta_description_s, fieldSize), - DELTA_DEF(delta_description_s, significant_bits), - DELTA_DEF(delta_description_s, premultiply), - DELTA_DEF(delta_description_s, postmultiply), - DELTA_DEF(delta_description_s, flags) -}; - -delta_description_t g_MetaDescription[] = -{ - { DT_INTEGER, DELTA_D_DEF(fieldType), 1, 32, 1.0, 1.0, 0, 0, 0 }, - { DT_STRING, DELTA_D_DEF(fieldName), 1, 1, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldOffset), 1, 16, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(fieldSize), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_INTEGER, DELTA_D_DEF(significant_bits), 1, 8, 1.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(premultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 }, - { DT_FLOAT, DELTA_D_DEF(postmultiply), 1, 32, 4000.0, 1.0, 0, 0, 0 } -}; - -namespace Delta { - delta_t g_MetaDelta[] = - { - { 0, ARRAYSIZE(g_MetaDescription), "", NULL, g_MetaDescription }, - }; - -}; // namespace Delta - -delta_definition_t g_EventDataDefinition[] = -{ - DELTA_DEF(event_args_s, entindex), - DELTA_DEF(event_args_s, origin[0]), - DELTA_DEF(event_args_s, origin[1]), - DELTA_DEF(event_args_s, origin[2]), - DELTA_DEF(event_args_s, angles[0]), - DELTA_DEF(event_args_s, angles[1]), - DELTA_DEF(event_args_s, angles[2]), - DELTA_DEF(event_args_s, fparam1), - DELTA_DEF(event_args_s, fparam2), - DELTA_DEF(event_args_s, iparam1), - DELTA_DEF(event_args_s, iparam2), - DELTA_DEF(event_args_s, bparam1), - DELTA_DEF(event_args_s, bparam2), - DELTA_DEF(event_args_s, ducking) -}; - -delta_definition_t g_EntityDataDefinition[] = -{ - DELTA_DEF(entity_state_s, startpos[0]), - DELTA_DEF(entity_state_s, startpos[1]), - DELTA_DEF(entity_state_s, startpos[2]), - DELTA_DEF(entity_state_s, endpos[0]), - DELTA_DEF(entity_state_s, endpos[1]), - DELTA_DEF(entity_state_s, endpos[2]), - DELTA_DEF(entity_state_s, impacttime), - DELTA_DEF(entity_state_s, starttime), - DELTA_DEF(entity_state_s, origin[0]), - DELTA_DEF(entity_state_s, origin[1]), - DELTA_DEF(entity_state_s, origin[2]), - DELTA_DEF(entity_state_s, angles[0]), - DELTA_DEF(entity_state_s, angles[1]), - DELTA_DEF(entity_state_s, angles[2]), - DELTA_DEF(entity_state_s, modelindex), - DELTA_DEF(entity_state_s, frame), - DELTA_DEF(entity_state_s, movetype), - DELTA_DEF(entity_state_s, colormap), - DELTA_DEF(entity_state_s, skin), - DELTA_DEF(entity_state_s, solid), - DELTA_DEF(entity_state_s, scale), - DELTA_DEF(entity_state_s, effects), - DELTA_DEF(entity_state_s, sequence), - DELTA_DEF(entity_state_s, animtime), - DELTA_DEF(entity_state_s, framerate), - DELTA_DEF(entity_state_s, controller[0]), - DELTA_DEF(entity_state_s, controller[1]), - DELTA_DEF(entity_state_s, controller[2]), - DELTA_DEF(entity_state_s, controller[3]), - DELTA_DEF(entity_state_s, blending[0]), - DELTA_DEF(entity_state_s, blending[1]), - DELTA_DEF(entity_state_s, body), - DELTA_DEF(entity_state_s, owner), - DELTA_DEF(entity_state_s, rendermode), - DELTA_DEF(entity_state_s, renderamt), - DELTA_DEF(entity_state_s, renderfx), - DELTA_DEF(entity_state_s, rendercolor.r), - DELTA_DEF(entity_state_s, rendercolor.g), - DELTA_DEF(entity_state_s, rendercolor.b), - DELTA_DEF(entity_state_s, weaponmodel), - DELTA_DEF(entity_state_s, gaitsequence), - DELTA_DEF(entity_state_s, mins[0]), - DELTA_DEF(entity_state_s, mins[1]), - DELTA_DEF(entity_state_s, mins[2]), - DELTA_DEF(entity_state_s, maxs[0]), - DELTA_DEF(entity_state_s, maxs[1]), - DELTA_DEF(entity_state_s, maxs[2]), - DELTA_DEF(entity_state_s, aiment), - DELTA_DEF(entity_state_s, basevelocity[0]), - DELTA_DEF(entity_state_s, basevelocity[1]), - DELTA_DEF(entity_state_s, basevelocity[2]), - DELTA_DEF(entity_state_s, friction), - DELTA_DEF(entity_state_s, gravity), - DELTA_DEF(entity_state_s, spectator), - DELTA_DEF(entity_state_s, velocity[0]), - DELTA_DEF(entity_state_s, velocity[1]), - DELTA_DEF(entity_state_s, velocity[2]), - DELTA_DEF(entity_state_s, team), - DELTA_DEF(entity_state_s, playerclass), - DELTA_DEF(entity_state_s, health), - DELTA_DEF(entity_state_s, usehull), - DELTA_DEF(entity_state_s, oldbuttons), - DELTA_DEF(entity_state_s, onground), - DELTA_DEF(entity_state_s, iStepLeft), - DELTA_DEF(entity_state_s, flFallVelocity), - DELTA_DEF(entity_state_s, weaponanim), - DELTA_DEF(entity_state_s, eflags), - DELTA_DEF(entity_state_s, iuser1), - DELTA_DEF(entity_state_s, iuser2), - DELTA_DEF(entity_state_s, iuser3), - DELTA_DEF(entity_state_s, iuser4), - DELTA_DEF(entity_state_s, fuser1), - DELTA_DEF(entity_state_s, fuser2), - DELTA_DEF(entity_state_s, fuser3), - DELTA_DEF(entity_state_s, fuser4), - DELTA_DEF(entity_state_s, vuser1[0]), - DELTA_DEF(entity_state_s, vuser1[1]), - DELTA_DEF(entity_state_s, vuser1[2]), - DELTA_DEF(entity_state_s, vuser2[0]), - DELTA_DEF(entity_state_s, vuser2[1]), - DELTA_DEF(entity_state_s, vuser2[2]), - DELTA_DEF(entity_state_s, vuser3[0]), - DELTA_DEF(entity_state_s, vuser3[1]), - DELTA_DEF(entity_state_s, vuser3[2]), - DELTA_DEF(entity_state_s, vuser4[0]), - DELTA_DEF(entity_state_s, vuser4[1]), - DELTA_DEF(entity_state_s, vuser4[2]) -}; - -delta_definition_t g_UsercmdDataDefinition[] = -{ - DELTA_DEF(usercmd_s, lerp_msec), - DELTA_DEF(usercmd_s, msec), - DELTA_DEF(usercmd_s, lightlevel), - DELTA_DEF(usercmd_s, viewangles[0]), - DELTA_DEF(usercmd_s, viewangles[1]), - DELTA_DEF(usercmd_s, viewangles[2]), - DELTA_DEF(usercmd_s, buttons), - DELTA_DEF(usercmd_s, forwardmove), - DELTA_DEF(usercmd_s, sidemove), - DELTA_DEF(usercmd_s, upmove), - DELTA_DEF(usercmd_s, impulse), - DELTA_DEF(usercmd_s, weaponselect), - DELTA_DEF(usercmd_s, impact_index), - DELTA_DEF(usercmd_s, impact_position[0]), - DELTA_DEF(usercmd_s, impact_position[1]), - DELTA_DEF(usercmd_s, impact_position[2]) -}; - -delta_definition_t g_WeaponDataDefinition[] = -{ - DELTA_DEF(weapon_data_s, m_iId), - DELTA_DEF(weapon_data_s, m_iClip), - DELTA_DEF(weapon_data_s, m_flNextPrimaryAttack), - DELTA_DEF(weapon_data_s, m_flNextSecondaryAttack), - DELTA_DEF(weapon_data_s, m_flTimeWeaponIdle), - DELTA_DEF(weapon_data_s, m_fInReload), - DELTA_DEF(weapon_data_s, m_fInSpecialReload), - DELTA_DEF(weapon_data_s, m_flNextReload), - DELTA_DEF(weapon_data_s, m_flPumpTime), - DELTA_DEF(weapon_data_s, m_fReloadTime), - DELTA_DEF(weapon_data_s, m_fAimedDamage), - DELTA_DEF(weapon_data_s, m_fNextAimBonus), - DELTA_DEF(weapon_data_s, m_fInZoom), - DELTA_DEF(weapon_data_s, m_iWeaponState), - DELTA_DEF(weapon_data_s, iuser1), - DELTA_DEF(weapon_data_s, iuser2), - DELTA_DEF(weapon_data_s, iuser3), - DELTA_DEF(weapon_data_s, iuser4), - DELTA_DEF(weapon_data_s, fuser1), - DELTA_DEF(weapon_data_s, fuser2), - DELTA_DEF(weapon_data_s, fuser3), - DELTA_DEF(weapon_data_s, fuser4) -}; - -delta_definition_t g_ClientDataDefinition[] = -{ - DELTA_DEF(clientdata_s, origin[0]), - DELTA_DEF(clientdata_s, origin[1]), - DELTA_DEF(clientdata_s, origin[2]), - DELTA_DEF(clientdata_s, velocity[0]), - DELTA_DEF(clientdata_s, velocity[1]), - DELTA_DEF(clientdata_s, velocity[2]), - DELTA_DEF(clientdata_s, viewmodel), - DELTA_DEF(clientdata_s, punchangle[0]), - DELTA_DEF(clientdata_s, punchangle[1]), - DELTA_DEF(clientdata_s, punchangle[2]), - DELTA_DEF(clientdata_s, flags), - DELTA_DEF(clientdata_s, waterlevel), - DELTA_DEF(clientdata_s, watertype), - DELTA_DEF(clientdata_s, view_ofs[0]), - DELTA_DEF(clientdata_s, view_ofs[1]), - DELTA_DEF(clientdata_s, view_ofs[2]), - DELTA_DEF(clientdata_s, health), - DELTA_DEF(clientdata_s, bInDuck), - DELTA_DEF(clientdata_s, weapons), - DELTA_DEF(clientdata_s, flTimeStepSound), - DELTA_DEF(clientdata_s, flDuckTime), - DELTA_DEF(clientdata_s, flSwimTime), - DELTA_DEF(clientdata_s, waterjumptime), - DELTA_DEF(clientdata_s, maxspeed), - DELTA_DEF(clientdata_s, m_iId), - DELTA_DEF(clientdata_s, ammo_nails), - DELTA_DEF(clientdata_s, ammo_shells), - DELTA_DEF(clientdata_s, ammo_cells), - DELTA_DEF(clientdata_s, ammo_rockets), - DELTA_DEF(clientdata_s, m_flNextAttack), - DELTA_DEF(clientdata_s, physinfo), - DELTA_DEF(clientdata_s, fov), - DELTA_DEF(clientdata_s, weaponanim), - DELTA_DEF(clientdata_s, tfstate), - DELTA_DEF(clientdata_s, pushmsec), - DELTA_DEF(clientdata_s, deadflag), - DELTA_DEF(clientdata_s, iuser1), - DELTA_DEF(clientdata_s, iuser2), - DELTA_DEF(clientdata_s, iuser3), - DELTA_DEF(clientdata_s, iuser4), - DELTA_DEF(clientdata_s, fuser1), - DELTA_DEF(clientdata_s, fuser2), - DELTA_DEF(clientdata_s, fuser3), - DELTA_DEF(clientdata_s, fuser4), - DELTA_DEF(clientdata_s, vuser1[0]), - DELTA_DEF(clientdata_s, vuser1[1]), - DELTA_DEF(clientdata_s, vuser1[2]), - DELTA_DEF(clientdata_s, vuser2[0]), - DELTA_DEF(clientdata_s, vuser2[1]), - DELTA_DEF(clientdata_s, vuser2[2]), - DELTA_DEF(clientdata_s, vuser3[0]), - DELTA_DEF(clientdata_s, vuser3[1]), - DELTA_DEF(clientdata_s, vuser3[2]), - DELTA_DEF(clientdata_s, vuser4[0]), - DELTA_DEF(clientdata_s, vuser4[1]), - DELTA_DEF(clientdata_s, vuser4[2]) -}; - -delta_description_t *DELTA_FindField(delta_t *pFields, const char *pszField) -{ - for (int i = 0; i < pFields->fieldCount; i++) - { - if (Q_stricmp(pFields->pdd[i].fieldName, pszField) == 0) { - return &pFields->pdd[i]; - } - } - - return nullptr; -} - -int DELTA_FindFieldIndex(delta_t *pFields, const char *fieldname) -{ - for (int i = 0; i < pFields->fieldCount; i++) - { - if (Q_stricmp(pFields->pdd[i].fieldName, fieldname) == 0) { - return i; - } - } - - return -1; -} - -void DELTA_SetField(delta_t *pFields, const char *fieldname) -{ - delta_description_t *pTest = DELTA_FindField(pFields, fieldname); - if (pTest) { - pTest->flags |= FDT_MARK; - } -} - -void DELTA_UnsetField(delta_t *pFields, const char *fieldname) -{ - delta_description_t *pTest = DELTA_FindField(pFields, fieldname); - if (pTest) { - pTest->flags &= ~FDT_MARK; - } -} - -void DELTA_SetFieldByIndex(delta_t *pFields, int fieldNumber) -{ - pFields->pdd[fieldNumber].flags |= FDT_MARK; -} - -void DELTA_UnsetFieldByIndex(delta_t *pFields, int fieldNumber) -{ - pFields->pdd[fieldNumber].flags &= ~FDT_MARK; -} - -void DELTA_ClearFlags(delta_t *pFields) -{ - for (int i = 0; i < pFields->fieldCount; i++) { - pFields->pdd[i].flags = 0; - } -} - -int DELTA_CountSendFields(delta_t *pFields) -{ - int i, c; - for (i = 0, c = 0; i < pFields->fieldCount; i++) - { - auto pitem = &pFields->pdd[i]; - if (pitem->flags & FDT_MARK) { - pitem->stats.sendcount++; - c++; - } - } - - return c; -} - -void DELTA_MarkSendFields(unsigned char *from, unsigned char *to, delta_t *pFields) -{ - int i; - char *st1, *st2; - delta_description_t *pTest; - int fieldType; - int fieldCount = pFields->fieldCount; - - for (i = 0, pTest = pFields->pdd; i < fieldCount; i++, pTest++) - { - fieldType = pTest->fieldType & ~DT_SIGNED; - switch (fieldType) - { - case DT_BYTE: - if (from[pTest->fieldOffset] != to[pTest->fieldOffset]) - pTest->flags |= FDT_MARK; - break; - case DT_SHORT: - if (*(uint16 *)&from[pTest->fieldOffset] != *(uint16 *)&to[pTest->fieldOffset]) - pTest->flags |= FDT_MARK; - break; - case DT_FLOAT: - case DT_INTEGER: - case DT_ANGLE: - if (*(uint32 *)&from[pTest->fieldOffset] != *(uint32 *)&to[pTest->fieldOffset]) - pTest->flags |= FDT_MARK; - break; - case DT_TIMEWINDOW_8: - case DT_TIMEWINDOW_BIG: - if (*(uint32 *)&from[pTest->fieldOffset] != *(uint32 *)&to[pTest->fieldOffset]) - pTest->flags |= FDT_MARK; - break; - case DT_STRING: - st1 = (char *)&from[pTest->fieldOffset]; - st2 = (char *)&to[pTest->fieldOffset]; - - // Not sure why it is case insensitive, but it looks so - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) { - pTest->flags |= FDT_MARK; - } - break; - default: - break; - } - } - - if (pFields->conditionalencode) { - pFields->conditionalencode(pFields, from, to); - } -} - -void DELTA_SetSendFlagBits(delta_t *pFields, int *bits, int *bytecount) -{ - int i; - int lastbit = -1; - int fieldCount = pFields->fieldCount; - - Q_memset(bits, 0, 8); - - for (i = fieldCount - 1; i >= 0; i--) - { - if (pFields->pdd[i].flags & FDT_MARK) - { - if (lastbit == -1) { - lastbit = i; - } - - bits[i > 31 ? 1 : 0] |= 1 << (i & 0x1f); - } - } - - // fix for bad bytecount when no fields are marked - if (lastbit == -1) { - *bytecount = 0; - return; - } - - *bytecount = (lastbit >> 3) + 1; -} - -void DELTA_WriteMarkedFields(BitBuffer *stream, unsigned char *from, unsigned char *to, delta_t *pFields) -{ - int i; - delta_description_t *pTest; - int fieldSign; - int fieldType; - - float f2; - int fieldCount = pFields->fieldCount; - - for (i = 0, pTest = pFields->pdd; i < fieldCount; i++, pTest++) - { - if (!(pTest->flags & FDT_MARK)) - continue; - - fieldSign = pTest->fieldType & DT_SIGNED; - fieldType = pTest->fieldType & ~DT_SIGNED; - switch (fieldType) - { - case DT_BYTE: - if (fieldSign) - { - int8 si8 = *(int8 *)&to[pTest->fieldOffset]; - si8 = (int8)((double)si8 * pTest->premultiply); - stream->WriteSBits(si8, pTest->significant_bits); - } - else - { - uint8 i8 = *(uint8 *)&to[pTest->fieldOffset]; - i8 = (uint8)((double)i8 * pTest->premultiply); - stream->WriteBits(i8, pTest->significant_bits); - } - break; - case DT_SHORT: - if (fieldSign) - { - int16 si16 = *(int16 *)&to[pTest->fieldOffset]; - si16 = (int16)((double)si16 * pTest->premultiply); - stream->WriteSBits(si16, pTest->significant_bits); - } - else - { - uint16 i16 = *(uint16 *)&to[pTest->fieldOffset]; - i16 = (uint16)((double)i16 * pTest->premultiply); - stream->WriteBits(i16, pTest->significant_bits); - } - break; - case DT_FLOAT: - { - double val = (double)(*(float *)&to[pTest->fieldOffset]) * pTest->premultiply; - if (fieldSign) - { - stream->WriteSBits((int32)val, pTest->significant_bits); - } - else - { - stream->WriteBits((uint32)val, pTest->significant_bits); - } - break; - } - case DT_INTEGER: - { - if (fieldSign) - { - int32 signedInt = *(int32 *)&to[pTest->fieldOffset]; - if (pTest->premultiply < 0.9999 || pTest->premultiply > 1.0001) { - signedInt = (int32)((double)signedInt * pTest->premultiply); - } - - stream->WriteSBits(signedInt, pTest->significant_bits); - } - else - { - uint32 unsignedInt = *(uint32 *)&to[pTest->fieldOffset]; - if (pTest->premultiply < 0.9999 || pTest->premultiply > 1.0001) { - unsignedInt = (uint32)((double)unsignedInt * pTest->premultiply); - } - - stream->WriteBits(unsignedInt, pTest->significant_bits); - } - break; - } - case DT_ANGLE: - f2 = *(float *)&to[pTest->fieldOffset]; - stream->WriteBitAngle(f2, pTest->significant_bits); - break; - case DT_TIMEWINDOW_8: - { - f2 = *(float *)&to[pTest->fieldOffset]; - if (g_large_Time_Buffers) { - stream->WriteFloat(f2); - } else { - int32 twVal = (int)(g_delta_Time * 100.0) - (int)(f2 * 100.0); - stream->WriteSBits(twVal, 8); - } - break; - } - case DT_TIMEWINDOW_BIG: - { - f2 = *(float *)&to[pTest->fieldOffset]; - if (g_large_Time_Buffers) { - stream->WriteFloat(f2); - } else { - int32 twVal = (int)(g_delta_Time * pTest->premultiply) - (int)(f2 * pTest->premultiply); - stream->WriteSBits((int32)twVal, pTest->significant_bits); - } - break; - } - case DT_STRING: - stream->WriteBitString((const char *)&to[pTest->fieldOffset]); - break; - default: - break; - } - } -} - -int DELTA_CheckDelta(unsigned char *from, unsigned char *to, delta_t *pFields) -{ - DELTA_ClearFlags(pFields); - DELTA_MarkSendFields(from, to, pFields); - - return DELTA_CountSendFields(pFields); -} - -void DELTA_WriteHeader(BitBuffer *stream, deltacallback_t *header) -{ - int delta = header->num - header->numbase; - if (header->full) - { - if (delta == 1) - { - stream->WriteBit(1); - } - else - { - stream->WriteBit(0); - if (delta <= 0 || delta >= 64) - { - stream->WriteBit(1); - stream->WriteBits(header->num, 11); - } - else - { - stream->WriteBit(0); - stream->WriteBits(delta, 6); - } - } - } - else - { - stream->WriteBit(header->remove != 0); - if (delta <= 0 || delta >= 64) - { - stream->WriteBit(1); - stream->WriteBits(header->num, 11); - } - else - { - stream->WriteBit(0); - stream->WriteBits(delta, 6); - } - } - - header->numbase = header->num; - if (!header->remove) - { - stream->WriteBit(header->custom != 0); - if (header->instanced_baseline) - { - if (header->newbl) - { - stream->WriteBit(1); - stream->WriteBits(header->newblindex, 6); - } - else - { - stream->WriteBit(0); - } - } - if (header->full && !header->newbl) - { - if (header->offset) - { - stream->WriteBit(1); - stream->WriteBits(header->offset, 6); - } - else - { - stream->WriteBit(0); - } - } - } -} - -qboolean DELTA_WriteDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, bool force, delta_t *pFields, deltacallback_t *header) -{ - int i; - int bytecount; - int bits[2]; - - if (!DELTA_CheckDelta(from, to, pFields) && !force) { - return FALSE; - } - - DELTA_SetSendFlagBits(pFields, bits, &bytecount); - - if (header) { - DELTA_WriteHeader(stream, header); - } - - stream->WriteBits(bytecount, 3); - for (i = 0; i < bytecount; i++) { - stream->WriteBits(((byte *)bits)[i], 8); - } - - DELTA_WriteMarkedFields(stream, from, to, pFields); - return TRUE; -} - -int DELTA_ParseDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, delta_t *pFields) -{ - delta_description_t *pTest; - int i; - int bits[2]; // this is a limit with 64 fields max in delta - int nbytes; - int bitfieldnumber; - int fieldCount = pFields->fieldCount; - int fieldType; - int fieldSign; - - double d2; - float t; - int addt; - char *st2; - char c; - int startbit; - - startbit = stream->CurrentBit(); - Q_memset(bits, 0, sizeof(bits)); - - nbytes = stream->ReadBits(3); - for (i = 0; i < nbytes; i++) { - ((byte *)bits)[i] = stream->ReadBits(8); - } - - for (i = 0, pTest = pFields->pdd; i < fieldCount; i++, pTest++) - { - fieldType = pTest->fieldType & ~DT_SIGNED; - - bitfieldnumber = (1 << (i & 0x1F)); - if (!(bitfieldnumber & bits[i > 31])) - { - // Field was not sent to us, just transfer info from the "from" - switch (fieldType) - { - case DT_BYTE: - to[pTest->fieldOffset] = from[pTest->fieldOffset]; - break; - case DT_SHORT: - *(uint16 *)&to[pTest->fieldOffset] = *(uint16 *)&from[pTest->fieldOffset]; - break; - case DT_FLOAT: - case DT_INTEGER: - case DT_ANGLE: - case DT_TIMEWINDOW_8: - case DT_TIMEWINDOW_BIG: - *(uint32 *)&to[pTest->fieldOffset] = *(uint32 *)&from[pTest->fieldOffset]; - break; - case DT_STRING: - Q_strcpy((char *)&to[pTest->fieldOffset], (char *)&from[pTest->fieldOffset]); - break; - default: - break; - } - continue; - } - - pTest->stats.receivedcount++; - fieldSign = pTest->fieldType & DT_SIGNED; - - switch (fieldType) - { - case DT_BYTE: - if (fieldSign) - { - d2 = (double)stream->ReadSBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(int8 *)&to[pTest->fieldOffset] = (int8)d2; - } - else - { - d2 = (double)stream->ReadBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(uint8 *)&to[pTest->fieldOffset] = (uint8)d2; - } - break; - case DT_SHORT: - if (fieldSign) - { - d2 = (double)stream->ReadSBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(int16 *)&to[pTest->fieldOffset] = (int16)d2; - } - else - { - d2 = (double)stream->ReadBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(uint16 *)&to[pTest->fieldOffset] = (uint16)d2; - } - break; - case DT_FLOAT: - if (fieldSign) - { - d2 = (double)stream->ReadSBits(pTest->significant_bits); - } - else - { - d2 = (double)stream->ReadBits(pTest->significant_bits); - } - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(float *)&to[pTest->fieldOffset] = (float)d2; - break; - case DT_INTEGER: - if (fieldSign) - { - d2 = (double)stream->ReadSBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(int32 *)&to[pTest->fieldOffset] = (int32)d2; - } - else - { - d2 = (double)stream->ReadBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - d2 = d2 / pTest->premultiply; - } -#if !defined(HLTV) - if (pTest->postmultiply <= 0.9999 || pTest->postmultiply >= 1.0001) { - d2 = d2 * pTest->postmultiply; - } -#endif - *(uint32 *)&to[pTest->fieldOffset] = (uint32)d2; - } - break; - case DT_ANGLE: - *(float *)&to[pTest->fieldOffset] = stream->ReadBitAngle(pTest->significant_bits); - break; - case DT_TIMEWINDOW_8: - if (g_large_Time_Buffers) { - t = stream->ReadFloat(); - } - else { - addt = stream->ReadSBits(8); - t = (float)((g_delta_Time * 100.0 - addt) / 100.0); - } - *(float *)&to[pTest->fieldOffset] = t; - break; - case DT_TIMEWINDOW_BIG: - if (g_large_Time_Buffers) { - t = stream->ReadFloat(); - } - else { - addt = stream->ReadSBits(pTest->significant_bits); - if (pTest->premultiply <= 0.9999 || pTest->premultiply >= 1.0001) { - t = (float)((g_delta_Time * pTest->premultiply - addt) / pTest->premultiply); - } - else { - t = (float)(g_delta_Time - addt); - } - } - - *(float *)&to[pTest->fieldOffset] = t; - break; - case DT_STRING: - st2 = (char *)&to[pTest->fieldOffset]; - do - { - c = stream->ReadBits(8); - *st2++ = c; - } while (c); - break; - default: - break; - } - } - - return stream->CurrentBit() - startbit; -} - -int DELTA_TestDelta(unsigned char *from, unsigned char *to, delta_t *pFields) -{ - int i; - char *st1, *st2; - delta_description_t *pTest; - int fieldType; - int fieldCount = pFields->fieldCount; - int length = 0; - bool different; - int neededBits = 0; - int highestBit = -1; - - for (i = 0, pTest = pFields->pdd; i < fieldCount; i++, pTest++) - { - different = false; - fieldType = pTest->fieldType & ~DT_SIGNED; - - switch (fieldType) - { - case DT_BYTE: - different = from[pTest->fieldOffset] != to[pTest->fieldOffset]; - break; - case DT_SHORT: - different = *(uint16 *)&from[pTest->fieldOffset] != *(uint16 *)&to[pTest->fieldOffset]; - break; - case DT_FLOAT: - case DT_INTEGER: - case DT_ANGLE: - different = *(uint32 *)&from[pTest->fieldOffset] != *(uint32 *)&to[pTest->fieldOffset]; - break; - // don't use multiplier when checking, to increase performance - // check values binary like it does in jit - case DT_TIMEWINDOW_8: - case DT_TIMEWINDOW_BIG: - different = (*(int32 *)&from[pTest->fieldOffset]) != (*(int32 *)&to[pTest->fieldOffset]); - break; - case DT_STRING: - st1 = (char *)&from[pTest->fieldOffset]; - st2 = (char *)&to[pTest->fieldOffset]; - - // Not sure why it is case insensitive, but it looks so - if (!(!*st1 && !*st2 || *st1 && *st2 && !Q_stricmp(st1, st2))) - { - different = true; - length = Q_strlen(st2) * 8; - pTest->flags |= FDT_MARK; - } - break; - default: - break; - } - - if (different) - { - highestBit = i; - neededBits += (fieldType == DT_STRING) ? length + 8 : pTest->significant_bits; - } - } - - if (highestBit != -1) { - neededBits += highestBit / 8 * 8 + 8; - } - - return neededBits; -} - -void DELTA_AddEncoder(char *name, encoder_t conditionalencode) -{ - delta_encoder_t *delta = (delta_encoder_t *)Mem_ZeroMalloc(sizeof(delta_encoder_t)); - delta->name = Q_strdup(name); - delta->conditionalencode = conditionalencode; - delta->next = g_encoders; - g_encoders = delta; -} - -void DELTA_ClearEncoders() -{ - delta_encoder_t *n, *p = g_encoders; - while (p) - { - n = p->next; - Mem_Free(p->name); - Mem_Free(p); - p = n; - } - - g_encoders = nullptr; -} - -encoder_t DELTA_LookupEncoder(char *name) -{ - delta_encoder_t *p = g_encoders; - while (p) - { - if (Q_stricmp(name, p->name) == 0) { - return p->conditionalencode; - } - - p = p->next; - } - - return nullptr; -} - -int DELTA_CountLinks(delta_link_t *plinks) -{ - delta_link_t *p = plinks; - - int c; - for (c = 0; p; c++) { - p = p->next; - } - - return c; -} - -void DELTA_ReverseLinks(delta_link_t **plinks) -{ - delta_link_t *n, *p = *plinks; - delta_link_t *newlist = nullptr; - - while (p) - { - n = p->next; - p->next = newlist; - newlist = p; - p = n; - } - - *plinks = newlist; -} - -void DELTA_ClearLinks(delta_link_t **plinks) -{ - delta_link_t *n, *p = *plinks; - while (p) - { - n = p->next; - Mem_Free(p); - p = n; - } - *plinks = 0; -} - -delta_t *DELTA_BuildFromLinks(delta_link_t **pplinks) -{ - delta_description_t *pdesc, *pcur; - delta_t *pdelta; - delta_link_t *p; - int count; - - pdelta = (delta_t *)Mem_ZeroMalloc(sizeof(delta_t)); - DELTA_ReverseLinks(pplinks); - count = DELTA_CountLinks(*pplinks); - - if (count > DELTA_MAX_FIELDS) { - return nullptr; - } - - pdesc = (delta_description_t *)Mem_ZeroMalloc(sizeof(delta_description_t) * count); - - for (p = *pplinks, pcur = pdesc; p; p = p->next, pcur++) - { - Q_memcpy(pcur, p->delta, sizeof(delta_description_t)); - Mem_Free(p->delta); - p->delta = nullptr; - } - - DELTA_ClearLinks(pplinks); - - pdelta->dynamic = 1; - pdelta->fieldCount = count; - pdelta->pdd = pdesc; - - return pdelta; -} - -int DELTA_FindOffset(int count, delta_definition_t *pdef, char *fieldname) -{ - for (int i = 0; i < count; i++) - { - if (Q_stricmp(fieldname, pdef[i].fieldName) == 0) { - return pdef[i].fieldOffset; - } - } - - return 0; -} - -bool DELTA_ParseType(delta_description_t *pdelta, char **pstream) -{ - // Read the stream till we hit the end - while (*pstream = COM_Parse(*pstream), com_token[0] != 0) - { - if (!Q_stricmp(com_token, ",")) - return true; // end of type description - - if (!Q_stricmp(com_token, "|")) - continue; // skip | token - - // Determine field type - if (!Q_stricmp(com_token, "DT_SIGNED")) - pdelta->fieldType |= DT_SIGNED; - else if (!Q_stricmp(com_token, "DT_BYTE")) - pdelta->fieldType |= DT_BYTE; - else if (!Q_stricmp(com_token, "DT_SHORT")) - pdelta->fieldType |= DT_SHORT; - else if (!Q_stricmp(com_token, "DT_FLOAT")) - pdelta->fieldType |= DT_FLOAT; - else if (!Q_stricmp(com_token, "DT_INTEGER")) - pdelta->fieldType |= DT_INTEGER; - else if (!Q_stricmp(com_token, "DT_ANGLE")) - pdelta->fieldType |= DT_ANGLE; - else if (!Q_stricmp(com_token, "DT_TIMEWINDOW_8")) - pdelta->fieldType |= DT_TIMEWINDOW_8; - else if (!Q_stricmp(com_token, "DT_TIMEWINDOW_BIG")) - pdelta->fieldType |= DT_TIMEWINDOW_BIG; - else if (!Q_stricmp(com_token, "DT_STRING")) - pdelta->fieldType |= DT_STRING; - else - { - return false; - } - } - - // We are hit the end of the stream - return false; -} - -bool DELTA_ParseField(int count, delta_definition_t *pdefinition, delta_link_t *pField, char **pstream) -{ - bool readpost = false; - if (Q_stricmp(com_token, "DEFINE_DELTA")) - { - if (Q_stricmp(com_token, "DEFINE_DELTA_POST") != 0) { - return false; - } - - readpost = true; - } - - *pstream = COM_Parse(*pstream); - if (Q_stricmp(com_token, "(")) - { - return false; - } - - *pstream = COM_Parse(*pstream); - if (com_token[0] == '\0') - { - return false; - } - - Q_strlcpy(pField->delta->fieldName, com_token); - - pField->delta->fieldOffset = DELTA_FindOffset(count, pdefinition, com_token); - - *pstream = COM_Parse(*pstream); - if (!DELTA_ParseType(pField->delta, pstream)) { - return false; - } - - *pstream = COM_Parse(*pstream); - pField->delta->fieldSize = 1; - pField->delta->significant_bits = Q_atoi(com_token); - *pstream = COM_Parse(*pstream); - *pstream = COM_Parse(*pstream); - pField->delta->premultiply = (float)Q_atof(com_token); - - if (readpost) - { - *pstream = COM_Parse(*pstream); - *pstream = COM_Parse(*pstream); - pField->delta->postmultiply = (float)Q_atof(com_token); - } - else - { - pField->delta->postmultiply = 1.0; - } - - *pstream = COM_Parse(*pstream); - if (Q_stricmp(com_token, ")")) - { - return false; - } - - *pstream = COM_Parse(*pstream); - if (Q_stricmp(com_token, ",")) { - COM_UngetToken(); - } - - return true; -} - -void DELTA_FreeDescription(delta_t **ppdesc) -{ - if (ppdesc && *ppdesc) - { - if ((*ppdesc)->dynamic) { - Mem_Free((*ppdesc)->pdd); - } - - Mem_Free(*ppdesc); - *ppdesc = nullptr; - } -} - -void DELTA_AddDefinition(char *name, delta_definition_t *pdef, int numelements) -{ - delta_definition_list_t *p = g_defs; - while (p) - { - if (Q_stricmp(name, p->ptypename) == 0) { - break; - } - - p = p->next; - } - - if (!p) - { - p = (delta_definition_list_t *)Mem_ZeroMalloc(sizeof(delta_definition_list_t)); - p->ptypename = Q_strdup(name); - p->next = g_defs; - g_defs = p; - } - - p->pdefinition = pdef; - p->numelements = numelements; -} - -void DELTA_ClearDefinitions() -{ - delta_definition_list_t *n, *p = g_defs; - while (p) - { - n = p->next; - Mem_Free(p->ptypename); - Mem_Free(p); - p = n; - } - - g_defs = nullptr; -} - -delta_definition_t *DELTA_FindDefinition(char *name, int *count) -{ - *count = 0; - - delta_definition_list_t *p = g_defs; - while (p) - { - if (!Q_stricmp(name, p->ptypename)) - { - *count = p->numelements; - return p->pdefinition; - } - - p = p->next; - } - - return nullptr; -} - -void DELTA_SkipDescription(char **pstream) -{ - *pstream = COM_Parse(*pstream); - do - { - *pstream = COM_Parse(*pstream); - if (com_token[0] == '\0') { - return; - } - } - while (Q_stricmp(com_token, "}")); -} - -bool DELTA_ParseOneField(char **ppstream, delta_link_t **pplist, int count, delta_definition_t *pdefinition) -{ - delta_link_t *newlink; - delta_link_t link; - - while (true) - { - if (!Q_stricmp(com_token, "}")) - { - COM_UngetToken(); - break; - } - - *ppstream = COM_Parse(*ppstream); - if (com_token[0] == '\0') { - break; - } - - Q_memset(&link, 0, sizeof(link)); - link.delta = (delta_description_t *)Mem_ZeroMalloc(sizeof(delta_description_t)); - if (!DELTA_ParseField(count, pdefinition, &link, ppstream)) { - return false; - } - - newlink = (delta_link_t *)Mem_ZeroMalloc(sizeof(delta_link_t)); - newlink->delta = link.delta; - newlink->next = *pplist; - *pplist = newlink; - } - - return true; -} - -bool DELTA_ParseDescription(char *name, delta_t **ppdesc, char *pstream) -{ - delta_link_t *links = nullptr; - delta_definition_t *pdefinition; - char encoder[32] = ""; - char source[32]; - int count = 0; - - if (!ppdesc) { - return false; - } - - *ppdesc = nullptr; - - if (!pstream) { - return false; - } - - while (true) - { - // Parse delta name - pstream = COM_Parse(pstream); - if (com_token[0] == '\0') { - break; - } - - if (Q_stricmp(com_token, name)) - { - DELTA_SkipDescription(&pstream); - } - else - { - pdefinition = DELTA_FindDefinition(com_token, &count); - if (!pdefinition) { - return false; - } - - // Parse source of conditional encoder - pstream = COM_Parse(pstream); - if (com_token[0] == '\0') { - return false; - } - - if (Q_stricmp(com_token, "none")) - { - Q_strlcpy(source, com_token); - - // Parse custom encoder function name - pstream = COM_Parse(pstream); - if (com_token[0] == '\0') { - return false; - } - - Q_strlcpy(encoder, com_token); - } - - // Parse fields - while (true) - { - pstream = COM_Parse(pstream); - if (com_token[0] == '\0') { - break; - } - - if (!Q_stricmp(com_token, "}")) { - break; - } - - if (Q_stricmp(com_token, "{")) { - return false; - } - - if (!DELTA_ParseOneField(&pstream, &links, count, pdefinition)) { - return false; - } - } - } - } - - *ppdesc = DELTA_BuildFromLinks(&links); - - if (encoder[0]) - { - Q_strlcpy((*ppdesc)->conditionalencodename, encoder1); - (*ppdesc)->conditionalencode = nullptr; - } - - return true; -} - -bool DELTA_Load(char *name, delta_t **ppdesc, char *pszFile) -{ - return false; -} - -void DELTA_RegisterDescription(char *name) -{ - delta_registry_t *p = (delta_registry_t *)Mem_ZeroMalloc(sizeof(delta_registry_t)); - p->next = g_deltaregistry; - g_deltaregistry = p; - p->name = Q_strdup(name); - p->pdesc = 0; -} - -void DELTA_ClearRegistrations() -{ - delta_registry_t *n, *p = g_deltaregistry; - while (p) - { - n = p->next; - Mem_Free(p->name); - - if (p->pdesc) { - DELTA_FreeDescription(&p->pdesc); - } - - Mem_Free(p); - p = n; - } - - g_deltaregistry = nullptr; -} - -delta_t **DELTA_LookupRegistration(char *name) -{ - delta_registry_t *delta = g_deltaregistry; - while (delta) - { - if (Q_stricmp(delta->name, name) == 0) { - return &delta->pdesc; - } - - delta = delta->next; - } - - return nullptr; -} - -void DELTA_ClearStats(delta_t *p) -{ - if (!p) { - return; - } - - for (int i = 0; i < p->fieldCount; i++) - { - p->pdd[i].stats.sendcount = 0; - p->pdd[i].stats.receivedcount = 0; - } -} - -void DELTA_Init() -{ - g_defs = nullptr; - g_encoders = nullptr; - g_deltaregistry = nullptr; - - DELTA_AddDefinition("clientdata_t", g_ClientDataDefinition, ARRAYSIZE(g_ClientDataDefinition)); - DELTA_AddDefinition("weapon_data_t", g_WeaponDataDefinition, ARRAYSIZE(g_WeaponDataDefinition)); - DELTA_AddDefinition("usercmd_t", g_UsercmdDataDefinition, ARRAYSIZE(g_UsercmdDataDefinition)); - DELTA_AddDefinition("entity_state_t", g_EntityDataDefinition, ARRAYSIZE(g_EntityDataDefinition)); - DELTA_AddDefinition("entity_state_player_t", g_EntityDataDefinition, ARRAYSIZE(g_EntityDataDefinition)); - DELTA_AddDefinition("custom_entity_state_t", g_EntityDataDefinition, ARRAYSIZE(g_EntityDataDefinition)); - DELTA_AddDefinition("event_t", g_EventDataDefinition, ARRAYSIZE(g_EventDataDefinition)); - - DELTA_RegisterDescription("clientdata_t"); - DELTA_RegisterDescription("entity_state_t"); - DELTA_RegisterDescription("entity_state_player_t"); - DELTA_RegisterDescription("custom_entity_state_t"); - DELTA_RegisterDescription("usercmd_t"); - DELTA_RegisterDescription("weapon_data_t"); - DELTA_RegisterDescription("event_t"); - - g_large_Time_Buffers = false; -} - -void DELTA_UpdateDescriptions() -{ - g_pplayerdelta = *DELTA_LookupRegistration("entity_state_player_t"); - g_pentitydelta = *DELTA_LookupRegistration("entity_state_t"); - g_pcustomentitydelta = *DELTA_LookupRegistration("custom_entity_state_t"); - g_pclientdelta = *DELTA_LookupRegistration("clientdata_t"); - g_pweapondelta = *DELTA_LookupRegistration("weapon_data_t"); - g_peventdelta = *DELTA_LookupRegistration("event_t"); -} - -void DELTA_Shutdown() -{ - DELTA_ClearEncoders(); - DELTA_ClearDefinitions(); - DELTA_ClearRegistrations(); -} - -void DELTA_SetTime(double time) -{ - g_delta_Time = time; -} - -void DELTA_SetLargeTimeBufferSize(bool bigBuffers) -{ - g_large_Time_Buffers = bigBuffers; -} - -bool World::IsDeltaEncoder() const -{ - if (g_pcustomentitydelta - && g_pentitydelta - && g_pplayerdelta) { - return true; - } - - return false; -} - -delta_t *World::GetDeltaEncoder(int index, bool custom) -{ - if (custom) { - return (delta_t *)g_pcustomentitydelta; - } - else if (IsPlayerIndex(index)) { - return (delta_t *)g_pplayerdelta; - } - - return (delta_t *)g_pentitydelta; -} - -delta_t *World::GetEventDelta() const { - return g_peventdelta; -} - -delta_t *World::GetClientDelta() const { - return g_pclientdelta; -} - -delta_t *World::GetEntityDelta() const { - return g_pentitydelta; -} - -delta_t *World::GetWeaponDelta() const { - return g_pweapondelta; -} - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Core/DeltaEx.h b/rehlds/hookers/HLTV/Core/DeltaEx.h deleted file mode 100644 index 06db8ed..0000000 --- a/rehlds/hookers/HLTV/Core/DeltaEx.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifdef HOOK_HLTV - -#include "event_args.h" - -#define g_defs (*pg_defs) -#define g_encoders (*pg_encoders) -#define g_deltaregistry (*pg_deltaregistry) - -#define g_pplayerdelta (*pg_pplayerdelta) -#define g_pentitydelta (*pg_pentitydelta) -#define g_pcustomentitydelta (*pg_pcustomentitydelta) -#define g_pclientdelta (*pg_pclientdelta) -#define g_pweapondelta (*pg_pweapondelta) -#define g_peventdelta (*pg_peventdelta) - -#define g_delta_Time (*pg_delta_Time) -#define g_large_Time_Buffers (*pg_large_Time_Buffers) - -typedef struct delta_link_s -{ - struct delta_link_s *next; - delta_description_t *delta; -} delta_link_t; - -typedef struct delta_definition_s -{ - char *fieldName; - size_t fieldOffset; -} delta_definition_t; - -typedef struct delta_definition_list_s -{ - struct delta_definition_list_s *next; - char *ptypename; - int numelements; - delta_definition_t *pdefinition; -} delta_definition_list_t; - -typedef struct delta_registry_s -{ - struct delta_registry_s *next; - char *name; - delta_t *pdesc; -} delta_registry_t; - -namespace Delta { - #define m_MetaDelta g_MetaDelta - extern delta_t g_MetaDelta[]; -}; - -#define m_EntityDelta g_pentitydelta -#define m_PlayerDelta g_pplayerdelta -#define m_CustomentityDelta g_pcustomentitydelta - -#define m_ClientDelta g_pclientdelta -#define m_WeaponDelta g_pweapondelta -#define m_EventDelta g_peventdelta - -extern delta_definition_list_t *g_defs; -extern delta_encoder_t *g_encoders; -extern delta_registry_t *g_deltaregistry; - -extern delta_t *g_pentitydelta; -extern delta_t *g_pplayerdelta; -extern delta_t *g_pcustomentitydelta; -extern delta_t *g_pclientdelta; -extern delta_t *g_pweapondelta; -extern delta_t *g_peventdelta; - -extern double g_delta_Time; -extern bool g_large_Time_Buffers; - -delta_description_t *DELTA_FindField(delta_t *pFields, const char *pszField); -int DELTA_FindFieldIndex(delta_t *pFields, const char *fieldname); -void DELTA_SetField(delta_t *pFields, const char *fieldname); -void DELTA_UnsetField(delta_t *pFields, const char *fieldname); -void DELTA_SetFieldByIndex(delta_t *pFields, int fieldNumber); -void DELTA_UnsetFieldByIndex(delta_t *pFields, int fieldNumber); -void DELTA_ClearFlags(delta_t *pFields); -int DELTA_CountSendFields(delta_t *pFields); -void DELTA_MarkSendFields(unsigned char *from, unsigned char *to, delta_t *pFields); -void DELTA_SetSendFlagBits(delta_t *pFields, int *bits, int *bytecount); -void DELTA_WriteMarkedFields(BitBuffer *stream, unsigned char *from, unsigned char *to, delta_t *pFields); -int DELTA_CheckDelta(unsigned char *from, unsigned char *to, delta_t *pFields); -void DELTA_WriteHeader(BitBuffer *stream, deltacallback_t *header); -qboolean DELTA_WriteDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, bool force, delta_t *pFields, deltacallback_t *header = nullptr); -int DELTA_ParseDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, delta_t *pFields); -int DELTA_TestDelta(unsigned char *from, unsigned char *to, delta_t *pFields); -void DELTA_AddEncoder(char *name, encoder_t conditionalencode); -void DELTA_ClearEncoders(); -encoder_t DELTA_LookupEncoder(char *name); -int DELTA_CountLinks(delta_link_t *plinks); -void DELTA_ReverseLinks(delta_link_t **plinks); -void DELTA_ClearLinks(delta_link_t **plinks); -delta_t *DELTA_BuildFromLinks(delta_link_t **pplinks); -int DELTA_FindOffset(int count, delta_definition_t *pdef, char *fieldname); -bool DELTA_ParseType(delta_description_t *pdelta, char **pstream); -bool DELTA_ParseField(int count, delta_definition_t *pdefinition, delta_link_t *pField, char **pstream); -void DELTA_FreeDescription(delta_t **ppdesc); -void DELTA_AddDefinition(char *name, delta_definition_t *pdef, int numelements); -void DELTA_ClearDefinitions(); -delta_definition_t *DELTA_FindDefinition(char *name, int *count); -void DELTA_SkipDescription(char **pstream); -bool DELTA_ParseOneField(char **ppstream, delta_link_t **pplist, int count, delta_definition_t *pdefinition); -bool DELTA_ParseDescription(char *name, delta_t **ppdesc, char *pstream); -bool DELTA_Load(char *name, delta_t **ppdesc, char *pszFile); -void DELTA_RegisterDescription(char *name); -void DELTA_ClearRegistrations(); -delta_t **DELTA_LookupRegistration(char *name); -void DELTA_ClearStats(delta_t *p); -void DELTA_Init(); -void DELTA_UpdateDescriptions(); -void DELTA_Shutdown(); -void DELTA_SetTime(double time); -void DELTA_SetLargeTimeBufferSize(bool bigBuffers); - -class DeltaWrapper { -public: - void Init(IBaseSystem *system) { DELTA_Init(); } - void Shutdown() { DELTA_Shutdown(); } - void UpdateDescriptions() { DELTA_UpdateDescriptions(); } - void WriteHeader(BitBuffer *stream, deltacallback_t *header) { DELTA_WriteHeader(stream, header); } - bool WriteDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, bool force, delta_t *pFields, deltacallback_t *header = nullptr) { return DELTA_WriteDelta(stream, from, to, force, pFields, header) ? true : false; } - int ParseDelta(BitBuffer *stream, unsigned char *from, unsigned char *to, delta_t *pFields) { return DELTA_ParseDelta(stream, from, to, pFields); } - void SetTime(double time) { DELTA_SetTime(time); } - void SetLargeTimeBufferSize(bool bigBuffers) { DELTA_SetLargeTimeBufferSize(bigBuffers); } - int TestDelta(unsigned char *from, unsigned char *to, delta_t *pFields) { return DELTA_TestDelta(from, to, pFields); } - delta_t **LookupRegistration(char *name) { return DELTA_LookupRegistration(name); } - void FreeDescription(delta_t **ppdesc) { DELTA_FreeDescription(ppdesc); } - delta_registry_t *GetRegistry() const { return g_deltaregistry; } -}; - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Core/hooklist.cpp b/rehlds/hookers/HLTV/Core/hooklist.cpp deleted file mode 100644 index d306a03..0000000 --- a/rehlds/hookers/HLTV/Core/hooklist.cpp +++ /dev/null @@ -1,617 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -#ifdef HOOK_HLTV - -// Hooks stuff -#include "hookers/memory.cpp" -#include "hookers/hooker.cpp" - -//#define Mem_region -//#define World_region -//#define Server_region -//#define Network_region -//#define NetSocket_region -//#define BSPModel_region -//#define Delta_region -//#define ObjectDictionary_region -//#define ObjectList_region -//#define BitBuffer_region -//#define Function_References_region -//#define Data_References_region - -FunctionHook g_FunctionHooks[] = -{ - // DO NOT DISABLE, other functions depends on memory allocation routines -#ifndef Mem_region - - HOOK_DEF(0x01D21F5F, malloc_wrapper), - HOOK_DEF(0x01D21E4E, free_wrapper), - HOOK_DEF(0x01D30145, strdup_wrapper), - HOOK_DEF(0x01D21F71, __nh_malloc_wrapper), - - HOOK_DEF(0x01D043C0, Mem_ZeroMalloc), - //HOOK_DEF(0x0, Mem_Malloc), - //HOOK_DEF(0x0, Mem_Realloc), - //HOOK_DEF(0x0, Mem_Calloc), - //HOOK_DEF(0x0, Mem_Strdup), - //HOOK_DEF(0x0, Mem_Free), - - //HOOK_DEF(0x0, realloc_wrapper), - //HOOK_DEF(0x0, calloc_wrapper), - -#endif // Mem_region - -#ifndef World_region - - // World virtual functions - HOOK_VIRTUAL_DEF(0x01D14DA0, World::Init), - HOOK_VIRTUAL_DEF(0x01D15470, World::RunFrame), - HOOK_VIRTUAL_DEF(0x01D154F0, World::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D15490, World::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D15500, World::RegisterListener), - HOOK_VIRTUAL_DEF(0x01D15530, World::RemoveListener), - HOOK_VIRTUAL_DEF(0x01D15570, World::GetSystem), - HOOK_VIRTUAL_DEF(0x01D15580, World::GetSerial), - HOOK_VIRTUAL_DEF(0x01D17380, World::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D17370, World::GetType), - HOOK_VIRTUAL_DEF(0x01D15590, World::GetName), - HOOK_VIRTUAL_DEF(0x01D155C0, World::GetState), - HOOK_VIRTUAL_DEF(0x01D15620, World::GetVersion), - HOOK_VIRTUAL_DEF(0x01D14F70, World::ShutDown), - HOOK_VIRTUAL_DEF(0x01D175D0, World::GetTime), - HOOK_VIRTUAL_DEF(0x01D186A0, World::GetGameServerAddress), - HOOK_VIRTUAL_DEF(0x01D186B0, World::GetLevelName), - HOOK_VIRTUAL_DEF(0x01D186F0, World::GetGameDir), - HOOK_VIRTUAL_DEF(0x01D16470, World::GetFrameByTime), - HOOK_VIRTUAL_DEF(0x01D16420, World::GetFrameBySeqNr), - HOOK_VIRTUAL_DEF(0x01D16450, World::GetLastFrame), - HOOK_VIRTUAL_DEF(0x01D16460, World::GetFirstFrame), - HOOK_VIRTUAL_DEF(0x01D18700, World::GetServerCount), - HOOK_VIRTUAL_DEF(0x01D18670, World::GetSlotNumber), - HOOK_VIRTUAL_DEF(0x01D18710, World::GetMaxClients), - HOOK_VIRTUAL_DEF(0x01D15840, World::GetNumPlayers), - HOOK_VIRTUAL_DEF(0x01D186C0, World::GetWorldModel), - HOOK_VIRTUAL_DEF(0x01D18350, World::GetServerInfoString), - HOOK_VIRTUAL_DEF(0x01D18360, World::GetPlayerInfoString), - HOOK_VIRTUAL_DEF(0x01D15450, World::GetUserMsg), - HOOK_VIRTUAL_DEF(0x01D15A60, World::GetHostName), - HOOK_VIRTUAL_DEF(0x01D189A0, World::GetServerInfo), - HOOK_VIRTUAL_DEF(0x01D15510, World::IsPlayerIndex), - HOOK_VIRTUAL_DEF(0x01D18660, World::IsVoiceEnabled), - HOOK_VIRTUAL_DEF(0x01D15870, World::IsActive), - HOOK_VIRTUAL_DEF(0x01D18190, World::IsPaused), - HOOK_VIRTUAL_DEF(0x01D181A0, World::IsComplete), - HOOK_VIRTUAL_DEF(0x01D18D20, World::IsHLTV), - HOOK_VIRTUAL_DEF(0x01D15010, World::Reset), - HOOK_VIRTUAL_DEF(0x01D158A0, World::SetServerInfoString), - HOOK_VIRTUAL_DEF(0x01D18C30, World::UpdateServerInfo), - HOOK_VIRTUAL_DEF(0x01D18150, World::SetPaused), - HOOK_VIRTUAL_DEF(0x01D15630, World::SetTime), - HOOK_VIRTUAL_DEF(0x01D181B0, World::SetBufferSize), - HOOK_VIRTUAL_DEF(0x01D18690, World::SetVoiceEnabled), - HOOK_VIRTUAL_DEF(0x01D18130, World::SetMoveVars), - HOOK_VIRTUAL_DEF(0x01D18320, World::SetCDInfo), - HOOK_VIRTUAL_DEF(0x01D18D10, World::SetHLTV), - HOOK_VIRTUAL_DEF(0x01D183B0, World::SetExtraInfo), - HOOK_VIRTUAL_DEF(0x01D18680, World::SetViewEntity), - HOOK_VIRTUAL_DEF(0x01D18340, World::SetGameServerAddress), - HOOK_VIRTUAL_DEF(0x01D15680, World::SetHostName), - HOOK_VIRTUAL_DEF(0x01D15760, World::NewGame), - HOOK_VIRTUAL_DEF(0x01D17490, World::FinishGame), - HOOK_VIRTUAL_DEF(0x01D18720, World::SaveAsDemo), - HOOK_VIRTUAL_DEF(0x01D174C0, World::StopGame), - HOOK_VIRTUAL_DEF(0x01D17560, World::FindUserMsgByName), - HOOK_VIRTUAL_DEF(0x01D181F0, World::ParseDeltaDescription), - HOOK_VIRTUAL_DEF(0x01D18420, World::ParseBaseline), - HOOK_VIRTUAL_DEF(0x01D183F0, World::ParseEvent), - HOOK_VIRTUAL_DEF(0x01D16990, World::ParseClientData), - HOOK_VIRTUAL_DEF(0x01D18070, World::SetServerInfo, void(int, CRC32_t, unsigned char *, int, int, int, char *, char *, char *)), - HOOK_VIRTUAL_DEF(0x01D17470, World::SetServerInfo, void(serverinfo_t *)), - HOOK_VIRTUAL_DEF(0x01D16740, World::GetUncompressedFrame, bool(unsigned int, frame_t *)), - HOOK_VIRTUAL_DEF(0x01D17A60, World::UncompressEntitiesFromStream, bool(frame_t *, BitBuffer *)), - HOOK_VIRTUAL_DEF(0x01D175E0, World::UncompressEntitiesFromStream, bool(frame_t *, BitBuffer *, unsigned int)), - HOOK_VIRTUAL_DEF(0x01D167F0, World::GetClientData, bool(frame_t *, clientdata_t *)), - HOOK_VIRTUAL_DEF(0x01D167B0, World::GetClientData, bool(unsigned int, clientdata_t *)), - HOOK_VIRTUAL_DEF(0x01D160A0, World::AddFrame), - HOOK_VIRTUAL_DEF(0x01D153B0, World::AddResource), - HOOK_VIRTUAL_DEF(0x01D156E0, World::AddLightStyle), - HOOK_VIRTUAL_DEF(0x01D17520, World::AddSignonData), - HOOK_VIRTUAL_DEF(0x01D15130, World::AddUserMessage), - HOOK_VIRTUAL_DEF(0x01D154A0, World::AddBaselineEntity), - HOOK_VIRTUAL_DEF(0x01D155D0, World::AddInstancedBaselineEntity), - HOOK_VIRTUAL_DEF(0x01D151F0, World::UpdatePlayer), - HOOK_VIRTUAL_DEF(0x01D164C0, World::WriteFrame), - HOOK_VIRTUAL_DEF(0x01D17CB0, World::WriteNewData), - HOOK_VIRTUAL_DEF(0x01D16030, World::WriteClientUpdate), - HOOK_VIRTUAL_DEF(0x01D15D20, World::WriteMovevars), - HOOK_VIRTUAL_DEF(0x01D174F0, World::WriteSigonData), - HOOK_VIRTUAL_DEF(0x01D15A20, World::WriteLightStyles), - HOOK_VIRTUAL_DEF(0x01D17D80, World::RemoveFrames), - HOOK_VIRTUAL_DEF(0x01D17ED0, World::DuplicateFrames), - HOOK_VIRTUAL_DEF(0x01D17EF0, World::MoveFrames), - HOOK_VIRTUAL_DEF(0x01D17F10, World::RevertFrames), - - // World non-virtual functions - HOOK_DEF(0x01D16BA0, World::CompressFrame), - HOOK_DEF(0x01D16A80, World::ParseDeltaHeader), - HOOK_DEF(0x01D150D0, World::SetMaxClients), - HOOK_DEF(0x01D17D30, World::GetBufferedGameTime), - HOOK_DEF(0x01D15800, World::ConnectionComplete), - HOOK_DEF(0x01D15F00, World::WriteResources), - HOOK_DEF(0x01D15C60, World::WriteDeltaDescriptions), - HOOK_DEF(0x01D15EB0, World::WriteRegisteredUserMessages), - HOOK_DEF(0x01D158B0, World::WriteBaseline), - HOOK_DEF(0x01D15A80, World::WriteServerinfo), - HOOK_DEF(0x01D170E0, World::WritePacketEntities), - HOOK_DEF(0x01D189B0, World::WriteDeltaEntities), - HOOK_DEF(0x01D15790, World::SetState), - HOOK_DEF(0x01D15100, World::ClearUserMessages), - HOOK_DEF(0x01D17430, World::ClearServerInfo), - HOOK_DEF(0x01D15410, World::ClearResources), - HOOK_DEF(0x01D155A0, World::ClearInstancedBaseline), - HOOK_DEF(0x01D15540, World::ClearBaseline), - HOOK_DEF(0x01D156C0, World::ClearLightStyles), - HOOK_DEF(0x01D15880, World::ClearPlayers), - HOOK_DEF(0x01D17F30, World::ClearFrames), - HOOK_DEF(0x01D16E80, World::ClearEntityCache), - HOOK_DEF(0x01D16F30, World::GetFrameFromCache), - HOOK_DEF(0x01D17010, World::GetDeltaFromCache), - HOOK_DEF(0x01D17F90, World::CheckFrameBufferSize), - HOOK_DEF(0x01D18000, World::ReorderFrameTimes), - HOOK_DEF(0x01D16D20, World::FindBestBaseline), - HOOK_DEF(0x01D18A60, World::RearrangeFrame), - HOOK_DEF(0x01D16880, World::GetUncompressedFrame, bool(frame_t *deltaFrame, frame_t *frame)), - - //HOOK_DEF(0x01D17D00, World::SetName), // NOXREF - //HOOK_DEF(0x0, World::SetDirector), // NOXREF - //HOOK_DEF(0x0, World::SetTimeScale), // NOXREF - //HOOK_DEF(0x0, World::SetGameGroupAddress), // NOXREF - //HOOK_DEF(0x0, World::GetDirector), // NOXREF - //HOOK_DEF(0x0, World::WriteCustomDecals), // NOXREF - -#endif // World_region - -#ifndef Server_region - - // IServer virtual functions - HOOK_VIRTUAL_DEF(0x01D106B0, Server::Init), - HOOK_VIRTUAL_DEF(0x01D10C10, Server::RunFrame), - HOOK_VIRTUAL_DEF(0x01D10A90, Server::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D13870, Server::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D137F0, Server::GetType), - HOOK_VIRTUAL_DEF(0x01D10B80, Server::ShutDown), - HOOK_VIRTUAL_DEF(0x01D14220, Server::Connect), - HOOK_VIRTUAL_DEF(0x01D142F0, Server::LoadDemo), - HOOK_VIRTUAL_DEF(0x01D13E40, Server::Reconnect), - HOOK_VIRTUAL_DEF(0x01D13EA0, Server::Disconnect), - HOOK_VIRTUAL_DEF(0x01D14620, Server::Retry), - HOOK_VIRTUAL_DEF(0x01D14680, Server::StopRetry), - HOOK_VIRTUAL_DEF(0x01D14430, Server::SendStringCommand), - HOOK_VIRTUAL_DEF(0x01D14470, Server::SendHLTVCommand), - HOOK_VIRTUAL_DEF(0x01D140C0, Server::IsConnected), - HOOK_VIRTUAL_DEF(0x01D140D0, Server::IsDemoFile), - HOOK_VIRTUAL_DEF(0x01D140E0, Server::IsGameServer), - HOOK_VIRTUAL_DEF(0x01D140F0, Server::IsRelayProxy), - HOOK_VIRTUAL_DEF(0x01D11260, Server::IsVoiceBlocking), - HOOK_VIRTUAL_DEF(0x01D13A70, Server::SetProxy), - HOOK_VIRTUAL_DEF(0x01D13A90, Server::SetDirector), - HOOK_VIRTUAL_DEF(0x01D137A0, Server::SetPlayerName), - HOOK_VIRTUAL_DEF(0x01D146B0, Server::SetDelayReconnect), - HOOK_VIRTUAL_DEF(0x01D14690, Server::SetAutoRetry), - HOOK_VIRTUAL_DEF(0x01D11270, Server::SetVoiceBlocking), - HOOK_VIRTUAL_DEF(0x01D11280, Server::SetRate), - HOOK_VIRTUAL_DEF(0x01D112D0, Server::SetUpdateRate), - HOOK_VIRTUAL_DEF(0x01D14390, Server::SetUserInfo), - HOOK_VIRTUAL_DEF(0x01D13770, Server::SetProtocol), - HOOK_VIRTUAL_DEF(0x01D109C0, Server::SetGameDirectory), - HOOK_VIRTUAL_DEF(0x01D13730, Server::GetRate), - HOOK_VIRTUAL_DEF(0x01D13740, Server::GetUpdateRate), - HOOK_VIRTUAL_DEF(0x01D13720, Server::GetServerInfoString), - HOOK_VIRTUAL_DEF(0x01D137D0, Server::GetPlayerName), - - // Server virtual functions - HOOK_VIRTUAL_DEF(0x01D145A0, Server::GetTime), - HOOK_VIRTUAL_DEF(0x01D13800, Server::GetWorld), - HOOK_VIRTUAL_DEF(0x01D13830, Server::GetDemoFileName), - HOOK_VIRTUAL_DEF(0x01D13810, Server::GetAddress), - HOOK_VIRTUAL_DEF(0x01D13750, Server::GetAutoRetry), - HOOK_VIRTUAL_DEF(0x01D13850, Server::GetHostName), - HOOK_VIRTUAL_DEF(0x01D13860, Server::GetPacketLoss), - HOOK_VIRTUAL_DEF(0x01D13760, Server::GetProtocol), - - // Server non-virtual functions - HOOK_DEF(0x01D14190, Server::CheckAutoRetry), - HOOK_DEF(0x01D145B0, Server::CheckConnection), - HOOK_DEF(0x01D141F0, Server::ScheduleAutoRetry), - HOOK_DEF(0x01D11750, Server::AcceptConnection), - HOOK_DEF(0x01D116C0, Server::AcceptBadPassword), - HOOK_DEF(0x01D11700, Server::AcceptRejection), - HOOK_DEF(0x01D117D0, Server::AcceptRedirect), - HOOK_DEF(0x01D11460, Server::SendConnectPacket), - HOOK_DEF(0x01D132F0, Server::SendServerCommands), - HOOK_DEF(0x01D11320, Server::SetState), - HOOK_DEF(0x01D10AB0, Server::Challenge), - HOOK_DEF(0x01D146C0, Server::Reset), - HOOK_DEF(0x01D11170, Server::AcceptChallenge), - HOOK_DEF(0x01D14050, Server::SendUserVar), - HOOK_DEF(0x01D10F70, Server::ProcessMessage), - HOOK_DEF(0x01D147B0, Server::ProcessEntityUpdate), - HOOK_DEF(0x01D10DA0, Server::ProcessConnectionlessMessage), - HOOK_DEF(0x01D12EF0, Server::ClearFrame), - HOOK_DEF(0x01D139E0, Server::ParseHLTV), - HOOK_DEF(0x01D13AA0, Server::ParseDirector), - HOOK_DEF(0x01D12CA0, Server::ParseFileTransferFailed), - HOOK_DEF(0x01D13B80, Server::ParseInfo), - HOOK_DEF(0x01D136E0, Server::ParseParticle), - HOOK_DEF(0x01D136B0, Server::ParseRoomType), - HOOK_DEF(0x01D13610, Server::ParseSpawnStaticSound), - HOOK_DEF(0x01D13580, Server::ParseEventReliable), - HOOK_DEF(0x01D13510, Server::ParsePings), - HOOK_DEF(0x01D12CE0, Server::ParseSignonNum), - HOOK_DEF(0x01D12FB0, Server::ParseUserMessage), - HOOK_DEF(0x01D134E0, Server::ParseStopSound), - HOOK_DEF(0x01D13410, Server::ParseEvent), - HOOK_DEF(0x01D13340, Server::ParseSound), - HOOK_DEF(0x01D13240, Server::ParseDeltaPacketEntities), - HOOK_DEF(0x01D131A0, Server::ParsePacketEntities), - HOOK_DEF(0x01D12DF0, Server::ParseCustomization), - HOOK_DEF(0x01D12010, Server::ParseCrosshairAngle), - HOOK_DEF(0x01D12050, Server::ParseSoundFade), - HOOK_DEF(0x01D12C10, Server::ParseDisconnect), - HOOK_DEF(0x01D12C00, Server::ParseChoke), - HOOK_DEF(0x01D12AC0, Server::ParseSetAngle), - HOOK_DEF(0x01D12B60, Server::ParseAddAngle), - HOOK_DEF(0x01D12A40, Server::ParseLightStyle), - HOOK_DEF(0x01D12A20, Server::ParseTime), - HOOK_DEF(0x01D129F0, Server::ParseVersion), - HOOK_DEF(0x01D129D0, Server::ParseBaseline), - HOOK_DEF(0x01D12860, Server::ParseTempEntity), - HOOK_DEF(0x01D12650, Server::ParseResourceList), - HOOK_DEF(0x01D12590, Server::ParseUpdateUserInfo), - HOOK_DEF(0x01D12150, Server::ParseStuffText), - HOOK_DEF(0x01D120C0, Server::ParseNewUserMsg), - HOOK_DEF(0x01D11F80, Server::ParseResourceRequest), - HOOK_DEF(0x01D11F00, Server::ParseSetView), - HOOK_DEF(0x01D11E90, Server::ParseCDTrack), - HOOK_DEF(0x01D11EC0, Server::ParseRestore), - HOOK_DEF(0x01D11CC0, Server::ParseMoveVars), - HOOK_DEF(0x01D11C60, Server::ParseDeltaDescription), - HOOK_DEF(0x01D119F0, Server::ParseServerinfo), - HOOK_DEF(0x01D119D0, Server::ParseBad), - HOOK_DEF(0x01D119C0, Server::ParseNop), - HOOK_DEF(0x01D11850, Server::ParsePrint), - HOOK_DEF(0x01D11880, Server::ParseVoiceInit), - HOOK_DEF(0x01D11940, Server::ParseVoiceData), - HOOK_DEF(0x01D144F0, Server::ParseTimeScale), - HOOK_DEF(0x01D144C0, Server::ParseSendExtraInfo), - HOOK_DEF(0x01D14100, Server::ParseCenterPrint), - HOOK_DEF(0x01D143D0, Server::ParseSetPause), - HOOK_DEF(0x01D14020, Server::ParseCutscene), - HOOK_DEF(0x01D12140, Server::ParseWeaponAnim), - HOOK_DEF(0x01D11C80, Server::ParseDecalName), - HOOK_DEF(0x01D13FF0, Server::ParseFinale), - HOOK_DEF(0x01D13FC0, Server::ParseIntermission), - HOOK_DEF(0x01D13F50, Server::ParseClientData), - HOOK_DEF(0x01D14570, Server::ParseResourceLocation), - HOOK_DEF(0x01D14820, Server::ParseSendCvarValue), - HOOK_DEF(0x01D14830, Server::ParseSendCvarValue2), - //HOOK_DEF(0x01D14740, Server::GetCmdName), // NOXREF - -#endif // Server_region - -#ifndef Network_region - - // Network virtual functions - HOOK_VIRTUAL_DEF(0x01D0E040, Network::Init), - HOOK_VIRTUAL_DEF(0x01D0E480, Network::RunFrame), - HOOK_VIRTUAL_DEF(0x01D0E5B0, Network::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D0E210, Network::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D0E5C0, Network::RegisterListener), - HOOK_VIRTUAL_DEF(0x01D0E670, Network::RemoveListener), - HOOK_VIRTUAL_DEF(0x01D0E680, Network::GetSystem), - HOOK_VIRTUAL_DEF(0x01D0E690, Network::GetSerial), - HOOK_VIRTUAL_DEF(0x01D0E4D0, Network::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D0E3B0, Network::GetType), - HOOK_VIRTUAL_DEF(0x01D0E6B0, Network::GetName), - HOOK_VIRTUAL_DEF(0x01D0E810, Network::GetState), - HOOK_VIRTUAL_DEF(0x01D0E820, Network::GetVersion), - HOOK_VIRTUAL_DEF(0x01D0E250, Network::ShutDown), - HOOK_VIRTUAL_DEF(0x01D0E2E0, Network::CreateSocket), - HOOK_VIRTUAL_DEF(0x01D0E3A0, Network::RemoveSocket), - HOOK_VIRTUAL_DEF(0x01D0E4C0, Network::GetLocalAddress), - HOOK_VIRTUAL_DEF(0x01D0E6C0, Network::ResolveAddress), - HOOK_VIRTUAL_DEF(0x01D0E530, Network::GetFlowStats), - HOOK_VIRTUAL_DEF(0x01D0E6A0, Network::GetLastErrorCode), - HOOK_VIRTUAL_DEF(0x01D0E830, Network::GetErrorText), - HOOK_VIRTUAL_DEF(0x01D0E2E0, Network::CreateSocket), - HOOK_VIRTUAL_DEF(0x01D0E3A0, Network::RemoveSocket), - HOOK_VIRTUAL_DEF(0x01D0E4C0, Network::GetLocalAddress), - HOOK_VIRTUAL_DEF(0x01D0E6C0, Network::ResolveAddress), - HOOK_VIRTUAL_DEF(0x01D0E530, Network::GetFlowStats), - HOOK_VIRTUAL_DEF(0x01D0E6A0, Network::GetLastErrorCode), - HOOK_VIRTUAL_DEF(0x01D0E830, Network::GetErrorText), - - // Network non-virtual functions - HOOK_DEF(0x01D0EAE0, Network::UpdateStats), - HOOK_DEF(0x01D0E440, Network::GetSocket), - HOOK_DEF(0x01D0E400, Network::SendData), - HOOK_DEF(0x01D0E3C0, Network::ReceiveData), - -#endif // Network_region - -#ifndef NetSocket_region - - // Network virtual functions - HOOK_VIRTUAL_DEF(0x01D0D940, NetSocket::ReceivePacket), - HOOK_VIRTUAL_DEF(0x01D0D950, NetSocket::FreePacket), - HOOK_VIRTUAL_DEF(0x01D0D980, NetSocket::AddPacket), - HOOK_VIRTUAL_DEF(0x01D0D000, NetSocket::AddChannel), - HOOK_VIRTUAL_DEF(0x01D0D010, NetSocket::RemoveChannel), - HOOK_VIRTUAL_DEF(0x01D0D310, NetSocket::GetNetwork), - HOOK_VIRTUAL_DEF(0x01D0D8D0, NetSocket::OutOfBandPrintf), - HOOK_VIRTUAL_DEF(0x01D0DA30, NetSocket::Flush), - HOOK_VIRTUAL_DEF(0x01D0D8A0, NetSocket::GetFlowStats), - HOOK_VIRTUAL_DEF(0x01D0D610, NetSocket::LeaveGroup), - HOOK_VIRTUAL_DEF(0x01D0D570, NetSocket::JoinGroup), - HOOK_VIRTUAL_DEF(0x01D0D500, NetSocket::Close), - HOOK_VIRTUAL_DEF(0x01D0DCB0, NetSocket::GetPort), - - HOOK_VIRTUAL_DEF(0x01D0D160, NetSocket::SendPacket, bool(NetPacket *)), - HOOK_VIRTUAL_DEF(0x01D0D190, NetSocket::SendPacket, bool(NetAddress *, const void *, int)), - - // Network non-virtual functions - HOOK_DEF(0x01D0DAC0, NetSocket::Create), - HOOK_DEF(0x01D0DCC0, NetSocket::UpdateStats), - HOOK_DEF(0x01D0D6B0, NetSocket::DrainChannels), - HOOK_DEF(0x01D0D020, NetSocket::DispatchIncoming), - HOOK_DEF(0x01D0D330, NetSocket::ReceivePacketIntern), - HOOK_DEF(0x01D0DD50, NetSocket::SendLong), - HOOK_DEF(0x01D0DE70, NetSocket::SendShort), - HOOK_DEF(0x01D0D730, NetSocket::GetLong), - -#endif // NetSocket_region - -#ifndef Delta_region - - HOOK_DEF(0x01D06740, DELTA_Init), - HOOK_DEF(0x01D06810, DELTA_UpdateDescriptions), - HOOK_DEF(0x01D06880, DELTA_Shutdown), - HOOK_DEF(0x01D06890, DELTA_SetTime), - HOOK_DEF(0x01D068B0, DELTA_SetLargeTimeBufferSize), - HOOK_DEF(0x01D04AF0, DELTA_FindField), - HOOK_DEF(0x01D04C10, DELTA_ClearFlags), - HOOK_DEF(0x01D04C40, DELTA_CountSendFields), - HOOK_DEF(0x01D04C80, DELTA_MarkSendFields), - HOOK_DEF(0x01D04E80, DELTA_SetSendFlagBits), - HOOK_DEF(0x01D04EF0, DELTA_WriteMarkedFields), - HOOK_DEF(0x01D052A0, DELTA_WriteHeader), - HOOK_DEF(0x01D053C0, DELTA_WriteDelta), - HOOK_DEF(0x01D05470, DELTA_ParseDelta), - HOOK_DEF(0x01D05A30, DELTA_TestDelta), - HOOK_DEF(0x01D05CA0, DELTA_AddEncoder), - HOOK_DEF(0x01D05CE0, DELTA_ClearEncoders), - HOOK_DEF(0x01D05D60, DELTA_CountLinks), - HOOK_DEF(0x01D05D80, DELTA_ReverseLinks), - HOOK_DEF(0x01D05DA0, DELTA_ClearLinks), - HOOK_DEF(0x01D05DD0, DELTA_BuildFromLinks), - HOOK_DEF(0x01D05E80, DELTA_FindOffset), - HOOK_DEF(0x01D05EC0, DELTA_ParseType), - HOOK_DEF(0x01D06050, DELTA_ParseField), - HOOK_DEF(0x01D06200, DELTA_FreeDescription), - HOOK_DEF(0x01D06240, DELTA_AddDefinition), - HOOK_DEF(0x01D062A0, DELTA_ClearDefinitions), - HOOK_DEF(0x01D062E0, DELTA_FindDefinition), - HOOK_DEF(0x01D06330, DELTA_SkipDescription), - HOOK_DEF(0x01D06380, DELTA_ParseOneField), - HOOK_DEF(0x01D06640, DELTA_RegisterDescription), - HOOK_DEF(0x01D06670, DELTA_ClearRegistrations), - HOOK_DEF(0x01D066C0, DELTA_LookupRegistration), - - //HOOK_DEF(0x01D06700, DELTA_ClearStats), // NOXREF - //HOOK_DEF(0x01D06430, DELTA_ParseDescription), // NOXREF - //HOOK_DEF(0x01D06630, DELTA_Load), // NOXREF - //HOOK_DEF(0x01D04B40, DELTA_FindFieldIndex), // NOXREF - //HOOK_DEF(0x01D04B90, DELTA_SetField), // NOXREF - //HOOK_DEF(0x01D04BB0, DELTA_UnsetField), // NOXREF - //HOOK_DEF(0x01D04BD0, DELTA_SetFieldByIndex), // NOXREF - //HOOK_DEF(0x01D04BF0, DELTA_UnsetFieldByIndex), // NOXREF - //HOOK_DEF(0x01D05270, DELTA_CheckDelta), // NOXREF - //HOOK_DEF(0x01D05D20, DELTA_LookupEncoder), // NOXREF - -#endif // Delta_region - -#ifndef ObjectDictionary_region - - HOOK_DEF(0x01D0ECA0, MethodThunk::Constructor), - HOOK_DEF(0x01D0ECE0, MethodThunk::Destructor), - - HOOK_VIRTUAL_DEF(0x01D0F220, ObjectDictionary::Init, void()), - HOOK_VIRTUAL_DEF(0x01D0F290, ObjectDictionary::Add, bool(void *)), - HOOK_VIRTUAL_DEF(0x01D0F050, ObjectDictionary::Remove), - HOOK_VIRTUAL_DEF(0x01D0ED10, ObjectDictionary::Clear), - HOOK_VIRTUAL_DEF(0x01D0F310, ObjectDictionary::GetFirst), - HOOK_VIRTUAL_DEF(0x01D0F5B0, ObjectDictionary::GetNext), - HOOK_VIRTUAL_DEF(0x01D0F2A0, ObjectDictionary::CountElements), - HOOK_VIRTUAL_DEF(0x01D0F2C0, ObjectDictionary::Contains), - HOOK_VIRTUAL_DEF(0x01D0F2B0, ObjectDictionary::IsEmpty), - - HOOK_DEF(0x01D0F250, ObjectDictionary::Init, void(int)), // NOXREF - HOOK_DEF(0x01D0ED90, ObjectDictionary::Add, bool(void *, float)), - HOOK_DEF(0x01D0F4D0, ObjectDictionary::AddToCache, void(ObjectDictionary::entry_t *, float)), - HOOK_DEF(0x01D0F490, ObjectDictionary::AddToCache, void(ObjectDictionary::entry_t *)), - HOOK_DEF(0x01D0F340, ObjectDictionary::ChangeKey), - HOOK_DEF(0x01D0F0D0, ObjectDictionary::RemoveKey), - HOOK_DEF(0x01D0F590, ObjectDictionary::FindClosestKey), - HOOK_DEF(0x01D0F5D0, ObjectDictionary::FindExactKey), - HOOK_DEF(0x01D0F320, ObjectDictionary::GetLast), - HOOK_DEF(0x01D0F510, ObjectDictionary::FindKeyInCache), - HOOK_DEF(0x01D0F550, ObjectDictionary::FindObjectInCache), - HOOK_DEF(0x01D0EF60, ObjectDictionary::ClearCache), - HOOK_DEF(0x01D0F130, ObjectDictionary::CheckSize), - HOOK_DEF(0x01D0EF80, ObjectDictionary::RemoveIndex), - HOOK_DEF(0x01D0F010, ObjectDictionary::RemoveIndexRange), - HOOK_DEF(0x01D0EE60, ObjectDictionary::FindClosestAsIndex), - //HOOK_DEF(0x0, ObjectDictionary::RemoveRange), // NOXREF - //HOOK_DEF(0x01D0F440, ObjectDictionary::UnsafeChangeKey), // NOXREF - //HOOK_DEF(0x01D0F090, ObjectDictionary::RemoveSingle), // NOXREF - -#endif // ObjectDictionary_region - -#ifndef ObjectList_region - - HOOK_DEF(0x01D0F610, MethodThunk::Constructor), - HOOK_DEF(0x01D0F650, MethodThunk::Destructor), - - HOOK_VIRTUAL_DEF(0x01D0F8D0, ObjectList::Init), - HOOK_VIRTUAL_DEF(0x01D0F920, ObjectList::Add), - HOOK_VIRTUAL_DEF(0x01D0F850, ObjectList::Remove), - HOOK_VIRTUAL_DEF(0x01D0F800, ObjectList::Clear), - HOOK_VIRTUAL_DEF(0x01D0F8E0, ObjectList::GetFirst), - HOOK_VIRTUAL_DEF(0x01D0F900, ObjectList::GetNext), - HOOK_VIRTUAL_DEF(0x01D0F7C0, ObjectList::CountElements), - HOOK_VIRTUAL_DEF(0x01D0F7D0, ObjectList::Contains), - HOOK_VIRTUAL_DEF(0x01D0F7B0, ObjectList::IsEmpty), - - HOOK_DEF(0x01D0F760, ObjectList::RemoveTail), - HOOK_DEF(0x01D0F6C0, ObjectList::RemoveHead), - HOOK_DEF(0x01D0F710, ObjectList::AddTail), - HOOK_DEF(0x01D0F670, ObjectList::AddHead), - -#endif // ObjectList_region - -#ifndef BitBuffer_region - - HOOK_DEF(0x01D015A0, MethodThunk::Destructor), - HOOK_DEF(0x01D01530, (MethodThunk::Constructor), void()), - HOOK_DEF(0x01D015B0, (MethodThunk::Constructor), void(unsigned int)), - HOOK_DEF(0x01D01570, (MethodThunk::Constructor), void(void *, unsigned int)), - - HOOK_DEF(0x01D015E0, BitBuffer::Resize), - HOOK_DEF(0x01D01630, BitBuffer::Clear), - HOOK_DEF(0x01D01670, BitBuffer::Reset), - HOOK_DEF(0x01D01690, BitBuffer::Free), - HOOK_DEF(0x01D01840, BitBuffer::PeekBits), - HOOK_DEF(0x01D01EF0, BitBuffer::CurrentSize), - HOOK_DEF(0x01D02300, BitBuffer::FastClear), - HOOK_DEF(0x01D02350, BitBuffer::ConcatBuffer), - HOOK_DEF(0x01D02210, BitBuffer::SkipBytes), - HOOK_DEF(0x01D01660, BitBuffer::CurrentBit), - HOOK_DEF(0x01D01F10, BitBuffer::SpaceLeft), - HOOK_DEF(0x01D01F20, BitBuffer::AlignByte), - HOOK_DEF(0x01D02090, BitBuffer::StartBitMode), - HOOK_DEF(0x01D020A0, BitBuffer::EndBitMode), - HOOK_DEF(0x01D020E0, BitBuffer::SetBuffer), - HOOK_DEF(0x01D02240, BitBuffer::SkipBits), - HOOK_DEF(0x01D022D0, BitBuffer::SkipString), - - // Read - HOOK_DEF(0x01D016D0, BitBuffer::ReadBits), - HOOK_DEF(0x01D017B0, BitBuffer::ReadBit), - HOOK_DEF(0x01D01870, BitBuffer::ReadChar), - HOOK_DEF(0x01D01880, BitBuffer::ReadByte), - HOOK_DEF(0x01D01890, BitBuffer::ReadShort), - HOOK_DEF(0x01D018A0, BitBuffer::ReadWord), - HOOK_DEF(0x01D018B0, BitBuffer::ReadLong), - HOOK_DEF(0x01D018C0, BitBuffer::ReadFloat), - HOOK_DEF(0x01D018E0, BitBuffer::ReadBuf), - HOOK_DEF(0x01D019C0, BitBuffer::ReadString), - HOOK_DEF(0x01D01A00, BitBuffer::ReadStringLine), // NOXREF - HOOK_DEF(0x01D02020, BitBuffer::ReadBitString), - HOOK_DEF(0x01D020B0, BitBuffer::ReadBitData), - HOOK_DEF(0x01D02110, BitBuffer::ReadBitVec3Coord), - HOOK_DEF(0x01D02170, BitBuffer::ReadBitCoord), - HOOK_DEF(0x01D021F0, BitBuffer::ReadCoord), - HOOK_DEF(0x01D01A40, BitBuffer::ReadAngle), // NOXREF - HOOK_DEF(0x01D01A60, BitBuffer::ReadHiresAngle), // NOXREF - HOOK_DEF(0x01D01F40, BitBuffer::ReadSBits), - HOOK_DEF(0x01D01F70, BitBuffer::ReadBitAngle), - - // Write - HOOK_DEF(0x01D01D90, BitBuffer::WriteBuf, void(const void *, int)), - HOOK_DEF(0x01D01990, BitBuffer::WriteBuf, void(BitBuffer *, int)), - - HOOK_DEF(0x01D01A80, BitBuffer::WriteBit), - HOOK_DEF(0x01D01B50, BitBuffer::WriteBits), - HOOK_DEF(0x01D01C70, BitBuffer::WriteSBits), - HOOK_DEF(0x01D01CD0, BitBuffer::WriteChar), - HOOK_DEF(0x01D01CE0, BitBuffer::WriteByte), - HOOK_DEF(0x01D01CF0, BitBuffer::WriteShort), - HOOK_DEF(0x01D01D00, BitBuffer::WriteWord), - HOOK_DEF(0x01D01D10, BitBuffer::WriteLong), - HOOK_DEF(0x01D01D20, BitBuffer::WriteFloat), - HOOK_DEF(0x01D01D50, BitBuffer::WriteString), - HOOK_DEF(0x01D02370, BitBuffer::WriteCoord), - HOOK_DEF(0x01D01E60, BitBuffer::WriteBitData), - HOOK_DEF(0x01D01E90, BitBuffer::WriteAngle), // NOXREF - HOOK_DEF(0x01D01EC0, BitBuffer::WriteHiresAngle), // NOXREF - HOOK_DEF(0x01D01FB0, BitBuffer::WriteBitAngle), - HOOK_DEF(0x01D02050, BitBuffer::WriteBitString), - -#endif // BitBuffer_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_FunctionRefs[] = -{ -#ifndef Function_References_region - -#endif // Function_References_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_DataRefs[] = -{ -#ifndef Data_References_region - - GLOBALVAR_LINK(0x01D45708, "_ZL6g_defs", pg_defs), - GLOBALVAR_LINK(0x01D4570C, "_ZL10g_encoders", pg_encoders), - GLOBALVAR_LINK(0x01D45710, "g_deltaregistry", pg_deltaregistry), - GLOBALVAR_LINK(0x01D456F0, "g_pplayerdelta", pg_pplayerdelta), - GLOBALVAR_LINK(0x01D456F4, "g_pentitydelta", pg_pentitydelta), - GLOBALVAR_LINK(0x01D456F8, "g_pcustomentitydelta", pg_pcustomentitydelta), - GLOBALVAR_LINK(0x01D456FC, "g_pclientdelta", pg_pclientdelta), - GLOBALVAR_LINK(0x01D45700, "g_pweapondelta", pg_pweapondelta), - GLOBALVAR_LINK(0x01D45704, "g_peventdelta", pg_peventdelta), - GLOBALVAR_LINK(0x01D456E8, "g_delta_Time", pg_delta_Time), - GLOBALVAR_LINK(0x01D456E0, "g_large_Time_Buffers", pg_large_Time_Buffers), - GLOBALVAR_LINK(0x01D46870, "g_DownloadURL", pg_DownloadURL), - - GLOBALVAR_LINK(0x01D442C8, "com_token", pcom_token), - GLOBALVAR_LINK(0x01D456C8, "s_com_token_unget", ps_com_token_unget), - -#endif // Data_References_region - - { NULL, NULL, NULL }, -}; - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Core/hooklist.h b/rehlds/hookers/HLTV/Core/hooklist.h deleted file mode 100644 index fcdf32b..0000000 --- a/rehlds/hookers/HLTV/Core/hooklist.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#ifdef HOOK_HLTV - -#include "hookers/memory.h" -#include "hookers/helper.h" -#include "hookers/hooker.h" - -#define rehlds_syserror HLTV_SysError - -#define com_token (*pcom_token) -#define s_com_token_unget (*ps_com_token_unget) -#define g_DownloadURL (*pg_DownloadURL) - -extern char com_token[COM_TOKEN_LEN]; -extern qboolean s_com_token_unget; - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Core/main.cpp b/rehlds/hookers/HLTV/Core/main.cpp deleted file mode 100644 index 7c4b3a8..0000000 --- a/rehlds/hookers/HLTV/Core/main.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "precompiled.h" - -#if defined(HOOK_HLTV) -#define ORIGINAL_CORE_DLL_NAME "core2.dll" - -CSysModule *g_pOriginalCoreModule = NULL; -CreateInterfaceFn g_OriginalCoreFactory = NULL; -ISystemModule *g_pOriginalServer = NULL; -ISystemModule *g_pOriginalWorld = NULL; -ISystemModule *g_pOriginalNetwork = NULL; - -IBaseInterface *CreateCoreInterface() -{ - if (g_pOriginalServer) { - return g_pOriginalServer; - } - - if (g_pOriginalCoreModule) - { - g_OriginalCoreFactory = Sys_GetFactory(g_pOriginalCoreModule); - if (g_OriginalCoreFactory) - { - int returnCode = 0; - g_pOriginalServer = reinterpret_cast(g_OriginalCoreFactory(SERVER_INTERFACE_VERSION, &returnCode)); - return g_pOriginalServer; - } - } - - return NULL; -} - -IBaseInterface *CreateWorldInterface() -{ - if (g_pOriginalWorld) { - return g_pOriginalWorld; - } - - if (g_pOriginalCoreModule) - { - g_OriginalCoreFactory = Sys_GetFactory(g_pOriginalCoreModule); - if (g_OriginalCoreFactory) - { - int returnCode = 0; - g_pOriginalWorld = reinterpret_cast(g_OriginalCoreFactory(WORLD_INTERFACE_VERSION, &returnCode)); - return g_pOriginalWorld; - } - } - - return NULL; -} - -IBaseInterface *CreateNetworkInterface() -{ - if (g_pOriginalNetwork) { - return g_pOriginalNetwork; - } - - if (g_pOriginalCoreModule) - { - g_OriginalCoreFactory = Sys_GetFactory(g_pOriginalCoreModule); - if (g_OriginalCoreFactory) - { - int returnCode = 0; - g_pOriginalNetwork = reinterpret_cast(g_OriginalCoreFactory(NETWORK_INTERFACE_VERSION, &returnCode)); - return g_pOriginalNetwork; - } - } - - return NULL; -} - -InterfaceReg iface_Server = InterfaceReg(CreateCoreInterface, SERVER_INTERFACE_VERSION); -InterfaceReg iface_World = InterfaceReg(CreateWorldInterface, WORLD_INTERFACE_VERSION); -InterfaceReg iface_Network= InterfaceReg(CreateNetworkInterface, NETWORK_INTERFACE_VERSION); - -// DLL entry point -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - g_pOriginalCoreModule = Sys_LoadModule(ORIGINAL_CORE_DLL_NAME); - size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_CORE_DLL_NAME, CREATEINTERFACE_PROCNAME); - HookModule("hltv.exe", addr); - } - else if (fdwReason == DLL_PROCESS_DETACH) - { - if (g_pOriginalCoreModule) - { - Sys_UnloadModule(g_pOriginalCoreModule); - g_pOriginalCoreModule = NULL; - g_OriginalCoreFactory = NULL; - - g_pOriginalServer = NULL; - g_pOriginalWorld = NULL; - g_pOriginalNetwork = NULL; - } - } - - return TRUE; -} - -#endif // #if defined(HOOK_HLTV) diff --git a/rehlds/hookers/HLTV/DemoPlayer/hooklist.cpp b/rehlds/hookers/HLTV/DemoPlayer/hooklist.cpp deleted file mode 100644 index ad0011e..0000000 --- a/rehlds/hookers/HLTV/DemoPlayer/hooklist.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -// Hooks stuff -#include "hookers/memory.cpp" -#include "hookers/hooker.cpp" - -//#define Mem_region -//#define Function_References_region -//#define Data_References_region - -FunctionHook g_FunctionHooks[] = -{ - // DO NOT DISABLE, other functions depends on memory allocation routines -#ifndef Mem_region - - HOOK_DEF(0x01D07C0F, malloc_wrapper), - HOOK_DEF(0x01D07AFE, free_wrapper), - HOOK_DEF(0x01D14F4D, strdup_wrapper), - HOOK_DEF(0x01D07C21, __nh_malloc_wrapper), - - HOOK_DEF(0x01D02510, Mem_ZeroMalloc), - //HOOK_DEF(0x0, Mem_Malloc), - //HOOK_DEF(0x0, Mem_Realloc), - //HOOK_DEF(0x0, Mem_Calloc), - //HOOK_DEF(0x0, Mem_Strdup), - //HOOK_DEF(0x0, Mem_Free), - - //HOOK_DEF(0x0, realloc_wrapper), - //HOOK_DEF(0x0, calloc_wrapper), - -#endif // Mem_region - -#ifndef DemoPlayer_Region - - // BaseSystemModule virtual function - //HOOK_VIRTUAL_DEF(0x01D032A0, DemoPlayer::RegisterListener), - //HOOK_VIRTUAL_DEF(0x01D03360, DemoPlayer::RemoveListener), - //HOOK_VIRTUAL_DEF(0x1D033700, DemoPlayer::GetSystem), - //HOOK_VIRTUAL_DEF(0x01D03380, DemoPlayer::GetSerial), - //HOOK_VIRTUAL_DEF(0x01D03390, DemoPlayer::GetName), - //HOOK_VIRTUAL_DEF(0x01D033A0, DemoPlayer::GetState), - //HOOK_VIRTUAL_DEF(0x01D033F0, DemoPlayer::GetVersion), - - // DemoPlayer virtual function - HOOK_VIRTUAL_DEF(0x01D03670, DemoPlayer::Init), - HOOK_VIRTUAL_DEF(0x01D04180, DemoPlayer::RunFrame), - HOOK_VIRTUAL_DEF(0x01D042E0, DemoPlayer::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D02FA0, DemoPlayer::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D02F70, DemoPlayer::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D02F60, DemoPlayer::GetType), - HOOK_VIRTUAL_DEF(0x01D04490, DemoPlayer::ShutDown), - HOOK_VIRTUAL_DEF(0x01D04400, DemoPlayer::NewGame), - HOOK_VIRTUAL_DEF(0x01D03410, DemoPlayer::GetModName), - HOOK_VIRTUAL_DEF(0x01D03420, DemoPlayer::WriteCommands), - HOOK_VIRTUAL_DEF(0x01D03570, DemoPlayer::AddCommand), - HOOK_VIRTUAL_DEF(0x01D035F0, DemoPlayer::RemoveCommand), - HOOK_VIRTUAL_DEF(0x01D04640, DemoPlayer::GetLastCommand), - HOOK_VIRTUAL_DEF(0x01D03660, DemoPlayer::GetCommands), - HOOK_VIRTUAL_DEF(0x01D03900, DemoPlayer::SetWorldTime), - HOOK_VIRTUAL_DEF(0x01D03940, DemoPlayer::SetTimeScale), - HOOK_VIRTUAL_DEF(0x01D039B0, DemoPlayer::SetPaused), - HOOK_VIRTUAL_DEF(0x01D039C0, DemoPlayer::SetEditMode), - HOOK_VIRTUAL_DEF(0x01D03A20, DemoPlayer::SetMasterMode), - HOOK_VIRTUAL_DEF(0x01D03A40, DemoPlayer::IsPaused), - HOOK_VIRTUAL_DEF(0x01D02F30, DemoPlayer::IsLoading), - HOOK_VIRTUAL_DEF(0x01D02F50, DemoPlayer::IsActive), - HOOK_VIRTUAL_DEF(0x01D039D0, DemoPlayer::IsEditMode), - HOOK_VIRTUAL_DEF(0x01D03A30, DemoPlayer::IsMasterMode), - HOOK_VIRTUAL_DEF(0x01D04560, DemoPlayer::RemoveFrames), - HOOK_VIRTUAL_DEF(0x01D04570, DemoPlayer::ExecuteDirectorCmd), - HOOK_VIRTUAL_DEF(0x01D02ED0, DemoPlayer::GetWorldTime), - HOOK_VIRTUAL_DEF(0x01D02EE0, DemoPlayer::GetStartTime), - HOOK_VIRTUAL_DEF(0x01D02F00, DemoPlayer::GetEndTime), - HOOK_VIRTUAL_DEF(0x01D03400, DemoPlayer::GetTimeScale), - HOOK_VIRTUAL_DEF(0x01D02F80, DemoPlayer::GetWorld), - HOOK_VIRTUAL_DEF(0x01D04630, DemoPlayer::GetFileName), - HOOK_VIRTUAL_DEF(0x01D02E60, DemoPlayer::SaveGame), - HOOK_VIRTUAL_DEF(0x01D04650, DemoPlayer::LoadGame), - HOOK_VIRTUAL_DEF(0x01D039E0, DemoPlayer::Stop), - HOOK_VIRTUAL_DEF(0x01D03A10, DemoPlayer::ForceHLTV), - HOOK_VIRTUAL_DEF(0x01D03A50, DemoPlayer::GetDemoViewInfo), - HOOK_VIRTUAL_DEF(0x01D03F90, DemoPlayer::ReadDemoMessage), - HOOK_VIRTUAL_DEF(0x01D04130, DemoPlayer::ReadNetchanState), - HOOK_VIRTUAL_DEF(0x01D02F90, DemoPlayer::GetDirector), // NOXREF - - // DemoPlayer non-virtual function - //HOOK_DEF(0x01D02F20, DemoPlayer::GetPlayerTime), // NOXREF - //HOOK_DEF(0x01D04500, DemoPlayer::FormatTime), // NOXREF - HOOK_DEF(0x01D041B0, DemoPlayer::RunClocks), - HOOK_DEF(0x01D046F0, DemoPlayer::WriteDatagram), - HOOK_DEF(0x01D03D30, DemoPlayer::WriteSpawn), - HOOK_DEF(0x01D03F50, DemoPlayer::ReindexCommands), - HOOK_DEF(0x01D03DC0, DemoPlayer::WriteCameraPath), - HOOK_DEF(0x01D04840, DemoPlayer::ExecuteDemoFileCommands), - HOOK_DEF(0x01D03030, DemoPlayer::CMD_Jump), - HOOK_DEF(0x01D030E0, DemoPlayer::CMD_ForceHLTV), - HOOK_DEF(0x01D031F0, DemoPlayer::CMD_Pause), - HOOK_DEF(0x01D032B0, DemoPlayer::CMD_Speed), - HOOK_DEF(0x01D033B0, DemoPlayer::CMD_Start), - HOOK_DEF(0x01D03170, DemoPlayer::CMD_Save), - -#endif // DemoPlayer_Region - - { NULL, NULL, NULL }, -}; - -AddressRef g_FunctionRefs[] = -{ -#ifndef Function_References_region - -#endif // Function_References_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_DataRefs[] = -{ -#ifndef Data_References_region - - -#endif // Data_References_region - - { NULL, NULL, NULL }, -}; diff --git a/rehlds/hookers/HLTV/DemoPlayer/hooklist.h b/rehlds/hookers/HLTV/DemoPlayer/hooklist.h deleted file mode 100644 index d030ec9..0000000 --- a/rehlds/hookers/HLTV/DemoPlayer/hooklist.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef HOOK_HLTV - -#include "hookers/memory.h" -#include "hookers/helper.h" -#include "hookers/hooker.h" - -#define rehlds_syserror HLTV_SysError - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/DemoPlayer/main.cpp b/rehlds/hookers/HLTV/DemoPlayer/main.cpp deleted file mode 100644 index 0837c3c..0000000 --- a/rehlds/hookers/HLTV/DemoPlayer/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "precompiled.h" - -#if defined(HOOK_HLTV) -#define ORIGINAL_DEMOPLAYER_DLL_NAME "DemoPlayer2.dll" - -CSysModule *g_pOriginalDemoPlayerModule = NULL; -CreateInterfaceFn g_OriginalDemoPlayerFactory = NULL; -ISystemModule *g_pOriginalDemoPlayer = NULL; - -IBaseInterface *CreateDemoPlayerInterface() -{ - if (g_pOriginalDemoPlayer) { - return g_pOriginalDemoPlayer; - } - - if (g_pOriginalDemoPlayerModule) - { - g_OriginalDemoPlayerFactory = Sys_GetFactory(g_pOriginalDemoPlayerModule); - if (g_OriginalDemoPlayerFactory) - { - int returnCode = 0; - g_pOriginalDemoPlayer = reinterpret_cast(g_OriginalDemoPlayerFactory(DEMOPLAYER_INTERFACE_VERSION, &returnCode)); - return g_pOriginalDemoPlayer; - } - } - - return NULL; -} - -InterfaceReg iface = InterfaceReg(CreateDemoPlayerInterface, DEMOPLAYER_INTERFACE_VERSION); - -// DLL entry point -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - g_pOriginalDemoPlayerModule = Sys_LoadModule(ORIGINAL_DEMOPLAYER_DLL_NAME); - size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_DEMOPLAYER_DLL_NAME, CREATEINTERFACE_PROCNAME); - HookModule("hltv.exe", addr); - } - else if (fdwReason == DLL_PROCESS_DETACH) - { - if (g_pOriginalDemoPlayerModule) - { - Sys_UnloadModule(g_pOriginalDemoPlayerModule); - g_pOriginalDemoPlayerModule = NULL; - g_OriginalDemoPlayerFactory = NULL; - g_pOriginalDemoPlayer = NULL; - } - } - - return TRUE; -} - -#endif // #if defined(HOOK_HLTV) diff --git a/rehlds/hookers/HLTV/Proxy/hooklist.cpp b/rehlds/hookers/HLTV/Proxy/hooklist.cpp deleted file mode 100644 index b4a2e59..0000000 --- a/rehlds/hookers/HLTV/Proxy/hooklist.cpp +++ /dev/null @@ -1,649 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -#ifdef HOOK_HLTV - -// Hooks stuff -#include "hookers/memory.cpp" -#include "hookers/hooker.cpp" - -//#define Mem_region -//#define Proxy_region -//#define BaseClient_region -//#define ProxyClient_region -//#define FakeClient_region -//#define DemoFile_region -//#define DemoClient_region -//#define Director_region -//#define DirectorCmd_region -//#define Status_region -//#define InfoString_region -//#define BitBuffer_region -//#define NetChannel_region -//#define Master_region -//#define Function_References_region -//#define Data_References_region - -FunctionHook g_FunctionHooks[] = -{ - // DO NOT DISABLE, other functions depends on memory allocation routines -#ifndef Mem_region - - HOOK_DEF(0x01D20F3F, malloc_wrapper), - HOOK_DEF(0x01D20E2E, free_wrapper), - HOOK_DEF(0x01D3078C, strdup_wrapper), - HOOK_DEF(0x01D20F51, __nh_malloc_wrapper), - - HOOK_DEF(0x01D03EF0, Mem_ZeroMalloc), - //HOOK_DEF(0x0, Mem_Malloc), - //HOOK_DEF(0x0, Mem_Realloc), - //HOOK_DEF(0x0, Mem_Calloc), - //HOOK_DEF(0x0, Mem_Strdup), - //HOOK_DEF(0x0, Mem_Free), - - //HOOK_DEF(0x0, realloc_wrapper), - //HOOK_DEF(0x0, calloc_wrapper), - -#endif // Mem_region - -#ifndef Proxy_region - - // virtual functions - BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D16010, Proxy::Init), - HOOK_VIRTUAL_DEF(0x01D16020, Proxy::RunFrame), - HOOK_VIRTUAL_DEF(0x01D16030, Proxy::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D16040, Proxy::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D16090, Proxy::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D160A0, Proxy::GetType), - HOOK_VIRTUAL_DEF(0x01D160E0, Proxy::ShutDown), - - // virtual functions - Proxy - HOOK_VIRTUAL_DEF(0x01D115D0, Proxy::Reset), - HOOK_VIRTUAL_DEF(0x01D11620, Proxy::Broadcast), - HOOK_VIRTUAL_DEF(0x01D14FE0, Proxy::IncreaseCheering), - HOOK_VIRTUAL_DEF(0x01D11600, Proxy::ParseStatusMsg), - HOOK_VIRTUAL_DEF(0x01D11610, Proxy::ParseStatusReport), - HOOK_VIRTUAL_DEF(0x01D12FF0, Proxy::ProcessConnectionlessMessage), - HOOK_VIRTUAL_DEF(0x01D14780, Proxy::ChatCommentator), - HOOK_VIRTUAL_DEF(0x01D137B0, Proxy::ChatSpectator), - HOOK_VIRTUAL_DEF(0x01D11370, Proxy::CountLocalClients), - HOOK_VIRTUAL_DEF(0x01D143B0, Proxy::AddResource), - HOOK_VIRTUAL_DEF(0x01D11570, Proxy::IsLanOnly), - HOOK_VIRTUAL_DEF(0x01D13A00, Proxy::IsMaster), - HOOK_VIRTUAL_DEF(0x01D11580, Proxy::IsActive), - HOOK_VIRTUAL_DEF(0x01D114F0, Proxy::IsPublicGame), - HOOK_VIRTUAL_DEF(0x01D11500, Proxy::IsPasswordProtected), - HOOK_VIRTUAL_DEF(0x01D11510, Proxy::IsStressed), - HOOK_VIRTUAL_DEF(0x01D154A0, Proxy::SetDelay), - HOOK_VIRTUAL_DEF(0x01D15540, Proxy::SetClientTime), - HOOK_VIRTUAL_DEF(0x01D15580, Proxy::SetClientTimeScale), - HOOK_VIRTUAL_DEF(0x01D15430, Proxy::SetMaxRate), - HOOK_VIRTUAL_DEF(0x01D118D0, Proxy::SetMaxLoss), - HOOK_VIRTUAL_DEF(0x01D15470, Proxy::SetMaxUpdateRate), - HOOK_VIRTUAL_DEF(0x01D11870, Proxy::SetMaxClients), - HOOK_VIRTUAL_DEF(0x01D11930, Proxy::SetRegion), - HOOK_VIRTUAL_DEF(0x01D14FA0, Proxy::GetDelay), - HOOK_VIRTUAL_DEF(0x01D14FC0, Proxy::GetSpectatorTime), - HOOK_VIRTUAL_DEF(0x01D14FD0, Proxy::GetProxyTime), - HOOK_VIRTUAL_DEF(0x01D11920, Proxy::GetMaxClients), - HOOK_VIRTUAL_DEF(0x01D10EF0, Proxy::GetWorld), - HOOK_VIRTUAL_DEF(0x01D10F00, Proxy::GetServer), - HOOK_VIRTUAL_DEF(0x01D10F10, Proxy::GetDirector), - HOOK_VIRTUAL_DEF(0x01D10F20, Proxy::GetSocket), - HOOK_VIRTUAL_DEF(0x01D10F30, Proxy::GetChatMode), - HOOK_VIRTUAL_DEF(0x01D113C0, Proxy::GetStatistics), - HOOK_VIRTUAL_DEF(0x01D113D0, Proxy::GetMaxRate), - HOOK_VIRTUAL_DEF(0x01D113E0, Proxy::GetMaxUpdateRate), - HOOK_VIRTUAL_DEF(0x01D14420, Proxy::GetResource), - HOOK_VIRTUAL_DEF(0x01D11550, Proxy::GetDispatchMode), - HOOK_VIRTUAL_DEF(0x01D115A0, Proxy::GetRegion), - HOOK_VIRTUAL_DEF(0x01D10EE0, Proxy::GetClients), - HOOK_VIRTUAL_DEF(0x01D113F0, Proxy::WriteSignonData), - - // non-virtual functions - Proxy - HOOK_DEF(0x01D12BD0, Proxy::ReplyServiceChallenge), - HOOK_DEF(0x01D115B0, Proxy::ReplyListen), - HOOK_DEF(0x01D10900, Proxy::ReplyConnect), - HOOK_DEF(0x01D10890, Proxy::ReplyRules), - HOOK_DEF(0x01D10820, Proxy::ReplyPlayers), - HOOK_DEF(0x01D10770, Proxy::ReplyInfo), - HOOK_DEF(0x01D10720, Proxy::ReplyInfoString), - HOOK_DEF(0x01D106D0, Proxy::ReplyChallenge), - HOOK_DEF(0x01D105F0, Proxy::ReplyPing), - HOOK_DEF(0x01D12F50, Proxy::ExecuteRcon), - HOOK_DEF(0x01D13B70, Proxy::ReconnectClients), - HOOK_DEF(0x01D129A0, Proxy::SendRcon), - HOOK_DEF(0x01D10DD0, Proxy::RejectConnection), - HOOK_DEF(0x01D10F40, Proxy::UpdateStatusLine), - HOOK_DEF(0x01D14220, Proxy::DispatchClient), - HOOK_DEF(0x01D13FA0, Proxy::IsValidPassword), - HOOK_DEF(0x01D13E50, Proxy::WriteHUDMsg), - HOOK_DEF(0x01D150D0, Proxy::ExecuteLoopCommands), - HOOK_DEF(0x01D12A30, Proxy::GetChallengeNumber), - HOOK_DEF(0x01D12B60, Proxy::CheckChallenge), - HOOK_DEF(0x01D15150, Proxy::CreateServerInfoString), - HOOK_DEF(0x01D13A10, Proxy::CheckDirectorModule), - HOOK_DEF(0x01D158B0, Proxy::RunClocks), - HOOK_DEF(0x01D156B0, Proxy::NewGameStarted), - HOOK_DEF(0x01D12CC0, Proxy::NewServerConnection), - HOOK_DEF(0x01D15620, Proxy::BroadcastPaused), - HOOK_DEF(0x01D12E80, Proxy::BroadcastRetryMessage), - HOOK_DEF(0x01D12EE0, Proxy::StopBroadcast), - HOOK_DEF(0x01D15A10, Proxy::DisconnectClients), - HOOK_DEF(0x01D14350, Proxy::FreeResource), - HOOK_DEF(0x01D14380, Proxy::ClearResources), - HOOK_DEF(0x01D142C0, Proxy::LoadResourceFromFile), - HOOK_DEF(0x01D14800, Proxy::IsBanned), - HOOK_DEF(0x01D15A60, Proxy::UpdateInfoMessages), - - HOOK_DEF(0x01D12860, Proxy::CMD_Rcon), - HOOK_DEF(0x01D11EF0, Proxy::CMD_ServerCmd), - HOOK_DEF(0x01D11F90, Proxy::CMD_ClientCmd), - HOOK_DEF(0x01D127D0, Proxy::CMD_RconPassword), - HOOK_DEF(0x01D12700, Proxy::CMD_RconAddress), - HOOK_DEF(0x01D11700, Proxy::CMD_Say), - HOOK_DEF(0x01D11C10, Proxy::CMD_Msg), - HOOK_DEF(0x01D10D40, Proxy::CMD_Clients), - HOOK_DEF(0x01D13920, Proxy::CMD_Kick), - HOOK_DEF(0x01D13650, Proxy::CMD_ChatMode), - HOOK_DEF(0x01D13DA0, Proxy::CMD_PublicGame), - HOOK_DEF(0x01D13BB0, Proxy::CMD_OffLineText), - HOOK_DEF(0x01D14550, Proxy::CMD_AdminPassword), - HOOK_DEF(0x01D14470, Proxy::CMD_SignOnCommands), - HOOK_DEF(0x01D13EE0, Proxy::CMD_SpectatorPassword), - HOOK_DEF(0x01D140B0, Proxy::CMD_DispatchMode), - HOOK_DEF(0x01D14F00, Proxy::CMD_CheeringThreshold), - HOOK_DEF(0x01D10610, Proxy::CMD_Ping), - HOOK_DEF(0x01D12C00, Proxy::CMD_ProxyPassword), - HOOK_DEF(0x01D11E50, Proxy::CMD_MaxRate), - HOOK_DEF(0x01D12570, Proxy::CMD_LoopCmd), - HOOK_DEF(0x01D117C0, Proxy::CMD_MaxClients), - HOOK_DEF(0x01D14610, Proxy::CMD_LocalMsg), - HOOK_DEF(0x01D11A50, Proxy::CMD_Connect), - HOOK_DEF(0x01D139F0, Proxy::CMD_Disconnect), - HOOK_DEF(0x01D14180, Proxy::CMD_PlayDemo), - HOOK_DEF(0x01D11940, Proxy::CMD_Delay), - HOOK_DEF(0x01D119E0, Proxy::CMD_Stop), - HOOK_DEF(0x01D12480, Proxy::CMD_Record), - HOOK_DEF(0x01D12530, Proxy::CMD_StopRecording), - HOOK_DEF(0x01D123C0, Proxy::CMD_BlockVoice), - HOOK_DEF(0x01D11B20, Proxy::CMD_Name), - HOOK_DEF(0x01D120B0, Proxy::CMD_Rate), - HOOK_DEF(0x01D12300, Proxy::CMD_Updaterate), - HOOK_DEF(0x01D12220, Proxy::CMD_HostName), - HOOK_DEF(0x01D13CC0, Proxy::CMD_AddResource), - HOOK_DEF(0x01D13C60, Proxy::CMD_Resources), - HOOK_DEF(0x01D14DD0, Proxy::CMD_BannerFile), - HOOK_DEF(0x01D14AF0, Proxy::CMD_Bann), - HOOK_DEF(0x01D14850, Proxy::CMD_AddFakeClients), - HOOK_DEF(0x01D14CD0, Proxy::CMD_Retry), - HOOK_DEF(0x01D14D00, Proxy::CMD_AutoRetry), - HOOK_DEF(0x01D14C40, Proxy::CMD_ServerPassword), - HOOK_DEF(0x01D11040, Proxy::CMD_Status), - HOOK_DEF(0x01D13710, Proxy::CMD_MaxQueries), - HOOK_DEF(0x01D12170, Proxy::CMD_Players), - HOOK_DEF(0x01D14C00, Proxy::CMD_ClearBanns), - HOOK_DEF(0x01D149B0, Proxy::CMD_MaxLoss), - HOOK_DEF(0x01D11D80, Proxy::CMD_Protocol), - HOOK_DEF(0x01D14A50, Proxy::CMD_Region), - - //HOOK_DEF(0x01D12E70, Proxy::GetModVersion), // NOXREF - //HOOK_DEF(0x0, Proxy::CMD_InformPlayers), // NOXREF - //HOOK_DEF(0x0, Proxy::CMD_MaxUpdateRate), // NOXREF - -#endif // Proxy_region - -#ifndef ProxyClient_region - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D16C50, ProxyClient::Init), - HOOK_VIRTUAL_DEF(0x01D16D20, ProxyClient::ShutDown), - - // BaseClient - HOOK_VIRTUAL_DEF(0x01D16A40, ProxyClient::HasChatEnabled), - HOOK_VIRTUAL_DEF(0x01D16B30, ProxyClient::DownloadFile), - HOOK_VIRTUAL_DEF(0x01D16920, ProxyClient::SendDatagram), - HOOK_VIRTUAL_DEF(0x01D168E0, ProxyClient::ReplySpawn), - HOOK_VIRTUAL_DEF(0x01D16770, ProxyClient::UpdateUserInfo), - HOOK_VIRTUAL_DEF(0x01D16A50, ProxyClient::ParseVoiceData), - HOOK_VIRTUAL_DEF(0x01D16310, ProxyClient::ProcessStringCmd), - HOOK_VIRTUAL_DEF(0x01D16850, ProxyClient::ParseHLTV), - -#endif // ProxyClient_region - -#ifndef FakeClient_region - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D09300, FakeClient::Init), - HOOK_VIRTUAL_DEF(0x01D09310, FakeClient::RunFrame), - HOOK_VIRTUAL_DEF(0x01D09320, FakeClient::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D09380, FakeClient::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D09390, FakeClient::GetType), - HOOK_VIRTUAL_DEF(0x01D093D0, FakeClient::ShutDown), - - // FakeClient - HOOK_DEF(0x01D08EA0, FakeClient::SetRate), - HOOK_DEF(0x01D08EB0, FakeClient::Connect), - HOOK_DEF(0x01D08EE0, FakeClient::Retry), // NOXREF - HOOK_DEF(0x01D08EF0, FakeClient::Say), // NOXREF - HOOK_DEF(0x01D08F50, FakeClient::Disconnect), // NOXREF - -#endif // FakeClient_region - -#ifndef BaseClient_region - - // IClient - HOOK_VIRTUAL_DEF(0x01D01670, BaseClient::Connect), - HOOK_VIRTUAL_DEF(0x01D02790, BaseClient::Send), - HOOK_VIRTUAL_DEF(0x01D01830, BaseClient::Disconnect), - HOOK_VIRTUAL_DEF(0x01D023F0, BaseClient::Reconnect), - HOOK_VIRTUAL_DEF(0x01D023C0, BaseClient::SetWorld), - HOOK_VIRTUAL_DEF(0x01D027D0, BaseClient::GetClientType), - HOOK_VIRTUAL_DEF(0x01D01810, BaseClient::GetClientName), - HOOK_VIRTUAL_DEF(0x01D01820, BaseClient::GetUserInfo), - HOOK_VIRTUAL_DEF(0x01D027C0, BaseClient::GetAddress), - HOOK_VIRTUAL_DEF(0x01D02420, BaseClient::IsActive), - HOOK_VIRTUAL_DEF(0x01D026F0, BaseClient::IsHearingVoices), - HOOK_VIRTUAL_DEF(0x01D02730, BaseClient::HasChatEnabled), - HOOK_VIRTUAL_DEF(0x01D02760, BaseClient::DownloadFailed), - HOOK_VIRTUAL_DEF(0x01D02740, BaseClient::DownloadFile), - HOOK_VIRTUAL_DEF(0x01D025C0, BaseClient::UpdateVoiceMask), - HOOK_VIRTUAL_DEF(0x01D02580, BaseClient::QueryVoiceEnabled), - HOOK_VIRTUAL_DEF(0x01D02470, BaseClient::SetName), - HOOK_VIRTUAL_DEF(0x01D02100, BaseClient::WriteSpawn), - HOOK_VIRTUAL_DEF(0x01D02180, BaseClient::WriteDatagram), - HOOK_VIRTUAL_DEF(0x01D027F0, BaseClient::SendDatagram), - HOOK_VIRTUAL_DEF(0x01D02820, BaseClient::Reset), - HOOK_VIRTUAL_DEF(0x01D02020, BaseClient::SetState), - HOOK_VIRTUAL_DEF(0x01D01F20, BaseClient::ReplyNew), - HOOK_VIRTUAL_DEF(0x01D01E50, BaseClient::ReplySpawn), - HOOK_VIRTUAL_DEF(0x01D01F90, BaseClient::ReplyFullUpdate), - HOOK_VIRTUAL_DEF(0x01D01E10, BaseClient::PrintfToClient), - HOOK_VIRTUAL_DEF(0x01D01D00, BaseClient::UpdateUserInfo), - HOOK_VIRTUAL_DEF(0x01D01900, BaseClient::ParseStringCmd), - HOOK_VIRTUAL_DEF(0x01D018C0, BaseClient::ParseNop), - HOOK_VIRTUAL_DEF(0x01D018D0, BaseClient::ParseBad), - HOOK_VIRTUAL_DEF(0x01D02450, BaseClient::ParseMove), - HOOK_VIRTUAL_DEF(0x01D02430, BaseClient::ParseVoiceData), - HOOK_VIRTUAL_DEF(0x01D02530, BaseClient::ParseHLTV), - HOOK_VIRTUAL_DEF(0x01D022E0, BaseClient::ParseDelta), - HOOK_VIRTUAL_DEF(0x01D02540, BaseClient::ParseCvarValue), - HOOK_VIRTUAL_DEF(0x01D02550, BaseClient::ParseCvarValue2), - HOOK_VIRTUAL_DEF(0x01D01740, BaseClient::ProcessMessage), - HOOK_VIRTUAL_DEF(0x01D01920, BaseClient::ProcessStringCmd), - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D02950, BaseClient::Init), - HOOK_VIRTUAL_DEF(0x01D02960, BaseClient::RunFrame), - HOOK_VIRTUAL_DEF(0x01D02330, BaseClient::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D16CE0, BaseClient::GetType), - HOOK_VIRTUAL_DEF(0x01D02A20, BaseClient::ShutDown), - -#endif // BaseClient_region - -#ifndef BitBuffer_region - - HOOK_DEF(0x01D02F80, MethodThunk::Destructor), - HOOK_DEF(0x01D02F10, (MethodThunk::Constructor), void()), - HOOK_DEF(0x01D02F90, (MethodThunk::Constructor), void(unsigned int)), - HOOK_DEF(0x01D02F50, (MethodThunk::Constructor), void(void *, unsigned int)), - - HOOK_DEF(0x01D02FC0, BitBuffer::Resize), - HOOK_DEF(0x01D03010, BitBuffer::Clear), - HOOK_DEF(0x01D03050, BitBuffer::Reset), - HOOK_DEF(0x01D03070, BitBuffer::Free), - HOOK_DEF(0x01D03220, BitBuffer::PeekBits), - HOOK_DEF(0x01D038D0, BitBuffer::CurrentSize), - HOOK_DEF(0x01D03CE0, BitBuffer::FastClear), - HOOK_DEF(0x01D03D30, BitBuffer::ConcatBuffer), - HOOK_DEF(0x01D03BF0, BitBuffer::SkipBytes), - HOOK_DEF(0x01D03040, BitBuffer::CurrentBit), // NOXREF - HOOK_DEF(0x01D038F0, BitBuffer::SpaceLeft), // NOXREF - HOOK_DEF(0x01D03900, BitBuffer::AlignByte), // NOXREF - HOOK_DEF(0x01D03A70, BitBuffer::StartBitMode), // NOXREF - HOOK_DEF(0x01D03A80, BitBuffer::EndBitMode), // NOXREF - HOOK_DEF(0x01D03AC0, BitBuffer::SetBuffer), // NOXREF - HOOK_DEF(0x01D03C20, BitBuffer::SkipBits), // NOXREF - HOOK_DEF(0x01D03CB0, BitBuffer::SkipString), // NOXREF - - // Read - HOOK_DEF(0x01D030B0, BitBuffer::ReadBits), - HOOK_DEF(0x01D03190, BitBuffer::ReadBit), - HOOK_DEF(0x01D03250, BitBuffer::ReadChar), - HOOK_DEF(0x01D03260, BitBuffer::ReadByte), - HOOK_DEF(0x01D03270, BitBuffer::ReadShort), - HOOK_DEF(0x01D03280, BitBuffer::ReadWord), - HOOK_DEF(0x01D03290, BitBuffer::ReadLong), - HOOK_DEF(0x01D032A0, BitBuffer::ReadFloat), - HOOK_DEF(0x01D032C0, BitBuffer::ReadBuf), - HOOK_DEF(0x01D033A0, BitBuffer::ReadString), - HOOK_DEF(0x01D033E0, BitBuffer::ReadStringLine), - HOOK_DEF(0x01D03A00, BitBuffer::ReadBitString), - HOOK_DEF(0x01D03A90, BitBuffer::ReadBitData), - HOOK_DEF(0x01D03AF0, BitBuffer::ReadBitVec3Coord), - HOOK_DEF(0x01D03B50, BitBuffer::ReadBitCoord), - HOOK_DEF(0x01D03BD0, BitBuffer::ReadCoord), - HOOK_DEF(0x01D03420, BitBuffer::ReadAngle), // NOXREF - HOOK_DEF(0x01D03440, BitBuffer::ReadHiresAngle), // NOXREF - HOOK_DEF(0x01D03920, BitBuffer::ReadSBits), // NOXREF - HOOK_DEF(0x01D03950, BitBuffer::ReadBitAngle), // NOXREF - - // Write - HOOK_DEF(0x01D03770, BitBuffer::WriteBuf, void(const void *, int)), - HOOK_DEF(0x01D03370, BitBuffer::WriteBuf, void(BitBuffer *, int)), - - HOOK_DEF(0x01D03460, BitBuffer::WriteBit), - HOOK_DEF(0x01D03530, BitBuffer::WriteBits), - HOOK_DEF(0x01D03650, BitBuffer::WriteSBits), // NOXREF - HOOK_DEF(0x01D036B0, BitBuffer::WriteChar), - HOOK_DEF(0x01D036C0, BitBuffer::WriteByte), - HOOK_DEF(0x01D036D0, BitBuffer::WriteShort), - HOOK_DEF(0x01D036E0, BitBuffer::WriteWord), - HOOK_DEF(0x01D036F0, BitBuffer::WriteLong), - HOOK_DEF(0x01D03700, BitBuffer::WriteFloat), - HOOK_DEF(0x01D03730, BitBuffer::WriteString), - HOOK_DEF(0x01D03D50, BitBuffer::WriteCoord), - HOOK_DEF(0x01D03840, BitBuffer::WriteBitData), // NOXREF - HOOK_DEF(0x01D03870, BitBuffer::WriteAngle), // NOXREF - HOOK_DEF(0x01D038A0, BitBuffer::WriteHiresAngle), // NOXREF - HOOK_DEF(0x01D03990, BitBuffer::WriteBitAngle), // NOXREF - HOOK_DEF(0x01D03A30, BitBuffer::WriteBitString), // NOXREF - -#endif // BitBuffer_region - -#ifndef NetChannel_region - - // virtual functions - HOOK_VIRTUAL_DEF(0x01D0C7E0, NetChannel::Create), - HOOK_VIRTUAL_DEF(0x01D0DC20, NetChannel::GetTargetAddress), - HOOK_VIRTUAL_DEF(0x01D0C8C0, NetChannel::Close), - HOOK_VIRTUAL_DEF(0x01D0C6E0, NetChannel::Clear), - HOOK_VIRTUAL_DEF(0x01D0C650, NetChannel::Reset), - HOOK_VIRTUAL_DEF(0x01D0DC40, NetChannel::IsConnected), - HOOK_VIRTUAL_DEF(0x01D0C8F0, NetChannel::IsReadyToSend), - HOOK_VIRTUAL_DEF(0x01D0DD60, NetChannel::IsCrashed), - HOOK_VIRTUAL_DEF(0x01D0DC70, NetChannel::IsTimedOut), - HOOK_VIRTUAL_DEF(0x01D0DC30, NetChannel::IsFakeChannel), - HOOK_VIRTUAL_DEF(0x01D0DC10, NetChannel::KeepAlive), - HOOK_VIRTUAL_DEF(0x01D0DB90, NetChannel::SetRate), - - HOOK_VIRTUAL_DEF(0x01D0D9F0, NetChannel::SetUpdateRate), - HOOK_VIRTUAL_DEF(0x01D0DC50, NetChannel::SetTimeOut), - HOOK_VIRTUAL_DEF(0x01D0DC00, NetChannel::SetKeepAlive), - HOOK_VIRTUAL_DEF(0x01D0DCB0, NetChannel::GetIdleTime), - HOOK_VIRTUAL_DEF(0x01D0DCC0, NetChannel::GetRate), - HOOK_VIRTUAL_DEF(0x01D0DCD0, NetChannel::GetUpdateRate), - HOOK_VIRTUAL_DEF(0x01D0DCE0, NetChannel::GetLoss), - - HOOK_VIRTUAL_DEF(0x01D0C9E0, NetChannel::TransmitOutgoing), - HOOK_VIRTUAL_DEF(0x01D0D130, NetChannel::ProcessIncoming), - HOOK_VIRTUAL_DEF(0x01D0DCF0, NetChannel::FakeAcknowledgement), - HOOK_VIRTUAL_DEF(0x01D0C480, NetChannel::OutOfBandPrintf), - - // non-virtual functions - HOOK_DEF(0x01D0C400, NetChannel::UnlinkFragment), - HOOK_DEF(0x01D0C530, NetChannel::ClearFragbufs), - HOOK_DEF(0x01D0C560, NetChannel::ClearFragments), - HOOK_DEF(0x01D0C5D0, NetChannel::FlushIncoming), - HOOK_DEF(0x01D0C910, NetChannel::UpdateFlow), - HOOK_DEF(0x01D0D030, NetChannel::FindBufferById), - HOOK_DEF(0x01D0D090, NetChannel::CheckForCompletion), - HOOK_DEF(0x01D0D620, NetChannel::FragSend), - HOOK_DEF(0x01D0D670, NetChannel::AddBufferToList), - HOOK_DEF(0x01D0D6C0, NetChannel::CreateFragmentsFromBuffer), - HOOK_DEF(0x01D0DD20, NetChannel::CreateFragmentsFromFile), - HOOK_DEF(0x01D0D970, NetChannel::AddFragbufToTail), - HOOK_DEF(0x01D0D9B0, NetChannel::GetPacket), - HOOK_DEF(0x01D0D9C0, NetChannel::FreePacket), - HOOK_DEF(0x01D0DA30, NetChannel::CopyNormalFragments), - HOOK_DEF(0x01D0DBD0, NetChannel::GetFlowStats), - HOOK_DEF(0x01D0DBC0, NetChannel::SetConnected), // NOXREF - HOOK_DEF(0x01D0DD70, NetChannel::CopyFileFragments), // NOXREF - -#endif // NetChannel_region - -#ifndef Master_region - - // virtual functions - HOOK_VIRTUAL_DEF(0x01D0A480, Master::Init), - HOOK_VIRTUAL_DEF(0x01D0A490, Master::RunFrame), - HOOK_VIRTUAL_DEF(0x01D0A4B0, Master::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D0A500, Master::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D0A510, Master::GetType), - HOOK_VIRTUAL_DEF(0x01D0A550, Master::ShutDown), - - //HOOK_DEF(0x0, Master::InitializeSteam), // NOXREF - HOOK_DEF(0x01D0A230, Master::CMD_Heartbeat), - HOOK_DEF(0x01D0A260, Master::CMD_NoMaster), - HOOK_DEF(0x01D0A350, Master::CMD_ListMaster), - HOOK_DEF(0x01D0A3E0, Master::SendShutdown), - -#endif // Master_region - -#ifndef DemoFile_region - - HOOK_DEF(0x01D04F60, MethodThunk::Destructor), - HOOK_DEF(0x01D04F10, MethodThunk::Constructor), - - HOOK_DEF(0x01D06380, DemoFile::Init), - HOOK_DEF(0x01D059D0, DemoFile::LoadDemo), - HOOK_DEF(0x01D05D30, DemoFile::StopPlayBack), - HOOK_DEF(0x01D056B0, DemoFile::StartRecording), - HOOK_DEF(0x01D04FC0, DemoFile::CloseFile), - HOOK_DEF(0x01D04F70, DemoFile::Reset), - HOOK_DEF(0x01D06370, DemoFile::SetContinuous), // NOXREF - HOOK_DEF(0x01D06360, DemoFile::IsContinuous), // NOXREF - HOOK_DEF(0x01D059C0, DemoFile::IsPlaying), - HOOK_DEF(0x01D04FB0, DemoFile::IsRecording), - HOOK_DEF(0x01D06350, DemoFile::GetFileName), - HOOK_DEF(0x01D05D60, DemoFile::ReadDemoPacket), - HOOK_DEF(0x01D053B0, DemoFile::WriteDemoMessage), - HOOK_DEF(0x01D05500, DemoFile::WriteUpdateClientData), - HOOK_DEF(0x01D055B0, DemoFile::GetDemoTime), - HOOK_DEF(0x01D06260, DemoFile::ReadSequenceInfo), - HOOK_DEF(0x01D06220, DemoFile::ReadDemoInfo), - HOOK_DEF(0x01D052B0, DemoFile::WriteDemoStartup), - HOOK_DEF(0x01D051C0, DemoFile::WriteSequenceInfo), - HOOK_DEF(0x01D05190, DemoFile::WriteDemoInfo), - HOOK_DEF(0x01D055D0, DemoFile::WriteSignonData), - -#endif // DemoFile_region - -#ifndef DemoClient_region - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D04E30, DemoClient::Init), - HOOK_VIRTUAL_DEF(0x01D04E40, DemoClient::RunFrame), - HOOK_VIRTUAL_DEF(0x01D04EB0, DemoClient::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D04EC0, DemoClient::GetType), - HOOK_VIRTUAL_DEF(0x01D04F00, DemoClient::ShutDown), - - // IClient - HOOK_VIRTUAL_DEF(0x01D04810, DemoClient::Connect), - HOOK_VIRTUAL_DEF(0x01D04D30, DemoClient::Send), - HOOK_VIRTUAL_DEF(0x01D04BE0, DemoClient::Disconnect), - HOOK_VIRTUAL_DEF(0x01D04800, DemoClient::Reconnect), - HOOK_VIRTUAL_DEF(0x01D04D90, DemoClient::SetWorld), - HOOK_VIRTUAL_DEF(0x01D047F0, DemoClient::GetClientType), - HOOK_VIRTUAL_DEF(0x01D04D60, DemoClient::GetClientName), - HOOK_VIRTUAL_DEF(0x01D04D70, DemoClient::GetUserInfo), - HOOK_VIRTUAL_DEF(0x01D04CE0, DemoClient::GetAddress), - HOOK_VIRTUAL_DEF(0x01D04BD0, DemoClient::IsActive), - HOOK_VIRTUAL_DEF(0x01D047C0, DemoClient::IsHearingVoices), - HOOK_VIRTUAL_DEF(0x01D047D0, DemoClient::HasChatEnabled), - - HOOK_DEF(0x01D04990, DemoClient::SendDatagram), - HOOK_DEF(0x01D04A30, DemoClient::WriteDatagram), - HOOK_DEF(0x01D04C70, DemoClient::FinishDemo), - HOOK_DEF(0x01D04D80, DemoClient::SetProxy), - HOOK_DEF(0x01D04DA0, DemoClient::SetFileName), - HOOK_DEF(0x01D04DD0, DemoClient::GetDemoFile), - -#endif // DemoClient_region - -#ifndef Director_region - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D07BC0, Director::Init), - HOOK_VIRTUAL_DEF(0x01D07BD0, Director::RunFrame), - HOOK_VIRTUAL_DEF(0x01D07BE0, Director::ReceiveSignal), - HOOK_VIRTUAL_DEF(0x01D07BF0, Director::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D07C40, Director::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D07C50, Director::GetType), - HOOK_VIRTUAL_DEF(0x01D07C90, Director::ShutDown), - - // IDirector - HOOK_VIRTUAL_DEF(0x01D068C0, Director::NewGame), - HOOK_VIRTUAL_DEF(0x01D068B0, Director::GetModName), - HOOK_VIRTUAL_DEF(0x01D06E10, Director::WriteCommands), - HOOK_VIRTUAL_DEF(0x01D07A60, Director::AddCommand), - HOOK_VIRTUAL_DEF(0x01D07B50, Director::RemoveCommand), - HOOK_VIRTUAL_DEF(0x01D07B60, Director::GetLastCommand), - HOOK_VIRTUAL_DEF(0x01D07B40, Director::GetCommands), - - // Director - HOOK_DEF(0x01D07910, Director::FindBestEvent), - HOOK_DEF(0x01D07690, Director::ExecuteDirectorCommands), - HOOK_DEF(0x01D07420, Director::RandomizeCommand), - HOOK_DEF(0x01D07280, Director::GetClosestPlayer), - HOOK_DEF(0x01D06EC0, Director::AddEvent), - HOOK_DEF(0x01D06B50, Director::SmoothRank), - HOOK_DEF(0x01D06C40, Director::AnalysePlayer), - HOOK_DEF(0x01D06980, Director::AnalyseFrame), - HOOK_DEF(0x01D073E0, Director::ClearDirectorCommands), - HOOK_DEF(0x01D07110, Director::AddBestMODCut), - HOOK_DEF(0x01D06F00, Director::AddBestGenericCut), - HOOK_DEF(0x01D06EA0, Director::WriteSignonData), - //HOOK_DEF(0x0, Director::WriteProxyStatus), // NOXREF - HOOK_DEF(0x01D07830, Director::CMD_SlowMotion), - -#endif // Director_region - -#ifndef DirectorCmd_region - - HOOK_DEF(0x01D07D00, DirectorCmd::GetEventData), - HOOK_DEF(0x01D07D50, DirectorCmd::GetModeData), - HOOK_DEF(0x01D07D80, DirectorCmd::GetChaseData), - HOOK_DEF(0x01D07DD0, DirectorCmd::GetInEyeData), - HOOK_DEF(0x01D07E00, DirectorCmd::GetMapData), - HOOK_DEF(0x01D07E50, DirectorCmd::GetCameraData), - HOOK_DEF(0x01D07EE0, DirectorCmd::GetCamPathData), - HOOK_DEF(0x01D07F70, DirectorCmd::GetSoundData), - HOOK_DEF(0x01D07FB0, DirectorCmd::GetTime), // NOXREF - HOOK_DEF(0x01D07FC0, DirectorCmd::GetType), - HOOK_DEF(0x01D07FD0, DirectorCmd::GetName), // NOXREF - HOOK_DEF(0x01D07FE0, DirectorCmd::GetTimeScaleData), - HOOK_DEF(0x01D08010, DirectorCmd::GetWayPointsData), - HOOK_DEF(0x01D08040, DirectorCmd::GetMessageData), - HOOK_DEF(0x01D080E0, DirectorCmd::GetStatusData), - HOOK_DEF(0x01D08130, DirectorCmd::GetBannerData), - HOOK_DEF(0x01D08170, DirectorCmd::GetStuffTextData), - HOOK_DEF(0x01D081B0, DirectorCmd::SetEventData), - HOOK_DEF(0x01D081F0, DirectorCmd::SetChaseData), // NOXREF - HOOK_DEF(0x01D08240, DirectorCmd::SetInEyeData), // NOXREF - HOOK_DEF(0x01D08270, DirectorCmd::SetMapData), // NOXREF - HOOK_DEF(0x01D082B0, DirectorCmd::SetStartData), // NOXREF - HOOK_DEF(0x01D082C0, DirectorCmd::SetModeData), // NOXREF - HOOK_DEF(0x01D082F0, DirectorCmd::SetCameraData), // NOXREF - HOOK_DEF(0x01D08370, DirectorCmd::SetCamPathData), // NOXREF - HOOK_DEF(0x01D083F0, DirectorCmd::SetSoundData), - HOOK_DEF(0x01D08440, DirectorCmd::SetTimeScaleData), - HOOK_DEF(0x01D08470, DirectorCmd::SetTime), - HOOK_DEF(0x01D08480, DirectorCmd::SetMessageData), - HOOK_DEF(0x01D08520, DirectorCmd::Copy), // NOXREF - HOOK_DEF(0x01D08570, DirectorCmd::SetStatusData), - HOOK_DEF(0x01D085B0, DirectorCmd::SetBannerData), - HOOK_DEF(0x01D085F0, DirectorCmd::SetStuffTextData), // NOXREF - HOOK_DEF(0x01D08630, DirectorCmd::SetWayPoints), // NOXREF - HOOK_DEF(0x01D08660, DirectorCmd::ReadFromStream), // NOXREF - HOOK_DEF(0x01D088C0, DirectorCmd::WriteToStream), - HOOK_DEF(0x01D08920, DirectorCmd::ToString), // NOXREF - HOOK_DEF(0x01D08D50, DirectorCmd::FromString), // NOXREF - HOOK_DEF(0x01D08D60, DirectorCmd::Clear), - HOOK_DEF(0x01D08D70, DirectorCmd::Resize), - -#endif // DirectorCmd_region - -#ifndef Status_region - - // BaseSystemModule - HOOK_VIRTUAL_DEF(0x01D178A0, Status::Init), - HOOK_VIRTUAL_DEF(0x01D178B0, Status::RunFrame), - HOOK_VIRTUAL_DEF(0x01D178D0, Status::ExecuteCommand), - HOOK_VIRTUAL_DEF(0x01D17920, Status::GetStatusLine), - HOOK_VIRTUAL_DEF(0x01D17930, Status::GetType), - HOOK_VIRTUAL_DEF(0x01D17970, Status::ShutDown), - -#endif // Status_region - -#ifndef InfoString_region - - HOOK_DEF(0x01D09590, MethodThunk::Destructor), - HOOK_DEF(0x01D094F0, (MethodThunk::Constructor), void()), - HOOK_DEF(0x01D09510, (MethodThunk::Constructor), void(unsigned int)), - HOOK_DEF(0x01D09540, (MethodThunk::Constructor), void(char *)), - HOOK_DEF(0x01D09480, (MethodThunk::Constructor), void(char *, unsigned int)), - - HOOK_DEF(0x01D095B0, InfoString::SetString), - HOOK_DEF(0x01D09600, InfoString::SetMaxSize), - HOOK_DEF(0x01D09660, InfoString::GetMaxSize), - HOOK_DEF(0x01D09670, InfoString::GetCurrentSize), - HOOK_DEF(0x01D09690, InfoString::Clear), - HOOK_DEF(0x01D096B0, InfoString::GetString), - HOOK_DEF(0x01D096C0, InfoString::ValueForKey), - HOOK_DEF(0x01D097B0, InfoString::RemoveKey), - HOOK_DEF(0x01D09880, InfoString::RemovePrefixedKeys), - HOOK_DEF(0x01D09900, InfoString::SetValueForStarKey), - HOOK_DEF(0x01D09AB0, InfoString::SetValueForKey), - -#endif // InfoString_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_FunctionRefs[] = -{ -#ifndef Function_References_region - -#endif // Function_References_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_DataRefs[] = -{ -#ifndef Data_References_region - -#endif // Data_References_region - - { NULL, NULL, NULL }, -}; - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Proxy/hooklist.h b/rehlds/hookers/HLTV/Proxy/hooklist.h deleted file mode 100644 index d030ec9..0000000 --- a/rehlds/hookers/HLTV/Proxy/hooklist.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef HOOK_HLTV - -#include "hookers/memory.h" -#include "hookers/helper.h" -#include "hookers/hooker.h" - -#define rehlds_syserror HLTV_SysError - -#endif // HOOK_HLTV diff --git a/rehlds/hookers/HLTV/Proxy/main.cpp b/rehlds/hookers/HLTV/Proxy/main.cpp deleted file mode 100644 index a1528c3..0000000 --- a/rehlds/hookers/HLTV/Proxy/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "precompiled.h" - -#if defined(HOOK_HLTV) -#define ORIGINAL_PROXY_DLL_NAME "proxy2.dll" - -CSysModule *g_pOriginalProxyModule = NULL; -CreateInterfaceFn g_OriginalProxyFactory = NULL; -ISystemModule *g_pOriginalProxy = NULL; - -IBaseInterface *CreateProxyInterface() -{ - if (g_pOriginalProxy) { - return g_pOriginalProxy; - } - - if (g_pOriginalProxyModule) - { - g_OriginalProxyFactory = Sys_GetFactory(g_pOriginalProxyModule); - if (g_OriginalProxyFactory) - { - int returnCode = 0; - g_pOriginalProxy = reinterpret_cast(g_OriginalProxyFactory(PROXY_INTERFACE_VERSION, &returnCode)); - return g_pOriginalProxy; - } - } - - return NULL; -} - -InterfaceReg iface = InterfaceReg(CreateProxyInterface, PROXY_INTERFACE_VERSION); - -// DLL entry point -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - g_pOriginalProxyModule = Sys_LoadModule(ORIGINAL_PROXY_DLL_NAME); - size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_PROXY_DLL_NAME, CREATEINTERFACE_PROCNAME); - HookModule("hltv.exe", addr); - } - else if (fdwReason == DLL_PROCESS_DETACH) - { - if (g_pOriginalProxyModule) - { - Sys_UnloadModule(g_pOriginalProxyModule); - g_pOriginalProxyModule = NULL; - g_OriginalProxyFactory = NULL; - g_pOriginalProxy = NULL; - } - } - - return TRUE; -} - -#endif // #if defined(HOOK_HLTV) diff --git a/rehlds/hookers/filesystem/hooklist.cpp b/rehlds/hookers/filesystem/hooklist.cpp deleted file mode 100644 index 7fb0b2d..0000000 --- a/rehlds/hookers/filesystem/hooklist.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -// Hooks stuff -#include "hookers/memory.cpp" -#include "hookers/hooker.cpp" - -//#define Mem_region -//#define BaseFileSystem_region -//#define CUtlSymbol_Region -//#define Function_References_region -//#define Data_References_region - -FunctionHook g_FunctionHooks[] = -{ - // DO NOT DISABLE, other functions depends on memory allocation routines -#ifndef Mem_region - -#ifdef _WIN32 - HOOK_SYMBOLDEF(0x01D06F5E, "_malloca", malloc_wrapper), - HOOK_SYMBOLDEF(0x01D067CA, "_free", free_wrapper), - HOOK_SYMBOLDEF(0x01D07098, "realloc", realloc_wrapper), - HOOK_SYMBOLDEF(0x01D06F70, "__nh_malloc", __nh_malloc_wrapper), -#endif //_WIN32 - -#endif // Mem_region - -#ifndef BaseFileSystem_region - - HOOK_DEF(0x01D01080, MethodThunk::Destructor), - HOOK_DEF(0x01D01010, (MethodThunk::Constructor)), - - // virtual functions - CFileSystem_Stdio - HOOK_VIRTUAL_DEF(0x01D05340, CFileSystem_Stdio::Mount), - HOOK_VIRTUAL_DEF(0x01D011C0, CFileSystem_Stdio::Unmount), - HOOK_VIRTUAL_DEF(0x01D05510, CFileSystem_Stdio::GetLocalCopy), - HOOK_VIRTUAL_DEF(0x01D05520, CFileSystem_Stdio::LogLevelLoadStarted), - HOOK_VIRTUAL_DEF(0x01D05530, CFileSystem_Stdio::LogLevelLoadFinished), - HOOK_VIRTUAL_DEF(0x01D05540, CFileSystem_Stdio::HintResourceNeed), - HOOK_VIRTUAL_DEF(0x01D05550, CFileSystem_Stdio::PauseResourcePreloading), - HOOK_VIRTUAL_DEF(0x01D05560, CFileSystem_Stdio::ResumeResourcePreloading), - HOOK_VIRTUAL_DEF(0x01D05570, CFileSystem_Stdio::SetVBuf), - HOOK_VIRTUAL_DEF(0x01D055B0, CFileSystem_Stdio::GetInterfaceVersion), - HOOK_VIRTUAL_DEF(0x01D055D0, CFileSystem_Stdio::WaitForResources), - HOOK_VIRTUAL_DEF(0x01D055E0, CFileSystem_Stdio::GetWaitForResourcesProgress), - HOOK_VIRTUAL_DEF(0x01D05600, CFileSystem_Stdio::CancelWaitForResources), - HOOK_VIRTUAL_DEF(0x01D05610, CFileSystem_Stdio::IsAppReadyForOfflinePlay), - - // virtual functions - BaseFileSystem - HOOK_SYMBOL_VIRTUAL_EX(0x01D01AF0, CFileSystem_Stdio, Open), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01CC0, CFileSystem_Stdio, OpenFromCacheForRead), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01D50, CFileSystem_Stdio, Close), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01DD0, CFileSystem_Stdio, Seek), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01EA0, CFileSystem_Stdio, Tell), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01EF0, CFileSystem_Stdio, Size, size_t (FileHandle_t)), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01F30, CFileSystem_Stdio, Size, size_t (const char *)), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02310, CFileSystem_Stdio, IsOk), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02370, CFileSystem_Stdio, Flush), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02150, CFileSystem_Stdio, EndOfFile), - HOOK_SYMBOL_VIRTUAL_EX(0x01D021E0, CFileSystem_Stdio, Read), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02240, CFileSystem_Stdio, Write), - HOOK_SYMBOL_VIRTUAL_EX(0x01D023B0, CFileSystem_Stdio, ReadLine), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02290, CFileSystem_Stdio, FPrintf), - HOOK_SYMBOL_VIRTUAL_EX(0x01D022F0, CFileSystem_Stdio, GetReadBuffer), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02300, CFileSystem_Stdio, ReleaseReadBuffer), - HOOK_SYMBOL_VIRTUAL_EX(0x01D012B0, CFileSystem_Stdio, GetCurrentDirectory), - HOOK_SYMBOL_VIRTUAL_EX(0x01D012B0, CFileSystem_Stdio, GetCurrentDirectory), - HOOK_SYMBOL_VIRTUAL_EX(0x01D011D0, CFileSystem_Stdio, CreateDirHierarchy), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01680, CFileSystem_Stdio, IsDirectory), - HOOK_SYMBOL_VIRTUAL_EX(0x01D024A0, CFileSystem_Stdio, GetLocalPath), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02400, CFileSystem_Stdio, RemoveFile), - HOOK_SYMBOL_VIRTUAL_EX(0x01D042B0, CFileSystem_Stdio, RemoveAllSearchPaths), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01320, CFileSystem_Stdio, AddSearchPath), - HOOK_SYMBOL_VIRTUAL_EX(0x01D014E0, CFileSystem_Stdio, RemoveSearchPath), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01AA0, CFileSystem_Stdio, FileExists), - HOOK_SYMBOL_VIRTUAL_EX(0x01D04000, CFileSystem_Stdio, GetFileTime), - HOOK_SYMBOL_VIRTUAL_EX(0x01D04060, CFileSystem_Stdio, FileTimeToString), - HOOK_SYMBOL_VIRTUAL_EX(0x01D036B0, CFileSystem_Stdio, FindFirst), - HOOK_SYMBOL_VIRTUAL_EX(0x01D03DB0, CFileSystem_Stdio, FindNext), - HOOK_SYMBOL_VIRTUAL_EX(0x01D03DF0, CFileSystem_Stdio, FindIsDirectory), - HOOK_SYMBOL_VIRTUAL_EX(0x01D03E10, CFileSystem_Stdio, FindClose), - HOOK_SYMBOL_VIRTUAL_EX(0x01D03EF0, CFileSystem_Stdio, ParseFile), - HOOK_SYMBOL_VIRTUAL_EX(0x01D04130, CFileSystem_Stdio, FullPathToRelativePath), - HOOK_SYMBOL_VIRTUAL_EX(0x01D012A0, CFileSystem_Stdio, PrintOpenedFiles), - HOOK_SYMBOL_VIRTUAL_EX(0x01D04090, CFileSystem_Stdio, SetWarningFunc), - HOOK_SYMBOL_VIRTUAL_EX(0x01D040A0, CFileSystem_Stdio, SetWarningLevel), - HOOK_SYMBOL_VIRTUAL_EX(0x01D02A20, CFileSystem_Stdio, AddPackFile), - HOOK_SYMBOL_VIRTUAL_EX(0x01D01300, CFileSystem_Stdio, AddSearchPathNoWrite), - - // non-virtual functions - BaseFileSystem - HOOK_DEF(0x01D02780, CBaseFileSystem::Trace_FOpen), - HOOK_DEF(0x01D028A0, CBaseFileSystem::Trace_FClose), - HOOK_DEF(0x01D029E0, CBaseFileSystem::Trace_DumpUnclosedFiles), - HOOK_DEF(0x01D01340, CBaseFileSystem::AddSearchPathInternal), - HOOK_DEF(0x01D040B0, CBaseFileSystem::Warning), - HOOK_DEF(0x01D04350, CBaseFileSystem::FixSlashes), - HOOK_DEF(0x01D04370, CBaseFileSystem::FixPath), - //HOOK_DEF(0x01D04320, CBaseFileSystem::StripFilename), // NOXREF - HOOK_DEF(0x01D01610, CBaseFileSystem::GetWritePath), - HOOK_DEF(0x01D01790, CBaseFileSystem::FindFile), - HOOK_DEF(0x01D01F70, CBaseFileSystem::FastFindFileSize), - //HOOK_DEF(0x01D034B0, CBaseFileSystem::RemoveAllMapSearchPaths), // NOXREF - HOOK_DEF(0x01D033A0, CBaseFileSystem::AddPackFiles), - HOOK_DEF(0x01D02A40, CBaseFileSystem::AddPackFileFromPath), - HOOK_DEF(0x01D02D20, CBaseFileSystem::PreparePackFile), - HOOK_DEF(0x01D03070, CBaseFileSystem::Prepare64BitPackFile), - HOOK_DEF(0x01D03510, CBaseFileSystem::SearchPakFile), - //HOOK_DEF(0x01D039B0, CBaseFileSystem::FileInSearchPaths), // NOXREF - HOOK_DEF(0x01D03B70, CBaseFileSystem::FindNextFileHelper), - HOOK_DEF(0x01D03890, CBaseFileSystem::FindFirstHelper), - -#endif // BaseFileSystem_region - -#ifndef CUtlSymbol_Region - - //HOOK_DEF(0x01D05AA0, MethodThunk::Destructor), // NOXREF - HOOK_DEF(0x01D05A30, (MethodThunk::Constructor), void(int, int, bool)), - HOOK_DEF(0x01D05C50, CUtlSymbolTable::AddString), - HOOK_DEF(0x01D05B10, CUtlSymbolTable::Find), - HOOK_DEF(0x01D05DA0, CUtlSymbolTable::String), - //HOOK_DEF(0x0, CUtlSymbolTable::RemoveAll), // NOXREF - HOOK_DEF(0x01D05960, CUtlSymbolTable::SymLess), - HOOK_DEF(0x01D059E0, CUtlSymbolTable::SymLessi), - - HOOK_DEF(0x01D05890, (MethodThunk::Constructor), void(const char *)), - HOOK_DEF(0x01D05830, CUtlSymbol::Initialize), // Don't touch it - HOOK_DEF(0x01D05880, CUtlSymbol::CurrTable), // Don't touch it - HOOK_DEF(0x01D058C0, CUtlSymbol::String), - //HOOK_DEF(0x01D058E0, CUtlSymbol::operator==, bool (const char *) const), // NOXREF - -#endif // CUtlSymbol_Region - - { NULL, NULL, NULL }, -}; - -AddressRef g_FunctionRefs[] = -{ -#ifndef Function_References_region - -#endif // Function_References_region - - { NULL, NULL, NULL }, -}; - -AddressRef g_DataRefs[] = -{ -#ifndef Data_References_region - - //GLOBALVAR_LINK(0x01D1B020, "CBaseFileSystem::s_pFileSystem", CBaseFileSystem::s_pFileSystem), - GLOBALVAR_LINK(0x01D1B0B8, "g_LessCtx", pg_LessCtx), - -#endif // Data_References_region - - { NULL, NULL, NULL }, -}; diff --git a/rehlds/hookers/filesystem/hooklist.h b/rehlds/hookers/filesystem/hooklist.h deleted file mode 100644 index 7b28577..0000000 --- a/rehlds/hookers/filesystem/hooklist.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifdef HOOK_FILESYSTEM - -#define rehlds_syserror FileSystem_SysError -#define g_LessCtx (*pg_LessCtx) - -#include "hookers/memory.h" -#include "hookers/helper.h" -#include "hookers/hooker.h" - -extern struct LessCtx_t g_LessCtx; - -#endif // HOOK_FILESYSTEM diff --git a/rehlds/hookers/filesystem/main.cpp b/rehlds/hookers/filesystem/main.cpp deleted file mode 100644 index 4a9fd7c..0000000 --- a/rehlds/hookers/filesystem/main.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -#if defined(HOOK_FILESYSTEM) - -const char *ORIGINAL_FILESYSTEM_DLL_NAME = "filesystem_stdio2.dll"; - -CSysModule *g_pOriginalFileSystemModule = nullptr; -CreateInterfaceFn g_OriginalFileSystemFactory = nullptr; -IFileSystem *g_pOriginalFileSystem = nullptr; - -IBaseInterface *CreateFileSystemInterface() -{ - if (g_pOriginalFileSystem) { - return g_pOriginalFileSystem; - } - - if (g_pOriginalFileSystemModule) - { - g_OriginalFileSystemFactory = (CreateInterfaceFn)Sys_GetFactory(g_pOriginalFileSystemModule); - - if (g_OriginalFileSystemFactory) - { - int returnCode = 0; - g_pOriginalFileSystem = (IFileSystem *)g_OriginalFileSystemFactory(FILESYSTEM_INTERFACE_VERSION, &returnCode); - return g_pOriginalFileSystem; - } - } - - return nullptr; -} - -EXPOSE_INTERFACE_FN(CreateFileSystemInterface, IFileSystem, FILESYSTEM_INTERFACE_VERSION); - -// DLL entry point -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - g_pOriginalFileSystemModule = (CSysModule *)LoadLibrary(ORIGINAL_FILESYSTEM_DLL_NAME); - size_t addr = (size_t)Sys_GetProcAddress(ORIGINAL_FILESYSTEM_DLL_NAME, CREATEINTERFACE_PROCNAME); - HookModule("hlds.exe", addr); - } - else if (fdwReason == DLL_PROCESS_DETACH) - { - if (g_pOriginalFileSystemModule) - { - Sys_UnloadModule(g_pOriginalFileSystemModule); - g_pOriginalFileSystemModule = nullptr; - - g_OriginalFileSystemFactory = nullptr; - g_pOriginalFileSystem = nullptr; - } - } - - return TRUE; -} - -#endif // #if defined(HOOK_FILESYSTEM) diff --git a/rehlds/hookers/helper.h b/rehlds/hookers/helper.h deleted file mode 100644 index 926d551..0000000 --- a/rehlds/hookers/helper.h +++ /dev/null @@ -1,163 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#if defined(HOOK_HLTV) || defined(HOOK_FILESYSTEM) - -#define private public -#define protected public - -template -class MethodThunk { -public: - void Constructor(TArgs ... args) { - new(this) T(args ...); - } - - void Destructor() { - (*(T *)this).~T(); - } -}; - -namespace MsvcMethod { - namespace Detail { - using Counter = std::size_t(*)(); - - template - std::size_t GetIndex() { - return N; - } - - template - constexpr auto GenerateCounters_Helper(std::index_sequence) { - // There is no make_array (and/or deduction guides), so we need to explicitly define array template params - return std::array { &GetIndex ... }; - } - - template - auto counters = GenerateCounters_Helper(std::make_index_sequence{}); - - struct VIndexGetter {}; - struct ThisGetter { - decltype(auto) GetThis() const { - return this; - } - - decltype(auto) GetThis(...) const { - return this; - } - }; - - template - class Singleton { - public: - static T &GetInstance() { - static T instance = {}; - return instance; - } - }; - - // primary template - template - struct is_variadic_function : std::false_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - template - struct is_variadic_function : std::true_type {}; - - template - constexpr bool is_variadic_function_v = is_variadic_function::value; - - template - constexpr bool is_function_v = std::is_function::value; - } // namespace Detail - - static constexpr auto& counters = Detail::counters<256>; - - template - std::enable_if_t, std::uintptr_t> - GetVirtualIndex(TMethod T::*method) - { - decltype(auto) pcounters = counters.data(); - decltype(auto) vIndexGetter = (Detail::VIndexGetter *)&pcounters; - - using VIndexGetterFunction = std::conditional_t, std::size_t (Detail::VIndexGetter::*)(...) const, std::size_t(Detail::VIndexGetter::*)() const>; - VIndexGetterFunction vIndexGetterFunction; - { - *(std::uintptr_t *)&vIndexGetterFunction = *(std::uintptr_t *)&method; - } - - return (vIndexGetter->*vIndexGetterFunction)(); - } - - template - TMethod &declmethod(TMethod T::*method); - - template - std::enable_if_t, std::uintptr_t> - GetVirtualAddress(TMethod T::*method) - { - using ThisGetterFunction = std::conditional_t, const T *(T::*)(...) const, const T *(T::*)() const>; - ThisGetterFunction thisGetterFunction = *(ThisGetterFunction *)&method; - { - decltype(auto) m = static_cast, const Detail::ThisGetter *(Detail::ThisGetter::*)(...) const, const Detail::ThisGetter *(Detail::ThisGetter::*)() const>>(&Detail::ThisGetter::GetThis); - *(std::uintptr_t *)&thisGetterFunction = *(std::uintptr_t *)&m; - } - - return *(*(std::uintptr_t **)(Detail::Singleton::GetInstance().*thisGetterFunction)() + GetVirtualIndex(method)); - } - - template - std::enable_if_t, std::uintptr_t> - GetAddress(TMethod (T::*method)) { - return (std::uintptr_t &)method; - } - - template - std::enable_if_t, std::uintptr_t> - GetAddress(TMethod (*method)) { - return (std::uintptr_t &)method; - } - -} // namespace MsvcMethod - -#ifdef _MSC_VER - #define GLOBALVAR_LINK(offset, symbol, var, ...) { offset, #symbol, (size_t)&##var, __VA_ARGS__ } - #define HOOK_SYMBOLDEF(offset, symbol, func, ...) { offset, #symbol, MsvcMethod::GetAddress<__VA_ARGS__>(&func) } - #define HOOK_SYMBOL_VIRTUAL_DEF(offset, symbol, func, ...) { offset, #symbol, MsvcMethod::GetVirtualAddress<__VA_ARGS__>(&func) } - #define HOOK_SYMBOL_VIRTUAL_EX(offset, class, func, ...) { offset, #class#func, MsvcMethod::GetVirtualAddress(&class::func))>::type, class>(&class::func) } - - #define HOOK_DEF(offset, func, ...) HOOK_SYMBOLDEF(offset, func, func, __VA_ARGS__) - #define HOOK_VIRTUAL_DEF(offset, func, ...) HOOK_SYMBOL_VIRTUAL_DEF(offset, func, func, __VA_ARGS__) - -#else - #error Hooking stuff is only available using MSVC compiler. -#endif // _MSC_VER - -#endif // #if defined(HOOK_HLTV) || defined(HOOK_FILESYSTEM) diff --git a/rehlds/hookers/hooker.cpp b/rehlds/hookers/hooker.cpp deleted file mode 100644 index 1fce842..0000000 --- a/rehlds/hookers/hooker.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* -* -* 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 -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -Module g_Module = { NULL, NULL, NULL, NULL }; - -// Offset where module assumed be loaded to ajust hooks offsets. NULL for the Linux to trigger symbols searching. -#ifdef _WIN32 -const size_t g_BaseOffset = 0x01D00000; -#else -const size_t g_BaseOffset = NULL; -#endif - -void *GetOriginalFuncAddrOrDie(const char *funcName) -{ - for (FunctionHook *cfh = &g_FunctionHooks[0]; cfh->symbolName; cfh++) - { - if (!strcmp(cfh->symbolName, funcName)) - return (void*) cfh->originalAddress; - } - - rehlds_syserror("%s: Could not find function '%s'", __func__, funcName); -} - -void *GetOriginalFuncAddrOrDefault(const char *funcName, void *def) -{ - for (FunctionHook *cfh = &g_FunctionHooks[0]; cfh->symbolName; cfh++) - { - if (!strcmp(cfh->symbolName, funcName)) - return (void*)cfh->originalAddress; - } - - return def; -} - -void *GetFuncRefAddrOrDie(const char *funcName) -{ - for (AddressRef *cfh = &g_FunctionRefs[0]; cfh->symbolName; cfh++) - { - if (!strcmp(cfh->symbolName, funcName)) - return (void*)cfh->originalAddress; - } - - rehlds_syserror("%s: Could not find function '%s'", __func__, funcName); -} - -void *GetFuncRefAddrOrDefault(const char *funcName, void *def) -{ - for (AddressRef *cfh = &g_FunctionRefs[0]; cfh->symbolName; cfh++) - { - if (!strcmp(cfh->symbolName, funcName)) - return (void*)cfh->originalAddress; - } - - return def; -} - -int HookModule(const char *pszAppName, size_t addr) -{ - if (addr == NULL || !FindModuleByAddress(addr, &g_Module)) { - return (FALSE); - } - - // Find all addresses - bool success = true; - - AddressRef *refData = g_DataRefs; - while (refData->symbolName != NULL) - { - if (!GetAddress(&g_Module, (Address*)refData, g_BaseOffset)) - { -#if _DEBUG - printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex); - success = false; -#endif - } - refData++; - } - - AddressRef *refFunc = g_FunctionRefs; - while (refFunc->symbolName != NULL) - { - if (!GetAddress(&g_Module, (Address*)refFunc, g_BaseOffset)) - { -#if _DEBUG - printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex); - success = false; -#endif - } - refFunc++; - } - - FunctionHook *hookFunc = g_FunctionHooks; - while (hookFunc->handlerFunc != NULL) - { - if (!GetAddress(&g_Module, (Address*)hookFunc, g_BaseOffset)) - { -#if _DEBUG - printf("%s: symbol not found \"%s\", symbol index: %i\n", __func__, refData->symbolName, refData->symbolIndex); - success = false; -#endif - } - hookFunc++; - } - - if (!success) - { -#if _DEBUG - printf("%s: failed to hook module!\n", __func__); -#endif - return (FALSE); - } - - refData = g_DataRefs; - while (refData->addressRef != NULL) - { - if (!FindDataRef(&g_Module, refData)) - return (FALSE); - refData++; - } - - refFunc = g_FunctionRefs; - while (refFunc->addressRef != NULL) - { - if (!FindDataRef(&g_Module, refFunc)) - return (FALSE); - refFunc++; - } - - hookFunc = g_FunctionHooks; - while (hookFunc->handlerFunc != NULL) - { - if (!HookFunction(&g_Module, hookFunc)) - return (FALSE); - hookFunc++; - } - - return (TRUE); -} - -#ifdef _WIN32 - -void *malloc_wrapper(size_t size) { - return malloc(size); -} - -void *realloc_wrapper(void *orig, size_t newSize) { - return realloc(orig, newSize); -} - -void free_wrapper(void *mem) { - free(mem); -} - -void *calloc_wrapper(size_t count, size_t size) { - return calloc(count, size); -} - -void *__nh_malloc_wrapper(size_t sz, int unk) { - return malloc(sz); -} - -char *strdup_wrapper(const char *s) { - return _strdup(s); -} - -#endif // _WIN32 - -void logf(const char *fmt, ...) -{ - va_list argptr; - static char string[8192]; - - va_start(argptr, fmt); - _vsnprintf(string, sizeof(string), fmt, argptr); - string[sizeof(string) - 1] = 0; - - FILE *fl = fopen("hooker.log", "a"); - fprintf(fl, "%s\n", string); - fclose(fl); -} diff --git a/rehlds/hookers/hooker.h b/rehlds/hookers/hooker.h deleted file mode 100644 index 8f5eeac..0000000 --- a/rehlds/hookers/hooker.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "osconfig.h" - -extern int HookModule(const char *pszAppName, size_t addr); -extern void *GetOriginalFuncAddrOrDie(const char *funcName); -extern void *GetOriginalFuncAddrOrDefault(const char *funcName, void *def); -extern void *GetFuncRefAddrOrDie(const char *funcName); -extern void *GetFuncRefAddrOrDefault(const char *funcName, void *def); -extern void logf(const char *fmt, ...); - -extern FunctionHook g_FunctionHooks[]; -extern AddressRef g_FunctionRefs[]; -extern AddressRef g_DataRefs[]; - -#ifdef _WIN32 - -void *malloc_wrapper(size_t size); -void *realloc_wrapper(void *orig, size_t newSize); -void free_wrapper(void *mem); -void *calloc_wrapper(size_t count, size_t size); -void *__nh_malloc_wrapper(size_t sz, int unk); -char *strdup_wrapper(const char *s); - -#endif // _WIN32 diff --git a/rehlds/lib/linux32/libm.so b/rehlds/lib/linux32/libm.so new file mode 100644 index 0000000..b0430eb Binary files /dev/null and b/rehlds/lib/linux32/libm.so differ diff --git a/rehlds/lib/linux32/librt.so b/rehlds/lib/linux32/librt.so new file mode 100644 index 0000000..4b39fa4 Binary files /dev/null and b/rehlds/lib/linux32/librt.so differ diff --git a/rehlds/msvc/ReHLDS.vcxproj b/rehlds/msvc/ReHLDS.vcxproj index 5742693..2078e83 100644 --- a/rehlds/msvc/ReHLDS.vcxproj +++ b/rehlds/msvc/ReHLDS.vcxproj @@ -88,7 +88,6 @@ - true true @@ -143,6 +142,7 @@ + @@ -176,9 +176,17 @@ true true - + + true + true + true + true + true + true + true + true true @@ -358,7 +366,6 @@ - @@ -440,26 +447,13 @@ + - - - true - true - true - true - - - true - true - true - true - - {792df067-9904-4579-99b9-46c17277ade3} @@ -467,6 +461,9 @@ {ceb94f7c-e459-4673-aabb-36e2074396c0} + + {6973dca5-253c-4d84-b51e-187e035eae06} + {70A2B904-B7DB-4C48-8DE0-AF567360D572} @@ -553,29 +550,31 @@ swds + true swds + true - filesystem_stdio + swds + true - filesystem_stdio + swds + true swds + false swds + false - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 Disabled true @@ -607,12 +606,8 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 Disabled true @@ -646,16 +641,12 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 Disabled true - REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h @@ -682,16 +673,12 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 Disabled true - REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_SSE;REHLDS_JIT;REHLDS_UNIT_TESTS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h @@ -717,18 +704,14 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 MaxSpeed true true true - REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded /arch:IA32 %(AdditionalOptions) Use @@ -761,12 +744,8 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - - $(ProjectDir)\..\;$(ProjectDir)\..\hookers\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories) Level3 MaxSpeed true diff --git a/rehlds/msvc/ReHLDS.vcxproj.filters b/rehlds/msvc/ReHLDS.vcxproj.filters index 81ac2fe..a59f265 100644 --- a/rehlds/msvc/ReHLDS.vcxproj.filters +++ b/rehlds/msvc/ReHLDS.vcxproj.filters @@ -338,8 +338,8 @@ rehlds - - rehlds + + testsuite @@ -1057,16 +1057,8 @@ engine - - rehlds + + testsuite - - - linux - - - linux - - \ No newline at end of file diff --git a/rehlds/public/HLTV/IProxy.h b/rehlds/public/HLTV/IProxy.h index 68f0d75..7313a26 100644 --- a/rehlds/public/HLTV/IProxy.h +++ b/rehlds/public/HLTV/IProxy.h @@ -102,6 +102,7 @@ public: virtual unsigned char GetRegion() = 0; virtual IObjectContainer *GetClients() = 0; virtual bool WriteSignonData(int type, BitBuffer *stream) = 0; + virtual int GetChatDelay() const = 0; }; #define PROXY_INTERFACE_VERSION "proxy001" diff --git a/rehlds/public/engine_hlds_api.h b/rehlds/public/engine_hlds_api.h index 007237e..8ae9b01 100644 --- a/rehlds/public/engine_hlds_api.h +++ b/rehlds/public/engine_hlds_api.h @@ -39,7 +39,7 @@ class IDedicatedServerAPI : public IBaseInterface { public: - virtual bool Init(char *basedir, char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory) = 0; + virtual bool Init(const char *basedir, const char *cmdline, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory) = 0; virtual int Shutdown() = 0; virtual bool RunFrame() = 0; virtual void AddConsoleText(char *text) = 0; diff --git a/rehlds/public/idedicatedexports.h b/rehlds/public/idedicatedexports.h index 2444e22..4e20b03 100644 --- a/rehlds/public/idedicatedexports.h +++ b/rehlds/public/idedicatedexports.h @@ -34,7 +34,7 @@ class IDedicatedExports : public IBaseInterface { public: virtual ~IDedicatedExports() {}; - virtual void Sys_Printf(char *text) = 0; + virtual void Sys_Printf(const char *text) = 0; }; #define VENGINE_DEDICATEDEXPORTS_API_VERSION "VENGINE_DEDICATEDEXPORTS_API_VERSION001" diff --git a/rehlds/public/interface.cpp b/rehlds/public/interface.cpp index d5a35ad..3394746 100644 --- a/rehlds/public/interface.cpp +++ b/rehlds/public/interface.cpp @@ -130,7 +130,7 @@ CSysModule *Sys_LoadModule(const char *pModuleName) HMODULE hDLL = LoadLibrary(pModuleName); #else HMODULE hDLL = nullptr; - char szAbsoluteModuleName[1024]; + char szAbsoluteModuleName[2048]; if (pModuleName[0] != '/') { char szCwd[1024]; @@ -150,7 +150,7 @@ CSysModule *Sys_LoadModule(const char *pModuleName) if (!hDLL) { - char str[512]; + char str[2048+6]; // room for extension string #if defined(_WIN32) _snprintf(str, sizeof(str), "%s.dll", pModuleName); diff --git a/rehlds/public/rehlds/custom.h b/rehlds/public/rehlds/custom.h index 2116ed4..1f0089a 100644 --- a/rehlds/public/rehlds/custom.h +++ b/rehlds/public/rehlds/custom.h @@ -63,13 +63,7 @@ typedef struct resourceinfo_s typedef struct resource_s { -#ifdef HOOK_HLTV - // NOTE HLTV: array szFileName declared on 260 cell, - // this changes necessary for compatibility hookers. - char szFileName[MAX_PATH]; -#else char szFileName[MAX_QPATH]; // File name to download/precache. -#endif // HOOK_HLTV resourcetype_t type; // t_sound, t_skin, t_model, t_decal. int nIndex; // For t_decals diff --git a/rehlds/public/rehlds/osconfig.h b/rehlds/public/rehlds/osconfig.h index 9f70ec9..8d889af 100644 --- a/rehlds/public/rehlds/osconfig.h +++ b/rehlds/public/rehlds/osconfig.h @@ -136,6 +136,8 @@ VirtualFree(ptr, 0, MEM_RELEASE); } #else // _WIN32 + #include + #ifndef PAGESIZE #define PAGESIZE 4096 #endif diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 0a73b4f..4d0a74e 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -37,7 +37,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 7 +#define REHLDS_API_VERSION_MINOR 10 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -108,8 +108,8 @@ typedef IVoidHookChain IRehldsHook_ClientConnected; typedef IVoidHookChainRegistry IRehldsHookRegistry_ClientConnected; //HandleNetCommand -typedef IVoidHookChain IRehldsHook_HandleNetCommand; -typedef IVoidHookChainRegistry IRehldsHookRegistry_HandleNetCommand; +typedef IVoidHookChain IRehldsHook_HandleNetCommand; +typedef IVoidHookChainRegistry IRehldsHookRegistry_HandleNetCommand; //Mod_LoadBrushModel typedef IVoidHookChain IRehldsHook_Mod_LoadBrushModel; @@ -203,6 +203,15 @@ typedef IHookChainRegistry IRehldsHookRe typedef IVoidHookChain<> IRehldsHook_SV_Frame; typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame; +//SV_ShouldSendConsistencyList hook +typedef IHookChain IRehldsHook_SV_ShouldSendConsistencyList; +typedef IHookChainRegistry IRehldsHookRegistry_SV_ShouldSendConsistencyList; + +//GetEntityInit hook +typedef IHookChain IRehldsHook_GetEntityInit; +typedef IHookChainRegistry IRehldsHookRegistry_GetEntityInit; + + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -248,6 +257,8 @@ public: virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0; virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0; virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0; + virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0; + virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0; }; struct RehldsFuncs_t { @@ -316,7 +327,7 @@ struct RehldsFuncs_t { char*(*MSG_ReadStringLine)(); float(*MSG_ReadAngle)(); float(*MSG_ReadHiresAngle)(); - void(*MSG_ReadUsercmd)(usercmd_t *to, usercmd_t *from); + void(*MSG_ReadUsercmd)(struct usercmd_s *to, struct usercmd_s *from); float(*MSG_ReadCoord)(); void(*MSG_ReadVec3Coord)(sizebuf_t *sb, vec3_t fa); @@ -340,7 +351,7 @@ struct RehldsFuncs_t { void(*MSG_WriteFloat)(sizebuf_t *sb, float f); void(*MSG_WriteAngle)(sizebuf_t *sb, float f); void(*MSG_WriteHiresAngle)(sizebuf_t *sb, float f); - void(*MSG_WriteUsercmd)(sizebuf_t *sb, usercmd_t *to, usercmd_t *from); + void(*MSG_WriteUsercmd)(sizebuf_t *sb, struct usercmd_s *to, struct usercmd_s *from); void(*MSG_WriteCoord)(sizebuf_t *sb, float f); void(*MSG_WriteVec3Coord)(sizebuf_t *sb, const vec3_t fa); diff --git a/rehlds/public/rehlds/rehlds_interfaces.h b/rehlds/public/rehlds/rehlds_interfaces.h index 8e12e33..da3768c 100644 --- a/rehlds/public/rehlds/rehlds_interfaces.h +++ b/rehlds/public/rehlds/rehlds_interfaces.h @@ -48,16 +48,22 @@ class IGameClient { public: virtual int GetId() = 0; + // false = client is free virtual bool IsActive() = 0; virtual void SetActive(bool active) = 0; + // false = don't send datagrams virtual bool IsSpawned() = 0; virtual void SetSpawned(bool spawned) = 0; + // The client's net connection virtual INetChan* GetNetChan() = 0; + // The datagram is written to after every frame, but only cleared + // when it is sent out to the client. It can be harmlessly overflowed virtual sizebuf_t* GetDatagram() = 0; + // EDICT_NUM(clientnum + 1) virtual edict_t* GetEdict() = 0; virtual USERID_t* GetNetworkUserID() = 0; @@ -67,12 +73,156 @@ public: virtual bool IsConnected() = 0; virtual void SetConnected(bool connected) = 0; + // Which other clients does this guy's voice stream go to? virtual uint32 GetVoiceStream(int stream_id) = 0; virtual void SetLastVoiceTime(double time) = 0; virtual double GetLastVoiceTime() = 0; + + // Does this client want to hear his own voice? virtual bool GetLoopback() = 0; virtual struct usercmd_s *GetLastCmd() = 0; + // This is spectator proxy (hltv) + virtual bool IsProxy() = 0; + virtual void SetProxy(bool proxy) = 0; + + // This client is a fake player controlled by the game DLL + virtual bool IsFakeClient() = 0; + virtual void SetFakeClient(bool state) = 0; + + // On server, getting data + virtual bool IsFullyConnected() = 0; + virtual void SetFullyConnected(bool state) = 0; + + virtual bool IsUploading() = 0; + virtual void SetUploading(bool state) = 0; + + virtual bool IsHasUserMsgs() = 0; + virtual void SetHasUserMsgs(bool value) = 0; + + virtual bool HasForceUnmodified() = 0; + virtual void SetHasForceUnmodified(bool value) = 0; + + // Number of packets choked at the server because the client - server network channel + // is backlogged with too much data + virtual int GetChokeCount() = 0; + virtual void SetChokeCount(int count) = 0; + + // -1 = no compression. This is where the server is creating the compressed info from + virtual int GetDeltaSequence() = 0; + virtual void SetDeltaSequence(int value) = 0; + + // For filling in big drops + virtual void SetLastCmd(struct usercmd_s *ucmd) = 0; + + virtual double GetConnectTime() = 0; + virtual void SetConnectTime(double time) = 0; + + virtual double GetCmdTime() = 0; + virtual void SetCmdTime(double time) = 0; + + virtual double GetIgnoreCmdTime() = 0; + virtual void SetIgnoreCmdTime(double time) = 0; + + virtual float GetLatency() = 0; + virtual void SetLatency(float latency) = 0; + + virtual float GetPacketLoss() = 0; + virtual void SetPacketLoss(float packetLoss) = 0; + + virtual double GetLocalTime() = 0; + virtual void SetLocalTime(double time) = 0; + + virtual double GetSvTimeBase() = 0; + virtual void SetSvTimeBase(double time) = 0; + + // Or time of disconnect for zombies + virtual double GetConnectionStartedTime() = 0; + virtual void SetConnectionStartedTime(double time) = 0; + + // Time when we should send next world state update (datagram) + virtual double GetNextMessageTime() = 0; + virtual void SetNextMessageTime(double time) = 0; + + // Default time to wait for next message + virtual double GetNextMessageIntervalTime() = 0; + virtual void SetNextMessageIntervalTime(double time_interval) = 0; + + // false - only send messages if the client has sent one and the bandwidth is not choked + virtual bool GetSendMessageState() = 0; + virtual void SetSendMessageState(bool state) = 0; + + virtual bool GetSkipMessageState() = 0; + virtual void SetSkipMessageState(bool state) = 0; + + virtual bool GetSendInfoState() = 0; + virtual void SetSendInfoState(bool state) = 0; + + virtual float GetSendInfoTime() = 0; + virtual void SetSendInfoTime(float time) = 0; + + // updates can be deltad from here + virtual struct client_frame_s *GetFrames() = 0; + + // Per edict events + virtual struct event_state_s *GetEvents() = 0; + + // View Entity (camera or the client itself) svc_setview + virtual const edict_t *GetViewEntity() = 0; + virtual void SetViewEntity(const edict_t *entity) = 0; + + // Identifying number on server + virtual int GetUserID() = 0; + virtual void SetUserID(int iUserID) = 0; + + // name, etc (received from client) + virtual char *GetUserInfo() = 0; + + // MD5 hash is 32 hex #'s, plus trailing 0 + // Hashed CD Key (32 hex alphabetic chars + 0 terminator) + virtual char *GetHashedCDKey() = 0; + + virtual int GetTopColor() = 0; + virtual void SetTopColor(int color) = 0; + + virtual int GetBottomColor() = 0; + virtual void SetBottomColor(int color) = 0; + + virtual resource_t *GetResourcesOnHand() = 0; + virtual resource_t *GetResourcesNeeded() = 0; + + virtual FileHandle_t GetUploadFileHandle() = 0; + virtual void SetUploadFileHandle(FileHandle_t fhFile) = 0; + + virtual bool IsUploadDoneRegistering() = 0; + virtual void SetUploadDoneRegistering(bool state) = 0; + + virtual customization_t *GetCustomizationData() = 0; + + virtual int GetCRC32MapValue() = 0; + virtual void SetCRC32MapValue(int crcMapValue) = 0; + + // Perform client side prediction of weapon effects + // Determines that the client enabled prediction weapons and will be handled pfnGetWeaponData + virtual bool IsClientPredictingWeapons() = 0; + virtual void SetClientPredictingWeapons(bool state) = 0; + + // Perform server side lag compensation of player movement + // Determines that the client is requesting lag compensation + virtual bool IsClientLagCompensation() = 0; + virtual void SetClientLagCompensation(bool state) = 0; + + // Set on server (transmit to client) + virtual char *GetPhysInfo() = 0; + + virtual void SetVoiceStream(int stream_id, int value) = 0; + + virtual int GetSendResourceCount() = 0; + virtual void SetSendResourceCount(int count) = 0; + + virtual bool IsSentNewResponse() = 0; + virtual void SetSentNewResponse(bool state) = 0; + // this must be the last virtual function in class #ifdef REHLDS_SELF virtual client_t* GetClient() = 0; @@ -105,6 +255,12 @@ public: virtual client_t* GetClient_t(int id) = 0; virtual int GetIndexOfClient_t(client_t* client) = 0; virtual int GetMaxClientsLimit() = 0; + virtual client_t *GetNextClient_t(client_t *client) = 0; + virtual int GetSpawnCount() = 0; + virtual void SetSpawnCount(int count) = 0; + virtual struct server_log_s *GetLog() = 0; + virtual bool IsSecure() = 0; + virtual void SetSecure(bool value) = 0; }; class IRehldsServerData { @@ -131,4 +287,40 @@ public: virtual class ISteamGameServer *GetSteamGameServer() = 0; virtual struct netadr_s *GetNetFrom() = 0; virtual double GetOldTime() = 0; + + virtual void SetNetFrom(struct netadr_s *from) = 0; + virtual void SetWorldmapCrc(uint32 crcValue) = 0; + virtual void SetDecalNameNum(int num) = 0; + + virtual bool IsActive() = 0; + virtual void SetActive(bool state) = 0; + virtual bool IsPaused() = 0; + virtual void SetPaused(bool state) = 0; + virtual int GetLastIndexCheckInPVS() = 0; + virtual void SetLastIndexCheckInPVS(int id) = 0; + virtual double GetLastIndexCheckTimeInPVS() = 0; + virtual void SetLastIndexCheckTimeInPVS(double time) = 0; + virtual const char *GetOldName() = 0; + virtual void SetOldName(const char *name) = 0; + virtual const char *GetStartSpotName() = 0; + virtual void SetStartSpotName(const char *startspot) = 0; + virtual struct model_s *GetWorldModel() = 0; + virtual void SetWorldModel(struct model_s *model) = 0; + virtual struct consistency_s *GetConsistency(int index) = 0; + virtual struct model_s *GetModel(int index) = 0; + virtual struct event_s *GetEventPrecache(int index) = 0; + virtual struct entity_state_s *GetEntityBaseline(int index) = 0; + virtual struct extra_baselines_s *GetEntityInstanceBaselines() = 0; + virtual int GetNumGenericNames() = 0; + virtual void SetNumGenericNames(int num) = 0; + virtual int GetNumEdicts() = 0; + virtual void SetNumEdicts(int num_edicts) = 0; + virtual int GetMaxEdicts() = 0; + virtual void SetMaxEdicts(int max_edicts) = 0; + virtual edict_t *GetEdict(int index) = 0; + virtual server_state_t GetState() = 0; + virtual void SetState(server_state_t st) = 0; + virtual sizebuf_t *GetMulticastBuf() = 0; + virtual sizebuf_t *GetSpectatorBuf() = 0; + virtual sizebuf_t *GetSignonBuf() = 0; }; diff --git a/rehlds/public/rehlds/static_map.h b/rehlds/public/rehlds/static_map.h index b1da16f..8b63d4c 100644 --- a/rehlds/public/rehlds/static_map.h +++ b/rehlds/public/rehlds/static_map.h @@ -229,8 +229,8 @@ protected: if (cpuinfo.sse4_2) { while (*pcc) { char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; + if (cc >= 'A' && cc <= 'Z') { + cc = (cc - 'A') + 'a'; } cksum = crc32c_t8_sse(cksum, cc); } @@ -240,8 +240,8 @@ protected: { while (*pcc) { char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; + if (cc >= 'A' && cc <= 'Z') { + cc = (cc - 'A') + 'a'; } cksum = crc32c_t8_nosse(cksum, cc); } diff --git a/rehlds/public/tier0/characterset.cpp b/rehlds/public/tier0/characterset.cpp index 9088b64..e179e2e 100644 --- a/rehlds/public/tier0/characterset.cpp +++ b/rehlds/public/tier0/characterset.cpp @@ -44,7 +44,7 @@ void CharacterSetBuild(characterset_t *pSetBuffer, const char *pszSetString) while (pszSetString[i]) { - pSetBuffer->set[pszSetString[i]] = 1; + pSetBuffer->set[(unsigned)pszSetString[i]] = 1; i++; } } diff --git a/rehlds/public/tier0/dbg.cpp b/rehlds/public/tier0/dbg.cpp index df1c6ce..dfd73d8 100644 --- a/rehlds/public/tier0/dbg.cpp +++ b/rehlds/public/tier0/dbg.cpp @@ -140,7 +140,7 @@ SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list /* Printf the file and line for warning + assert only... */ int len = 0; - if ((spewType == SPEW_ASSERT)) + if (spewType == SPEW_ASSERT) { len = sprintf(pTempBuffer, "%s (%d) : ", s_pFileName, s_Line); } @@ -149,7 +149,7 @@ SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list len += vsprintf(&pTempBuffer[len], pMsgFormat, args); // Add \n for warning and assert - if ((spewType == SPEW_ASSERT)) + if (spewType == SPEW_ASSERT) { len += sprintf(&pTempBuffer[len], "\n"); } diff --git a/rehlds/public/utlbuffer.cpp b/rehlds/public/utlbuffer.cpp index 69ba751..13aec0e 100644 --- a/rehlds/public/utlbuffer.cpp +++ b/rehlds/public/utlbuffer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============ // // The copyright to the contents herein is the property of Valve, L.L.C. // The contents may be used and/or copied only with the written permission of @@ -205,7 +205,7 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) char c; char* pEnd; - while (c = *pFmt++) + while ((c = *pFmt++)) { // Stop if we hit the end of the buffer if (m_Get >= Size()) diff --git a/rehlds/public/utlrbtree.h b/rehlds/public/utlrbtree.h index 45bed14..67463dc 100644 --- a/rehlds/public/utlrbtree.h +++ b/rehlds/public/utlrbtree.h @@ -234,11 +234,12 @@ protected: // Constructor, Destructor template CUtlRBTree::CUtlRBTree(int growSize, int initSize, LessFunc_t lessfunc) : - m_Elements(growSize, initSize), m_LessFunc(lessfunc), + m_Elements(growSize, initSize), m_Root(InvalidIndex()), - m_NumElements(0), m_TotalElements(0), - m_FirstFree(InvalidIndex()) + m_NumElements(0), + m_FirstFree(InvalidIndex()), + m_TotalElements(0) { } diff --git a/rehlds/rehlds/jitasm.h b/rehlds/rehlds/jitasm.h index a33113f..13cb32e 100644 --- a/rehlds/rehlds/jitasm.h +++ b/rehlds/rehlds/jitasm.h @@ -322,7 +322,7 @@ namespace detail bool operator==(const Opd& rhs) const { - if ((opdtype_ & O_TYPE_TYPE_MASK) != (rhs.opdtype_ & O_TYPE_TYPE_MASK) || opdsize_ != opdsize_) {return false;} + if ((opdtype_ & O_TYPE_TYPE_MASK) != (rhs.opdtype_ & O_TYPE_TYPE_MASK) || opdsize_ != rhs.opdsize_) {return false;} if (IsReg()) {return reg_ == rhs.reg_ && reg_assignable_ == rhs.reg_assignable_;} if (IsMem()) {return base_ == rhs.base_ && index_ == rhs.index_ && scale_ == rhs.scale_ && disp_ == rhs.disp_ && addrsize_ == rhs.addrsize_;} if (IsImm()) {return imm_ == rhs.imm_;} diff --git a/rehlds/rehlds/platform.cpp b/rehlds/rehlds/platform.cpp index 21a08f6..d6e8a79 100644 --- a/rehlds/rehlds/platform.cpp +++ b/rehlds/rehlds/platform.cpp @@ -102,7 +102,7 @@ int CSimplePlatform::setsockopt(SOCKET s, int level, int optname, const char* op #ifdef _WIN32 return setsockopt_v11(s, level, optname, optval, optlen); #else - return setsockopt(s, level, optname, optval, optlen); + return ::setsockopt(s, level, optname, optval, optlen); #endif } @@ -213,6 +213,8 @@ void NORETURN rehlds_syserror(const char* fmt, ...) { fclose(fl); //TerminateProcess(GetCurrentProcess(), 1); - *((int*)NULL) = 0; + volatile int *null = 0; + *null = 0; + while (true); } diff --git a/rehlds/rehlds/precompiled.h b/rehlds/rehlds/precompiled.h index 5127133..de99a03 100644 --- a/rehlds/rehlds/precompiled.h +++ b/rehlds/rehlds/precompiled.h @@ -14,8 +14,6 @@ #include "static_map.h" #include "ed_strpool.h" - -#include "memory.h" #include "strtools.h" // Valve libs stuff diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index f4ade26..7cfe15e 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -515,7 +515,7 @@ RehldsFuncs_t g_RehldsApiFuncs = &AddCvarListener_api, &RemoveExtDll_api, &RemoveCvarListener_api, - &GetEntityInit, + &GetEntityInit_api, &MSG_ReadChar_api, &MSG_ReadByte_api, &MSG_ReadLong_api, @@ -827,6 +827,14 @@ IRehldsHookRegistry_SV_Frame* CRehldsHookchains::SV_Frame() { return &m_SV_Frame; } +IRehldsHookRegistry_SV_ShouldSendConsistencyList* CRehldsHookchains::SV_ShouldSendConsistencyList() { + return &m_SV_ShouldSendConsistencyList; +} + +IRehldsHookRegistry_GetEntityInit* CRehldsHookchains::GetEntityInit() { + return &m_GetEntityInit; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 689556b..835a24b 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -103,8 +103,8 @@ typedef IVoidHookChainImpl CRehldsHook_ClientConnected; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_ClientConnected; //HandleNetCommand -typedef IVoidHookChainImpl CRehldsHook_HandleNetCommand; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_HandleNetCommand; +typedef IVoidHookChainImpl CRehldsHook_HandleNetCommand; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_HandleNetCommand; //Mod_LoadBrushModel typedef IVoidHookChainImpl CRehldsHook_Mod_LoadBrushModel; @@ -198,6 +198,14 @@ typedef IHookChainRegistryImpl CRehldsHo typedef IVoidHookChainImpl<> CRehldsHook_SV_Frame; typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Frame; +//SV_ShouldSendConsistencyList hook +typedef IHookChainImpl CRehldsHook_SV_ShouldSendConsistencyList; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_ShouldSendConsistencyList; + +//GetEntityInit hook +typedef IHookChainImpl CRehldsHook_GetEntityInit; +typedef IHookChainRegistryImpl CRehldsHookRegistry_GetEntityInit; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -241,6 +249,8 @@ public: CRehldsHookRegistry_CreateFakeClient m_CreateFakeClient; CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits; CRehldsHookRegistry_SV_Frame m_SV_Frame; + CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList; + CRehldsHookRegistry_GetEntityInit m_GetEntityInit; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -284,6 +294,8 @@ public: EXT_FUNC virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits(); EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame(); + EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList(); + EXT_FUNC virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index a1103a8..fa07ac5 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -53,30 +53,40 @@ struct usercmd_s* EXT_FUNC CGameClient::GetLastCmd() bool EXT_FUNC CGameClient::IsActive() { - return m_pClient->active != 0; + return m_pClient->active != FALSE; } void EXT_FUNC CGameClient::SetActive(bool active) { - m_pClient->active = active ? 1 : 0; + m_pClient->active = active ? TRUE : FALSE; } bool EXT_FUNC CGameClient::IsSpawned() { - return m_pClient->spawned != 0; + return m_pClient->spawned != FALSE; } void EXT_FUNC CGameClient::SetSpawned(bool spawned) { - m_pClient->spawned = spawned ? 1 : 0; + m_pClient->spawned = spawned ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::IsProxy() +{ + return m_pClient->proxy != FALSE; +} + +void EXT_FUNC CGameClient::SetProxy(bool proxy) +{ + m_pClient->proxy = proxy ? TRUE : FALSE; } bool EXT_FUNC CGameClient::IsConnected() { - return m_pClient->connected != 0; + return m_pClient->connected != FALSE; } void EXT_FUNC CGameClient::SetConnected(bool connected) { - m_pClient->connected = connected ? 1 : 0; + m_pClient->connected = connected ? TRUE : FALSE; } uint32 EXT_FUNC CGameClient::GetVoiceStream(int stream_id) { @@ -94,7 +104,7 @@ double EXT_FUNC CGameClient::GetLastVoiceTime() { } bool EXT_FUNC CGameClient::GetLoopback() { - return m_pClient->m_bLoopback != 0; + return m_pClient->m_bLoopback != FALSE; } INetChan* EXT_FUNC CGameClient::GetNetChan() @@ -127,6 +137,378 @@ client_t* EXT_FUNC CGameClient::GetClient() return m_pClient; } +bool EXT_FUNC CGameClient::IsFakeClient() +{ + return m_pClient->fakeclient; +} + +void EXT_FUNC CGameClient::SetFakeClient(bool state) +{ + m_pClient->fakeclient = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::IsFullyConnected() +{ + return m_pClient->fully_connected; +} + +void EXT_FUNC CGameClient::SetFullyConnected(bool state) +{ + m_pClient->fully_connected = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::IsUploading() +{ + return m_pClient->uploading != FALSE; +} + +void EXT_FUNC CGameClient::SetUploading(bool state) +{ + m_pClient->uploading = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::IsHasUserMsgs() +{ + return m_pClient->hasusrmsgs != FALSE; +} + +void EXT_FUNC CGameClient::SetHasUserMsgs(bool value) +{ + m_pClient->hasusrmsgs = value ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::HasForceUnmodified() +{ + return m_pClient->has_force_unmodified != FALSE; +} + +void EXT_FUNC CGameClient::SetHasForceUnmodified(bool value) +{ + m_pClient->has_force_unmodified = value ? TRUE : FALSE; +} + +int EXT_FUNC CGameClient::GetChokeCount() +{ + return m_pClient->chokecount; +} + +void EXT_FUNC CGameClient::SetChokeCount(int count) +{ + m_pClient->chokecount = count; +} + +int EXT_FUNC CGameClient::GetDeltaSequence() +{ + return m_pClient->delta_sequence; +} + +void EXT_FUNC CGameClient::SetDeltaSequence(int value) +{ + m_pClient->delta_sequence = value; +} + +void EXT_FUNC CGameClient::SetLastCmd(usercmd_t *ucmd) +{ + m_pClient->lastcmd = *ucmd; +} + +double EXT_FUNC CGameClient::GetConnectTime() +{ + return m_pClient->connecttime; +} + +void EXT_FUNC CGameClient::SetConnectTime(double time) +{ + m_pClient->connecttime = time; +} + +double EXT_FUNC CGameClient::GetCmdTime() +{ + return m_pClient->cmdtime; +} + +void EXT_FUNC CGameClient::SetCmdTime(double time) +{ + m_pClient->cmdtime = time; +} + +double EXT_FUNC CGameClient::GetIgnoreCmdTime() +{ + return m_pClient->ignorecmdtime; +} + +void EXT_FUNC CGameClient::SetIgnoreCmdTime(double time) +{ + m_pClient->ignorecmdtime = time; +} + +float EXT_FUNC CGameClient::GetLatency() +{ + return m_pClient->latency; +} + +void EXT_FUNC CGameClient::SetLatency(float latency) +{ + m_pClient->latency = latency; +} + +float EXT_FUNC CGameClient::GetPacketLoss() +{ + return m_pClient->packet_loss; +} + +void EXT_FUNC CGameClient::SetPacketLoss(float packetLoss) +{ + m_pClient->packet_loss = packetLoss; +} + +double EXT_FUNC CGameClient::GetLocalTime() +{ + return m_pClient->localtime; +} + +void EXT_FUNC CGameClient::SetLocalTime(double time) +{ + m_pClient->localtime = time; +} + +double EXT_FUNC CGameClient::GetSvTimeBase() +{ + return m_pClient->svtimebase; +} + +void EXT_FUNC CGameClient::SetSvTimeBase(double time) +{ + m_pClient->svtimebase = time; +} + +double EXT_FUNC CGameClient::GetConnectionStartedTime() +{ + return m_pClient->connection_started; +} + +void EXT_FUNC CGameClient::SetConnectionStartedTime(double time) +{ + m_pClient->connection_started = time; +} + +double EXT_FUNC CGameClient::GetNextMessageTime() +{ + return m_pClient->next_messagetime; +} + +void EXT_FUNC CGameClient::SetNextMessageTime(double time) +{ + m_pClient->next_messagetime = time; +} + +double EXT_FUNC CGameClient::GetNextMessageIntervalTime() +{ + return m_pClient->next_messageinterval; +} + +void EXT_FUNC CGameClient::SetNextMessageIntervalTime(double time_interval) +{ + m_pClient->next_messageinterval = time_interval; +} + +bool EXT_FUNC CGameClient::GetSendMessageState() +{ + return m_pClient->send_message != FALSE; +} + +void EXT_FUNC CGameClient::SetSendMessageState(bool state) +{ + m_pClient->send_message = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::GetSkipMessageState() +{ + return m_pClient->skip_message != FALSE; +} + +void EXT_FUNC CGameClient::SetSkipMessageState(bool state) +{ + m_pClient->skip_message = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::GetSendInfoState() +{ + return m_pClient->sendinfo != FALSE; +} + +void EXT_FUNC CGameClient::SetSendInfoState(bool state) +{ + m_pClient->sendinfo = state ? TRUE : FALSE; +} + +float EXT_FUNC CGameClient::GetSendInfoTime() +{ + return m_pClient->sendinfo_time; +} + +void EXT_FUNC CGameClient::SetSendInfoTime(float time) +{ + m_pClient->sendinfo_time = time; +} + +client_frame_t *EXT_FUNC CGameClient::GetFrames() +{ + return m_pClient->frames; +} + +event_state_t *EXT_FUNC CGameClient::GetEvents() +{ + return &m_pClient->events; +} + +const edict_t *EXT_FUNC CGameClient::GetViewEntity() +{ + return m_pClient->pViewEntity; +} + +void EXT_FUNC CGameClient::SetViewEntity(const edict_t *entity) +{ + m_pClient->pViewEntity = entity; +} + +int EXT_FUNC CGameClient::GetUserID() +{ + return m_pClient->userid; +} + +void EXT_FUNC CGameClient::SetUserID(int iUserID) +{ + m_pClient->userid = iUserID; +} + +char *EXT_FUNC CGameClient::GetUserInfo() +{ + return m_pClient->userinfo; +} + +char *EXT_FUNC CGameClient::GetHashedCDKey() +{ + return m_pClient->hashedcdkey; +} + +int EXT_FUNC CGameClient::GetTopColor() +{ + return m_pClient->topcolor; +} + +void EXT_FUNC CGameClient::SetTopColor(int color) +{ + m_pClient->topcolor = color; +} + +int EXT_FUNC CGameClient::GetBottomColor() +{ + return m_pClient->bottomcolor; +} + +void EXT_FUNC CGameClient::SetBottomColor(int color) +{ + m_pClient->bottomcolor = color; +} + +resource_t *EXT_FUNC CGameClient::GetResourcesOnHand() +{ + return &m_pClient->resourcesonhand; +} + +resource_t *EXT_FUNC CGameClient::GetResourcesNeeded() +{ + return &m_pClient->resourcesneeded; +} + +FileHandle_t EXT_FUNC CGameClient::GetUploadFileHandle() +{ + return m_pClient->upload; +} + +void EXT_FUNC CGameClient::SetUploadFileHandle(FileHandle_t fhFile) +{ + m_pClient->upload = fhFile; +} + +bool EXT_FUNC CGameClient::IsUploadDoneRegistering() +{ + return m_pClient->uploaddoneregistering != FALSE; +} + +void EXT_FUNC CGameClient::SetUploadDoneRegistering(bool state) +{ + m_pClient->uploaddoneregistering = state ? TRUE : FALSE; +} + +customization_t *EXT_FUNC CGameClient::GetCustomizationData() +{ + return &m_pClient->customdata; +} + +int EXT_FUNC CGameClient::GetCRC32MapValue() +{ + return m_pClient->crcValue; +} + +void EXT_FUNC CGameClient::SetCRC32MapValue(int crcMapValue) +{ + m_pClient->crcValue = crcMapValue; +} + +bool EXT_FUNC CGameClient::IsClientPredictingWeapons() +{ + return m_pClient->lw != FALSE; +} + +void EXT_FUNC CGameClient::SetClientPredictingWeapons(bool state) +{ + m_pClient->lw = state ? TRUE : FALSE; +} + +bool EXT_FUNC CGameClient::IsClientLagCompensation() +{ + return m_pClient->lc != FALSE; +} + +void EXT_FUNC CGameClient::SetClientLagCompensation(bool state) +{ + m_pClient->lc = state ? TRUE : FALSE; +} + +char *EXT_FUNC CGameClient::GetPhysInfo() +{ + return m_pClient->physinfo; +} + +void EXT_FUNC CGameClient::SetVoiceStream(int stream_id, int value) +{ + if (stream_id < 0 || stream_id >= ARRAYSIZE(m_pClient->m_VoiceStreams)) + return; + + m_pClient->m_VoiceStreams[stream_id] = value; +} + +int EXT_FUNC CGameClient::GetSendResourceCount() +{ + return m_pClient->m_sendrescount; +} + +void EXT_FUNC CGameClient::SetSendResourceCount(int count) +{ + m_pClient->m_sendrescount = count; +} + +bool EXT_FUNC CGameClient::IsSentNewResponse() +{ + return m_pClient->m_bSentNewResponse != FALSE; +} + +void EXT_FUNC CGameClient::SetSentNewResponse(bool state) +{ + m_pClient->m_bSentNewResponse = state ? TRUE : FALSE; +} CNetChan::CNetChan(netchan_t* chan) { @@ -160,6 +542,36 @@ int EXT_FUNC CRehldsServerStatic::GetMaxClientsLimit() return g_psvs.maxclientslimit; } +client_t *EXT_FUNC CRehldsServerStatic::GetNextClient_t(client_t *client) +{ + return ++client; +} + +int EXT_FUNC CRehldsServerStatic::GetSpawnCount() +{ + return g_psvs.spawncount; +} + +void EXT_FUNC CRehldsServerStatic::SetSpawnCount(int count) +{ + g_psvs.spawncount = count; +} + +server_log_t *EXT_FUNC CRehldsServerStatic::GetLog() +{ + return &g_psvs.log; +} + +bool EXT_FUNC CRehldsServerStatic::IsSecure() +{ + return g_psvs.isSecure != FALSE; +} + +void EXT_FUNC CRehldsServerStatic::SetSecure(bool value) +{ + g_psvs.isSecure = value ? TRUE : FALSE; +} + bool EXT_FUNC CRehldsServerStatic::IsLogActive() { return g_psvs.log.active ? true : false; @@ -216,6 +628,10 @@ uint32 EXT_FUNC CRehldsServerData::GetWorldmapCrc() { return g_psv.worldmapCRC; } +void EXT_FUNC CRehldsServerData::SetWorldmapCrc(uint32 crcValue) { + g_psv.worldmapCRC = crcValue; +} + uint8* EXT_FUNC CRehldsServerData::GetClientDllMd5() { return g_psv.clientdllmd5; } @@ -244,6 +660,10 @@ int EXT_FUNC CRehldsServerData::GetDecalNameNum() { return sv_decalnamecount; } +void EXT_FUNC CRehldsServerData::SetDecalNameNum(int num) { + sv_decalnamecount = num; +} + double EXT_FUNC CRehldsServerData::GetTime() { return g_psv.time; } @@ -264,6 +684,178 @@ struct resource_s *EXT_FUNC CRehldsServerData::GetResource(int index) { #endif // REHLDS_FIXES } +bool EXT_FUNC CRehldsServerData::IsActive() +{ + return g_psv.active != FALSE; +} + +void EXT_FUNC CRehldsServerData::SetActive(bool state) +{ + g_psv.active = state ? TRUE : FALSE; +} + +bool EXT_FUNC CRehldsServerData::IsPaused() +{ + return g_psv.paused != FALSE; +} + +void EXT_FUNC CRehldsServerData::SetPaused(bool state) +{ + g_psv.paused = state ? TRUE : FALSE; +} + +int EXT_FUNC CRehldsServerData::GetLastIndexCheckInPVS() +{ + return g_psv.lastcheck; +} + +void EXT_FUNC CRehldsServerData::SetLastIndexCheckInPVS(int id) +{ + g_psv.lastcheck = id; +} + +double EXT_FUNC CRehldsServerData::GetLastIndexCheckTimeInPVS() +{ + return g_psv.lastchecktime; +} + +void EXT_FUNC CRehldsServerData::SetLastIndexCheckTimeInPVS(double time) +{ + g_psv.lastchecktime = time; +} + +const char *EXT_FUNC CRehldsServerData::GetOldName() +{ + return g_psv.oldname; +} + +void EXT_FUNC CRehldsServerData::SetOldName(const char *name) +{ + Q_strncpy(g_psv.oldname, name, ARRAYSIZE(g_psv.oldname) - 1); + g_psv.oldname[ARRAYSIZE(g_psv.oldname) - 1] = '\0'; +} + +const char *EXT_FUNC CRehldsServerData::GetStartSpotName() +{ + return g_psv.startspot; +} + +void EXT_FUNC CRehldsServerData::SetStartSpotName(const char *startspot) +{ + Q_strncpy(g_psv.startspot, startspot, ARRAYSIZE(g_psv.startspot) - 1); + g_psv.startspot[ARRAYSIZE(g_psv.startspot) - 1] = '\0'; +} + +model_t *EXT_FUNC CRehldsServerData::GetWorldModel() +{ + return g_psv.worldmodel; +} + +void EXT_FUNC CRehldsServerData::SetWorldModel(model_t *model) +{ + g_psv.worldmodel = model; +} + +consistency_t *EXT_FUNC CRehldsServerData::GetConsistency(int index) +{ + if (index < 0 || index >= MAX_CONSISTENCY_LIST) + return NULL; + + return &g_psv.consistency_list[index]; +} + +model_t *EXT_FUNC CRehldsServerData::GetModel(int index) +{ + if (index < 0 || index >= MAX_MODELS) + return NULL; + + return g_psv.models[index]; +} + +event_t *EXT_FUNC CRehldsServerData::GetEventPrecache(int index) +{ + if (index < 0 || index >= MAX_EVENTS) + return NULL; + + return &g_psv.event_precache[index]; +} + +entity_state_t *EXT_FUNC CRehldsServerData::GetEntityBaseline(int index) +{ + if (index < 0 || index >= g_psv.max_edicts) + return NULL; + + return &g_psv.baselines[index]; +} + +extra_baselines_t *EXT_FUNC CRehldsServerData::GetEntityInstanceBaselines() +{ + return g_psv.instance_baselines; +} + +int EXT_FUNC CRehldsServerData::GetNumGenericNames() +{ + return g_psv.num_generic_names; +} + +void EXT_FUNC CRehldsServerData::SetNumGenericNames(int num) +{ + g_psv.num_generic_names = num; +} + +int EXT_FUNC CRehldsServerData::GetNumEdicts() +{ + return g_psv.num_edicts; +} + +void EXT_FUNC CRehldsServerData::SetNumEdicts(int num_edicts) +{ + g_psv.num_edicts = num_edicts; +} + +int EXT_FUNC CRehldsServerData::GetMaxEdicts() +{ + return g_psv.max_edicts; +} + +void EXT_FUNC CRehldsServerData::SetMaxEdicts(int max_edicts) +{ + g_psv.max_edicts = max_edicts; +} + +edict_t *EXT_FUNC CRehldsServerData::GetEdict(int index) +{ + if (index < 0 || index >= g_psv.max_edicts) + return NULL; + + return &g_psv.edicts[index]; +} + +server_state_t EXT_FUNC CRehldsServerData::GetState() +{ + return g_psv.state; +} + +void EXT_FUNC CRehldsServerData::SetState(server_state_t st) +{ + g_psv.state = st; +} + +sizebuf_t *EXT_FUNC CRehldsServerData::GetMulticastBuf() +{ + return &g_psv.multicast; +} + +sizebuf_t *EXT_FUNC CRehldsServerData::GetSpectatorBuf() +{ + return &g_psv.spectator; +} + +sizebuf_t *EXT_FUNC CRehldsServerData::GetSignonBuf() +{ + return &g_psv.signon; +} + void Rehlds_Interfaces_FreeClients() { if (g_GameClients == NULL) @@ -310,3 +902,7 @@ ISteamGameServer* EXT_FUNC CRehldsServerData::GetSteamGameServer() { netadr_t* EXT_FUNC CRehldsServerData::GetNetFrom() { return &net_from; } + +void EXT_FUNC CRehldsServerData::SetNetFrom(netadr_t *from) { + net_from = *from; +} diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index 431ca99..5cf4dba 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -98,8 +98,148 @@ public: virtual bool GetLoopback(); virtual struct usercmd_s *GetLastCmd(); + virtual bool IsProxy(); + virtual void SetProxy(bool proxy); + virtual client_t* GetClient(); + // This client is a fake player controlled by the game DLL + virtual bool IsFakeClient(); + virtual void SetFakeClient(bool state); + + // On server, getting data + virtual bool IsFullyConnected(); + virtual void SetFullyConnected(bool state); + + virtual bool IsUploading(); + virtual void SetUploading(bool state); + + virtual bool IsHasUserMsgs(); + virtual void SetHasUserMsgs(bool value); + + virtual bool HasForceUnmodified(); + virtual void SetHasForceUnmodified(bool value); + + // Number of packets choked at the server because the client - server network channel + // is backlogged with too much data + virtual int GetChokeCount(); + virtual void SetChokeCount(int count); + + // -1 = no compression. This is where the server is creating the compressed info from + virtual int GetDeltaSequence(); + virtual void SetDeltaSequence(int value); + + // For filling in big drops + virtual void SetLastCmd(struct usercmd_s *ucmd); + + virtual double GetConnectTime(); + virtual void SetConnectTime(double time); + + virtual double GetCmdTime(); + virtual void SetCmdTime(double time); + + virtual double GetIgnoreCmdTime(); + virtual void SetIgnoreCmdTime(double time); + + virtual float GetLatency(); + virtual void SetLatency(float latency); + + virtual float GetPacketLoss(); + virtual void SetPacketLoss(float packetLoss); + + virtual double GetLocalTime(); + virtual void SetLocalTime(double time); + + virtual double GetSvTimeBase(); + virtual void SetSvTimeBase(double time); + + // Or time of disconnect for zombies + virtual double GetConnectionStartedTime(); + virtual void SetConnectionStartedTime(double time); + + // Time when we should send next world state update (datagram) + virtual double GetNextMessageTime(); + virtual void SetNextMessageTime(double time); + + // Default time to wait for next message + virtual double GetNextMessageIntervalTime(); + virtual void SetNextMessageIntervalTime(double time_interval); + + // false - only send messages if the client has sent one and the bandwidth is not choked + virtual bool GetSendMessageState(); + virtual void SetSendMessageState(bool state); + + virtual bool GetSkipMessageState(); + virtual void SetSkipMessageState(bool state); + + virtual bool GetSendInfoState(); + virtual void SetSendInfoState(bool state); + + virtual float GetSendInfoTime(); + virtual void SetSendInfoTime(float time); + + // updates can be deltad from here + virtual struct client_frame_s *GetFrames(); + + // Per edict events + virtual struct event_state_s *GetEvents(); + + // View Entity (camera or the client itself) svc_setview + virtual const edict_t *GetViewEntity(); + virtual void SetViewEntity(const edict_t *entity); + + // Identifying number on server + virtual int GetUserID(); + virtual void SetUserID(int iUserID); + + // name, etc (received from client) + virtual char *GetUserInfo(); + + // MD5 hash is 32 hex #'s, plus trailing 0 + // Hashed CD Key (32 hex alphabetic chars + 0 terminator) + virtual char *GetHashedCDKey(); + + virtual int GetTopColor(); + virtual void SetTopColor(int color); + + virtual int GetBottomColor(); + virtual void SetBottomColor(int color); + + virtual resource_t *GetResourcesOnHand(); + virtual resource_t *GetResourcesNeeded(); + + virtual FileHandle_t GetUploadFileHandle(); + virtual void SetUploadFileHandle(FileHandle_t fhFile); + + virtual bool IsUploadDoneRegistering(); + virtual void SetUploadDoneRegistering(bool state); + + virtual customization_t *GetCustomizationData(); + + virtual int GetCRC32MapValue(); + virtual void SetCRC32MapValue(int crcMapValue); + + // Perform client side prediction of weapon effects + // Determines that the client enabled prediction weapons and will be handled pfnGetWeaponData + virtual bool IsClientPredictingWeapons(); + virtual void SetClientPredictingWeapons(bool state); + + // Perform server side lag compensation of player movement + // Determines that the client is requesting lag compensation + virtual bool IsClientLagCompensation(); + virtual void SetClientLagCompensation(bool state); + + // Set on server (transmit to client) + virtual char *GetPhysInfo(); + + virtual void SetVoiceStream(int stream_id, int value); + + virtual int GetSendResourceCount(); + virtual void SetSendResourceCount(int count); + + virtual bool IsSentNewResponse(); + virtual void SetSentNewResponse(bool state); + public: bool GetSpawnedOnce() const { return m_bSpawnedOnce; } void SetSpawnedOnce(bool spawned) { m_bSpawnedOnce = spawned; } @@ -122,6 +262,12 @@ public: virtual client_t* GetClient_t(int id); virtual int GetIndexOfClient_t(client_t* client); virtual int GetMaxClientsLimit(); + virtual client_t *GetNextClient_t(client_t *client); + virtual int GetSpawnCount(); + virtual void SetSpawnCount(int count); + virtual struct server_log_s *GetLog(); + virtual bool IsSecure(); + virtual void SetSecure(bool value); }; class CRehldsServerData : public IRehldsServerData { @@ -146,6 +292,42 @@ public: virtual ISteamGameServer *GetSteamGameServer(); virtual netadr_t *GetNetFrom(); virtual double GetOldTime(); + + virtual void SetNetFrom(struct netadr_s *from); + virtual void SetWorldmapCrc(uint32 crcValue); + virtual void SetDecalNameNum(int num); + + virtual bool IsActive(); + virtual void SetActive(bool state); + virtual bool IsPaused(); + virtual void SetPaused(bool state); + virtual int GetLastIndexCheckInPVS(); + virtual void SetLastIndexCheckInPVS(int id); + virtual double GetLastIndexCheckTimeInPVS(); + virtual void SetLastIndexCheckTimeInPVS(double time); + virtual const char *GetOldName(); + virtual void SetOldName(const char *name); + virtual const char *GetStartSpotName(); + virtual void SetStartSpotName(const char *startspot); + virtual struct model_s *GetWorldModel(); + virtual void SetWorldModel(struct model_s *model); + virtual struct consistency_s *GetConsistency(int index); + virtual struct model_s *GetModel(int index); + virtual struct event_s *GetEventPrecache(int index); + virtual struct entity_state_s *GetEntityBaseline(int index); + virtual struct extra_baselines_s *GetEntityInstanceBaselines(); + virtual int GetNumGenericNames(); + virtual void SetNumGenericNames(int num); + virtual int GetNumEdicts(); + virtual void SetNumEdicts(int num_edicts); + virtual int GetMaxEdicts(); + virtual void SetMaxEdicts(int max_edicts); + virtual edict_t *GetEdict(int index); + virtual server_state_t GetState(); + virtual void SetState(server_state_t st); + virtual sizebuf_t *GetMulticastBuf(); + virtual sizebuf_t *GetSpectatorBuf(); + virtual sizebuf_t *GetSignonBuf(); }; extern CGameClient** g_GameClients; diff --git a/rehlds/hookers/memory.cpp b/rehlds/testsuite/memory.cpp similarity index 100% rename from rehlds/hookers/memory.cpp rename to rehlds/testsuite/memory.cpp diff --git a/rehlds/hookers/memory.h b/rehlds/testsuite/memory.h similarity index 100% rename from rehlds/hookers/memory.h rename to rehlds/testsuite/memory.h diff --git a/rehlds/testsuite/testsuite.h b/rehlds/testsuite/testsuite.h index f3a912b..fc20067 100644 --- a/rehlds/testsuite/testsuite.h +++ b/rehlds/testsuite/testsuite.h @@ -15,4 +15,4 @@ const int TESTSUITE_PROTOCOL_VERSION_MAJOR = 0; void TestSuite_Init(const Module* engine, const Module* executable, const AddressRef* funcRefs); -#endif \ No newline at end of file +#endif diff --git a/rehlds/unittests/TestRunner.cpp b/rehlds/unittests/TestRunner.cpp index cb9fa86..cffaeff 100644 --- a/rehlds/unittests/TestRunner.cpp +++ b/rehlds/unittests/TestRunner.cpp @@ -1,16 +1,10 @@ #include "precompiled.h" #include "rehlds_tests_shared.h" -#include "cppunitlite/GradleAdapter.h" +#include "cppunitlite/MainAdapter.h" int main(int argc, char* argv[]) { printf("TestRunner: main()\n"); - GradleAdapter a; - int res = a.testsEntryPoint(argc, argv); - -#ifdef _BUILD_FROM_IDE - system("PAUSE"); -#endif - - return res; + MainAdapter a; + return a.testsEntryPoint(argc, argv); } diff --git a/rehlds/unittests/delta_tests.cpp b/rehlds/unittests/delta_tests.cpp index efa8f14..efc7998 100644 --- a/rehlds/unittests/delta_tests.cpp +++ b/rehlds/unittests/delta_tests.cpp @@ -177,7 +177,7 @@ NOINLINE void _GetBitmaskAndBytecount(delta_t* delta, int* bits, int* bytecount, NOINLINE delta_t* _CreateTestDeltaDesc() { static delta_description_t _fields[32]; - delta_test_struct_t d; d; // "use" d variable + delta_test_struct_t d = {}; UNUSED(d); _InitDeltaField(&_fields[0], 0x00, DT_BYTE, "b_00", offsetof(delta_test_struct_t, b_00), 1, 8, 1.0f, 1.0f); _InitDeltaField(&_fields[1], 0x01, DT_BYTE, "b_01", offsetof(delta_test_struct_t, b_01), 1, 8, 1.0f, 1.0f); diff --git a/rehlds/unittests/info_tests.cpp b/rehlds/unittests/info_tests.cpp index 8e176c8..87d0479 100644 --- a/rehlds/unittests/info_tests.cpp +++ b/rehlds/unittests/info_tests.cpp @@ -67,13 +67,13 @@ TEST(SetValueForStarKey, Info, 1000) { "\\cl_updaterate\\100\\topcolor\\60\\name\\abcdefghijklmnop\\*sid\\12332432525345\\_vgui_menus\\1\\model\\urban\\somelargeuselesskey\\12312321321323123123123213123123123123123123123123123123123123123dasdsad\\_cl_autowepswitch\\1", }, - { + { "\\cl_updaterate\\100\\topcolor\\60\\name\\abcdefghijklmnop\\*sid\\12332432525345\\_vgui_menus\\1\\model\\urban\\somelargeuselesskey\\12312321321323123123123213123123123123123123123123123123123123123dasdsad\\_cl_autowepswitch\\1", "*team", "12345678901234567890123456789012345678", "\\cl_updaterate\\100\\topcolor\\60\\name\\abcdefghijklmnop\\*sid\\12332432525345\\_vgui_menus\\1\\model\\urban\\_cl_autowepswitch\\1\\*team\\12345678901234567890123456789012345678", }, - + { "\\cl_updaterate\\100\\topcolor\\60\\name\\abcdefghijklmnop\\*sid\\12332432525345\\_vgui_menus\\1\\model\\urban\\somelargeuselesskey\\12312321321323123123123213123123123123123123123123123123123123123dasdsad\\_cl_autowepswitch\\1", "*team", @@ -126,7 +126,7 @@ TEST(SetValueForStarKeyResult, Info, 1000) { char localInfo[256]; strcpy(localInfo, d->initialInfo); localInfo[255] = 0; - bool result = Info_SetValueForStarKey(localInfo, d->key, d->value, 256); + bool result = Info_SetValueForStarKey(localInfo, d->key, d->value, 256) ? true : false; CHECK("Invalid info string", d->success == result); } } @@ -301,7 +301,7 @@ TEST(Info_IsKeyImportant, Info, 1000) for (int i = 0; i < ARRAYSIZE(testdata); i++) { testdata_t* d = &testdata[i]; - bool result = Info_IsKeyImportant(d->key); + bool result = Info_IsKeyImportant(d->key) ? true : false; CHECK("wrong result", d->result == result); } diff --git a/rehlds/msvc/PreBuild.bat b/rehlds/version/appversion.bat similarity index 88% rename from rehlds/msvc/PreBuild.bat rename to rehlds/version/appversion.bat index 03f6b34..b2d4bdb 100644 --- a/rehlds/msvc/PreBuild.bat +++ b/rehlds/version/appversion.bat @@ -4,6 +4,8 @@ :: Pre-build auto-versioning script :: +chcp 65001 + set srcdir=%~1 set repodir=%~2 @@ -77,14 +79,6 @@ IF EXIST "%srcdir%\version.h" ( IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k ) ) -) ELSE ( - FOR /F "usebackq tokens=1,2,3,* delims==" %%i in ("%repodir%..\gradle.properties") do ( - IF NOT [%%j] == [] ( - IF %%i==majorVersion set version_major=%%j - IF %%i==minorVersion set version_minor=%%j - IF %%i==maintenanceVersion set version_maintenance=%%j - ) - ) ) :: @@ -210,11 +204,5 @@ echo.>>"%srcdir%\appversion.h" echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h" -:: -:: Do update of version.cpp file last modify time to force it recompile -:: -copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp" -endlocal - :_exit exit /B 0 diff --git a/rehlds/version/appversion.sh b/rehlds/version/appversion.sh new file mode 100755 index 0000000..ffafce2 --- /dev/null +++ b/rehlds/version/appversion.sh @@ -0,0 +1,158 @@ +#!/bin/bash + +init() +{ + SOURCE_DIR=$@ + GIT_DIR=$SOURCE_DIR + VERSION_FILE=$SOURCE_DIR/rehlds/version/version.h + APPVERSION_FILE=$SOURCE_DIR/rehlds/version/appversion.h + + if test -z "`git --version`"; then + echo "Please install git client" + echo "sudo apt-get install git" + exit -1 + fi + + # Read old version + if [ -e $APPVERSION_FILE ]; then + OLD_VERSION=$(cat $APPVERSION_FILE | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') + if [ $? -ne 0 ]; then + OLD_VERSION="" + else + # Remove quotes + OLD_VERSION=$(echo $OLD_VERSION | xargs) + fi + fi + + # Get major, minor and maintenance information from gradle.properties + MAJOR=$(cat $VERSION_FILE | grep -wi 'VERSION_MAJOR' | sed -e 's/.*VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MAJOR" = "" ]; then + MAJOR=0 + fi + + MINOR=$(cat $VERSION_FILE | grep -wi 'VERSION_MINOR' | sed -e 's/.*VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MINOR" = "" ]; then + MINOR=0 + fi + + MAINTENANCE=$(cat $VERSION_FILE | grep -i 'VERSION_MAINTENANCE' | sed -e 's/.*VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then + MAINTENANCE=0 + fi + + BRANCH_NAME=$(git -C "$GIT_DIR/" rev-parse --abbrev-ref HEAD) + if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then + BRANCH_NAME=master + fi + + COMMIT_COUNT=$(git -C "$GIT_DIR/" rev-list --count $BRANCH_NAME) + if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then + COMMIT_COUNT=0 + fi + + # + # Configure remote url repository + # + # Get remote name by current branch + BRANCH_REMOTE=$(git -C "$GIT_DIR/" config branch.$BRANCH_NAME.remote) + if [ $? -ne 0 -o "$BRANCH_REMOTE" = "" ]; then + BRANCH_REMOTE=origin + fi + + # Get commit id + COMMIT_SHA=$(git -C "$GIT_DIR/" rev-parse --verify HEAD) + COMMIT_SHA=${COMMIT_SHA:0:7} + + # Get remote url + COMMIT_URL=$(git -C "$GIT_DIR/" config remote.$BRANCH_REMOTE.url) + + URL_CONSTRUCT=0 + + if [[ "$COMMIT_URL" == *"git@"* ]]; then + URL_CONSTRUCT=1 + + # Strip prefix 'git@' + COMMIT_URL=${COMMIT_URL#git@} + + # Strip postfix '.git' + COMMIT_URL=${COMMIT_URL%.git} + + # Replace ':' to '/' + COMMIT_URL=${COMMIT_URL/:/\/} + + elif [[ "$COMMIT_URL" == *"https://"* ]]; then + URL_CONSTRUCT=1 + + # Strip prefix 'https://' + COMMIT_URL=${COMMIT_URL#https://} + + # Strip postfix '.git' + COMMIT_URL=${COMMIT_URL%.git} + fi + + if test "$URL_CONSTRUCT" -eq 1; then + # Append extra string + if [[ "$COMMIT_URL" == *"bitbucket.org"* ]]; then + COMMIT_URL=$(echo https://$COMMIT_URL/commits/) + else + COMMIT_URL=$(echo https://$COMMIT_URL/commit/) + fi + fi + + # + # Detect local modifications + # + if [ `git -C "$GIT_DIR/" ls-files -m | wc -l` = 0 ]; then + MODIFIED= + else + MODIFIED=+m + fi + + NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT-dev$MODIFIED" + + # Update appversion.h if version has changed or modifications/mixed revisions detected + if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then + update_appversion + fi +} + +update_appversion() +{ + day=$(date +%d) + year=$(date +%Y) + hours=$(date +%H:%M:%S) + month=$(LANG=en_us_88591; date +"%b") + + # Write appversion.h + echo Updating appversion.h, new version is '"'$NEW_VERSION'"', the old one was $OLD_VERSION + + echo -e "#ifndef __APPVERSION_H__\r">"$APPVERSION_FILE" + echo -e "#define __APPVERSION_H__\r">>"$APPVERSION_FILE" + echo -e "\r">>"$APPVERSION_FILE" + echo -e "//\r">>"$APPVERSION_FILE" + echo -e "// This file is generated automatically.\r">>"$APPVERSION_FILE" + echo -e "// Don't edit it.\r">>"$APPVERSION_FILE" + echo -e "//\r">>"$APPVERSION_FILE" + echo -e "\r">>"$APPVERSION_FILE" + echo -e "// Version defines\r">>"$APPVERSION_FILE" + echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>"$APPVERSION_FILE" + + echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>"$APPVERSION_FILE" + echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>"$APPVERSION_FILE" + echo -e "#define APP_VERSION_FLAGS 0x0L\r">>"$APPVERSION_FILE" + echo -e "\r">>"$APPVERSION_FILE" + echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>"$APPVERSION_FILE" + echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>"$APPVERSION_FILE" + echo -e "\r">>"$APPVERSION_FILE" + + echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>"$APPVERSION_FILE" + echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>"$APPVERSION_FILE" + echo -e "\r">>"$APPVERSION_FILE" + echo -e "#endif //__APPVERSION_H__\r">>"$APPVERSION_FILE" +} + +# Initialise +init $* + +# Exit normally +exit 0 diff --git a/rehlds/version/appversion.vm b/rehlds/version/appversion.vm deleted file mode 100644 index 6fe6c2e..0000000 --- a/rehlds/version/appversion.vm +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __APPVERSION_H__ -\#define __APPVERSION_H__ - -// -// This file is generated automatically. -// Don't edit it. -// - -// Version defines -\#define APP_VERSION "$verInfo.asMavenVersion()" - -\#define APP_COMMIT_DATE "$verInfo.asCommitDate()" -\#define APP_COMMIT_TIME "$verInfo.asCommitTime()" - -\#define APP_COMMIT_SHA "$verInfo.commitSHA" -\#define APP_COMMIT_URL "$verInfo.commitURL" - -#endif //__APPVERSION_H__ diff --git a/rehlds/version/glibc_test.sh b/rehlds/version/glibc_test.sh new file mode 100755 index 0000000..74d41d2 --- /dev/null +++ b/rehlds/version/glibc_test.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +main() +{ + files=($@) + + declare -A threshold_version + threshold_version[CXXABI]="1.3.5" + threshold_version[GLIBCXX]="3.4.15" + threshold_version[GLIBC]="2.11" + + for k in "${!threshold_version[@]}"; do + for f in "${files[@]}" + do + : + version=$(readelf -sV $f | sed -n 's/.*@'$k'_//p' | sort -u -V | tail -1 | cut -d ' ' -f 1) + + # version no present - skipped + if [[ -z "$version" ]]; then + version="UND" + # version is private - skipped + elif [ "$version" = "PRIVATE" ]; then + version="PRV" + # ensure numeric + elif [[ $version =~ ^([0-9]+\.){0,2}(\*|[0-9]+)$ ]]; then + check_version_greater $version ${threshold_version[$k]} + if [[ $? -eq 1 ]]; then + echo -e "\033[0;31mAssertion failed:\033[0m Binary \033[0;32m${f}\033[0m has ${k}_\033[0;33m$version\033[0m greater than max version ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + exit -1 + fi + fi + done + + if [[ "$version" = "PRV" || "$version" = "UND" ]]; then + echo -e "[\033[0;90mSKIP\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + else + echo -e "[\033[0;32mOK\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + fi + done +} + +check_version_greater() +{ + if [[ -z "$1" || $1 == $2 ]]; then + return 0 + fi + + local IFS=. + local i ver1=($1) ver2=($2) + + # fill empty fields in ver1 with zeros + for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)) + do + ver1[i]=0 + done + + for ((i = 0; i < ${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + break + fi + done + + return 0 +} + +# Initialize +main $* + +# Exit normally +exit 0 diff --git a/rehlds/version/msvc/version.vcxproj b/rehlds/version/msvc/version.vcxproj new file mode 100644 index 0000000..10f353f --- /dev/null +++ b/rehlds/version/msvc/version.vcxproj @@ -0,0 +1,79 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + {6973DCA5-253C-4D84-B51E-187E035EAE06} + MakeFileProj + version + version + + + + Makefile + true + v120 + v140 + v141 + v142 + + + Makefile + false + v120 + v140 + v141 + v142 + + + + + + + + + + + + + + + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + WIN32;_DEBUG;$(NMakePreprocessorDefinitions) + echo ON +del /s "$(ProjectDir)..\appversion.h" >nul 2>&1 + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + WIN32;NDEBUG;$(NMakePreprocessorDefinitions) + echo ON +del /s "$(ProjectDir)..\appversion.h" >nul 2>&1 + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + + + + + diff --git a/rehlds/version/msvc/version.vcxproj.filters b/rehlds/version/msvc/version.vcxproj.filters new file mode 100644 index 0000000..b2ccc8c --- /dev/null +++ b/rehlds/version/msvc/version.vcxproj.filters @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rehlds/version/version.cpp b/rehlds/version/version.cpp deleted file mode 100644 index c5a6b06..0000000 --- a/rehlds/version/version.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* -* Version declaration dependency file -* -*/ - -// -// This file needed just to add the dependency and appversion.h -// -#include "precompiled.h" - diff --git a/rehlds/version/version.h b/rehlds/version/version.h new file mode 100644 index 0000000..0a1f095 --- /dev/null +++ b/rehlds/version/version.h @@ -0,0 +1,10 @@ +/* +* Version declaration dependency file +* +*/ + +#pragma once + +#define VERSION_MAJOR 3 +#define VERSION_MINOR 10 +#define VERSION_MAINTENANCE 0 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index acdb2b7..0000000 --- a/settings.gradle +++ /dev/null @@ -1,8 +0,0 @@ -rootProject.name = 'rehlds' -include 'dep/cppunitlite' -include 'dep/bzip2' -include 'rehlds' -include 'rehlds/dedicated' -include 'rehlds/filesystem/FileSystem_Stdio' -include 'rehlds/HLTV', 'rehlds/HLTV/Core', 'rehlds/HLTV/Proxy', 'rehlds/HLTV/Console', 'rehlds/HLTV/Director', 'rehlds/HLTV/DemoPlayer' -include 'flightrec/decoder_api', 'flightrec/decoder' diff --git a/shared.gradle b/shared.gradle deleted file mode 100644 index ec81f33..0000000 --- a/shared.gradle +++ /dev/null @@ -1,36 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.BinaryKind -import org.doomedsociety.gradlecpp.toolchain.icc.Icc -import org.gradle.nativeplatform.NativeBinarySpec -import org.gradle.nativeplatform.NativeExecutableBinarySpec -import org.gradle.nativeplatform.SharedLibraryBinarySpec -import org.gradle.nativeplatform.StaticLibraryBinarySpec -import org.gradle.nativeplatform.toolchain.VisualCpp - -apply from: 'shared_msvc.gradle' -apply from: 'shared_icc.gradle' -apply from: 'shared_gcc.gradle' - -rootProject.ext.createToolchainConfig = { NativeBinarySpec bin -> - BinaryKind binaryKind - if (bin instanceof NativeExecutableBinarySpec) { - binaryKind = BinaryKind.EXECUTABLE - } else if (bin instanceof SharedLibraryBinarySpec) { - binaryKind = BinaryKind.SHARED_LIBRARY - } else if (bin instanceof StaticLibraryBinarySpec) { - binaryKind = BinaryKind.STATIC_LIBRARY - } else { - throw new RuntimeException("Unknown executable kind ${bin.class.name}") - } - - boolean releaseBuild = bin.buildType.name.toLowerCase() == 'release' - - if (bin.toolChain instanceof VisualCpp) { - return rootProject.createMsvcConfig(releaseBuild, binaryKind) - } else if (bin.toolChain instanceof Icc) { - return rootProject.createIccConfig(releaseBuild, binaryKind) - } else if (bin.toolChain instanceof Gcc) { - return rootProject.createGccConfig(releaseBuild, binaryKind) - } else { - throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}") - } -} diff --git a/shared_gcc.gradle b/shared_gcc.gradle deleted file mode 100644 index 2c1d1f4..0000000 --- a/shared_gcc.gradle +++ /dev/null @@ -1,71 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.BinaryKind -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.gcc.OptimizationLevel - -rootProject.ext.createGccConfig = { boolean release, BinaryKind binKind -> - GccToolchainConfig cfg - if (release) { - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.LEVEL_3, - stackProtector: false, - //interProceduralOptimizations: true, - - noBuiltIn: true, - - //intelExtensions: false, - //asmBlocks: true, - - positionIndependentCode: false, - - extraDefines: [ - '_GLIBCXX_USE_CXX11_ABI': 0, - ] - ), - - linkerOptions: new GccToolchainConfig.LinkerOptions( - //interProceduralOptimizations: true, - stripSymbolTable: false, - staticLibGcc: false, - //staticIntel: true, - staticLibStdCpp: false, - ), - - librarianOptions: new GccToolchainConfig.LibrarianOptions( - - ) - ) - } else { - //debug - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.DISABLE, - stackProtector: true, - //interProceduralOptimizations: false, - - noBuiltIn: true, - //intelExtensions: false, - //asmBlocks: true, - - extraDefines: [ - '_GLIBCXX_USE_CXX11_ABI': 0, - ] - ), - - linkerOptions: new GccToolchainConfig.LinkerOptions( - //interProceduralOptimizations: false, - stripSymbolTable: false, - staticLibGcc: false, - //staticIntel: true, - staticLibStdCpp: false, - ), - - librarianOptions: new GccToolchainConfig.LibrarianOptions( - - ) - ) - } - - cfg.singleDefines('LINUX', '_LINUX') - return cfg -} diff --git a/shared_icc.gradle b/shared_icc.gradle deleted file mode 100644 index aa8a7d7..0000000 --- a/shared_icc.gradle +++ /dev/null @@ -1,75 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.BinaryKind -import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig -import org.doomedsociety.gradlecpp.gcc.OptimizationLevel - -rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind -> - GccToolchainConfig cfg - if (release) { - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.LEVEL_3, - stackProtector: false, - interProceduralOptimizations: true, - - noBuiltIn: true, - - intelExtensions: false, - asmBlocks: true, - - positionIndependentCode: false, - - extraDefines: [ - '_GLIBCXX_USE_CXX11_ABI': 0, - ] - ), - - linkerOptions: new GccToolchainConfig.LinkerOptions( - interProceduralOptimizations: true, - stripSymbolTable: false, - staticLibGcc: false, - staticIntel: true, - staticLibStdCpp: false, - ), - - librarianOptions: new GccToolchainConfig.LibrarianOptions( - - ) - ) - } else { - //debug - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.DISABLE, - stackProtector: true, - interProceduralOptimizations: false, - - noBuiltIn: true, - intelExtensions: false, - asmBlocks: true, - - extraDefines: [ - '_GLIBCXX_USE_CXX11_ABI': 0, - ] - ), - - linkerOptions: new GccToolchainConfig.LinkerOptions( - interProceduralOptimizations: false, - stripSymbolTable: false, - staticLibGcc: false, - staticIntel: true, - staticLibStdCpp: false, - ), - - librarianOptions: new GccToolchainConfig.LibrarianOptions( - - ) - ) - } - - // ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations - // https://software.intel.com/en-us/node/522979#GUID-99936BBA-1508-4E9F-AC09-FA98613CE2F5 - - cfg.compilerOptions.args('-fp-model=precise'); - cfg.singleDefines('LINUX', '_LINUX') - return cfg -} diff --git a/shared_msvc.gradle b/shared_msvc.gradle deleted file mode 100644 index bf8f548..0000000 --- a/shared_msvc.gradle +++ /dev/null @@ -1,140 +0,0 @@ -import org.doomedsociety.gradlecpp.cfg.BinaryKind -import org.doomedsociety.gradlecpp.msvc.CallingConvention -import org.doomedsociety.gradlecpp.msvc.CodeGenerationKind -import org.doomedsociety.gradlecpp.msvc.CppExceptions -import org.doomedsociety.gradlecpp.msvc.DebugInfoFormat -import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet -import org.doomedsociety.gradlecpp.msvc.ErrorReporting -import org.doomedsociety.gradlecpp.msvc.FloatingPointModel -import org.doomedsociety.gradlecpp.msvc.LinkTimeCodeGenKind -import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig -import org.doomedsociety.gradlecpp.msvc.OptimizationLevel -import org.doomedsociety.gradlecpp.msvc.RuntimeChecks -import org.doomedsociety.gradlecpp.msvc.WarningLevel - -rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind -> - MsvcToolchainConfig cfg - if (release) { - cfg = new MsvcToolchainConfig( - compilerOptions: new MsvcToolchainConfig.CompilerOptions( - codeGeneration: CodeGenerationKind.MULTITHREADED, - optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION, - debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, - runtimeChecks: RuntimeChecks.DEFAULT, - cppExceptions: CppExceptions.ENABLED_WITH_SEH, - warningLevel: WarningLevel.LEVEL_3, - callingConvention: CallingConvention.CDECL, - enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, - floatingPointModel: FloatingPointModel.FAST, - - enableMinimalRebuild: false, - omitFramePointers: false, - wholeProgramOptimization: true, - enabledFunctionLevelLinking: true, - enableSecurityCheck: true, - analyzeCode: false, - sdlChecks: false, - treatWarningsAsErrors: false, - treatWchartAsBuiltin: true, - forceConformanceInForLoopScope: true, - - extraDefines: [ - 'WIN32': null, - '_MBCS': null, - 'NDEBUG': null, - ] - ), - - linkerOptions: new MsvcToolchainConfig.LinkerOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG, - errorReportingMode: ErrorReporting.NO_ERROR_REPORT, - - enableIncrementalLinking: false, - eliminateUnusedRefs: true, - enableCOMDATFolding: true, - generateDebugInfo: true, - dataExecutionPrevention: true, - randomizedBaseAddress: true - ), - - librarianOptions: new MsvcToolchainConfig.LibrarianOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG - ), - - generatePdb: true - ) - } else { - //debug - cfg = new MsvcToolchainConfig( - compilerOptions: new MsvcToolchainConfig.CompilerOptions( - codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG, - optimizationLevel: OptimizationLevel.DISABLED, - debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, - runtimeChecks: RuntimeChecks.DEFAULT, - cppExceptions: CppExceptions.ENABLED_WITH_SEH, - warningLevel: WarningLevel.LEVEL_3, - callingConvention: CallingConvention.CDECL, - enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, - floatingPointModel: FloatingPointModel.FAST, - - enableMinimalRebuild: true, - omitFramePointers: false, - wholeProgramOptimization: false, - enabledFunctionLevelLinking: true, - enableSecurityCheck: true, - analyzeCode: false, - sdlChecks: false, - treatWarningsAsErrors: false, - treatWchartAsBuiltin: true, - forceConformanceInForLoopScope: true, - - extraDefines: [ - 'WIN32': null, - '_MBCS': null, - '_DEBUG': null, - ] - ), - - linkerOptions: new MsvcToolchainConfig.LinkerOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT, - errorReportingMode: ErrorReporting.NO_ERROR_REPORT, - - enableIncrementalLinking: true, - eliminateUnusedRefs: false, - enableCOMDATFolding: false, - generateDebugInfo: true, - dataExecutionPrevention: true, - randomizedBaseAddress: true - ), - - librarianOptions: new MsvcToolchainConfig.LibrarianOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG - ), - - generatePdb: true - ) - - if (binKind == BinaryKind.STATIC_LIBRARY) { - cfg.compilerConfig.extraDefines['_LIB'] = null - } - } - - // Detect and setup UCRT paths - def ucrtInfo = "getucrtinfo.bat".execute().text - def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/ - if (!m.find()) { - return cfg - } - def kitPath = m.group(1) - def ucrtVersion = m.group(2) - def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h"); - if (!ucrtCheckFile.exists()) { - return cfg - } - - cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt"; - cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86"); - - return cfg -} -