Changeset - r28795:d2835fac2109
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 3 months ago 2024-02-20 20:51:35
j.g.rennison@gmail.com
Fix cb588d8d: Ordering of command per tick limit and pause mode filtering (#12126)

The command per tick limit should be applied after the pause mode filter
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/network/network_command.cpp
Show inline comments
 
@@ -318,33 +318,33 @@ static void DistributeQueue(CommandQueue
 
	/* When replaying we do not want this limitation. */
 
	int to_go = UINT16_MAX;
 
#else
 
	int to_go = _settings_client.network.commands_per_frame;
 
	if (owner == nullptr) {
 
		/* This is the server, use the commands_per_frame_server setting if higher */
 
		to_go = std::max<int>(to_go, _settings_client.network.commands_per_frame_server);
 
	}
 
#endif
 

	
 
	/* Not technically the most performant way, but consider clients rarely click more than once per tick. */
 
	for (auto cp = queue.begin(); cp != queue.end(); /* removing some items */) {
 
		/* Limit the number of commands per client per tick. */
 
		if (--to_go < 0) break;
 

	
 
		/* Do not distribute commands when paused and the command is not allowed while paused. */
 
		if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cp->cmd)) {
 
			++cp;
 
			continue;
 
		}
 

	
 
		/* Limit the number of commands per client per tick. */
 
		if (--to_go < 0) break;
 

	
 
		DistributeCommandPacket(*cp, owner);
 
		NetworkAdminCmdLogging(owner, *cp);
 
		cp = queue.erase(cp);
 
	}
 
}
 

	
 
/** Distribute the commands of ourself and the clients. */
 
void NetworkDistributeCommands()
 
{
 
	/* First send the server's commands. */
 
	DistributeQueue(_local_wait_queue, nullptr);
 

	
0 comments (0 inline, 0 general)