From eefb930120aa329c9ae4ec54f4cffd6a5f603e91 Mon Sep 17 00:00:00 2001 From: mathusummut Date: Fri, 14 Dec 2018 08:45:11 +0100 Subject: [PATCH] Fixed nework UI bugs --- source/glest_game/menu/menu_state_connected_game.cpp | 8 ++++---- source/shared_lib/sources/platform/posix/socket.cpp | 10 ++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 98c6edda8..38f903f19 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -3626,12 +3626,12 @@ namespace Game { ClientInterface * clientInterface = networkManager.getClientInterface(); for (int i = 0; i < GameConstants::maxPlayers; ++i) { - if (listBoxControls[i].getSelectedItemIndex() == ctNetwork) { + /*if (listBoxControls[i].getSelectedItemIndex() == ctNetwork) { bool renderIt = true; //printf("Player #%d [%s] control = %d\n",i,labelPlayerNames[i].getText().c_str(),listBoxControls[i].getSelectedItemIndex()); - /*if (labelNetStatus[i].getText().length() == 0) { + if (labelNetStatus[i].getText().length() == 0) { renderIt = false; - }*/ + } labelPlayers[i].setVisible(renderIt); labelPlayerNames[i].setVisible(renderIt); listBoxControls[i].setVisible(renderIt); @@ -3639,7 +3639,7 @@ namespace Game { listBoxFactions[i].setVisible(renderIt); listBoxTeams[i].setVisible(renderIt); labelNetStatus[i].setVisible(renderIt); - } + }*/ if (listBoxControls[i].getSelectedItemIndex() != ctClosed) { renderer.renderLabel(&labelPlayerStatus[i]); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 51caa7fb1..22f078775 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -2100,15 +2100,12 @@ namespace Shared { std::vector foundServers; - short port; // The port for the broadcast. struct sockaddr_in bcSender; // local socket address for the broadcast. struct sockaddr_in bcaddr; // The broadcast address for the receiver. PLATFORM_SOCKET bcfd; // The file descriptor used for the broadcast. //bool one = true; // Parameter for "setscokopt". socklen_t alen = 0; - port = htons(Socket::getBroadCastPort()); - // Prepare to receive the broadcast. bcfd = socket(AF_INET, SOCK_DGRAM, 0); if (bcfd <= 0) { @@ -2118,7 +2115,7 @@ namespace Shared { memset((char*) &bcaddr, 0, sizeof(bcaddr)); bcaddr.sin_family = AF_INET; bcaddr.sin_addr.s_addr = htonl(INADDR_ANY); - bcaddr.sin_port = htons(port); + bcaddr.sin_port = htons(Socket::getBroadCastPort()); int val = 1; #ifndef WIN32 @@ -2920,7 +2917,6 @@ namespace Shared { if (SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork, "Broadcast thread is running\n"); const int MAX_NIC_COUNT = 10; - short port = 0; // The port for the broadcast. struct sockaddr_in bcLocal[MAX_NIC_COUNT]; // local socket address for the broadcast. PLATFORM_SOCKET bcfd[MAX_NIC_COUNT]; // The socket used for the broadcast. int one = 1; // Parameter for "setscokopt". @@ -2970,8 +2966,6 @@ namespace Shared { ipSubnetMaskList.push_back("*"); } - port = htons(Socket::getBroadCastPort()); - //for(unsigned int idx = 0; idx < ipList.size() && idx < MAX_NIC_COUNT; idx++) { for (unsigned int idx = 0; idx < (unsigned int) ipSubnetMaskList.size(); idx++) { // Create the broadcast socket @@ -2985,7 +2979,7 @@ namespace Shared { if (SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork, "UDP Socket broadcast using IP [%s]\n", ipSubnetMaskList[idx].c_str()); bcLocal[idx].sin_addr.s_addr = inet_addr(ipSubnetMaskList[idx].c_str()); //htonl( INADDR_BROADCAST ); } - bcLocal[idx].sin_port = htons(port); // We are letting the OS fill in the port number for the local machine. + bcLocal[idx].sin_port = htons(Socket::getBroadCastPort()); // We are letting the OS fill in the port number for the local machine. #ifdef WIN32 bcfd[idx] = INVALID_SOCKET; #else