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';
+9 -5
View File
@@ -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)
@@ -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;
}
+24 -9
View File
@@ -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` 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;
}
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;
}
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();
+3
View File
@@ -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;
+3 -5
View File
@@ -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();
-1
View File
@@ -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();
+1 -5
View File
@@ -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: