Core/Events

* Changed how quests are linked to events (no longer in Quest class)
* Added quest validation when loading game_event_seasonal_questrelation
* Renamed fields in new table to be consistent with game_event* tables
* Corrected db data (some entries had -1 as event id)
This commit is contained in:
Shauren
2012-01-05 13:27:17 +01:00
parent fc987e9a2f
commit 01900b5829
7 changed files with 51 additions and 31 deletions
@@ -0,0 +1,5 @@
UPDATE `game_event_seasonal_questrelation` SET `event`=8 WHERE `event`=-1;
ALTER TABLE `game_event_seasonal_questrelation`
CHANGE `quest` `questId` int(10) unsigned NOT NULL COMMENT 'Quest Identifier',
CHANGE `event` `eventEntry` mediumint(8) unsigned NOT NULL DEFAULT 0 COMMENT 'Entry of the game event';
+11 -7
View File
@@ -15449,9 +15449,13 @@ bool Player::SatisfyQuestSeasonal(Quest const* qInfo, bool /*msg*/)
{ {
if (!qInfo->IsSeasonal() || m_seasonalquests.empty()) if (!qInfo->IsSeasonal() || m_seasonalquests.empty())
return true; 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 // 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) 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); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_STATUS_SEASONAL_CHAR);
stmt->setUInt32(0, GetGUIDLow()); stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt); trans->Append(stmt);
for (SeasonalEventQuestMap::const_iterator iter = m_seasonalquests.begin(); iter != m_seasonalquests.end(); ++iter) for (SeasonalEventQuestMap::const_iterator iter = m_seasonalquests.begin(); iter != m_seasonalquests.end(); ++iter)
{ {
uint16 event_id = iter->first; uint16 event_id = iter->first;
@@ -22117,11 +22121,11 @@ void Player::SetWeeklyQuestStatus(uint32 quest_id)
void Player::SetSeasonalQuestStatus(uint32 quest_id) void Player::SetSeasonalQuestStatus(uint32 quest_id)
{ {
Quest const* q = sObjectMgr->GetQuestTemplate(quest_id); Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
if (!q) if (!quest)
return; return;
m_seasonalquests[q->GetSeasonalQuestEvent()].insert(quest_id); m_seasonalquests[sGameEventMgr->GetEventIdForQuest(quest)].insert(quest_id);
m_SeasonalQuestChanged = true; m_SeasonalQuestChanged = true;
} }
+25 -10
View File
@@ -764,7 +764,7 @@ void GameEventMgr::LoadFromDB()
uint32 oldMSTime = getMSTime(); uint32 oldMSTime = getMSTime();
// 0 1 // 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) if (!result)
{ {
@@ -778,19 +778,22 @@ void GameEventMgr::LoadFromDB()
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 quest = fields[0].GetUInt32(); uint32 questId = fields[0].GetUInt32();
uint16 event_id = fields[1].GetUInt16(); uint16 eventEntry = fields[1].GetUInt16();
if (event_id >= mGameEvent.size()) if (!sObjectMgr->GetQuestTemplate(questId))
{ {
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` quest id (%u) does not exist in `quest_template`", questId);
continue; continue;
} }
Quest * qInfo = sObjectMgr->GetQuestTemplate(quest);
if (qInfo)
qInfo->SetSeasonalQuestEvent(event_id);
if (eventEntry >= mGameEvent.size())
{
sLog->outErrorDb("`game_event_seasonal_questrelation` event id (%u) is out of range compared to max event in `game_event`", eventEntry);
continue;
}
_questToEventLinks[questId] = eventEntry;
++count; ++count;
} }
while (result->NextRow()); 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) bool IsHolidayActive(HolidayIds id)
{ {
if (id == HOLIDAY_NONE) if (id == HOLIDAY_NONE)
@@ -1686,7 +1701,7 @@ bool IsHolidayActive(HolidayIds id)
return false; return false;
} }
bool IsEventActive(uint16 event_id) bool IsEventActive(uint16 event_id)
{ {
GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList();
return ae.find(event_id) != ae.end(); return ae.find(event_id) != ae.end();
+3
View File
@@ -89,6 +89,7 @@ struct NPCVendorEntry
class Player; class Player;
class Creature; class Creature;
class Quest;
class GameEventMgr class GameEventMgr
{ {
@@ -118,6 +119,7 @@ class GameEventMgr
void HandleWorldEventGossip(Player* player, Creature* c); void HandleWorldEventGossip(Player* player, Creature* c);
uint32 GetNPCFlag(Creature* cr); uint32 GetNPCFlag(Creature* cr);
uint32 GetNpcTextId(uint32 guid); uint32 GetNpcTextId(uint32 guid);
uint16 GetEventIdForQuest(Quest const* quest) const;
private: private:
void SendWorldStateUpdate(Player* player, uint16 event_id); void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
@@ -169,6 +171,7 @@ class GameEventMgr
QuestIdToEventConditionMap mQuestToEventConditions; QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags; GameEventNPCFlagMap mGameEventNPCFlags;
ActiveEvents m_ActiveEvents; ActiveEvents m_ActiveEvents;
UNORDERED_MAP<uint32, uint16> _questToEventLinks;
bool isSystemInit; bool isSystemInit;
public: public:
GameEventGuidMap mGameEventCreatureGuids; GameEventGuidMap mGameEventCreatureGuids;
+3 -5
View File
@@ -670,6 +670,7 @@ class ObjectMgr
return NULL; return NULL;
return info; return info;
} }
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const;
uint64 GetPlayerGUIDByName(std::string name) const; uint64 GetPlayerGUIDByName(std::string name) const;
@@ -687,11 +688,7 @@ class ObjectMgr
QuestMap::const_iterator itr = mQuestTemplates.find(quest_id); QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
return itr != mQuestTemplates.end() ? itr->second : NULL; 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; } QuestMap const& GetQuestTemplates() const { return mQuestTemplates; }
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
@@ -701,6 +698,7 @@ class ObjectMgr
return itr->second; return itr->second;
return 0; return 0;
} }
bool IsTavernAreaTrigger(uint32 Trigger_ID) const bool IsTavernAreaTrigger(uint32 Trigger_ID) const
{ {
return mTavernAreaTriggerSet.find(Trigger_ID) != mTavernAreaTriggerSet.end(); return mTavernAreaTriggerSet.find(Trigger_ID) != mTavernAreaTriggerSet.end();
+3 -4
View File
@@ -65,7 +65,6 @@ Quest::Quest(Field* questRecord)
RequiredPlayerKills = questRecord[40].GetUInt32(); RequiredPlayerKills = questRecord[40].GetUInt32();
RewardTalents = questRecord[41].GetUInt32(); RewardTalents = questRecord[41].GetUInt32();
RewardArenaPoints = questRecord[42].GetInt32(); RewardArenaPoints = questRecord[42].GetInt32();
SeasonalQuestEvent = 0;
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
RewardItemId[i] = questRecord[43+i].GetUInt32(); RewardItemId[i] = questRecord[43+i].GetUInt32();
@@ -78,7 +77,7 @@ Quest::Quest(Field* questRecord)
for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
RewardChoiceItemCount[i] = questRecord[57+i].GetUInt32(); RewardChoiceItemCount[i] = questRecord[57+i].GetUInt32();
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
RewardFactionId[i] = questRecord[63+i].GetUInt32(); RewardFactionId[i] = questRecord[63+i].GetUInt32();
@@ -87,7 +86,7 @@ Quest::Quest(Field* questRecord)
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
RewardFactionValueIdOverride[i] = questRecord[73+i].GetInt32(); RewardFactionValueIdOverride[i] = questRecord[73+i].GetInt32();
PointMapId = questRecord[78].GetUInt32(); PointMapId = questRecord[78].GetUInt32();
PointX = questRecord[79].GetFloat(); PointX = questRecord[79].GetFloat();
PointY = questRecord[80].GetFloat(); PointY = questRecord[80].GetFloat();
@@ -203,7 +202,7 @@ uint32 Quest::XPValue(Player* player) const
return 0; return 0;
} }
int32 Quest::GetRewOrReqMoney() const int32 Quest::GetRewOrReqMoney() const
{ {
if (RewardOrRequiredMoney <= 0) if (RewardOrRequiredMoney <= 0)
return RewardOrRequiredMoney; return RewardOrRequiredMoney;
+1 -5
View File
@@ -187,7 +187,6 @@ class Quest
bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; } bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; }
void SetFlag(uint32 flag) { Flags |= flag; } void SetFlag(uint32 flag) { Flags |= flag; }
void SetSeasonalQuestEvent(uint16 event_id) { SeasonalQuestEvent = event_id; }
// table data accessors: // table data accessors:
uint32 GetQuestId() const { return Id; } uint32 GetQuestId() const { return Id; }
@@ -247,13 +246,12 @@ class Quest
uint32 GetCompleteEmote() const { return EmoteOnComplete; } uint32 GetCompleteEmote() const { return EmoteOnComplete; }
uint32 GetQuestStartScript() const { return StartScript; } uint32 GetQuestStartScript() const { return StartScript; }
uint32 GetQuestCompleteScript() const { return CompleteScript; } uint32 GetQuestCompleteScript() const { return CompleteScript; }
uint16 GetSeasonalQuestEvent() const {return SeasonalQuestEvent; }
bool IsRepeatable() const { return Flags & QUEST_TRINITY_FLAGS_REPEATABLE; } bool IsRepeatable() const { return Flags & QUEST_TRINITY_FLAGS_REPEATABLE; }
bool IsAutoComplete() const; bool IsAutoComplete() const;
uint32 GetFlags() const { return Flags; } uint32 GetFlags() const { return Flags; }
bool IsDaily() const { return Flags & QUEST_FLAGS_DAILY; } bool IsDaily() const { return Flags & QUEST_FLAGS_DAILY; }
bool IsWeekly() const { return Flags & QUEST_FLAGS_WEEKLY; } 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 IsDailyOrWeekly() const { return Flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); }
bool IsAutoAccept() const { return Flags & QUEST_FLAGS_AUTO_ACCEPT; } 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; } 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_reqCreatureOrGOcount;
uint32 m_rewchoiceitemscount; uint32 m_rewchoiceitemscount;
uint32 m_rewitemscount; uint32 m_rewitemscount;
//additional data needed for seasonal quest events
uint16 SeasonalQuestEvent;
// table data // table data
protected: protected: