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:
@@ -0,0 +1,4 @@
|
|||||||
|
INSERT INTO version_db_auth (`sql_rev`) VALUES ('1534268747940576100');
|
||||||
|
|
||||||
|
ALTER TABLE `account`
|
||||||
|
ADD COLUMN `totaltime` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `recruiter`;
|
||||||
@@ -33,7 +33,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
|
|||||||
PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT id, sessionkey, last_ip, locked, lock_country, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT id, sessionkey, last_ip, locked, lock_country, expansion, mutetime, locale, recruiter, os, totaltime FROM account WHERE username = ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL, "SELECT id, username FROM account WHERE email = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL, "SELECT id, username FROM account WHERE email = ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_NUM_CHARS_ON_REALM, "SELECT numchars FROM realmcharacters WHERE realmid = ? AND acctid= ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_NUM_CHARS_ON_REALM, "SELECT numchars FROM realmcharacters WHERE realmid = ? AND acctid= ?", CONNECTION_SYNCH);
|
||||||
PrepareStatement(LOGIN_SEL_ACCOUNT_BY_IP, "SELECT id, username FROM account WHERE last_ip = ?", CONNECTION_SYNCH);
|
PrepareStatement(LOGIN_SEL_ACCOUNT_BY_IP, "SELECT id, username FROM account WHERE last_ip = ?", CONNECTION_SYNCH);
|
||||||
|
|||||||
@@ -1633,6 +1633,7 @@ void Player::Update(uint32 p_time)
|
|||||||
uint32 elapsed = uint32(now - m_Last_tick);
|
uint32 elapsed = uint32(now - m_Last_tick);
|
||||||
m_Played_time[PLAYED_TIME_TOTAL] += elapsed; // Total played time
|
m_Played_time[PLAYED_TIME_TOTAL] += elapsed; // Total played time
|
||||||
m_Played_time[PLAYED_TIME_LEVEL] += elapsed; // Level played time
|
m_Played_time[PLAYED_TIME_LEVEL] += elapsed; // Level played time
|
||||||
|
GetSession()->SetTotalTime(GetSession()->GetTotalTime() + elapsed);
|
||||||
m_Last_tick = now;
|
m_Last_tick = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,12 +86,33 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// WorldSession constructor
|
/// WorldSession constructor
|
||||||
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue):
|
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),
|
m_muteTime(mute_time),
|
||||||
_security(sec), _skipQueue(skipQueue), _accountId(id), m_expansion(expansion), _logoutTime(0),
|
m_timeOutTime(0),
|
||||||
m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerSave(false),
|
_lastAuctionListItemsMSTime(0),
|
||||||
m_sessionDbcLocale(sWorld->GetDefaultDbcLocale()), m_sessionDbLocaleIndex(locale),
|
_lastAuctionListOwnerItemsMSTime(0),
|
||||||
m_latency(0), m_clientTimeDelay(0), m_TutorialsChanged(false), recruiterId(recruiter), isRecruiter(isARecruiter), m_currentBankerGUID(0), timeWhoCommandAllowed(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));
|
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 destructor
|
||||||
WorldSession::~WorldSession()
|
WorldSession::~WorldSession()
|
||||||
{
|
{
|
||||||
|
LoginDatabase.PExecute("UPDATE account SET totaltime = %u WHERE id = %u", GetTotalTime(), GetAccountId());
|
||||||
|
|
||||||
///- unload player if not unloaded
|
///- unload player if not unloaded
|
||||||
if (_player)
|
if (_player)
|
||||||
LogoutPlayer (true);
|
LogoutPlayer (true);
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class CharacterCreateInfo
|
|||||||
class WorldSession
|
class WorldSession
|
||||||
{
|
{
|
||||||
public:
|
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();
|
~WorldSession();
|
||||||
|
|
||||||
bool PlayerLoading() const { return m_playerLoading; }
|
bool PlayerLoading() const { return m_playerLoading; }
|
||||||
@@ -223,6 +223,9 @@ class WorldSession
|
|||||||
void SetPlayer(Player* player);
|
void SetPlayer(Player* player);
|
||||||
uint8 Expansion() const { return m_expansion; }
|
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);
|
void InitWarden(BigNumber* k, std::string const& os);
|
||||||
|
|
||||||
/// Session in auth.queue currently
|
/// Session in auth.queue currently
|
||||||
@@ -964,6 +967,7 @@ class WorldSession
|
|||||||
bool _skipQueue;
|
bool _skipQueue;
|
||||||
uint32 _accountId;
|
uint32 _accountId;
|
||||||
uint8 m_expansion;
|
uint8 m_expansion;
|
||||||
|
uint32 m_total_time;
|
||||||
|
|
||||||
typedef std::list<AddonInfo> AddonsList;
|
typedef std::list<AddonInfo> AddonsList;
|
||||||
|
|
||||||
|
|||||||
@@ -730,6 +730,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||||||
uint64 DosResponse;
|
uint64 DosResponse;
|
||||||
uint32 BuiltNumberClient;
|
uint32 BuiltNumberClient;
|
||||||
uint32 id, security;
|
uint32 id, security;
|
||||||
|
uint32 TotalTime = 0;
|
||||||
bool skipQueue = false;
|
bool skipQueue = false;
|
||||||
//uint8 expansion = 0;
|
//uint8 expansion = 0;
|
||||||
LocaleConstant locale;
|
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);
|
sLog->outStaticDebug ("WorldSocket::HandleAuthSession: client %u, loginServerID %u, account %s, loginServerType %u, clientseed %u", BuiltNumberClient, loginServerID, account.c_str(), loginServerType, clientSeed);
|
||||||
#endif
|
#endif
|
||||||
// Get the account information from the realmd database
|
// Get the account information from the realmd database
|
||||||
// 0 1 2 3 4 5 6 7 8 9
|
// 0 1 2 3 4 5 6 7 8 9 10
|
||||||
// SELECT id, sessionkey, last_ip, locked, lock_country, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?
|
// 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);
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME);
|
||||||
|
|
||||||
stmt->setString(0, account);
|
stmt->setString(0, account);
|
||||||
@@ -834,6 +835,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||||||
|
|
||||||
uint32 recruiter = fields[8].GetUInt32();
|
uint32 recruiter = fields[8].GetUInt32();
|
||||||
std::string os = fields[9].GetString();
|
std::string os = fields[9].GetString();
|
||||||
|
TotalTime = fields[10].GetUInt32();
|
||||||
|
|
||||||
// Must be done before WorldSession is created
|
// Must be done before WorldSession is created
|
||||||
if (sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED) && os != "Win" && os != "OSX")
|
if (sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED) && os != "Win" && os != "OSX")
|
||||||
@@ -949,7 +951,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||||||
LoginDatabase.Execute(stmt);
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
// NOTE ATM the socket is single-threaded, have this in mind ...
|
// 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);
|
m_Crypt.Init(&k);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user