OpenTTD
Public Member Functions | Private Attributes
CommandQueue Class Reference

A queue of CommandPackets. More...

#include <tcp_game.h>

Public Member Functions

 CommandQueue ()
 Initialise the command queue.
 ~CommandQueue ()
 Clear the command queue.
void Append (CommandPacket *p)
 Append a CommandPacket at the end of the queue.
CommandPacketPop (bool ignore_paused=false)
 Return the first item in the queue and remove it from the queue.
CommandPacketPeek (bool ignore_paused=false)
 Return the first item in the queue, but don't remove it.
void Free ()
 Free everything that is in the queue.
uint Count () const
 Get the number of items in the queue.

Private Attributes

CommandPacketfirst
 The first packet in the queue.
CommandPacketlast
 The last packet in the queue; only valid when first != NULL.
uint count
 The number of items in the queue.

Detailed Description

A queue of CommandPackets.

Definition at line 133 of file tcp_game.h.

Constructor & Destructor Documentation

CommandQueue::CommandQueue ( )
inline

Initialise the command queue.

Definition at line 140 of file tcp_game.h.

CommandQueue::~CommandQueue ( )
inline

Clear the command queue.

Definition at line 142 of file tcp_game.h.

References Free().

Member Function Documentation

void CommandQueue::Append ( CommandPacket p)

Append a CommandPacket at the end of the queue.

Parameters
pThe packet to append to the queue.
Note
A new instance of the CommandPacket will be made.

Definition at line 61 of file network_command.cpp.

References count, first, last, and CommandPacket::next.

Referenced by DistributeCommandPacket(), NetworkSendCommand(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), and ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND().

uint CommandQueue::Count ( ) const
inline

Get the number of items in the queue.

Definition at line 148 of file tcp_game.h.

References count.

Referenced by ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND().

void CommandQueue::Free ( )

Free everything that is in the queue.

Definition at line 116 of file network_command.cpp.

References count, free(), and Pop().

Referenced by NetworkFreeLocalCommandQueue(), and ~CommandQueue().

CommandPacket * CommandQueue::Peek ( bool  ignore_paused = false)

Return the first item in the queue, but don't remove it.

Parameters
ignore_pausedWhether to ignore commands that may not be executed while paused.
Returns
the first item in the queue.

Definition at line 105 of file network_command.cpp.

References _pause_mode, first, IsCommandAllowedWhilePaused(), CommandPacket::next, and PM_UNPAUSED.

Referenced by NetworkExecuteLocalCommandQueue(), and NetworkSyncCommandQueue().

CommandPacket * CommandQueue::Pop ( bool  ignore_paused = false)

Return the first item in the queue and remove it from the queue.

Parameters
ignore_pausedWhether to ignore commands that may not be executed while paused.
Returns
the first item in the queue.

Definition at line 80 of file network_command.cpp.

References _pause_mode, CommandContainer::cmd, count, first, IsCommandAllowedWhilePaused(), last, CommandPacket::next, and PM_UNPAUSED.

Referenced by DistributeQueue(), Free(), and NetworkExecuteLocalCommandQueue().


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