Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit e9a748b

Browse files
committed
update engine
1 parent 2abaedd commit e9a748b

File tree

13 files changed

+102
-93
lines changed

13 files changed

+102
-93
lines changed

.github/workflows/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838

3939
- name: Build
4040
shell: bash
41+
#dotnet build Core/core.csproj -f net7.0 -r win-x86 -c Debug --no-self-contained --output .deploy
4142
run: |
4243
COMMIT_VERSION=$(git rev-list --count HEAD)
4344
dotnet build PluginExample/PluginExample.csproj -f net7.0 -r ${{ matrix.target }} --no-self-contained -c Release

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,7 @@ FodyWeavers.xsd
399399
.idea
400400

401401
# Counter
402-
.VSCodeCounter
402+
.VSCodeCounter
403+
404+
# Build
405+
.deploy

Core/Bootstrap.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using SourceSharp.Sdk.Interfaces;
88
using System;
99
using System.IO;
10+
using System.Reflection;
1011
using System.Runtime.InteropServices;
1112
using System.Threading;
1213
using System.Threading.Tasks;
@@ -29,6 +30,9 @@ private static int Initialize()
2930
{
3031
try
3132
{
33+
Console.WriteLine("SourceSharp Path: " + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
34+
Console.WriteLine("GetGamePath: " + Bridges.SourceSharp.GetGamePath());
35+
3236
// bin
3337
var dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!;
3438
// root

Core/Bridges/ConVar.cs

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

Core/Bridges/Event.cs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,100 +14,100 @@
1414

1515
namespace SourceSharp.Core.Bridges
1616
{
17-
public unsafe partial class IGameEvent : IDisposable
17+
public unsafe partial class SSGameEvent : IDisposable
1818
{
1919
[StructLayout(LayoutKind.Sequential, Size = 8)]
2020
public partial struct __Internal
2121
{
2222
internal __IntPtr m_pEvent;
2323

24-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "??0IGameEvent@@QEAA@AEBV0@@Z", CallingConvention = __CallingConvention.Cdecl)]
24+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "??0SSGameEvent@@QEAA@AEBV0@@Z", CallingConvention = __CallingConvention.Cdecl)]
2525
internal static extern __IntPtr cctor(__IntPtr __instance, __IntPtr _0);
2626

27-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetInt@IGameEvent@@QEAA_NPEBDH@Z", CallingConvention = __CallingConvention.Cdecl)]
27+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetInt@SSGameEvent@@QEAA_NPEBDH@Z", CallingConvention = __CallingConvention.Cdecl)]
2828
[return: MarshalAs(UnmanagedType.I1)]
2929
internal static extern bool SetInt(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey, int value);
3030

31-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetInt@IGameEvent@@QEAAHPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
31+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetInt@SSGameEvent@@QEAAHPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
3232
internal static extern int GetInt(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey);
3333

34-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetBool@IGameEvent@@QEAA_NPEBD_N@Z", CallingConvention = __CallingConvention.Cdecl)]
34+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetBool@SSGameEvent@@QEAA_NPEBD_N@Z", CallingConvention = __CallingConvention.Cdecl)]
3535
[return: MarshalAs(UnmanagedType.I1)]
3636
internal static extern bool SetBool(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey, bool value);
3737

38-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetBool@IGameEvent@@QEAA_NPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
38+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetBool@SSGameEvent@@QEAA_NPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
3939
[return: MarshalAs(UnmanagedType.I1)]
4040
internal static extern bool GetBool(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey);
4141

42-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetFloat@IGameEvent@@QEAA_NPEBDM@Z", CallingConvention = __CallingConvention.Cdecl)]
42+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetFloat@SSGameEvent@@QEAA_NPEBDM@Z", CallingConvention = __CallingConvention.Cdecl)]
4343
[return: MarshalAs(UnmanagedType.I1)]
4444
internal static extern bool SetFloat(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey, float value);
4545

46-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetFloat@IGameEvent@@QEAAMPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
46+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetFloat@SSGameEvent@@QEAAMPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
4747
internal static extern float GetFloat(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey);
4848

49-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetString@IGameEvent@@QEAA_NPEBD0@Z", CallingConvention = __CallingConvention.Cdecl)]
49+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetString@SSGameEvent@@QEAA_NPEBD0@Z", CallingConvention = __CallingConvention.Cdecl)]
5050
[return: MarshalAs(UnmanagedType.I1)]
5151
internal static extern bool SetString(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string value);
5252

53-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetString@IGameEvent@@QEAAPEBDPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
53+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetString@SSGameEvent@@QEAAPEBDPEBD@Z", CallingConvention = __CallingConvention.Cdecl)]
5454
internal static extern __IntPtr GetString(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string pKey);
5555

56-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetBroadcast@IGameEvent@@QEAA_N_N@Z", CallingConvention = __CallingConvention.Cdecl)]
56+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?SetBroadcast@SSGameEvent@@QEAA_N_N@Z", CallingConvention = __CallingConvention.Cdecl)]
5757
[return: MarshalAs(UnmanagedType.I1)]
5858
internal static extern bool SetBroadcast(__IntPtr __instance, bool value);
5959

60-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?Cancel@IGameEvent@@QEAAXXZ", CallingConvention = __CallingConvention.Cdecl)]
60+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?Cancel@SSGameEvent@@QEAAXXZ", CallingConvention = __CallingConvention.Cdecl)]
6161
internal static extern void Cancel(__IntPtr __instance);
6262

63-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetName@IGameEvent@@QEAAPEBDXZ", CallingConvention = __CallingConvention.Cdecl)]
63+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetName@SSGameEvent@@QEAAPEBDXZ", CallingConvention = __CallingConvention.Cdecl)]
6464
internal static extern __IntPtr GetName(__IntPtr __instance);
6565

66-
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetBroadcast@IGameEvent@@QEAA_NXZ", CallingConvention = __CallingConvention.Cdecl)]
66+
[SuppressUnmanagedCodeSecurity, DllImport("sourcesharp", EntryPoint = "?GetBroadcast@SSGameEvent@@QEAA_NXZ", CallingConvention = __CallingConvention.Cdecl)]
6767
[return: MarshalAs(UnmanagedType.I1)]
6868
internal static extern bool GetBroadcast(__IntPtr __instance);
6969
}
7070

7171
public __IntPtr __Instance { get; protected set; }
7272

73-
internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::SourceSharp.Core.Bridges.IGameEvent> NativeToManagedMap =
74-
new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::SourceSharp.Core.Bridges.IGameEvent>();
73+
internal static readonly new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::SourceSharp.Core.Bridges.SSGameEvent> NativeToManagedMap =
74+
new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::SourceSharp.Core.Bridges.SSGameEvent>();
7575

76-
internal static void __RecordNativeToManagedMapping(IntPtr native, global::SourceSharp.Core.Bridges.IGameEvent managed)
76+
internal static void __RecordNativeToManagedMapping(IntPtr native, global::SourceSharp.Core.Bridges.SSGameEvent managed)
7777
{
7878
NativeToManagedMap[native] = managed;
7979
}
8080

81-
internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::SourceSharp.Core.Bridges.IGameEvent managed)
81+
internal static bool __TryGetNativeToManagedMapping(IntPtr native, out global::SourceSharp.Core.Bridges.SSGameEvent managed)
8282
{
8383

8484
return NativeToManagedMap.TryGetValue(native, out managed);
8585
}
8686

