From 939237df7156f903d2a84f37e5d9c2bde24d045e Mon Sep 17 00:00:00 2001
From: Roman Chistokhodov <freeslave93@gmail.com>
Date: Sun, 28 Aug 2022 14:28:29 +0300
Subject: [PATCH 1/7] Update README.md. Add a note about mods [ci skip] (#321)

---
 README.md | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index c07deea0..3f7e36a6 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Half-Life SDK for GoldSource & Xash3D with some bugfixes.
 - Scientists now react to smells. [Patch](https://github.com/FWGS/hlsdk-portable/commit/2de4e7ab003d5b1674d12525f5aefb1e57a49fa3)
 - Tau-cannon (gauss) plays idle animations.
 - Tau-cannon (gauss) beam color depends on the charge as it was before the prediction code was introduced in Half-Life. [Patch](https://github.com/FWGS/hlsdk-portable/commit/0a29ec49c8183ebb8da22a6d2ef395eae9c3dffe)
-- Brought back gluon flare in singleplayer.
+- Brought back gluon flare in singleplayer. [Patch](https://github.com/FWGS/hlsdk-portable/commit/9d7ab6acf46a8b71ef119d9c252767865522d21d)
 - Hand grenades don't stay primed after holster, preventing detonation after weapon switch. [Patch](https://github.com/FWGS/hlsdk-portable/commit/6e1059026faa90c5bfe5e3b3f4f58fde398d4524)
 - Fixed flashlight battery appearing as depleted on restore.
 - Fixed a potential overflow when reading sentences.txt. [Patch](https://github.com/FWGS/hlsdk-xash3d/commit/cb51d2aa179f1eb622e08c1c07b053ccd49e40a5)
@@ -37,7 +37,7 @@ Bugfix-related server cvars:
 - **explosionfix**: if set to 1, explosion damage won't propagate through thin bruses.
 - **selfgauss**: if set to 0, players won't hurt themselves with secondary attack when shooting thick brushes.
 
-*Note*: the macros and cvars were adjusted in [hlfixed](https://github.com/FWGS/hlsdk-portable/tree/hlfixed) branch. The bugfix macros are kept turned off in master branch to maintain the compatibility with vanilla servers and clients.
+*Note*: the macros and cvars were adjusted in [hlfixed](https://github.com/FWGS/hlsdk-portable/tree/hlfixed) branch (for further information read [this](https://github.com/FWGS/hlsdk-portable/wiki/HL-Fixed)). The bugfix macros are kept turned off in `master` branch to maintain the compatibility with vanilla servers and clients.
 
 Other server cvars:
 
@@ -48,6 +48,22 @@ Other server cvars:
 </p>
 </details>
 
+<details><summary>Support for mods</summary>
+<p>
+
+This repository contains (re-)implementations of some mods as separate branches derived from `master`. The list of supported mods can be found [here](https://github.com/FWGS/hlsdk-portable/wiki/Mods). Note that some branches are unstable and incomplete.
+
+To get the mod branch locally run the following git command:
+
+```
+git fetch origin asheep:asheep
+```
+
+This is considering that you have set **FWGS/hlsdk-portable** as an `origin` remote and want to fetch `asheep` branch.
+
+</p>
+</details>
+
 # Obtaining source code
 
 Either clone the repository via [git](`https://git-scm.com/downloads`) or just download ZIP via **Code** button on github. The first option is more preferable as it also allows you to search through the repo history, switch between branches and clone the vgui submodule.
@@ -87,7 +103,7 @@ cd projects\hlsdk-portable
 ```
 cmake -A Win32 -B build
 ```
-Once you configure the project you don't need to call `cmake` anymore unless you modify `CMakeLists.txt` files or want to reconfigure the project with different parameters.
+Note that you must repeat the configuration step if you modify `CMakeLists.txt` files or want to reconfigure the project with different parameters.
 
 The next step is to compile the libraries:
 ```

From 99dc2c519f5523ed9c3bc38e1f81c29e09baf957 Mon Sep 17 00:00:00 2001
From: Roman Chistokhodov <freeslave93@gmail.com>
Date: Tue, 30 Aug 2022 19:35:13 +0300
Subject: [PATCH 2/7] Fix HUD_ChatInputPosition qualifier (#323)

---
 cl_dll/vgui_SpectatorPanel.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cl_dll/vgui_SpectatorPanel.cpp b/cl_dll/vgui_SpectatorPanel.cpp
index 4b2b897c..2d78b932 100644
--- a/cl_dll/vgui_SpectatorPanel.cpp
+++ b/cl_dll/vgui_SpectatorPanel.cpp
@@ -29,7 +29,7 @@ Sets the location of the input for chat text
 ==========================
 */
 
-void DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
+extern "C" void DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
 {
 //	RecClChatInputPosition( x, y );
 

From 1394637ce87755f9d1f2673a806b24dc8624f518 Mon Sep 17 00:00:00 2001
From: Alibek Omarov <a1ba.omarov@gmail.com>
Date: Sun, 18 Sep 2022 23:49:58 +0300
Subject: [PATCH 3/7] server: func_tank: prevent domain error on barrel adjust
 (#328)

When target is too close to the tank origin, `d2 - r2` expression may become negative
causing domain error on square root, and poisoning other fields and even other entities with NaN
---
 dlls/func_tank.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp
index fd6ff1e7..c9945848 100644
--- a/dlls/func_tank.cpp
+++ b/dlls/func_tank.cpp
@@ -626,12 +626,14 @@ void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance )
 		if( m_barrelPos.y )
 		{
 			r2 = m_barrelPos.y * m_barrelPos.y;
-			angles.y += ( 180.0f / M_PI_F ) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) );
+			if( d2 > r2 )
+				angles.y += ( 180.0f / M_PI_F ) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) );
 		}
 		if( m_barrelPos.z )
 		{
 			r2 = m_barrelPos.z * m_barrelPos.z;
-			angles.x += ( 180.0f / M_PI_F ) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) );
+			if( d2 > r2 )
+				angles.x += ( 180.0f / M_PI_F ) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) );
 		}
 	}
 }

From 63ce6eda310f9a8b3fb5477a402b3ea3a97c805d Mon Sep 17 00:00:00 2001
From: Alibek Omarov <a1ba.omarov@gmail.com>
Date: Mon, 19 Sep 2022 21:35:26 +0300
Subject: [PATCH 4/7] client: view: fix reading from uninitialized variable
 when setting model angles from camera angles (#329)

---
 cl_dll/view.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp
index 6c9a1582..4c93fb87 100644
--- a/cl_dll/view.cpp
+++ b/cl_dll/view.cpp
@@ -735,7 +735,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
 
 	// Apply this at all times
 	{
-		float pitch = camAngles[0];
+		float pitch = pparams->viewangles[0];
 
 		// Normalize angles
 		if( pitch > 180.0f )

From 5db68d407624152fa00b4862b01ec4d1a34797bf Mon Sep 17 00:00:00 2001
From: Roman Chistokhodov <freeslave93@gmail.com>
Date: Mon, 26 Sep 2022 01:40:52 +0300
Subject: [PATCH 5/7] Revert changes to LinearMove (#331)

---
 dlls/subs.cpp | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/dlls/subs.cpp b/dlls/subs.cpp
index 400e05c8..118554d4 100644
--- a/dlls/subs.cpp
+++ b/dlls/subs.cpp
@@ -400,13 +400,6 @@ void CBaseToggle::LinearMove( Vector vecDest, float flSpeed )
 	// divide vector length by speed to get time to reach dest
 	float flTravelTime = vecDestDelta.Length() / flSpeed;
 
-	if( flTravelTime < 0.05f )
-	{
-		UTIL_SetOrigin( pev, m_vecFinalDest );
-		LinearMoveDone();
-		return;
-	}
-
 	// set nextthink to trigger a call to LinearMoveDone when dest is reached
 	pev->nextthink = pev->ltime + flTravelTime;
 	SetThink( &CBaseToggle::LinearMoveDone );

From 901d1947fba561dba7555b02997c843c59914e2b Mon Sep 17 00:00:00 2001
From: Roman Chistokhodov <freeslave93@gmail.com>
Date: Mon, 26 Sep 2022 17:55:19 +0300
Subject: [PATCH 6/7] Fix tripmines blowing up after loading save game in c1a3d
 with TRIPMINE_BEAM_DUPLICATION_FIX enabled (#332)

---
 dlls/tripmine.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp
index 859e3548..90379807 100644
--- a/dlls/tripmine.cpp
+++ b/dlls/tripmine.cpp
@@ -282,9 +282,23 @@ void CTripmineGrenade::BeamBreakThink( void )
 	// respawn detect. 
 	if( !m_pBeam )
 	{
+#if TRIPMINE_BEAM_DUPLICATION_FIX
+		// Use the same trace parameters as the original trace above so the right entity is hit.
+		TraceResult tr2;
+		UTIL_TraceLine( pev->origin + m_vecDir * 8.0f, pev->origin - m_vecDir * 32.0f, dont_ignore_monsters, ENT( pev ), &tr2 );
+#endif
 		MakeBeam();
+#if TRIPMINE_BEAM_DUPLICATION_FIX
+		if( tr2.pHit )
+		{
+			// reset owner too
+			pev->owner = tr2.pHit;
+			m_hOwner = CBaseEntity::Instance( tr2.pHit );
+		}
+#else
 		if( tr.pHit )
 			m_hOwner = CBaseEntity::Instance( tr.pHit );	// reset owner too
+#endif
 	}
 
 	if( fabs( m_flBeamLength - tr.flFraction ) > 0.001f )

From 06521e89500b277a04fe9c101eb97929203c8b1e Mon Sep 17 00:00:00 2001
From: Roman Chistokhodov <freeslave93@gmail.com>
Date: Sun, 23 Oct 2022 16:38:28 +0300
Subject: [PATCH 7/7] Update github actions (#341)

---
 .github/workflows/build.yml  | 20 ++++++++++----------
 .github/workflows/manual.yml | 16 ++++++++--------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 29c3bdaa..3b5ae35c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -22,20 +22,20 @@ jobs:
       CXX: ${{ matrix.cxx }}
     steps:
     - name: Checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         submodules: recursive
 
     - name: Checkout steam-runtime
       if: startsWith(matrix.os, 'ubuntu')
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         repository: ValveSoftware/steam-runtime
         path: steam-runtime
     - name: Cache steam-runtime
       if: startsWith(matrix.os, 'ubuntu')
       id: cache-steam-runtime
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       with:
         path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
         key: ${{ runner.os }}-steam-runtime
@@ -65,7 +65,7 @@ jobs:
 
     - name: Add msbuild to PATH
       if: startsWith(matrix.os, 'windows')
-      uses: microsoft/setup-msbuild@v1.0.2
+      uses: microsoft/setup-msbuild@v1.1
     - name: Build on Windows
       if: startsWith(matrix.os, 'windows')
       run: |
@@ -79,33 +79,33 @@ jobs:
 
     - name: Extract branch name
       shell: bash
-      run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')"
+      run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT
       id: extract_branch
     - name: Extract gamedir
       shell: bash
-      run: echo "##[set-output name=gamedir;]$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)"
+      run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
       id: extract_gamedir
     - name: Upload linux artifact
       if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux
         path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
     - name: Upload linux artifact with vgui
       if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux-vgui
         path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}
     - name: Upload windows artifact
       if: startsWith(matrix.os, 'windows')
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows
         path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
     - name: Upload windows artifact with vgui
       if: startsWith(matrix.os, 'windows')
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui
         path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}
diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml
index 19cf0201..9f03d110 100644
--- a/.github/workflows/manual.yml
+++ b/.github/workflows/manual.yml
@@ -32,20 +32,20 @@ jobs:
       CXX: ${{ matrix.cxx }}
     steps:
     - name: Checkout
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         submodules: recursive
 
     - name: Checkout steam-runtime
       if: startsWith(matrix.os, 'ubuntu')
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         repository: ValveSoftware/steam-runtime
         path: steam-runtime
     - name: Cache steam-runtime
       if: startsWith(matrix.os, 'ubuntu')
       id: cache-steam-runtime
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       with:
         path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
         key: ${{ runner.os }}-steam-runtime
@@ -73,7 +73,7 @@ jobs:
 
     - name: Add msbuild to PATH
       if: startsWith(matrix.os, 'windows')
-      uses: microsoft/setup-msbuild@v1.0.2
+      uses: microsoft/setup-msbuild@v1.1
     - name: Build on Windows
       if: startsWith(matrix.os, 'windows')
       run: |
@@ -82,11 +82,11 @@ jobs:
 
     - name: Extract branch name
       shell: bash
-      run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')"
+      run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT
       id: extract_branch
     - name: Extract gamedir
       shell: bash
-      run: echo "##[set-output name=gamedir;]$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)"
+      run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
       id: extract_gamedir
     - name: Copy pdbs to dist dir
       if: ${{ startsWith(matrix.os, 'windows') && github.event.inputs.buildtype == 'Debug' }}
@@ -100,13 +100,13 @@ jobs:
         Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/hl.lib
     - name: Upload linux artifact
       if: startsWith(matrix.os, 'ubuntu')
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux
         path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
     - name: Upload windows artifact
       if: startsWith(matrix.os, 'windows')
-      uses: actions/upload-artifact@v2
+      uses: actions/upload-artifact@v3
       with:
         name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows
         path: dist/${{ steps.extract_gamedir.outputs.gamedir }}