mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[10655] Add support for monthly quests
Quest that can repeated each month are set by quest_template.SpecialFlags |0x04 flag Quest are reset at midnight the first day of each month. Note: for the time being, quest must also be set repeatable (SpecialFlags |0x01) Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
331a7e7f5b
commit
a38f97f71c
12 changed files with 218 additions and 13 deletions
|
|
@ -1311,6 +1311,9 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString("Calculate next weekly quest reset time..." );
|
||||
InitWeeklyQuestResetTime();
|
||||
|
||||
sLog.outString("Calculate next monthly quest reset time..." );
|
||||
SetMonthlyQuestResetTime();
|
||||
|
||||
sLog.outString("Starting objects Pooling system..." );
|
||||
sPoolMgr.Initialize();
|
||||
|
||||
|
|
@ -1395,6 +1398,10 @@ void World::Update(uint32 diff)
|
|||
if (m_gameTime > m_NextWeeklyQuestReset)
|
||||
ResetWeeklyQuests();
|
||||
|
||||
/// Handle monthly quests reset time
|
||||
if (m_gameTime > m_NextMonthlyQuestReset)
|
||||
ResetMonthlyQuests();
|
||||
|
||||
/// <ul><li> Handle auctions when the timer has passed
|
||||
if (m_timers[WUPDATE_AUCTIONS].Passed())
|
||||
{
|
||||
|
|
@ -1994,6 +2001,52 @@ void World::InitDailyQuestResetTime()
|
|||
delete result;
|
||||
}
|
||||
|
||||
void World::SetMonthlyQuestResetTime(bool initialize)
|
||||
{
|
||||
if (initialize)
|
||||
{
|
||||
QueryResult * result = CharacterDatabase.Query("SELECT NextMonthlyQuestResetTime FROM saved_variables");
|
||||
|
||||
if (!result)
|
||||
m_NextMonthlyQuestReset = time_t(time(NULL));
|
||||
else
|
||||
m_NextMonthlyQuestReset = time_t((*result)[0].GetUInt64());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
// generate time
|
||||
time_t currentTime = time(NULL);
|
||||
tm localTm = *localtime(¤tTime);
|
||||
|
||||
int month = localTm.tm_mon;
|
||||
int year = localTm.tm_year;
|
||||
|
||||
++month;
|
||||
|
||||
// month 11 is december, next is january (0)
|
||||
if (month > 11)
|
||||
{
|
||||
month = 0;
|
||||
year += 1;
|
||||
}
|
||||
|
||||
// reset time for next month
|
||||
localTm.tm_year = year;
|
||||
localTm.tm_mon = month;
|
||||
localTm.tm_mday = 1; // don't know if we really need config option for day/hour
|
||||
localTm.tm_hour = 0;
|
||||
localTm.tm_min = 0;
|
||||
localTm.tm_sec = 0;
|
||||
|
||||
time_t nextMonthResetTime = mktime(&localTm);
|
||||
|
||||
m_NextMonthlyQuestReset = (initialize && m_NextMonthlyQuestReset < nextMonthResetTime) ? m_NextMonthlyQuestReset : nextMonthResetTime;
|
||||
|
||||
// Row must exist for this to work. Currently row is added by InitDailyQuestResetTime(), called before this function
|
||||
CharacterDatabase.PExecute("UPDATE saved_variables SET NextMonthlyQuestResetTime = '"UI64FMTD"'", uint64(m_NextMonthlyQuestReset));
|
||||
}
|
||||
|
||||
void World::ResetDailyQuests()
|
||||
{
|
||||
DETAIL_LOG("Daily quests reset for all characters.");
|
||||
|
|
@ -2018,6 +2071,18 @@ void World::ResetWeeklyQuests()
|
|||
CharacterDatabase.PExecute("UPDATE saved_variables SET NextWeeklyQuestResetTime = '"UI64FMTD"'", uint64(m_NextWeeklyQuestReset));
|
||||
}
|
||||
|
||||
void World::ResetMonthlyQuests()
|
||||
{
|
||||
DETAIL_LOG("Monthly quests reset for all characters.");
|
||||
CharacterDatabase.Execute("TRUNCATE character_queststatus_monthly");
|
||||
|
||||
for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
if (itr->second->GetPlayer())
|
||||
itr->second->GetPlayer()->ResetMonthlyQuestStatus();
|
||||
|
||||
SetMonthlyQuestResetTime(false);
|
||||
}
|
||||
|
||||
void World::SetPlayerLimit( int32 limit, bool needUpdate )
|
||||
{
|
||||
if (limit < -SEC_ADMINISTRATOR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue