Codechange: use std::vector for the incoming command queue

This commit is contained in:
Rubidium
2024-02-04 17:02:08 +01:00
committed by rubidium42
parent b3aa8a9c35
commit cb588d8d3f
6 changed files with 37 additions and 114 deletions

View File

@@ -131,24 +131,12 @@ enum PacketGameType : uint8_t {
/** Packet that wraps a command */
struct CommandPacket;
/** A queue of CommandPackets. */
class CommandQueue {
CommandPacket *first; ///< The first packet in the queue.
CommandPacket *last; ///< The last packet in the queue; only valid when first != nullptr.
uint count; ///< The number of items in the queue.
public:
/** Initialise the command queue. */
CommandQueue() : first(nullptr), last(nullptr), count(0) {}
/** Clear the command queue. */
~CommandQueue() { this->Free(); }
void Append(CommandPacket *p);
CommandPacket *Pop(bool ignore_paused = false);
CommandPacket *Peek(bool ignore_paused = false);
void Free();
/** Get the number of items in the queue. */
uint Count() const { return this->count; }
};
/**
* A "queue" of CommandPackets.
* Not a std::queue because, when paused, some commands remain on the queue.
* In other words, you do not always pop the first element from this queue.
*/
using CommandQueue = std::vector<CommandPacket>;
/** Base socket handler for all TCP sockets */
class NetworkGameSocketHandler : public NetworkTCPSocketHandler {