Skip to content

Commit

Permalink
Revert "Fix UninitializedSaveTest prototypes (#16144)"
Browse files Browse the repository at this point in the history
This reverts commit 9094727.
  • Loading branch information
AJCM-git authored May 6, 2023
1 parent c1dfb43 commit acadc4c
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 72 deletions.
75 changes: 59 additions & 16 deletions Content.IntegrationTests/Tests/PrototypeSaveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,64 @@ public sealed class PrototypeSaveTest
{
"Singularity", // physics collision uses "AllMask" (-1). The flag serializer currently fails to save this because this features un-named bits.
"constructionghost",

// These ones are from the serialization change to alwayswrite.
// These should NOT be added to.
// 99% of these are going to be changing the physics bodytype (where the entity is anchored)
// or some ambientsound change.
"GasVentScrubber",
"GasPassiveVent",
"CableHV",
"ParticleAcceleratorFuelChamberUnfinished",
"ComfyChair",
"PlasticFlapsOpaque",
"ParticleAcceleratorEmitterRightUnfinished",
"PlasticFlapsAirtightClear",
"SignalControlledValve",
"SignalControlledValve",
"GasPipeTJunction",
"GasFilter",
"GasOutletInjector",
"GasPressurePump",
"SurveillanceWirelessCameraAnchoredEntertainment",
"GasPort",
"Chair",
"GasMixer",
"ParticleAcceleratorPowerBoxUnfinished",
"GasValve",
"Thruster",
"BoxingBell",
"CableApcExtension",
"PlasticFlapsClear",
"ClothingBackpackChameleon",
"AMEControllerUnanchored",
"GasPipeFourway",
"NuclearBomb",
"PlasticFlapsAirtightOpaque",
"ParticleAcceleratorControlBoxUnfinished",
"GasPipeHalf",
"GasVolumePump",
"ParticleAcceleratorEmitterLeftUnfinished",
"GasMixerFlipped",
"ToiletDirtyWater",
"GasPipeBend",
"ParticleAcceleratorEndCapUnfinished",
"GasPipeStraight",
"MachineFrameDestroyed",
"ChairPilotSeat",
"VehicleJanicartDestroyed",
"Gyroscope",
"ParticleAcceleratorEmitterCenterUnfinished",
"ToiletEmpty",
"GasPassiveGate",
"CableMV",
"ClothingBackpackChameleonFill",
"GasDualPortVentPump",
"GasVentPump",
"PressureControlledValve",
"GasFilterFlipped",
"SurveillanceWirelessCameraAnchoredConstructed",

};

