Revert "Revert "Fix UninitializedSaveTest prototypes" (#16169)" (#16175)

* Revert "Revert "Fix UninitializedSaveTest prototypes" (#16169)"

This reverts commit de1613f7ef.

* Invert if statement
This commit is contained in:
Leon Friedrich
2023-05-07 06:30:51 +12:00
committed by GitHub
parent cebf021a12
commit e3793227b6
25 changed files with 71 additions and 103 deletions

View File

@@ -38,64 +38,6 @@ public sealed class PrototypeSaveTest
{ {
"Singularity", // physics collision uses "AllMask" (-1). The flag serializer currently fails to save this because this features un-named bits. "Singularity", // physics collision uses "AllMask" (-1). The flag serializer currently fails to save this because this features un-named bits.
"constructionghost", "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] [Test]
@@ -127,7 +69,7 @@ public sealed class PrototypeSaveTest
grid = mapManager.CreateGrid(mapId); grid = mapManager.CreateGrid(mapId);
var tileDefinition = tileDefinitionManager["UnderPlating"]; var tileDefinition = tileDefinitionManager["FloorSteel"]; // Wires n such disable ambiance while under the floor
var tile = new Tile(tileDefinition.TileId); var tile = new Tile(tileDefinition.TileId);
var coordinates = grid.ToCoordinates(); var coordinates = grid.ToCoordinates();
@@ -168,6 +110,7 @@ public sealed class PrototypeSaveTest
foreach (var prototype in prototypes) foreach (var prototype in prototypes)
{ {
uid = entityMan.SpawnEntity(prototype.ID, testLocation); uid = entityMan.SpawnEntity(prototype.ID, testLocation);
context.Prototype = prototype;
// get default prototype data // get default prototype data
Dictionary<string, MappingDataNode> protoData = new(); Dictionary<string, MappingDataNode> protoData = new();
@@ -177,9 +120,11 @@ public sealed class PrototypeSaveTest
foreach (var (compType, comp) in prototype.Components) 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)); protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, alwaysWrite: true, context: context));
} }
context.WritingComponent = string.Empty;
context.WritingReadingPrototypes = false; context.WritingReadingPrototypes = false;
} }
catch (Exception e) catch (Exception e)
@@ -202,6 +147,7 @@ public sealed class PrototypeSaveTest
MappingDataNode compMapping; MappingDataNode compMapping;
try try
{ {
context.WritingComponent = compName;
compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, alwaysWrite: true, context: context); compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, alwaysWrite: true, context: context);
} }
catch (Exception e) catch (Exception e)
@@ -246,6 +192,9 @@ public sealed class PrototypeSaveTest
public SerializationManager.SerializerProvider SerializerProvider { get; } public SerializationManager.SerializerProvider SerializerProvider { get; }
public bool WritingReadingPrototypes { get; set; } public bool WritingReadingPrototypes { get; set; }
public string WritingComponent = string.Empty;
public EntityPrototype Prototype = default!;
public TestEntityUidContext() public TestEntityUidContext()
{ {
SerializerProvider = new(); SerializerProvider = new();
@@ -262,6 +211,14 @@ public sealed class PrototypeSaveTest
IDependencyCollection dependencies, bool alwaysWrite = false, IDependencyCollection dependencies, bool alwaysWrite = false,
ISerializationContext? context = null) 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()); return new ValueDataNode(value.ToString());
} }

View File

@@ -10,7 +10,7 @@ public sealed class DragonRiftComponent : SharedDragonRiftComponent
/// <summary> /// <summary>
/// Dragon that spawned this rift. /// Dragon that spawned this rift.
/// </summary> /// </summary>
[DataField("dragon")] public EntityUid Dragon; [DataField("dragon")] public EntityUid? Dragon;
/// <summary> /// <summary>
/// How long the rift has been active. /// How long the rift has been active.

View File

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

View File

