aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp18
-rwxr-xr-xsrc/server/game/Events/GameEventMgr.cpp35
-rwxr-xr-xsrc/server/game/Events/GameEventMgr.h3
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.h8
-rwxr-xr-xsrc/server/game/Quests/QuestDef.cpp7
-rwxr-xr-xsrc/server/game/Quests/QuestDef.h6
6 files changed, 46 insertions, 31 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index d6a33c1c4e8..f2e7e60a3e3 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -15449,9 +15449,13 @@ bool Player::SatisfyQuestSeasonal(Quest const* qInfo, bool /*msg*/)
{
if (!qInfo->IsSeasonal() || m_seasonalquests.empty())
return true;
- if (m_seasonalquests.find(qInfo->GetSeasonalQuestEvent()) == m_seasonalquests.end()) return false;
+
+ uint16 eventId = sGameEventMgr->GetEventIdForQuest(qInfo);
+ if (m_seasonalquests.find(eventId) == m_seasonalquests.end())
+ return false;
+
// if not found in cooldown list
- return m_seasonalquests[qInfo->GetSeasonalQuestEvent()].find(qInfo->GetQuestId()) == m_seasonalquests[qInfo->GetSeasonalQuestEvent()].end();
+ return m_seasonalquests[eventId].find(qInfo->GetQuestId()) == m_seasonalquests[eventId].end();
}
bool Player::GiveQuestSourceItem(Quest const* quest)
@@ -19004,7 +19008,7 @@ void Player::_SaveSeasonalQuestStatus(SQLTransaction& trans)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR);
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
-
+
for (SeasonalEventQuestMap::const_iterator iter = m_seasonalquests.begin(); iter != m_seasonalquests.end(); ++iter)
{
uint16 event_id = iter->first;
@@ -22117,11 +22121,11 @@ void Player::SetWeeklyQuestStatus(uint32 quest_id)
void Player::SetSeasonalQuestStatus(uint32 quest_id)
{
- Quest const* q = sObjectMgr->GetQuestTemplate(quest_id);
- if (!q)
+ Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
+ if (!quest)
return;
-
- m_seasonalquests[q->GetSeasonalQuestEvent()].insert(quest_id);
+
+ m_seasonalquests[sGameEventMgr->GetEventIdForQuest(quest)].insert(quest_id);
m_SeasonalQuestChanged = true;
}
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index e1900c6c994..6f5dc0e511e 100755
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -764,7 +764,7 @@ void GameEventMgr::LoadFromDB()
uint32 oldMSTime = getMSTime();
// 0 1
- QueryResult result = WorldDatabase.Query("SELECT quest, event FROM game_event_seasonal_questrelation");
+ QueryResult result = WorldDatabase.Query("SELECT questId, eventEntry FROM game_event_seasonal_questrelation");
if (!result)
{
@@ -778,19 +778,22 @@ void GameEventMgr::LoadFromDB()
{
Field* fields = result->Fetch();
- uint32 quest = fields[0].GetUInt32();
- uint16 event_id = fields[1].GetUInt16();
+ uint32 questId = fields[0].GetUInt32();
+ uint16 eventEntry = fields[1].GetUInt16();
- if (event_id >= mGameEvent.size())
+ if (!sObjectMgr->GetQuestTemplate(questId))
+ {
+ sLog->outErrorDb("`game_event_seasonal_questrelation` quest id (%u) does not exist in `quest_template`", questId);
+ continue;
+ }
+
+ if (eventEntry >= mGameEvent.size())
{
- sLog->outErrorDb("`game_event_seasonal_questrelation` event id (%u) is out of range compared to max event in `game_event`", event_id);
+ sLog->outErrorDb("`game_event_seasonal_questrelation` event id (%u) is out of range compared to max event in `game_event`", eventEntry);
continue;
}
-
- Quest * qInfo = sObjectMgr->GetQuestTemplate(quest);
- if (qInfo)
- qInfo->SetSeasonalQuestEvent(event_id);
+ _questToEventLinks[questId] = eventEntry;
++count;
}
while (result->NextRow());
@@ -1671,6 +1674,18 @@ void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate)
}
}
+uint16 GameEventMgr::GetEventIdForQuest(Quest const* quest) const
+{
+ if (!quest)
+ return 0;
+
+ UNORDERED_MAP<uint32, uint16>::const_iterator itr = _questToEventLinks.find(quest->GetQuestId());
+ if (itr == _questToEventLinks.end())
+ return 0;
+
+ return itr->second;
+}
+
bool IsHolidayActive(HolidayIds id)
{
if (id == HOLIDAY_NONE)
@@ -1686,7 +1701,7 @@ bool IsHolidayActive(HolidayIds id)
return false;
}
- bool IsEventActive(uint16 event_id)
+bool IsEventActive(uint16 event_id)
{
GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList();
return ae.find(event_id) != ae.end();
diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h
index 34258bac499..d9b5890bfe5 100755
--- a/src/server/game/Events/GameEventMgr.h
+++ b/src/server/game/Events/GameEventMgr.h
@@ -89,6 +89,7 @@ struct NPCVendorEntry
class Player;
class Creature;
+class Quest;
class GameEventMgr
{
@@ -118,6 +119,7 @@ class GameEventMgr
void HandleWorldEventGossip(Player* player, Creature* c);
uint32 GetNPCFlag(Creature* cr);
uint32 GetNpcTextId(uint32 guid);
+ uint16 GetEventIdForQuest(Quest const* quest) const;
private:
void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
@@ -169,6 +171,7 @@ class GameEventMgr
QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags;
ActiveEvents m_ActiveEvents;
+ UNORDERED_MAP<uint32, uint16> _questToEventLinks;
bool isSystemInit;
public:
GameEventGuidMap mGameEventCreatureGuids;
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 1b6d90da0a6..126cca59ef0 100755
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -670,6 +670,7 @@ class ObjectMgr
return NULL;
return info;
}
+
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const;
uint64 GetPlayerGUIDByName(std::string name) const;
@@ -687,11 +688,7 @@ class ObjectMgr
QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
return itr != mQuestTemplates.end() ? itr->second : NULL;
}
- Quest * GetQuestTemplate(uint32 quest_id)
- {
- QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
- return itr != mQuestTemplates.end() ? itr->second : NULL;
- }
+
QuestMap const& GetQuestTemplates() const { return mQuestTemplates; }
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
@@ -701,6 +698,7 @@ class ObjectMgr
return itr->second;
return 0;
}
+
bool IsTavernAreaTrigger(uint32 Trigger_ID) const
{
return mTavernAreaTriggerSet.find(Trigger_ID) != mTavernAreaTriggerSet.end();
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp
index 674f54d07a8..0467eaa3253 100755
--- a/src/server/game/Quests/QuestDef.cpp
+++ b/src/server/game/Quests/QuestDef.cpp
@@ -65,7 +65,6 @@ Quest::Quest(Field* questRecord)
RequiredPlayerKills = questRecord[40].GetUInt32();
RewardTalents = questRecord[41].GetUInt32();
RewardArenaPoints = questRecord[42].GetInt32();
- SeasonalQuestEvent = 0;
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
RewardItemId[i] = questRecord[43+i].GetUInt32();
@@ -78,7 +77,7 @@ Quest::Quest(Field* questRecord)
for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
RewardChoiceItemCount[i] = questRecord[57+i].GetUInt32();
-
+
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
RewardFactionId[i] = questRecord[63+i].GetUInt32();
@@ -87,7 +86,7 @@ Quest::Quest(Field* questRecord)
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
RewardFactionValueIdOverride[i] = questRecord[73+i].GetInt32();
-
+
PointMapId = questRecord[78].GetUInt32();
PointX = questRecord[79].GetFloat();
PointY = questRecord[80].GetFloat();
@@ -203,7 +202,7 @@ uint32 Quest::XPValue(Player* player) const
return 0;
}
-int32 Quest::GetRewOrReqMoney() const
+int32 Quest::GetRewOrReqMoney() const
{
if (RewardOrRequiredMoney <= 0)
return RewardOrRequiredMoney;
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 4fbfcd176f4..3e142e1d84c 100755
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -187,7 +187,6 @@ class Quest
bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; }
void SetFlag(uint32 flag) { Flags |= flag; }
- void SetSeasonalQuestEvent(uint16 event_id) { SeasonalQuestEvent = event_id; }
// table data accessors:
uint32 GetQuestId() const { return Id; }
@@ -247,13 +246,12 @@ class Quest
uint32 GetCompleteEmote() const { return EmoteOnComplete; }
uint32 GetQuestStartScript() const { return StartScript; }
uint32 GetQuestCompleteScript() const { return CompleteScript; }
- uint16 GetSeasonalQuestEvent() const {return SeasonalQuestEvent; }
bool IsRepeatable() const { return Flags & QUEST_TRINITY_FLAGS_REPEATABLE; }
bool IsAutoComplete() const;
uint32 GetFlags() const { return Flags; }
bool IsDaily() const { return Flags & QUEST_FLAGS_DAILY; }
bool IsWeekly() const { return Flags & QUEST_FLAGS_WEEKLY; }
- bool IsSeasonal() const { return ZoneOrSort == -22; }
+ bool IsSeasonal() const { return ZoneOrSort == -QUEST_SORT_SEASONAL; }
bool IsDailyOrWeekly() const { return Flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); }
bool IsAutoAccept() const { return Flags & QUEST_FLAGS_AUTO_ACCEPT; }
bool IsRaidQuest() const { return Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25; }
@@ -298,8 +296,6 @@ class Quest
uint32 m_reqCreatureOrGOcount;
uint32 m_rewchoiceitemscount;
uint32 m_rewitemscount;
- //additional data needed for seasonal quest events
- uint16 SeasonalQuestEvent;
// table data
protected: