Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Revert "Fix UninitializedSaveTest prototypes" #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions Content.IntegrationTests/Tests/PrototypeSaveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 @@ -108,16 +166,26 @@ await server.WaitAssertion(() =>
foreach (var prototype in prototypes)
{
uid = entityMan.SpawnEntity(prototype.ID, testLocation);
<<<<<<< HEAD
server.RunTicks(1);
=======
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))

// get default prototype data
Dictionary<string, MappingDataNode> protoData = new();
try
{
foreach (var (compType, comp) in prototype.Components)
{
<<<<<<< HEAD
protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, context: context));
}
=======
protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, alwaysWrite: true, context: context));
}

context.WritingReadingPrototypes = false;
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
}
catch (Exception e)
{
Expand All @@ -139,7 +207,11 @@ await server.WaitAssertion(() =>
MappingDataNode compMapping;
try
{
<<<<<<< HEAD
compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, context: context);
=======
compMapping = seriMan.WriteValueAs<MappingDataNode>(compType, component, alwaysWrite: true, context: context);
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
}
catch (Exception e)
{
Expand Down Expand Up @@ -181,6 +253,10 @@ private sealed class TestEntityUidContext : ISerializationContext,
ITypeSerializer<EntityUid, ValueDataNode>
{
public SerializationManager.SerializerProvider SerializerProvider { get; }
<<<<<<< HEAD
=======
public bool WritingReadingPrototypes { get; set; }
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))

public TestEntityUidContext()
{
Expand All @@ -198,8 +274,12 @@ public DataNode Write(ISerializationManager serializationManager, EntityUid valu
IDependencyCollection dependencies, bool alwaysWrite = false,
ISerializationContext? context = null)
{
<<<<<<< HEAD
// EntityUids should be nullable and have no initial value.
throw new InvalidOperationException("Serializing prototypes should not attempt to write entity Uids");
=======
return new ValueDataNode(value.ToString());
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
}

EntityUid ITypeReader<EntityUid, ValueDataNode>.Read(ISerializationManager serializationManager,
Expand Down
12 changes: 12 additions & 0 deletions Resources/Prototypes/Entities/Structures/Furniture/chairs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
components:
- type: Transform
anchored: true
<<<<<<< HEAD
=======
- type: Anchorable
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
- type: Rotatable
- type: Sprite
state: chair
Expand Down Expand Up @@ -122,6 +126,10 @@
components:
- type: Transform
anchored: true
<<<<<<< HEAD
=======
- type: Anchorable
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
- type: Rotatable
- type: Sprite
state: comfy
Expand All @@ -137,6 +145,10 @@
components:
- type: Transform
anchored: true
<<<<<<< HEAD
=======
- type: Anchorable
>>>>>>> de1613f7ef (Revert "Fix UninitializedSaveTest prototypes" (#16169))
- type: Rotatable
- type: Sprite
state: shuttle
Expand Down
47 changes: 47 additions & 0 deletions Resources/Prototypes/Entities/Structures/Wallmounts/bell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- type: entity
id: BoxingBell
name: boxing bell
description: Ding ding!
placement:
mode: SnapgridCenter
snap:
- Wallmount
components:
- type: Transform
anchored: true
- type: WallMount
- type: Sprite
sprite: Structures/Wallmounts/bell.rsi
layers:
- state: bell
- type: InteractionPopup
successChance: 1
interactSuccessSound:
path: /Audio/Weapons/boxingbell.ogg
- type: Clickable
- type: MeleeSound
soundGroups:
Brute:
path:
"/Audio/Weapons/boxingbell.ogg"
- type: Appearance
- type: Rotatable
- type: CollisionWake
enabled: false
- type: Physics
canCollide: false
bodyType: Dynamic
- type: Fixtures
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 150
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
- !type:PlaySoundBehavior
sound:
path: /Audio/Effects/metalbreak.ogg