Skip to content

Commit 930c949

Browse files
authored
Merge branch 'Facepunch:master' into test
2 parents da0b238 + 3be8514 commit 930c949

84 files changed

Lines changed: 4071 additions & 776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "animationsystem/ianimationsystemutils.h"
2+
3+
native accessor g_pAnimationSystemUtils
4+
{
5+
void MaintainDecodeCaches();
6+
}

engine/Launcher/CrashReporter/Program.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@ static async Task<int> Main( string[] args )
1919
var envelope = await Envelope.FromFileStreamAsync( stream );
2020

2121
var dsn = envelope.TryGetDsn();
22-
var event_id = envelope.TryGetEventId();
22+
var eventId = envelope.TryGetEventId();
2323

2424
// Submit to Sentry
2525
await SentryClient.SubmitEnvelopeAsync( dsn!, envelope );
2626

2727
// Submit to our own API
2828
var sentryEvent = envelope.TryGetEvent()?.TryParseAsJson();
29+
if ( sentryEvent is null )
30+
return 0;
2931

30-
if ( sentryEvent is not null )
32+
var tags = sentryEvent["tags"];
33+
var processName = sentryEvent["contexts"]?["process"]?["name"]?.GetValue<string>();
34+
35+
var payload = new
3136
{
32-
var tags = sentryEvent["tags"];
33-
34-
var payload = new
35-
{
36-
sentry_event_id = event_id,
37-
timestamp = sentryEvent["timestamp"],
38-
version = sentryEvent["release"],
39-
session_id = tags?["session_id"],
40-
activity_session_id = tags?["activity_session_id"],
41-
launch_guid = tags?["launch_guid"],
42-
gpu = tags?["gpu"],
43-
cpu = tags?["cpu"],
44-
mode = tags?["mode"],
45-
};
46-
47-
// Submit to our API
48-
using var client = new HttpClient();
49-
await client.PostAsJsonAsync( "https://services.facepunch.com/sbox/event/crash/1/", payload );
50-
}
37+
sentry_event_id = eventId,
38+
timestamp = sentryEvent["timestamp"],
39+
version = sentryEvent["release"],
40+
session_id = tags?["session_id"],
41+
activity_session_id = tags?["activity_session_id"],
42+
launch_guid = tags?["launch_guid"],
43+
gpu = tags?["gpu"],
44+
cpu = tags?["cpu"],
45+
mode = tags?["mode"],
46+
process_name = processName,
47+
};
48+
49+
using var client = new HttpClient();
50+
await client.PostAsJsonAsync( "https://services.facepunch.com/sbox/event/crash/1/", payload );
5151

5252
// Open browser to crash report page
53-
Process.Start( new ProcessStartInfo( $"https://sbox.game/crashes/{event_id}" ) { UseShellExecute = true } );
53+
Process.Start( new ProcessStartInfo( $"https://sbox.game/crashes/{eventId}" ) { UseShellExecute = true } );
5454

5555
return 0;
5656
}

