Table of Contents

Class ItemSnapshotContent

Namespace
FishMMO.Server.Implementation.World.SceneServer
Assembly
FishMMO.Server.dll

Decides whether a character's containers still say exactly what the last confirmed item snapshot wrote — the test that lets the periodic snapshot skip a character that has not changed.

public static class ItemSnapshotContent
Inheritance
ItemSnapshotContent
Inherited Members

Remarks

A comparison of content, deliberately not a dirty flag. A flag is only as good as the list of places that set it, and items change through more doors than any list would hold: the container primitives, a stack amount edited in place, an identity arriving from a write-back, a slot repaired by the snapshot itself. The snapshot exists precisely to backstop a write that some path forgot to make, so a skip that trusted every path to have raised a flag would switch the backstop off exactly where it is needed. Comparing what the containers hold with what the database was last confirmed to hold needs no path's co-operation.

The other half of the proof is in the journal. The confirmed rows are only a description of the database while no later write has landed for the character, so ItemWriteJournal drops the confirmation the moment any later batch claims its sequence, and records one only while the snapshot's own sequence is still the character's newest. Everything that writes character_item for a resident character passes that claim.

Versions are not compared: the snapshot bumps every item's version as it captures, so they never repeat, and they say nothing about what the row holds. An item with no identity never matches, so a character holding one is always written — that write is what issues the id.

Methods

Matches(IReadOnlyList<ItemContainerType>, IReadOnlyList<CharacterItemData>, IReadOnlyList<ItemContainerType>, IReadOnlyList<CharacterItemData>)

True when current states exactly the rows confirmed does, for the same containers, in the same order.

public static bool Matches(IReadOnlyList<ItemContainerType> confirmedContainers, IReadOnlyList<CharacterItemData> confirmed, IReadOnlyList<ItemContainerType> currentContainers, IReadOnlyList<CharacterItemData> current)

Parameters

confirmedContainers IReadOnlyList<ItemContainerType>

The containers the confirmed snapshot spoke for.

confirmed IReadOnlyList<CharacterItemData>

The rows it wrote, with the identities the database issued.

currentContainers IReadOnlyList<ItemContainerType>

The containers the character has now.

current IReadOnlyList<CharacterItemData>

The rows its containers would produce now.

Returns

bool

True only when a snapshot now would write nothing different.

Remarks

Order-sensitive on purpose. Both lists come from the same walk — inventory, bank, equipment, each by slot — so equal content in a different order would itself be a sign that something moved.

WithIssuedIdentities(IReadOnlyList<CharacterItemData>, IReadOnlyList<CharacterItemIdAssignment>)

The rows a snapshot wrote, restated with the identities the database issued for the rows that arrived without one.

public static List<CharacterItemData> WithIssuedIdentities(IReadOnlyList<CharacterItemData> written, IReadOnlyList<CharacterItemIdAssignment> assigned)

Parameters

written IReadOnlyList<CharacterItemData>

The rows as sent.

assigned IReadOnlyList<CharacterItemIdAssignment>

The identities the write issued, by container and slot. May be null.

Returns

List<CharacterItemData>

A new list; written is not modified.

Remarks

Those are the identities the write-back hands the live items, so recording them is what lets the next comparison match once the write-back has landed — rather than finding an item with no identity in the record and writing the whole character again for it.