Skip to content

Commit 19ef4a2

Browse files
committed
Update for latest CS2 update
- Fall back to HTML menu, code remains should the new viewmodel stuff be figured out - Update `ProcessUserCmds()` signature - Update dependencies
1 parent f970355 commit 19ef4a2

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/SharpModMenu/PlayerExtensions.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ internal static class PlayerExtensions
3232
{
3333
public static ObserverInfo GetObserverInfo(this CCSPlayerController player)
3434
{
35+
if (!player.IsValid)
36+
return new() { Mode = ObserverMode.Roaming, Observing = null };
37+
3538
if (!player.Pawn.IsValid || player.Pawn.Value is not CBasePlayerPawn pawn)
3639
return new() { Mode = ObserverMode.Roaming, Observing = null };
3740

@@ -79,15 +82,18 @@ public static ObserverInfo GetObserverInfo(this CCSPlayerController player)
7982
};
8083
}
8184

82-
public static CCSGOViewModel? GetPredictedViewmodel(this ObserverInfo observerInfo)
85+
public static CBaseEntity? GetPredictedViewmodel(this ObserverInfo observerInfo)
8386
{
87+
// no viewmodel ability right now
88+
return null;
89+
8490
if (observerInfo.Observing is not CCSPlayerPawnBase pawn)
8591
return null;
86-
if (pawn.ViewModelServices is null)
87-
return null;
92+
//if (pawn.ViewModelServices is null)
93+
// return null;
8894
if (observerInfo.Mode != ObserverMode.FirstPerson)
8995
return null;
90-
96+
/*
9197
var offset = Schema.GetSchemaOffset("CCSPlayer_ViewModelServices", "m_hViewModel");
9298
nint viewmodelHandleAddress = pawn.ViewModelServices.Handle + offset + 4;
9399
@@ -101,5 +107,6 @@ public static ObserverInfo GetObserverInfo(this CCSPlayerController player)
101107
}
102108
103109
return handle.Value;
110+
*/
104111
}
105112
}

src/SharpModMenu/PlayerMenuState.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ private void CreateEntities()
241241
/// </summary>
242242
private bool CreateInitialInvisibleWorldTextEntity()
243243
{
244+
return false;
244245
var observerInfo = Player.GetObserverInfo();
245246

246247
if (_CreatedFor.HasValue && _CreatedFor.Value == observerInfo.Observing?.Handle)
@@ -309,7 +310,7 @@ private CPointWorldText CreateWorldText(
309310
private static QAngle _Ang = new();
310311
private void UpdateEntity(
311312
CPointWorldText ent,
312-
CCSGOViewModel? viewmodel,
313+
CBaseEntity? viewmodel,
313314
string newText,
314315
Vector3 position,
315316
Vector3 angles,
@@ -356,9 +357,11 @@ public Vector2 MenuPosition
356357
private readonly StringBuilder BackgroundSb = new();
357358
private nint MenuCurrentObserver { get; set; } = nint.Zero;
358359
private ObserverMode MenuCurrentObserverMode { get; set; }
359-
private CCSGOViewModel? MenuCurrentViewmodel { get; set; }
360+
private CBaseEntity? MenuCurrentViewmodel { get; set; }
360361
public bool DrawActiveMenu()
361362
{
363+
return false; // nothing to parent to right now, further work needed
364+
362365
if (ReferenceEquals(CurrentMenu, LastPresented))
363366
{
364367
if (CurrentMenu is not null && !CurrentMenu.IsDirty)

src/SharpModMenu/SharpModMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class SharpModMenuPlugin : BasePlugin
3131
// https://github.com/CharlesBarone/CSSharp-Fixes/blob/9f20129bd4d17dcf7f30311ac0d24ec56895b04a/gamedata/cssharpfixes.json#L44
3232
private static string ProcessUserCmdsSig => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
3333
? "48 8B C4 44 88 48 20 44 89 40 18 48 89 50 10 53"
34-
: "55 48 89 E5 41 57 41 56 41 89 D6 41 55 41 54 49 89 FC 53 48 83 EC 38";
34+
: "55 48 89 E5 41 57 41 56 41 55 41 54 53 48 89 FB 48 83 EC ? 89 4D";
3535
// void* FASTCALL ProcessUsercmds(CCSPlayerController* player, CUserCmdPB* cmds, int cmdCount, bool paused, float margin);
3636
private static MemoryFunctionWithReturn<nint, nint, int, bool, float, nint, nint>? ProcessUserCmdsFunc { get; set; }
3737
private bool UseFallbackWasdInputMethod { get; set; } = false;

src/SharpModMenu/SharpModMenu.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="CSSUniversalMenuAPI" Version="0.3.1" ExcludeAssets="runtime" />
9+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.331" />
10+
<PackageReference Include="CSSUniversalMenuAPI" Version="0.4.0" ExcludeAssets="runtime" />
1011
</ItemGroup>
1112

1213
</Project>

0 commit comments

Comments
 (0)