diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e62c178e..61c85856 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -5,16 +5,18 @@ on:
branches: [master]
paths-ignore:
- '**.md'
+ - '.github/**'
pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]
+ workflow_dispatch:
jobs:
windows:
name: 'Windows'
- runs-on: windows-2019
+ runs-on: windows-2025
env:
solution: 'msvc/ReGameDLL.sln'
@@ -24,6 +26,9 @@ jobs:
buildTests: 'Tests'
steps:
+ - name: Configure
+ run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
+
- name: Checkout
uses: actions/checkout@v4
with:
@@ -31,12 +36,48 @@ jobs:
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- with:
- vs-version: '16'
+
+# TODO: add support of 141_xp toolchain at VS2022+
+# - name: Install v140, v141 and v142 toolsets
+# shell: cmd
+# run: |
+# "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify ^
+# --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" ^
+# --add Microsoft.VisualStudio.Component.WindowsXP ^
+# --add Microsoft.VisualStudio.Component.VC.v140 ^
+# --add Microsoft.VisualStudio.Component.VC.v140.x86.x64 ^
+# --add Microsoft.VisualStudio.Component.VC.v140.xp ^
+# --add Microsoft.VisualStudio.Component.VC.140.CRT ^
+# --add Microsoft.VisualStudio.Component.VC.v141 ^
+# --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
+# --add Microsoft.VisualStudio.Component.VC.v141.xp ^
+# --add Microsoft.VisualStudio.Component.VC.v142 ^
+# --add Microsoft.VisualStudio.Component.VC.v142.x86.x64 ^
+# --quiet --norestart
+
+ - name: Select PlatformToolset
+ id: select_toolset
+ shell: pwsh
+ run: |
+ $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
+ $vs2019 = & $vswhere -products * -version "[16.0,17.0)" -property installationPath -latest
+ $vs2022 = & $vswhere -products * -version "[17.0,)" -property installationPath -latest
+
+ if ($vs2019) {
+ "toolset=v140_xp" >> $env:GITHUB_OUTPUT
+ Write-Host "Selected v140_xp toolset"
+ } elseif ($vs2022) {
+ "toolset=v143" >> $env:GITHUB_OUTPUT
+ Write-Host "Selected v143 toolset"
+ } else {
+ Write-Error "No suitable Visual Studio installation found"
+ exit 1
+ }
- name: Build and Run unittests
run: |
- msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
+ $toolset = '${{ steps.select_toolset.outputs.toolset }}'
+ msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
.\"msvc\Tests\mp.exe"
If ($LASTEXITCODE -ne 0 -And
$LASTEXITCODE -ne 3)
@@ -45,8 +86,13 @@ jobs:
- 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
+ $toolset = '${{ steps.select_toolset.outputs.toolset }}'
+ msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
+ msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
+ - name: Get rcedit from chocolatey
+ shell: pwsh
+ run: |
+ choco install rcedit -y
- name: Move files
run: |
@@ -57,6 +103,49 @@ jobs:
move msvc\${{ env.buildRelease }}\mp.dll publish\bin\win32\cstrike\dlls\mp.dll
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb
+ - name: Get app version
+ id: get_version
+ shell: pwsh
+ run: |
+ $versionFile = "regamedll/version/appversion.h"
+ if (-not (Test-Path $versionFile)) {
+ Write-Error "Version file not found: $versionFile"
+ exit 1
+ }
+
+ $content = Get-Content $versionFile
+ foreach ($line in $content) {
+ if ($line -match '^\s*#define\s+APP_VERSION\s+"([^"]+)"') {
+ $version = $matches[1]
+ "version=$version" >> $env:GITHUB_OUTPUT
+ Write-Host "Found version: $version"
+ exit 0
+ }
+ }
+ Write-Error "APP_VERSION not found in file"
+ exit 1
+
+ - name: Show version
+ run: echo "Version is ${{ steps.get_version.outputs.version }}"
+
+ - name: Import PFX and sign
+ if: github.event_name != 'pull_request'
+ env:
+ KEY_PFX_PASS: ${{ secrets.KEY_PFX_PASS }}
+ # https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
+ run: |
+ $pfxBase64 = "${{ secrets.KEY_PFX_B64 }}"
+ [IO.File]::WriteAllBytes("${{ github.workspace }}\signing-cert.pfx", [Convert]::FromBase64String($pfxBase64))
+ certutil -f -p "${{ secrets.KEY_PFX_PASS }}" -importPFX "${{ github.workspace }}\signing-cert.pfx"
+ & 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "Regamedll_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 /v ${{ github.workspace }}\publish\bin\win32\cstrike\dlls\mp.dll
+ Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
+ shell: "pwsh"
+
+ - name: Edit resources at windows binaries
+ run: |
+ rcedit ${{ github.workspace }}\publish\bin\win32\cstrike\dlls\mp.dll --set-version-string ProductName "Regamedll_CS - mp.dll" --set-file-version "${{ steps.get_version.outputs.version }}" --set-product-version "${{ steps.get_version.outputs.version }}" --set-version-string FileDescription "Regamedll_CS (mp.dll) - provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Regamedll_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so. Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon regamedll/msvc/icon.ico
+ shell: "pwsh"
+
- name: Deploy artifacts
uses: actions/upload-artifact@v4
with:
@@ -105,11 +194,6 @@ jobs:
container: debian:11-slim
steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- name: Install dependencies
run: |
dpkg --add-architecture i386
@@ -121,6 +205,58 @@ jobs:
git cmake rsync \
g++ gcc
+ - name: Configure
+ run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
+
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ submodules: recursive
+ fetch-depth: 0
+
+ - name: GPG Import
+ run: |
+ echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
+ echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
+
+ # Import the public key
+ gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
+ if [[ $? -ne 0 ]]; then
+ echo "Error: Failed to import the public key"
+ exit 1
+ fi
+
+ # Import the private key
+ gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
+ if [[ $? -ne 0 ]]; then
+ echo "Error: Failed to import the private key"
+ exit 2
+ fi
+
+ # Extract the fingerprint of the imported public key
+ GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
+
+ # Check if the fingerprint was extracted
+ if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
+ echo "Error: Failed to extract the fingerprint of the key"
+ exit 3
+ fi
+
+ # Set the trust level for the key
+ echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
+ if [ $? -ne 0 ]; then
+ echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
+ exit 4
+ fi
+
+ echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
+ gpg --list-keys
+
+ #export for global use
+ echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
+ shell: bash
+ if: github.event_name != 'pull_request'
+
- name: Build and Run unittests
run: |
rm -rf build && CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
@@ -217,7 +353,29 @@ jobs:
run: |
rsync -a dist/ bin/win32/cstrike
rsync -a dist/ bin/linux32/cstrike
+
+ # new runner, niw signs
+ echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
+ echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
+ gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
+ gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
+ GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
+ echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
+ echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
+
+ sign_file() {
+ local file=$1
+ gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
+ if [ $? -ne 0 ]; then
+ echo "Error: Failed to sign $file"
+ exit 2
+ fi
+ echo "$file signed successfully."
+ }
+
+ # Pack and sign final archive
7z a -tzip regamedll-bin-${{ env.APP_VERSION }}.zip bin/ cssdk/
+ sign_file "regamedll-bin-${{ env.APP_VERSION }}.zip"
- name: Publish artifacts
uses: softprops/action-gh-release@v2
@@ -228,6 +386,8 @@ jobs:
with:
files: |
*.zip
+ *.7z
+ *.asc
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}
diff --git a/LICENSE b/LICENSE
index 9cecc1d4..4fa78b54 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,21 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {one line to give the program's name and a brief idea of what it does.}
- Copyright (C) {year} {name of author}
-
- 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 3 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, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- {project} Copyright (C) {year} {fullname}
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+MIT License
+
+Copyright (c) 2015–2025 ReGameDLL_CS Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the “Software”), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/LICENSE-TRANSITION.md b/LICENSE-TRANSITION.md
new file mode 100644
index 00000000..905e4930
--- /dev/null
+++ b/LICENSE-TRANSITION.md
@@ -0,0 +1,16 @@
+# License Transition Notice
+
+ReGameDLL_CS was originally licensed under the GNU General Public License v3.0 (GPLv3).
+
+As of July 2025, the project has transitioned to the MIT License with the explicit agreement of the major contributors, including:
+
+- s1lent
+- Vaqtincha
+- In-line
+- wopox
+- WPMGPRoSToTeMa
+
+All significant contributors have agreed to this license transition.
+All previous contributions are now considered to be licensed under the MIT License unless otherwise noted.
+
+For questions, contact us via GitHub or the ReHLDS dev chat.
diff --git a/README.md b/README.md
index 7bdfc9f8..0703cff5 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,27 @@
-# ReGameDLL_CS [](https://github.com/s1lentq/ReGameDLL_CS/releases/latest)  [](http://isitmaintained.com/project/s1lentq/ReGameDLL_CS "Percentage of issues still open") [](https://www.gnu.org/licenses/gpl-3.0)
+# ReGameDLL_CS [](https://github.com/rehlds/ReGameDLL_CS/releases/latest)  [](http://isitmaintained.com/project/rehlds/ReGameDLL_CS "Percentage of issues still open") [](https://www.gnu.org/licenses/gpl-3.0)
Reverse-engineered gamedll (mp.dll / Counter-Strike)
## What is this?
-Regamedll_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so
+ReGameDLL_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so
## Goals of the project
* Provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins
+## 🛠 License
+
+ReGameDLL_CS is licensed under the [MIT License](./LICENSE).
+
+### License Transition
+> [!NOTE]
+> Originally released under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html), ReHReGameDLL_CSLDS transitioned to the MIT License in July 2025 with the agreement of the core contributors.
+> See [LICENSE-TRANSITION.md](./LICENSE-TRANSITION.md) for details.
+
## How can use it?
ReGameDLL_CS is fully compatible with official mod CS 1.6 / CZero by Valve. All you have to do is to download binaries and replace original mp.dll/cs.so
## Downloads
-* [Release builds](https://github.com/s1lentq/ReGameDLL_CS/releases)
-* [Dev builds](https://github.com/s1lentq/ReGameDLL_CS/actions/workflows/build.yml)
+* [Release builds](https://github.com/rehlds/ReGameDLL_CS/releases)
+* [Dev builds](https://github.com/rehlds/ReGameDLL_CS/actions/workflows/build.yml)
Warning! ReGameDLL_CS is not binary compatible with original hlds since it's compiled with compilers other than ones used for original mod CS.
This means that plugins that do binary code analysis (Orpheu for example) probably will not work with ReGameDLL_CS.
@@ -98,6 +107,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_ct_give_player_knife | 1 | 0 | 1 | Whether Counter-Terrorist player spawn with knife. |
| mp_ct_default_weapons_primary | "" | "" | - | The default primary (rifle) weapon that the CTs will spawn with. |
| mp_ct_default_weapons_secondary | "usp" | "" | - | The default secondary (pistol) weapon that the CTs will spawn with. |
+| mp_default_weapons_random | 0 | 0 | 1 | Randomize default weapons (if there are multiple). `0` disabled `1` enabled |
| mp_give_player_c4 | 1 | 0 | 1 | Whether this map should spawn a C4 bomb for a player or not. `0` disabled `1` enabled |
| mp_weapons_allow_map_placed | 1 | 0 | 1 | When set, map weapons (located on the floor by map) will be shown. `0` hide all map weapons. `1` enabled `NOTE`: Effect will work after round restart. |
| mp_free_armor | 0 | 0 | 2 | Give free armor on player spawn. `0` disabled `1` Give Kevlar `2` Give Kevlar + Helmet |
@@ -123,6 +133,15 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. |
| mp_vote_flags | km | 0 | - | Vote systems enabled in server. `0` voting disabled `k` votekick enabled via `vote` command `m` votemap enabled via `votemap` command |
| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. |
+| mp_flymove_method | 0 | 0 | 1 | Set the method used for flymove calculations. `0` default method `1` alternative method (more accurate) |
+| mp_stamina_restore_rate | 0 | 0.0 | - | Framerate (FPS), that used as reference when restoring stamina (fuser2) after jump. |
+| mp_logkills | 1 | 0 | 1 | Log kills. `0` disabled `1` enabled |
+| mp_jump_height | 45 | 0.0 | - | Player jump height. |
+| bot_excellent_morale | 0 | 0 | 1 | Bots always have great morale regardless of defeat or victory. |
+| mp_randomspawn | 0 | 0 | 1 | Random player spawns `0` disabled `1` enabled `NOTE`: Navigation `maps/.nav` file required |
+| mp_playerid_showhealth | 1 | 0 | 2 | Player ID display mode. `0` don't show health `1` show health for teammates only (default CS behaviour) `2` show health for all players |
+| mp_playerid_field | 3 | 0 | 3 | Player ID field display mode. `0` don't show additional information `1` show team name `2` show health percentage `3` show both team name and health percentage |
+| mp_knockback | 170 | - | - | Knockback force applied to the victim when damaged by strong weapons (e.g. `AWP`, `AK47`). Works only if not crouching, and not hit in the legs. Set to `0` to disable. |
diff --git a/build.sh b/build.sh
index 876b458d..6dbfad24 100755
--- a/build.sh
+++ b/build.sh
@@ -33,7 +33,7 @@ main()
case "$C" in
("intel"|"icc") CC=icc CXX=icpc ;;
("gcc"|"g++") CC=gcc CXX=g++ ;;
- ("clang|llvm") CC=clang CXX=clang++ ;;
+ ("clang"|"llvm") CC=clang CXX=clang++ ;;
*)
;;
esac
diff --git a/dist/game.cfg b/dist/game.cfg
index c5dad01c..f566ee9b 100644
--- a/dist/game.cfg
+++ b/dist/game.cfg
@@ -466,6 +466,13 @@ mp_ct_default_weapons_primary ""
// Default value: "usp"
mp_ct_default_weapons_secondary "usp"
+// Randomize default weapons (if there are multiple)
+// 0 - disabled (default behaviour)
+// 1 - enabled
+//
+// Default value: "0"
+mp_default_weapons_random "0"
+
// Give the player free armor on player spawn
// 0 - No armor (default behavior)
// 1 - Give Kevlar
@@ -521,7 +528,7 @@ mp_give_c4_frags "3"
// Default value: "1.0"
mp_hostages_rescued_ratio "1.0"
-// Legacy func_vehicle behavior when blocked by another entity.
+// Legacy func_vehicle behavior when blocked by another entity.
// New one is more useful for playing multiplayer.
//
// 0 - New behavior
@@ -620,3 +627,63 @@ mp_vote_flags "km"
//
// Default value: "180"
mp_votemap_min_time "180"
+
+// Set the method used for flymove calculations.
+// 0 - default method
+// 1 - alternative method (more accurate)
+//
+// Default value: "0"
+mp_flymove_method "0"
+
+// Framerate (FPS), that is used as a reference when restoring stamina (fuser2) after a jump.
+// 0 - disabled
+//
+// Default value: "0"
+mp_stamina_restore_rate "0"
+
+// Player jump height
+//
+// Default value: "45"
+mp_jump_height "45"
+
+// Bots always have great morale regardless of defeat or victory.
+// 0 - disabled (default behaviour)
+// 1 - enabled
+//
+// Default value: "0"
+bot_excellent_morale "0"
+
+// Random player spawns
+// 0 - disabled (default behaviour)
+// 1 - enabled
+//
+// NOTE: Navigation "maps/.nav" file required
+//
+// Default value: "0"
+mp_randomspawn "0"
+
+// Player ID display mode
+//
+// 0 - don't show health (default behaviour)
+// 1 - show health for teammates only (default CS behaviour)
+// 2 - show health for all players
+//
+// Default value: "1"
+mp_playerid_showhealth "1"
+
+// Player ID field display mode
+//
+// 0 - don't show additional information
+// 1 - show team name
+// 2 - show health percentage
+// 3 - show both team name and health percentage
+//
+// Default value: "3"
+mp_playerid_field "3"
+
+// Knockback force applied to the victim when damaged by strong weapons (e.g. AWP, AK47).
+// Works only if not crouching, and not hit in the legs.
+// Set to "0" to disable.
+//
+// Default: "170"
+mp_knockback "170"
diff --git a/regamedll/CMakeLists.txt b/regamedll/CMakeLists.txt
index bc0a990e..c1a13f9b 100644
--- a/regamedll/CMakeLists.txt
+++ b/regamedll/CMakeLists.txt
@@ -20,20 +20,47 @@
cmake_minimum_required(VERSION 3.1)
project(regamedll CXX)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
option(DEBUG "Build with debug information." OFF)
option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)
option(USE_LEGACY_LIBC "Enables linking against legacy libc (<= 2.15) for compat with older distros (Debian 8/Ubuntu 16.04/Centos 7)." OFF)
+option(XASH_COMPAT "Enable Xash3D FWGS compatiblity (support for it's 64-bit ABI support and crossplatform library suffix)")
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 "")
+if (NOT XASH_COMPAT)
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
+ set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
+endif()
-set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE")
-set(LINK_FLAGS "-m32 -s")
-set(LINK_LIBS dl aelf32)
+set(COMPILE_FLAGS "-U_FORTIFY_SOURCE")
+set(LINK_LIBS dl)
+
+# do not strip debuginfo during link
+if (NOT DEBUG)
+ set(LINK_FLAGS "-s")
+endif()
+
+# add -m32 flag only on 64-bit systems, if building for 64-bit wasn't enabled with XASH_COMPAT
+if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+ if (XASH_COMPAT)
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -DXASH_64BIT")
+ else()
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -m32")
+ set(LINK_FLAGS "${LINK_FLAGS} -m32")
+ list(APPEND LINK_LIBS aelf32)
+ set(CMAKE_SIZEOF_VOID_P 4)
+ endif()
+endif()
+
+if(XASH_COMPAT)
+ # Xash3D FWGS Library Naming Scheme compliance
+ # see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/extensions/library-naming.md
+ include(LibraryNaming)
+endif()
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-builtin -Wno-unknown-pragmas")
@@ -47,7 +74,7 @@ else()
endif()
# Check Intel C++ compiler
-if ("$ENV{CXX}" MATCHES "icpc")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
#
# -fp-model=precise
# ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations
@@ -75,11 +102,15 @@ if ("$ENV{CXX}" MATCHES "icpc")
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.
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (NOT XASH_COMPAT OR XASH_AMD64 OR XASH_X86)
+ # 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")
+ endif()
+
set(COMPILE_FLAGS "${COMPILE_FLAGS} \
- -mtune=generic -msse3\
-fpermissive -fno-sized-deallocation\
-Wno-delete-non-virtual-dtor -Wno-invalid-offsetof\
-Wno-unused-variable -Wno-unused-value -Wno-unused-result -Wno-unused-function\
@@ -87,7 +118,7 @@ else()
-Wno-sign-compare -Wno-format -Wno-ignored-attributes -Wno-strict-aliasing")
# Check Clang compiler
- if ("$ENV{CXX}" MATCHES "clang")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMPILE_FLAGS "${COMPILE_FLAGS} \
-Wno-unused-local-typedef\
-Wno-unused-private-field\
@@ -102,16 +133,11 @@ 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 -Wno-class-memaccess")
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation -Wno-class-memaccess -fcf-protection=none")
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\"")
@@ -378,14 +404,36 @@ if (USE_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(LINK_FLAGS "${LINK_FLAGS} -Wl,-rpath,'$ORIGIN/.'")
+
+if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(LINK_FLAGS "${LINK_FLAGS} -L${PROJECT_SOURCE_DIR}/lib/linux32")
+endif()
set_target_properties(regamedll PROPERTIES
- OUTPUT_NAME cs
- PREFIX ""
COMPILE_FLAGS ${COMPILE_FLAGS}
LINK_FLAGS ${LINK_FLAGS}
- POSITION_INDEPENDENT_CODE OFF
)
+
+if (XASH_COMPAT)
+ if (CMAKE_SYSTEM_NAME STREQUAL "Android")
+ set_target_properties(regamedll PROPERTIES
+ OUTPUT_NAME server)
+ else()
+ set_target_properties(regamedll PROPERTIES
+ PREFIX ""
+ OUTPUT_NAME cs${POSTFIX})
+ endif()
+else()
+ set_target_properties(regamedll PROPERTIES
+ OUTPUT_NAME cs
+ PREFIX ""
+ POSITION_INDEPENDENT_CODE OFF)
+endif()
+
+install(TARGETS regamedll
+ RUNTIME DESTINATION "cstrike/dlls/"
+ LIBRARY DESTINATION "cstrike/dlls/"
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
diff --git a/regamedll/cmake/LibraryNaming.cmake b/regamedll/cmake/LibraryNaming.cmake
new file mode 100644
index 00000000..a20529ae
--- /dev/null
+++ b/regamedll/cmake/LibraryNaming.cmake
@@ -0,0 +1,198 @@
+include(CheckSymbolExists)
+
+macro(check_build_target symbol)
+ check_symbol_exists(${symbol} "build.h" ${symbol})
+endmacro()
+
+macro(check_group_build_target symbol group)
+ if(NOT ${group})
+ check_build_target(${symbol})
+ if(${symbol})
+ set(${group} TRUE)
+ endif()
+ else()
+ set(${symbol} FALSE)
+ endif()
+endmacro()
+
+# So there is a problem:
+# 1. Number of these symbols only grows, as we support more and more ports
+# 2. CMake was written by morons and can't check these symbols in parallel
+# 3. MSVC is very slow at everything (startup, parsing, generating error)
+
+# Solution: group these symbols and set variable if one of them was found
+# this way we can reorder to reorder them by most common configurations
+# but we can't generate this list anymore! ... OR IS IT ???
+
+# Well, after reordering positions in engine's buildenums.h, we can partially autogenerate this list!
+# echo "check_build_target(XASH_64BIT)"
+# grep "#define PLATFORM" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 " XASH_PLATFORM)" }'
+# grep "#define ARCHITECTURE" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 " XASH_ARCHITECTURE)"
+# grep "#define ENDIAN" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 "_ENDIAN XASH_ENDIANNESS)"}'
+# echo "if(XASH_ARM)"
+# grep '^#undef XASH' build.h | grep "XASH_ARM[v_]" | awk '{ print "check_build_target(" $2 ")"}'
+# echo "endif()"
+# echo "if(XASH_RISCV)"
+# grep '^#undef XASH' build.h | grep "XASH_RISCV_" | awk '{ print "check_build_target(" $2 ")"}'
+# echo "endif()"
+
+# NOTE: Android must have priority over Linux to work correctly!
+
+set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/public/")
+check_build_target(XASH_64BIT)
+check_group_build_target(XASH_WIN32 XASH_PLATFORM)
+check_group_build_target(XASH_ANDROID XASH_PLATFORM)
+check_group_build_target(XASH_LINUX XASH_PLATFORM)
+check_group_build_target(XASH_FREEBSD XASH_PLATFORM)
+check_group_build_target(XASH_APPLE XASH_PLATFORM)
+check_group_build_target(XASH_NETBSD XASH_PLATFORM)
+check_group_build_target(XASH_OPENBSD XASH_PLATFORM)
+check_group_build_target(XASH_EMSCRIPTEN XASH_PLATFORM)
+check_group_build_target(XASH_DOS4GW XASH_PLATFORM)
+check_group_build_target(XASH_HAIKU XASH_PLATFORM)
+check_group_build_target(XASH_SERENITY XASH_PLATFORM)
+check_group_build_target(XASH_IRIX XASH_PLATFORM)
+check_group_build_target(XASH_NSWITCH XASH_PLATFORM)
+check_group_build_target(XASH_PSVITA XASH_PLATFORM)
+check_group_build_target(XASH_WASI XASH_PLATFORM)
+check_group_build_target(XASH_SUNOS XASH_PLATFORM)
+check_group_build_target(XASH_X86 XASH_ARCHITECTURE)
+check_group_build_target(XASH_AMD64 XASH_ARCHITECTURE)
+check_group_build_target(XASH_ARM XASH_ARCHITECTURE)
+check_group_build_target(XASH_MIPS XASH_ARCHITECTURE)
+check_group_build_target(XASH_PPC XASH_ARCHITECTURE)
+check_group_build_target(XASH_JS XASH_ARCHITECTURE)
+check_group_build_target(XASH_E2K XASH_ARCHITECTURE)
+check_group_build_target(XASH_RISCV XASH_ARCHITECTURE)
+check_group_build_target(XASH_LITTLE_ENDIAN XASH_ENDIANNESS)
+check_group_build_target(XASH_BIG_ENDIAN XASH_ENDIANNESS)
+if(XASH_ARM)
+check_build_target(XASH_ARM_HARDFP)
+check_build_target(XASH_ARM_SOFTFP)
+check_build_target(XASH_ARMv4)
+check_build_target(XASH_ARMv5)
+check_build_target(XASH_ARMv6)
+check_build_target(XASH_ARMv7)
+check_build_target(XASH_ARMv8)
+endif()
+if(XASH_RISCV)
+check_build_target(XASH_RISCV_DOUBLEFP)
+check_build_target(XASH_RISCV_SINGLEFP)
+check_build_target(XASH_RISCV_SOFTFP)
+endif()
+unset(CMAKE_REQUIRED_INCLUDES)
+
+# engine/common/build.c
+if(XASH_ANDROID)
+ set(BUILDOS "android")
+elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE)
+ set(BUILDOS "") # no prefix for default OS
+elseif(XASH_FREEBSD)
+ set(BUILDOS "freebsd")
+elseif(XASH_NETBSD)
+ set(BUILDOS "netbsd")
+elseif(XASH_OPENBSD)
+ set(BUILDOS "openbsd")
+elseif(XASH_EMSCRIPTEN)
+ set(BUILDOS "emscripten")
+elseif(XASH_DOS4GW)
+ set(BUILDOS "DOS4GW")
+elseif(XASH_HAIKU)
+ set(BUILDOS "haiku")
+elseif(XASH_SERENITY)
+ set(BUILDOS "serenityos")
+elseif(XASH_NSWITCH)
+ set(BUILDOS "nswitch")
+elseif(XASH_PSVITA)
+ set(BUILDOS "psvita")
+elseif(XASH_IRIX)
+ set(BUILDOS "irix")
+elseif(XASH_WASI)
+ set(BUILDOS "wasi")
+elseif(XASH_SUNOS)
+ set(BUILDOS "sunos")
+else()
+ message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug")
+endif()
+
+if(XASH_AMD64)
+ set(BUILDARCH "amd64")
+elseif(XASH_X86)
+ if(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE)
+ set(BUILDARCH "") # no prefix for default OS
+ else()
+ set(BUILDARCH "i386")
+ endif()
+elseif(XASH_ARM AND XASH_64BIT)
+ set(BUILDARCH "arm64")
+elseif(XASH_ARM)
+ set(BUILDARCH "armv")
+ if(XASH_ARMv8)
+ set(BUILDARCH "${BUILDARCH}8_32")
+ elseif(XASH_ARMv7)
+ set(BUILDARCH "${BUILDARCH}7")
+ elseif(XASH_ARMv6)
+ set(BUILDARCH "${BUILDARCH}6")
+ elseif(XASH_ARMv5)
+ set(BUILDARCH "${BUILDARCH}5")
+ elseif(XASH_ARMv4)
+ set(BUILDARCH "${BUILDARCH}4")
+ else()
+ message(SEND_ERROR "Unknown ARM")
+ endif()
+
+ if(XASH_ARM_HARDFP)
+ set(BUILDARCH "${BUILDARCH}hf")
+ else()
+ set(BUILDARCH "${BUILDARCH}l")
+ endif()
+elseif(XASH_MIPS)
+ set(BUILDARCH "mips")
+ if(XASH_64BIT)
+ set(BUILDARCH "${BUILDARCH}64")
+ endif()
+
+ if(XASH_LITTLE_ENDIAN)
+ set(BUILDARCH "${BUILDARCH}el")
+ endif()
+elseif(XASH_RISCV)
+ set(BUILDARCH "riscv")
+ if(XASH_64BIT)
+ set(BUILDARCH "${BUILDARCH}64")
+ else()
+ set(BUILDARCH "${BUILDARCH}32")
+ endif()
+
+ if(XASH_RISCV_DOUBLEFP)
+ set(BUILDARCH "${BUILDARCH}d")
+ elseif(XASH_RISCV_SINGLEFP)
+ set(BUILDARCH "${BUILDARCH}f")
+ endif()
+elseif(XASH_JS)
+ set(BUILDARCH "javascript")
+elseif(XASH_E2K)
+ set(BUILDARCH "e2k")
+elseif(XASH_PPC)
+ set(BUILDARCH "ppc")
+ if(XASH_64BIT)
+ set(BUILDARCH "${BUILDARCH}64")
+ endif()
+
+ if(XASH_LITTLE_ENDIAN)
+ set(BUILDARCH "${BUILDARCH}el")
+ endif()
+else()
+ message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug")
+endif()
+
+if(BUILDOS STREQUAL "android")
+ set(POSTFIX "") # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming
+elseif(BUILDOS AND BUILDARCH)
+ set(POSTFIX "_${BUILDOS}_${BUILDARCH}")
+elseif(BUILDARCH)
+ set(POSTFIX "_${BUILDARCH}")
+else()
+ set(POSTFIX "")
+endif()
+
+message(STATUS "Library postfix: " ${POSTFIX})
diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp
index 41175c83..55da8ae3 100644
--- a/regamedll/dlls/API/CAPI_Impl.cpp
+++ b/regamedll/dlls/API/CAPI_Impl.cpp
@@ -336,6 +336,8 @@ GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage);
GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);
GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think);
GAMEHOOK_REGISTRY(CBasePlayer_RemoveAllItems);
+GAMEHOOK_REGISTRY(CBasePlayer_UpdateStatusBar);
+GAMEHOOK_REGISTRY(CBasePlayer_TakeDamageImpulse);
int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h
index 2635be5b..727fdf9e 100644
--- a/regamedll/dlls/API/CAPI_Impl.h
+++ b/regamedll/dlls/API/CAPI_Impl.h
@@ -749,6 +749,14 @@ typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBase
typedef IHookChainClassImpl CReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_RemoveAllItems;
+// CBasePlayer::UpdateStatusBar hook
+typedef IHookChainClassImpl CReGameHook_CBasePlayer_UpdateStatusBar;
+typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_UpdateStatusBar;
+
+// CBasePlayer::TakeDamageImpulse hook
+typedef IHookChainClassImpl CReGameHook_CBasePlayer_TakeDamageImpulse;
+typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_TakeDamageImpulse;
+
class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
@@ -910,6 +918,8 @@ public:
CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink;
CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think;
CReGameHookRegistry_CBasePlayer_RemoveAllItems m_CBasePlayer_RemoveAllItems;
+ CReGameHookRegistry_CBasePlayer_UpdateStatusBar m_CBasePlayer_UpdateStatusBar;
+ CReGameHookRegistry_CBasePlayer_TakeDamageImpulse m_CBasePlayer_TakeDamageImpulse;
public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
@@ -1070,6 +1080,8 @@ public:
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems();
+ virtual IReGameHookRegistry_CBasePlayer_UpdateStatusBar *CBasePlayer_UpdateStatusBar();
+ virtual IReGameHookRegistry_CBasePlayer_TakeDamageImpulse *CBasePlayer_TakeDamageImpulse();
};
extern CReGameHookchains g_ReGameHookchains;
diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp
index 8ebf7930..cab27a47 100644
--- a/regamedll/dlls/API/CSPlayer.cpp
+++ b/regamedll/dlls/API/CSPlayer.cpp
@@ -412,6 +412,11 @@ EXT_FUNC void CCSPlayer::Observer_SetMode(int iMode)
BasePlayer()->Observer_SetMode(iMode);
}
+EXT_FUNC void CCSPlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
+{
+ BasePlayer()->Observer_FindNextPlayer(bReverse, name);
+}
+
EXT_FUNC bool CCSPlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot)
{
return BasePlayer()->SelectSpawnSpot(pEntClassName, pSpot);
@@ -534,6 +539,11 @@ EXT_FUNC bool CCSPlayer::CheckActivityInGame()
return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f);
}
+EXT_FUNC void CCSPlayer::TakeDamageImpulse(CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier)
+{
+ BasePlayer()->TakeDamageImpulse(pAttacker, flKnockbackForce, flVelModifier);
+}
+
void CCSPlayer::ResetVars()
{
m_szModel[0] = '\0';
diff --git a/regamedll/dlls/animation.cpp b/regamedll/dlls/animation.cpp
index 7d5df6f0..fbf6a1bb 100644
--- a/regamedll/dlls/animation.cpp
+++ b/regamedll/dlls/animation.cpp
@@ -547,7 +547,9 @@ void AngleQuaternion(vec_t *angles, vec_t *quaternion)
{
static const ALIGN16_BEG size_t ps_signmask[4] ALIGN16_END = { 0x80000000, 0, 0x80000000, 0 };
- __m128 a = _mm_loadu_ps(angles);
+ vec4_t _ps_angles = { angles[0], angles[1], angles[2], 0.0f };
+
+ __m128 a = _mm_loadu_ps(_ps_angles);
a = _mm_mul_ps(a, _mm_load_ps(_ps_0p5)); //a *= 0.5
__m128 s, c;
sincos_ps(a, &s, &c);
diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp
index dd85448c..2302e461 100644
--- a/regamedll/dlls/bot/cs_bot.cpp
+++ b/regamedll/dlls/bot/cs_bot.cpp
@@ -900,3 +900,129 @@ float CCSBot::GetRangeToFarthestEscortedHostage() const
return away.m_farRange;
}
+
+// Remove all occurrences of a given area from the path list
+void CCSBot::RemovePath(CNavArea *area)
+{
+ int i = 0;
+ while (i < m_pathLength)
+ {
+ if (m_path[i].area == area)
+ {
+ // If this area is linked to a ladder, clear the reference
+ if (m_path[i].ladder == m_pathLadder)
+ m_pathLadder = nullptr;
+
+ m_pathLength--;
+
+ // adjust the current path index if the removed element is being used
+ if (i == m_pathIndex)
+ {
+ if (i > 0)
+ m_pathIndex = i - 1;
+ else
+ m_pathIndex = 0;
+ }
+
+ if (m_pathLength != i)
+ Q_memmove(&m_path[i], &m_path[i + 1], (m_pathLength - i) * sizeof(m_path[0]));
+
+ // clear the slot
+ Q_memset(&m_path[m_pathLength], 0, sizeof(m_path[m_pathLength]));
+ }
+ else
+ {
+ i++;
+ }
+ }
+}
+
+// Remove a hiding spot from the checked spots list
+void CCSBot::RemoveHidingSpot(HidingSpot *spot)
+{
+ int i = 0;
+ while (i < m_checkedHidingSpotCount)
+ {
+ if (m_checkedHidingSpot[i].spot == spot)
+ {
+ m_checkedHidingSpotCount--;
+
+ if (m_checkedHidingSpotCount != i)
+ Q_memmove(&m_checkedHidingSpot[i], &m_checkedHidingSpot[i + 1], (m_checkedHidingSpotCount - i) * sizeof(m_checkedHidingSpot[0]));
+
+ // clear the slot
+ Q_memset(&m_checkedHidingSpot[m_checkedHidingSpotCount], 0, sizeof(m_checkedHidingSpot[m_checkedHidingSpotCount]));
+ }
+ else
+ {
+ i++;
+ }
+ }
+}
+
+// Handle navigation-related cleanup when a nav area, spot, or encounter is destroyed
+void CCSBot::OnDestroyNavDataNotify(NavNotifyDestroyType navNotifyType, void *dead)
+{
+ switch (navNotifyType)
+ {
+ case NAV_NOTIFY_DESTROY_AREA:
+ {
+ CNavArea *area = static_cast(dead);
+
+ // If the destroyed area was linked to a spot encounter, clear it
+ if (m_spotEncounter)
+ {
+ if (m_spotEncounter->from.area == area || m_spotEncounter->to.area == area)
+ m_spotEncounter = nullptr;
+ }
+
+ RemovePath(area);
+
+ // Invalidate any references to the destroyed area
+
+ if (m_noiseArea == area)
+ m_noiseArea = nullptr;
+
+ if (m_currentArea == area)
+ m_currentArea = nullptr;
+
+ if (m_lastKnownArea == area)
+ m_lastKnownArea = nullptr;
+
+ if (m_hideState.GetSearchArea() == area)
+ m_hideState.SetSearchArea(nullptr);
+
+ if (m_huntState.GetHuntArea() == area)
+ m_huntState.ClearHuntArea();
+
+ break;
+ }
+ case NAV_NOTIFY_DESTROY_SPOT_ENCOUNTER:
+ {
+ CNavArea *area = static_cast(dead);
+
+ // Remove the encounter if it references the destroyed area
+ if (m_spotEncounter && area->HasSpotEncounter(m_spotEncounter))
+ m_spotEncounter = nullptr;
+
+ break;
+ }
+ case NAV_NOTIFY_DESTROY_SPOT:
+ {
+ HidingSpot *spot = static_cast(dead);
+
+ // Remove the destroyed hiding spot from the spot order list
+ if (m_spotEncounter)
+ {
+ SpotOrderList &spotOrderList = m_spotEncounter->spotList;
+ spotOrderList.erase(std::remove_if(spotOrderList.begin(), spotOrderList.end(), [&](SpotOrder &spotOrder) {
+ return spotOrder.spot == spot;
+ }
+ ), spotOrderList.end());
+ }
+
+ RemoveHidingSpot(spot);
+ break;
+ }
+ }
+}
diff --git a/regamedll/dlls/bot/cs_bot.h b/regamedll/dlls/bot/cs_bot.h
index 9670744f..0ba29985 100644
--- a/regamedll/dlls/bot/cs_bot.h
+++ b/regamedll/dlls/bot/cs_bot.h
@@ -71,6 +71,7 @@ public:
virtual const char *GetName() const { return "Hunt"; }
void ClearHuntArea() { m_huntArea = nullptr; }
+ CNavArea *GetHuntArea() { return m_huntArea; }
private:
CNavArea *m_huntArea;
@@ -204,6 +205,7 @@ public:
const Vector &GetHidingSpot() const { return m_hidingSpot; }
void SetSearchArea(CNavArea *area) { m_searchFromArea = area; }
+ CNavArea *GetSearchArea() { return m_searchFromArea; }
void SetSearchRange(float range) { m_range = range; }
void SetDuration(float time) { m_duration = time; }
@@ -533,12 +535,21 @@ public:
bool IsAwareOfEnemyDeath() const; // return true if we *noticed* that our enemy died
int GetLastVictimID() const; // return the ID (entindex) of the last victim we killed, or zero
+#ifdef REGAMEDLL_ADD
+ bool CanSeeSniper(void) const; ///< return true if we can see an enemy sniper
+ bool HasSeenSniperRecently(void) const; ///< return true if we have seen a sniper recently
+#endif
+
// navigation
bool HasPath() const;
void DestroyPath();
float GetFeetZ() const; // return Z of bottom of feet
+ void OnDestroyNavDataNotify(NavNotifyDestroyType navNotifyType, void *dead);
+ void RemovePath(CNavArea *area);
+ void RemoveHidingSpot(HidingSpot *spot);
+
enum PathResult
{
PROGRESSING, // we are moving along the path
@@ -921,6 +932,11 @@ private:
float m_fireWeaponTimestamp;
+#ifdef REGAMEDLL_ADD
+ bool m_isEnemySniperVisible; ///< do we see an enemy sniper right now
+ CountdownTimer m_sawEnemySniperTimer; ///< tracking time since saw enemy sniper
+#endif
+
// reaction time system
enum { MAX_ENEMY_QUEUE = 20 };
struct ReactionState
@@ -1109,6 +1125,11 @@ inline bool CCSBot::IsAtBombsite()
inline CCSBot::MoraleType CCSBot::GetMorale() const
{
+#ifdef REGAMEDLL_ADD
+ if (cv_bot_excellent_morale.value != 0.0f)
+ return EXCELLENT;
+#endif
+
return m_morale;
}
@@ -1250,6 +1271,18 @@ inline int CCSBot::GetLastVictimID() const
return m_lastVictimID;
}
+#ifdef REGAMEDLL_ADD
+inline bool CCSBot::CanSeeSniper(void) const
+{
+ return m_isEnemySniperVisible;
+}
+
+inline bool CCSBot::HasSeenSniperRecently(void) const
+{
+ return !m_sawEnemySniperTimer.IsElapsed();
+}
+#endif
+
inline bool CCSBot::HasPath() const
{
return m_pathLength != 0;
diff --git a/regamedll/dlls/bot/cs_bot_chatter.cpp b/regamedll/dlls/bot/cs_bot_chatter.cpp
index f58759fe..d48898ae 100644
--- a/regamedll/dlls/bot/cs_bot_chatter.cpp
+++ b/regamedll/dlls/bot/cs_bot_chatter.cpp
@@ -246,6 +246,17 @@ void BotHostageBeingTakenMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) con
pReceiver->GetChatter()->Say("Affirmative");
}
+#ifdef REGAMEDLL_ADD
+//---------------------------------------------------------------------------------------------------------------
+/**
+ * A teammate warned about snipers, so we shouldn't warn again for awhile
+ */
+void BotWarnSniperMeme::Interpret(CCSBot* sender, CCSBot* receiver) const
+{
+ receiver->GetChatter()->FriendSpottedSniper();
+}
+#endif
+
BotSpeakable::BotSpeakable()
{
m_phrase = nullptr;
@@ -1270,6 +1281,9 @@ void BotChatterInterface::Reset()
m_planInterval.Invalidate();
m_encourageTimer.Invalidate();
m_escortingHostageTimer.Invalidate();
+#ifdef REGAMEDLL_ADD
+ m_warnSniperTimer.Invalidate();
+#endif
}
// Register a statement for speaking
@@ -1626,6 +1640,42 @@ void BotChatterInterface::EnemySpotted()
AddStatement(say);
}
+#ifdef REGAMEDLL_ADD
+//---------------------------------------------------------------------------------------------------------------
+/**
+ * If a friend warned of snipers, don't warn again for awhile
+ */
+void BotChatterInterface::FriendSpottedSniper(void)
+{
+ m_warnSniperTimer.Start(60.0f);
+}
+
+//---------------------------------------------------------------------------------------------------------------
+/**
+ * Warn of an enemy sniper
+ */
+void BotChatterInterface::SpottedSniper(void)
+{
+ if (!m_warnSniperTimer.IsElapsed())
+ {
+ return;
+ }
+
+ if (m_me->GetFriendsRemaining() == 0)
+ {
+ // no-one to warn
+ return;
+ }
+
+ BotStatement* say = new BotStatement(this, REPORT_INFORMATION, 10.0f);
+
+ say->AppendPhrase(TheBotPhrases->GetPhrase("SniperWarning"));
+ say->AttachMeme(new BotWarnSniperMeme());
+
+ AddStatement(say);
+}
+#endif
+
NOXREF void BotChatterInterface::Clear(Place place)
{
BotStatement *say = new BotStatement(this, REPORT_INFORMATION, 10.0f);
diff --git a/regamedll/dlls/bot/cs_bot_chatter.h b/regamedll/dlls/bot/cs_bot_chatter.h
index 4a4591cf..8d3a5baa 100644
--- a/regamedll/dlls/bot/cs_bot_chatter.h
+++ b/regamedll/dlls/bot/cs_bot_chatter.h
@@ -140,6 +140,14 @@ public:
virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
};
+#ifdef REGAMEDLL_ADD
+class BotWarnSniperMeme : public BotMeme
+{
+public:
+ virtual void Interpret(CCSBot* sender, CCSBot* receiver) const; ///< cause the given bot to act on this meme
+};
+#endif
+
enum BotStatementType
{
REPORT_VISIBLE_ENEMIES,
@@ -531,6 +539,10 @@ public:
void KilledFriend();
void FriendlyFire();
+#ifdef REGAMEDLL_ADD
+ void SpottedSniper(void);
+ void FriendSpottedSniper(void);
+#endif
bool SeesAtLeastOneEnemy() const { return m_seeAtLeastOneEnemy; }
private:
@@ -557,6 +569,9 @@ private:
CountdownTimer m_spottedLooseBombTimer;
CountdownTimer m_heardNoiseTimer;
CountdownTimer m_escortingHostageTimer;
+#ifdef REGAMEDLL_ADD
+ CountdownTimer m_warnSniperTimer;
+#endif
};
inline BotChatterInterface::VerbosityType BotChatterInterface::GetVerbosity() const
diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp
index 665b3c33..2db6b02d 100644
--- a/regamedll/dlls/bot/cs_bot_init.cpp
+++ b/regamedll/dlls/bot/cs_bot_init.cpp
@@ -65,6 +65,7 @@ cvar_t cv_bot_join_delay = { "bot_join_delay", "0", FCVAR_SERVER, 0.
cvar_t cv_bot_freeze = { "bot_freeze", "0", 0, 0.0f, nullptr };
cvar_t cv_bot_mimic = { "bot_mimic", "0", 0, 0.0f, nullptr };
cvar_t cv_bot_mimic_yaw_offset = { "bot_mimic_yaw_offset", "0", 0, 0.0f, nullptr };
+cvar_t cv_bot_excellent_morale = { "bot_excellent_morale", "0", 0, 0.0f, nullptr };
#else
// Migrated to bot_quota_mode, use "match"
cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr };
@@ -136,6 +137,7 @@ void Bot_RegisterCVars()
CVAR_REGISTER(&cv_bot_freeze);
CVAR_REGISTER(&cv_bot_mimic);
CVAR_REGISTER(&cv_bot_mimic_yaw_offset);
+ CVAR_REGISTER(&cv_bot_excellent_morale);
#endif
}
@@ -194,6 +196,11 @@ void CCSBot::ResetValues()
m_currentArea = nullptr;
m_lastKnownArea = nullptr;
+#ifdef REGAMEDLL_ADD
+ m_isEnemySniperVisible = false;
+ m_sawEnemySniperTimer.Invalidate();
+#endif
+
m_avoidFriendTimer.Invalidate();
m_isFriendInTheWay = false;
m_isWaitingBehindFriend = false;
@@ -330,7 +337,7 @@ void CCSBot::ResetValues()
// NOTE: For some reason, this can be called twice when a bot is added.
void CCSBot::SpawnBot()
{
- TheCSBots()->ValidateMapData();
+ TheCSBots()->LoadNavigationMap();
ResetValues();
Q_strlcpy(m_name, STRING(pev->netname));
diff --git a/regamedll/dlls/bot/cs_bot_init.h b/regamedll/dlls/bot/cs_bot_init.h
index b50e020c..691c518f 100644
--- a/regamedll/dlls/bot/cs_bot_init.h
+++ b/regamedll/dlls/bot/cs_bot_init.h
@@ -65,6 +65,7 @@ extern cvar_t cv_bot_join_delay;
extern cvar_t cv_bot_freeze;
extern cvar_t cv_bot_mimic;
extern cvar_t cv_bot_mimic_yaw_offset;
+extern cvar_t cv_bot_excellent_morale;
#else
extern cvar_t cv_bot_quota_match;
#endif
diff --git a/regamedll/dlls/bot/cs_bot_learn.cpp b/regamedll/dlls/bot/cs_bot_learn.cpp
index 3cf041e3..e68a77a5 100644
--- a/regamedll/dlls/bot/cs_bot_learn.cpp
+++ b/regamedll/dlls/bot/cs_bot_learn.cpp
@@ -477,31 +477,24 @@ void CCSBot::StartSaveProcess()
void CCSBot::UpdateSaveProcess()
{
- char msg[256];
- char cmd[128];
-
char gd[64]{};
GET_GAME_DIR(gd);
char filename[MAX_OSPATH];
Q_snprintf(filename, sizeof(filename), "%s\\%s", gd, TheBots->GetNavMapFilename());
-
- HintMessageToAllPlayers("Saving...");
SaveNavigationMap(filename);
+ char msg[256]{};
Q_snprintf(msg, sizeof(msg), "Navigation file '%s' saved.", filename);
HintMessageToAllPlayers(msg);
+ CONSOLE_ECHO("%s\n", msg);
hideProgressMeter();
StartNormalProcess();
-#ifndef REGAMEDLL_FIXES
- Q_snprintf(cmd, sizeof(cmd), "map %s\n", STRING(gpGlobals->mapname));
-#else
- Q_snprintf(cmd, sizeof(cmd), "changelevel %s\n", STRING(gpGlobals->mapname));
-#endif
-
- SERVER_COMMAND(cmd);
+ // tell bot manager that the analysis is completed
+ if (TheCSBots())
+ TheCSBots()->AnalysisCompleted();
}
void CCSBot::StartNormalProcess()
diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp
index a5be7342..8c7c7a1f 100644
--- a/regamedll/dlls/bot/cs_bot_manager.cpp
+++ b/regamedll/dlls/bot/cs_bot_manager.cpp
@@ -231,13 +231,12 @@ bool CCSBotManager::IsOnOffense(CBasePlayer *pPlayer) const
// Invoked when a map has just been loaded
void CCSBotManager::ServerActivate()
{
- DestroyNavigationMap();
m_isMapDataLoaded = false;
m_zoneCount = 0;
m_gameScenario = SCENARIO_DEATHMATCH;
- ValidateMapData();
+ LoadNavigationMap();
RestartRound();
m_isLearningMap = false;
@@ -591,7 +590,8 @@ void CCSBotManager::ServerCommand(const char *pcmd)
}
else if (FStrEq(pcmd, "bot_nav_load"))
{
- ValidateMapData();
+ m_isMapDataLoaded = false; // force nav reload
+ LoadNavigationMap();
}
else if (FStrEq(pcmd, "bot_nav_use_place"))
{
@@ -1144,22 +1144,232 @@ private:
CCSBotManager::Zone *m_zone;
};
-// Search the map entities to determine the game scenario and define important zones.
-void CCSBotManager::ValidateMapData()
+LINK_ENTITY_TO_CLASS(info_spawn_point, CPointEntity, CCSPointEntity)
+
+inline bool IsFreeSpace(Vector vecOrigin, int iHullNumber, edict_t *pSkipEnt = nullptr)
{
+ if (UTIL_PointContents(vecOrigin) != CONTENTS_EMPTY)
+ return false;
+
+ TraceResult trace;
+ UTIL_TraceHull(vecOrigin, vecOrigin, dont_ignore_monsters, iHullNumber, pSkipEnt, &trace);
+
+ return (!trace.fStartSolid && !trace.fAllSolid && trace.fInOpen);
+}
+
+inline bool pointInRadius(Vector vecOrigin, float radius)
+{
+ CBaseEntity *pEntity = nullptr;
+ while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecOrigin, radius)))
+ {
+ if (!UTIL_IsValidEntity(pEntity->edict()))
+ continue; // ignore the entity marked for deletion
+
+ if (FClassnameIs(pEntity->edict(), "info_spawn_point"))
+ return true;
+ }
+
+ return false;
+}
+
+// a simple algorithm that searches for the farthest point (so that the player does not look at the wall)
+inline bool GetIdealLookYawForSpawnPoint(const Vector &vecStart, float &flIdealLookYaw)
+{
+ const float ANGLE_STEP = 30.0f;
+ float bestDistance = 0.0f;
+
+ for (float angleYaw = 0.0f; angleYaw <= 360.0f; angleYaw += ANGLE_STEP)
+ {
+ TraceResult tr;
+ UTIL_MakeVectors(Vector(0, angleYaw, 0));
+
+ Vector vecEnd(vecStart + gpGlobals->v_forward * 8192);
+ UTIL_TraceLine(vecStart, vecEnd, ignore_monsters, nullptr, &tr);
+
+ float distance = (vecStart - tr.vecEndPos).Length();
+ if (distance > bestDistance)
+ {
+ bestDistance = distance;
+ flIdealLookYaw = angleYaw;
+ }
+ }
+
+ return bestDistance > 0.0f;
+}
+
+// this function from leaked csgo sources 2020y
+inline bool IsValidArea(CNavArea *area)
+{
+ ShortestPathCost cost;
+ bool bNotOrphaned;
+
+ // check that we can path from the nav area to a ct spawner to confirm it isn't orphaned.
+ CBaseEntity *CTSpawn = UTIL_FindEntityByClassname(nullptr, "info_player_start");
+
+ if (CTSpawn)
+ {
+ CNavArea *CTSpawnArea = TheNavAreaGrid.GetNearestNavArea(&CTSpawn->pev->origin);
+ bNotOrphaned = NavAreaBuildPath(area, CTSpawnArea, nullptr, cost);
+
+ if (bNotOrphaned)
+ return true;
+ }
+
+ // double check that we can path from the nav area to a t spawner to confirm it isn't orphaned.
+ CBaseEntity *TSpawn = UTIL_FindEntityByClassname(nullptr, "info_player_deathmatch");
+
+ if (TSpawn)
+ {
+ CNavArea *TSpawnArea = TheNavAreaGrid.GetNearestNavArea(&TSpawn->pev->origin);
+ bNotOrphaned = NavAreaBuildPath(area, TSpawnArea, nullptr, cost);
+
+ if (bNotOrphaned)
+ return true;
+ }
+
+ return false;
+}
+
+#ifdef REGAMEDLL_ADD
+
+// Generates spawn points (info_spawn_point entities) for players and bots based on the navigation map data
+// It uses the navigation areas to find valid spots for spawn points considering factors like area size, slope,
+// available free space, and distance from other spawn points.
+void GenerateSpawnPointsFromNavData()
+{
+ // Remove any existing spawn points
+ UTIL_RemoveOther("info_spawn_point");
+
+ const int MAX_SPAWNS_POINTS = 128; // Max allowed spawn points
+
+ const float MAX_SLOPE = 0.85f; // Maximum slope allowed for a spawn point
+ const float MIN_AREA_SIZE = 32.0f; // Minimum area size for a valid spawn point
+ const float MIN_NEARBY_SPAWNPOINT = 128.0f; // Minimum distance between spawn point
+
+ // Total number of spawn points generated
+ int totalSpawns = 0;
+
+ for (CNavArea *area : TheNavAreaList)
+ {
+ if (totalSpawns >= MAX_SPAWNS_POINTS)
+ break;
+
+ if (!area)
+ continue;
+
+ // Skip areas that are too small
+ if (area->GetSizeX() < MIN_AREA_SIZE || area->GetSizeY() < MIN_AREA_SIZE)
+ continue;
+
+ // Skip areas with unwanted attributes (jump, crouch, etc.)
+ if (area->GetAttributes() != 0)
+ continue;
+
+ // Skip areas with steep slopes
+ if (area->GetAreaSlope() < MAX_SLOPE)
+ {
+ //CONSOLE_ECHO("Skip area slope: %0.3f\n", area->GetAreaSlope());
+ continue;
+ }
+
+ // Calculate the spawn point position above the area center
+ Vector vecOrigin = *area->GetCenter() + Vector(0, 0, HalfHumanHeight + 5);
+
+ // Ensure there is free space at the calculated position
+ if (!IsFreeSpace(vecOrigin, human_hull))
+ {
+ //CONSOLE_ECHO("No free space!\n");
+ continue;
+ }
+
+ if (pointInRadius(vecOrigin, MIN_NEARBY_SPAWNPOINT))
+ continue; // spawn point is too close to others
+
+ if (!IsValidArea(area))
+ continue;
+
+ // Calculate ideal spawn point yaw angle
+ float flIdealSpawnPointYaw = 0.0f;
+ if (GetIdealLookYawForSpawnPoint(vecOrigin, flIdealSpawnPointYaw))
+ {
+ CBaseEntity *pPoint = CBaseEntity::Create("info_spawn_point", vecOrigin, Vector(0, flIdealSpawnPointYaw, 0), nullptr);
+ if (pPoint)
+ {
+ totalSpawns++;
+ //CONSOLE_ECHO("Add spawn at x:%f y:%f z:%f with angle %0.1f slope %0.3f \n", vecOrigin.x, vecOrigin.y, vecOrigin.z, bestAngle.y, area->GetAreaSlope());
+
+ // use only for debugging
+ if (randomspawn.value > 1.0f)
+ {
+ SET_MODEL(ENT(pPoint->pev), "models/player.mdl");
+ pPoint->pev->sequence = ACT_IDLE;
+ pPoint->pev->rendermode = kRenderTransAdd;
+ pPoint->pev->renderamt = 150.0f;
+ }
+ }
+ }
+ }
+
+ CONSOLE_ECHO("Total spawns points: %i\n", totalSpawns);
+}
+
+#endif
+
+// Load the map's navigation data
+bool CCSBotManager::LoadNavigationMap()
+{
+ // check if the map data is already loaded or if bots are not allowed
if (m_isMapDataLoaded || !AreBotsAllowed())
- return;
+ return false;
m_isMapDataLoaded = true;
- if (LoadNavigationMap())
+ // Clear navigation map data from previous map
+ DestroyNavigationMap();
+
+ // Try to load the map's navigation file
+ NavErrorType navStatus = ::LoadNavigationMap();
+ if (navStatus != NAV_OK)
{
- CONSOLE_ECHO("Failed to load navigation map.\n");
- return;
+ CONSOLE_ECHO("ERROR: Failed to load 'maps/%s.nav' file navigation map!\n", STRING(gpGlobals->mapname));
+
+ switch (navStatus)
+ {
+ case NAV_CANT_ACCESS_FILE:
+ CONSOLE_ECHO("\tNavigation file not found or access denied.\n");
+ break;
+ case NAV_INVALID_FILE:
+ CONSOLE_ECHO("\tInvalid navigation file format.\n");
+ break;
+ case NAV_BAD_FILE_VERSION:
+ CONSOLE_ECHO("\tBad navigation file version.\n");
+ break;
+ case NAV_CORRUPT_DATA:
+ CONSOLE_ECHO("\tCorrupted navigation data detected.\n");
+ break;
+ default:
+ break;
+ }
+
+ if (navStatus != NAV_CANT_ACCESS_FILE)
+ CONSOLE_ECHO("\tTry regenerating it using the command: bot_nav_analyze\n");
+
+ return false;
}
- CONSOLE_ECHO("Navigation map loaded.\n");
+ // Determine the scenario for the current map (e.g., bomb defuse, hostage rescue etc)
+ DetermineMapScenario();
+#ifdef REGAMEDLL_ADD
+ GenerateSpawnPointsFromNavData();
+#endif
+
+ return true;
+}
+
+// Search the map entities to determine the game scenario and define important zones.
+void CCSBotManager::DetermineMapScenario()
+{
m_zoneCount = 0;
m_gameScenario = SCENARIO_DEATHMATCH;
@@ -1299,6 +1509,59 @@ void CCSBotManager::ValidateMapData()
}
}
+// Tell all bots that the given nav data no longer exists
+// This function is called when a part of the map or the nav data is destroyed
+void CCSBotManager::OnDestroyNavDataNotify(NavNotifyDestroyType navNotifyType, void *dead)
+{
+ for (int i = 1; i <= gpGlobals->maxClients; i++)
+ {
+ CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
+
+ if (!UTIL_IsValidPlayer(pPlayer))
+ continue;
+
+ if (!pPlayer->IsBot())
+ continue;
+
+ // Notify the bot about the destroyed nav data
+ CCSBot *pBot = static_cast(pPlayer);
+ pBot->OnDestroyNavDataNotify(navNotifyType, dead);
+ }
+}
+
+// Called when the map analysis process has completed
+// This function makes sure all bots are removed from the map analysis process
+// and are reset to normal bot behavior. It also reloads the navigation map
+// and triggers a game restart after the analysis is completed
+void CCSBotManager::AnalysisCompleted()
+{
+ // Ensure that all bots are no longer involved in map analysis and start their normal process
+ for (int i = 1; i <= gpGlobals->maxClients; i++)
+ {
+ CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
+
+ if (!UTIL_IsValidPlayer(pPlayer))
+ continue;
+
+ if (!pPlayer->IsBot())
+ continue;
+
+ CCSBot *pBot = static_cast(pPlayer);
+ pBot->StartNormalProcess();
+ }
+
+ m_isLearningMap = false;
+ m_isMapDataLoaded = false;
+ m_isAnalysisRequested = false;
+
+ // Try to reload the navigation map from the file
+ if (LoadNavigationMap())
+ {
+ // Initiate a game restart in 3 seconds
+ CVAR_SET_FLOAT("sv_restart", 3);
+ }
+}
+
bool CCSBotManager::AddBot(const BotProfile *profile, BotProfileTeamType team)
{
if (!AreBotsAllowed())
diff --git a/regamedll/dlls/bot/cs_bot_manager.h b/regamedll/dlls/bot/cs_bot_manager.h
index 9552c697..6f3b0e68 100644
--- a/regamedll/dlls/bot/cs_bot_manager.h
+++ b/regamedll/dlls/bot/cs_bot_manager.h
@@ -56,13 +56,16 @@ public:
virtual bool IsImportantPlayer(CBasePlayer *pPlayer) const; // return true if pPlayer is important to scenario (VIP, bomb carrier, etc)
public:
- void ValidateMapData();
+ bool LoadNavigationMap();
+ void DetermineMapScenario();
void OnFreeEntPrivateData(CBaseEntity *pEntity);
+ void OnDestroyNavDataNotify(NavNotifyDestroyType navNotifyType, void *dead);
bool IsLearningMap() const { return m_isLearningMap; }
void SetLearningMapFlag() { m_isLearningMap = true; }
bool IsAnalysisRequested() const { return m_isAnalysisRequested; }
void RequestAnalysis() { m_isAnalysisRequested = true; }
void AckAnalysisRequest() { m_isAnalysisRequested = false; }
+ void AnalysisCompleted();
// difficulty levels
static BotDifficultyType GetDifficultyLevel()
@@ -269,3 +272,4 @@ inline bool AreBotsAllowed()
}
void PrintAllEntities();
+void GenerateSpawnPointsFromNavData();
diff --git a/regamedll/dlls/bot/cs_bot_update.cpp b/regamedll/dlls/bot/cs_bot_update.cpp
index 37d49665..de75bf6a 100644
--- a/regamedll/dlls/bot/cs_bot_update.cpp
+++ b/regamedll/dlls/bot/cs_bot_update.cpp
@@ -255,7 +255,7 @@ void CCSBot::Update()
Vector dir = m_spotEncounter->path.to - m_spotEncounter->path.from;
float length = dir.NormalizeInPlace();
- for (auto &order : m_spotEncounter->spotList) {
+ for (auto& order : m_spotEncounter->spotList) {
UTIL_DrawBeamPoints(m_spotEncounter->path.from + order.t * length * dir, *order.spot->GetPosition(), 3, 0, 255, 255);
}
}
@@ -339,7 +339,7 @@ void CCSBot::Update()
UpdateReactionQueue();
// "threat" may be the same as our current enemy
- CBasePlayer *threat = GetRecognizedEnemy();
+ CBasePlayer* threat = GetRecognizedEnemy();
if (threat)
{
// adjust our personal "safe" time
@@ -592,6 +592,10 @@ void CCSBot::Update()
SecondaryAttack();
}
+#ifdef REGAMEDLL_ADD
+ if (!IsBlind())
+ {
+#endif
// check encounter spots
UpdatePeripheralVision();
@@ -601,11 +605,24 @@ void CCSBot::Update()
GetChatter()->SpottedBomber(GetBomber());
}
+#ifdef REGAMEDLL_ADD
+ // watch for snipers
+ if (CanSeeSniper() && !HasSeenSniperRecently())
+ {
+ GetChatter()->SpottedSniper();
+
+ const float sniperRecentInterval = 20.0f;
+ m_sawEnemySniperTimer.Start(sniperRecentInterval);
+ }
+#endif
+
if (CanSeeLooseBomb())
{
GetChatter()->SpottedLooseBomb(TheCSBots()->GetLooseBomb());
}
-
+#ifdef REGAMEDLL_ADD
+}
+#endif
// Scenario interrupts
switch (TheCSBots()->GetScenario())
{
diff --git a/regamedll/dlls/bot/cs_bot_vision.cpp b/regamedll/dlls/bot/cs_bot_vision.cpp
index f7b16acc..5e4e3026 100644
--- a/regamedll/dlls/bot/cs_bot_vision.cpp
+++ b/regamedll/dlls/bot/cs_bot_vision.cpp
@@ -697,6 +697,13 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
m_closestVisibleFriend = nullptr;
m_closestVisibleHumanFriend = nullptr;
+#ifdef REGAMEDLL_ADD
+ m_isEnemySniperVisible = false;
+ CBasePlayer* sniperThreat = NULL;
+ float sniperThreatRange = 99999999999.9f;
+ bool sniperThreatIsFacingMe = false;
+#endif
+
float closeFriendRange = 99999999999.9f;
float closeHumanFriendRange = 99999999999.9f;
@@ -789,6 +796,53 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
Vector d = pev->origin - pPlayer->pev->origin;
float distSq = d.LengthSquared();
+#ifdef REGAMEDLL_ADD
+ CBasePlayerWeapon *pCurrentWeapon = static_cast(pPlayer->m_pActiveItem);
+ if (pCurrentWeapon && isSniperRifle(pCurrentWeapon))
+ {
+ m_isEnemySniperVisible = true;
+ if (sniperThreat)
+ {
+ if (IsPlayerLookingAtMe(pPlayer))
+ {
+ if (sniperThreatIsFacingMe)
+ {
+ // several snipers are facing us - keep closest
+ if (distSq < sniperThreatRange)
+ {
+ sniperThreat = pPlayer;
+ sniperThreatRange = distSq;
+ sniperThreatIsFacingMe = true;
+ }
+ }
+ else
+ {
+ // even if this sniper is farther away, keep it because he's aiming at us
+ sniperThreat = pPlayer;
+ sniperThreatRange = distSq;
+ sniperThreatIsFacingMe = true;
+ }
+ }
+ else
+ {
+ // this sniper is not looking at us, only consider it if we dont have a sniper facing us
+ if (!sniperThreatIsFacingMe && distSq < sniperThreatRange)
+ {
+ sniperThreat = pPlayer;
+ sniperThreatRange = distSq;
+ }
+ }
+ }
+ else
+ {
+ // first sniper we see
+ sniperThreat = pPlayer;
+ sniperThreatRange = distSq;
+ sniperThreatIsFacingMe = IsPlayerLookingAtMe(pPlayer);
+ }
+ }
+#endif
+
// maintain set of visible threats, sorted by increasing distance
if (threatCount == 0)
{
@@ -950,6 +1004,23 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
{
return currentThreat;
}
+
+ // if we are a sniper and we see a sniper threat, attack it unless
+ // there are other close enemies facing me
+ if (IsSniper() && sniperThreat)
+ {
+ const float closeCombatRange = 500.0f;
+
+ for (t = 0; t < threatCount; ++t)
+ {
+ if (threat[t].range < closeCombatRange && IsPlayerLookingAtMe(threat[t].enemy))
+ {
+ return threat[t].enemy;
+ }
+ }
+
+ return sniperThreat;
+ }
#endif
// otherwise, find the closest threat that without using shield
diff --git a/regamedll/dlls/bot/states/cs_bot_buy.cpp b/regamedll/dlls/bot/states/cs_bot_buy.cpp
index f210423e..c34351f0 100644
--- a/regamedll/dlls/bot/states/cs_bot_buy.cpp
+++ b/regamedll/dlls/bot/states/cs_bot_buy.cpp
@@ -462,17 +462,26 @@ void BuyState::OnUpdate(CCSBot *me)
me->ClientCommand("vesthelm");
me->ClientCommand("vest");
- // pistols - if we have no preferred pistol, buy at random
- if (TheCSBots()->AllowPistols() && !me->GetProfile()->HasPistolPreference())
+ if (TheCSBots()->AllowPistols()
+#ifndef REGAMEDLL_FIXES
+ && !me->GetProfile()->HasPistolPreference()
+#endif
+ )
{
if (m_buyPistol)
{
- int which = RANDOM_LONG(0, MAX_BUY_WEAPON_SECONDARY - 1);
+#ifdef REGAMEDLL_FIXES
+ // pistols - if we have no preferred pistol, buy at random
+ if (!me->GetProfile()->HasPistolPreference())
+#endif
+ {
+ int which = RANDOM_LONG(0, MAX_BUY_WEAPON_SECONDARY - 1);
- if (me->m_iTeam == TERRORIST)
- me->ClientCommand(secondaryWeaponBuyInfoT[which].buyAlias);
- else
- me->ClientCommand(secondaryWeaponBuyInfoCT[which].buyAlias);
+ if (me->m_iTeam == TERRORIST)
+ me->ClientCommand(secondaryWeaponBuyInfoT[which].buyAlias);
+ else
+ me->ClientCommand(secondaryWeaponBuyInfoCT[which].buyAlias);
+ }
// only buy one pistol
m_buyPistol = false;
diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp
index 08efa039..b802a2e3 100644
--- a/regamedll/dlls/client.cpp
+++ b/regamedll/dlls/client.cpp
@@ -841,6 +841,12 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
char *pszConsoleFormat = nullptr;
bool consoleUsesPlaceName = false;
+#ifdef REGAMEDLL_ADD
+ // there's no team on FFA mode
+ if (teamonly && CSGameRules()->IsFreeForAll() && (pPlayer->m_iTeam == CT || pPlayer->m_iTeam == TERRORIST))
+ teamonly = FALSE;
+#endif
+
// team only
if (teamonly)
{
@@ -995,7 +1001,13 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
if (gpGlobals->deathmatch != 0.0f && CSGameRules()->m_VoiceGameMgr.PlayerHasBlockedPlayer(pReceiver, pPlayer))
continue;
- if (teamonly && pReceiver->m_iTeam != pPlayer->m_iTeam)
+ if (teamonly
+#ifdef REGAMEDLL_FIXES
+ && CSGameRules()->PlayerRelationship(pPlayer, pReceiver) != GR_TEAMMATE
+#else
+ && pReceiver->m_iTeam != pPlayer->m_iTeam
+#endif
+ )
continue;
if (
@@ -1008,7 +1020,13 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
continue;
}
- if ((pReceiver->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && pReceiver->m_iTeam == pPlayer->m_iTeam)
+ if ((pReceiver->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY
+#ifdef REGAMEDLL_FIXES
+ && CSGameRules()->PlayerRelationship(pPlayer, pReceiver) == GR_TEAMMATE
+#else
+ && pReceiver->m_iTeam == pPlayer->m_iTeam
+#endif
+ )
|| pReceiver->m_iIgnoreGlobalChat == IGNOREMSG_NONE)
{
MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, pReceiver->pev);
@@ -3815,9 +3833,6 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
#ifdef REGAMEDLL_ADD
CSGameRules()->ServerActivate();
-
- if (location_area_info.value)
- LoadNavigationMap();
#endif
}
diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp
index 5680db82..2c6d9fbf 100644
--- a/regamedll/dlls/game.cpp
+++ b/regamedll/dlls/game.cpp
@@ -160,6 +160,7 @@ cvar_t t_default_grenades = { "mp_t_default_grenades", "", 0, 0.0
cvar_t t_give_player_knife = { "mp_t_give_player_knife", "1", 0, 1.0f, nullptr };
cvar_t t_default_weapons_secondary = { "mp_t_default_weapons_secondary", "glock18", 0, 0.0f, nullptr };
cvar_t t_default_weapons_primary = { "mp_t_default_weapons_primary", "", 0, 0.0f, nullptr };
+cvar_t default_weapons_random = { "mp_default_weapons_random", "", 0, 0.0f, nullptr };
cvar_t free_armor = { "mp_free_armor", "0", 0, 0.0f, nullptr };
cvar_t teamflash = { "mp_team_flash", "1", 0, 1.0f, nullptr };
cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr };
@@ -171,10 +172,11 @@ cvar_t deathmsg_flags = { "mp_deathmsg_flags", "abc", 0, 0.0f
cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", 0, 40.0f, nullptr };
cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr };
cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr };
+cvar_t jump_height = { "mp_jump_height", "45", FCVAR_SERVER, 45.0f, nullptr };
-cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };
+cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };
-cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };
+cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };
cvar_t dying_time = { "mp_dying_time", "3.0", 0, 3.0f, nullptr };
cvar_t defuser_allocation = { "mp_defuser_allocation", "0", 0, 0.0f, nullptr };
@@ -188,6 +190,17 @@ cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 2
cvar_t vote_flags = { "mp_vote_flags", "km", 0, 0.0f, nullptr };
cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, nullptr };
+cvar_t flymove_method = { "mp_flymove_method", "0", 0, 0.0f, nullptr };
+cvar_t stamina_restore_rate = { "mp_stamina_restore_rate", "0", 0, 0.f, nullptr };
+
+cvar_t logkills = { "mp_logkills", "1", FCVAR_SERVER, 0.0f, nullptr };
+cvar_t randomspawn = { "mp_randomspawn", "0", FCVAR_SERVER, 0.0f, nullptr };
+
+cvar_t playerid_showhealth = { "mp_playerid_showhealth", "1", 0, 1.0f, nullptr };
+cvar_t playerid_field = { "mp_playerid_field", "3", 0, 3.0f, nullptr };
+
+cvar_t knockback = { "mp_knockback", "170", 0, 170.0f, nullptr };
+
void GameDLL_Version_f()
{
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
@@ -431,6 +444,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&t_give_player_knife);
CVAR_REGISTER(&t_default_weapons_secondary);
CVAR_REGISTER(&t_default_weapons_primary);
+ CVAR_REGISTER(&default_weapons_random);
CVAR_REGISTER(&free_armor);
CVAR_REGISTER(&teamflash);
CVAR_REGISTER(&allchat);
@@ -449,6 +463,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&freezetime_duck);
CVAR_REGISTER(&freezetime_jump);
+ CVAR_REGISTER(&jump_height);
CVAR_REGISTER(&defuser_allocation);
CVAR_REGISTER(&location_area_info);
CVAR_REGISTER(&chat_loc_fallback);
@@ -459,9 +474,20 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&vote_flags);
CVAR_REGISTER(&votemap_min_time);
+ CVAR_REGISTER(&randomspawn);
CVAR_REGISTER(&cv_bot_enable);
CVAR_REGISTER(&cv_hostage_ai_enable);
+ CVAR_REGISTER(&logkills);
+
+ CVAR_REGISTER(&playerid_showhealth);
+ CVAR_REGISTER(&playerid_field);
+
+ CVAR_REGISTER(&stamina_restore_rate);
+
+ CVAR_REGISTER(&flymove_method);
+
+ CVAR_REGISTER(&knockback);
// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h
index 09da5305..ecf1001c 100644
--- a/regamedll/dlls/game.h
+++ b/regamedll/dlls/game.h
@@ -186,6 +186,7 @@ extern cvar_t t_default_grenades;
extern cvar_t t_give_player_knife;
extern cvar_t t_default_weapons_secondary;
extern cvar_t t_default_weapons_primary;
+extern cvar_t default_weapons_random;
extern cvar_t free_armor;
extern cvar_t teamflash;
extern cvar_t allchat;
@@ -200,6 +201,7 @@ extern cvar_t deathmsg_flags;
extern cvar_t assist_damage_threshold;
extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;
+extern cvar_t jump_height;
extern cvar_t defuser_allocation;
extern cvar_t location_area_info;
extern cvar_t chat_loc_fallback;
@@ -208,6 +210,13 @@ extern cvar_t weapon_respawn_time;
extern cvar_t ammo_respawn_time;
extern cvar_t vote_flags;
extern cvar_t votemap_min_time;
+extern cvar_t flymove_method;
+extern cvar_t stamina_restore_rate;
+extern cvar_t logkills;
+extern cvar_t randomspawn;
+extern cvar_t playerid_showhealth;
+extern cvar_t playerid_field;
+extern cvar_t knockback;
#endif
@@ -215,4 +224,6 @@ extern cvar_t scoreboard_showmoney;
extern cvar_t scoreboard_showhealth;
extern cvar_t scoreboard_showdefkit;
+
+
void GameDLLInit();
diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp
index 41e92f27..87835565 100644
--- a/regamedll/dlls/ggrenade.cpp
+++ b/regamedll/dlls/ggrenade.cpp
@@ -1170,6 +1170,12 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
if (!m_bIsC4)
return;
+#ifdef REGAMEDLL_FIXES
+ // block the start of defuse if the bomb timer has expired
+ if (m_flC4Blow > 0 && gpGlobals->time >= m_flC4Blow)
+ return;
+#endif
+
// TODO: We must be sure that the activator is a player.
CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pActivator->pev);
@@ -1503,6 +1509,13 @@ void CGrenade::C4Think()
{
DefuseBombEnd(pPlayer, false);
}
+#ifdef REGAMEDLL_FIXES
+ // if the bomb timer has expired and defuse is still ongoing, stop the defuse
+ else if (gpGlobals->time >= m_flC4Blow)
+ {
+ DefuseBombEnd(pPlayer, false);
+ }
+#endif
}
else
{
diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp
index 7a84afd4..2b91a50f 100644
--- a/regamedll/dlls/multiplay_gamerules.cpp
+++ b/regamedll/dlls/multiplay_gamerules.cpp
@@ -656,8 +656,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
#endif
// Remove grenades and C4
- const int grenadesRemoveCount = 20;
- UTIL_RemoveOther("grenade", grenadesRemoveCount);
+ UTIL_RemoveOther("grenade");
#ifndef REGAMEDLL_FIXES
// Remove defuse kit
@@ -1817,6 +1816,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
if (!UTIL_IsValidPlayer(pPlayer))
continue;
+#ifdef REGAMEDLL_FIXES
+ if (!pPlayer->IsBot())
+ pPlayer->ForceClientDllUpdate();
+#endif
+
pPlayer->Reset();
}
@@ -3246,19 +3250,6 @@ void CHalfLifeMultiplay::CareerRestart()
}
m_bSkipSpawn = false;
-
- for (int i = 1; i <= gpGlobals->maxClients; i++)
- {
- CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
-
- if (!UTIL_IsValidPlayer(pPlayer))
- continue;
-
- if (!pPlayer->IsBot())
- {
- pPlayer->ForceClientDllUpdate();
- }
- }
}
BOOL CHalfLifeMultiplay::IsMultiplayer()
@@ -4160,29 +4151,33 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim,
pVictim->CSPlayer()->m_iNumKilledByUnanswered[iPlayerIndexKiller - 1]++;
}
}
+#ifdef REGAMEDLL_ADD
+ if (static_cast(logkills.value))
+#endif
+ {
+ // Did he kill himself?
+ if (pVictim->pev == pevKiller)
+ {
+ // killed self
+ char *team = GetTeam(pVictim->m_iTeam);
+ UTIL_LogPrintf("\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n", STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()),
+ GETPLAYERAUTHID(pVictim->edict()), team, killer_weapon_name);
+ }
+ else if (pevKiller->flags & FL_CLIENT)
+ {
+ const char *VictimTeam = GetTeam(pVictim->m_iTeam);
+ const char *KillerTeam = (pKiller && pKiller->IsPlayer()) ? GetTeam(pKiller->m_iTeam) : "";
- // Did he kill himself?
- if (pVictim->pev == pevKiller)
- {
- // killed self
- char *team = GetTeam(pVictim->m_iTeam);
- UTIL_LogPrintf("\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n", STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()),
- GETPLAYERAUTHID(pVictim->edict()), team, killer_weapon_name);
- }
- else if (pevKiller->flags & FL_CLIENT)
- {
- const char *VictimTeam = GetTeam(pVictim->m_iTeam);
- const char *KillerTeam = (pKiller && pKiller->IsPlayer()) ? GetTeam(pKiller->m_iTeam) : "";
-
- UTIL_LogPrintf("\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n", STRING(pevKiller->netname), GETPLAYERUSERID(ENT(pevKiller)), GETPLAYERAUTHID(ENT(pevKiller)),
- KillerTeam, STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()), GETPLAYERAUTHID(pVictim->edict()), VictimTeam, killer_weapon_name);
- }
- else
- {
- // killed by the world
- char *team = GetTeam(pVictim->m_iTeam);
- UTIL_LogPrintf("\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n", STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()),
- GETPLAYERAUTHID(pVictim->edict()), team, killer_weapon_name);
+ UTIL_LogPrintf("\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n", STRING(pevKiller->netname), GETPLAYERUSERID(ENT(pevKiller)), GETPLAYERAUTHID(ENT(pevKiller)),
+ KillerTeam, STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()), GETPLAYERAUTHID(pVictim->edict()), VictimTeam, killer_weapon_name);
+ }
+ else
+ {
+ // killed by the world
+ char *team = GetTeam(pVictim->m_iTeam);
+ UTIL_LogPrintf("\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n", STRING(pVictim->pev->netname), GETPLAYERUSERID(pVictim->edict()),
+ GETPLAYERAUTHID(pVictim->edict()), team, killer_weapon_name);
+ }
}
// TODO: It is called in CBasePlayer::Killed too, most likely,
diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp
index 3f23a629..67aa43e4 100644
--- a/regamedll/dlls/player.cpp
+++ b/regamedll/dlls/player.cpp
@@ -115,6 +115,57 @@ void CBasePlayer::SendItemStatus()
MESSAGE_END();
}
+#ifdef REGAMEDLL_ADD
+
+enum PlayerIdShowHealth
+{
+ PLAYERID_HIDE = 0, // Don't show health
+ PLAYERID_TEAMMATES = 1, // Show health for teammates only (default CS)
+ PLAYERID_ALL = 2 // Show health for all players
+};
+
+enum PlayerIdField
+{
+ PLAYERID_FIELD_NONE = 0, // No extra info
+ PLAYERID_FIELD_TEAM = 1, // Show team name
+ PLAYERID_FIELD_HEALTH = 2, // Show health percentage
+ PLAYERID_FIELD_BOTH = 3 // Show both team name and health
+};
+
+inline const char *GetPlayerIdString(bool sameTeam)
+{
+ int showHealth = static_cast(playerid_showhealth.value);
+ int fieldType = static_cast(playerid_field.value);
+
+ // Don't show health
+ if (showHealth == PLAYERID_HIDE)
+ {
+ return (fieldType == PLAYERID_FIELD_NONE) ? "1 %p2" : "1 %c1: %p2";
+ }
+
+ // Health only for teammates
+ if (showHealth == PLAYERID_TEAMMATES && !sameTeam)
+ {
+ switch (fieldType)
+ {
+ case PLAYERID_FIELD_TEAM: return "1 %c1: %p2";
+ case PLAYERID_FIELD_HEALTH: return "1 %p2";
+ case PLAYERID_FIELD_BOTH: return "1 %c1: %p2";
+ default: return "1 %p2";
+ }
+ }
+
+ // Show health to everyone
+ switch (fieldType)
+ {
+ case PLAYERID_FIELD_TEAM: return "1 %c1: %p2\n2 : %i3%%";
+ case PLAYERID_FIELD_HEALTH: return "1 %p2\n2 %h: %i3%%";
+ case PLAYERID_FIELD_BOTH: return "1 %c1: %p2\n2 %h: %i3%%";
+ default: return "1 %p2\n2 : %i3%%";
+ }
+}
+#endif
+
const char *GetCSModelName(int item_id)
{
const char *modelName = nullptr;
@@ -1182,7 +1233,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType))
{
- m_flVelocityModifier = 0.5f;
+ TakeDamageImpulse(pAttack, 0.0f, 0.5f);
if (m_LastHitGroup == HITGROUP_HEAD)
m_bHighDamage = (flDamage > 60);
@@ -1195,10 +1246,13 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
{
if (pev->velocity.Length() < 300)
{
- Vector attack_velocity = (pev->origin - pAttack->pev->origin).Normalize() * 170;
- pev->velocity = pev->velocity + attack_velocity;
+#ifdef REGAMEDLL_ADD
+ float knockbackValue = knockback.value;
+#else
+ float knockbackValue = 170;
+#endif
- m_flVelocityModifier = 0.65f;
+ TakeDamageImpulse(pAttack, knockbackValue, 0.65f);
}
SetAnimation(PLAYER_LARGE_FLINCH);
@@ -1487,7 +1541,7 @@ void CBasePlayer::PackDeadPlayerItems()
{
DropShield();
#ifdef REGAMEDLL_ADD
- if(iPackGun != GR_PLR_DROP_GUN_ALL)
+ if (iPackGun != GR_PLR_DROP_GUN_ALL)
#endif
{
bSkipPrimSec = true;
@@ -1644,6 +1698,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)()
// Give default secondary equipment
{
char *secondaryString = NULL;
+ int secondaryCount = 0;
+ const int MAX_SECONDARY = 13; // x2 + 1
+ WeaponInfoStruct *secondaryWeaponInfoArray[MAX_SECONDARY];
+
if (m_iTeam == CT)
secondaryString = ct_default_weapons_secondary.string;
else if (m_iTeam == TERRORIST)
@@ -1665,18 +1723,34 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)()
if (weaponInfo) {
const auto iItemID = GetItemIdByWeaponId(weaponInfo->id);
if (iItemID != ITEM_NONE && !HasRestrictItem(iItemID, ITEM_TYPE_EQUIPPED) && IsSecondaryWeapon(iItemID)) {
- GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ if (default_weapons_random.value != 0.0f) {
+ if (secondaryCount < MAX_SECONDARY) {
+ secondaryWeaponInfoArray[secondaryCount++] = weaponInfo;
+ }
+ }
+ else {
+ GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ }
}
}
secondaryString = SharedParse(secondaryString);
}
+
+ if (default_weapons_random.value != 0.0f) {
+ WeaponInfoStruct *weaponInfo = secondaryWeaponInfoArray[RANDOM_LONG(0, secondaryCount - 1)];
+ if (weaponInfo)
+ GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ }
}
}
// Give default primary equipment
{
char *primaryString = NULL;
+ int primaryCount = 0;
+ const int MAX_PRIMARY = 39; // x2 + 1
+ WeaponInfoStruct *primaryWeaponInfoArray[MAX_PRIMARY];
if (m_iTeam == CT)
primaryString = ct_default_weapons_primary.string;
@@ -1699,12 +1773,25 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)()
if (weaponInfo) {
const auto iItemID = GetItemIdByWeaponId(weaponInfo->id);
if (iItemID != ITEM_NONE && !HasRestrictItem(iItemID, ITEM_TYPE_EQUIPPED) && IsPrimaryWeapon(iItemID)) {
- GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ if (default_weapons_random.value != 0.0f) {
+ if (primaryCount < MAX_PRIMARY) {
+ primaryWeaponInfoArray[primaryCount++] = weaponInfo;
+ }
+ }
+ else {
+ GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ }
}
}
primaryString = SharedParse(primaryString);
}
+
+ if (default_weapons_random.value != 0.0f) {
+ WeaponInfoStruct *weaponInfo = primaryWeaponInfoArray[RANDOM_LONG(0, primaryCount - 1)];
+ if (weaponInfo)
+ GiveWeapon(weaponInfo->gunClipSize * iAmountOfBPAmmo, weaponInfo->entityName);
+ }
}
}
@@ -2186,7 +2273,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
{
CBasePlayer *pAttacker = CBasePlayer::Instance(pevAttacker);
- if(pAttacker /*safety*/ && !pAttacker->IsBot() && pAttacker->m_iTeam != m_iTeam)
+ if (pAttacker /*safety*/ && !pAttacker->IsBot() && pAttacker->m_iTeam != m_iTeam)
{
if (pAttacker->HasShield())
killerHasShield = true;
@@ -5338,17 +5425,24 @@ pt_end:
}
// checks if the spot is clear of players
-BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot)
+BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot, float fRadius)
{
if (!pSpot->IsTriggered(pPlayer))
return FALSE;
CBaseEntity *pEntity = nullptr;
- while ((pEntity = UTIL_FindEntityInSphere(pEntity, pSpot->pev->origin, MAX_PLAYER_USE_RADIUS)))
+
+ while ((pEntity = UTIL_FindEntityInSphere(pEntity, pSpot->pev->origin, fRadius)))
{
// if ent is a client, don't spawn on 'em
- if (pEntity->IsPlayer() && pEntity != pPlayer)
+ if (pEntity->IsPlayer() && pEntity != pPlayer
+#ifdef REGAMEDLL_FIXES
+ && pEntity->IsAlive()
+#endif
+ )
+ {
return FALSE;
+ }
}
return TRUE;
@@ -5373,17 +5467,34 @@ bool CBasePlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot
{
if (pSpot)
{
- // check if pSpot is valid
- if (IsSpawnPointValid(this, pSpot))
+#ifdef REGAMEDLL_ADD
+ if (FClassnameIs(pSpot->edict(), "info_spawn_point"))
{
- if (pSpot->pev->origin == Vector(0, 0, 0))
+ if (!IsSpawnPointValid(this, pSpot, 512.0f) || pSpot->pev->origin == Vector(0, 0, 0))
{
pSpot = UTIL_FindEntityByClassname(pSpot, pEntClassName);
continue;
}
+ else
+ {
+ return true;
+ }
+ }
+ else
+#endif
+ {
+ // check if pSpot is valid
+ if (IsSpawnPointValid(this, pSpot, MAX_PLAYER_USE_RADIUS))
+ {
+ if (pSpot->pev->origin == Vector(0, 0, 0))
+ {
+ pSpot = UTIL_FindEntityByClassname(pSpot, pEntClassName);
+ continue;
+ }
- // if so, go to pSpot
- return true;
+ // if so, go to pSpot
+ return true;
+ }
}
}
@@ -5441,6 +5552,24 @@ edict_t *EXT_FUNC CBasePlayer::__API_HOOK(EntSelectSpawnPoint)()
if (!FNullEnt(pSpot))
goto ReturnSpot;
}
+#ifdef REGAMEDLL_ADD
+ else if (randomspawn.value > 0)
+ {
+ pSpot = g_pLastSpawn;
+
+ if (SelectSpawnSpot("info_spawn_point", pSpot))
+ {
+ g_pLastSpawn = pSpot;
+
+ return pSpot->edict();
+ }
+
+ if (m_iTeam == CT)
+ goto CTSpawn;
+ else if (m_iTeam == TERRORIST)
+ goto TSpawn;
+ }
+#endif
// VIP spawn point
else if (g_pGameRules->IsDeathmatch() && m_bIsVIP)
{
@@ -5468,6 +5597,9 @@ CTSpawn:
// The terrorist spawn points
else if (g_pGameRules->IsDeathmatch() && m_iTeam == TERRORIST)
{
+#ifdef REGAMEDLL_ADD
+TSpawn:
+#endif
pSpot = g_pLastTerroristSpawn;
if (SelectSpawnSpot("info_player_deathmatch", pSpot))
@@ -8037,7 +8169,9 @@ void CBasePlayer::InitStatusBar()
m_SbarString0[0] = '\0';
}
-void CBasePlayer::UpdateStatusBar()
+LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, UpdateStatusBar)
+
+void EXT_FUNC CBasePlayer::__API_HOOK(UpdateStatusBar)()
{
int newSBarState[SBAR_END];
char sbuf0[MAX_SBAR_STRING];
@@ -8073,11 +8207,19 @@ void CBasePlayer::UpdateStatusBar()
if (sameTeam || GetObserverMode() != OBS_NONE)
{
if (playerid.value != PLAYERID_MODE_OFF || GetObserverMode() != OBS_NONE)
+#ifndef REGAMEDLL_ADD
Q_strlcpy(sbuf0, "1 %c1: %p2\n2 %h: %i3%%");
+#else
+ Q_strlcpy(sbuf0, GetPlayerIdString(sameTeam));
+#endif
else
Q_strlcpy(sbuf0, " ");
-
- newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
+#ifdef REGAMEDLL_ADD
+ if (static_cast(playerid_showhealth.value) != PLAYERID_FIELD_NONE)
+#endif
+ {
+ newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
+ }
if (!(m_flDisplayHistory & DHF_FRIEND_SEEN) && !(pev->flags & FL_SPECTATOR))
{
@@ -8088,10 +8230,18 @@ void CBasePlayer::UpdateStatusBar()
else if (GetObserverMode() == OBS_NONE)
{
if (playerid.value != PLAYERID_MODE_TEAMONLY && playerid.value != PLAYERID_MODE_OFF)
+#ifndef REGAMEDLL_ADD
Q_strlcpy(sbuf0, "1 %c1: %p2");
+#else
+ Q_strlcpy(sbuf0, GetPlayerIdString(sameTeam));
+#endif
else
Q_strlcpy(sbuf0, " ");
+#ifdef REGAMEDLL_ADD
+ if (static_cast(playerid_showhealth.value) == PLAYERID_ALL)
+ newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
+#endif
if (!(m_flDisplayHistory & DHF_ENEMY_SEEN))
{
m_flDisplayHistory |= DHF_ENEMY_SEEN;
@@ -10116,7 +10266,11 @@ bool CBasePlayer::IsObservingPlayer(CBasePlayer *pPlayer)
void CBasePlayer::UpdateLocation(bool forceUpdate)
{
+#ifdef REGAMEDLL_FIXES
+ if (!forceUpdate && m_flLastUpdateTime > gpGlobals->time - 2.0f)
+#else
if (!forceUpdate && m_flLastUpdateTime >= gpGlobals->time + 2.0f)
+#endif
return;
const char *placeName = nullptr;
@@ -10716,6 +10870,17 @@ bool CBasePlayer::Kill()
return true;
}
+LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, TakeDamageImpulse, (CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier), pAttacker, flKnockbackForce, flVelModifier)
+
+void EXT_FUNC CBasePlayer::__API_HOOK(TakeDamageImpulse)(CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier)
+{
+ if (flKnockbackForce != 0.0f)
+ pev->velocity += (pev->origin - pAttacker->pev->origin).Normalize() * flKnockbackForce;
+
+ if (flVelModifier != 0.0f)
+ m_flVelocityModifier = flVelModifier;
+}
+
const usercmd_t *CBasePlayer::GetLastUserCommand() const
{
#ifdef REGAMEDLL_API
diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h
index b13c2c82..f3ec649c 100644
--- a/regamedll/dlls/player.h
+++ b/regamedll/dlls/player.h
@@ -450,6 +450,8 @@ public:
void PlayerDeathThink_OrigFunc();
void Observer_Think_OrigFunc();
void RemoveAllItems_OrigFunc(BOOL removeSuit);
+ void UpdateStatusBar_OrigFunc();
+ void TakeDamageImpulse_OrigFunc(CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier);
CCSPlayer *CSPlayer() const;
#endif // REGAMEDLL_API
@@ -658,6 +660,7 @@ public:
void UseEmpty();
void DropIdlePlayer(const char *reason);
bool Kill();
+ void TakeDamageImpulse(CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier);
// templates
template
@@ -1044,7 +1047,7 @@ int TrainSpeed(int iSpeed, int iMax);
void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name);
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *pEntity);
void FixPlayerCrouchStuck(edict_t *pPlayer);
-BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);
+BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot, float fRadius);
CBaseEntity *FindEntityForward(CBaseEntity *pMe);
real_t GetPlayerPitch(const edict_t *pEdict);
real_t GetPlayerYaw(const edict_t *pEdict);
diff --git a/regamedll/dlls/qstring.h b/regamedll/dlls/qstring.h
index 0b158292..1f5d679d 100644
--- a/regamedll/dlls/qstring.h
+++ b/regamedll/dlls/qstring.h
@@ -30,16 +30,18 @@
#define QSTRING_DEFINE
-constexpr unsigned int iStringNull = {0};
-
// Quake string (helper class)
class QString final
{
public:
+#if XASH_64BIT
+ using qstring_t = int;
+#else
using qstring_t = unsigned int;
+#endif
- QString(): m_string(iStringNull) {};
- QString(qstring_t string): m_string(string) {};
+ QString();
+ QString(qstring_t string);
bool IsNull() const;
bool IsNullOrEmpty() const;
@@ -52,13 +54,15 @@ public:
bool operator==(const char *pszString) const;
operator const char *() const;
- operator unsigned int() const;
+ operator qstring_t() const;
const char *str() const;
private:
qstring_t m_string;
};
+constexpr QString::qstring_t iStringNull = {0};
+
#ifdef USE_QSTRING
#define string_t QString
#endif
@@ -70,10 +74,25 @@ private:
extern globalvars_t *gpGlobals;
-#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset)))
-#define MAKE_STRING(str) ((unsigned int)(str) - (unsigned int)(STRING(0)))
+#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (QString::qstring_t)(offset)))
+#if XASH_64BIT
+// Xash3D FWGS in 64-bit mode has internal string pool which allows mods to continue use 32-bit string_t
+inline int MAKE_STRING(const char *str)
+{
+ ptrdiff_t diff = str - STRING(0);
+ if (diff >= INT_MIN && diff <= INT_MAX)
+ return (int)diff;
+
+ return ALLOC_STRING(str);
+}
+#else
+#define MAKE_STRING(str) ((QString::qstring_t)(str) - (QString::qstring_t)(STRING(0)))
+#endif
// Inlines
+inline QString::QString(): m_string(iStringNull) {}
+inline QString::QString(qstring_t string): m_string(string) {}
+
inline bool QString::IsNull() const
{
return m_string == iStringNull;
@@ -115,7 +134,7 @@ inline QString::operator const char *() const
return str();
}
-inline QString::operator unsigned int() const
+inline QString::operator qstring_t() const
{
return m_string;
}
diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp
index b1102c47..e0ffed53 100644
--- a/regamedll/dlls/util.cpp
+++ b/regamedll/dlls/util.cpp
@@ -1464,7 +1464,7 @@ void UTIL_Remove(CBaseEntity *pEntity)
pEntity->pev->targetname = 0;
}
-NOXREF BOOL UTIL_IsValidEntity(edict_t *pent)
+BOOL UTIL_IsValidEntity(edict_t *pent)
{
if (!pent || pent->free || (pent->v.flags & FL_KILLME))
return FALSE;
diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp
index 47a77c6f..b98749cb 100644
--- a/regamedll/dlls/weapons.cpp
+++ b/regamedll/dlls/weapons.cpp
@@ -618,11 +618,17 @@ void CBasePlayerItem::DefaultTouch(CBaseEntity *pOther)
CBasePlayer *pPlayer = static_cast(pOther);
if (pPlayer->m_bIsVIP
- && m_iId != WEAPON_USP
+ &&
+#ifndef REGAMEDLL_FIXES
+ m_iId != WEAPON_USP
&& m_iId != WEAPON_GLOCK18
&& m_iId != WEAPON_P228
&& m_iId != WEAPON_DEAGLE
- && m_iId != WEAPON_KNIFE)
+ && m_iId != WEAPON_KNIFE
+#else
+ !IsSecondaryWeapon(m_iId)
+#endif
+ )
{
return;
}
diff --git a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd
index 3d56907e..cab21059 100644
--- a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd
+++ b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd
@@ -3143,3 +3143,7 @@
@PointClass base(BaseCommand) size(-8 -8 -8, 8 8 8) = point_clientcommand : "It issues commands to the client console"
[
]
+
+@PointClass iconsprite("sprites/CS/info_player_start.spr") base(PlayerClass) = info_spawn_point : "Random spawn start"
+[
+]
\ No newline at end of file
diff --git a/regamedll/game_shared/bot/nav.h b/regamedll/game_shared/bot/nav.h
index a917aa99..d23a734e 100644
--- a/regamedll/game_shared/bot/nav.h
+++ b/regamedll/game_shared/bot/nav.h
@@ -71,6 +71,13 @@ enum NavAttributeType
NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping
};
+enum NavNotifyDestroyType
+{
+ NAV_NOTIFY_DESTROY_AREA,
+ NAV_NOTIFY_DESTROY_SPOT,
+ NAV_NOTIFY_DESTROY_SPOT_ENCOUNTER
+};
+
enum NavDirType
{
NORTH = 0,
diff --git a/regamedll/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp
index 6c596051..845b2a3f 100644
--- a/regamedll/game_shared/bot/nav_area.cpp
+++ b/regamedll/game_shared/bot/nav_area.cpp
@@ -72,17 +72,29 @@ NOXREF void buildGoodSizedList()
void DestroyHidingSpots()
{
- // remove all hiding spot references from the nav areas
- for (auto area : TheNavAreaList)
- area->m_hidingSpotList.clear();
-
- HidingSpot::m_nextID = 0;
-
// free all the HidingSpots
- for (auto spot : TheHidingSpotList)
+ for (HidingSpot *spot : TheHidingSpotList)
+ {
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_SPOT, spot);
delete spot;
+ }
TheHidingSpotList.clear();
+
+ // remove all hiding spot references from the nav areas
+ for (CNavArea *area : TheNavAreaList)
+ {
+ area->m_hidingSpotList.clear();
+
+ // free all the HidingSpots in area
+ for (SpotEncounter &e : area->m_spotEncounterList)
+ e.spotList.clear();
+
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_SPOT_ENCOUNTER, area);
+ area->m_spotEncounterList.clear();
+ }
+
+ HidingSpot::m_nextID = 0;
}
// For use when loading from a file
@@ -249,6 +261,9 @@ CNavArea::CNavArea(CNavNode *nwNode, class CNavNode *neNode, class CNavNode *seN
// Destructor
CNavArea::~CNavArea()
{
+ // tell all bots that this area no longer exists
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_AREA, this);
+
// if we are resetting the system, don't bother cleaning up - all areas are being destroyed
if (m_isReset)
return;
@@ -344,6 +359,7 @@ void CNavArea::FinishMerge(CNavArea *adjArea)
// remove subsumed adjacent area
TheNavAreaList.remove(adjArea);
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_AREA, this);
delete adjArea;
}
@@ -536,6 +552,7 @@ bool CNavArea::SplitEdit(bool splitAlongX, float splitEdge, CNavArea **outAlpha,
// remove original area
TheNavAreaList.remove(this);
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_AREA, this);
delete this;
return true;
@@ -868,6 +885,7 @@ bool CNavArea::MergeEdit(CNavArea *adj)
// remove subsumed adjacent area
TheNavAreaList.remove(adj);
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_AREA, adj);
delete adj;
return true;
@@ -900,6 +918,9 @@ void DestroyNavigationMap()
{
CNavArea::m_isReset = true;
+ // destroy all hiding spots
+ DestroyHidingSpots();
+
// remove each element of the list and delete them
while (!TheNavAreaList.empty())
{
@@ -913,8 +934,8 @@ void DestroyNavigationMap()
// destroy ladder representations
DestroyLadders();
- // destroy all hiding spots
- DestroyHidingSpots();
+ // cleanup from previous analysis
+ CleanupApproachAreaAnalysisPrep();
// destroy navigation nodes created during map learning
CNavNode *node, *next;
@@ -1772,6 +1793,13 @@ void GenerateNavigationAreaMesh()
break;
}
+ if (!TheNavAreaList.size())
+ {
+ // If we somehow have no areas, don't try to create an impossibly-large grid
+ TheNavAreaGrid.Initialize(0, 0, 0, 0);
+ return;
+ }
+
Extent extent;
extent.lo.x = 9999999999.9f;
extent.lo.y = 9999999999.9f;
@@ -2828,6 +2856,22 @@ SpotEncounter *CNavArea::GetSpotEncounter(const CNavArea *from, const CNavArea *
return nullptr;
}
+// Checks if a SpotEncounter is present in the list of encounters for the given CNavArea
+bool CNavArea::HasSpotEncounter(const SpotEncounter *encounter)
+{
+ SpotEncounter *e;
+
+ for (SpotEncounterList::iterator iter = m_spotEncounterList.begin(); iter != m_spotEncounterList.end(); iter++)
+ {
+ e = &(*iter);
+
+ if (e == encounter)
+ return true;
+ }
+
+ return false;
+}
+
// Add spot encounter data when moving from area to area
void CNavArea::AddSpotEncounters(const class CNavArea *from, NavDirType fromDir, const CNavArea *to, NavDirType toDir)
{
@@ -3968,6 +4012,7 @@ void EditNavAreas(NavEditCmdType cmd)
case EDIT_DELETE:
EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100);
TheNavAreaList.remove(area);
+ TheCSBots()->OnDestroyNavDataNotify(NAV_NOTIFY_DESTROY_AREA, area);
delete area;
return;
case EDIT_ATTRIB_CROUCH:
@@ -4636,6 +4681,12 @@ void CNavAreaGrid::Initialize(float minX, float maxX, float minY, float maxY)
// Add an area to the grid
void CNavAreaGrid::AddNavArea(CNavArea *area)
{
+ if (!m_grid)
+ {
+ // If we somehow have no grid (manually creating a nav area without loading or generating a mesh), don't crash
+ TheNavAreaGrid.Initialize(0, 0, 0, 0);
+ }
+
// add to grid
const Extent *extent = area->GetExtent();
diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h
index c4cf8a1f..2792cd3b 100644
--- a/regamedll/game_shared/bot/nav_area.h
+++ b/regamedll/game_shared/bot/nav_area.h
@@ -273,6 +273,7 @@ public:
void ComputeHidingSpots(); // analyze local area neighborhood to find "hiding spots" in this area - for map learning
void ComputeSniperSpots(); // analyze local area neighborhood to find "sniper spots" in this area - for map learning
+ bool HasSpotEncounter(const SpotEncounter *encounter);
SpotEncounter *GetSpotEncounter(const CNavArea *from, const CNavArea *to); // given the areas we are moving between, return the spots we will encounter
void ComputeSpotEncounters(); // compute spot encounter data - for map learning
@@ -345,6 +346,25 @@ public:
void AddLadderUp(CNavLadder *ladder) { m_ladder[LADDER_UP].push_back(ladder); }
void AddLadderDown(CNavLadder *ladder) { m_ladder[LADDER_DOWN].push_back(ladder); }
+ inline float GetAreaSlope()
+ {
+ Vector u, v;
+
+ // compute our unit surface normal
+ u.x = m_extent.hi.x - m_extent.lo.x;
+ u.y = 0.0f;
+ u.z = m_neZ - m_extent.lo.z;
+
+ v.x = 0.0f;
+ v.y = m_extent.hi.y - m_extent.lo.y;
+ v.z = m_swZ - m_extent.lo.z;
+
+ Vector normal = CrossProduct(u, v);
+ normal.NormalizeInPlace();
+
+ return normal.z;
+ }
+
private:
friend void ConnectGeneratedAreas();
friend void MergeGeneratedAreas();
diff --git a/regamedll/game_shared/bot/nav_file.cpp b/regamedll/game_shared/bot/nav_file.cpp
index cf97f6f6..e43a0200 100644
--- a/regamedll/game_shared/bot/nav_file.cpp
+++ b/regamedll/game_shared/bot/nav_file.cpp
@@ -623,6 +623,13 @@ bool SaveNavigationMap(const char *filename)
area->Save(fd, version);
}
+ // Ensure that all data is flushed to disk
+#ifdef WIN32
+ _commit(fd);
+#else
+ fsync(fd);
+#endif
+
_close(fd);
return true;
}
@@ -839,6 +846,11 @@ NavErrorType LoadNavigationMap()
unsigned int count;
result = navFile.Read(&count, sizeof(unsigned int));
+ if (count == 0)
+ {
+ return NAV_INVALID_FILE;
+ }
+
Extent extent;
extent.lo.x = 9999999999.9f;
extent.lo.y = 9999999999.9f;
diff --git a/regamedll/msvc/PreBuild.bat b/regamedll/msvc/PreBuild.bat
index 38dac044..b861b43c 100644
--- a/regamedll/msvc/PreBuild.bat
+++ b/regamedll/msvc/PreBuild.bat
@@ -18,13 +18,32 @@ set commitURL=
set commitCount=0
set branch_name=master
-for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
-set "YYYY=%dt:~0,4%"
-set "MM=%dt:~4,2%"
-set "DD=%dt:~6,2%"
-set "hour=%dt:~8,2%"
-set "min=%dt:~10,2%"
-set "sec=%dt:~12,2%"
+for /f "tokens=*" %%i in ('powershell -NoProfile -Command ^
+ "$now = Get-Date; Write-Output ('{0:yyyy}|{0:MM}|{0:dd}|{0:HH}|{0:mm}|{0:ss}' -f $now)"') do (
+ for /f "tokens=1-6 delims=|" %%a in ("%%i") do (
+ set "YYYY=%%a"
+ set "MM=%%b"
+ set "DD=%%c"
+ set "hour=%%d"
+ set "min=%%e"
+ set "sec=%%f"
+ )
+)
+
+echo YYYY=%YYYY%
+echo MM=%MM%
+echo DD=%DD%
+echo hour=%hour%
+echo min=%min%
+echo sec=%sec%
+
+:: for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
+:: set "YYYY=%dt:~0,4%"
+:: set "MM=%dt:~4,2%"
+:: set "DD=%dt:~6,2%"
+:: set "hour=%dt:~8,2%"
+:: set "min=%dt:~10,2%"
+:: set "sec=%dt:~12,2%"
::
:: Remove leading zero from MM (e.g 09 > 9)
diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj
index f33cfa3d..80e93c92 100644
--- a/regamedll/msvc/ReGameDLL.vcxproj
+++ b/regamedll/msvc/ReGameDLL.vcxproj
@@ -932,7 +932,7 @@
DisabledtrueREGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SSE;REGAMEDLL_SELF;REGAMEDLL_CHECKS;UNICODE_FIXES;BUILD_LATEST;BUILD_LATEST_FIXES;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)
- Fast
+ Precise/arch:IA32 %(AdditionalOptions)/Zc:threadSafeInit- %(AdditionalOptions)MultiThreadedDebug
@@ -969,7 +969,7 @@
FulltrueREGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SSE;REGAMEDLL_SELF;REGAMEDLL_CHECKS;UNICODE_FIXES;BUILD_LATEST;BUILD_LATEST_FIXES;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)
- Fast
+ Precise/arch:IA32 %(AdditionalOptions)/Zc:threadSafeInit- %(AdditionalOptions)MultiThreaded
@@ -1102,6 +1102,7 @@
Useprecompiled.hNoExtensions
+ Precisetrue
diff --git a/regamedll/msvc/icon.ico b/regamedll/msvc/icon.ico
new file mode 100644
index 00000000..8c7e14c0
Binary files /dev/null and b/regamedll/msvc/icon.ico differ
diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp
index e9efb376..846b410d 100644
--- a/regamedll/pm_shared/pm_shared.cpp
+++ b/regamedll/pm_shared/pm_shared.cpp
@@ -641,9 +641,184 @@ void PM_FixupGravityVelocity()
pmove->velocity[2] -= (pmove->movevars->gravity * pmove->frametime * ent_gravity * 0.5);
PM_CheckVelocity();
}
+#ifdef REGAMEDLL_ADD
+int PM_FlyMove_New()
+{
+ int bumpcount, numbumps;
+ vec3_t dir;
+ float d;
+ int numplanes;
+ vec3_t planes[MAX_CLIP_PLANES];
+ vec3_t primal_velocity;
+ vec3_t clipVelocity;
+ int i, j, k;
+ pmtrace_t trace;
+ vec3_t end;
+ float time_left;
+ float into;
+ vec3_t endVelocity;
+ vec3_t endClipVelocity;
+ int blocked;
+ numbumps = 4;
+
+ VectorCopy(pmove->velocity, primal_velocity);
+
+
+ time_left = pmove->frametime;
+
+ numplanes = 0;
+ blocked = 0x00; // Assume not blocked
+
+ // never turn against original velocity
+ VectorCopy(pmove->velocity, planes[numplanes]);
+ VectorNormalize(planes[numplanes]);
+ numplanes++;
+
+ for (bumpcount = 0; bumpcount < numbumps; bumpcount++) {
+
+ // calculate position we are trying to move to
+ VectorMA(pmove->origin, time_left, pmove->velocity, end);
+
+ // see if we can make it there
+ trace = pmove->PM_PlayerTrace(pmove->origin, end, PM_NORMAL, -1);
+
+ if (trace.allsolid) {
+ // entity is completely trapped in another solid
+ pmove->velocity[2] = 0; // don't build up falling damage, but allow sideways acceleration
+ return 4;
+ }
+
+ if (trace.fraction > 0) {
+ // actually covered some distance
+ VectorCopy(trace.endpos, pmove->origin);
+ }
+
+ if (trace.fraction == 1) {
+ break; // moved the entire distance
+ }
+
+ // save entity for contact
+ PM_AddToTouched(trace, pmove->velocity);
+
+ // If the plane we hit has a high z component in the normal, then
+ // it's probably a floor
+ if (trace.plane.normal[2] > 0.7f)
+ {
+ // floor
+ blocked |= 0x01;
+ }
+
+ // If the plane has a zero z component in the normal, then it's a
+ // step or wall
+ if (!trace.plane.normal[2])
+ {
+ // step / wall
+ blocked |= 0x02;
+ }
+
+ time_left -= time_left * trace.fraction;
+
+ if (numplanes >= MAX_CLIP_PLANES) {
+ // this shouldn't really happen
+ VectorClear(pmove->velocity);
+ break;
+ }
+
+ //
+ // if this is the same plane we hit before, nudge velocity
+ // out along it, which fixes some epsilon issues with
+ // non-axial planes
+ //
+ for (i = 0; i < numplanes; i++) {
+ if (DotProduct(trace.plane.normal, planes[i]) > 0.99) {
+ VectorAdd(trace.plane.normal, pmove->velocity, pmove->velocity);
+ break;
+ }
+ }
+ if (i < numplanes) {
+ continue;
+ }
+ VectorCopy(trace.plane.normal, planes[numplanes]);
+ numplanes++;
+
+ //
+ // modify velocity so it parallels all of the clip planes
+ //
+
+ // find a plane that it enters
+ for (i = 0; i < numplanes; i++) {
+ into = DotProduct(pmove->velocity, planes[i]);
+ if (into >= 0.1) {
+ continue; // move doesn't interact with the plane
+ }
+
+ // slide along the plane
+ PM_ClipVelocity(pmove->velocity, planes[i], clipVelocity, 1);
+
+ // slide along the plane
+ PM_ClipVelocity(endVelocity, planes[i], endClipVelocity, 1);
+
+ // see if there is a second plane that the new move enters
+ for (j = 0; j < numplanes; j++) {
+ if (j == i) {
+ continue;
+ }
+ if (DotProduct(clipVelocity, planes[j]) >= 0.1) {
+ continue; // move doesn't interact with the plane
+ }
+
+ // try clipping the move to the plane
+ PM_ClipVelocity(clipVelocity, planes[j], clipVelocity, 1);
+ PM_ClipVelocity(endClipVelocity, planes[j], endClipVelocity, 1);
+
+ // see if it goes back into the first clip plane
+ if (DotProduct(clipVelocity, planes[i]) >= 0) {
+ continue;
+ }
+
+ // slide the original velocity along the crease
+ CrossProduct(planes[i], planes[j], dir);
+ VectorNormalize(dir);
+ d = DotProduct(dir, pmove->velocity);
+ VectorScale(dir, d, clipVelocity);
+
+ CrossProduct(planes[i], planes[j], dir);
+ VectorNormalize(dir);
+ d = DotProduct(dir, endVelocity);
+ VectorScale(dir, d, endClipVelocity);
+
+ // see if there is a third plane the the new move enters
+ for (k = 0; k < numplanes; k++) {
+ if (k == i || k == j) {
+ continue;
+ }
+ if (DotProduct(clipVelocity, planes[k]) >= 0.1) {
+ continue; // move doesn't interact with the plane
+ }
+
+ // stop dead at a tripple plane interaction
+ VectorClear(pmove->velocity);
+ return 4;
+ }
+ }
+
+ // if we have fixed all interactions, try another move
+ VectorCopy(clipVelocity, pmove->velocity);
+ VectorCopy(endClipVelocity, endVelocity);
+ break;
+ }
+ }
+
+ return blocked;
+}
+#endif
int PM_FlyMove()
{
+#ifdef REGAMEDLL_ADD
+ if (flymove_method.value)
+ return PM_FlyMove_New();
+#endif
int bumpcount, numbumps;
vec3_t dir;
float d;
@@ -886,6 +1061,18 @@ void PM_WalkMove()
{
real_t flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01;
+#ifdef REGAMEDLL_ADD
+ // change stamina restoration speed by fps reference
+ if (stamina_restore_rate.value > 0.0f)
+ {
+ real_t flReferenceFrametime = 1.0f / stamina_restore_rate.value;
+
+ float flFrametimeRatio = pmove->frametime / flReferenceFrametime;
+
+ flRatio = pow(flRatio, flFrametimeRatio);
+ }
+#endif
+
pmove->velocity[0] *= flRatio;
pmove->velocity[1] *= flRatio;
}
@@ -2429,13 +2616,18 @@ inline real_t PM_JumpHeight(bool longjump)
#ifdef REGAMEDLL_API
if (longjump)
{
- if(pmoveplayer->m_flLongJumpHeight > 0.0)
+ if (pmoveplayer->m_flLongJumpHeight > 0.0)
return pmoveplayer->m_flLongJumpHeight;
}
else if (pmoveplayer->m_flJumpHeight > 0.0)
return pmoveplayer->m_flJumpHeight;
#endif
+
+#ifdef REGAMEDLL_ADD
+ return Q_sqrt(2.0 * 800.0f * (longjump ? 56.0f : Q_max(jump_height.value, 0.0f)));
+#else
return Q_sqrt(2.0 * 800.0f * (longjump ? 56.0f : 45.0f));
+#endif
}
LINK_HOOK_VOID_CHAIN2(PM_Jump)
@@ -2606,6 +2798,7 @@ void EXT_FUNC __API_HOOK(PM_Jump)()
{
// NOTE: don't do it in .f (float)
real_t flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0) * 0.01;
+
pmove->velocity[2] *= flRatio;
}
diff --git a/regamedll/public/build.h b/regamedll/public/build.h
new file mode 100644
index 00000000..24fd9d5b
--- /dev/null
+++ b/regamedll/public/build.h
@@ -0,0 +1,269 @@
+/*
+build.h - compile-time build information
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
+*/
+#pragma once
+#ifndef BUILD_H
+#define BUILD_H
+
+/*
+All XASH_* macros set by this header are guaranteed to have positive value
+otherwise not defined.
+
+Every macro is intended to be the unified interface for buildsystems that lack
+platform & CPU detection, and a neat quick way for checks in platform code
+For Q_build* macros, refer to buildenums.h
+
+Any new define must be undefined at first
+You can generate #undef list below with this oneliner:
+ $ sed 's/\t//g' build.h | grep '^#define XASH' | awk '{ print $2 }' | \
+ sort | uniq | awk '{ print "#undef " $1 }'
+
+Then you can use another oneliner to query all variables:
+ $ grep '^#undef XASH' build.h | awk '{ print $2 }'
+*/
+
+#undef XASH_64BIT
+#undef XASH_AMD64
+#undef XASH_ANDROID
+#undef XASH_APPLE
+#undef XASH_ARM
+#undef XASH_ARM_HARDFP
+#undef XASH_ARM_SOFTFP
+#undef XASH_ARMv4
+#undef XASH_ARMv5
+#undef XASH_ARMv6
+#undef XASH_ARMv7
+#undef XASH_ARMv8
+#undef XASH_BIG_ENDIAN
+#undef XASH_DOS4GW
+#undef XASH_E2K
+#undef XASH_EMSCRIPTEN
+#undef XASH_FREEBSD
+#undef XASH_HAIKU
+#undef XASH_IOS
+#undef XASH_IRIX
+#undef XASH_JS
+#undef XASH_LINUX
+#undef XASH_LITTLE_ENDIAN
+#undef XASH_MIPS
+#undef XASH_MOBILE_PLATFORM
+#undef XASH_NETBSD
+#undef XASH_OPENBSD
+#undef XASH_POSIX
+#undef XASH_PPC
+#undef XASH_RISCV
+#undef XASH_RISCV_DOUBLEFP
+#undef XASH_RISCV_SINGLEFP
+#undef XASH_RISCV_SOFTFP
+#undef XASH_SERENITY
+#undef XASH_SUNOS
+#undef XASH_WIN32
+#undef XASH_X86
+#undef XASH_NSWITCH
+#undef XASH_PSVITA
+#undef XASH_WASI
+#undef XASH_WASM
+
+//================================================================
+//
+// PLATFORM DETECTION CODE
+//
+//================================================================
+#if defined _WIN32
+ #define XASH_WIN32 1
+#elif defined __EMSCRIPTEN__
+ #define XASH_EMSCRIPTEN 1
+#elif defined __WATCOMC__ && defined __DOS__
+ #define XASH_DOS4GW 1
+#else // POSIX compatible
+ #define XASH_POSIX 1
+ #if defined __linux__
+ #if defined __ANDROID__
+ #define XASH_ANDROID 1
+ #endif
+ #define XASH_LINUX 1
+ #elif defined __FreeBSD__
+ #define XASH_FREEBSD 1
+ #elif defined __NetBSD__
+ #define XASH_NETBSD 1
+ #elif defined __OpenBSD__
+ #define XASH_OPENBSD 1
+ #elif defined __HAIKU__
+ #define XASH_HAIKU 1
+ #elif defined __serenity__
+ #define XASH_SERENITY 1
+ #elif defined __sgi
+ #define XASH_IRIX 1
+ #elif defined __APPLE__
+ #include
+ #define XASH_APPLE 1
+ #if TARGET_OS_IOS
+ #define XASH_IOS 1
+ #endif // TARGET_OS_IOS
+ #elif defined __SWITCH__
+ #define XASH_NSWITCH 1
+ #elif defined __vita__
+ #define XASH_PSVITA 1
+ #elif defined __wasi__
+ #define XASH_WASI 1
+ #elif defined __sun__
+ #define XASH_SUNOS 1
+ #else
+ #error
+ #endif
+#endif
+
+// XASH_SAILFISH is special: SailfishOS by itself is a normal GNU/Linux platform
+// It doesn't make sense to split it to separate platform
+// but we still need XASH_MOBILE_PLATFORM for the engine.
+// So this macro is defined entirely in build-system: see main wscript
+// HLSDK/PrimeXT/other SDKs users note: you may ignore this macro
+#if XASH_ANDROID || XASH_IOS || XASH_NSWITCH || XASH_PSVITA || XASH_SAILFISH
+ #define XASH_MOBILE_PLATFORM 1
+#endif
+
+//================================================================
+//
+// ENDIANNESS DEFINES
+//
+//================================================================
+
+#if !defined XASH_ENDIANNESS
+ #if defined XASH_WIN32 || __LITTLE_ENDIAN__
+ //!!! Probably all WinNT installations runs in little endian
+ #define XASH_LITTLE_ENDIAN 1
+ #elif __BIG_ENDIAN__
+ #define XASH_BIG_ENDIAN 1
+ #elif defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__ && defined __ORDER_LITTLE_ENDIAN__ // some compilers define this
+ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #define XASH_BIG_ENDIAN 1
+ #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ #define XASH_LITTLE_ENDIAN 1
+ #endif
+ #else
+ #include
+ #if __BYTE_ORDER == __BIG_ENDIAN
+ #define XASH_BIG_ENDIAN 1
+ #elif __BYTE_ORDER == __LITTLE_ENDIAN
+ #define XASH_LITTLE_ENDIAN 1
+ #endif
+ #endif // !XASH_WIN32
+#endif
+
+//================================================================
+//
+// CPU ARCHITECTURE DEFINES
+//
+//================================================================
+#if defined __x86_64__ || defined _M_X64
+ #define XASH_64BIT 1
+ #define XASH_AMD64 1
+#elif defined __i386__ || defined _X86_ || defined _M_IX86
+ #define XASH_X86 1
+#elif defined __aarch64__ || defined _M_ARM64
+ #define XASH_64BIT 1
+ #define XASH_ARM 8
+#elif defined __mips__
+ #define XASH_MIPS 1
+#elif defined __EMSCRIPTEN__
+ #define XASH_JS 1
+#elif defined __e2k__
+ #define XASH_64BIT 1
+ #define XASH_E2K 1
+#elif defined __PPC__ || defined __powerpc__
+ #define XASH_PPC 1
+ #if defined __PPC64__ || defined __powerpc64__
+ #define XASH_64BIT 1
+ #endif
+#elif defined _M_ARM // msvc
+ #define XASH_ARM 7
+ #define XASH_ARM_HARDFP 1
+#elif defined __arm__
+ #if __ARM_ARCH == 8 || __ARM_ARCH_8__
+ #define XASH_ARM 8
+ #elif __ARM_ARCH == 7 || __ARM_ARCH_7__
+ #define XASH_ARM 7
+ #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__
+ #define XASH_ARM 6
+ #elif __ARM_ARCH == 5 || __ARM_ARCH_5__
+ #define XASH_ARM 5
+ #elif __ARM_ARCH == 4 || __ARM_ARCH_4__
+ #define XASH_ARM 4
+ #else
+ #error "Unknown ARM"
+ #endif
+
+ #if defined __SOFTFP__ || __ARM_PCS_VFP == 0
+ #define XASH_ARM_SOFTFP 1
+ #else // __SOFTFP__
+ #define XASH_ARM_HARDFP 1
+ #endif // __SOFTFP__
+#elif defined __riscv
+ #define XASH_RISCV 1
+
+ #if __riscv_xlen == 64
+ #define XASH_64BIT 1
+ #elif __riscv_xlen != 32
+ #error "Unknown RISC-V ABI"
+ #endif
+
+ #if defined __riscv_float_abi_soft
+ #define XASH_RISCV_SOFTFP 1
+ #elif defined __riscv_float_abi_single
+ #define XASH_RISCV_SINGLEFP 1
+ #elif defined __riscv_float_abi_double
+ #define XASH_RISCV_DOUBLEFP 1
+ #else
+ #error "Unknown RISC-V float ABI"
+ #endif
+#elif defined __wasm__
+ #if defined __wasm64__
+ #define XASH_64BIT 1
+ #endif
+ #define XASH_WASM 1
+#else
+ #error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
+#endif
+
+#if !XASH_64BIT && ( defined( __LP64__ ) || defined( _LP64 ))
+#define XASH_64BIT 1
+#endif
+
+#if XASH_ARM == 8
+ #define XASH_ARMv8 1
+#elif XASH_ARM == 7
+ #define XASH_ARMv7 1
+#elif XASH_ARM == 6
+ #define XASH_ARMv6 1
+#elif XASH_ARM == 5
+ #define XASH_ARMv5 1
+#elif XASH_ARM == 4
+ #define XASH_ARMv4 1
+#endif
+
+#endif // BUILD_H
diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h
index 05b81b70..3ead37a2 100644
--- a/regamedll/public/regamedll/API/CSPlayer.h
+++ b/regamedll/public/regamedll/API/CSPlayer.h
@@ -117,6 +117,8 @@ public:
virtual void Reset();
virtual void OnSpawnEquip(bool addDefault = true, bool equipGame = true);
virtual void SetScoreboardAttributes(CBasePlayer *destination = nullptr);
+ virtual void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr);
+ virtual void TakeDamageImpulse(CBasePlayer *pAttacker, float flKnockbackForce, float flVelModifier);
bool IsPlayerDominated(int iPlayerIndex) const;
void SetPlayerDominated(CBasePlayer *pPlayer, bool bDominated);
diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h
index 74879aa4..fda245bc 100644
--- a/regamedll/public/regamedll/regamedll_api.h
+++ b/regamedll/public/regamedll/regamedll_api.h
@@ -38,7 +38,7 @@
#include
#define REGAMEDLL_API_VERSION_MAJOR 5
-#define REGAMEDLL_API_VERSION_MINOR 28
+#define REGAMEDLL_API_VERSION_MINOR 30
// CBasePlayer::Spawn hook
typedef IHookChainClass IReGameHook_CBasePlayer_Spawn;
@@ -628,6 +628,14 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa
typedef IHookChainClass IReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemoveAllItems;
+// CBasePlayer::UpdateStatusBar hook
+typedef IHookChainClass IReGameHook_CBasePlayer_UpdateStatusBar;
+typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_UpdateStatusBar;
+
+// CBasePlayer::TakeDamageImpulse hook
+typedef IHookChainClass IReGameHook_CBasePlayer_TakeDamageImpulse;
+typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamageImpulse;
+
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@@ -790,6 +798,8 @@ public:
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0;
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0;
+ virtual IReGameHookRegistry_CBasePlayer_UpdateStatusBar *CBasePlayer_UpdateStatusBar() = 0;
+ virtual IReGameHookRegistry_CBasePlayer_TakeDamageImpulse *CBasePlayer_TakeDamageImpulse() = 0;
};
struct ReGameFuncs_t {
diff --git a/regamedll/version/version.h b/regamedll/version/version.h
index 62c33001..3838a2f8 100644
--- a/regamedll/version/version.h
+++ b/regamedll/version/version.h
@@ -6,5 +6,5 @@
#pragma once
#define VERSION_MAJOR 5
-#define VERSION_MINOR 28
+#define VERSION_MINOR 30
#define VERSION_MAINTENANCE 0