aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnubisss <none@none>2010-05-12 22:08:43 +0200
committerAnubisss <none@none>2010-05-12 22:08:43 +0200
commit02e0136867d7ac7db91f78fa00489192df054ebb (patch)
treee2b19d98f71b7dd9828676ddf8f5011ddc770410
parent8dfbb15b2acb2421f916f3b8fc05d952c8e043bd (diff)
Fix the bug that client can see incompatible realms in the RealmList.
--HG-- branch : trunk
-rw-r--r--src/trinityrealm/AuthSocket.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp
index 2568fedc3bd..876a6b453e5 100644
--- a/src/trinityrealm/AuthSocket.cpp
+++ b/src/trinityrealm/AuthSocket.cpp
@@ -816,33 +816,24 @@ bool AuthSocket::_HandleRealmList()
///- Update realm list if need
sRealmList->UpdateIfNeed();
- RealmList::RealmMap::const_iterator rlm;
- for (rlm = sRealmList->begin(); rlm != sRealmList->end(); ++rlm)
+ ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
+ ByteBuffer pkt;
+
+ size_t RealmListSize = 0;
+ for (RealmList::RealmMap::const_iterator i = sRealmList->begin(); i != sRealmList->end(); ++i)
{
- if ( _expversion & POST_BC_EXP_FLAG )//2.4.3 and 3.1.3 cliens
+ // don't work with realms which not compatible with the client
+ if (_expversion & POST_BC_EXP_FLAG) // 2.4.3 and 3.1.3 cliens
{
- if (rlm->second.gamebuild == _build)
- sRealmList->AddRealm(rlm->second);
+ if (i->second.gamebuild != _build)
+ continue;
}
- else if ( _expversion & PRE_BC_EXP_FLAG )//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 ( AuthHelper::IsPreBCAcceptedClientBuild ( rlm->second.gamebuild ) )
- sRealmList->AddRealm(rlm->second);
+ if (!AuthHelper::IsPreBCAcceptedClientBuild(i->second.gamebuild))
+ continue;
}
- }
-
- ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
- ByteBuffer pkt;
- pkt << (uint32) 0;
- if ( _expversion & POST_BC_EXP_FLAG )//only 2.4.3 and 3.1.3 cliens
- pkt << (uint16) sRealmList->size();
- else
- pkt << (uint32) sRealmList->size();
-
- RealmList::RealmMap::const_iterator i;
- for (i = sRealmList->begin(); i != sRealmList->end(); ++i)
- {
uint8 AmountOfCharacters;
// No SQL injection. id of realm is controlled by the database.
@@ -870,6 +861,8 @@ bool AuthSocket::_HandleRealmList()
pkt << (uint8) 0x2C; // unk, may be realm number/id?
else
pkt << (uint8) 0x0; //1.12.1 and 1.12.2 clients
+
+ ++RealmListSize;
}
if ( _expversion & POST_BC_EXP_FLAG )//2.4.3 and 3.1.3 cliens
@@ -881,10 +874,19 @@ bool AuthSocket::_HandleRealmList()
pkt << (uint8) 0x02;
}
+ // make a ByteBuffer which stores the RealmList's size
+ ByteBuffer RealmListSizeBuffer;
+ RealmListSizeBuffer << (uint32)0;
+ if (_expversion & POST_BC_EXP_FLAG) // only 2.4.3 and 3.1.3 cliens
+ RealmListSizeBuffer << (uint16)RealmListSize;
+ else
+ RealmListSizeBuffer << (uint32)RealmListSize;
+
ByteBuffer hdr;
hdr << (uint8) REALM_LIST;
- hdr << (uint16)pkt.size();
- hdr.append(pkt);
+ hdr << (uint16)(pkt.size() + RealmListSizeBuffer.size());
+ hdr.append(RealmListSizeBuffer); // append RealmList's size buffer
+ hdr.append(pkt); // append realms in the realmlist
socket().send((char const*)hdr.contents(), hdr.size());