@@ -37,28 +37,28 @@ public sealed class LightningSystem : SharedLightningSystem
private void OnCollide(EntityUid uid, LightningComponent component, ref StartCollideEvent args) 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; return;
}
if (component.CanArc) if (!component.CanArc || beamController.CreatedBeams.Count >= component.MaxTotalArcs)
{ return;
while (beamController.CreatedBeams.Count < component.MaxTotalArcs)
{ Arc(component, args.OtherEntity, lightningBeam.VirtualBeamController.Value);
Arc(component, args.OtherFixture.Body.Owner, lightningBeam.VirtualBeamController.Value);
if (component.ArcTarget == null)
return;
var spriteState = LightningRandomizer(); var spriteState = LightningRandomizer();
component.ArcTargets.Add(args.OtherEntity);
component.ArcTargets.Add(component.ArcTarget.Value);
component.ArcTargets.Add(args.OtherFixture.Body.Owner); _beam.TryCreateBeam(
component.ArcTargets.Add(component.ArcTarget); args.OtherEntity,
component.ArcTarget.Value,
_beam.TryCreateBeam(args.OtherFixture.Body.Owner, component.ArcTarget, component.LightningPrototype, spriteState, controller: lightningBeam.VirtualBeamController.Value); component.LightningPrototype,
spriteState,
//Break from this loop so other created bolts can collide and arc controller: lightningBeam.VirtualBeamController.Value);
break;
}
}
} }
/// <summary> /// <summary>

View File

@@ -34,7 +34,7 @@ public abstract class SharedLightningComponent : Component
/// The target that the lightning will Arc to. /// The target that the lightning will Arc to.
/// </summary> /// </summary>
[DataField("arcTarget")] [DataField("arcTarget")]
public EntityUid ArcTarget; public EntityUid? ArcTarget;
/// <summary> /// <summary>
/// How far should this lightning go? /// How far should this lightning go?

View File

@@ -9,9 +9,6 @@
tags: [] # ignore "WhitelistChameleon" tag tags: [] # ignore "WhitelistChameleon" tag
- type: Sprite - type: Sprite
sprite: Clothing/Back/Backpacks/backpack.rsi sprite: Clothing/Back/Backpacks/backpack.rsi
netsync: false
- type: Clothing
sprite: Clothing/Back/Backpacks/backpack.rsi
- type: ChameleonClothing - type: ChameleonClothing
slot: [back] slot: [back]
default: ClothingBackpack default: ClothingBackpack

View File

@@ -34,6 +34,7 @@
name: lightning name: lightning
id: Lightning id: Lightning
parent: BaseLightning parent: BaseLightning
noSpawn: true
components: components:
- type: Lightning - type: Lightning
canArc: true canArc: true
@@ -42,6 +43,7 @@
name: spooky lightning name: spooky lightning
id: LightningRevenant id: LightningRevenant
parent: BaseLightning parent: BaseLightning
noSpawn: true
components: components:
- type: Sprite - type: Sprite
sprite: /Textures/Effects/lightning.rsi sprite: /Textures/Effects/lightning.rsi
@@ -65,6 +67,7 @@
name: charged lightning name: charged lightning
id: ChargedLightning id: ChargedLightning
parent: BaseLightning parent: BaseLightning
noSpawn: true
components: components:
- type: Sprite - type: Sprite
sprite: /Textures/Effects/lightning.rsi sprite: /Textures/Effects/lightning.rsi
@@ -83,6 +86,7 @@
name: supercharged lightning name: supercharged lightning
id: SuperchargedLightning id: SuperchargedLightning
parent: ChargedLightning parent: ChargedLightning
noSpawn: true
components: components:
- type: Sprite - type: Sprite
sprite: /Textures/Effects/lightning.rsi sprite: /Textures/Effects/lightning.rsi
@@ -108,6 +112,7 @@
name: hypercharged lightning name: hypercharged lightning
id: HyperchargedLightning id: HyperchargedLightning
parent: ChargedLightning parent: ChargedLightning
noSpawn: true
components: components:
- type: Sprite - type: Sprite
sprite: /Textures/Effects/lightning.rsi sprite: /Textures/Effects/lightning.rsi

