Hotfix storage arbitrage (#10652)
This commit is contained in:
@@ -1,14 +1,42 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
|
using Content.Shared.Item;
|
||||||
|
using Content.Shared.Storage;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests
|
namespace Content.IntegrationTests.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public sealed class StorageFillTest
|
public sealed class StorageTest
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Can an item store more than itself weighs.
|
||||||
|
/// In an ideal world this test wouldn't need to exist because sizes would be recursive.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public async Task StorageSizeArbitrageTest()
|
||||||
|
{
|
||||||
|
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||||
|
var server = pairTracker.Pair.Server;
|
||||||
|
|
||||||
|
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||||
|
|
||||||
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||||
|
{
|
||||||
|
if (!proto.TryGetComponent<ServerStorageComponent>("Storage", out var storage) ||
|
||||||
|
storage.Whitelist != null ||
|
||||||
|
!proto.TryGetComponent<ItemComponent>("Item", out var item)) continue;
|
||||||
|
|
||||||
|
Assert.That(storage.StorageCapacityMax, Is.LessThanOrEqualTo(item.Size), $"Found storage arbitrage on {proto.ID}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await pairTracker.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TestStorageFillPrototypes()
|
public async Task TestStorageFillPrototypes()
|
||||||
{
|
{
|
||||||
@@ -191,4 +191,4 @@
|
|||||||
- type: Clothing
|
- type: Clothing
|
||||||
equippedPrefix: holding
|
equippedPrefix: holding
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 10000
|
capacity: 9999
|
||||||
|
|||||||
@@ -157,4 +157,4 @@
|
|||||||
- state: icon-unlit
|
- state: icon-unlit
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 10000
|
capacity: 9999
|
||||||
|
|||||||
@@ -101,4 +101,4 @@
|
|||||||
- state: icon-unlit
|
- state: icon-unlit
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 10000
|
capacity: 9999
|
||||||
|
|||||||
@@ -391,6 +391,8 @@
|
|||||||
sprite: Clothing/Belt/bandolier.rsi
|
sprite: Clothing/Belt/bandolier.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Belt/bandolier.rsi
|
sprite: Clothing/Belt/bandolier.rsi
|
||||||
|
- type: Item
|
||||||
|
size: 60
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 60
|
capacity: 60
|
||||||
whitelist:
|
whitelist:
|
||||||
@@ -432,6 +434,8 @@
|
|||||||
sprite: Clothing/Belt/syndieholster.rsi
|
sprite: Clothing/Belt/syndieholster.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Belt/syndieholster.rsi
|
sprite: Clothing/Belt/syndieholster.rsi
|
||||||
|
- type: Item
|
||||||
|
size: 60
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 60
|
capacity: 60
|
||||||
whitelist:
|
whitelist:
|
||||||
@@ -473,6 +477,8 @@
|
|||||||
sprite: Clothing/Belt/militarywebbingmed.rsi
|
sprite: Clothing/Belt/militarywebbingmed.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Belt/militarywebbingmed.rsi
|
sprite: Clothing/Belt/militarywebbingmed.rsi
|
||||||
|
- type: Item
|
||||||
|
size: 60
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 60
|
capacity: 60
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
id: ClothingOuterStorageBase
|
id: ClothingOuterStorageBase
|
||||||
components:
|
components:
|
||||||
|
- type: Item
|
||||||
|
size: 10
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 10
|
capacity: 10
|
||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/matches.rsi
|
sprite: Objects/Tools/matches.rsi
|
||||||
heldPrefix: matchbox
|
heldPrefix: matchbox
|
||||||
|
size: 10
|
||||||
- type: StorageFill
|
- type: StorageFill
|
||||||
contents:
|
contents:
|
||||||
- id: Matchstick
|
- id: Matchstick
|
||||||
|
|||||||
Reference in New Issue
Block a user