Files
sbox-public/engine/Launcher/SboxServer/Launcher.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

80 lines
1.7 KiB
C#

using System;
using System.Threading.Tasks;
namespace Sandbox;
public static class Launcher
{
public static int Main()
{
var appSystem = new DedicatedServerAppSystem();
appSystem.Run();
return 0;
}
}
public class DedicatedServerAppSystem : AppSystem
{
Sandbox.Diagnostics.Logger Log = new Diagnostics.Logger( "Console" );
DedicatedServerConsole console;
public override void Init()
{
LoadSteamDll();
TestSystemRequirements();
base.Init();
CreateGame();
var createInfo = new AppSystemCreateInfo()
{
WindowTitle = "s&box server",
Flags = AppSystemFlags.IsDedicatedServer | AppSystemFlags.IsGameApp | AppSystemFlags.IsConsoleApp
};
InitGame( createInfo );
// No game specified, show some help
if ( !Environment.CommandLine.Contains( "game " ) )
{
PrintHelp();
}
// Redirecting console output (docker/wine/etc..) won't support this overlay, so don't bother with it
if ( !Console.IsOutputRedirected )
{
console = new DedicatedServerConsole();
console.Update();
}
}
protected override bool RunFrame()
{
console?.Update();
return base.RunFrame();
}
public override void Shutdown()
{
base.Shutdown();
}
void PrintHelp()
{
Log.Info( "Welcome to the s&box dedicated server. This is currently a work in progress." );
Log.Info( "Submit any issues to https://github.com/facepunch/sbox-issues" );
Log.Info( "" );
Log.Info( "game <gameident> - load a game" );
Log.Info( "game <gameident> <mapident> - load a game with a map" );
Log.Info( "find <text> - find a concommand or convar" );
Log.Info( "kick <id> - kick a player by name or steam id" );
Log.Info( "status - current game status" );
Log.Info( "quit - quit" );
Log.Info( "" );
}
}