1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-21 14:53:02 +01:00

Fixes clients receiving commands before the map data is sent and loaded.

This commit is contained in:
ZehM4tt
2017-06-16 07:53:20 +02:00
committed by Michał Janiszewski
parent bb0a655558
commit ea59769cfd
2 changed files with 12 additions and 3 deletions

View File

@@ -595,9 +595,18 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
return formatted; return formatted;
} }
void Network::SendPacketToClients(NetworkPacket& packet, bool front) void Network::SendPacketToClients(NetworkPacket& packet, bool front, bool gameCmd)
{ {
for (auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) { for (auto it = client_connection_list.begin(); it != client_connection_list.end(); it++) {
if (gameCmd) {
// If marked as game command we can not send the packet to connections that are not fully connected.
// Sending the packet would cause the client to store a command that is behind the tick where he starts,
// which would be essentially never executed. The clients do not require commands before the map is loaded.
if ((*it)->Player == nullptr) {
continue;
}
}
(*it)->QueuePacket(NetworkPacket::Duplicate(packet), front); (*it)->QueuePacket(NetworkPacket::Duplicate(packet), front);
} }
} }
@@ -1122,7 +1131,7 @@ void Network::Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate()); std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) *packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
<< ecx << edx << esi << edi << ebp << playerid << callback; << ecx << edx << esi << edi << ebp << playerid << callback;
SendPacketToClients(*packet); SendPacketToClients(*packet, false, true);
} }
void Network::Server_Send_TICK() void Network::Server_Send_TICK()

View File

@@ -113,7 +113,7 @@ public:
std::vector<std::unique_ptr<NetworkGroup>>::iterator GetGroupIteratorByID(uint8 id); std::vector<std::unique_ptr<NetworkGroup>>::iterator GetGroupIteratorByID(uint8 id);
NetworkGroup* GetGroupByID(uint8 id); NetworkGroup* GetGroupByID(uint8 id);
static const char* FormatChat(NetworkPlayer* fromplayer, const char* text); static const char* FormatChat(NetworkPlayer* fromplayer, const char* text);
void SendPacketToClients(NetworkPacket& packet, bool front = false); void SendPacketToClients(NetworkPacket& packet, bool front = false, bool gameCmd = false);
bool CheckSRAND(uint32 tick, uint32 srand0); bool CheckSRAND(uint32 tick, uint32 srand0);
void KickPlayer(sint32 playerId); void KickPlayer(sint32 playerId);
void SetPassword(const char* password); void SetPassword(const char* password);