Changeset - r28690:c7e4e84fc4dc
[Not reviewed]
master
0 3 0
Rubidium - 10 months ago 2024-02-04 15:23:44
rubidium@openttd.org
Codechange: use std::vector for the outgoing command "queues"
3 files changed with 5 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/network/network_command.cpp
Show inline comments
 
@@ -304,9 +304,8 @@ void NetworkSendCommand(Commands cmd, St
 
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(Comm
 
			 *  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);
 
		}
 
	}
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -1701,11 +1701,8 @@ void NetworkServerSetCompanyPassword(Com
 
 */
 
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();
 
}
 

	
 
/**
src/network/network_server.h
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)