View File

@@ -12,7 +12,7 @@
noRot: true noRot: true
state: nuclearbomb_base state: nuclearbomb_base
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Static
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:

View File

@@ -57,6 +57,8 @@
components: components:
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Anchorable - type: Anchorable
- type: Rotatable - type: Rotatable
- type: Sprite - type: Sprite
@@ -128,6 +130,8 @@
components: components:
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Anchorable - type: Anchorable
- type: Rotatable - type: Rotatable
- type: Sprite - type: Sprite
@@ -144,6 +148,8 @@
components: components:
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Anchorable - type: Anchorable
- type: Rotatable - type: Rotatable
- type: Sprite - type: Sprite

View File

@@ -27,6 +27,8 @@
maxVol: 250 maxVol: 250
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Construction - type: Construction
graph: Toilet graph: Toilet
node: toilet node: toilet

View File

@@ -124,6 +124,8 @@
- type: Transform - type: Transform
anchored: true anchored: true
noRot: true noRot: true
- type: Physics
bodyType: Static
- type: Construction - type: Construction
graph: Machine graph: Machine
node: destroyedMachineFrame node: destroyedMachineFrame

View File

@@ -49,6 +49,8 @@
- type: Anchorable - type: Anchorable
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Sprite - type: Sprite
noRot: true noRot: true
sprite: Structures/monitors.rsi sprite: Structures/monitors.rsi

View File

@@ -175,7 +175,7 @@
graph: GasBinary graph: GasBinary
node: valve node: valve
- type: AmbientSound - type: AmbientSound
enabled: false enabled: true
volume: -9 volume: -9
range: 5 range: 5
sound: sound:
@@ -229,7 +229,7 @@
graph: GasBinary graph: GasBinary
node: signalvalve node: signalvalve
- type: AmbientSound - type: AmbientSound
enabled: false enabled: true
volume: -9 volume: -9
range: 5 range: 5
sound: sound:
@@ -313,6 +313,8 @@
!type:PipeNode !type:PipeNode
nodeGroupID: Pipe nodeGroupID: Pipe
pipeDirection: South pipeDirection: South
- type: AmbientSound
enabled: true
- type: entity - type: entity
parent: [ BaseMachine, ConstructibleMachine ] parent: [ BaseMachine, ConstructibleMachine ]
@@ -355,7 +357,7 @@
- type: AtmosDevice - type: AtmosDevice
- type: AtmosPipeColor - type: AtmosPipeColor
- type: AmbientSound - type: AmbientSound
enabled: false enabled: true
volume: -9 volume: -9
range: 5 range: 5
sound: sound:

View File

@@ -42,6 +42,7 @@
- Pipe - Pipe
- type: Physics - type: Physics
canCollide: false canCollide: false
bodyType: static
- type: AmbientSound - type: AmbientSound
enabled: false enabled: false
volume: -15 volume: -15

View File

@@ -79,7 +79,7 @@
node: ventpump node: ventpump
- type: VentCritterSpawnLocation - type: VentCritterSpawnLocation
- type: AmbientSound - type: AmbientSound
enabled: false enabled: true
volume: -12 volume: -12
range: 5 range: 5
sound: sound:
@@ -171,7 +171,7 @@
graph: GasUnary graph: GasUnary
node: ventscrubber node: ventscrubber
- type: AmbientSound - type: AmbientSound
enabled: false enabled: true
volume: -12 volume: -12
range: 5 range: 5
sound: sound:

View File

@@ -45,8 +45,6 @@
suffix: Unfinished suffix: Unfinished
description: This controls the density of the particles. It looks unfinished. description: This controls the density of the particles. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/control_box.rsi sprite: Structures/Power/Generation/PA/control_box.rsi
- type: Construction - type: Construction

