]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Revert "Revert "Fix UninitializedSaveTest prototypes" (#16169)" (#16175)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sat, 6 May 2023 18:30:51 +0000 (06:30 +1200)
committerGitHub <noreply@github.com>
Sat, 6 May 2023 18:30:51 +0000 (14:30 -0400)
* Revert "Revert "Fix UninitializedSaveTest prototypes" (#16169)"

This reverts commit de1613f7ef6c5f3ba556ce9754149cbe5e72b050.

* Invert if statement

25 files changed:
Content.IntegrationTests/Tests/PrototypeSaveTest.cs
Content.Server/Dragon/Components/DragonRiftComponent.cs
Content.Server/Dragon/DragonSystem.cs
Content.Server/Lightning/LightningSystem.cs
Content.Shared/Lightning/Components/SharedLightningComponent.cs
Resources/Prototypes/Entities/Clothing/Back/specific.yml
Resources/Prototypes/Entities/Effects/lightning.yml
Resources/Prototypes/Entities/Objects/Devices/nuke.yml
Resources/Prototypes/Entities/Structures/Furniture/chairs.yml
Resources/Prototypes/Entities/Structures/Furniture/toilet.yml
Resources/Prototypes/Entities/Structures/Machines/frame.yml
Resources/Prototypes/Entities/Structures/Machines/wireless_surveillance_camera.yml
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/pipes.yml
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/control_box.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml
Resources/Prototypes/Entities/Structures/Power/Generation/ame.yml
Resources/Prototypes/Entities/Structures/Power/cables.yml
Resources/Prototypes/Entities/Structures/Shuttles/thrusters.yml
Resources/Prototypes/Entities/Structures/Wallmounts/bell.yml
Resources/Prototypes/Entities/Structures/plastic_flaps.yml

index 15c3416ae1e4e60fbba0fa16862dd6f34173e8b3..eda8e10ae2731f7d842b24dffb9cac37bdb81f23 100644 (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.
         "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]
@@ -127,7 +69,7 @@ public sealed class PrototypeSaveTest
 
             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 coordinates = grid.ToCoordinates();
 
@@ -168,6 +110,7 @@ public sealed class PrototypeSaveTest
                 foreach (var prototype in prototypes)
                 {
                     uid = entityMan.SpawnEntity(prototype.ID, testLocation);
+                    context.Prototype = prototype;
 
                     // get default prototype data
                     Dictionary<string, MappingDataNode> protoData = new();
@@ -177,9 +120,11 @@ public sealed class PrototypeSaveTest
 
                         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)
@@ -202,6 +147,7 @@ public sealed class PrototypeSaveTest
                         MappingDataNode compMapping;
                         try
                         {
+                            context.WritingComponent = compName;
                             compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, alwaysWrite: true, context: context);
                         }
                         catch (Exception e)
@@ -246,6 +192,9 @@ public sealed class PrototypeSaveTest
         public SerializationManager.SerializerProvider SerializerProvider { get; }
         public bool WritingReadingPrototypes { get; set; }
 
+        public string WritingComponent = string.Empty;
+        public EntityPrototype Prototype = default!;
+
         public TestEntityUidContext()
         {
             SerializerProvider = new();
@@ -262,6 +211,14 @@ public sealed class PrototypeSaveTest
             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());
         }
 
index c1abb67bbe34abcaefbcdab59d041fc4f0d57963..b5c7c79a9d9c4cf2d0398b1306383063b359c46d 100644 (file)
@@ -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.
index 6bd1f08bdbfe193d4274c7b92b1ebe3ca5ffeafc..329a4379f65c1f2090cda5ff80b9339e1bdfab3c 100644 (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.
                 dragon.WeakenedAccumulator = dragon.WeakenedDuration;
-                _movement.RefreshMovementSpeedModifiers(component.Dragon);
-                _popupSystem.PopupEntity(Loc.GetString("carp-rift-destroyed"), component.Dragon, component.Dragon);
+                _movement.RefreshMovementSpeedModifiers(component.Dragon.Value);
+                _popupSystem.PopupEntity(Loc.GetString("carp-rift-destroyed"), component.Dragon.Value, component.Dragon.Value);
             }
         }
 
index 523cf734ab8954077576e1c9bdc4102e31f5b274..8d82275b0a88a03cb0a976c5f5d59c9cb1ab2fce 100644 (file)
@@ -37,28 +37,28 @@ public sealed class LightningSystem : SharedLightningSystem
 
     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)
-        {
-            while (beamController.CreatedBeams.Count < component.MaxTotalArcs)
-            {
-                Arc(component, args.OtherFixture.Body.Owner, lightningBeam.VirtualBeamController.Value);
 
-                var spriteState = LightningRandomizer();
+        if (!component.CanArc || beamController.CreatedBeams.Count >= component.MaxTotalArcs)
+            return;
 
-                component.ArcTargets.Add(args.OtherFixture.Body.Owner);
-                component.ArcTargets.Add(component.ArcTarget);
+        Arc(component, args.OtherEntity, lightningBeam.VirtualBeamController.Value);
 
-                _beam.TryCreateBeam(args.OtherFixture.Body.Owner, component.ArcTarget, component.LightningPrototype, spriteState, controller: lightningBeam.VirtualBeamController.Value);
+        if (component.ArcTarget == null)
+            return;
 
-                //Break from this loop so other created bolts can collide and arc
-                break;
-            }
-        }
+        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);
     }
 
     /// <summary>
