mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-09 05:02:25 +00:00
[Repositories] Convert Total Time Played to Repositories (#5008)
This commit is contained in:
parent
6506ad5b51
commit
0bbb5b90e7
@ -191,6 +191,22 @@ public:
|
|||||||
|
|
||||||
return character_ids;
|
return character_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t GetTotalTimePlayed(Database& db, uint32_t account_id)
|
||||||
|
{
|
||||||
|
auto query = fmt::format(
|
||||||
|
"SELECT SUM(time_played) FROM `character_data` WHERE `account_id` = {}",
|
||||||
|
account_id
|
||||||
|
);
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
return Strings::ToUnsignedInt(row[0]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
||||||
|
|||||||
@ -122,16 +122,6 @@ bool SharedDatabase::SetGMFlymode(uint32 account_id, uint8 flymode)
|
|||||||
return a.id > 0;
|
return a.id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
|
||||||
uint32 EntitledTime = 0;
|
|
||||||
const std::string query = StringFormat("SELECT `time_played` FROM `character_data` WHERE `account_id` = %u", AccountID);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
for (auto& row = results.begin(); row != results.end(); ++row) {
|
|
||||||
EntitledTime += Strings::ToUnsignedInt(row[0]);
|
|
||||||
}
|
|
||||||
return EntitledTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SharedDatabase::SetMailKey(int CharID, int IPAddress, int MailKey)
|
void SharedDatabase::SetMailKey(int CharID, int IPAddress, int MailKey)
|
||||||
{
|
{
|
||||||
char mail_key[17];
|
char mail_key[17];
|
||||||
|
|||||||
@ -82,7 +82,6 @@ public:
|
|||||||
bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
|
bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
|
||||||
bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned);
|
bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned);
|
||||||
bool GetCommandSubSettings(std::vector<CommandSubsettingsRepository::CommandSubsettings> &command_subsettings);
|
bool GetCommandSubSettings(std::vector<CommandSubsettingsRepository::CommandSubsettings> &command_subsettings);
|
||||||
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
|
|
||||||
bool SetGMInvul(uint32 account_id, bool gminvul);
|
bool SetGMInvul(uint32 account_id, bool gminvul);
|
||||||
bool SetGMFlymode(uint32 account_id, uint8 flymode);
|
bool SetGMFlymode(uint32 account_id, uint8 flymode);
|
||||||
void SetMailKey(int CharID, int IPAddress, int MailKey);
|
void SetMailKey(int CharID, int IPAddress, int MailKey);
|
||||||
|
|||||||
@ -1713,7 +1713,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
|||||||
if (zone->IsPVPZone())
|
if (zone->IsPVPZone())
|
||||||
m_pp.pvp = 1;
|
m_pp.pvp = 1;
|
||||||
/* Time entitled on Account: Move to account */
|
/* Time entitled on Account: Move to account */
|
||||||
m_pp.timeentitledonaccount = database.GetTotalTimeEntitledOnAccount(AccountID()) / 1440;
|
m_pp.timeentitledonaccount = CharacterDataRepository::GetTotalTimePlayed(database, AccountID()) / 1440;
|
||||||
/* Reset rest timer if the durations have been lowered in the database */
|
/* Reset rest timer if the durations have been lowered in the database */
|
||||||
if ((m_pp.RestTimer > RuleI(Character, RestRegenTimeToActivate)) && (m_pp.RestTimer > RuleI(Character, RestRegenRaidTimeToActivate)))
|
if ((m_pp.RestTimer > RuleI(Character, RestRegenTimeToActivate)) && (m_pp.RestTimer > RuleI(Character, RestRegenRaidTimeToActivate)))
|
||||||
m_pp.RestTimer = 0;
|
m_pp.RestTimer = 0;
|
||||||
@ -7988,7 +7988,7 @@ void Client::Handle_OP_GuildCreate(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
if ((Admin() < RuleI(Guild, PlayerCreationRequiredStatus)) ||
|
if ((Admin() < RuleI(Guild, PlayerCreationRequiredStatus)) ||
|
||||||
(GetLevel() < RuleI(Guild, PlayerCreationRequiredLevel)) ||
|
(GetLevel() < RuleI(Guild, PlayerCreationRequiredLevel)) ||
|
||||||
(database.GetTotalTimeEntitledOnAccount(AccountID()) < (unsigned int)RuleI(Guild, PlayerCreationRequiredTime)))
|
(CharacterDataRepository::GetTotalTimePlayed(database, AccountID()) < (unsigned int)RuleI(Guild, PlayerCreationRequiredTime)))
|
||||||
{
|
{
|
||||||
Message(Chat::Red, "Your status, level or time playing on this account are insufficient to use this feature.");
|
Message(Chat::Red, "Your status, level or time playing on this account are insufficient to use this feature.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user