Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
NetCommandList Class Reference

#include <NetCommandList.h>

Inherits MemoryPoolObject.

Public Member Functions

 NetCommandList ()
 
void init ()
 Initialize the list.
 
void reset ()
 Reset the list to the initial state.
 
NetCommandRefaddMessage (NetCommandMsg *cmdMsg)
 Add message to the list in its properly ordered place.
 
Bool isEqualCommandMsg (NetCommandMsg *msg1, NetCommandMsg *msg2)
 
NetCommandRefgetFirstMessage ()
 Get the first message on the list.
 
NetCommandReffindMessage (NetCommandMsg *msg)
 Find and return a reference to the given message if one exists.
 
NetCommandReffindMessage (UnsignedShort commandID, UnsignedByte playerID)
 
void removeMessage (NetCommandRef *msg)
 Remove the given message from the list.
 
void appendList (NetCommandList *list)
 Append the given list to the end of this list.
 
Int length ()
 Returns the number of nodes in this list. This is inefficient and is meant to be a debug tool.
 
- Public Member Functions inherited from MemoryPoolObject
void deleteInstance ()
 

Protected Attributes

NetCommandRefm_first
 Head of the list.
 
NetCommandRefm_last
 Tail of the list.
 
NetCommandRefm_lastMessageInserted
 The last message that was inserted to this list.
 

Additional Inherited Members

- Protected Member Functions inherited from MemoryPoolObject
virtual ~MemoryPoolObject ()
 
void * operator new (size_t s)
 
void operator delete (void *p)
 
virtual MemoryPoolgetObjectMemoryPool ()=0
 

Detailed Description

The NetCommandList is a ordered linked list of NetCommandRef objects. The list is ordered based on the command id, player id, and command type. It is ordered in this way to aid in constructing the packets efficiently. The list keeps track of the last message inserted in order to accommodate adding commands in order more efficiently since that is whats going to be done most of the time. If the new message doesn't go after the last message inserted, then the list will be traversed linearly until the proper spot is found. We can get away with this inefficient method since these occurances will be rare. Also, the list is not expected to ever have more than 30 or so commands on it at a time. Five commands would probably be a normal amount.

Definition at line 47 of file NetCommandList.h.

Constructor & Destructor Documentation

◆ NetCommandList()

NetCommandList::NetCommandList ( )

Constructor.

Definition at line 34 of file NetCommandList.cpp.

Member Function Documentation

◆ addMessage()

NetCommandRef * NetCommandList::addMessage ( NetCommandMsg * cmdMsg)

Add message to the list in its properly ordered place.

Insert sorts msg. Assumes that all the previous message inserts were done using this function. The message is sorted in based first on command type, then player id, and then command id.

Definition at line 129 of file NetCommandList.cpp.

◆ appendList()

void NetCommandList::appendList ( NetCommandList * list)

Append the given list to the end of this list.

Append the given list of commands to this list.

Definition at line 50 of file NetCommandList.cpp.

◆ findMessage() [1/2]

NetCommandRef * NetCommandList::findMessage ( NetCommandMsg * msg)

Find and return a reference to the given message if one exists.

This is really inefficient, but we can probably get away with it because there shouldn't be too many messages for any given frame.

Definition at line 352 of file NetCommandList.cpp.

◆ findMessage() [2/2]

NetCommandRef * NetCommandList::findMessage ( UnsignedShort commandID,
UnsignedByte playerID )

Find and return a reference to the message given the player id and the command id. This will only check against messages of types that require a command id.

Definition at line 360 of file NetCommandList.cpp.

◆ getFirstMessage()

NetCommandRef * NetCommandList::getFirstMessage ( )

Get the first message on the list.

Return the first message in this list.

Definition at line 72 of file NetCommandList.cpp.

◆ init()

void NetCommandList::init ( )

Initialize the list.

Initialize the list.

Definition at line 105 of file NetCommandList.cpp.

◆ isEqualCommandMsg()

Bool NetCommandList::isEqualCommandMsg ( NetCommandMsg * msg1,
NetCommandMsg * msg2 )

Definition at line 373 of file NetCommandList.cpp.

◆ length()

Int NetCommandList::length ( )

Returns the number of nodes in this list. This is inefficient and is meant to be a debug tool.

Definition at line 338 of file NetCommandList.cpp.

◆ removeMessage()

void NetCommandList::removeMessage ( NetCommandRef * msg)

Remove the given message from the list.

Remove the given message from this list.

Definition at line 79 of file NetCommandList.cpp.

◆ reset()

void NetCommandList::reset ( )

Reset the list to the initial state.

Reset the contents of this list.

Definition at line 112 of file NetCommandList.cpp.

Member Data Documentation

◆ m_first

NetCommandRef* NetCommandList::m_first
protected

Head of the list.

Definition at line 69 of file NetCommandList.h.

◆ m_last

NetCommandRef* NetCommandList::m_last
protected

Tail of the list.

Definition at line 70 of file NetCommandList.h.

◆ m_lastMessageInserted

NetCommandRef* NetCommandList::m_lastMessageInserted
protected

The last message that was inserted to this list.

Definition at line 71 of file NetCommandList.h.


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