diff --git a/Core/GameEngine/Include/Common/GameDefines.h b/Core/GameEngine/Include/Common/GameDefines.h index 02229cfc8e..189e5b07a3 100644 --- a/Core/GameEngine/Include/Common/GameDefines.h +++ b/Core/GameEngine/Include/Common/GameDefines.h @@ -86,6 +86,14 @@ #define ENABLE_GUI_HACKS (1) #endif +// Tell our computer identity in the LAN lobby. Disable for privacy. +// Was enabled in the retail game and exposed the computer login and host names. +#ifdef RTS_DEBUG +#ifndef TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY +#define TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY (1) +#endif +#endif + #define MIN_DISPLAY_BIT_DEPTH 16 #define DEFAULT_DISPLAY_BIT_DEPTH 32 #define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for diff --git a/Generals/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h b/Generals/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h index 315ee7b227..15e492f3bb 100644 --- a/Generals/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h +++ b/Generals/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h @@ -74,7 +74,7 @@ extern const Color acceptFalseColor; void lanUpdateSlotList( void ); void updateGameOptions( void ); - +void setLANPlayerTooltip(LANPlayer* player); //Enum is used for the utility function so other windows do not need //to know about controls on LanGameOptions window. diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp index 46ccea0032..b72c833429 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp @@ -214,15 +214,8 @@ static void playerTooltip(GameWindow *window, TheMouse->setCursorTooltip( UnicodeString::TheEmptyString ); return; } - UnicodeString tooltip; - tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); -#if defined(RTS_DEBUG) - UnicodeString ip; - ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); - tooltip.concat(ip); -#endif - TheMouse->setCursorTooltip( tooltip ); + setLANPlayerTooltip(player); } void StartPressed(void) @@ -903,6 +896,29 @@ void updateGameOptions( void ) } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +void setLANPlayerTooltip(LANPlayer* player) +{ + UnicodeString tooltip; + + if (!player->getLogin().isEmpty() || !player->getHost().isEmpty()) + { + tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); + } + +#if defined(RTS_DEBUG) + UnicodeString ip; + ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); + tooltip.concat(ip); +#endif + + if (!tooltip.isEmpty()) + { + TheMouse->setCursorTooltip( tooltip ); + } +} + //------------------------------------------------------------------------------------------------- /** This is called when a shutdown is complete for this menu */ diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp index 28489122cf..5015309083 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp @@ -310,14 +310,8 @@ static void playerTooltip(GameWindow *window, //TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyPlayers") ); return; } - UnicodeString tooltip; - tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); -#if defined(RTS_DEBUG) - UnicodeString ip; - ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); - tooltip.concat(ip); -#endif - TheMouse->setCursorTooltip( tooltip ); + + setLANPlayerTooltip(player); } diff --git a/Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp b/Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp index 89a53cd1b6..5feff8444e 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -112,21 +112,29 @@ void LANAPI::init( void ) m_lastGameopt = ""; - unsigned long bufSize = UNLEN + 1; +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY char userName[UNLEN + 1]; - if (!GetUserName(userName, &bufSize)) + DWORD bufSize = ARRAY_SIZE(userName); + if (GetUserNameA(userName, &bufSize)) { - strcpy(userName, "unknown"); + m_userName.set(userName, bufSize); + } + else + { + m_userName = "unknown"; } - m_userName = userName; - bufSize = MAX_COMPUTERNAME_LENGTH + 1; char computerName[MAX_COMPUTERNAME_LENGTH + 1]; - if (!GetComputerName(computerName, &bufSize)) + bufSize = ARRAY_SIZE(computerName); + if (GetComputerNameA(computerName, &bufSize)) + { + m_hostName.set(computerName, bufSize); + } + else { - strcpy(computerName, "unknown"); + m_hostName = "unknown"; } - m_hostName = computerName; +#endif } void LANAPI::reset( void ) @@ -445,11 +453,13 @@ void LANAPI::update( void ) } else { +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY AsciiString text; text.format("User=%s", m_userName.str()); RequestGameOptions( text, true ); text.format("Host=%s", m_hostName.str()); RequestGameOptions( text, true ); +#endif RequestGameOptions( "HELLO", false ); } } diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h index ef31229a2d..8f4a726ce3 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h +++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h @@ -74,7 +74,7 @@ extern const Color acceptFalseColor; void lanUpdateSlotList( void ); void updateGameOptions( void ); - +void setLANPlayerTooltip(LANPlayer* player); //Enum is used for the utility function so other windows do not need //to know about controls on LanGameOptions window. diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp index d686c7130e..8e34a81e01 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp @@ -221,15 +221,8 @@ static void playerTooltip(GameWindow *window, TheMouse->setCursorTooltip( UnicodeString::TheEmptyString ); return; } - UnicodeString tooltip; - tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); -#if defined(RTS_DEBUG) - UnicodeString ip; - ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); - tooltip.concat(ip); -#endif - TheMouse->setCursorTooltip( tooltip ); + setLANPlayerTooltip(player); } void StartPressed(void) @@ -998,6 +991,29 @@ void updateGameOptions( void ) } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +void setLANPlayerTooltip(LANPlayer* player) +{ + UnicodeString tooltip; + + if (!player->getLogin().isEmpty() || !player->getHost().isEmpty()) + { + tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); + } + +#if defined(RTS_DEBUG) + UnicodeString ip; + ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); + tooltip.concat(ip); +#endif + + if (!tooltip.isEmpty()) + { + TheMouse->setCursorTooltip( tooltip ); + } +} + //------------------------------------------------------------------------------------------------- /** This is called when a shutdown is complete for this menu */ diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp index 59a4d7a786..1f1a8e2b05 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanLobbyMenu.cpp @@ -352,14 +352,8 @@ static void playerTooltip(GameWindow *window, //TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyPlayers") ); return; } - UnicodeString tooltip; - tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str()); -#if defined(RTS_DEBUG) - UnicodeString ip; - ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP())); - tooltip.concat(ip); -#endif - TheMouse->setCursorTooltip( tooltip ); + + setLANPlayerTooltip(player); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp index e10a45aa26..87027fe46d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -112,21 +112,29 @@ void LANAPI::init( void ) m_lastGameopt = ""; - unsigned long bufSize = UNLEN + 1; +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY char userName[UNLEN + 1]; - if (!GetUserName(userName, &bufSize)) + DWORD bufSize = ARRAY_SIZE(userName); + if (GetUserNameA(userName, &bufSize)) { - strcpy(userName, "unknown"); + m_userName.set(userName, bufSize); + } + else + { + m_userName = "unknown"; } - m_userName = userName; - bufSize = MAX_COMPUTERNAME_LENGTH + 1; char computerName[MAX_COMPUTERNAME_LENGTH + 1]; - if (!GetComputerName(computerName, &bufSize)) + bufSize = ARRAY_SIZE(computerName); + if (GetComputerNameA(computerName, &bufSize)) + { + m_hostName.set(computerName, bufSize); + } + else { - strcpy(computerName, "unknown"); + m_hostName = "unknown"; } - m_hostName = computerName; +#endif } void LANAPI::reset( void ) @@ -445,11 +453,13 @@ void LANAPI::update( void ) } else { +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY AsciiString text; text.format("User=%s", m_userName.str()); RequestGameOptions( text, true ); text.format("Host=%s", m_hostName.str()); RequestGameOptions( text, true ); +#endif RequestGameOptions( "HELLO", false ); } }