View File

@@ -46,8 +46,6 @@
suffix: Unfinished, Left suffix: Unfinished, Left
description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished. description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/emitter_left.rsi sprite: Structures/Power/Generation/PA/emitter_left.rsi
- type: Construction - type: Construction
@@ -60,8 +58,6 @@
suffix: Unfinished suffix: Unfinished
description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished. description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/emitter_center.rsi sprite: Structures/Power/Generation/PA/emitter_center.rsi
- type: Construction - type: Construction
@@ -74,8 +70,6 @@
suffix: Unfinished suffix: Unfinished
description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished. description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/emitter_right.rsi sprite: Structures/Power/Generation/PA/emitter_right.rsi
- type: Construction - type: Construction

View File

@@ -22,8 +22,6 @@
suffix: Unfinished suffix: Unfinished
description: Formally known as the Alpha Particle Generation Array. This is where Alpha particles are generated from [REDACTED]. It looks unfinished. description: Formally known as the Alpha Particle Generation Array. This is where Alpha particles are generated from [REDACTED]. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/end_cap.rsi sprite: Structures/Power/Generation/PA/end_cap.rsi
- type: Construction - type: Construction

View File

@@ -19,8 +19,6 @@
suffix: Unfinished suffix: Unfinished
description: Formally known as the EM Acceleration Chamber. This is where the Alpha particles are accelerated to radical speeds. It looks unfinished. description: Formally known as the EM Acceleration Chamber. This is where the Alpha particles are accelerated to radical speeds. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/fuel_chamber.rsi sprite: Structures/Power/Generation/PA/fuel_chamber.rsi
- type: Construction - type: Construction

View File

@@ -25,8 +25,6 @@
suffix: Unfinished suffix: Unfinished
description: Formally known as the Particle Focusing EM Lens. This uses electromagnetic waves to focus the Alpha-Particles. It looks unfinished. description: Formally known as the Particle Focusing EM Lens. This uses electromagnetic waves to focus the Alpha-Particles. It looks unfinished.
components: components:
- type: Physics
bodyType: Dynamic
- type: Sprite - type: Sprite
sprite: Structures/Power/Generation/PA/power_box.rsi sprite: Structures/Power/Generation/PA/power_box.rsi
- type: Construction - type: Construction

View File

@@ -83,6 +83,8 @@
id: AMEControllerUnanchored id: AMEControllerUnanchored
suffix: Unanchored suffix: Unanchored
components: components:
- type: Transform
anchored: false
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Dynamic

View File

@@ -11,6 +11,9 @@
- type: Transform - type: Transform
anchored: true anchored: true
noRot: true noRot: true
- type: Physics
bodyType: Static
canCollide: false
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: ThinWire drawdepth: ThinWire

View File

@@ -11,6 +11,8 @@
path: /Audio/Effects/shuttle_thruster.ogg path: /Audio/Effects/shuttle_thruster.ogg
- type: Transform - type: Transform
anchored: true anchored: true
- type: Physics
bodyType: Static
- type: Rotatable - type: Rotatable
rotateWhileAnchored: true rotateWhileAnchored: true
- type: Thruster - type: Thruster

View File

@@ -30,7 +30,7 @@
enabled: false enabled: false
- type: Physics - type: Physics
canCollide: false canCollide: false
bodyType: Dynamic bodyType: Static
- type: Fixtures - type: Fixtures
- type: Damageable - type: Damageable
damageContainer: Inorganic damageContainer: Inorganic

View File

@@ -13,6 +13,7 @@
state: plasticflaps state: plasticflaps
drawdepth: Mobs drawdepth: Mobs
- type: Physics - type: Physics
bodyType: Static
- type: Transform - type: Transform
anchored: true anchored: true
- type: Fixtures - type: Fixtures