* Massive cleanup of realmd

* Patch by w12x -- THANK YOU!

--HG--
branch : trunk
This commit is contained in:
Brian
2009-12-20 22:15:24 -07:00
parent 920c919417
commit e55710fc68
4 changed files with 26 additions and 24 deletions
+13 -2
View File
@@ -72,8 +72,19 @@ enum LoginResult
//2.4.3 build 8606 //2.4.3 build 8606
//3.1.3 build 9947 //3.1.3 build 9947
//3.1.3 build 10146 Chinese build //3.1.3 build 10146 Chinese build
//3.2.2a build 10505
#define EXPECTED_TRINITY_CLIENT_BUILD {10505, 10146, 9947, 8606, 5875, 6005, 0} #define POST_BC_ACCEPTED_CLIENT_BUILD {10505, 10146, 9947, 8606, 0}
#define PRE_BC_ACCEPTED_CLIENT_BUILD {5875, 6005, 0}
#define POST_BC_EXP_FLAG 0x2
#define PRE_BC_EXP_FLAG 0x1
#define NO_VALID_EXP_FLAG 0x0
namespace AuthHelper
{
bool IsAcceptedClientBuild(int build);
bool IsPostBCAcceptedClientBuild(int build);
bool IsPreBCAcceptedClientBuild(int build);
};
#endif #endif
+11 -22
View File
@@ -379,6 +379,7 @@ bool AuthSocket::_HandleLogonChallenge()
_login = (const char*)ch->I; _login = (const char*)ch->I;
_build = ch->build; _build = ch->build;
_expversion = (AuthHelper::IsPostBCAcceptedClientBuild(_build) ? POST_BC_EXP_FLAG : NO_VALID_EXP_FLAG) + (AuthHelper::IsPreBCAcceptedClientBuild(_build) ? PRE_BC_EXP_FLAG : NO_VALID_EXP_FLAG);
///- Normalize account name ///- Normalize account name
//utf8ToUpperOnlyLatin(_login); -- client already send account in expected form //utf8ToUpperOnlyLatin(_login); -- client already send account in expected form
@@ -549,22 +550,10 @@ bool AuthSocket::_HandleLogonProof()
sAuthLogonProof_C lp; sAuthLogonProof_C lp;
ibuf.Read((char *)&lp, sizeof(sAuthLogonProof_C)); ibuf.Read((char *)&lp, sizeof(sAuthLogonProof_C));
///- Check if the client has one of the expected version numbers
bool valid_version = false;
int accepted_versions[] = EXPECTED_TRINITY_CLIENT_BUILD;
for (int i = 0; accepted_versions[i]; ++i)
{
if (_build == accepted_versions[i])
{
valid_version = true;
break;
}
}
/// <ul><li> If the client has no valid version /// <ul><li> If the client has no valid version
if (!valid_version) if (_expversion == NO_VALID_EXP_FLAG)
{ {
///- Check if we have the apropriate patch on the disk ///- Check if we have the appropriate patch on the disk
// 24 = len("./patches/65535enGB.mpq")+1 // 24 = len("./patches/65535enGB.mpq")+1
char tmp[24]; char tmp[24];
@@ -706,7 +695,7 @@ bool AuthSocket::_HandleLogonProof()
sha.UpdateBigNumbers(&A, &M, &K, NULL); sha.UpdateBigNumbers(&A, &M, &K, NULL);
sha.Finalize(); sha.Finalize();
if (_build == 8606 || _build == 9947 || _build == 10146 || _build == 10505)//2.4.3, 3.1.3 and 3.2.2a clients (10146 is Chinese build for 3.1.3) if (_expversion & POST_BC_EXP_FLAG)//2.4.3 and 3.1.3 clients (10146 is Chinese build for 3.1.3)
{ {
sAuthLogonProof_S proof; sAuthLogonProof_S proof;
memcpy(proof.M2, sha.GetDigest(), 20); memcpy(proof.M2, sha.GetDigest(), 20);
@@ -909,14 +898,14 @@ bool AuthSocket::_HandleRealmList()
RealmList built_realmList; RealmList built_realmList;
for (rlm = m_realmList.begin(); rlm != m_realmList.end(); ++rlm) for (rlm = m_realmList.begin(); rlm != m_realmList.end(); ++rlm)
{ {
if (_build == 8606 || _build == 9947 || _build == 10146 || _build == 10505)//2.4.3, 3.1.3 and 3.2.2a clients if ( _expversion & POST_BC_EXP_FLAG )//2.4.3 and 3.1.3 cliens
{ {
if (rlm->second.gamebuild == _build) if (rlm->second.gamebuild == _build)
built_realmList.AddRealm(rlm->second); built_realmList.AddRealm(rlm->second);
} }
else if (_build == 5875 || _build == 6005)//1.12.1 and 1.12.2 clients are compatible with eachother else if ( _expversion & PRE_BC_EXP_FLAG )//1.12.1 and 1.12.2 clients are compatible with eachother
{ {
if (rlm->second.gamebuild == 5875 || rlm->second.gamebuild == 6005) if ( AuthHelper::IsPreBCAcceptedClientBuild ( rlm->second.gamebuild ) )
built_realmList.AddRealm(rlm->second); built_realmList.AddRealm(rlm->second);
} }
@@ -925,7 +914,7 @@ bool AuthSocket::_HandleRealmList()
///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm) ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
ByteBuffer pkt; ByteBuffer pkt;
pkt << (uint32) 0; pkt << (uint32) 0;
if (_build == 8606 || _build == 9947 || _build == 10146 || _build == 10505)//only 2.4.3, 3.1.3 and 3.2.2a clients if ( _expversion & POST_BC_EXP_FLAG )//only 2.4.3 and 3.1.3 cliens
pkt << (uint16) built_realmList.size(); pkt << (uint16) built_realmList.size();
else else
pkt << (uint32) built_realmList.size(); pkt << (uint32) built_realmList.size();
@@ -948,7 +937,7 @@ bool AuthSocket::_HandleRealmList()
uint8 lock = (i->second.allowedSecurityLevel > _accountSecurityLevel) ? 1 : 0; uint8 lock = (i->second.allowedSecurityLevel > _accountSecurityLevel) ? 1 : 0;
pkt << i->second.icon; // realm type pkt << i->second.icon; // realm type
if (i->second.gamebuild == 10505 || i->second.gamebuild == 9947 || i->second.gamebuild == 10146 || i->second.gamebuild == 8606)//only 2.4.3, 3.1.3 and 3.2.2a clients if ( _expversion & POST_BC_EXP_FLAG )//only 2.4.3 and 3.1.3 cliens
pkt << lock; // if 1, then realm locked pkt << lock; // if 1, then realm locked
pkt << i->second.color; // if 2, then realm is offline pkt << i->second.color; // if 2, then realm is offline
pkt << i->first; pkt << i->first;
@@ -956,13 +945,13 @@ bool AuthSocket::_HandleRealmList()
pkt << i->second.populationLevel; pkt << i->second.populationLevel;
pkt << AmountOfCharacters; pkt << AmountOfCharacters;
pkt << i->second.timezone; // realm category pkt << i->second.timezone; // realm category
if (i->second.gamebuild == 10505 || i->second.gamebuild == 9947 || i->second.gamebuild == 10146 || i->second.gamebuild == 8606)//2.4.3, 3.1.3 and 3.2.2a clients if ( _expversion & POST_BC_EXP_FLAG )//2.4.3 and 3.1.3 clients
pkt << (uint8) 0x2C; // unk, may be realm number/id? pkt << (uint8) 0x2C; // unk, may be realm number/id?
else else
pkt << (uint8) 0x0; //1.12.1 and 1.12.2 clients pkt << (uint8) 0x0; //1.12.1 and 1.12.2 clients
} }
if (_build == 10505 || _build == 9947 || _build == 10146 || _build == 8606)//2.4.3, 3.1.3 and 3.2.2a clients if ( _expversion & POST_BC_EXP_FLAG )//2.4.3 and 3.1.3 cliens
{ {
pkt << (uint8) 0x10; pkt << (uint8) 0x10;
pkt << (uint8) 0x00; pkt << (uint8) 0x00;
+1
View File
@@ -79,6 +79,7 @@ class AuthSocket: public TcpSocket
// between enUS and enGB, which is important for the patch system // between enUS and enGB, which is important for the patch system
std::string _localizationName; std::string _localizationName;
uint16 _build; uint16 _build;
uint8 _expversion;
AccountTypes _accountSecurityLevel; AccountTypes _accountSecurityLevel;
}; };
#endif #endif
+1
View File
@@ -1,6 +1,7 @@
########### next target ############### ########### next target ###############
SET(trinity-realm_SRCS SET(trinity-realm_SRCS
AuthCodes.cpp
AuthCodes.h AuthCodes.h
AuthSocket.cpp AuthSocket.cpp
AuthSocket.h AuthSocket.h