Compare commits

...

24 Commits

Author SHA1 Message Date
metalgearsloth
50981ad1a1 Layered PlacementManager (#1403)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-01-11 22:42:54 +11:00
Pieter-Jan Briers
0cbfbeffae Revert "Analyzer to check if interfacemethods are explicitly marked as such" (#1499)
This reverts commit e603153016.
2021-01-11 12:26:23 +01:00
Paul Ritter
e603153016 Analyzer to check if interfacemethods are explicitly marked as such (#1477)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2021-01-11 12:14:26 +01:00
Pieter-Jan Briers
e7c417ca0c Remove a couple MiB of memory usage. 2021-01-11 10:58:42 +01:00
Pieter-Jan Briers
a3989f28eb Re-order exception handler in StatusHost to avoid blowing up in some cases ??? 2021-01-11 10:24:29 +01:00
Pieter-Jan Briers
38ace3c348 Fix exception with trying to place entities at... NaN?
This is still a bug but it should not cause an exception on the server
2021-01-11 10:24:29 +01:00
Ygg01
0e00170f45 Make RSI directions default to 1. (#1495)
Add some helper methods, made an `example.rsi` for testing.

Closes #1463
2021-01-11 18:12:34 +11:00
Pieter-Jan Briers
261ee96cad Make client connect 1 second faster.
Whoops.
2021-01-11 02:39:35 +01:00
Pieter-Jan Briers
2c851885db Fix ItemList not working correctly with scaling. 2021-01-11 02:06:25 +01:00
Pieter-Jan Briers
849be86455 Add launchauth command to bootstrap login tokens for connecting to live servers. 2021-01-10 23:55:01 +01:00
Pieter-Jan Briers
ffd5c120be Add PreserveBaseOverridesAttribute to sandbox whitelist.
Used by covariant returns.
2021-01-10 22:03:18 +01:00
Vera Aguilera Puerto
76b15dda70 Client-side addcompc/rmcompc (#1497) 2021-01-10 20:09:14 +01:00
Vera Aguilera Puerto
0bf7f519ad Adds client-side setinputcontext command (#1498) 2021-01-10 20:08:44 +01:00
Vera Aguilera Puerto
f97f325a36 Fixes sprite scale not being taken into account. (#1496)
* Fixes sprite scale not being taken into account.
- Only apply scale if length of scale vector not close or equal to 1.

* I blame Remie

* Fix vector maths
I should spend more time studying maths instead of contributing, to be fair.

* Remie no please nO
2021-01-10 19:53:04 +01:00
metalgearsloth
24315fa787 Avoid unnecessary EntMapIdChangedMessages (#1493)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-01-10 12:46:59 +11:00
Ygg01
792179657b Fix space in dotnet breaking windows builds (#1490)
Who would win?
Thirty developers
-OR-
One sneaky ` ` boi?

On windows default path to dotnet are `C:\Program Files`. Without quoting the
the command if it contains a space, it's going to break Windows builds that
install in `C:\Program Files`.
2021-01-08 13:53:42 +01:00
Paul
9b92bcf911 intermediate fix to garantuee people with dotnet in path to launch commpilerobustxaml 2021-01-05 12:15:03 +01:00
metalgearsloth
86e34ea27b Fix enum caching (#1485)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-01-05 16:17:20 +11:00
Clyybber
62cf778958 Fix build when dotnet is not in the PATH (#1483) 2021-01-04 20:25:43 +01:00
py01
5d667e44c3 Replaces AnchoredChanged C# event with a ComponentMessage (#1482)
Co-authored-by: py01 <pyronetics01@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2021-01-04 10:16:05 +01:00
metalgearsloth
6d84b8741c Cache enum references (#1480)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-01-03 03:45:02 +01:00
DrSmugleaf
d08ca59b75 Make RobustUnitTest register content cvars and set _isServer (#1481) 2021-01-03 03:44:12 +01:00
Pieter-Jan Briers
f06b046c1c Fix Content-Type not being set for status API. 2021-01-03 03:42:21 +01:00
Vera Aguilera Puerto
bb412a6906 Entity Timer SpawnTimer throws if entity is deleted. 2021-01-01 15:45:13 +01:00
25 changed files with 312 additions and 39 deletions

View File

@@ -53,8 +53,11 @@
DelaySign="$(DelaySign)"
UpdateBuildIndicator="$(IntermediateOutputPath)XAML/doot"/>
<PropertyGroup>
<DOTNET_HOST_PATH Condition="'$(DOTNET_HOST_PATH)' == ''">dotnet</DOTNET_HOST_PATH>
</PropertyGroup>
<Exec
Condition="'$(_RobustUseExternalMSBuild)' == 'true'"
Command="dotnet msbuild /nodereuse:false $(MSBuildProjectFile) /t:CompileRobustXaml /p:_RobustForceInternalMSBuild=true /p:Configuration=$(Configuration) /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:TargetFramework=$(TargetFramework) /p:BuildProjectReferences=false"/>
Command="&quot;$(DOTNET_HOST_PATH)&quot; msbuild /nodereuse:false $(MSBuildProjectFile) /t:CompileRobustXaml /p:_RobustForceInternalMSBuild=true /p:Configuration=$(Configuration) /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:TargetFramework=$(TargetFramework) /p:BuildProjectReferences=false"/>
</Target>
</Project>

View File

@@ -0,0 +1,72 @@
using JetBrains.Annotations;
using Robust.Client.Interfaces.Console;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
[UsedImplicitly]
internal sealed class AddCompCommand : IConsoleCommand
{
public string Command => "addcompc";
public string Description => "Adds a component to an entity on the client";
public string Help => "addcompc <uid> <componentName>";
public bool Execute(IDebugConsole shell, params string[] args)
{
if (args.Length != 2)
{
shell.AddLine("Wrong number of arguments");
return false;
}
var entityUid = EntityUid.Parse(args[0]);
var componentName = args[1];
var compManager = IoCManager.Resolve<IComponentManager>();
var compFactory = IoCManager.Resolve<IComponentFactory>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var entity = entityManager.GetEntity(entityUid);
var component = (Component) compFactory.GetComponent(componentName);
component.Owner = entity;
compManager.AddComponent(entity, component);
return false;
}
}
[UsedImplicitly]
internal sealed class RemoveCompCommand : IConsoleCommand
{
public string Command => "rmcompc";
public string Description => "Removes a component from an entity.";
public string Help => "rmcompc <uid> <componentName>";
public bool Execute(IDebugConsole shell, string[] args)
{
if (args.Length != 2)
{
shell.AddLine("Wrong number of arguments");
return false;
}
var entityUid = EntityUid.Parse(args[0]);
var componentName = args[1];
var compManager = IoCManager.Resolve<IComponentManager>();
var compFactory = IoCManager.Resolve<IComponentFactory>();
var registration = compFactory.GetRegistration(componentName);
compManager.RemoveComponent(entityUid, registration.Type);
return false;
}
}
}

View File

@@ -0,0 +1,69 @@
#if !FULL_RELEASE
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Robust.Client.Interfaces.Console;
using Robust.Client.Utility;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
internal sealed class LauncherAuthCommand : IConsoleCommand
{
public string Command => "launchauth";
public string Description => "Load authentication tokens from launcher data to aid in testing of live servers";
public string Help => "launchauth [account name]";
public bool Execute(IDebugConsole console, params string[] args)
{
var wantName = args.Length > 0 ? args[0] : null;
var basePath = Path.GetDirectoryName(UserDataDir.GetUserDataDir())!;
var cfgPath = Path.Combine(basePath, "launcher", "launcher_config.json");
var data = JsonSerializer.Deserialize<LauncherConfig>(File.ReadAllText(cfgPath))!;
var login = wantName != null
? data.Logins.FirstOrDefault(p => p.Username == wantName)
: data.Logins.FirstOrDefault();
if (login == null)
{
console.AddLine("Unable to find a matching login");
return false;
}
var token = login.Token.Token;
var userId = login.UserId;
var cfg = IoCManager.Resolve<IConfigurationManagerInternal>();
cfg.SetSecureCVar(CVars.AuthUserId, userId);
cfg.SetSecureCVar(CVars.AuthToken, token);
return false;
}
private sealed class LauncherConfig
{
[JsonInclude] [JsonPropertyName("logins")]
public LauncherLogin[] Logins = default!;
}
private sealed class LauncherLogin
{
[JsonInclude] public string Username = default!;
[JsonInclude] public string UserId = default!;
[JsonInclude] public LauncherToken Token = default!;
}
private sealed class LauncherToken
{
[JsonInclude] public string Token = default!;
}
}
}
#endif

View File

@@ -0,0 +1,35 @@
using JetBrains.Annotations;
using Robust.Client.Interfaces.Console;
using Robust.Client.Interfaces.Input;
using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
[UsedImplicitly]
public class SetInputContextCommand : IConsoleCommand
{
public string Command => "setinputcontext";
public string Description => "Sets the active input context.";
public string Help => "setinputcontext <context>";
public bool Execute(IDebugConsole console, params string[] args)
{
if (args.Length != 1)
{
console.AddLine("Invalid number of arguments!");
return false;
}
var inputMan = IoCManager.Resolve<IInputManager>();
if (!inputMan.Contexts.Exists(args[0]))
{
console.AddLine("Context not found!");
return false;
}
inputMan.Contexts.SetActiveContext(args[0]);
return false;
}
}
}

View File

@@ -991,6 +991,9 @@ namespace Robust.Client.GameObjects
var mRotation = Matrix3.CreateRotation(angle);
Matrix3.Multiply(ref mRotation, ref mOffset, out var transform);
// Only apply scale if needed.
if(!Scale.EqualsApprox(Vector2.One)) transform.Multiply(Matrix3.CreateScale(Scale));
transform.Multiply(worldTransform);
RenderInternal(drawingHandle, worldRotation, overrideDirection, transform);

View File

@@ -128,7 +128,8 @@ namespace Robust.Client.GameObjects.EntitySystems
if (!entity.TryGetComponent(out InputComponent? inputComp))
{
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity.Uid}, entProto={entity.Prototype}");
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity.Uid}, entProto={entity.Prototype}. Setting default \"{InputContextContainer.DefaultContextName}\" context...");
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
return;
}
@@ -138,7 +139,8 @@ namespace Robust.Client.GameObjects.EntitySystems
}
else
{
Logger.ErrorS("input.context", $"Unknown context: entId={entity.Uid}, entProto={entity.Prototype}, context={inputComp.ContextName}");
Logger.ErrorS("input.context", $"Unknown context: entId={entity.Uid}, entProto={entity.Prototype}, context={inputComp.ContextName}. . Setting default \"{InputContextContainer.DefaultContextName}\" context...");
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
}
}

View File

@@ -31,7 +31,7 @@
}
}
},
"required": ["name","directions"] //'delays' is marked as optional in the spec
"required": ["name"] //'delays' is marked as optional in the spec
}
},
"properties": {

View File

@@ -98,9 +98,9 @@ namespace Robust.Client.Placement
public bool Eraser { get; private set; }
/// <summary>
/// The texture we use to show from our placement manager to represent the entity to place
/// The texture we use to show from our placement manager to represent the entity to place
/// </summary>
public IDirectionalTextureProvider? CurrentBaseSprite { get; set; }
public List<IDirectionalTextureProvider>? CurrentTextures { get; set; }
/// <summary>
/// Which of the placement orientations we are trying to place with
@@ -311,7 +311,7 @@ namespace Robust.Client.Placement
{
PlacementChanged?.Invoke(this, EventArgs.Empty);
Hijack = null;
CurrentBaseSprite = null;
CurrentTextures = null;
CurrentPrototype = null;
CurrentPermission = null;
CurrentMode = null;
@@ -555,7 +555,7 @@ namespace Robust.Client.Placement
{
var prototype = _prototypeManager.Index<EntityPrototype>(templateName);
CurrentBaseSprite = SpriteComponent.GetPrototypeIcon(prototype, ResourceCache);
CurrentTextures = SpriteComponent.GetPrototypeTextures(prototype, ResourceCache).ToList();
CurrentPrototype = prototype;
IsActive = true;
@@ -563,8 +563,9 @@ namespace Robust.Client.Placement
private void PreparePlacementTile()
{
CurrentBaseSprite = ResourceCache
.GetResource<TextureResource>(new ResourcePath("/Textures/UserInterface/tilebuildoverlay.png")).Texture;
CurrentTextures = new List<IDirectionalTextureProvider>
{ResourceCache
.GetResource<TextureResource>(new ResourcePath("/Textures/UserInterface/tilebuildoverlay.png")).Texture};
IsActive = true;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Robust.Client.Graphics;
using Robust.Client.Graphics.ClientEye;
using Robust.Client.Graphics.Drawing;
@@ -28,9 +29,9 @@ namespace Robust.Client.Placement
public EntityCoordinates MouseCoords { get; set; }
/// <summary>
/// Texture resource to draw to represent the entity we are tryign to spawn
/// Texture resources to draw to represent the entity we are trying to spawn
/// </summary>
public Texture? SpriteToDraw { get; set; }
public List<Texture>? TexturesToDraw { get; set; }
/// <summary>
/// Color set to the ghost entity when it has a valid spawn position
@@ -85,12 +86,15 @@ namespace Robust.Client.Placement
public virtual void Render(DrawingHandleWorld handle)
{
if (SpriteToDraw == null)
if (TexturesToDraw == null)
{
SetSprite();
DebugTools.AssertNotNull(SpriteToDraw);
DebugTools.AssertNotNull(TexturesToDraw);
}
if (TexturesToDraw == null || TexturesToDraw.Count == 0)
return;
IEnumerable<EntityCoordinates> locationcollection;
switch (pManager.PlacementType)
{
@@ -108,13 +112,17 @@ namespace Robust.Client.Placement
break;
}
var size = SpriteToDraw!.Size;
var size = TexturesToDraw[0].Size;
foreach (var coordinate in locationcollection)
{
var worldPos = coordinate.ToMapPos(pManager.EntityManager);
var pos = worldPos - (size/(float)EyeManager.PixelsPerMeter) / 2f;
var color = IsValidPosition(coordinate) ? ValidPlaceColor : InvalidPlaceColor;
handle.DrawTexture(SpriteToDraw, pos, color);
foreach (var texture in TexturesToDraw)
{
handle.DrawTexture(texture, pos, color);
}
}
}
@@ -188,7 +196,10 @@ namespace Robust.Client.Placement
public void SetSprite()
{
SpriteToDraw = pManager.CurrentBaseSprite!.TextureFor(pManager.Direction);
if (pManager.CurrentTextures == null)
return;
TexturesToDraw = pManager.CurrentTextures.Select(o => o.TextureFor(pManager.Direction)).ToList();
}
/// <summary>

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Utility;
@@ -346,15 +345,25 @@ namespace Robust.Client.ResourceManagement
foreach (var stateObject in manifestJson["states"]!.Cast<JObject>())
{
var stateName = stateObject["name"]!.ToObject<string>()!;
var dirValue = stateObject["directions"]!.ToObject<int>();
RSI.State.DirectionType directions;
int dirValue;
var directions = dirValue switch
if (stateObject.TryGetValue("directions", out var dirJToken))
{
1 => RSI.State.DirectionType.Dir1,
4 => RSI.State.DirectionType.Dir4,
8 => RSI.State.DirectionType.Dir8,
_ => throw new RSILoadException($"Invalid direction: {dirValue}")
};
dirValue= dirJToken.ToObject<int>();
directions = dirValue switch
{
1 => RSI.State.DirectionType.Dir1,
4 => RSI.State.DirectionType.Dir4,
8 => RSI.State.DirectionType.Dir8,
_ => throw new RSILoadException($"Invalid direction: {dirValue} expected 1, 4 or 8")
};
}
else
{
dirValue = 1;
directions = RSI.State.DirectionType.Dir1;
}
// We can ignore selectors and flags for now,
// because they're not used yet!

View File

@@ -433,7 +433,7 @@ namespace Robust.Client.UserInterface.Controls
if (item.Region == null)
continue;
if (!item.Region.Value.Contains(args.RelativePosition))
if (!item.Region.Value.Contains(args.RelativePixelPosition))
continue;
if (item.Selectable && !item.Disabled)

View File

@@ -4,7 +4,7 @@ using JetBrains.Annotations;
namespace Robust.Client.Utility
{
public static class UserDataDir
internal static class UserDataDir
{
[Pure]
public static string GetUserDataDir()

View File

@@ -38,6 +38,7 @@ namespace Robust.Server.Console.Commands
}
}
[UsedImplicitly]
internal sealed class RemoveCompCommand : IClientCommand
{
public string Command => "rmcomp";

View File

@@ -11,6 +11,7 @@ using System.Linq;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network.Messages;
@@ -88,6 +89,12 @@ namespace Robust.Server.Placement
var coordinates = msg.EntityCoordinates;
if (!coordinates.IsValid(_entityManager))
{
Logger.WarningS("placement",
$"{session} tried to place {msg.ObjType} at invalid coordinate {coordinates}");
return;
}
/* TODO: Redesign permission system, or document what this is supposed to be doing
var permission = GetPermission(session.attachedEntity.Uid, alignRcv);

View File

@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Primitives;
@@ -68,8 +69,8 @@ namespace Robust.Server.ServerStatus
}
catch (Exception e)
{
apiContext.Respond("Internal Server Error", HttpStatusCode.InternalServerError);
_httpSawmill.Error($"Exception in StatusHost: {e}");
apiContext.Respond("Internal Server Error", HttpStatusCode.InternalServerError);
}
/*
@@ -234,12 +235,12 @@ namespace Robust.Server.ServerStatus
return serializer.Deserialize<T>(jsonReader);
}
public void Respond(string text, HttpStatusCode code = HttpStatusCode.OK, string contentType = "text/plain")
public void Respond(string text, HttpStatusCode code = HttpStatusCode.OK, string contentType = MediaTypeNames.Text.Plain)
{
Respond(text, (int) code, contentType);
}
public void Respond(string text, int code = 200, string contentType = "text/plain")
public void Respond(string text, int code = 200, string contentType = MediaTypeNames.Text.Plain)
{
_context.Response.StatusCode = code;
_context.Response.ContentType = contentType;
@@ -263,6 +264,8 @@ namespace Robust.Server.ServerStatus
{
using var streamWriter = new StreamWriter(_context.Response.OutputStream, EncodingHelpers.UTF8);
_context.Response.ContentType = MediaTypeNames.Application.Json;
using var jsonWriter = new JsonTextWriter(streamWriter);
JsonSerializer.Serialize(jsonWriter, jsonData);

View File

@@ -306,9 +306,14 @@ namespace Robust.Shared.Configuration
/// <inheritdoc />
public void SetCVar(string name, object value)
{
SetCVarInternal(name, value);
}
private void SetCVarInternal(string name, object value, bool allowSecure = false)
{
//TODO: Make flags work, required non-derpy net system.
if (_configVars.TryGetValue(name, out var cVar) && cVar.Registered && (cVar.Flags & CVar.SECURE) == 0)
if (_configVars.TryGetValue(name, out var cVar) && cVar.Registered && (allowSecure || (cVar.Flags & CVar.SECURE) == 0))
{
if (!Equals(cVar.OverrideValueParsed ?? cVar.Value, value))
{
@@ -348,6 +353,18 @@ namespace Robust.Shared.Configuration
throw new InvalidConfigurationException($"Trying to get unregistered variable '{name}'");
}
public void SetSecureCVar(string name, object value)
{
SetCVarInternal(name, value, allowSecure: true);
}
public void SetSecureCVar<T>(CVarDef<T> def, T value) where T : notnull
{
SetSecureCVar(def.Name, value);
}
public T GetCVar<T>(CVarDef<T> def) where T : notnull
{
return GetCVar<T>(def.Name);

View File

@@ -442,6 +442,7 @@ Types:
IsExternalInit: { All: True }
IsReadOnlyAttribute: { All: True }
IteratorStateMachineAttribute: { All: True }
PreserveBaseOverridesAttribute: { All: True }
RuntimeCompatibilityAttribute: { All: True }
RuntimeHelpers: { All: True }
TaskAwaiter: { All: True }

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Interfaces.Physics;
@@ -41,6 +41,7 @@ namespace Robust.Shared.GameObjects.Components
/// </summary>
bool Anchored { get; set; }
[Obsolete("Use AnchoredChangedMessage instead")]
event Action? AnchoredChanged;
bool Predict { get; set; }
@@ -344,11 +345,15 @@ namespace Robust.Shared.GameObjects.Components
return;
_anchored = value;
#pragma warning disable 618
AnchoredChanged?.Invoke();
#pragma warning restore 618
SendMessage(new AnchoredChangedMessage(Anchored));
Dirty();
}
}
[Obsolete("Use AnchoredChangedMessage instead")]
public event Action? AnchoredChanged;
[ViewVariables(VVAccess.ReadWrite)]
@@ -518,4 +523,14 @@ namespace Robust.Shared.GameObjects.Components
return !Anchored && Mass > 0;
}
}
public class AnchoredChangedMessage : ComponentMessage
{
public readonly bool Anchored;
public AnchoredChangedMessage(bool anchored)
{
Anchored = anchored;
}
}
}

View File

@@ -55,9 +55,6 @@ namespace Robust.Shared.GameObjects.Components.Timers
/// <param name="cancellationToken"></param>
public static void SpawnTimer(this IEntity entity, int milliseconds, Action onFired, CancellationToken cancellationToken = default)
{
if (entity.Deleted)
return;
entity
.EnsureComponent<TimerComponent>()
.Spawn(milliseconds, onFired, cancellationToken);

View File

@@ -583,7 +583,11 @@ namespace Robust.Shared.GameObjects.Components.Transform
internal void ChangeMapId(MapId newMapId)
{
if (newMapId == MapID)
return;
var oldMapId = MapID;
MapID = newMapId;
MapIdChanged(oldMapId);
UpdateChildMapIdsRecursive(MapID, Owner.EntityManager.ComponentManager);

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Reflection;
using Robust.Shared.Configuration;
namespace Robust.Shared.Interfaces.Configuration
{
@@ -9,6 +10,10 @@ namespace Robust.Shared.Interfaces.Configuration
void LoadCVarsFromAssembly(Assembly assembly);
T GetSecureCVar<T>(string name);
void SetSecureCVar(string name, object value);
void SetSecureCVar<T>(CVarDef<T> def, T value) where T : notnull;
void Initialize(bool isServer);
/// <summary>

View File

@@ -42,7 +42,7 @@ namespace Robust.Shared.Log
private const string LogBeforeLevel = AnsiFgDefault + "[";
private const string LogAfterLevel = AnsiFgDefault + "] ";
private readonly Stream _stream = new BufferedStream(System.Console.OpenStandardOutput(), 2 * 1024 * 1024);
private readonly Stream _stream = new BufferedStream(System.Console.OpenStandardOutput(), 128 * 1024);
private readonly StringBuilder _line = new(1024);

View File

@@ -663,7 +663,6 @@ namespace Robust.Shared.Network
try
{
await Task.Delay(1000);
await _serializer.Handshake(channel);
}
catch (TaskCanceledException)

View File

@@ -31,6 +31,8 @@ namespace Robust.Shared.Reflection
private readonly Dictionary<string, Type> _looseTypeCache = new();
private readonly Dictionary<string, Enum> _enumCache = new();
/// <inheritdoc />
public IEnumerable<Type> GetAllChildren<T>(bool inclusive = false)
{
@@ -179,8 +181,13 @@ namespace Robust.Shared.Reflection
}
reference = reference.Substring(5);
if (_enumCache.TryGetValue(reference, out @enum))
return true;
var dotIndex = reference.LastIndexOf('.');
var typeName = reference.Substring(0, dotIndex);
var value = reference.Substring(dotIndex + 1);
foreach (var assembly in assemblies)
@@ -193,6 +200,7 @@ namespace Robust.Shared.Reflection
}
@enum = (Enum) Enum.Parse(type, value);
_enumCache[reference] = @enum;
return true;
}
}

View File

@@ -52,15 +52,26 @@ namespace Robust.UnitTesting
assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));
assemblies.Add(Assembly.GetExecutingAssembly());
var configurationManager = IoCManager.Resolve<IConfigurationManagerInternal>();
configurationManager.Initialize(Project == UnitTestProject.Server);
foreach (var assembly in assemblies)
{
IoCManager.Resolve<IConfigurationManagerInternal>().LoadCVarsFromAssembly(assembly);
configurationManager.LoadCVarsFromAssembly(assembly);
}
var contentAssemblies = GetContentAssemblies();
foreach (var assembly in contentAssemblies)
{
configurationManager.LoadCVarsFromAssembly(assembly);
}
IoCManager.Resolve<IReflectionManager>().LoadAssemblies(assemblies);
var modLoader = IoCManager.Resolve<TestingModLoader>();
modLoader.Assemblies = GetContentAssemblies();
modLoader.Assemblies = contentAssemblies;
modLoader.TryLoadModulesFrom(ResourcePath.Root, "");
// Required components for the engine to work