File tree Expand file tree Collapse file tree 8 files changed +66
-50
lines changed
GeneralsMD/Code/GameEngine Expand file tree Collapse file tree 8 files changed +66
-50
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ extern const Color acceptFalseColor;
7474
7575void lanUpdateSlotList ( void );
7676void updateGameOptions ( void );
77-
77+ void setLANPlayerTooltip ( LANPlayer * player );
7878
7979//Enum is used for the utility function so other windows do not need
8080//to know about controls on LanGameOptions window.
Original file line number Diff line number Diff line change @@ -214,15 +214,8 @@ static void playerTooltip(GameWindow *window,
214214 TheMouse->setCursorTooltip ( UnicodeString::TheEmptyString );
215215 return ;
216216 }
217- UnicodeString tooltip;
218- tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
219- #if defined(RTS_DEBUG)
220- UnicodeString ip;
221- ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
222- tooltip.concat (ip);
223- #endif
224217
225- TheMouse-> setCursorTooltip ( tooltip );
218+ setLANPlayerTooltip (player );
226219}
227220
228221void StartPressed (void )
@@ -903,6 +896,21 @@ void updateGameOptions( void )
903896}
904897
905898
899+ // -------------------------------------------------------------------------------------------------
900+ // -------------------------------------------------------------------------------------------------
901+ void setLANPlayerTooltip (LANPlayer* player)
902+ {
903+ UnicodeString tooltip;
904+ tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
905+ #if defined(RTS_DEBUG)
906+ UnicodeString ip;
907+ ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
908+ tooltip.concat (ip);
909+ #endif
910+ TheMouse->setCursorTooltip ( tooltip );
911+
912+ }
913+
906914
907915// -------------------------------------------------------------------------------------------------
908916/* * This is called when a shutdown is complete for this menu */
Original file line number Diff line number Diff line change @@ -310,14 +310,8 @@ static void playerTooltip(GameWindow *window,
310310 // TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyPlayers") );
311311 return ;
312312 }
313- UnicodeString tooltip;
314- tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
315- #if defined(RTS_DEBUG)
316- UnicodeString ip;
317- ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
318- tooltip.concat (ip);
319- #endif
320- TheMouse->setCursorTooltip ( tooltip );
313+
314+ setLANPlayerTooltip (player);
321315}
322316
323317
Original file line number Diff line number Diff line change @@ -112,21 +112,27 @@ void LANAPI::init( void )
112112
113113 m_lastGameopt = " " ;
114114
115- unsigned long bufSize = UNLEN + 1 ;
116115 char userName[UNLEN + 1 ];
117- if (!GetUserName (userName, &bufSize))
116+ DWORD bufSize = ARRAY_SIZE (userName);
117+ if (GetUserNameA (userName, &bufSize))
118118 {
119- strcpy (userName, " unknown" );
119+ m_userName.set (userName, bufSize);
120+ }
121+ else
122+ {
123+ m_userName = " unknown" ;
120124 }
121- m_userName = userName;
122125
123- bufSize = MAX_COMPUTERNAME_LENGTH + 1 ;
124126 char computerName[MAX_COMPUTERNAME_LENGTH + 1 ];
125- if (!GetComputerName (computerName, &bufSize))
127+ bufSize = ARRAY_SIZE (computerName);
128+ if (GetComputerNameA (computerName, &bufSize))
129+ {
130+ m_hostName.set (computerName, bufSize);
131+ }
132+ else
126133 {
127- strcpy (computerName, " unknown" ) ;
134+ m_hostName = " unknown" ;
128135 }
129- m_hostName = computerName;
130136}
131137
132138void LANAPI::reset ( void )
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ extern const Color acceptFalseColor;
7474
7575void lanUpdateSlotList ( void );
7676void updateGameOptions ( void );
77-
77+ void setLANPlayerTooltip ( LANPlayer * player );
7878
7979//Enum is used for the utility function so other windows do not need
8080//to know about controls on LanGameOptions window.
Original file line number Diff line number Diff line change @@ -221,15 +221,8 @@ static void playerTooltip(GameWindow *window,
221221 TheMouse->setCursorTooltip ( UnicodeString::TheEmptyString );
222222 return ;
223223 }
224- UnicodeString tooltip;
225- tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
226- #if defined(RTS_DEBUG)
227- UnicodeString ip;
228- ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
229- tooltip.concat (ip);
230- #endif
231224
232- TheMouse-> setCursorTooltip ( tooltip );
225+ setLANPlayerTooltip (player );
233226}
234227
235228void StartPressed (void )
@@ -998,6 +991,21 @@ void updateGameOptions( void )
998991}
999992
1000993
994+ // -------------------------------------------------------------------------------------------------
995+ // -------------------------------------------------------------------------------------------------
996+ void setLANPlayerTooltip (LANPlayer* player)
997+ {
998+ UnicodeString tooltip;
999+ tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
1000+ #if defined(RTS_DEBUG)
1001+ UnicodeString ip;
1002+ ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
1003+ tooltip.concat (ip);
1004+ #endif
1005+ TheMouse->setCursorTooltip ( tooltip );
1006+
1007+ }
1008+
10011009
10021010// -------------------------------------------------------------------------------------------------
10031011/* * This is called when a shutdown is complete for this menu */
Original file line number Diff line number Diff line change @@ -352,14 +352,8 @@ static void playerTooltip(GameWindow *window,
352352 // TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyPlayers") );
353353 return ;
354354 }
355- UnicodeString tooltip;
356- tooltip.format (TheGameText->fetch (" TOOLTIP:LANPlayer" ), player->getLogin ().str (), player->getHost ().str ());
357- #if defined(RTS_DEBUG)
358- UnicodeString ip;
359- ip.format (L" - %d.%d.%d.%d" , PRINTF_IP_AS_4_INTS (player->getIP ()));
360- tooltip.concat (ip);
361- #endif
362- TheMouse->setCursorTooltip ( tooltip );
355+
356+ setLANPlayerTooltip (player);
363357}
364358
365359
Original file line number Diff line number Diff line change @@ -112,21 +112,27 @@ void LANAPI::init( void )
112112
113113 m_lastGameopt = " " ;
114114
115- unsigned long bufSize = UNLEN + 1 ;
116115 char userName[UNLEN + 1 ];
117- if (!GetUserName (userName, &bufSize))
116+ DWORD bufSize = ARRAY_SIZE (userName);
117+ if (GetUserNameA (userName, &bufSize))
118118 {
119- strcpy (userName, " unknown" );
119+ m_userName.set (userName, bufSize);
120+ }
121+ else
122+ {
123+ m_userName = " unknown" ;
120124 }
121- m_userName = userName;
122125
123- bufSize = MAX_COMPUTERNAME_LENGTH + 1 ;
124126 char computerName[MAX_COMPUTERNAME_LENGTH + 1 ];
125- if (!GetComputerName (computerName, &bufSize))
127+ bufSize = ARRAY_SIZE (computerName);
128+ if (GetComputerNameA (computerName, &bufSize))
129+ {
130+ m_hostName.set (computerName, bufSize);
131+ }
132+ else
126133 {
127- strcpy (computerName, " unknown" ) ;
134+ m_hostName = " unknown" ;
128135 }
129- m_hostName = computerName;
130136}
131137
132138void LANAPI::reset ( void )
You can’t perform that action at this time.
0 commit comments