Class KnownAbilityAddBroadcastSerializer
Wire format for KnownAbilityAddBroadcast.
public static class KnownAbilityAddBroadcastSerializer
- Inheritance
-
KnownAbilityAddBroadcastSerializer
- Inherited Members
Remarks
Hand written for one field. TemplateID is a deterministic 32-bit hash
(CachedScriptableObject.AddToCache), so it spans the whole signed range and FishNet's
signed-packed form zigzags all but a sixteenth of it past 2^28 and spends FIVE bytes where
unpacked spends exactly four. The login sync ships the ENTIRE known-ability set in one
KnownAbilityAddMultipleBroadcast — on the order of a hundred ids — so that
byte is paid per known ability on every login. See InventorySetItemBroadcast.
Fields
MaxKnownAbilities
Upper bound accepted for a known-ability array length, against a corrupt stream.
public const int MaxKnownAbilities = 8192
Field Value
Remarks
Registry-bounded rather than capacity-bounded. One entry is one learned
BaseAbilityTemplate, so the largest legitimate array — the whole known set shipped
at login in one KnownAbilityAddMultipleBroadcast — cannot exceed the number
of base ability templates authored in the project. That is currently under a hundred
assets under Assets/Templates/Entity/Abilities, and there is no constant anywhere
that caps it: nothing stops a designer adding the next one, so no exact bound exists to
reference.
This ceiling is therefore an explicitly generous, explicitly arbitrary one rather than a
derived limit — two orders of magnitude above today's content, chosen so that ability
authoring can grow for the life of the project without anyone rediscovering this file.
The deliberate asymmetry: a bound set too low truncates a legitimate array and a player
logs in missing abilities they own, which is a much worse bug than the large allocation
the bound exists to prevent. A bound set too high still turns an unbounded
new T[2_000_000_000] into a few tens of kilobytes, which is the entire point.
Server → client, so the honest threat is a mangled or truncated stream — a reader that has lost alignment and is interpreting some other field as a length prefix — not a hostile client, which has no way to send this message to itself.
Methods
ReadKnownAbilityAddBroadcast(Reader)
Reads a KnownAbilityAddBroadcast.
public static KnownAbilityAddBroadcast ReadKnownAbilityAddBroadcast(this Reader reader)
Parameters
readerReader
Returns
ReadKnownAbilityAddBroadcastArray(Reader)
Reads an array of KnownAbilityAddBroadcast.
public static KnownAbilityAddBroadcast[] ReadKnownAbilityAddBroadcastArray(this Reader reader)
Parameters
readerReader
Returns
Remarks
A length past MaxKnownAbilities 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 nothing is learned. Only the sender's own -1, which is not a length at all, means null.
WriteKnownAbilityAddBroadcast(Writer, KnownAbilityAddBroadcast)
Writes a KnownAbilityAddBroadcast.
public static void WriteKnownAbilityAddBroadcast(this Writer writer, KnownAbilityAddBroadcast value)
Parameters
writerWritervalueKnownAbilityAddBroadcast
WriteKnownAbilityAddBroadcastArray(Writer, KnownAbilityAddBroadcast[])
Writes an array of KnownAbilityAddBroadcast.
public static void WriteKnownAbilityAddBroadcastArray(this Writer writer, KnownAbilityAddBroadcast[] value)
Parameters
writerWritervalueKnownAbilityAddBroadcast[]
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 KnownAbilityAddBroadcast[]", 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.