mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Add support for multirealm. Patch by streetrat.
--HG-- branch : trunk
This commit is contained in:
@@ -182,6 +182,7 @@ CREATE TABLE `realmlist` (
|
||||
`timezone` tinyint(3) unsigned NOT NULL default '0',
|
||||
`allowedSecurityLevel` tinyint(3) unsigned NOT NULL default '0',
|
||||
`population` float unsigned NOT NULL default '0',
|
||||
`gamebuild` int(11) unsigned NOT NULL default '9947',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_name` (`name`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Realm System';
|
||||
|
||||
2
sql/updates/5642_realmd.sql
Normal file
2
sql/updates/5642_realmd.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `realmlist`
|
||||
ADD `gamebuild` int(11) unsigned NOT NULL default '9947' AFTER `population`;
|
||||
@@ -66,10 +66,12 @@ enum LoginResult
|
||||
LOGIN_LOCKED_ENFORCED = 0x10,
|
||||
};
|
||||
|
||||
// we need to stick to 1 version or half of the stuff will work for someone
|
||||
// others will not and opposite
|
||||
// will only support WoW, WoW:TBC and WoW:WotLK 3.1.3 client build 9947...
|
||||
//multirealm supported versions:
|
||||
//1.12.1 build 5875
|
||||
//1.12.2 build 6005
|
||||
//2.4.3 build 8606
|
||||
//3.1.3 build 9947
|
||||
|
||||
#define EXPECTED_MANGOS_CLIENT_BUILD {9947, 0}
|
||||
#define EXPECTED_MANGOS_CLIENT_BUILD {9947, 8606, 5875, 6005, 0}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -133,6 +133,16 @@ typedef struct AUTH_LOGON_PROOF_S
|
||||
uint16 unk3;
|
||||
} sAuthLogonProof_S;
|
||||
|
||||
typedef struct AUTH_LOGON_PROOF_S_OLD
|
||||
{
|
||||
uint8 cmd;
|
||||
uint8 error;
|
||||
uint8 M2[20];
|
||||
//uint32 unk1;
|
||||
uint32 unk2;
|
||||
//uint16 unk3;
|
||||
} sAuthLogonProof_S_Old;
|
||||
|
||||
typedef struct AUTH_RECONNECT_PROOF_C
|
||||
{
|
||||
uint8 cmd;
|
||||
@@ -696,15 +706,26 @@ bool AuthSocket::_HandleLogonProof()
|
||||
sha.UpdateBigNumbers(&A, &M, &K, NULL);
|
||||
sha.Finalize();
|
||||
|
||||
sAuthLogonProof_S proof;
|
||||
memcpy(proof.M2, sha.GetDigest(), 20);
|
||||
proof.cmd = AUTH_LOGON_PROOF;
|
||||
proof.error = 0;
|
||||
proof.unk1 = 0x00800000;
|
||||
proof.unk2 = 0x00;
|
||||
proof.unk3 = 0x00;
|
||||
|
||||
SendBuf((char *)&proof, sizeof(proof));
|
||||
if(_build == 8606 || _build == 9947)//2.4.3 and 3.1.3 cliens
|
||||
{
|
||||
sAuthLogonProof_S proof;
|
||||
memcpy(proof.M2, sha.GetDigest(), 20);
|
||||
proof.cmd = AUTH_LOGON_PROOF;
|
||||
proof.error = 0;
|
||||
proof.unk1 = 0x00800000;
|
||||
proof.unk2 = 0x00;
|
||||
proof.unk3 = 0x00;
|
||||
SendBuf((char *)&proof, sizeof(proof));
|
||||
}else{
|
||||
sAuthLogonProof_S_Old proof;
|
||||
memcpy(proof.M2, sha.GetDigest(), 20);
|
||||
proof.cmd = AUTH_LOGON_PROOF;
|
||||
proof.error = 0;
|
||||
//proof.unk1 = 0x00800000;
|
||||
proof.unk2 = 0x00;
|
||||
//proof.unk3 = 0x00;
|
||||
SendBuf((char *)&proof, sizeof(proof));
|
||||
}
|
||||
|
||||
///- Set _authed to true!
|
||||
_authed = true;
|
||||
@@ -884,12 +905,32 @@ bool AuthSocket::_HandleRealmList()
|
||||
///- Update realm list if need
|
||||
m_realmList.UpdateIfNeed();
|
||||
|
||||
RealmList::RealmMap::const_iterator rlm;
|
||||
RealmList built_realmList;
|
||||
for( rlm = m_realmList.begin(); rlm != m_realmList.end(); ++rlm )
|
||||
{
|
||||
if(_build == 8606 || _build == 9947)//2.4.3 and 3.1.3 cliens
|
||||
{
|
||||
if(rlm->second.gamebuild == _build)
|
||||
built_realmList.AddRealm(rlm->second);
|
||||
}
|
||||
else if(_build == 5875 || _build == 6005)//1.12.1 and 1.12.2 clients are compatible with eachother
|
||||
{
|
||||
if(rlm->second.gamebuild == 5875 || rlm->second.gamebuild == 6005)
|
||||
built_realmList.AddRealm(rlm->second);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
|
||||
ByteBuffer pkt;
|
||||
pkt << (uint32) 0;
|
||||
pkt << (uint16) m_realmList.size();
|
||||
if(_build == 8606 || _build == 9947)//only 2.4.3 and 3.1.3 cliens
|
||||
pkt << (uint16) built_realmList.size();
|
||||
else
|
||||
pkt << (uint32) built_realmList.size();
|
||||
RealmList::RealmMap::const_iterator i;
|
||||
for( i = m_realmList.begin(); i != m_realmList.end(); ++i )
|
||||
for( i = built_realmList.begin(); i != built_realmList.end(); ++i )
|
||||
{
|
||||
uint8 AmountOfCharacters;
|
||||
|
||||
@@ -907,17 +948,28 @@ bool AuthSocket::_HandleRealmList()
|
||||
uint8 lock = (i->second.allowedSecurityLevel > _accountSecurityLevel) ? 1 : 0;
|
||||
|
||||
pkt << i->second.icon; // realm type
|
||||
pkt << lock; // if 1, then realm locked
|
||||
if(i->second.gamebuild == 9947 || i->second.gamebuild == 8606)//only 2.4.3 and 3.1.3 cliens
|
||||
pkt << lock; // if 1, then realm locked
|
||||
pkt << i->second.color; // if 2, then realm is offline
|
||||
pkt << i->first;
|
||||
pkt << i->second.address;
|
||||
pkt << i->second.populationLevel;
|
||||
pkt << AmountOfCharacters;
|
||||
pkt << i->second.timezone; // realm category
|
||||
pkt << (uint8) 0x2C; // unk, may be realm number/id?
|
||||
if(i->second.gamebuild == 9947 || i->second.gamebuild == 8606)//2.4.3 and 3.1.3 clients
|
||||
pkt << (uint8) 0x2C; // unk, may be realm number/id?
|
||||
else
|
||||
pkt << (uint8) 0x0; //1.12.1 and 1.12.2 clients
|
||||
}
|
||||
|
||||
if(_build == 9947 || _build == 8606)//2.4.3 and 3.1.3 cliens
|
||||
{
|
||||
pkt << (uint8) 0x10;
|
||||
pkt << (uint8) 0x00;
|
||||
}else{//1.12.1 and 1.12.2 clients
|
||||
pkt << (uint8) 0x00;
|
||||
pkt << (uint8) 0x02;
|
||||
}
|
||||
pkt << (uint8) 0x10;
|
||||
pkt << (uint8) 0x00;
|
||||
|
||||
ByteBuffer hdr;
|
||||
hdr << (uint8) REALM_LIST;
|
||||
|
||||
@@ -44,7 +44,7 @@ void RealmList::Initialize(uint32 updateInterval)
|
||||
UpdateRealms(true);
|
||||
}
|
||||
|
||||
void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu)
|
||||
void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build)
|
||||
{
|
||||
///- Create new if not exist or update existed
|
||||
Realm& realm = m_realms[name];
|
||||
@@ -61,6 +61,7 @@ void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::stri
|
||||
std::ostringstream ss;
|
||||
ss << address << ":" << port;
|
||||
realm.address = ss.str();
|
||||
realm.gamebuild = build;
|
||||
}
|
||||
|
||||
void RealmList::UpdateIfNeed()
|
||||
@@ -82,7 +83,7 @@ void RealmList::UpdateRealms(bool init)
|
||||
{
|
||||
sLog.outDetail("Updating Realm List...");
|
||||
|
||||
QueryResult *result = loginDatabase.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" );
|
||||
QueryResult *result = loginDatabase.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE color <> 3 ORDER BY name" );
|
||||
|
||||
///- Circle through results and add them to the realm map
|
||||
if(result)
|
||||
@@ -93,7 +94,7 @@ void RealmList::UpdateRealms(bool init)
|
||||
|
||||
uint8 allowedSecurityLevel = fields[7].GetUInt8();
|
||||
|
||||
UpdateRealm(fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(),fields[4].GetUInt8(), fields[5].GetUInt8(), fields[6].GetUInt8(), (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), fields[8].GetFloat() );
|
||||
UpdateRealm(fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(),fields[4].GetUInt8(), fields[5].GetUInt8(), fields[6].GetUInt8(), (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), fields[8].GetFloat(), fields[9].GetUInt32() );
|
||||
if(init)
|
||||
sLog.outString("Added realm \"%s\".", fields[1].GetString());
|
||||
} while( result->NextRow() );
|
||||
|
||||
@@ -38,6 +38,7 @@ struct Realm
|
||||
uint32 m_ID;
|
||||
AccountTypes allowedSecurityLevel;
|
||||
float populationLevel;
|
||||
uint32 gamebuild;
|
||||
};
|
||||
|
||||
/// Storage object for the list of realms on the server
|
||||
@@ -53,12 +54,14 @@ class RealmList
|
||||
|
||||
void UpdateIfNeed();
|
||||
|
||||
void AddRealm(Realm NewRealm) {m_realms[NewRealm.name] = NewRealm;}
|
||||
|
||||
RealmMap::const_iterator begin() const { return m_realms.begin(); }
|
||||
RealmMap::const_iterator end() const { return m_realms.end(); }
|
||||
uint32 size() const { return m_realms.size(); }
|
||||
private:
|
||||
void UpdateRealms(bool init);
|
||||
void UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu);
|
||||
void UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
|
||||
private:
|
||||
RealmMap m_realms; ///< Internal map of realms
|
||||
uint32 m_UpdateInterval;
|
||||
|
||||
Reference in New Issue
Block a user