File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
managed/CounterStrikeSharp.Tests.Native Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 11using System . Linq ;
2+ using System . Threading ;
23using System . Threading . Tasks ;
34using CounterStrikeSharp . API ;
45using CounterStrikeSharp . API . Core ;
@@ -14,7 +15,19 @@ public void GetSchemaOffset_ReturnsValidOffset()
1415 {
1516 var offset = NativeAPI . GetSchemaOffset ( "CBaseEntity" , "m_iHealth" ) ;
1617
17- Assert . True ( offset > 0 , $ "Schema offset for m_iHealth should be positive, got { offset } ") ;
18+ Assert . Equal ( 1464 , offset ) ; // Hardcode for now, this may change but I want to know if it changes
19+ }
20+
21+ [ Fact ]
22+ public async Task GetSchemaOffset_CanRunOnAnotherThread ( )
23+ {
24+ await Task . Run ( async ( ) =>
25+ {
26+ await Task . Yield ( ) ;
27+ Assert . NotEqual ( Thread . CurrentThread . ManagedThreadId , NativeTestsPlugin . gameThreadId ) ;
28+ var offset = NativeAPI . GetSchemaOffset ( "CBaseEntity" , "m_iHealth" ) ;
29+ Assert . True ( offset > 0 ) ;
30+ } ) ;
1831 }
1932
2033 [ Fact ]
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ DLL_EXPORT void InvokeNative(counterstrikesharp::fxNativeContext& context)
5555 if (context.nativeIdentifier == 0 ) return ;
5656
5757 if (context.nativeIdentifier != counterstrikesharp::hash_string_const (" QUEUE_TASK_FOR_FRAME" ) &&
58+ context.nativeIdentifier != counterstrikesharp::hash_string_const (" GET_SCHEMA_OFFSET" ) &&
5859 counterstrikesharp::globals::gameThreadId != std::this_thread::get_id ())
5960 {
6061 counterstrikesharp::ScriptContextRaw scriptContext (context);
You can’t perform that action at this time.
0 commit comments