Fix crash of prequest

This commit is contained in:
Yunfan Li
2024-09-17 18:03:41 +08:00
parent bfbc451bfb
commit d443b48edf

View File

@@ -78,6 +78,19 @@ void PlayerbotFactory::Init()
if (!quest->GetRequiredClasses() || quest->IsRepeatable() || quest->GetMinLevel() < 10) if (!quest->GetRequiredClasses() || quest->IsRepeatable() || quest->GetMinLevel() < 10)
continue; continue;
if (quest->GetRewSpellCast() > 0)
{
int32 spellId = quest->GetRewSpellCast();
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
continue;
} else if (quest->GetRewSpell() > 0) {
int32 spellId = quest->GetRewSpell();
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
continue;
}
AddPrevQuests(questId, classQuestIds); AddPrevQuests(questId, classQuestIds);
classQuestIds.remove(questId); classQuestIds.remove(questId);
@@ -381,7 +394,7 @@ void PlayerbotFactory::Randomize(bool incremental)
if (bot->GetLevel() >= 70) if (bot->GetLevel() >= 70)
{ {
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Arenas"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Arenas");
LOG_INFO("playerbots", "Initializing arena teams..."); // LOG_INFO("playerbots", "Initializing arena teams...");
InitArenaTeam(); InitArenaTeam();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
@@ -2723,9 +2736,9 @@ void PlayerbotFactory::InitQuests(std::list<uint32>& questMap)
bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE); bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE);
bot->RewardQuest(quest, 0, bot, false); bot->RewardQuest(quest, 0, bot, false);
LOG_INFO("playerbots", "Bot {} ({} level) rewarded quest {}: {} (MinLevel={}, QuestLevel={})", // LOG_INFO("playerbots", "Bot {} ({} level) rewarded quest {}: {} (MinLevel={}, QuestLevel={})",
bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(), // bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(),
quest->GetQuestLevel()); // quest->GetQuestLevel());
if (!(count++ % 10)) if (!(count++ % 10))
ClearInventory(); ClearInventory();
@@ -2738,7 +2751,7 @@ void PlayerbotFactory::InitInstanceQuests()
{ {
// Yunfan: use configuration instead of hard code // Yunfan: use configuration instead of hard code
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP); uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
LOG_INFO("playerbots", "Initializing quests..."); // LOG_INFO("playerbots", "Initializing quests...");
InitQuests(classQuestIds); InitQuests(classQuestIds);
InitQuests(specialQuestIds); InitQuests(specialQuestIds);