engine/Sandbox.AppSystem/QtAppSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected virtual void OnShutdown()
9393
protected void LoadSteamDll()
9494
{
9595
var dllName = $"{Environment.CurrentDirectory}\\bin\\win64\\steam_api64.dll";
96-
if ( !NativeLibrary.TryLoad( dllName, out var steamApiDll ) )
96+
if ( !NativeLibrary.TryLoad( dllName, out steamApiDll ) )
9797
{
9898
throw new System.Exception( "Couldn't load bin/win64/steam_api64.dll" );
9999
}

engine/Sandbox.Compiling.Test/Data/code/blacklist/UsingStatic.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using static System.Runtime.InteropServices.MemoryMarshal;
23

34
class UsingStaticTest

engine/Sandbox.Compiling.Test/Tests/BlacklistTest.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,65 @@ namespace TestCompiler;
99
[TestClass]
1010
public partial class BlacklistTest
1111
{
12+
13+
[TestMethod]
14+
public async Task DefaultCompilerFailsWhitelist()
15+
{
16+
var codePath = System.IO.Path.GetFullPath( "data/code/blacklist" );
17+
var group = new CompileGroup( "TestWhitelist" );
18+
19+
var compiler = group.GetOrCreateCompiler( "test" );
20+
compiler.AddSourcePath( codePath );
21+
compiler.MarkForRecompile();
22+
await group.BuildAsync();
23+
24+
// Verify compilation failed due to whitelist violations
25+
var output = compiler.Output;
26+
Assert.IsNotNull( output );
27+
Assert.IsFalse( output.Successful, "Compiler should fail with default whitelist settings" );
28+
Assert.IsTrue( output.Diagnostics.Count > 0, "Should have diagnostics for whitelist violations" );
29+
}
30+
31+
[TestMethod]
32+
public async Task CompilerWithWhitelistFails()
33+
{
34+
var codePath = System.IO.Path.GetFullPath( "data/code/blacklist" );
35+
var group = new CompileGroup( "TestWhitelist" );
36+
37+
var compilerSettings = new Compiler.Configuration();
38+
compilerSettings.Whitelist = true;
39+
compilerSettings.Unsafe = false;
40+
41+
var compiler = group.CreateCompiler( "test", codePath, compilerSettings );
42+
await group.BuildAsync();
43+
44+
// Verify compilation failed due to whitelist being enabled
45+
var output = compiler.Output;
46+
Assert.IsNotNull( output );
47+
Assert.IsFalse( output.Successful, "Compiler should fail when whitelist is explicitly enabled" );
48+
Assert.IsTrue( output.Diagnostics.Count > 0, "Should have diagnostics for whitelist violations" );
49+
}
50+
51+
[TestMethod]
52+
public async Task CompilerWithoutWhitelistSucceeds()
53+
{
54+
var codePath = System.IO.Path.GetFullPath( "data/code/blacklist" );
55+
var group = new CompileGroup( "TestWhitelist" );
56+
57+
var compilerSettings = new Compiler.Configuration();
58+
compilerSettings.Whitelist = false;
59+
compilerSettings.Unsafe = true;
60+
61+
var compiler = group.CreateCompiler( "test", codePath, compilerSettings );
62+
await group.BuildAsync();
63+
64+
// Verify compilation succeeded with whitelist disabled
65+
var output = compiler.Output;
66+
Assert.IsNotNull( output );
67+
Assert.IsTrue( output.Successful, "Compiler should succeed when whitelist is disabled" );
68+
Assert.IsNull( output.Exception, "Should not have any exceptions" );
69+
}
70+
1271
[TestMethod]
1372
public async Task EndToEndBuildFailure()
1473
{

engine/Sandbox.Compiling/Compiler/Compiler.Build.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ CodeArchive BuildArchive( CompilerOutput output )
114114

115115
var archive = new CodeArchive();
116116
archive.CompilerName = Name;
117-
archive.Configuration = config;
117+
archive.Configuration = _config;
118118
output.Archive = archive;
119119

120-
var parseOptions = config.GetParseOptions();
120+
var parseOptions = _config.GetParseOptions();
121121

122122
//
123123
// References
@@ -217,7 +217,7 @@ void BuildInternal( IReadOnlyList<PortableExecutableReference> refs, CompilerOut
217217
// check for blacklisted methods/types used in compilation
218218
// we need this because the c# compiler will post optimize and use tons of blacklisted methods
219219
// run this after generators because they can contain user inputs too
220-
if ( config.Whitelist )
220+
if ( _config.Whitelist )
221221
{
222222
RunBlacklistWalker( compiler, output );
223223

@@ -242,7 +242,7 @@ void BuildInternal( IReadOnlyList<PortableExecutableReference> refs, CompilerOut
242242

243243
peStream.Seek( 0, System.IO.SeekOrigin.Begin );
244244

245-
if ( config.Whitelist && Group.AccessControl is { } access )
245+
if ( _config.Whitelist && Group.AccessControl is { } access )
246246
{
247247
var result = access.VerifyAssembly( peStream, out TrustedBinaryStream stream );
248248
if ( !result.Success )

engine/Sandbox.Compiling/Compiler/Compiler.SyntaxTree.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static SyntaxTree StripDisabledTextTrivia( SyntaxTree tree )
7878
/// </summary>
7979
private string GetReplacementDirective( string filePath )
8080
{
81-
foreach ( var pair in config.ReplacementDirectives )
81+
foreach ( var pair in _config.ReplacementDirectives )
8282
{
8383
if ( filePath.EndsWith( pair.Key, StringComparison.OrdinalIgnoreCase ) )
8484
return pair.Value;
@@ -108,7 +108,7 @@ void CollectFromFilesystem( BaseFileSystem filesystem, CodeArchive targetArchive
108108
var pathFolders = folderName.Split( new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries );
109109

110110
// is this ignored
111-
if ( pathFolders.Any( x => config.IgnoreFolders.Contains( x, StringComparer.OrdinalIgnoreCase ) ) )
111+
if ( pathFolders.Any( x => _config.IgnoreFolders.Contains( x, StringComparer.OrdinalIgnoreCase ) ) )
112112
return;
113113

114114
if ( pathFolders.Contains( "obj", StringComparer.OrdinalIgnoreCase ) )
@@ -156,7 +156,7 @@ void CollectFromFilesystem( BaseFileSystem filesystem, CodeArchive targetArchive
156156
{
157157
tree = CSharpSyntaxTree.ParseText( text: sourceText, options: fileOptions, path: physicalPath );
158158

159-
if ( config.StripDisabledTextTrivia )
159+
if ( _config.StripDisabledTextTrivia )
160160
tree = StripDisabledTextTrivia( tree );
161161
}
162162

@@ -168,7 +168,7 @@ void CollectFromFilesystem( BaseFileSystem filesystem, CodeArchive targetArchive
168168
var wrappedSourceText = SourceText.From( wrappedText, Encoding.UTF8 );
169169
tree = CSharpSyntaxTree.ParseText( wrappedSourceText, fileOptions, physicalPath );
170170

171-
if ( config.StripDisabledTextTrivia )
171+
if ( _config.StripDisabledTextTrivia )
172172
tree = StripDisabledTextTrivia( tree );
173173
}
174174

engine/Sandbox.Compiling/Compiler/Compiler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public sealed partial class Compiler : IDisposable
8585
/// <summary>
8686
/// The compiler's settings.
8787
/// </summary>
88-
private Compiler.Configuration config;
88+
private Compiler.Configuration _config = new();
8989

9090
/// <summary>
9191
/// Should only ever get called from CompileGroup.
@@ -134,13 +134,13 @@ internal void AddSourceLocation( BaseFileSystem fileSystem )
134134

135135
public void SetConfiguration( Compiler.Configuration newConfig )
136136
{
137-
config = newConfig;
137+
_config = newConfig;
138138
incrementalState.Reset();
139139
}
140140

141141
public Configuration GetConfiguration()
142142
{
143-
return config;
143+
return _config;
144144
}
145145

146146
/// <summary>

engine/Sandbox.Engine/Editor/Gizmos/Draw/Draw.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ public void ScreenText( string text, Vector2 pos, string font = "Roboto", float
209209
so.TextFlags = flags;
210210
}
211211

212+
/// <summary>
213+
/// Draw text with a text rendering scope for more text rendering customization.
214+
/// </summary>
215+
public void ScreenText( TextRendering.Scope text, Vector2 pos, TextFlag flags = TextFlag.LeftTop )
216+
{
217+
var so = Active.FindOrCreate( $"text", () => new TextSceneObject( World ) );
218+
219+
so.TextBlock = text;
220+
so.Transform = Transform.Zero;
221+
so.ScreenPos = pos;
222+
so.Bounds = BBox.FromPositionAndSize( 0, float.MaxValue );
223+
so.TextFlags = flags;
224+
}
225+
212226
/// <summary>
213227
/// Draw text on screen at a 3d position
214228
/// </summary>
@@ -220,6 +234,17 @@ public void ScreenText( string text, Vector3 worldPos, Vector2 offset, string fo
220234
ScreenText( text, screen + offset, font, size, flags );
221235
}
222236

237+
/// <summary>
238+
/// Draw text on screen at a 3d position with a text rendering scope for more text rendering customization.
239+
/// </summary>
240+
public void ScreenText( TextRendering.Scope text, Vector3 worldPos, Vector2 offset, TextFlag flags = TextFlag.LeftTop )
241+
{
242+
if ( !Camera.ToScreen( worldPos, out var screen ) )
243+
return;
244+
245+
ScreenText( text, screen + offset, flags );
246+
}
247+
223248
/// <summary>
224249
/// Draw a rect, on the screen
225250
/// </summary>
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11

2-
namespace Sandbox
2+
namespace Sandbox;
3+
4+
public partial class Model
35
{
4-
public partial class Model
5-
{
6-
/// <summary>
7-
/// Total bounds of all the meshes.
8-
/// </summary>
9-
public BBox Bounds => native.GetMeshBounds();
6+
/// <summary>
7+
/// Total bounds of all the meshes.
8+
/// </summary>
9+
public BBox Bounds => native.GetMeshBounds();
1010

11-
/// <summary>
12-
/// Total bounds of all the physics shapes.
13-
/// </summary>
14-
public BBox PhysicsBounds => native.GetPhysicsBounds();
11+
/// <summary>
12+
/// Total bounds of all the physics shapes.
13+
/// </summary>
14+
public BBox PhysicsBounds => native.GetPhysicsBounds();
1515

16-
/// <summary>
17-
/// Render view bounds.
18-
/// </summary>
19-
public BBox RenderBounds => native.GetModelRenderBounds();
20-
}
16+
/// <summary>
17+
/// Render view bounds.
18+
/// </summary>
19+
public BBox RenderBounds => native.GetModelRenderBounds();
2120
}

0 commit comments

Comments
 (0)