mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[9687] Add to mangos.conf options for daily/weekly reset time.
* Quests.Daily.ResetHour (0..23) for daily quests * Quests.Weekly.ResetWeekDay (0..6) and Quests.Weekly.ResetHour (0..23) for weekly quests. * Drop time from character_queststatus_daily and use same way as weekly quest reset time store.
This commit is contained in:
parent
fdddf9188a
commit
d78117bbc8
11 changed files with 83 additions and 53 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_9686_01_characters_character_queststatus_weekly` bit(1) default NULL
|
||||
`required_9687_01_characters_character_queststatus_daily` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
|
@ -702,7 +702,6 @@ DROP TABLE IF EXISTS `character_queststatus_daily`;
|
|||
CREATE TABLE `character_queststatus_daily` (
|
||||
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
|
||||
`quest` int(11) unsigned NOT NULL default '0' COMMENT 'Quest Identifier',
|
||||
`time` bigint(20) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`guid`,`quest`),
|
||||
KEY `idx_guid` (`guid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System';
|
||||
|
|
@ -1583,6 +1582,7 @@ UNLOCK TABLES;
|
|||
DROP TABLE IF EXISTS `saved_variables`;
|
||||
CREATE TABLE `saved_variables` (
|
||||
`NextArenaPointDistributionTime` bigint(40) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`NextDailyQuestResetTime` bigint(40) unsigned NOT NULL default '0',
|
||||
`NextWeeklyQuestResetTime` bigint(40) unsigned NOT NULL default '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Variable Saves';
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_9686_01_characters_character_queststatus_weekly required_9687_01_characters_character_queststatus_daily bit;
|
||||
|
||||
ALTER TABLE `character_queststatus_daily`
|
||||
DROP COLUMN `time`;
|
||||
|
||||
ALTER TABLE `saved_variables`
|
||||
ADD COLUMN `NextDailyQuestResetTime` bigint(40) unsigned NOT NULL default '0' AFTER `NextArenaPointDistributionTime`;
|
||||
|
||||
|
|
@ -104,6 +104,7 @@ pkgdata_DATA = \
|
|||
9663_01_mangos_mangos_string.sql \
|
||||
9680_01_characters_character_stats.sql \
|
||||
9686_01_characters_character_queststatus_weekly.sql \
|
||||
9687_01_characters_character_queststatus_daily.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -188,4 +189,5 @@ EXTRA_DIST = \
|
|||
9663_01_mangos_mangos_string.sql \
|
||||
9680_01_characters_character_stats.sql \
|
||||
9686_01_characters_character_queststatus_weekly.sql \
|
||||
9687_01_characters_character_queststatus_daily.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ bool LoginQueryHolder::Initialize()
|
|||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS,"SELECT quest FROM character_queststatus_weekly WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT data,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GUID_LOPART(m_guid));
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
|||
m_currentBuybackSlot = BUYBACK_SLOT_START;
|
||||
|
||||
m_DailyQuestChanged = false;
|
||||
m_lastDailyQuestTime = 0;
|
||||
m_WeeklyQuestChanged = false;
|
||||
|
||||
for (int i=0; i<MAX_TIMERS; ++i)
|
||||
m_MirrorTimer[i] = DISABLED_MIRROR_TIMER;
|
||||
|
|
@ -4138,6 +4138,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
|||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_queststatus WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_queststatus_weekly WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_skills WHERE guid = '%u'",guid);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u'",guid);
|
||||
|
|
@ -15890,7 +15891,7 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
|
|||
for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0);
|
||||
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow());
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow());
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
|
@ -15908,9 +15909,6 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
|
|||
|
||||
uint32 quest_id = fields[0].GetUInt32();
|
||||
|
||||
// save _any_ from daily quest times (it must be after last reset anyway)
|
||||
m_lastDailyQuestTime = (time_t)fields[1].GetUInt64();
|
||||
|
||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
|
||||
if( !pQuest )
|
||||
continue;
|
||||
|
|
@ -16849,16 +16847,14 @@ void Player::_SaveDailyQuestStatus()
|
|||
if (!m_DailyQuestChanged)
|
||||
return;
|
||||
|
||||
m_DailyQuestChanged = false;
|
||||
|
||||
// save last daily quest time for all quests: we need only mostly reset time for reset check anyway
|
||||
|
||||
// we don't need transactions here.
|
||||
CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",GetGUIDLow());
|
||||
for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
|
||||
CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')",
|
||||
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
|
||||
CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest) VALUES ('%u', '%u')",
|
||||
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx));
|
||||
|
||||
m_DailyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_SaveWeeklyQuestStatus()
|
||||
|
|
@ -19574,7 +19570,6 @@ void Player::SetDailyQuestStatus( uint32 quest_id )
|
|||
if(!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
|
||||
{
|
||||
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id);
|
||||
m_lastDailyQuestTime = time(NULL); // last daily quest time
|
||||
m_DailyQuestChanged = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -19594,7 +19589,6 @@ void Player::ResetDailyQuestStatus()
|
|||
|
||||
// DB data deleted in caller
|
||||
m_DailyQuestChanged = false;
|
||||
m_lastDailyQuestTime = 0;
|
||||
}
|
||||
|
||||
void Player::ResetWeeklyQuestStatus()
|
||||
|
|
|
|||
|
|
@ -2460,7 +2460,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
|
||||
bool m_DailyQuestChanged;
|
||||
bool m_WeeklyQuestChanged;
|
||||
time_t m_lastDailyQuestTime;
|
||||
|
||||
uint32 m_drunkTimer;
|
||||
uint16 m_drunk;
|
||||
|
|
|
|||
|
|
@ -678,6 +678,10 @@ void World::LoadConfigSettings(bool reload)
|
|||
if (getConfig(CONFIG_UINT32_QUEST_HIGH_LEVEL_HIDE_DIFF) > MAX_LEVEL)
|
||||
setConfig(CONFIG_UINT32_QUEST_HIGH_LEVEL_HIDE_DIFF, MAX_LEVEL);
|
||||
|
||||
setConfigMinMax(CONFIG_UINT32_QUEST_DAILY_RESET_HOUR, "Quests.Daily.ResetHour", 6, 0, 23);
|
||||
setConfigMinMax(CONFIG_UINT32_QUEST_WEEKLY_RESET_WEEK_DAY, "Quests.Weekly.ResetWeekDay", 3, 0, 6);
|
||||
setConfigMinMax(CONFIG_UINT32_QUEST_WEEKLY_RESET_HOUR, "Quests.Weekly.ResetHour", 6, 0 , 23);
|
||||
|
||||
setConfig(CONFIG_BOOL_DETECT_POS_COLLISION, "DetectPosCollision", true);
|
||||
|
||||
setConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL, "Channel.RestrictedLfg", true);
|
||||
|
|
@ -1888,60 +1892,65 @@ void World::InitWeeklyQuestResetTime()
|
|||
{
|
||||
QueryResult * result = CharacterDatabase.Query("SELECT NextWeeklyQuestResetTime FROM saved_variables");
|
||||
if (!result)
|
||||
{
|
||||
m_NextWeeklyQuestReset = time_t(m_gameTime + WEEK);
|
||||
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextWeeklyQuestResetTime) VALUES ('"UI64FMTD"')", uint64(m_NextWeeklyQuestReset));
|
||||
}
|
||||
m_NextWeeklyQuestReset = time_t(time(NULL)); // game time not yet init
|
||||
else
|
||||
{
|
||||
m_NextWeeklyQuestReset = time_t((*result)[0].GetUInt64());
|
||||
|
||||
// move to just before if need
|
||||
time_t cur = time(NULL);
|
||||
if(m_NextWeeklyQuestReset < cur)
|
||||
m_NextWeeklyQuestReset += WEEK * ((cur - m_NextWeeklyQuestReset) / WEEK);
|
||||
// generate time by config
|
||||
time_t curTime = time(NULL);
|
||||
tm localTm = *localtime(&curTime);
|
||||
|
||||
int week_day_offset = localTm.tm_wday - int(getConfig(CONFIG_UINT32_QUEST_WEEKLY_RESET_WEEK_DAY));
|
||||
|
||||
// current week reset time
|
||||
localTm.tm_hour = getConfig(CONFIG_UINT32_QUEST_WEEKLY_RESET_HOUR);
|
||||
localTm.tm_min = 0;
|
||||
localTm.tm_sec = 0;
|
||||
time_t nextWeekResetTime = mktime(&localTm);
|
||||
nextWeekResetTime -= week_day_offset * DAY; // move time to proper day
|
||||
|
||||
// next reset time before current moment
|
||||
if (curTime >= nextWeekResetTime)
|
||||
nextWeekResetTime += WEEK;
|
||||
|
||||
// normalize reset time
|
||||
m_NextWeeklyQuestReset = m_NextWeeklyQuestReset < curTime ? nextWeekResetTime - WEEK : nextWeekResetTime;
|
||||
|
||||
if (!result)
|
||||
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextWeeklyQuestResetTime) VALUES ('"UI64FMTD"')", uint64(m_NextWeeklyQuestReset));
|
||||
else
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
void World::InitDailyQuestResetTime()
|
||||
{
|
||||
time_t mostRecentQuestTime;
|
||||
|
||||
QueryResult* result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily");
|
||||
if(result)
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
mostRecentQuestTime = (time_t)fields[0].GetUInt64();
|
||||
delete result;
|
||||
}
|
||||
QueryResult * result = CharacterDatabase.Query("SELECT NextDailyQuestResetTime FROM saved_variables");
|
||||
if (!result)
|
||||
m_NextDailyQuestReset = time_t(time(NULL)); // game time not yet init
|
||||
else
|
||||
mostRecentQuestTime = 0;
|
||||
m_NextWeeklyQuestReset = time_t((*result)[0].GetUInt64());
|
||||
|
||||
// client built-in time for reset is 6:00 AM
|
||||
// FIX ME: client not show day start time
|
||||
// generate time by config
|
||||
time_t curTime = time(NULL);
|
||||
tm localTm = *localtime(&curTime);
|
||||
localTm.tm_hour = 6;
|
||||
localTm.tm_hour = getConfig(CONFIG_UINT32_QUEST_DAILY_RESET_HOUR);
|
||||
localTm.tm_min = 0;
|
||||
localTm.tm_sec = 0;
|
||||
|
||||
// current day reset time
|
||||
time_t curDayResetTime = mktime(&localTm);
|
||||
time_t nextDayResetTime = mktime(&localTm);
|
||||
|
||||
// last reset time before current moment
|
||||
time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime;
|
||||
// next reset time before current moment
|
||||
if (curTime >= nextDayResetTime)
|
||||
nextDayResetTime += DAY;
|
||||
|
||||
// need reset (if we have quest time before last reset time (not processed by some reason)
|
||||
if(mostRecentQuestTime && mostRecentQuestTime <= resetTime)
|
||||
m_NextDailyQuestReset = mostRecentQuestTime;
|
||||
// normalize reset time
|
||||
m_NextDailyQuestReset = m_NextDailyQuestReset < curTime ? nextDayResetTime - DAY : nextDayResetTime;
|
||||
|
||||
if (!result)
|
||||
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextDailyQuestResetTime) VALUES ('"UI64FMTD"')", uint64(m_NextDailyQuestReset));
|
||||
else
|
||||
{
|
||||
// plan next reset time
|
||||
m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + DAY : curDayResetTime;
|
||||
}
|
||||
delete result;
|
||||
}
|
||||
|
||||
void World::ResetDailyQuests()
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ enum eConfigUInt32Values
|
|||
CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF,
|
||||
CONFIG_UINT32_QUEST_LOW_LEVEL_HIDE_DIFF,
|
||||
CONFIG_UINT32_QUEST_HIGH_LEVEL_HIDE_DIFF,
|
||||
CONFIG_UINT32_QUEST_DAILY_RESET_HOUR,
|
||||
CONFIG_UINT32_QUEST_WEEKLY_RESET_WEEK_DAY,
|
||||
CONFIG_UINT32_QUEST_WEEKLY_RESET_HOUR,
|
||||
CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY,
|
||||
CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_KICK,
|
||||
CONFIG_UINT32_CORPSE_DECAY_NORMAL,
|
||||
|
|
|
|||
|
|
@ -558,6 +558,18 @@ LogColors = ""
|
|||
# Default: 7
|
||||
# -1 (show all available quests marks)
|
||||
#
|
||||
# Quests.Daily.ResetHour
|
||||
# Hour when daily quests reset (0..23)
|
||||
# Default: 6
|
||||
#
|
||||
# Quests.Weekly.ResetWeekDay
|
||||
# Week day when daily quests reset (0..6) 0 == Sunday
|
||||
# Default: 3
|
||||
#
|
||||
# Quests.Weekly.ResetHour
|
||||
# Hour in one from weekly days when weekly quests reset (0..23)
|
||||
# Default: 6
|
||||
#
|
||||
# Guild.EventLogRecordsCount
|
||||
# Count of guild event log records stored in guild_eventlog table
|
||||
# Increase to store more guild events in table, minimum is 100
|
||||
|
|
@ -685,6 +697,9 @@ Instance.ResetTimeHour = 4
|
|||
Instance.UnloadDelay = 1800000
|
||||
Quests.LowLevelHideDiff = 4
|
||||
Quests.HighLevelHideDiff = 7
|
||||
Quests.Daily.ResetHour = 6
|
||||
Quests.Weekly.ResetWeekDay = 3
|
||||
Quests.Weekly.ResetHour = 6
|
||||
Guild.EventLogRecordsCount = 100
|
||||
Guild.BankEventLogRecordsCount = 25
|
||||
TimerBar.Fatigue.GMLevel = 4
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9686"
|
||||
#define REVISION_NR "9687"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_9686_01_characters_character_queststatus_weekly"
|
||||
#define REVISION_DB_CHARACTERS "required_9687_01_characters_character_queststatus_daily"
|
||||
#define REVISION_DB_MANGOS "required_9663_01_mangos_mangos_string"
|
||||
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue