Core/DB: Add a world state for daily quest reset time to characters. Not used right now, but written to allow easier transition later.

Port From (https://github.com/TrinityCore/TrinityCore/commit/9fa5c714096a9755a3a7ada45c8d5e6a54f18950)
This commit is contained in:
hondacrx
2022-01-01 15:04:31 -05:00
parent 8766de8286
commit 882f9c49fb
3 changed files with 33 additions and 22 deletions
+21 -19
View File
@@ -80,6 +80,25 @@ namespace Game
Global.ScriptMgr.OnOpenStateChange(!val);
}
void LoadDBAllowedSecurityLevel()
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_REALMLIST_SECURITY_LEVEL);
stmt.AddValue(0, (int)_realm.Id.Index);
SQLResult result = DB.Login.Query(stmt);
if (!result.IsEmpty())
SetPlayerSecurityLimit((AccountTypes)result.Read<byte>(0));
}
void SetPlayerSecurityLimit(AccountTypes _sec)
{
AccountTypes sec = _sec < AccountTypes.Console ? _sec : AccountTypes.Player;
bool update = sec > m_allowedSecurityLevel;
m_allowedSecurityLevel = sec;
if (update)
KickAllLess(m_allowedSecurityLevel);
}
public void SetMotd(string motd)
{
Global.ScriptMgr.OnMotdChange(motd);
@@ -1979,6 +1998,8 @@ namespace Game
m_NextDailyQuestReset = mostRecentQuestTime;
else // plan next reset time
m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + Time.Day : curDayResetTime;
SetWorldState(WorldStates.DailyQuestResetTime, (ulong)m_NextDailyQuestReset);
}
void InitMonthlyQuestResetTime()
@@ -2083,25 +2104,6 @@ namespace Game
SetWorldState(WorldStates.CurrencyResetTime, (ulong)m_NextCurrencyReset);
}
public void LoadDBAllowedSecurityLevel()
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_REALMLIST_SECURITY_LEVEL);
stmt.AddValue(0, _realm.Id.Index);
SQLResult result = DB.Login.Query(stmt);
if (!result.IsEmpty())
SetPlayerSecurityLimit((AccountTypes)result.Read<byte>(0));
}
public void SetPlayerSecurityLimit(AccountTypes accountType)
{
AccountTypes security = accountType < AccountTypes.Console ? accountType : AccountTypes.Player;
bool update = security > m_allowedSecurityLevel;
m_allowedSecurityLevel = security;
if (update)
KickAllLess(m_allowedSecurityLevel);
}
void ResetWeeklyQuests()
{
Log.outInfo(LogFilter.Server, "Weekly quests reset for all characters.");