Random spontaneous cleanup PR (#25131)
* Use new Subs.CVar helper Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe. This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown. * Fix a bunch of warnings * More warning fixes * Use new DateTime serializer to get rid of ISerializationHooks in changelog code. * Get rid of some more ISerializationHooks for enums * And a little more * Apply suggestions from code review Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
committed by
GitHub
parent
d0c174388c
commit
68ce53ae17
@@ -269,7 +269,7 @@ namespace Content.Server.Construction
|
||||
|
||||
if (!TryComp(newEntity, out ConstructionComponent? construction))
|
||||
{
|
||||
_sawmill.Error($"Initial construction does not have a valid target entity! It is missing a ConstructionComponent.\nGraph: {graph.ID}, Initial Target: {edge.Target}, Ent. Prototype: {newEntityProto}\nCreated Entity {ToPrettyString(newEntity)} will be deleted.");
|
||||
Log.Error($"Initial construction does not have a valid target entity! It is missing a ConstructionComponent.\nGraph: {graph.ID}, Initial Target: {edge.Target}, Ent. Prototype: {newEntityProto}\nCreated Entity {ToPrettyString(newEntity)} will be deleted.");
|
||||
Del(newEntity); // Screw you, make proper construction graphs.
|
||||
return null;
|
||||
}
|
||||
@@ -321,14 +321,14 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(prototype, out ConstructionPrototype? constructionPrototype))
|
||||
{
|
||||
_sawmill.Error($"Tried to start construction of invalid recipe '{prototype}'!");
|
||||
Log.Error($"Tried to start construction of invalid recipe '{prototype}'!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_prototypeManager.TryIndex(constructionPrototype.Graph,
|
||||
out ConstructionGraphPrototype? constructionGraph))
|
||||
{
|
||||
_sawmill.Error(
|
||||
Log.Error(
|
||||
$"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{prototype}'!");
|
||||
return false;
|
||||
}
|
||||
@@ -394,21 +394,21 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(ev.PrototypeName, out ConstructionPrototype? constructionPrototype))
|
||||
{
|
||||
_sawmill.Error($"Tried to start construction of invalid recipe '{ev.PrototypeName}'!");
|
||||
Log.Error($"Tried to start construction of invalid recipe '{ev.PrototypeName}'!");
|
||||
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_prototypeManager.TryIndex(constructionPrototype.Graph, out ConstructionGraphPrototype? constructionGraph))
|
||||
{
|
||||
_sawmill.Error($"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
|
||||
Log.Error($"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
|
||||
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} user)
|
||||
{
|
||||
_sawmill.Error($"Client sent {nameof(TryStartStructureConstructionMessage)} with no attached entity!");
|
||||
Log.Error($"Client sent {nameof(TryStartStructureConstructionMessage)} with no attached entity!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Content.Server.Construction
|
||||
|
||||
if (step == null)
|
||||
{
|
||||
_sawmill.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
|
||||
Log.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
|
||||
return HandleResult.False;
|
||||
}
|
||||
|
||||
@@ -513,10 +513,10 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (construction.Deleted)
|
||||
{
|
||||
_sawmill.Error($"Construction component was deleted while still processing interactions." +
|
||||
$"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
|
||||
$"Next: {interaction.GetType().Name}, " +
|
||||
$"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
|
||||
Log.Error($"Construction component was deleted while still processing interactions." +
|
||||
$"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
|
||||
$"Next: {interaction.GetType().Name}, " +
|
||||
$"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ namespace Content.Server.Construction
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_sawmill.Error($"Caught exception while processing construction queue. Entity {ToPrettyString(uid)}, graph: {construction.Graph}");
|
||||
Log.Error($"Caught exception while processing construction queue. Entity {ToPrettyString(uid)}, graph: {construction.Graph}");
|
||||
_runtimeLog.LogException(e, $"{nameof(ConstructionSystem)}.{nameof(UpdateInteractions)}");
|
||||
Del(uid);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using Content.Server.Construction.Components;
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Tools;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -17,7 +16,6 @@ namespace Content.Server.Construction
|
||||
[UsedImplicitly]
|
||||
public sealed partial class ConstructionSystem : SharedConstructionSystem
|
||||
{
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
@@ -25,15 +23,10 @@ namespace Content.Server.Construction
|
||||
[Dependency] private readonly StackSystem _stackSystem = default!;
|
||||
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
|
||||
|
||||
private const string SawmillName = "Construction";
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_sawmill = _logManager.GetSawmill(SawmillName);
|
||||
|
||||
InitializeComputer();
|
||||
InitializeGraphs();
|
||||
InitializeGuided();
|
||||
@@ -50,13 +43,13 @@ namespace Content.Server.Construction
|
||||
var construction = ent.Comp;
|
||||
if (GetCurrentGraph(ent, construction) is not {} graph)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
||||
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
||||
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +58,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +69,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
||||
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user