mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-04 04:18:27 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using static Facepunch.Constants;
|
|
|
|
namespace Facepunch.Steps;
|
|
|
|
internal class NvPatch( string name ) : Step( name )
|
|
{
|
|
protected override ExitCode RunInternal()
|
|
{
|
|
string rootDir = Directory.GetCurrentDirectory();
|
|
string nvpatchPath = Path.Combine( rootDir, "engine", "ThirdParty", "nvpatch", "nvpatch.exe" );
|
|
|
|
try
|
|
{
|
|
if ( !File.Exists( nvpatchPath ) )
|
|
{
|
|
Log.Error( $"Error: NVPatch executable not found at {nvpatchPath}" );
|
|
return ExitCode.Failure;
|
|
}
|
|
|
|
Log.Info( "Step 1: Running nvpatch on sbox.exe" );
|
|
string sboxPath = Path.Combine( rootDir, "game", "sbox.exe" );
|
|
if ( !RunNvPatch( nvpatchPath, sboxPath ) )
|
|
return ExitCode.Failure;
|
|
|
|
Log.Info( "Step 2: Running nvpatch on sbox-dev.exe" );
|
|
string sboxDevPath = Path.Combine( rootDir, "game", "sbox-dev.exe" );
|
|
if ( !RunNvPatch( nvpatchPath, sboxDevPath ) )
|
|
return ExitCode.Failure;
|
|
|
|
Console.WriteLine( "NVPatch operations completed successfully!" );
|
|
return ExitCode.Success;
|
|
}
|
|
catch ( Exception ex )
|
|
{
|
|
Log.Error( $"NVPatch operations failed with error: {ex}" );
|
|
return ExitCode.Failure;
|
|
}
|
|
}
|
|
|
|
static bool RunNvPatch( string nvpatchPath, string targetExePath )
|
|
{
|
|
if ( !File.Exists( targetExePath ) )
|
|
{
|
|
Log.Warning( $"Warning: Target executable not found at {targetExePath}" );
|
|
Log.Warning( "Skipping this nvpatch operation." );
|
|
return true;
|
|
}
|
|
|
|
return Utility.RunProcess( nvpatchPath, $"--enable \"{targetExePath}\"", null );
|
|
}
|
|
}
|