8787
protected bool __ownsNativeInstance;
8888

89-
internal static IGameEvent __CreateInstance(__IntPtr native, bool skipVTables = false)
89+
internal static SSGameEvent __CreateInstance(__IntPtr native, bool skipVTables = false)
9090
{
9191
if (native == __IntPtr.Zero)
9292
return null;
93-
return new IGameEvent(native.ToPointer(), skipVTables);
93+
return new SSGameEvent(native.ToPointer(), skipVTables);
9494
}
9595

96-
internal static IGameEvent __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false)
96+
internal static SSGameEvent __GetOrCreateInstance(__IntPtr native, bool saveInstance = false, bool skipVTables = false)
9797
{
9898
if (native == __IntPtr.Zero)
9999
return null;
100100
if (__TryGetNativeToManagedMapping(native, out var managed))
101-
return (IGameEvent)managed;
101+
return (SSGameEvent)managed;
102102
var result = __CreateInstance(native, skipVTables);
103103
if (saveInstance)
104104
__RecordNativeToManagedMapping(native, result);
105105
return result;
106106
}
107107

108-
internal static IGameEvent __CreateInstance(__Internal native, bool skipVTables = false)
108+
internal static SSGameEvent __CreateInstance(__Internal native, bool skipVTables = false)
109109
{
110-
return new IGameEvent(native, skipVTables);
110+
return new SSGameEvent(native, skipVTables);
111111
}
112112

113113
private static void* __CopyValue(__Internal native)
@@ -117,33 +117,33 @@ internal static IGameEvent __CreateInstance(__Internal native, bool skipVTables
117117
return ret.ToPointer();
118118
}
119119

120-
private IGameEvent(__Internal native, bool skipVTables = false)
120+
private SSGameEvent(__Internal native, bool skipVTables = false)
121121
: this(__CopyValue(native), skipVTables)
122122
{
123123
__ownsNativeInstance = true;
124124
__RecordNativeToManagedMapping(__Instance, this);
125125
}
126126

127-
protected IGameEvent(void* native, bool skipVTables = false)
127+
protected SSGameEvent(void* native, bool skipVTables = false)
128128
{
129129
if (native == null)
130130
return;
131131
__Instance = new __IntPtr(native);
132132
}
133133

