mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 12:33:17 +01:00
Format to break long lines in network.cpp
[ci skip]
This commit is contained in:
@@ -398,7 +398,8 @@ int NetworkConnection::ReadPacket()
|
||||
} else {
|
||||
// read packet data
|
||||
if (inboundpacket.data->capacity() > 0) {
|
||||
int readBytes = recv(socket, (char*)&inboundpacket.GetData()[inboundpacket.transferred - sizeof(inboundpacket.size)], sizeof(inboundpacket.size) + inboundpacket.size - inboundpacket.transferred, 0);
|
||||
int readBytes = recv(socket, (char*)&inboundpacket.GetData()[inboundpacket.transferred - sizeof(inboundpacket.size)],
|
||||
sizeof(inboundpacket.size) + inboundpacket.size - inboundpacket.transferred, 0);
|
||||
if (readBytes == SOCKET_ERROR || readBytes == 0) {
|
||||
if (LAST_SOCKET_ERROR() != EWOULDBLOCK && LAST_SOCKET_ERROR() != EAGAIN) {
|
||||
return NETWORK_READPACKET_DISCONNECTED;
|
||||
@@ -880,7 +881,8 @@ void Network::UpdateClient()
|
||||
break;
|
||||
}
|
||||
|
||||
if (connect(server_connection.socket, (sockaddr *)&(*server_address.ss), (*server_address.ss_len)) == SOCKET_ERROR && (LAST_SOCKET_ERROR() == EINPROGRESS || LAST_SOCKET_ERROR() == EWOULDBLOCK)){
|
||||
if (connect(server_connection.socket, (sockaddr *)&(*server_address.ss),
|
||||
(*server_address.ss_len)) == SOCKET_ERROR && (LAST_SOCKET_ERROR() == EINPROGRESS || LAST_SOCKET_ERROR() == EWOULDBLOCK)){
|
||||
char str_connecting[256];
|
||||
format_string(str_connecting, STR_MULTIPLAYER_CONNECTING, NULL);
|
||||
window_network_status_open(str_connecting, []() -> void {
|
||||
@@ -946,7 +948,8 @@ void Network::UpdateClient()
|
||||
}break;
|
||||
case NETWORK_STATUS_CONNECTED:
|
||||
if (!ProcessConnection(server_connection)) {
|
||||
if (server_connection.authstatus == NETWORK_AUTH_REQUIREPASSWORD) { // Do not show disconnect message window when password window closed/canceled
|
||||
// Do not show disconnect message window when password window closed/canceled
|
||||
if (server_connection.authstatus == NETWORK_AUTH_REQUIREPASSWORD) {
|
||||
window_network_status_close();
|
||||
} else {
|
||||
char str_disconnected[256];
|
||||
@@ -1219,7 +1222,9 @@ NetworkGroup* Network::AddGroup()
|
||||
int newid = -1;
|
||||
// Find first unused group id
|
||||
for (int id = 0; id < 255; id++) {
|
||||
if (std::find_if(group_list.begin(), group_list.end(), [&id](std::unique_ptr<NetworkGroup> const& group) { return group->id == id; }) == group_list.end()) {
|
||||
if (std::find_if(group_list.begin(), group_list.end(), [&id](std::unique_ptr<NetworkGroup> const& group) {
|
||||
return group->id == id;
|
||||
}) == group_list.end()) {
|
||||
newid = id;
|
||||
break;
|
||||
}
|
||||
@@ -1439,14 +1444,16 @@ void Network::Server_Send_CHAT(const char* text)
|
||||
void Network::Client_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet = std::move(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << ecx << edx << esi << edi << ebp << callback;
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
<< ecx << edx << esi << edi << ebp << callback;
|
||||
server_connection.QueuePacket(std::move(packet));
|
||||
}
|
||||
|
||||
void Network::Server_Send_GAMECMD(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp, uint8 playerid, uint8 callback)
|
||||
{
|
||||
std::unique_ptr<NetworkPacket> packet = std::move(NetworkPacket::Allocate());
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED) << ecx << edx << esi << edi << ebp << playerid << callback;
|
||||
*packet << (uint32)NETWORK_COMMAND_GAMECMD << (uint32)gCurrentTicks << eax << (ebx | GAME_COMMAND_FLAG_NETWORKED)
|
||||
<< ecx << edx << esi << edi << ebp << playerid << callback;
|
||||
SendPacketToClients(*packet);
|
||||
}
|
||||
|
||||
@@ -1674,7 +1681,9 @@ void Network::RemoveClient(std::unique_ptr<NetworkConnection>& connection)
|
||||
chat_history_add(text);
|
||||
gNetwork.Server_Send_EVENT_PLAYER_DISCONNECTED((char*)connection_player->name, connection->getLastDisconnectReason());
|
||||
}
|
||||
player_list.erase(std::remove_if(player_list.begin(), player_list.end(), [connection_player](std::unique_ptr<NetworkPlayer>& player){ return player.get() == connection_player; }), player_list.end());
|
||||
player_list.erase(std::remove_if(player_list.begin(), player_list.end(), [connection_player](std::unique_ptr<NetworkPlayer>& player){
|
||||
return player.get() == connection_player;
|
||||
}), player_list.end());
|
||||
client_connection_list.remove(connection);
|
||||
Server_Send_PLAYERLIST();
|
||||
}
|
||||
@@ -1686,7 +1695,9 @@ NetworkPlayer* Network::AddPlayer()
|
||||
if (GetMode() == NETWORK_MODE_SERVER) {
|
||||
// Find first unused player id
|
||||
for (int id = 0; id < 255; id++) {
|
||||
if (std::find_if(player_list.begin(), player_list.end(), [&id](std::unique_ptr<NetworkPlayer> const& player) { return player->id == id; }) == player_list.end()) {
|
||||
if (std::find_if(player_list.begin(), player_list.end(), [&id](std::unique_ptr<NetworkPlayer> const& player) {
|
||||
return player->id == id;
|
||||
}) == player_list.end()) {
|
||||
newid = id;
|
||||
break;
|
||||
}
|
||||
@@ -1708,7 +1719,8 @@ void Network::PrintError()
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
wchar_t *s = NULL;
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, LAST_SOCKET_ERROR(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&s, 0, NULL);
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
LAST_SOCKET_ERROR(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&s, 0, NULL);
|
||||
fprintf(stderr, "%S\n", s);
|
||||
LocalFree(s);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user