resonance 1.0.1
Loading...
Searching...
No Matches
Packet Class Reference

Abstract base of every network packet. More...

#include <packet.h>

Inheritance diagram for Packet:
Collaboration diagram for Packet:

Public Member Functions

virtual void saveGuts (OBStream &stream) const
 Write the four words to a stream.
virtual void restoreGuts (IBStream &stream)
 Read the four words back from a stream.
Public Member Functions inherited from Message
void * operator new (size_t nSize)
 Allocate a message from the tagged heap under the tag MSG.
void operator delete (void *pBlock)
 Release a message to the tagged heap under the tag MSG.
virtual ~Message ()
 Vtable slot 1.
virtual Message * Clone ()=0
 Produce a heap copy of this message.
virtual int Type ()=0
 Report this message's registered identity.
virtual const char * GetName () const =0
 Report this message's class name.
virtual void PrintExtra (std::ostream &stream) const
 Write this message's payload to a stream.
std::ostream & Print (std::ostream &stream) const
 Write this message to a diagnostic stream as {GetName() PrintExtra()}.

Protected Member Functions

 Packet (int nDestination, int nDestinationSystem)
 Set the two routing words and mark the remaining two as unset.

Protected Attributes

int mDestination
int mDestinationSystem
int mClientId
 The client the packet concerns, or -1 until set.
int mTargetClientId
 A second client identifier, -1 until set.

Additional Inherited Members

Static Public Member Functions inherited from Message
static Message * NewMessage (int nType)
 Produce a message of the identified class through the factory list.

Detailed Description

Abstract base of every network packet.

Its RTTI descriptor is at 0x009021a0. It has Message as its one base. Its vtable at 0x00814920 has eight entries and a zero terminator at index 8. Slots 2, 3, and 4 address the pure-virtual handler, so the class implements none of Clone(), Type(), or GetName() and is never instantiated. Slot 5 retains Message::PrintExtra(). Slots 6 and 7 are the class's own overrides.

Slot 0 of that table constructs the descriptor above from this class's type name at 0x00814aa0, which is what establishes the table as this class's rather than as a derived class's. CSInitiatePlayPacket's table at 0x00814728 records the same two addresses because CSInitiatePlayPacket adds no payload and inherits the pair. The 22 concrete packet classes all inherit both.

Both members are very likely inline in this header in the original, and the definitions in packet.cpp are the out-of-line emission that fills the table slots. Every one of the twenty overriding packet classes opens its saveGuts() with a byte-identical expansion of the four transfers below, and not one of them contains a call instruction to either address. A qualified call to a non-inline out-of-line member would compile to a call, so the body was available for expansion. That is the same evidence this tree already accepts for the inlined HxStr destructor. Moving the two definitions into this header is a deliberate one-time change rather than something to discover partway through the derived classes, so the question is recorded here instead.

The four words below transfer through those two overrides, which recovers the layout from the class's own code. Three unrelated routing families give the identical shared prefix independently, and two packets, CSInitiatePlayPacket and SCStartPlayingPacket, are exactly 0x14 bytes and add nothing to it.

The destructor at 0x003eedc8 is compiler-generated and has no declaration here.

Constructor & Destructor Documentation

◆ Packet()

Packet::Packet ( int nDestination,
int nDestinationSystem )
inlineprotected

Set the two routing words and mark the remaining two as unset.

No address attaches to the constructor on its own. Every one of the 21 New() factories at 0x003e4a98 through 0x003e54d8 expands it in place, storing a pair of small constants at +0x04 and +0x08 and -1 at both +0x0c and +0x10. The pair is fixed by the routing class the packet derives from, which is why each routing class supplies it: ToHostPacket passes 0 and 0, ToSingleNetManagerPacket 1 and 0, ToAllOtherNetManagersPacket 2 and 0, ToAllOtherGameSystemsPacket 2 and 3, ToAllNetManagersPacket 3 and 0, ToAllGameControllersPacket 3 and 2, and ToArbiterPacket 0 and 1. The first word therefore selects which peers receive the packet and the second which subsystem on each peer, but no literal in the image labels either one.

Parameters
nDestinationThe peers that receive the packet.
nDestinationSystemThe subsystem on each receiving peer.

Member Function Documentation

◆ saveGuts()

virtual void Packet::saveGuts ( OBStream & stream) const
virtual

◆ restoreGuts()

virtual void Packet::restoreGuts ( IBStream & stream)
virtual

Read the four words back from a stream.

Slot 7. The words come back in the order saveGuts() wrote them, and each transfer fills its field in place.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x003f1ea0
Ghidra address:
PAL: 0x0042a3e8

Reimplemented from Message.

Reimplemented in BSLoadLevelPacket, BumpPacket, CatchProgressPacket, CaughtPhrasePacket, CripplePacket, CSClientStatusPacket, GameChatPacket, GemPacket, PhrasePacket, PSJoinRequestPacket, SCAllClientsStatusPacket, SCAllPlayersInfoPacket, SCGameOverPacket, SCLoadLevelPacket, SCPlayerJoinedPacket, SCStartPlayingPacket, SPJoinAcceptPacket, SPJoinDenyPacket, TestArbiterPacket, TrackSelectPacket, and UpdateScorePacket.

Member Data Documentation

◆ mDestination

int Packet::mDestination
protected

The peers that receive the packet. +0x04

◆ mDestinationSystem

int Packet::mDestinationSystem
protected

The subsystem on each receiving peer. +0x08

◆ mClientId

int Packet::mClientId
protected

The client the packet concerns, or -1 until set.

+0x0c

GemPacket::PrintExtra() labels it clid:, and six packets transfer it a second time after their payload.

◆ mTargetClientId

int Packet::mTargetClientId
protected

A second client identifier, -1 until set.

+0x10

The image does not write or read it outside the transfers. The title is inferred from the -1 default it shares with mClientId.


The documentation for this class was generated from the following file: