OpenTTD Source  1.11.2
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. More...
 
CommandPacketPop (bool ignore_paused=false)
 Return the first item in the queue and remove it from the queue. More...
 
CommandPacketPeek (bool ignore_paused=false)
 Return the first item in the queue, but don't remove it. More...
 
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 != nullptr.
 
uint count
 The number of items in the queue.
 

Detailed Description

A queue of CommandPackets.

Definition at line 134 of file tcp_game.h.

Member Function Documentation

◆ Append()

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 57 of file network_command.cpp.

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

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

◆ Peek()

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 101 of file network_command.cpp.

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

Referenced by NetworkExecuteLocalCommandQueue(), and NetworkSyncCommandQueue().

◆ Pop()

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 76 of file network_command.cpp.

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

Referenced by Free(), and NetworkExecuteLocalCommandQueue().


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