mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: use std::vector for the outgoing command "queues"
This commit is contained in:
parent
09a12f230f
commit
b3aa8a9c35
@ -304,9 +304,8 @@ void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *cal
|
||||
void NetworkSyncCommandQueue(NetworkClientSocket *cs)
|
||||
{
|
||||
for (CommandPacket *p = _local_execution_queue.Peek(); p != nullptr; p = p->next) {
|
||||
CommandPacket c = *p;
|
||||
CommandPacket &c = cs->outgoing_queue.emplace_back(*p);
|
||||
c.callback = nullptr;
|
||||
cs->outgoing_queue.Append(&c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,7 +370,7 @@ static void DistributeCommandPacket(CommandPacket &cp, const NetworkClientSocket
|
||||
* first place. This filters that out. */
|
||||
cp.callback = (cs != owner) ? nullptr : callback;
|
||||
cp.my_cmd = (cs == owner);
|
||||
cs->outgoing_queue.Append(&cp);
|
||||
cs->outgoing_queue.push_back(cp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1701,11 +1701,8 @@ void NetworkServerSetCompanyPassword(CompanyID company_id, const std::string &pa
|
||||
*/
|
||||
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
|
||||
{
|
||||
CommandPacket *cp;
|
||||
while ((cp = cs->outgoing_queue.Pop()) != nullptr) {
|
||||
cs->SendCommand(cp);
|
||||
delete cp;
|
||||
}
|
||||
for (auto &cp : cs->outgoing_queue) cs->SendCommand(&cp);
|
||||
cs->outgoing_queue.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
byte last_token; ///< The last random token we did send to verify the client is listening
|
||||
uint32_t last_token_frame; ///< The last frame we received the right token
|
||||
ClientStatus status; ///< Status of this client
|
||||
CommandQueue outgoing_queue; ///< The command-queue awaiting delivery
|
||||
std::vector<CommandPacket> outgoing_queue; ///< The command-queue awaiting delivery; conceptually more a bucket to gather commands in, after which the whole bucket is sent to the client.
|
||||
size_t receive_limit; ///< Amount of bytes that we can receive at this moment
|
||||
|
||||
std::shared_ptr<struct PacketWriter> savegame; ///< Writer used to write the savegame.
|
||||
|
Loading…
Reference in New Issue
Block a user