134-
public IGameEvent()
134+
public SSGameEvent()
135135
{
136-
__Instance = Marshal.AllocHGlobal(sizeof(global::SourceSharp.Core.Bridges.IGameEvent.__Internal));
136+
__Instance = Marshal.AllocHGlobal(sizeof(global::SourceSharp.Core.Bridges.SSGameEvent.__Internal));
137137
__ownsNativeInstance = true;
138138
__RecordNativeToManagedMapping(__Instance, this);
139139
}
140140

141-
public IGameEvent(global::SourceSharp.Core.Bridges.IGameEvent _0)
141+
public SSGameEvent(global::SourceSharp.Core.Bridges.SSGameEvent _0)
142142
{
143-
__Instance = Marshal.AllocHGlobal(sizeof(global::SourceSharp.Core.Bridges.IGameEvent.__Internal));
143+
__Instance = Marshal.AllocHGlobal(sizeof(global::SourceSharp.Core.Bridges.SSGameEvent.__Internal));
144144
__ownsNativeInstance = true;
145145
__RecordNativeToManagedMapping(__Instance, this);
146-
*((global::SourceSharp.Core.Bridges.IGameEvent.__Internal*) __Instance) = *((global::SourceSharp.Core.Bridges.IGameEvent.__Internal*) _0.__Instance);
146+
*((global::SourceSharp.Core.Bridges.SSGameEvent.__Internal*) __Instance) = *((global::SourceSharp.Core.Bridges.SSGameEvent.__Internal*) _0.__Instance);
147147
}
148148

149149
public void Dispose()
@@ -265,10 +265,10 @@ public static bool RegGameEventHook(string pName)
265265
return ___ret;
266266
}
267267

268-
public static global::SourceSharp.Core.Bridges.IGameEvent CreateGameEvent(string pName, bool bBroadcast)
268+
public static global::SourceSharp.Core.Bridges.SSGameEvent CreateGameEvent(string pName, bool bBroadcast)
269269
{
270270
var ___ret = __Internal.CreateGameEvent(pName, bBroadcast);
271-
var __result0 = global::SourceSharp.Core.Bridges.IGameEvent.__GetOrCreateInstance(___ret, false);
271+
var __result0 = global::SourceSharp.Core.Bridges.SSGameEvent.__GetOrCreateInstance(___ret, false);
272272
return __result0;
273273
}
274274
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include <ConVar.h>
22
#include <new>
33

4-
class IConVar& (IConVar::*_0)(class IConVar&&) = &IConVar::operator=;
4+
class SSConVar& (SSConVar::*_0)(class SSConVar&&) = &SSConVar::operator=;

Core/Interfaces/IConVarManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace SourceSharp.Core.Interfaces;
44

55
internal interface IConVarManager : IListenerBase
66
{
7-
public void OnConVarChanged(IConVar conVar, string oldValue, string newValue);
7+
public void OnConVarChanged(SSConVar conVar, string oldValue, string newValue);
88
}

Core/Interfaces/ISourceSharpBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public string BuildPath(PathType type, params string[] format)
4848
{
4949
case PathType.SourceSharpAbsolute:
5050
{
51-
var ssDir = GetSourceSharpPath();
51+
var ssDir = GetRootPath();
5252
finalPath = ssDir;
5353
foreach (var p in format)
5454
{
@@ -90,7 +90,7 @@ public string BuildPath(PathType type, params string[] format)
9090
public string GetGamePath()
9191
=> CoreBridge.GetGamePath();
9292

93-
public string GetSourceSharpPath()
93+
public string GetRootPath()
9494
=> Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
9595

9696
public void LogError(string message)

Core/Invoker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ public static int ClientConsoleCommand(
125125
[UnmanagedCallersOnly]
126126
public static int OnFireEvent([DNNE.C99Type("const void*")] IntPtr pEvent)
127127
{
128-
var @event = IGameEvent.__CreateInstance(pEvent);
128+
var @event = SSGameEvent.__CreateInstance(pEvent);
129129
return _gameEventListener.OnEventFire(new CGameEvent(@event, false)) ? 1 : 0;
130130
}
131131

132132
[UnmanagedCallersOnly]
133133
public static void OnFiredEvent([DNNE.C99Type("const void*")] IntPtr pEvent)
134134
{
135-
var @event = IGameEvent.__CreateInstance(pEvent);
135+
var @event = SSGameEvent.__CreateInstance(pEvent);
136136
_gameEventListener.OnEventFired(new CGameEvent(@event, true));
137137
}
138138

Core/Models/CConVar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace SourceSharp.Core.Models;
1010

1111
internal class CConVar : ConVar
1212
{
13-
private readonly IConVar _conVar;
13+
private readonly SSConVar _conVar;
1414
private readonly string _name;
1515
private readonly string _description;
1616

17-
public CConVar(IConVar conVar, string name, string description)
17+
public CConVar(SSConVar conVar, string name, string description)
1818
{
1919
_conVar = conVar;
2020
_name = name;

0 commit comments

Comments
 (0)