OpenTTD
|
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. | |
CommandPacket * | Pop (bool ignore_paused=false) |
Return the first item in the queue and remove it from the queue. | |
CommandPacket * | Peek (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 | |
CommandPacket * | first |
The first packet in the queue. | |
CommandPacket * | last |
The last packet in the queue; only valid when first != NULL. | |
uint | count |
The number of items in the queue. |
A queue of CommandPackets.
Definition at line 133 of file tcp_game.h.
|
inline |
Initialise the command queue.
Definition at line 140 of file tcp_game.h.
|
inline |
void CommandQueue::Append | ( | CommandPacket * | p | ) |
Append a CommandPacket at the end of the queue.
p | The packet to append to the queue. |
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().
|
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.
ignore_paused | Whether to ignore commands that may not be executed while paused. |
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.
ignore_paused | Whether to ignore commands that may not be executed while paused. |
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().