feat(Core/Config): CONFIG_INTERVAL_SAVE (#3171)

This commit is contained in:
Kitzunu
2020-08-20 15:50:32 +02:00
committed by GitHub
parent 5d284f02a7
commit 73d725312d
5 changed files with 38 additions and 4 deletions

View File

@@ -1085,9 +1085,32 @@ public:
return true;
}
static bool HandleSaveCommand(ChatHandler* /*handler*/, char const* /*args*/)
static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/)
{
// pussywizard: fully disabled on 28.12.2011, but disabled it "silently"
Player* player = handler->GetSession()->GetPlayer();
// save GM account without delay and output message
if (handler->GetSession()->GetSecurity() >= SEC_GAMEMASTER)
{
if (Player* target = handler->getSelectedPlayer())
{
target->SaveToDB(true, false);
}
else
{
player->SaveToDB(true, false);
}
handler->SendSysMessage(LANG_PLAYER_SAVED);
return true;
}
// save if the player has last been saved over 20 seconds ago
uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
{
player->SaveToDB(true, false);
}
return true;
}