[Test]
Expand Down Expand Up @@ -69,7 +127,7 @@ await server.WaitPost(() =>

grid = mapManager.CreateGrid(mapId);

var tileDefinition = tileDefinitionManager["FloorSteel"]; // Wires n such disable ambiance while under the floor
var tileDefinition = tileDefinitionManager["UnderPlating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = grid.ToCoordinates();

Expand Down Expand Up @@ -110,7 +168,6 @@ await server.WaitAssertion(() =>
foreach (var prototype in prototypes)
{
uid = entityMan.SpawnEntity(prototype.ID, testLocation);
context.Prototype = prototype;

// get default prototype data
Dictionary<string, MappingDataNode> protoData = new();
Expand All @@ -120,11 +177,9 @@ await server.WaitAssertion(() =>

foreach (var (compType, comp) in prototype.Components)
{
context.WritingComponent = compType;
protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, alwaysWrite: true, context: context));
}

context.WritingComponent = string.Empty;
context.WritingReadingPrototypes = false;
}
catch (Exception e)
Expand All @@ -147,7 +202,6 @@ await server.WaitAssertion(() =>
MappingDataNode compMapping;
try
{
context.WritingComponent = compName;
compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, alwaysWrite: true, context: context);
}
catch (Exception e)
Expand Down Expand Up @@ -192,9 +246,6 @@ private sealed class TestEntityUidContext : ISerializationContext,
public SerializationManager.SerializerProvider SerializerProvider { get; }
public bool WritingReadingPrototypes { get; set; }

public string WritingComponent = string.Empty;
public EntityPrototype Prototype = default!;

public TestEntityUidContext()
{
SerializerProvider = new();
Expand All @@ -211,14 +262,6 @@ public DataNode Write(ISerializationManager serializationManager, EntityUid valu
IDependencyCollection dependencies, bool alwaysWrite = false,
ISerializationContext? context = null)
{
if (WritingComponent != "Transform" && !Prototype.NoSpawn)
{
// Maybe this will be necessary in the future, but at the moment it just indicates that there is some
// issue, like a non-nullable entityUid data-field. If a component MUST have an entity uid to work with,
// then the prototype very likely has to be a no-spawn entity that is never meant to be directly spawned.
Assert.Fail($"Uninitialized entities should not be saving entity Uids. Component: {WritingComponent}. Prototype: {Prototype.ID}");
}

return new ValueDataNode(value.ToString());
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Dragon/Components/DragonRiftComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed class DragonRiftComponent : SharedDragonRiftComponent
/// <summary>
/// Dragon that spawned this rift.
/// </summary>
[DataField("dragon")] public EntityUid? Dragon;
[DataField("dragon")] public EntityUid Dragon;

/// <summary>
/// How long the rift has been active.
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Dragon/DragonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private void OnRiftShutdown(EntityUid uid, DragonRiftComponent component, Compon

// We can't predict the rift being destroyed anyway so no point adding weakened to shared.
dragon.WeakenedAccumulator = dragon.WeakenedDuration;
_movement.RefreshMovementSpeedModifiers(component.Dragon.Value);
_popupSystem.PopupEntity(Loc.GetString("carp-rift-destroyed"), component.Dragon.Value, component.Dragon.Value);
_movement.RefreshMovementSpeedModifiers(component.Dragon);
_popupSystem.PopupEntity(Loc.GetString("carp-rift-destroyed"), component.Dragon, component.Dragon);
}
}

Expand Down
34 changes: 17 additions & 17 deletions Content.Server/Lightning/LightningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ private void OnRemove(EntityUid uid, LightningComponent component, ComponentRemo

private void OnCollide(EntityUid uid, LightningComponent component, ref StartCollideEvent args)
{
if (!TryComp<BeamComponent>(uid, out var lightningBeam)
|| !TryComp<BeamComponent>(lightningBeam.VirtualBeamController, out var beamController))
if (!TryComp<BeamComponent>(uid, out var lightningBeam) || !TryComp<BeamComponent>(lightningBeam.VirtualBeamController, out var beamController))
{
return;
}

if (!component.CanArc && beamController.CreatedBeams.Count < component.MaxTotalArcs)
return;
if (component.CanArc)
{
while (beamController.CreatedBeams.Count < component.MaxTotalArcs)
{
Arc(component, args.OtherFixture.Body.Owner, lightningBeam.VirtualBeamController.Value);

Arc(component, args.OtherEntity, lightningBeam.VirtualBeamController.Value);
var spriteState = LightningRandomizer();

if (component.ArcTarget == null)
return;
component.ArcTargets.Add(args.OtherFixture.Body.Owner);
component.ArcTargets.Add(component.ArcTarget);

var spriteState = LightningRandomizer();
component.ArcTargets.Add(args.OtherEntity);
component.ArcTargets.Add(component.ArcTarget.Value);

_beam.TryCreateBeam(
args.OtherEntity,
component.ArcTarget.Value,
component.LightningPrototype,
spriteState,
controller: lightningBeam.VirtualBeamController.Value);
_beam.TryCreateBeam(args.OtherFixture.Body.Owner, component.ArcTarget, component.LightningPrototype, spriteState, controller: lightningBeam.VirtualBeamController.Value);

//Break from this loop so other created bolts can collide and arc
break;
}
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class SharedLightningComponent : Component
/// The target that the lightning will Arc to.
/// </summary>
[DataField("arcTarget")]
public EntityUid? ArcTarget;
public EntityUid ArcTarget;

/// <summary>
/// How far should this lightning go?
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Back/specific.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
tags: [] # ignore "WhitelistChameleon" tag
- type: Sprite
sprite: Clothing/Back/Backpacks/backpack.rsi
netsync: false
- type: Clothing
sprite: Clothing/Back/Backpacks/backpack.rsi
- type: ChameleonClothing
slot: [back]
default: ClothingBackpack
Expand Down
5 changes: 0 additions & 5 deletions Resources/Prototypes/Entities/Effects/lightning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
name: lightning
id: Lightning
parent: BaseLightning
noSpawn: true
components:
- type: Lightning
canArc: true
Expand All @@ -43,7 +42,6 @@
name: spooky lightning
id: LightningRevenant
parent: BaseLightning
noSpawn: true
components:
- type: Sprite
sprite: /Textures/Effects/lightning.rsi
Expand All @@ -67,7 +65,6 @@
name: charged lightning
id: ChargedLightning
parent: BaseLightning
noSpawn: true
components:
- type: Sprite
sprite: /Textures/Effects/lightning.rsi
Expand All @@ -86,7 +83,6 @@
name: supercharged lightning
id: SuperchargedLightning
parent: ChargedLightning
noSpawn: true
components:
- type: Sprite
sprite: /Textures/Effects/lightning.rsi
Expand All @@ -112,7 +108,6 @@
name: hypercharged lightning
id: HyperchargedLightning
parent: ChargedLightning
noSpawn: true
components:
- type: Sprite
sprite: /Textures/Effects/lightning.rsi
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Devices/nuke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
noRot: true
state: nuclearbomb_base
- type: Physics
bodyType: Static
bodyType: Dynamic
- type: Fixtures
fixtures:
fix1:
Expand Down
6 changes: 0 additions & 6 deletions Resources/Prototypes/Entities/Structures/Furniture/chairs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
components:
- type: Transform
anchored: true
- type: Physics
bodyType: Static
- type: Anchorable
- type: Rotatable
- type: Sprite
Expand Down Expand Up @@ -130,8 +128,6 @@
components:
- type: Transform
anchored: true
- type: Physics
bodyType: Static
- type: Anchorable
- type: Rotatable
- type: Sprite
Expand All @@ -148,8 +144,6 @@
components:
- type: Transform
anchored: true
- type: Physics
bodyType: Static
- type: Anchorable
- type: Rotatable
- type: Sprite
Expand Down
2 changes: 0 additions & 2 deletions Resources/Prototypes/Entities/Structures/Furniture/toilet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
maxVol: 250
- type: Transform
anchored: true
- type: Physics
bodyType: Static
- type: Construction
graph: Toilet
node: toilet
Expand Down
2 changes: 0 additions & 2 deletions Resources/Prototypes/Entities/Structures/Machines/frame.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
- type: Transform
anchored: true
noRot: true
- type: Physics
bodyType: Static
- type: Construction
graph: Machine
node: destroyedMachineFrame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
- type: Anchorable
- type: Transform
anchored: true
- type: Physics
bodyType: Static
- type: Sprite
noRot: true
sprite: Structures/monitors.rsi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
graph: GasBinary
node: valve
- type: AmbientSound
enabled: true
enabled: false
volume: -9
range: 5
sound:
Expand Down Expand Up @@ -229,7 +229,7 @@
graph: GasBinary
node: signalvalve
- type: AmbientSound
enabled: true
enabled: false
volume: -9
range: 5
sound:
Expand Down Expand Up @@ -313,8 +313,6 @@
!type:PipeNode
nodeGroupID: Pipe
pipeDirection: South
- type: AmbientSound
enabled: true

- type: entity
parent: [ BaseMachine, ConstructibleMachine ]
Expand Down Expand Up @@ -357,7 +355,7 @@
- type: AtmosDevice
- type: AtmosPipeColor
- type: AmbientSound
enabled: true
enabled: false
volume: -9
range: 5
sound:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
- Pipe
- type: Physics
canCollide: false
bodyType: static
- type: AmbientSound
enabled: false
volume: -15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
node: ventpump
- type: VentCritterSpawnLocation
- type: AmbientSound
enabled: true
enabled: false
volume: -12
range: 5
sound:
Expand Down Expand Up @@ -171,7 +171,7 @@
graph: GasUnary
node: ventscrubber
- type: AmbientSound
enabled: true
enabled: false
volume: -12
range: 5
sound:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
suffix: Unfinished
description: This controls the density of the particles. It looks unfinished.
components:
- type: Physics
bodyType: Dynamic
- type: Sprite
sprite: Structures/Power/Generation/PA/control_box.rsi
- type: Construction
Expand Down
Loading

0 comments on commit acadc4c

Please sign in to comment.