Class ArenaBroadcastSerializers
Hand written wire format for ArenaMatchStateBroadcast and the entries it carries.
public static class ArenaBroadcastSerializers
- Inheritance
-
ArenaBroadcastSerializers
- Inherited Members
Remarks
The match state goes to every occupant of an arena instance once a second for the clock, and again on every phase change and every score change — so it is the one arena message whose size is worth shaping. Two things the generated serializer had to send unconditionally are shaped away here:
-
Position is only meaningful for a flag lying on the
ground. A flag at home has no marker to place and a carried flag hangs off the carrier's
transform, so
ArenaFlagVisualsreads the field on the dropped branch alone; a control point never has a position at all, and the producer leaves it at zero. Twelve bytes per objective per second, on every control-point map, for a field nothing read. - A member's three flags — present, ready, reconnecting — share one byte instead of spending one each.
ArenaTemplateID is written UNPACKED. Template ids
are (typeName + assetName).GetDeterministicHashCode() values that occupy the whole
32-bit range, so FishNet's signed-packed form — a seven-bit-per-byte varint — spends five
bytes where unpacked spends four. The same trade
WriteTo(Writer) makes for a buff template id. Everything else here
stays packed, because scores, team indices, seconds and object ids really are small.
Discovered by FishNet's codegen through the Write*/Read* naming convention,
and applied in the Client and Server assemblies because each struct carries
[UseGlobalCustomSerializer] — the same arrangement
AbilityObserverBroadcastSerializers uses. ArenaMemberEntry is marked
too, so the one wire form serves both the state broadcast and
Placements rather than two shapes drifting apart.
Fields
MaxMembers
Upper bound accepted for a seat count, against a corrupt or hostile stream.
public const int MaxMembers = 256
Field Value
Remarks
An arena format's seats are a handful per team; the bound exists so a malformed message cannot make the reader allocate an arbitrarily large array before the stream runs out, not because 256 seats is expected.
MaxObjectives
Upper bound accepted for an objective count.
public const int MaxObjectives = 256
Field Value
MaxTeamScores
Upper bound accepted for a team count.
public const int MaxTeamScores = 64
Field Value
Methods
ReadArenaMatchStateBroadcast(Reader)
Reads an ArenaMatchStateBroadcast written by the method above.
public static ArenaMatchStateBroadcast ReadArenaMatchStateBroadcast(this Reader reader)
Parameters
readerReader
Returns
Remarks
A count outside its bound cannot be resynchronised past — the entries behind it are of unknown length — so the message is abandoned at that point and returned with empty arrays, which the HUD treats as a match with nothing in it rather than indexing into a partially read one.
ReadArenaMemberEntry(Reader)
Reads one ArenaMemberEntry written by the method above.
public static ArenaMemberEntry ReadArenaMemberEntry(this Reader reader)
Parameters
readerReader
Returns
ReadArenaObjectiveEntry(Reader)
Reads one ArenaObjectiveEntry written by the method above.
public static ArenaObjectiveEntry ReadArenaObjectiveEntry(this Reader reader)
Parameters
readerReader
Returns
Remarks
An objective that carried no position comes back at Vector3.zero, which is exactly
what the producer set for it and what every consumer already ignores: the flag visuals
only read the field on their dropped branch, and the HUD's objective lines never read it
at all.
WriteArenaMatchStateBroadcast(Writer, ArenaMatchStateBroadcast)
Writes an ArenaMatchStateBroadcast.
public static void WriteArenaMatchStateBroadcast(this Writer writer, ArenaMatchStateBroadcast value)
Parameters
writerWritervalueArenaMatchStateBroadcast
WriteArenaMemberEntry(Writer, ArenaMemberEntry)
Writes one ArenaMemberEntry, its three flags in one byte.
public static void WriteArenaMemberEntry(this Writer writer, ArenaMemberEntry value)
Parameters
writerWritervalueArenaMemberEntry
WriteArenaObjectiveEntry(Writer, ArenaObjectiveEntry)
Writes one ArenaObjectiveEntry, sending its position only for a dropped flag.
public static void WriteArenaObjectiveEntry(this Writer writer, ArenaObjectiveEntry value)
Parameters
writerWritervalueArenaObjectiveEntry