#include <NetCommandList.h>
Inherits MemoryPoolObject.
Public Member Functions | |
| NetCommandList () | |
| void | init () |
| Initialize the list. | |
| void | reset () |
| Reset the list to the initial state. | |
| NetCommandRef * | addMessage (NetCommandMsg *cmdMsg) |
| Add message to the list in its properly ordered place. | |
| Bool | isEqualCommandMsg (NetCommandMsg *msg1, NetCommandMsg *msg2) |
| NetCommandRef * | getFirstMessage () |
| Get the first message on the list. | |
| NetCommandRef * | findMessage (NetCommandMsg *msg) |
| Find and return a reference to the given message if one exists. | |
| NetCommandRef * | findMessage (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 | |
| NetCommandRef * | m_first |
| Head of the list. | |
| NetCommandRef * | m_last |
| Tail of the list. | |
| NetCommandRef * | m_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 MemoryPool * | getObjectMemoryPool ()=0 |
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.
| NetCommandList::NetCommandList | ( | ) |
Constructor.
Definition at line 34 of file NetCommandList.cpp.
| 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.
| 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.
| 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.
| 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.
| 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.
| void NetCommandList::init | ( | ) |
| Bool NetCommandList::isEqualCommandMsg | ( | NetCommandMsg * | msg1, |
| NetCommandMsg * | msg2 ) |
Definition at line 373 of file NetCommandList.cpp.
| 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.
| 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.
| void NetCommandList::reset | ( | ) |
Reset the list to the initial state.
Reset the contents of this list.
Definition at line 112 of file NetCommandList.cpp.
|
protected |
Head of the list.
Definition at line 69 of file NetCommandList.h.
|
protected |
Tail of the list.
Definition at line 70 of file NetCommandList.h.
|
protected |
The last message that was inserted to this list.
Definition at line 71 of file NetCommandList.h.