CS# bug bypass for survival mode
This commit is contained in:
parent
99ff071723
commit
8739fd3ac0
6 changed files with 29 additions and 6 deletions
23
Outnumbered/Engine/RespawnFix.cs
Normal file
23
Outnumbered/Engine/RespawnFix.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
|
||||
namespace Outnumbered.Engine;
|
||||
|
||||
// Workaround, pending a CounterStrikeSharp release carrying the upstream fix: CSSharp's
|
||||
// CCSPlayerController.Respawn() calls SetPawn(PlayerPawn.Value), which faults inside the engine's
|
||||
// network-state change code when the pawn is DEAD — the usual respawn case — on the current CS2
|
||||
// build (a bot respawned right after we kill it took the crash). This mirrors CSSharp's Respawn()
|
||||
// but only re-attaches a LIVE pawn; the CCSPlayerController_Respawn vfunc re-creates the pawn on
|
||||
// respawn regardless. Revert every SafeRespawn() call back to .Respawn() once the fixed package ships.
|
||||
internal static class RespawnFix
|
||||
{
|
||||
public static void SafeRespawn(this CCSPlayerController controller)
|
||||
{
|
||||
if (controller is not { IsValid: true }) return;
|
||||
var pawn = controller.PlayerPawn.Value;
|
||||
if (pawn == null) return;
|
||||
if (pawn is { IsValid: true, Health: > 0 }) controller.SetPawn(pawn);
|
||||
VirtualFunction.CreateVoid<IntPtr>(controller.Handle, GameData.GetOffset("CCSPlayerController_Respawn"))(controller.Handle);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue