Fix misc construction bugs (#15600)
This commit is contained in:
@@ -14,11 +14,12 @@ namespace Content.Server.Construction.Completions
|
|||||||
[DataField("container")] public string Container { get; private set; } = string.Empty;
|
[DataField("container")] public string Container { get; private set; } = string.Empty;
|
||||||
|
|
||||||
// TODO use or generalize ConstructionSystem.ChangeEntity();
|
// TODO use or generalize ConstructionSystem.ChangeEntity();
|
||||||
|
// TODO pass in node/edge & graph ID for better error logs.
|
||||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Computer entity {uid} did not have a container manager! Aborting build computer action.");
|
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have a container manager! Aborting build computer action.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,20 +27,21 @@ namespace Content.Server.Construction.Completions
|
|||||||
|
|
||||||
if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager))
|
if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Computer entity {uid} did not have the specified '{Container}' container! Aborting build computer action.");
|
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have the specified '{Container}' container! Aborting build computer action.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.ContainedEntities.Count != 1)
|
if (container.ContainedEntities.Count != 1)
|
||||||
{
|
{
|
||||||
Logger.Warning($"Computer entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
|
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var board = container.ContainedEntities[0];
|
var board = container.ContainedEntities[0];
|
||||||
|
|
||||||
if (!entityManager.TryGetComponent(board, out ComputerBoardComponent? boardComponent))
|
if (!entityManager.TryGetComponent(board, out ComputerBoardComponent? boardComponent))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Computer entity {uid} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
|
Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Content.Server.Construction
|
|||||||
|
|
||||||
if (step == null)
|
if (step == null)
|
||||||
{
|
{
|
||||||
_sawmill.Warning($"Called {nameof(HandleEdge)} on entity {uid} but the current state is not valid for that!");
|
_sawmill.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
|
||||||
return HandleResult.False;
|
return HandleResult.False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +163,10 @@ namespace Content.Server.Construction
|
|||||||
{
|
{
|
||||||
// Edge finished!
|
// Edge finished!
|
||||||
PerformActions(uid, user, edge.Completed);
|
PerformActions(uid, user, edge.Completed);
|
||||||
|
|
||||||
|
if (construction.Deleted)
|
||||||
|
return HandleResult.True;
|
||||||
|
|
||||||
construction.TargetEdgeIndex = null;
|
construction.TargetEdgeIndex = null;
|
||||||
construction.EdgeIndex = null;
|
construction.EdgeIndex = null;
|
||||||
construction.StepIndex = 0;
|
construction.StepIndex = 0;
|
||||||
@@ -470,28 +474,17 @@ namespace Content.Server.Construction
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// temporary code for debugging a grafana exception. Something is fishy with the girder graph.
|
|
||||||
object? prev = null;
|
|
||||||
var queued = string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name));
|
|
||||||
|
|
||||||
// Handle all queued interactions!
|
// Handle all queued interactions!
|
||||||
while (construction.InteractionQueue.TryDequeue(out var interaction))
|
while (construction.InteractionQueue.TryDequeue(out var interaction))
|
||||||
{
|
{
|
||||||
if (construction.Deleted)
|
if (construction.Deleted)
|
||||||
{
|
{
|
||||||
// I suspect the error might just happen if two users try to deconstruction or otherwise modify an entity at the exact same tick?
|
|
||||||
// In which case this isn't really an error, but should just be a `if (deleted) -> break`
|
|
||||||
// But might as well verify this.
|
|
||||||
|
|
||||||
_sawmill.Error($"Construction component was deleted while still processing interactions." +
|
_sawmill.Error($"Construction component was deleted while still processing interactions." +
|
||||||
$"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
|
$"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
|
||||||
$"Previous: {prev?.GetType()?.Name ?? "null"}, " +
|
|
||||||
$"Next: {interaction.GetType().Name}, " +
|
$"Next: {interaction.GetType().Name}, " +
|
||||||
$"Initial Queue: {queued}, " +
|
|
||||||
$"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
|
$"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prev = interaction;
|
|
||||||
|
|
||||||
// We set validation to false because we actually want to perform the interaction here.
|
// We set validation to false because we actually want to perform the interaction here.
|
||||||
HandleEvent(uid, interaction, false, construction);
|
HandleEvent(uid, interaction, false, construction);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
[ImplicitDataDefinitionForInheritors]
|
[ImplicitDataDefinitionForInheritors]
|
||||||
public interface IGraphAction
|
public interface IGraphAction
|
||||||
{
|
{
|
||||||
|
// TODO pass in node/edge & graph ID for better error logs.
|
||||||
void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager);
|
void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,11 +301,6 @@
|
|||||||
entity: WallSolidRust
|
entity: WallSolidRust
|
||||||
edges:
|
edges:
|
||||||
- to: wall
|
- to: wall
|
||||||
completed:
|
|
||||||
- !type:SpawnPrototype
|
|
||||||
prototype: WallSolid
|
|
||||||
amount: 1
|
|
||||||
- !type:DeleteEntity {}
|
|
||||||
steps:
|
steps:
|
||||||
- tool: Welding
|
- tool: Welding
|
||||||
doAfter: 5
|
doAfter: 5
|
||||||
|
|||||||
@@ -65,7 +65,6 @@
|
|||||||
- !type:SpawnPrototype
|
- !type:SpawnPrototype
|
||||||
prototype: SheetGlass1
|
prototype: SheetGlass1
|
||||||
amount: 5
|
amount: 5
|
||||||
- !type:DeleteEntity { }
|
|
||||||
steps:
|
steps:
|
||||||
- tool: Screwing
|
- tool: Screwing
|
||||||
doAfter: 2
|
doAfter: 2
|
||||||
@@ -163,7 +162,6 @@
|
|||||||
- !type:SpawnPrototype
|
- !type:SpawnPrototype
|
||||||
prototype: SheetRGlass1
|
prototype: SheetRGlass1
|
||||||
amount: 5
|
amount: 5
|
||||||
- !type:DeleteEntity { }
|
|
||||||
steps:
|
steps:
|
||||||
- tool: Screwing
|
- tool: Screwing
|
||||||
doAfter: 4
|
doAfter: 4
|
||||||
|
|||||||
Reference in New Issue
Block a user