index 24e56509845d4db9d4bca969edcbd63e3a50672a..7fc2dcacbad8fe385116a95a558f74631aee3c4b 100644 (file)
@@ -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?
index a5ffeb93836b4e3908bea940de8779199292f87e..df7c978a2e3a0d5e1bacfbe5cc85b18c1c5121b3 100644 (file)
@@ -9,9 +9,6 @@
       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
index 0f5ee91264383504b1e310caf5fcb90a06966e47..e7d0cf5df3893d08d1494e0e13c226955f92563c 100644 (file)
@@ -34,6 +34,7 @@
   name: lightning
   id: Lightning
   parent: BaseLightning
+  noSpawn: true
   components:
     - type: Lightning
       canArc: true
@@ -42,6 +43,7 @@
   name: spooky lightning
   id: LightningRevenant
   parent: BaseLightning
+  noSpawn: true
   components:
     - type: Sprite
       sprite: /Textures/Effects/lightning.rsi
@@ -65,6 +67,7 @@
   name: charged lightning
   id: ChargedLightning
   parent: BaseLightning
+  noSpawn: true
   components:
     - type: Sprite
       sprite: /Textures/Effects/lightning.rsi
@@ -83,6 +86,7 @@
   name: supercharged lightning
   id: SuperchargedLightning
   parent: ChargedLightning
+  noSpawn: true
   components:
     - type: Sprite
       sprite: /Textures/Effects/lightning.rsi
   name: hypercharged lightning
   id: HyperchargedLightning
   parent: ChargedLightning
+  noSpawn: true
   components:
     - type: Sprite
       sprite: /Textures/Effects/lightning.rsi
index 22857113aa4e3cb4b87057374d657ef4aae5184b..47d1f45875103d25e5176734df79fbb4623f99cf 100644 (file)
@@ -12,7 +12,7 @@
     noRot: true
     state: nuclearbomb_base
   - type: Physics
-    bodyType: Dynamic
+    bodyType: Static
   - type: Fixtures
     fixtures:
       fix1:
index da233122ba3c501c788f602e92878645c29fb521..bf9cc0b0181977b183c9aef14310f985e75c5e0f 100644 (file)
@@ -57,6 +57,8 @@
   components:
   - type: Transform
     anchored: true
+  - type: Physics
+    bodyType: Static
   - type: Anchorable
   - type: Rotatable
   - type: Sprite
   components:
   - type: Transform
     anchored: true
+  - type: Physics
+    bodyType: Static
   - type: Anchorable
   - type: Rotatable
   - type: Sprite
   components:
   - type: Transform
     anchored: true
+  - type: Physics
+    bodyType: Static
   - type: Anchorable
   - type: Rotatable
   - type: Sprite
index 598b1a99d826aaf4210e42e13df5918fb441bfc4..95251a7b0f407b911030ada4d0145eebec6a6640 100644 (file)
@@ -27,6 +27,8 @@
         maxVol: 250
   - type: Transform
     anchored: true
+  - type: Physics
+    bodyType: Static
   - type: Construction
     graph: Toilet
     node: toilet
index 69c90085163c13ac5fa765cc4fa0a8449bc99248..b26882c306ecb2804e3d40ce1d1887272086830c 100644 (file)
     - type: Transform
       anchored: true
       noRot: true
+    - type: Physics
+      bodyType: Static
     - type: Construction
       graph: Machine
       node: destroyedMachineFrame
index e825b685124a081bb2625972ed0a5d9b729f9fdc..d69eb96f6237ea420f6eb41f526874bd4d409560 100644 (file)
@@ -49,6 +49,8 @@
     - type: Anchorable
     - type: Transform
       anchored: true
+    - type: Physics
+      bodyType: Static
     - type: Sprite
       noRot: true
       sprite: Structures/monitors.rsi
index c6995778342447d4ae5a90de4cbf94139ce4feba..1ca4fce8118c9441a55c3e93f24b46da7dc954b5 100644 (file)
       graph: GasBinary
       node: valve
     - type: AmbientSound
-      enabled: false
+      enabled: true
       volume: -9
       range: 5
       sound:
     graph: GasBinary
     node: signalvalve
   - type: AmbientSound
-    enabled: false
+    enabled: true
     volume: -9
     range: 5
     sound:
           !type:PipeNode
           nodeGroupID: Pipe
           pipeDirection: South
+    - type: AmbientSound
+      enabled: true
 
 - type: entity
   parent: [ BaseMachine, ConstructibleMachine ]
   - type: AtmosDevice
   - type: AtmosPipeColor
   - type: AmbientSound
