Rate limit saving to at most once a second

There are A LOT of unneeded saves ...

This will prevent a lot of excessive database hits at least
with very little room to exploit
This commit is contained in:
Michael Cook (mackal) 2016-08-03 01:13:51 -04:00
parent acb5bb3e3e
commit f26dce39c3
2 changed files with 10 additions and 1 deletions

View File

@ -155,7 +155,8 @@ Client::Client(EQStreamInterface* ieqs)
m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number
m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f),
m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f),
m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f)
m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f),
m_lastsave(-1)
{
for(int cf=0; cf < _FilterCount; cf++)
ClientFilters[cf] = FilterShow;
@ -569,6 +570,10 @@ bool Client::Save(uint8 iCommitNow) {
if(!ClientDataLoaded())
return false;
// saved less than 2 seconds ago, lets just skip for now
if ((time(nullptr) - m_lastsave) < 2)
return true;
/* Wrote current basics to PP for saves */
m_pp.x = m_Position.x;
m_pp.y = m_Position.y;
@ -658,6 +663,7 @@ bool Client::Save(uint8 iCommitNow) {
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp, &m_epp); /* Save Character Data */
m_lastsave = time(nullptr);
return true;
}

View File

@ -1458,6 +1458,9 @@ private:
Timer helm_toggle_timer;
Timer light_update_timer;
time_t m_lastsave;
glm::vec3 m_Proximity;
void BulkSendInventoryItems();