mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
Core/Account: Add total time played in account (#1003)
This saves the total time played on the account, even if your characters have been deleted.
This commit is contained in:
@@ -1633,6 +1633,7 @@ void Player::Update(uint32 p_time)
|
||||
uint32 elapsed = uint32(now - m_Last_tick);
|
||||
m_Played_time[PLAYED_TIME_TOTAL] += elapsed; // Total played time
|
||||
m_Played_time[PLAYED_TIME_LEVEL] += elapsed; // Level played time
|
||||
GetSession()->SetTotalTime(GetSession()->GetTotalTime() + elapsed);
|
||||
m_Last_tick = now;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,12 +86,33 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
|
||||
}
|
||||
|
||||
/// WorldSession constructor
|
||||
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue):
|
||||
m_muteTime(mute_time), m_timeOutTime(0), _lastAuctionListItemsMSTime(0), _lastAuctionListOwnerItemsMSTime(0), m_GUIDLow(0), _player(NULL), m_Socket(sock),
|
||||
_security(sec), _skipQueue(skipQueue), _accountId(id), m_expansion(expansion), _logoutTime(0),
|
||||
m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerSave(false),
|
||||
m_sessionDbcLocale(sWorld->GetDefaultDbcLocale()), m_sessionDbLocaleIndex(locale),
|
||||
m_latency(0), m_clientTimeDelay(0), m_TutorialsChanged(false), recruiterId(recruiter), isRecruiter(isARecruiter), m_currentBankerGUID(0), timeWhoCommandAllowed(0)
|
||||
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue, uint32 TotalTime):
|
||||
m_muteTime(mute_time),
|
||||
m_timeOutTime(0),
|
||||
_lastAuctionListItemsMSTime(0),
|
||||
_lastAuctionListOwnerItemsMSTime(0),
|
||||
m_GUIDLow(0),
|
||||
_player(NULL),
|
||||
m_Socket(sock),
|
||||
_security(sec),
|
||||
_skipQueue(skipQueue),
|
||||
_accountId(id),
|
||||
m_expansion(expansion),
|
||||
m_total_time(TotalTime),
|
||||
_logoutTime(0),
|
||||
m_inQueue(false),
|
||||
m_playerLoading(false),
|
||||
m_playerLogout(false),
|
||||
m_playerSave(false),
|
||||
m_sessionDbcLocale(sWorld->GetDefaultDbcLocale()),
|
||||
m_sessionDbLocaleIndex(locale),
|
||||
m_latency(0),
|
||||
m_clientTimeDelay(0),
|
||||
m_TutorialsChanged(false),
|
||||
recruiterId(recruiter),
|
||||
isRecruiter(isARecruiter),
|
||||
m_currentBankerGUID(0),
|
||||
timeWhoCommandAllowed(0)
|
||||
{
|
||||
memset(m_Tutorials, 0, sizeof(m_Tutorials));
|
||||
|
||||
@@ -114,6 +135,8 @@ m_latency(0), m_clientTimeDelay(0), m_TutorialsChanged(false), recruiterId(recru
|
||||
/// WorldSession destructor
|
||||
WorldSession::~WorldSession()
|
||||
{
|
||||
LoginDatabase.PExecute("UPDATE account SET totaltime = %u WHERE id = %u", GetTotalTime(), GetAccountId());
|
||||
|
||||
///- unload player if not unloaded
|
||||
if (_player)
|
||||
LogoutPlayer (true);
|
||||
|
||||
@@ -185,7 +185,7 @@ class CharacterCreateInfo
|
||||
class WorldSession
|
||||
{
|
||||
public:
|
||||
WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue);
|
||||
WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue, uint32 TotalTime);
|
||||
~WorldSession();
|
||||
|
||||
bool PlayerLoading() const { return m_playerLoading; }
|
||||
@@ -223,6 +223,9 @@ class WorldSession
|
||||
void SetPlayer(Player* player);
|
||||
uint8 Expansion() const { return m_expansion; }
|
||||
|
||||
void SetTotalTime(uint32 TotalTime) { m_total_time = TotalTime; }
|
||||
uint32 GetTotalTime() const { return m_total_time; }
|
||||
|
||||
void InitWarden(BigNumber* k, std::string const& os);
|
||||
|
||||
/// Session in auth.queue currently
|
||||
@@ -964,6 +967,7 @@ class WorldSession
|
||||
bool _skipQueue;
|
||||
uint32 _accountId;
|
||||
uint8 m_expansion;
|
||||
uint32 m_total_time;
|
||||
|
||||
typedef std::list<AddonInfo> AddonsList;
|
||||
|
||||
|
||||
@@ -730,6 +730,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
uint64 DosResponse;
|
||||
uint32 BuiltNumberClient;
|
||||
uint32 id, security;
|
||||
uint32 TotalTime = 0;
|
||||
bool skipQueue = false;
|
||||
//uint8 expansion = 0;
|
||||
LocaleConstant locale;
|
||||
@@ -765,8 +766,8 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
sLog->outStaticDebug ("WorldSocket::HandleAuthSession: client %u, loginServerID %u, account %s, loginServerType %u, clientseed %u", BuiltNumberClient, loginServerID, account.c_str(), loginServerType, clientSeed);
|
||||
#endif
|
||||
// Get the account information from the realmd database
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
// SELECT id, sessionkey, last_ip, locked, lock_country, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
// SELECT id, sessionkey, last_ip, locked, lock_country, expansion, mutetime, locale, recruiter, os, totaltime FROM account WHERE username = ?
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME);
|
||||
|
||||
stmt->setString(0, account);
|
||||
@@ -834,6 +835,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
|
||||
uint32 recruiter = fields[8].GetUInt32();
|
||||
std::string os = fields[9].GetString();
|
||||
TotalTime = fields[10].GetUInt32();
|
||||
|
||||
// Must be done before WorldSession is created
|
||||
if (sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED) && os != "Win" && os != "OSX")
|
||||
@@ -949,7 +951,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
// NOTE ATM the socket is single-threaded, have this in mind ...
|
||||
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter, skipQueue), -1);
|
||||
ACE_NEW_RETURN(m_Session, WorldSession(id, this, AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter, skipQueue, TotalTime), -1);
|
||||
|
||||
m_Crypt.Init(&k);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user