-    enabled: false
+    enabled: true
     volume: -9
     range: 5
     sound:
index ee049039bccccb80b274b1e0e319bfcfcdf37711..23f2f7b8cd203ba4aadc7af130bc973faaed4a99 100644 (file)
@@ -42,6 +42,7 @@
     - Pipe
   - type: Physics
     canCollide: false
+    bodyType: static
   - type: AmbientSound
     enabled: false
     volume: -15
index 6c3bf09eecb16ac18e8c83be748e305f17e707f2..f35425c048fb6696aa039f20011ce68cd79dce57 100644 (file)
@@ -79,7 +79,7 @@
       node: ventpump
     - type: VentCritterSpawnLocation
     - type: AmbientSound
-      enabled: false
+      enabled: true
       volume: -12
       range: 5
       sound:
       graph: GasUnary
       node: ventscrubber
     - type: AmbientSound
-      enabled: false
+      enabled: true
       volume: -12
       range: 5
       sound:
index 3aa3393390fb6f9ca466bf044f5f9e1cd0de7fb0..e1f62631f08d32cb956a7da472cf08bc05cffb86 100644 (file)
@@ -45,8 +45,6 @@
   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
index 331341adfec5089236ef3eed0d5527a60f77e17e..f89d38e6b00f487e43fa280ca65bf9519157a490 100644 (file)
@@ -46,8 +46,6 @@
   suffix: Unfinished, Left
   description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/emitter_left.rsi
     - type: Construction
@@ -60,8 +58,6 @@
   suffix: Unfinished
   description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/emitter_center.rsi
     - type: Construction
@@ -74,8 +70,6 @@
   suffix: Unfinished
   description: This launchs the Alpha particles, might not want to stand near this end. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/emitter_right.rsi
     - type: Construction
index 676b95b2ccff273d1c2bc704e7a3834314d28a00..cd43d3bd362f4a3febd1c35209b619e36470fed4 100644 (file)
@@ -22,8 +22,6 @@
   suffix: Unfinished
   description: Formally known as the Alpha Particle Generation Array. This is where Alpha particles are generated from [REDACTED]. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/end_cap.rsi
     - type: Construction
index 63661830c4d33133bcd9aa63469a4f1a21da89a3..d835895b01e5d86a403205f08e58d125a050e002 100644 (file)
@@ -19,8 +19,6 @@
   suffix: Unfinished
   description: Formally known as the EM Acceleration Chamber. This is where the Alpha particles are accelerated to radical speeds. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/fuel_chamber.rsi
     - type: Construction
index cf98367287c0ba5d64ac86cc8022d9bfc64cb3fd..93a4b4b029f58dd42d185fa9881e0ba7bdc45718 100644 (file)
@@ -25,8 +25,6 @@
   suffix: Unfinished
   description: Formally known as the Particle Focusing EM Lens. This uses electromagnetic waves to focus the Alpha-Particles. It looks unfinished.
   components:
-    - type: Physics
-      bodyType: Dynamic
     - type: Sprite
       sprite: Structures/Power/Generation/PA/power_box.rsi
     - type: Construction
index 07515857ad8e4d4b7d0cac314653761d58ea1558..44c175de702d3d0916b357c8eb43dfbf0ba672f7 100644 (file)
@@ -83,6 +83,8 @@
   id: AMEControllerUnanchored
   suffix: Unanchored
   components:
+  - type: Transform
+    anchored: false
   - type: Physics
     bodyType: Dynamic
 
index d8e51d8aea24af0f6918848e28cdd879c669be45..77abc3f109541376b1e39e6e5e41471d5d052e47 100644 (file)
@@ -11,6 +11,9 @@
   - type: Transform
     anchored: true
     noRot: true
+  - type: Physics
+    bodyType: Static
+    canCollide: false
   - type: Sprite
     netsync: false
     drawdepth: ThinWire
index 58376b9399554d493f3cd8e848bd78524ef43894..f423f2b8e04d614e026ba18b6601b47a8ae5e662 100644 (file)
@@ -11,6 +11,8 @@
         path: /Audio/Effects/shuttle_thruster.ogg
     - type: Transform
       anchored: true
+    - type: Physics
+      bodyType: Static
     - type: Rotatable
       rotateWhileAnchored: true
     - type: Thruster
index e10baa2a1d9b505c077ac1ff4a76a6805be21c24..a4ea19d15e8904027c7e4c60e9f44d351567b126 100644 (file)
@@ -30,7 +30,7 @@
     enabled: false
   - type: Physics
     canCollide: false
-    bodyType: Dynamic
+    bodyType: Static
   - type: Fixtures
   - type: Damageable
     damageContainer: Inorganic
index 1caf8820934ecb4d82d4423bfcccf8ce3ea6da47..d5d016264d11e031a4fa9c9beb8e1b563603ac18 100644 (file)
@@ -13,6 +13,7 @@
     state: plasticflaps
     drawdepth: Mobs
   - type: Physics
+    bodyType: Static
   - type: Transform
     anchored: true
   - type: Fixtures