Class InventorySetItemBroadcastSerializer
Wire format for InventorySetItemBroadcast.
public static class InventorySetItemBroadcastSerializer
- Inheritance
-
InventorySetItemBroadcastSerializer
- Inherited Members
Remarks
Hand written for two fields. TemplateID is a deterministic 32-bit hash
(CachedScriptableObject.AddToCache) and Seed is full entropy by construction,
so both span the whole range and FishNet's signed-packed form spends FIVE bytes on each
where unpacked spends exactly four. The login sync ships the ENTIRE inventory in one
InventorySetMultipleItemsBroadcast, so those two bytes are paid per occupied
slot on every login. InstanceID stays packed — it is a database sequence value and
small — as do the slot index and stack size. See ObservedBuffEntry.
Fields
MaxInventoryItems
Upper bound accepted for an inventory array length, against a corrupt stream.
public const int MaxInventoryItems = 1024
Field Value
Remarks
Anchored on the container: InventoryController.OnAwake calls
AddSlots(null, 32), so the largest legitimate array — a full inventory sent in one
InventorySetMultipleItemsBroadcast at login — is 32 entries. There is no
Constants value to point at; 32 is written into the controller directly, which is
why this bound restates it here rather than referencing it.
The ceiling is 32x that capacity on purpose. Truncating a legitimate array is worse than
the allocation it prevents — a player would silently lose rows from their own bags — and
the bound's whole job is to stop new InventorySetItemBroadcast[2_000_000_000], not
to police a plausible count. A thousand of these structs is tens of kilobytes, so the
headroom costs nothing and survives bag slots, expansions, or a doubled starting size
without anybody remembering this file exists.
This is a server → client path, so the realistic trigger is a mangled or truncated stream — a desynchronised reader interpreting the middle of some other field as a length prefix — rather than a hostile client. A client cannot send this message to itself. The bound is cheap insurance against corruption, not a security control.
Methods
ReadInventorySetItemBroadcast(Reader)
Reads an InventorySetItemBroadcast.
public static InventorySetItemBroadcast ReadInventorySetItemBroadcast(this Reader reader)
Parameters
readerReader
Returns
ReadInventorySetItemBroadcastArray(Reader)
Reads an array of InventorySetItemBroadcast.
public static InventorySetItemBroadcast[] ReadInventorySetItemBroadcastArray(this Reader reader)
Parameters
readerReader
Returns
Remarks
A length past MaxInventoryItems cannot be allocated and cannot be resynchronised past either — the entries behind it are only locatable by trusting the count just rejected — so the array comes back empty and the caller applies nothing. Only the sender's own -1, which is not a length at all, means null.
WriteInventorySetItemBroadcast(Writer, InventorySetItemBroadcast)
Writes an InventorySetItemBroadcast.
public static void WriteInventorySetItemBroadcast(this Writer writer, InventorySetItemBroadcast value)
Parameters
writerWritervalueInventorySetItemBroadcast
WriteInventorySetItemBroadcastArray(Writer, InventorySetItemBroadcast[])
Writes an array of InventorySetItemBroadcast.
public static void WriteInventorySetItemBroadcastArray(this Writer writer, InventorySetItemBroadcast[] value)
Parameters
writerWritervalueInventorySetItemBroadcast[]
Remarks
Explicit because the element carries [UseGlobalCustomSerializer]. That attribute
tells FishNet the element has a hand-written serializer, and codegen then declines to
synthesise one for the ARRAY as well — it emits nothing and says nothing at build time.
The gap only appears when a broadcast carrying the array is actually sent, as
"Write method not found for InventorySetItemBroadcast[]", by which point the send has already failed.
A null array is written as length -1 so it round-trips as null rather than as empty.