Permalink
Browse files

added new config value bnet*_locale

git-svn-id: http://ghostplusplus.googlecode.com/svn/trunk@402 a7494f72-a4b0-11dd-a887-7ffe1a420f8d
  • Loading branch information...
1 parent 83d05be commit 1f4414552d3bceb4d78e648a4ff94327576505e6 hogantp committed Mar 18, 2010
Showing with 48 additions and 11 deletions.
  1. +13 −0 ghost.cfg
  2. +3 −2 ghost/bnet.cpp
  3. +2 −1 ghost/bnet.h
  4. +4 −6 ghost/bnetprotocol.cpp
  5. +1 −1 ghost/bnetprotocol.h
  6. +25 −1 ghost/ghost.cpp
View
@@ -382,6 +382,17 @@ bnet_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
bnet_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
+### the locale specifies the area of the world you are from
+### battle.net uses this to group players together, showing them games hosted by players and bots mostly from their own area
+### it's important to set this to the correct value to increase the effectiveness of the game refresher
+### if you are using Windows you can set this to "system" to use the locale of your system
+### otherwise you can use the list at the following URL to get the correct value for your area:
+### http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx
+### put the "decimal value" here, e.g. 1033 is the default for "English - United States"
+### note: you cannot use a value of "system" on Linux, doing so will use a default value of 1033 instead
+
+bnet_locale = system
+
### your battle.net username
### you cannot use the same username here that you yourself use to login to battle.net if you plan to login at the same time as your bot
@@ -441,6 +452,7 @@ bnet_custom_pvpgnrealmname = PvPGN Realm
# bnet2_serveralias = USWest
# bnet2_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet2_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
+# bnet2_locale = system
# bnet2_username =
# bnet2_password =
# bnet2_firstchannel = The Void
@@ -461,6 +473,7 @@ bnet_custom_pvpgnrealmname = PvPGN Realm
# bnet3_serveralias = EuroBattle
# bnet3_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF
# bnet3_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF
+# bnet3_locale = system
# bnet3_username =
# bnet3_password =
# bnet3_firstchannel = The Void
View
@@ -44,7 +44,7 @@ using namespace boost :: filesystem;
// CBNET
//
-CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID )
+CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID )
{
// todotodo: append path seperator to Warcraft3Path if needed
@@ -102,6 +102,7 @@ CBNET :: CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNL
m_CountryAbbrev = nCountryAbbrev;
m_Country = nCountry;
+ m_LocaleID = nLocaleID;
m_UserName = nUserName;
m_UserPassword = nUserPassword;
m_FirstChannel = nFirstChannel;
@@ -548,7 +549,7 @@ bool CBNET :: Update( void *fd, void *send_fd )
CONSOLE_Print( "[BNET: " + m_ServerAlias + "] connected" );
m_GHost->EventBNETConnected( this );
m_Socket->PutBytes( m_Protocol->SEND_PROTOCOL_INITIALIZE_SELECTOR( ) );
- m_Socket->PutBytes( m_Protocol->SEND_SID_AUTH_INFO( m_War3Version, m_GHost->m_TFT, m_CountryAbbrev, m_Country ) );
+ m_Socket->PutBytes( m_Protocol->SEND_SID_AUTH_INFO( m_War3Version, m_GHost->m_TFT, m_LocaleID, m_CountryAbbrev, m_Country ) );
m_Socket->DoSend( (fd_set *)send_fd );
m_LastNullTime = GetTime( );
m_LastOutPacketTicks = GetTicks( );
View
@@ -91,6 +91,7 @@ class CBNET
string m_CDKeyTFT; // TFT CD key
string m_CountryAbbrev; // country abbreviation
string m_Country; // country
+ uint32_t m_LocaleID; // see: http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx
string m_UserName; // battle.net username
string m_UserPassword; // battle.net password
string m_FirstChannel; // the first chat channel to join upon entering chat (note: we hijack this to store the last channel when entering a game)
@@ -120,7 +121,7 @@ class CBNET
bool m_PublicCommands; // whether to allow public commands or not
public:
- CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID );
+ CBNET( CGHost *nGHost, string nServer, string nServerAlias, string nBNLSServer, uint16_t nBNLSPort, uint32_t nBNLSWardenCookie, string nCDKeyROC, string nCDKeyTFT, string nCountryAbbrev, string nCountry, uint32_t nLocaleID, string nUserName, string nUserPassword, string nFirstChannel, string nRootAdmin, char nCommandTrigger, bool nHoldFriends, bool nHoldClan, bool nPublicCommands, unsigned char nWar3Version, BYTEARRAY nEXEVersion, BYTEARRAY nEXEVersionHash, string nPasswordHashType, string nPVPGNRealmName, uint32_t nMaxMessageLength, uint32_t nHostCounterID );
~CBNET( );
bool GetExiting( ) { return m_Exiting; }
@@ -766,7 +766,7 @@ BYTEARRAY CBNETProtocol :: SEND_SID_NETGAMEPORT( uint16_t serverPort )
return packet;
}
-BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, string countryAbbrev, string country )
+BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, uint32_t localeID, string countryAbbrev, string country )
{
unsigned char ProtocolID[] = { 0, 0, 0, 0 };
unsigned char PlatformID[] = { 54, 56, 88, 73 }; // "IX86"
@@ -776,8 +776,6 @@ BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, stri
unsigned char Language[] = { 83, 85, 110, 101 }; // "enUS"
unsigned char LocalIP[] = { 127, 0, 0, 1 };
unsigned char TimeZoneBias[] = { 44, 1, 0, 0 }; // 300 minutes (GMT -0500)
- unsigned char LocaleID[] = { 9, 4, 0, 0 }; // 0x0409 English (United States)
- unsigned char LanguageID[] = { 9, 4, 0, 0 }; // 0x0409 English (United States)
BYTEARRAY packet;
packet.push_back( BNET_HEADER_CONSTANT ); // BNET header constant
@@ -793,11 +791,11 @@ BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, stri
UTIL_AppendByteArray( packet, ProductID_ROC, 4 ); // Product ID (ROC)
UTIL_AppendByteArray( packet, Version, 4 ); // Version
- UTIL_AppendByteArray( packet, Language, 4 ); // Language
+ UTIL_AppendByteArray( packet, Language, 4 ); // Language (hardcoded as enUS to ensure battle.net sends the bot messages in English)
UTIL_AppendByteArray( packet, LocalIP, 4 ); // Local IP for NAT compatibility
UTIL_AppendByteArray( packet, TimeZoneBias, 4 ); // Time Zone Bias
- UTIL_AppendByteArray( packet, LocaleID, 4 ); // Locale ID
- UTIL_AppendByteArray( packet, LanguageID, 4 ); // Language ID
+ UTIL_AppendByteArray( packet, localeID, false ); // Locale ID
+ UTIL_AppendByteArray( packet, localeID, false ); // Language ID (copying the locale ID should be sufficient since we don't care about sublanguages)
UTIL_AppendByteArrayFast( packet, countryAbbrev ); // Country Abbreviation
UTIL_AppendByteArrayFast( packet, country ); // Country
AssignLength( packet );
@@ -152,7 +152,7 @@ class CBNETProtocol
BYTEARRAY SEND_SID_PING( BYTEARRAY pingValue );
BYTEARRAY SEND_SID_LOGONRESPONSE( BYTEARRAY clientToken, BYTEARRAY serverToken, BYTEARRAY passwordHash, string accountName );
BYTEARRAY SEND_SID_NETGAMEPORT( uint16_t serverPort );
- BYTEARRAY SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, string countryAbbrev, string country );
+ BYTEARRAY SEND_SID_AUTH_INFO( unsigned char ver, bool TFT, uint32_t localeID, string countryAbbrev, string country );
BYTEARRAY SEND_SID_AUTH_CHECK( bool TFT, BYTEARRAY clientToken, BYTEARRAY exeVersion, BYTEARRAY exeVersionHash, BYTEARRAY keyInfoROC, BYTEARRAY keyInfoTFT, string exeInfo, string keyOwnerName );
BYTEARRAY SEND_SID_AUTH_ACCOUNTLOGON( BYTEARRAY clientPublicKey, string accountName );
BYTEARRAY SEND_SID_AUTH_ACCOUNTLOGONPROOF( BYTEARRAY clientPasswordProof );
View
@@ -533,6 +533,20 @@ CGHost :: CGHost( CConfig *CFG )
string CDKeyTFT = CFG->GetString( Prefix + "cdkeytft", string( ) );
string CountryAbbrev = CFG->GetString( Prefix + "countryabbrev", "USA" );
string Country = CFG->GetString( Prefix + "country", "United States" );
+ string Locale = CFG->GetString( Prefix + "locale", "system" );
+ uint32_t LocaleID;
+
+ if( Locale == "system" )
+ {
+#ifdef WIN32
+ LocaleID = GetUserDefaultLangID( );
+#else
+ LocaleID = 1033;
+#endif
+ }
+ else
+ LocaleID = UTIL_ToUInt32( Locale );
+
string UserName = CFG->GetString( Prefix + "username", string( ) );
string UserPassword = CFG->GetString( Prefix + "password", string( ) );
string FirstChannel = CFG->GetString( Prefix + "firstchannel", "The Void" );
@@ -583,7 +597,17 @@ CGHost :: CGHost( CConfig *CFG )
}
CONSOLE_Print( "[GHOST] found battle.net connection #" + UTIL_ToString( i ) + " for server [" + Server + "]" );
- m_BNETs.push_back( new CBNET( this, Server, ServerAlias, BNLSServer, (uint16_t)BNLSPort, (uint32_t)BNLSWardenCookie, CDKeyROC, CDKeyTFT, CountryAbbrev, Country, UserName, UserPassword, FirstChannel, RootAdmin, BNETCommandTrigger[0], HoldFriends, HoldClan, PublicCommands, War3Version, EXEVersion, EXEVersionHash, PasswordHashType, PVPGNRealmName, MaxMessageLength, i ) );
+
+ if( Locale == "system" )
+ {
+#ifdef WIN32
+ CONSOLE_Print( "[GHOST] using system locale of " + UTIL_ToString( LocaleID ) );
+#else
+ CONSOLE_Print( "[GHOST] unable to get system locale, using default locale of 1033" );
+#endif
+ }
+
+ m_BNETs.push_back( new CBNET( this, Server, ServerAlias, BNLSServer, (uint16_t)BNLSPort, (uint32_t)BNLSWardenCookie, CDKeyROC, CDKeyTFT, CountryAbbrev, Country, LocaleID, UserName, UserPassword, FirstChannel, RootAdmin, BNETCommandTrigger[0], HoldFriends, HoldClan, PublicCommands, War3Version, EXEVersion, EXEVersionHash, PasswordHashType, PVPGNRealmName, MaxMessageLength, i ) );
}
if( m_BNETs.empty( ) )

0 comments on commit 1f44145

Please sign in to comment.