Skip to content

Commit 9ede47f

Browse files
committed
tweak(lan): Hide computer identity in LAN lobby (#1693)
1 parent 1e37075 commit 9ede47f

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

Core/GameEngine/Include/Common/GameDefines.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
#define ENABLE_GUI_HACKS (1)
8787
#endif
8888

89+
// Tell our computer identity in the LAN lobby. Disable for privacy.
90+
// Was enabled in the retail game and exposed the computer login and host names.
91+
#ifdef RTS_DEBUG
92+
#ifndef TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY
93+
#define TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY (1)
94+
#endif
95+
#endif
96+
8997
#define MIN_DISPLAY_BIT_DEPTH 16
9098
#define DEFAULT_DISPLAY_BIT_DEPTH 32
9199
#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,22 @@ void updateGameOptions( void )
901901
void setLANPlayerTooltip(LANPlayer* player)
902902
{
903903
UnicodeString tooltip;
904-
tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str());
904+
905+
if (!player->getLogin().isEmpty() || !player->getHost().isEmpty())
906+
{
907+
tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str());
908+
}
909+
905910
#if defined(RTS_DEBUG)
906911
UnicodeString ip;
907912
ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP()));
908913
tooltip.concat(ip);
909914
#endif
910-
TheMouse->setCursorTooltip( tooltip );
911915

916+
if (!tooltip.isEmpty())
917+
{
918+
TheMouse->setCursorTooltip( tooltip );
919+
}
912920
}
913921

914922

Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ void LANAPI::init( void )
112112

113113
m_lastGameopt = "";
114114

115+
#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY
115116
char userName[UNLEN + 1];
116117
DWORD bufSize = ARRAY_SIZE(userName);
117118
if (GetUserNameA(userName, &bufSize))
@@ -133,6 +134,7 @@ void LANAPI::init( void )
133134
{
134135
m_hostName = "unknown";
135136
}
137+
#endif
136138
}
137139

138140
void LANAPI::reset( void )
@@ -451,11 +453,13 @@ void LANAPI::update( void )
451453
}
452454
else
453455
{
456+
#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY
454457
AsciiString text;
455458
text.format("User=%s", m_userName.str());
456459
RequestGameOptions( text, true );
457460
text.format("Host=%s", m_hostName.str());
458461
RequestGameOptions( text, true );
462+
#endif
459463
RequestGameOptions( "HELLO", false );
460464
}
461465
}

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,14 +996,22 @@ void updateGameOptions( void )
996996
void setLANPlayerTooltip(LANPlayer* player)
997997
{
998998
UnicodeString tooltip;
999-
tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str());
999+
1000+
if (!player->getLogin().isEmpty() || !player->getHost().isEmpty())
1001+
{
1002+
tooltip.format(TheGameText->fetch("TOOLTIP:LANPlayer"), player->getLogin().str(), player->getHost().str());
1003+
}
1004+
10001005
#if defined(RTS_DEBUG)
10011006
UnicodeString ip;
10021007
ip.format(L" - %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(player->getIP()));
10031008
tooltip.concat(ip);
10041009
#endif
1005-
TheMouse->setCursorTooltip( tooltip );
10061010

1011+
if (!tooltip.isEmpty())
1012+
{
1013+
TheMouse->setCursorTooltip( tooltip );
1014+
}
10071015
}
10081016

10091017

GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ void LANAPI::init( void )
112112

113113
m_lastGameopt = "";
114114

115+
#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY
115116
char userName[UNLEN + 1];
116117
DWORD bufSize = ARRAY_SIZE(userName);
117118
if (GetUserNameA(userName, &bufSize))
@@ -133,6 +134,7 @@ void LANAPI::init( void )
133134
{
134135
m_hostName = "unknown";
135136
}
137+
#endif
136138
}
137139

138140
void LANAPI::reset( void )
@@ -451,11 +453,13 @@ void LANAPI::update( void )
451453
}
452454
else
453455
{
456+
#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY
454457
AsciiString text;
455458
text.format("User=%s", m_userName.str());
456459
RequestGameOptions( text, true );
457460
text.format("Host=%s", m_hostName.str());
458461
RequestGameOptions( text, true );
462+
#endif
459463
RequestGameOptions( "HELLO", false );
460464
}
461465
}

0 commit comments

Comments
 (0)