Part 1: Merge branch 'master' into 4.3.4

This commit is contained in:
Shauren committed 2014-07-19 13:40:14 +02:00
1 parent 909acdbac3
commit 3e56a4b8d7
10 files changed
+53 -92

No files matched your search

+31 -15
View File
@@ -16,35 +16,51 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/asio/ip/tcp.hpp>
#include "Common.h"
#include "RealmList.h"
#include "BattlenetManager.h"
#include "Database/DatabaseEnv.h"
#include "Util.h"
namespace boost { namespace asio { namespace ip { class address; } } }
ACE_INET_Addr const& Realm::GetAddressForClient(ACE_INET_Addr const& clientAddr) const
tcp::endpoint Realm::GetAddressForClient(ip::address const& clientAddr) const
{
ip::address realmIp;
// Attempt to send best address for client
if (clientAddr.is_loopback())
// Assume that user connecting from the machine that authserver is located on
// has all realms available in his local network
return LocalAddress;
{
// Try guessing if realm is also connected locally
if (LocalAddress.is_loopback() || ExternalAddress.is_loopback())
realmIp = clientAddr;
else
{
// Assume that user connecting from the machine that authserver is located on
// has all realms available in his local network
realmIp = LocalAddress;
}
}
else
{
if (clientAddr.is_v4() &&
(clientAddr.to_v4().to_ulong() & LocalSubnetMask.to_v4().to_ulong()) ==
(LocalAddress.to_v4().to_ulong() & LocalSubnetMask.to_v4().to_ulong()))
{
realmIp = LocalAddress;
}
else
realmIp = ExternalAddress;
}
// Check if connecting client is in the same network
if (IsIPAddrInNetwork(LocalAddress, clientAddr, LocalSubnetMask))
return LocalAddress;
tcp::endpoint endpoint(realmIp, port);
// Return external IP
return ExternalAddress;
return endpoint;
}
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL))
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)), _resolver(nullptr)
{
}
RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)), _resolver(nullptr) { }
RealmList::~RealmList()
{
delete _resolver;
@@ -60,7 +76,7 @@ void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInte
UpdateRealms(true);
}
void RealmList::UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr,
void RealmList::UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr,
ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population, uint32 build, uint8 region, uint8 battlegroup)
{
// Create new if not exist or update existed
@@ -156,8 +172,8 @@ void RealmList::UpdateRealms(bool init)
uint8 allowedSecurityLevel = fields[9].GetUInt8();
float pop = fields[10].GetFloat();
uint32 build = fields[11].GetUInt32();
uint8 region = fields[12].GetUInt8();
uint8 battlegroup = fields[13].GetUInt8();
uint8 region = fields[12].GetUInt8();
uint8 battlegroup = fields[13].GetUInt8();
UpdateRealm(realmId, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone,
(allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build, region, battlegroup);
+2 -2
View File
@@ -57,7 +57,7 @@ struct Realm
uint8 Region;
uint8 Battlegroup;
ACE_INET_Addr const& GetAddressForClient(ACE_INET_Addr const& clientAddr) const;
ip::tcp::endpoint GetAddressForClient(ip::address const& clientAddr) const;
};
namespace Battlenet
@@ -76,7 +76,7 @@ public:
static RealmList *instance = new RealmList();
return *instance;
}
~RealmList();
void Initialize(boost::asio::io_service& ioService, uint32 updateInterval);
+3 -46
View File
@@ -739,41 +739,6 @@ bool AuthSession::_HandleReconnectProof()
}
}
tcp::endpoint const GetAddressForClient(Realm const& realm, ip::address const& clientAddr)
{
ip::address realmIp;
// Attempt to send best address for client
if (clientAddr.is_loopback())
{
// Try guessing if realm is also connected locally
if (realm.LocalAddress.is_loopback() || realm.ExternalAddress.is_loopback())
realmIp = clientAddr;
else
{
// Assume that user connecting from the machine that authserver is located on
// has all realms available in his local network
realmIp = realm.LocalAddress;
}
}
else
{
if (clientAddr.is_v4() &&
(clientAddr.to_v4().to_ulong() & realm.LocalSubnetMask.to_v4().to_ulong()) ==
(realm.LocalAddress.to_v4().to_ulong() & realm.LocalSubnetMask.to_v4().to_ulong()))
{
realmIp = realm.LocalAddress;
}
else
realmIp = realm.ExternalAddress;
}
tcp::endpoint endpoint(realmIp, realm.port);
// Return external IP
return endpoint;
}
bool AuthSession::_HandleRealmList()
{
TC_LOG_DEBUG("server.authserver", "Entering _HandleRealmList");
@@ -843,7 +808,7 @@ bool AuthSession::_HandleRealmList()
pkt << lock; // if 1, then realm locked
pkt << uint8(flag); // RealmFlags
pkt << name;
pkt << boost::lexical_cast<std::string>(GetAddressForClient(realm, _socket.remote_endpoint().address()));
pkt << boost::lexical_cast<std::string>(realm.GetAddressForClient(_socket.remote_endpoint().address()));
pkt << realm.populationLevel;
pkt << AmountOfCharacters;
pkt << realm.timezone; // realm category
@@ -918,17 +883,9 @@ void AuthSession::SetVSFields(const std::string& rI)
x.SetBinary(sha.GetDigest(), sha.GetLength());
v = g.ModExp(x, N);
// No SQL injection (username escaped)
char *v_hex, *s_hex;
v_hex = v.AsHexStr();
s_hex = s.AsHexStr();
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_VS);
stmt->setString(0, v_hex);
stmt->setString(1, s_hex);
stmt->setString(0, v.AsHexStr());
stmt->setString(1, s.AsHexStr());
stmt->setString(2, _login);
LoginDatabase.Execute(stmt);
OPENSSL_free(v_hex);
OPENSSL_free(s_hex);
}
@@ -390,19 +390,6 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
}
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_ID:
return source->GetMapId() == map_id.mapId;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_NTH_BIRTHDAY:
{
time_t birthday_start = time_t(sWorld->getIntConfig(CONFIG_BIRTHDAY_TIME));
tm birthday_tm;
localtime_r(&birthday_start, &birthday_tm);
// exactly N birthday
birthday_tm.tm_year += birthday_login.nth_birthday;
time_t birthday = mktime(&birthday_tm);
time_t now = sWorld->GetGameTime();
return now <= birthday + DAY && now >= birthday;
}
case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE:
{
if (CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(known_title.title_id))
+4 -3
View File
@@ -76,9 +76,10 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
// sort problematic db2 to (1) non compatible and (2) nonexistent
if (FILE* f = fopen(db2_filename.c_str(), "rb"))
{
char buf[100];
snprintf(buf, 100,"(exist, but have %d fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
errlist.push_back(db2_filename + buf);
std::ostringstream stream;
stream << db2_filename << " exists, and has " << storage.GetFieldCount() << " field(s) (expected " << strlen(storage.GetFormat()) << "). Extracted file might be from wrong client version.";
std::string buf = stream.str();
errlist.push_back(buf);
fclose(f);
}
else
+1 -1
View File
@@ -22498,7 +22498,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 ite
if (categoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_MIDNIGHT)
{
tm date;
ACE_OS::localtime_r(&curTime, &date);
localtime_r(&curTime, &date);
catrec = catrec * DAY - (date.tm_hour * HOUR + date.tm_min * MINUTE + date.tm_sec) * IN_MILLISECONDS;
}
}
+7 -4
View File
@@ -18,7 +18,6 @@
#ifndef __TRINITY_GUILDFINDER_H
#define __TRINITY_GUILDFINDER_H
#include <ace/Singleton.h>
#include "Common.h"
#include "World.h"
#include "GuildMgr.h"
@@ -188,8 +187,6 @@ typedef std::map<uint32 /* guildGuid */, std::vector<MembershipRequest> > Member
class GuildFinderMgr
{
friend class ACE_Singleton<GuildFinderMgr, ACE_Null_Mutex>;
private:
GuildFinderMgr();
~GuildFinderMgr();
@@ -267,8 +264,14 @@ class GuildFinderMgr
void SendApplicantListUpdate(Guild& guild);
void SendMembershipRequestListUpdate(Player& player);
static GuildFinderMgr* instance()
{
static GuildFinderMgr instance;
return &instance;
}
};
#define sGuildFinderMgr ACE_Singleton<GuildFinderMgr, ACE_Null_Mutex>::instance()
#define sGuildFinderMgr GuildFinderMgr::instance()
#endif // __TRINITY_GUILDFINDER_H
+1 -2
View File
@@ -270,7 +270,6 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
recvPacket.ReadBit();
uint32 accountNameLength = recvPacket.ReadBits(12);
account = recvPacket.ReadString(accountNameLength);
if (sWorld->IsClosed())
{
SendAuthResponseError(AUTH_REJECT);
@@ -463,7 +462,7 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
_worldSession->LoadGlobalAccountData();
_worldSession->LoadTutorialsData();
_worldSession->ReadAddonsInfo(recvPacket);
_worldSession->ReadAddonsInfo(addonsData);
_worldSession->LoadPermissions();
// At this point, we can safely hook a successful login
+1 -1
View File
@@ -74,7 +74,7 @@ private:
char _readBuffer[4096];
uint32 _authSeed;
AuthCrypt _authCrypt;
WorldPacketCrypt _authCrypt;
std::chrono::steady_clock::time_point _LastPingTime;
uint32 _OverSpeedPings;
@@ -121,7 +121,7 @@ bool RASession::CheckAccessLevel(const std::string& user)
{
std::string safeUser = user;
AccountMgr::normalizeString(safeUser);
Utf8ToUpperOnlyLatin(safeUser);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS);
stmt->setString(0, safeUser);
@@ -152,12 +152,10 @@ bool RASession::CheckAccessLevel(const std::string& user)
bool RASession::CheckPassword(const std::string& user, const std::string& pass)
{
std::string safe_user = user;
std::transform(safe_user.begin(), safe_user.end(), safe_user.begin(), ::toupper);
AccountMgr::normalizeString(safe_user);
Utf8ToUpperOnlyLatin(safe_user);
std::string safe_pass = pass;
AccountMgr::normalizeString(safe_pass);
std::transform(safe_pass.begin(), safe_pass.end(), safe_pass.begin(), ::toupper);
Utf8ToUpperOnlyLatin(safe_pass);
std::string hash = AccountMgr::CalculateShaPassHash(safe_user, safe_pass);