From 97640c17e28434b9b4cb6b4d7daa3f404b94b1b3 Mon Sep 17 00:00:00 2001 From: moonheart08 Date: Mon, 19 Feb 2024 05:42:24 -0600 Subject: [PATCH] Update template. --- Content.Client/Content.Client.csproj | 2 - Content.Packaging/Content.Packaging.csproj | 3 +- Content.Packaging/ContentPackaging.cs | 5 ++- Content.Packaging/README | 10 +++++ Content.Server/Content.Server.csproj | 1 - Content.Server/EntryPoint.cs | 4 -- Content.Server/LocalHostConGroup.cs | 49 ++++++++++++++++++---- Content.Shared/Content.Shared.csproj | 4 +- RobustTemplate.sln | 22 +++++----- RobustToolbox | 2 +- 10 files changed, 68 insertions(+), 34 deletions(-) create mode 100644 Content.Packaging/README diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index 4d3d8e8..ded98b1 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -13,7 +13,6 @@ Debug;Release;Tools;DebugOpt AnyCPU - @@ -25,6 +24,5 @@ - diff --git a/Content.Packaging/Content.Packaging.csproj b/Content.Packaging/Content.Packaging.csproj index 1b5acec..071cf12 100644 --- a/Content.Packaging/Content.Packaging.csproj +++ b/Content.Packaging/Content.Packaging.csproj @@ -3,6 +3,7 @@ Exe enable enable + True @@ -10,4 +11,4 @@ - + \ No newline at end of file diff --git a/Content.Packaging/ContentPackaging.cs b/Content.Packaging/ContentPackaging.cs index 41bfeec..3751942 100644 --- a/Content.Packaging/ContentPackaging.cs +++ b/Content.Packaging/ContentPackaging.cs @@ -3,6 +3,7 @@ using Robust.Packaging.AssetProcessing; namespace Content.Packaging; +// Used both for manual packaging, and server-provided automatic packaging. public static class ContentPackaging { public static async Task WriteResources( @@ -18,12 +19,12 @@ public static class ContentPackaging var inputPass = graph.Input; - await RobustClientPackaging.WriteContentAssemblies( + await RobustSharedPackaging.WriteContentAssemblies( inputPass, contentDir, "Content.Client", new[] { "Content.Client", "Content.Shared" }, - cancel); + cancel: cancel); await RobustClientPackaging.WriteClientResources(contentDir, inputPass, cancel); diff --git a/Content.Packaging/README b/Content.Packaging/README new file mode 100644 index 0000000..d156020 --- /dev/null +++ b/Content.Packaging/README @@ -0,0 +1,10 @@ +Relatively barebones packaging script. Does not contain a server packaging script. +Packaging a (sandboxed) client is generally very easy, but the server is a bit more complex due to likely depending on assets unique to your project. +Here's a few notes to help: +- It's recommended to build specific to your target OS, especially if depending on natives (i.e. sqlite). +- If using hybrid ACZ, you will need to include a client package in the server package's root directory for it to use. +- RobustServerPackaging is your friend, but be aware it will specifically omit texture resources. +- Familiarize yourself with AssetGraph and RobustServerAssetGraph, it allows for asset preprocessing, postprocessing of the final build, etc. +- The default asset passes will automatically compute metadata for audio without actually including the audio files in the server build. This allows your server to know how long sound clips are. + +It is additionally recommended to properly configure StatusHost to use a custom provider. The default works, but cannot handle complex cases. \ No newline at end of file diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index 0f4044f..541abef 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -10,7 +10,6 @@ true Exe - diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index 31849fd..8258874 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -12,10 +12,6 @@ public sealed class EntryPoint : GameServer public override void Init() { base.Init(); - - // Configure ACZ correctly. - IoCManager.Resolve().SetAczInfo( - "Content.Client", new []{"Content.Client", "Content.Shared"}); var factory = IoCManager.Resolve(); diff --git a/Content.Server/LocalHostConGroup.cs b/Content.Server/LocalHostConGroup.cs index 8967ea7..d6b39a2 100644 --- a/Content.Server/LocalHostConGroup.cs +++ b/Content.Server/LocalHostConGroup.cs @@ -1,7 +1,12 @@ -using System.Net; +using System.Diagnostics; +using System.Net; using JetBrains.Annotations; using Robust.Server.Console; using Robust.Server.Player; +using Robust.Shared.Player; +using Robust.Shared.Toolshed; +using Robust.Shared.Toolshed.Errors; +using Robust.Shared.Utility; namespace Content.Server; @@ -10,32 +15,32 @@ namespace Content.Server; /// [UsedImplicitly] public sealed class LocalHostConGroup : IConGroupControllerImplementation, IPostInjectInit { - public bool CanCommand(IPlayerSession session, string cmdName) { + public bool CanCommand(ICommonSession session, string cmdName) { return IsLocal(session); } - public bool CanViewVar(IPlayerSession session) { + public bool CanViewVar(ICommonSession session) { return IsLocal(session); } - public bool CanAdminPlace(IPlayerSession session) { + public bool CanAdminPlace(ICommonSession session) { return IsLocal(session); } - public bool CanScript(IPlayerSession session) { + public bool CanScript(ICommonSession session) { return IsLocal(session); } - public bool CanAdminMenu(IPlayerSession session) { + public bool CanAdminMenu(ICommonSession session) { return IsLocal(session); } - public bool CanAdminReloadPrototypes(IPlayerSession session) { + public bool CanAdminReloadPrototypes(ICommonSession session) { return IsLocal(session); } - private static bool IsLocal(IPlayerSession player) { - var ep = player.ConnectedClient.RemoteEndPoint; + private static bool IsLocal(ICommonSession player) { + var ep = player.Channel.RemoteEndPoint; var addr = ep.Address; if (addr.IsIPv4MappedToIPv6) { addr = addr.MapToIPv4(); @@ -47,4 +52,30 @@ public sealed class LocalHostConGroup : IConGroupControllerImplementation, IPost void IPostInjectInit.PostInject() { IoCManager.Resolve().Implementation = this; } + + private record NotLocalError : IConError + { + public FormattedMessage DescribeInner() + { + return FormattedMessage.FromUnformatted("Not the local user, refusing!"); + } + + public string Expression { get; set; } + + public Vector2i? IssueSpan { get; set; } + + public StackTrace Trace { get; set; } + } + + public bool CheckInvokable(CommandSpec command, ICommonSession user, out IConError error) + { + if (!IsLocal(user)) + { + error = new NotLocalError(); + return false; + } + + error = null; + return true; + } } \ No newline at end of file diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index a1f8ce1..a1bcfc0 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -9,7 +9,6 @@ nullable enable - @@ -24,7 +23,6 @@ false - - + diff --git a/RobustTemplate.sln b/RobustTemplate.sln index 058010d..d1dfb5e 100644 --- a/RobustTemplate.sln +++ b/RobustTemplate.sln @@ -13,8 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RobustToolbox", "RobustTool EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Client", "RobustToolbox\Robust.Client\Robust.Client.csproj", "{2A829DE3-FCB2-4FEA-A6F3-B85122C8D11E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Physics", "RobustToolbox\Robust.Physics\Robust.Physics.csproj", "{97EBBD32-8980-4243-9F90-BC7075B3EC8F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Shared", "RobustToolbox\Robust.Shared\Robust.Shared.csproj", "{B4D5BABE-B7C5-4D73-9F8F-B5411866A1BE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Server", "RobustToolbox\Robust.Server\Robust.Server.csproj", "{68AA41CC-6095-4889-8114-B9E1B3F08B75}" @@ -61,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Packaging", "RobustT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Packaging", "Content.Packaging\Content.Packaging.csproj", "{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Serialization.Generator", "RobustToolbox\Robust.Serialization.Generator\Robust.Serialization.Generator.csproj", "{066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,14 +104,6 @@ Global {2A829DE3-FCB2-4FEA-A6F3-B85122C8D11E}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU {2A829DE3-FCB2-4FEA-A6F3-B85122C8D11E}.Tools|Any CPU.ActiveCfg = Tools|Any CPU {2A829DE3-FCB2-4FEA-A6F3-B85122C8D11E}.Tools|Any CPU.Build.0 = Tools|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Release|Any CPU.Build.0 = Release|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.DebugOpt|Any CPU.ActiveCfg = DebugOpt|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Tools|Any CPU.ActiveCfg = Tools|Any CPU - {97EBBD32-8980-4243-9F90-BC7075B3EC8F}.Tools|Any CPU.Build.0 = Tools|Any CPU {B4D5BABE-B7C5-4D73-9F8F-B5411866A1BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4D5BABE-B7C5-4D73-9F8F-B5411866A1BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4D5BABE-B7C5-4D73-9F8F-B5411866A1BE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -264,10 +256,17 @@ Global {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.ActiveCfg = Tools|Any CPU {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.Build.0 = Tools|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Debug|Any CPU.Build.0 = Debug|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Release|Any CPU.ActiveCfg = Release|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Release|Any CPU.Build.0 = Release|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.DebugOpt|Any CPU.ActiveCfg = Debug|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.DebugOpt|Any CPU.Build.0 = Debug|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Tools|Any CPU.ActiveCfg = Debug|Any CPU + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186}.Tools|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {2A829DE3-FCB2-4FEA-A6F3-B85122C8D11E} = {F5F87A9D-C304-4833-B107-D666317F6931} - {97EBBD32-8980-4243-9F90-BC7075B3EC8F} = {F5F87A9D-C304-4833-B107-D666317F6931} {B4D5BABE-B7C5-4D73-9F8F-B5411866A1BE} = {F5F87A9D-C304-4833-B107-D666317F6931} {68AA41CC-6095-4889-8114-B9E1B3F08B75} = {F5F87A9D-C304-4833-B107-D666317F6931} {09D5BA00-5066-4FDF-81C5-DC5E469DB11F} = {F5F87A9D-C304-4833-B107-D666317F6931} @@ -290,5 +289,6 @@ Global {BDF16A97-6269-4CA1-8D67-785DDD357B30} = {F5F87A9D-C304-4833-B107-D666317F6931} {81E28D82-BB23-44C7-AFFC-6CC1BB04CDF5} = {F5F87A9D-C304-4833-B107-D666317F6931} {D7F76B45-DAF9-49E1-A910-632DB0BDF471} = {F5F87A9D-C304-4833-B107-D666317F6931} + {066A19F7-7D5B-4C2B-BFC5-DE8C6FD3E186} = {F5F87A9D-C304-4833-B107-D666317F6931} EndGlobalSection EndGlobal diff --git a/RobustToolbox b/RobustToolbox index d4902a9..ef0bc1a 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit d4902a97148a35a422f9b0e9844951099575a3c5 +Subproject commit ef0bc1a2e4878eedc24dd6fedc0631be56aca072