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

Relay that stores a copy of every message it accepts and forwards to its own sinks. More...

#include <msgqueue.h>

Inheritance diagram for MsgQueue:
Collaboration diagram for MsgQueue:

Public Member Functions

 MsgQueue ()
 Start with both vectors empty and mFirst accepting.
virtual ~MsgQueue ()
 Delete every stored message and release both vectors.
void Store (Message *pMsg)
 Store a copy of a message without reading its identity first.
void Poll ()
 Deliver and discard every stored message.
Public Member Functions inherited from MsgSource
virtual ~MsgSource ()
virtual void AddSink (MsgSink *pSink)
 Register a sink, ignoring a sink that is already registered.
virtual void RemoveSink (MsgSink *pSink)
 Unregister the first occurrence of a sink.
void Send (Message *pMsg) const
 Deliver a message to every registered sink, in registration order.
void ClearSinks ()
 Unregister every sink.
Public Member Functions inherited from MsgSink
void * operator new (size_t nSize)
 Allocate a sink from the tagged heap under the tag "MsgSink".
void operator delete (void *pBlock)
 Release a sink to the tagged heap.
virtual ~MsgSink ()
virtual void Dispatch (Message *pMsg)
 Accept a message.

Protected Member Functions

virtual void DispatchPriv (Message *pMsg)
 Store a copy of a message.

Additional Inherited Members

Public Attributes inherited from MsgSource
int mGraphBuilt
 A word no member of this class reads.

Detailed Description

Relay that stores a copy of every message it accepts and forwards to its own sinks.

Its RTTI descriptor is at 0x00902220. It derives from MsgSource at offset 0 and from MsgSink at +0x14. The base records in the descriptor give both offsets directly. The object is 0x3c bytes, fixed by GameManagerImpl embedding one at +0xc0 and writing its next member at +0xfc. Two vtables belong to the class. The table at 0x00829b18 is addressed by the MsgSource subobject and inherits both of that base's virtuals unchanged; the table at 0x00829af0 is addressed by the MsgSink subobject, adjusts this by -0x14 on every entry it overrides, and inherits MsgSink::Dispatch() with no adjustment at all.

Deriving from both mix-ins is the whole design. A message arrives through the MsgSink side, which stores a copy, and arrives at its readers through the inherited MsgSource sink list. GameManagerImpl demonstrates the arrangement: its constructor builds the embedded queue and then registers itself as a sink of it at 0x00105fec.

The queue owns its stored messages. The destructor deletes every element of both vectors through Message's virtual destructor, which is what establishes the ownership and in turn establishes that Message::Clone() returns a heap copy.

Poll() at 0x0054aa58 is the drain, and it shows what the pair of vectors is for. Poll() points mTarget at the vector it is not iterating. A message that a sink stores while receiving an earlier one lands in the other vector, and the iteration is undisturbed.

Constructor & Destructor Documentation

◆ MsgQueue()

MsgQueue::MsgQueue ( )

Start with both vectors empty and mFirst accepting.

Ghidra address:
NTSC-U/C: 0x0054a738
Ghidra address:
PAL: 0x0058ac68

◆ ~MsgQueue()

virtual MsgQueue::~MsgQueue ( )
virtual

Delete every stored message and release both vectors.

Ghidra address:
NTSC-U/C: 0x0054a7a0
Ghidra address:
PAL: 0x0058acd0

Member Function Documentation

◆ Store()

void MsgQueue::Store ( Message * pMsg)

Store a copy of a message without reading its identity first.

The body is DispatchPriv() with the Message::Type() call omitted.

Parameters
pMsgThe message to copy and store.
Ghidra address:
NTSC-U/C: 0x0054b220
Ghidra address:
PAL: 0x0058b750

◆ Poll()

void MsgQueue::Poll ( )

Deliver and discard every stored message.

The routine marks itself as running, swaps the accepting vector, then sends each stored message on to the queue's own sinks and deletes it. The drained vector is emptied afterwards. Rnd::World::DrawFrame() and slot 6 of the metagame renderer are the callers. Both run once per frame.

The title is inferred from the behaviour. The member is not virtual and both call sites are direct calls. No recovered metadata records a title for it.

Ghidra address:
NTSC-U/C: 0x0054aa58
Ghidra address:
PAL: 0x0058af88

◆ DispatchPriv()

virtual void MsgQueue::DispatchPriv ( Message * pMsg)
protectedvirtual

Store a copy of a message.

Parameters
pMsgThe message to copy and store.
Ghidra address:
NTSC-U/C: 0x0054b290
Ghidra address:
PAL: 0x0058b7c0

Implements MsgSink.


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