[9685] Code style cleanups in quest code.

This commit is contained in:
VladimirMangos 2010-04-07 03:25:05 +04:00
parent ea5788ff70
commit e45d165a8e
6 changed files with 111 additions and 111 deletions

View file

@ -3374,7 +3374,7 @@ void ObjectMgr::LoadQuests()
// 138 139 // 138 139
"StartScript, CompleteScript" "StartScript, CompleteScript"
" FROM quest_template"); " FROM quest_template");
if(result == NULL) if (result == NULL)
{ {
barGoLink bar( 1 ); barGoLink bar( 1 );
bar.step(); bar.step();
@ -3410,7 +3410,7 @@ void ObjectMgr::LoadQuests()
// additional quest integrity checks (GO, creature_template and item_template must be loaded already) // additional quest integrity checks (GO, creature_template and item_template must be loaded already)
if( qinfo->GetQuestMethod() >= 3 ) if (qinfo->GetQuestMethod() >= 3)
{ {
sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.",qinfo->GetQuestId(),qinfo->GetQuestMethod()); sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.",qinfo->GetQuestId(),qinfo->GetQuestMethod());
} }
@ -3422,21 +3422,21 @@ void ObjectMgr::LoadQuests()
qinfo->QuestFlags &= QUEST_MANGOS_FLAGS_DB_ALLOWED; qinfo->QuestFlags &= QUEST_MANGOS_FLAGS_DB_ALLOWED;
} }
if(qinfo->QuestFlags & QUEST_FLAGS_DAILY) if (qinfo->QuestFlags & QUEST_FLAGS_DAILY)
{ {
if(!(qinfo->QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE)) if (!(qinfo->QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE))
{ {
sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId()); sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId());
qinfo->QuestFlags |= QUEST_MANGOS_FLAGS_REPEATABLE; qinfo->QuestFlags |= QUEST_MANGOS_FLAGS_REPEATABLE;
} }
} }
if(qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED) if (qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED)
{ {
// at auto-reward can be rewarded only RewChoiceItemId[0] // at auto-reward can be rewarded only RewChoiceItemId[0]
for(int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) for(int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
{ {
if(uint32 id = qinfo->RewChoiceItemId[j]) if (uint32 id = qinfo->RewChoiceItemId[j])
{ {
sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.",
qinfo->GetQuestId(),j+1,id,j+1); qinfo->GetQuestId(),j+1,id,j+1);
@ -3446,9 +3446,9 @@ void ObjectMgr::LoadQuests()
} }
// client quest log visual (area case) // client quest log visual (area case)
if( qinfo->ZoneOrSort > 0 ) if (qinfo->ZoneOrSort > 0)
{ {
if(!GetAreaEntryByAreaID(qinfo->ZoneOrSort)) if (!GetAreaEntryByAreaID(qinfo->ZoneOrSort))
{ {
sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.",
qinfo->GetQuestId(),qinfo->ZoneOrSort); qinfo->GetQuestId(),qinfo->ZoneOrSort);
@ -3456,30 +3456,30 @@ void ObjectMgr::LoadQuests()
} }
} }
// client quest log visual (sort case) // client quest log visual (sort case)
if( qinfo->ZoneOrSort < 0 ) if (qinfo->ZoneOrSort < 0)
{ {
QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort)); QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
if( !qSort ) if (!qSort)
{ {
sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.", sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.",
qinfo->GetQuestId(),qinfo->ZoneOrSort); qinfo->GetQuestId(),qinfo->ZoneOrSort);
// no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check)
} }
//check SkillOrClass value (class case). //check SkillOrClass value (class case).
if( ClassByQuestSort(-int32(qinfo->ZoneOrSort)) ) if (ClassByQuestSort(-int32(qinfo->ZoneOrSort)))
{ {
// SkillOrClass should not have class case when class case already set in ZoneOrSort. // SkillOrClass should not have class case when class case already set in ZoneOrSort.
if(qinfo->SkillOrClass < 0) if (qinfo->SkillOrClass < 0)
{ {
sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClass` = %i (class case), redundant.", sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClass` = %i (class case), redundant.",
qinfo->GetQuestId(),qinfo->ZoneOrSort,qinfo->SkillOrClass); qinfo->GetQuestId(),qinfo->ZoneOrSort,qinfo->SkillOrClass);
} }
} }
//check for proper SkillOrClass value (skill case) //check for proper SkillOrClass value (skill case)
if(int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort))) if (int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
{ {
// skill is positive value in SkillOrClass // skill is positive value in SkillOrClass
if(qinfo->SkillOrClass != skill_id ) if (qinfo->SkillOrClass != skill_id )
{ {
sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClass` does not have a corresponding value (%i).", sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClass` does not have a corresponding value (%i).",
qinfo->GetQuestId(),qinfo->ZoneOrSort,skill_id); qinfo->GetQuestId(),qinfo->ZoneOrSort,skill_id);
@ -3489,34 +3489,34 @@ void ObjectMgr::LoadQuests()
} }
// SkillOrClass (class case) // SkillOrClass (class case)
if( qinfo->SkillOrClass < 0 ) if (qinfo->SkillOrClass < 0)
{ {
if( !sChrClassesStore.LookupEntry(-int32(qinfo->SkillOrClass)) ) if (!sChrClassesStore.LookupEntry(-int32(qinfo->SkillOrClass)))
{ {
sLog.outErrorDb("Quest %u has `SkillOrClass` = %i (class case) but class (%i) does not exist", sLog.outErrorDb("Quest %u has `SkillOrClass` = %i (class case) but class (%i) does not exist",
qinfo->GetQuestId(),qinfo->SkillOrClass,-qinfo->SkillOrClass); qinfo->GetQuestId(),qinfo->SkillOrClass,-qinfo->SkillOrClass);
} }
} }
// SkillOrClass (skill case) // SkillOrClass (skill case)
if( qinfo->SkillOrClass > 0 ) if (qinfo->SkillOrClass > 0)
{ {
if( !sSkillLineStore.LookupEntry(qinfo->SkillOrClass) ) if (!sSkillLineStore.LookupEntry(qinfo->SkillOrClass))
{ {
sLog.outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist", sLog.outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist",
qinfo->GetQuestId(),qinfo->SkillOrClass,qinfo->SkillOrClass); qinfo->GetQuestId(),qinfo->SkillOrClass,qinfo->SkillOrClass);
} }
} }
if( qinfo->RequiredSkillValue ) if (qinfo->RequiredSkillValue)
{ {
if( qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue() ) if (qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue())
{ {
sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue());
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if( qinfo->SkillOrClass <= 0 ) if (qinfo->SkillOrClass <= 0)
{ {
sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.", sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.",
qinfo->GetQuestId(),qinfo->RequiredSkillValue,qinfo->SkillOrClass); qinfo->GetQuestId(),qinfo->RequiredSkillValue,qinfo->SkillOrClass);
@ -3525,63 +3525,63 @@ void ObjectMgr::LoadQuests()
} }
// else Skill quests can have 0 skill level, this is ok // else Skill quests can have 0 skill level, this is ok
if(qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) if (qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction))
{ {
sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction);
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if(qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
{ {
sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction);
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if(qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
{ {
sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction);
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap) if (qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap)
{ {
sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap); qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap);
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if(qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
{ {
sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue);
// no changes, quest can't be done for this requirement // no changes, quest can't be done for this requirement
} }
if(!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 ) if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 )
{ {
sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RepObjectiveValue); qinfo->GetQuestId(),qinfo->RepObjectiveValue);
// warning // warning
} }
if(!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 ) if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 )
{ {
sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RequiredMinRepValue); qinfo->GetQuestId(),qinfo->RequiredMinRepValue);
// warning // warning
} }
if(!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 ) if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 )
{ {
sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); qinfo->GetQuestId(),qinfo->RequiredMaxRepValue);
// warning // warning
} }
if(qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) if (qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId))
{ {
sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.",
qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId());
@ -3589,38 +3589,38 @@ void ObjectMgr::LoadQuests()
// quest can't reward this title // quest can't reward this title
} }
if(qinfo->SrcItemId) if (qinfo->SrcItemId)
{ {
if(!sItemStorage.LookupEntry<ItemPrototype>(qinfo->SrcItemId)) if (!sItemStorage.LookupEntry<ItemPrototype>(qinfo->SrcItemId))
{ {
sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId);
qinfo->SrcItemId = 0; // quest can't be done for this requirement qinfo->SrcItemId = 0; // quest can't be done for this requirement
} }
else if(qinfo->SrcItemCount==0) else if (qinfo->SrcItemCount==0)
{ {
sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.",
qinfo->GetQuestId(),qinfo->SrcItemId); qinfo->GetQuestId(),qinfo->SrcItemId);
qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
} }
} }
else if(qinfo->SrcItemCount>0) else if (qinfo->SrcItemCount>0)
{ {
sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.",
qinfo->GetQuestId(),qinfo->SrcItemCount); qinfo->GetQuestId(),qinfo->SrcItemCount);
qinfo->SrcItemCount=0; // no quest work changes in fact qinfo->SrcItemCount=0; // no quest work changes in fact
} }
if(qinfo->SrcSpell) if (qinfo->SrcSpell)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell); SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell);
qinfo->SrcSpell = 0; // quest can't be done for this requirement qinfo->SrcSpell = 0; // quest can't be done for this requirement
} }
else if(!SpellMgr::IsSpellValid(spellInfo)) else if (!SpellMgr::IsSpellValid(spellInfo))
{ {
sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.",
qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell);
@ -3630,10 +3630,9 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j ) for(int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j )
{ {
uint32 id = qinfo->ReqItemId[j]; if (uint32 id = qinfo->ReqItemId[j])
if(id)
{ {
if(qinfo->ReqItemCount[j] == 0) if (qinfo->ReqItemCount[j] == 0)
{ {
sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(), j+1, id, j+1); qinfo->GetQuestId(), j+1, id, j+1);
@ -3642,14 +3641,14 @@ void ObjectMgr::LoadQuests()
qinfo->SetFlag(QUEST_MANGOS_FLAGS_DELIVER); qinfo->SetFlag(QUEST_MANGOS_FLAGS_DELIVER);
if(!sItemStorage.LookupEntry<ItemPrototype>(id)) if (!sItemStorage.LookupEntry<ItemPrototype>(id))
{ {
sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(), j+1, id, id); qinfo->GetQuestId(), j+1, id, id);
qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest
} }
} }
else if(qinfo->ReqItemCount[j] > 0) else if (qinfo->ReqItemCount[j] > 0)
{ {
sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.",
qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]); qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]);
@ -3659,10 +3658,9 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j )
{ {
uint32 id = qinfo->ReqSourceId[j]; if (uint32 id = qinfo->ReqSourceId[j])
if(id)
{ {
if(!sItemStorage.LookupEntry<ItemPrototype>(id)) if (!sItemStorage.LookupEntry<ItemPrototype>(id))
{ {
sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,id); qinfo->GetQuestId(),j+1,id,id);
@ -3671,7 +3669,7 @@ void ObjectMgr::LoadQuests()
} }
else else
{ {
if(qinfo->ReqSourceCount[j]>0) if (qinfo->ReqSourceCount[j]>0)
{ {
sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.",
qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]);
@ -3682,18 +3680,17 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j )
{ {
uint32 id = qinfo->ReqSpell[j]; if (uint32 id = qinfo->ReqSpell[j])
if(id)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); SpellEntry const* spellInfo = sSpellStore.LookupEntry(id);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,id); qinfo->GetQuestId(),j+1,id,id);
continue; continue;
} }
if(!qinfo->ReqCreatureOrGOId[j]) if (!qinfo->ReqCreatureOrGOId[j])
{ {
bool found = false; bool found = false;
for(int k = 0; k < MAX_EFFECT_INDEX; ++k) for(int k = 0; k < MAX_EFFECT_INDEX; ++k)
@ -3706,9 +3703,9 @@ void ObjectMgr::LoadQuests()
} }
} }
if(found) if (found)
{ {
if(!qinfo->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) if (!qinfo->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT))
{ {
sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1); sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1);
@ -3729,34 +3726,34 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j )
{ {
int32 id = qinfo->ReqCreatureOrGOId[j]; int32 id = qinfo->ReqCreatureOrGOId[j];
if(id < 0 && !sGOStorage.LookupEntry<GameObjectInfo>(-id)) if (id < 0 && !sGOStorage.LookupEntry<GameObjectInfo>(-id))
{ {
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,uint32(-id)); qinfo->GetQuestId(),j+1,id,uint32(-id));
qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
} }
if(id > 0 && !sCreatureStorage.LookupEntry<CreatureInfo>(id)) if (id > 0 && !sCreatureStorage.LookupEntry<CreatureInfo>(id))
{ {
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,uint32(id)); qinfo->GetQuestId(),j+1,id,uint32(id));
qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
} }
if(id) if (id)
{ {
// In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
qinfo->SetFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO); qinfo->SetFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO);
if(!qinfo->ReqCreatureOrGOCount[j]) if (!qinfo->ReqCreatureOrGOCount[j])
{ {
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(),j+1,id,j+1); qinfo->GetQuestId(),j+1,id,j+1);
// no changes, quest can be incorrectly done, but we already report this // no changes, quest can be incorrectly done, but we already report this
} }
} }
else if(qinfo->ReqCreatureOrGOCount[j]>0) else if (qinfo->ReqCreatureOrGOCount[j]>0)
{ {
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.",
qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]);
@ -3766,24 +3763,23 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j ) for(int j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j )
{ {
uint32 id = qinfo->RewChoiceItemId[j]; if (uint32 id = qinfo->RewChoiceItemId[j])
if(id)
{ {
if(!sItemStorage.LookupEntry<ItemPrototype>(id)) if (!sItemStorage.LookupEntry<ItemPrototype>(id))
{ {
sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
qinfo->GetQuestId(),j+1,id,id); qinfo->GetQuestId(),j+1,id,id);
qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this
} }
if(!qinfo->RewChoiceItemCount[j]) if (!qinfo->RewChoiceItemCount[j])
{ {
sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(),j+1,id,j+1); qinfo->GetQuestId(),j+1,id,j+1);
// no changes, quest can't be done // no changes, quest can't be done
} }
} }
else if(qinfo->RewChoiceItemCount[j]>0) else if (qinfo->RewChoiceItemCount[j]>0)
{ {
sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.",
qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]);
@ -3793,24 +3789,23 @@ void ObjectMgr::LoadQuests()
for(int j = 0; j < QUEST_REWARDS_COUNT; ++j ) for(int j = 0; j < QUEST_REWARDS_COUNT; ++j )
{ {
uint32 id = qinfo->RewItemId[j]; if (uint32 id = qinfo->RewItemId[j])
if(id)
{ {
if(!sItemStorage.LookupEntry<ItemPrototype>(id)) if (!sItemStorage.LookupEntry<ItemPrototype>(id))
{ {
sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
qinfo->GetQuestId(),j+1,id,id); qinfo->GetQuestId(),j+1,id,id);
qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item
} }
if(!qinfo->RewItemCount[j]) if (!qinfo->RewItemCount[j])
{ {
sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.",
qinfo->GetQuestId(),j+1,id,j+1); qinfo->GetQuestId(),j+1,id,j+1);
// no changes // no changes
} }
} }
else if(qinfo->RewItemCount[j]>0) else if (qinfo->RewItemCount[j]>0)
{ {
sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.",
qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]);
@ -3840,23 +3835,23 @@ void ObjectMgr::LoadQuests()
} }
} }
if(qinfo->RewSpell) if (qinfo->RewSpell)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell); SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.",
qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell);
qinfo->RewSpell = 0; // no spell reward will display for this quest qinfo->RewSpell = 0; // no spell reward will display for this quest
} }
else if(!SpellMgr::IsSpellValid(spellInfo)) else if (!SpellMgr::IsSpellValid(spellInfo))
{ {
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.", sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell);
qinfo->RewSpell = 0; // no spell reward will display for this quest qinfo->RewSpell = 0; // no spell reward will display for this quest
} }
else if(GetTalentSpellCost(qinfo->RewSpell)) else if (GetTalentSpellCost(qinfo->RewSpell))
{ {
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell);
@ -3864,23 +3859,23 @@ void ObjectMgr::LoadQuests()
} }
} }
if(qinfo->RewSpellCast) if (qinfo->RewSpellCast)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast); SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast);
qinfo->RewSpellCast = 0; // no spell will be casted on player qinfo->RewSpellCast = 0; // no spell will be casted on player
} }
else if(!SpellMgr::IsSpellValid(spellInfo)) else if (!SpellMgr::IsSpellValid(spellInfo))
{ {
sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.", sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast);
qinfo->RewSpellCast = 0; // no spell will be casted on player qinfo->RewSpellCast = 0; // no spell will be casted on player
} }
else if(GetTalentSpellCost(qinfo->RewSpellCast)) else if (GetTalentSpellCost(qinfo->RewSpellCast))
{ {
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast);
@ -3935,7 +3930,7 @@ void ObjectMgr::LoadQuests()
} }
} }
if(qinfo->NextQuestId) if (qinfo->NextQuestId)
{ {
QuestMap::iterator qNextItr = mQuestTemplates.find(abs(qinfo->GetNextQuestId())); QuestMap::iterator qNextItr = mQuestTemplates.find(abs(qinfo->GetNextQuestId()));
if (qNextItr == mQuestTemplates.end()) if (qNextItr == mQuestTemplates.end())
@ -3949,9 +3944,9 @@ void ObjectMgr::LoadQuests()
} }
} }
if(qinfo->ExclusiveGroup) if (qinfo->ExclusiveGroup)
mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId())); mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
if(qinfo->LimitTime) if (qinfo->LimitTime)
qinfo->SetFlag(QUEST_MANGOS_FLAGS_TIMED); qinfo->SetFlag(QUEST_MANGOS_FLAGS_TIMED);
} }
@ -3959,12 +3954,12 @@ void ObjectMgr::LoadQuests()
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
{ {
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); SpellEntry const *spellInfo = sSpellStore.LookupEntry(i);
if(!spellInfo) if (!spellInfo)
continue; continue;
for(int j = 0; j < MAX_EFFECT_INDEX; ++j) for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if(spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) if (spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE)
continue; continue;
uint32 quest_id = spellInfo->EffectMiscValue[j]; uint32 quest_id = spellInfo->EffectMiscValue[j];
@ -3972,10 +3967,10 @@ void ObjectMgr::LoadQuests()
Quest const* quest = GetQuestTemplate(quest_id); Quest const* quest = GetQuestTemplate(quest_id);
// some quest referenced in spells not exist (outdated spells) // some quest referenced in spells not exist (outdated spells)
if(!quest) if (!quest)
continue; continue;
if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) if (!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT))
{ {
sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE for quest %u , but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.",spellInfo->Id,quest_id); sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE for quest %u , but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.",spellInfo->Id,quest_id);

View file

@ -1138,7 +1138,7 @@ void Player::Update( uint32 p_time )
if (!m_timedquests.empty()) if (!m_timedquests.empty())
{ {
std::set<uint32>::iterator iter = m_timedquests.begin(); QuestSet::iterator iter = m_timedquests.begin();
while (iter != m_timedquests.end()) while (iter != m_timedquests.end())
{ {
QuestStatusData& q_status = mQuestStatus[*iter]; QuestStatusData& q_status = mQuestStatus[*iter];
@ -13106,15 +13106,15 @@ bool Player::CanCompleteRepeatableQuest( Quest const *pQuest )
bool Player::CanRewardQuest( Quest const *pQuest, bool msg ) bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
{ {
// not auto complete quest and not completed quest (only cheating case, then ignore without message) // not auto complete quest and not completed quest (only cheating case, then ignore without message)
if(!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE) if (!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE)
return false; return false;
// daily quest can't be rewarded (25 daily quest already completed) // daily quest can't be rewarded (25 daily quest already completed)
if(!SatisfyQuestDay(pQuest,true)) if (!SatisfyQuestDay(pQuest,true))
return false; return false;
// rewarded and not repeatable quest (only cheating case, then ignore without message) // rewarded and not repeatable quest (only cheating case, then ignore without message)
if(GetQuestRewardStatus(pQuest->GetQuestId())) if (GetQuestRewardStatus(pQuest->GetQuestId()))
return false; return false;
// prevent receive reward with quest items in bank // prevent receive reward with quest items in bank
@ -13133,7 +13133,7 @@ bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
} }
// prevent receive reward with low money and GetRewOrReqMoney() < 0 // prevent receive reward with low money and GetRewOrReqMoney() < 0
if(pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()) ) if (pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()) )
return false; return false;
return true; return true;
@ -13710,7 +13710,7 @@ bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg)
bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
{ {
// non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed // non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed
if(qInfo->GetExclusiveGroup() <= 0) if (qInfo->GetExclusiveGroup() <= 0)
return true; return true;
ObjectMgr::ExclusiveQuestGroups::const_iterator iter = sObjectMgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::const_iterator iter = sObjectMgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup());
@ -13723,12 +13723,12 @@ bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
uint32 exclude_Id = iter->second; uint32 exclude_Id = iter->second;
// skip checked quest id, only state of other quests in group is interesting // skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == qInfo->GetQuestId()) if (exclude_Id == qInfo->GetQuestId())
continue; continue;
// not allow have daily quest if daily quest from exclusive group already recently completed // not allow have daily quest if daily quest from exclusive group already recently completed
Quest const* Nquest = sObjectMgr.GetQuestTemplate(exclude_Id); Quest const* Nquest = sObjectMgr.GetQuestTemplate(exclude_Id);
if( !SatisfyQuestDay(Nquest, false) ) if (!SatisfyQuestDay(Nquest, false))
{ {
if( msg ) if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@ -13738,8 +13738,8 @@ bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id );
// alternative quest already started or completed // alternative quest already started or completed
if( i_exstatus != mQuestStatus.end() if (i_exstatus != mQuestStatus.end()
&& (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE) ) && (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE))
{ {
if( msg ) if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@ -13806,21 +13806,21 @@ bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg ) bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg )
{ {
if(!qInfo->IsDaily()) if (!qInfo->IsDaily())
return true; return true;
bool have_slot = false; bool have_slot = false;
for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
{ {
uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx);
if(qInfo->GetQuestId()==id) if (qInfo->GetQuestId()==id)
return false; return false;
if(!id) if(!id)
have_slot = true; have_slot = true;
} }
if(!have_slot) if (!have_slot)
{ {
if( msg ) if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DAILY_QUESTS_REMAINING ); SendCanTakeQuestResponse( INVALIDREASON_DAILY_QUESTS_REMAINING );
@ -13833,7 +13833,7 @@ bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg )
bool Player::GiveQuestSourceItem( Quest const *pQuest ) bool Player::GiveQuestSourceItem( Quest const *pQuest )
{ {
uint32 srcitem = pQuest->GetSrcItemId(); uint32 srcitem = pQuest->GetSrcItemId();
if( srcitem > 0 ) if (srcitem > 0)
{ {
uint32 count = pQuest->GetSrcItemCount(); uint32 count = pQuest->GetSrcItemCount();
if( count <= 0 ) if( count <= 0 )
@ -13841,14 +13841,14 @@ bool Player::GiveQuestSourceItem( Quest const *pQuest )
ItemPosCountVec dest; ItemPosCountVec dest;
uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count );
if( msg == EQUIP_ERR_OK ) if (msg == EQUIP_ERR_OK)
{ {
Item * item = StoreNewItem(dest, srcitem, true); Item * item = StoreNewItem(dest, srcitem, true);
SendNewItem(item, count, true, false); SendNewItem(item, count, true, false);
return true; return true;
} }
// player already have max amount required item, just report success // player already have max amount required item, just report success
else if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS)
return true; return true;
else else
SendEquipError( msg, NULL, NULL, srcitem ); SendEquipError( msg, NULL, NULL, srcitem );
@ -16493,7 +16493,7 @@ void Player::SaveToDB()
CharacterDatabase.Execute( ss.str().c_str() ); CharacterDatabase.Execute( ss.str().c_str() );
if(m_mailsUpdated) //save mails only when needed if (m_mailsUpdated) //save mails only when needed
_SaveMail(); _SaveMail();
_SaveBGData(); _SaveBGData();
@ -16516,11 +16516,11 @@ void Player::SaveToDB()
// check if stats should only be saved on logout // check if stats should only be saved on logout
// save stats can be out of transaction // save stats can be out of transaction
if(m_session->isLogingOut() || !sWorld.getConfig(CONFIG_BOOL_STATS_SAVE_ONLY_ON_LOGOUT)) if (m_session->isLogingOut() || !sWorld.getConfig(CONFIG_BOOL_STATS_SAVE_ONLY_ON_LOGOUT))
_SaveStats(); _SaveStats();
// save pet (hunter pet level and experience and all type pets health/mana). // save pet (hunter pet level and experience and all type pets health/mana).
if(Pet* pet = GetPet()) if (Pet* pet = GetPet())
pet->SavePetToDB(PET_SAVE_AS_CURRENT); pet->SavePetToDB(PET_SAVE_AS_CURRENT);
} }
@ -16803,7 +16803,7 @@ void Player::_SaveQuestStatus()
void Player::_SaveDailyQuestStatus() void Player::_SaveDailyQuestStatus()
{ {
if(!m_DailyQuestChanged) if (!m_DailyQuestChanged)
return; return;
m_DailyQuestChanged = false; m_DailyQuestChanged = false;
@ -16813,7 +16813,7 @@ void Player::_SaveDailyQuestStatus()
// we don't need transactions here. // we don't need transactions here.
CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",GetGUIDLow()); 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) 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)) if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" UI64FMTD "')", 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)); GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
} }

View file

@ -2312,7 +2312,8 @@ class MANGOS_DLL_SPEC Player : public Unit
/*********************************************************/ /*********************************************************/
//We allow only one timed quest active at the same time. Below can then be simple value instead of set. //We allow only one timed quest active at the same time. Below can then be simple value instead of set.
std::set<uint32> m_timedquests; typedef std::set<uint32> QuestSet;
QuestSet m_timedquests;
uint64 m_divider; uint64 m_divider;
uint32 m_ingametime; uint32 m_ingametime;

View file

@ -1329,15 +1329,18 @@ void World::Update(uint32 diff)
{ {
///- Update the different timers ///- Update the different timers
for(int i = 0; i < WUPDATE_COUNT; ++i) for(int i = 0; i < WUPDATE_COUNT; ++i)
if(m_timers[i].GetCurrent()>=0) {
if (m_timers[i].GetCurrent()>=0)
m_timers[i].Update(diff); m_timers[i].Update(diff);
else m_timers[i].SetCurrent(0); else
m_timers[i].SetCurrent(0);
}
///- Update the game time and check for shutdown time ///- Update the game time and check for shutdown time
_UpdateGameTime(); _UpdateGameTime();
/// Handle daily quests reset time /// Handle daily quests reset time
if(m_gameTime > m_NextDailyQuestReset) if (m_gameTime > m_NextDailyQuestReset)
{ {
ResetDailyQuests(); ResetDailyQuests();
m_NextDailyQuestReset += DAY; m_NextDailyQuestReset += DAY;
@ -1915,13 +1918,13 @@ void World::ResetDailyQuests()
sLog.outDetail("Daily quests reset for all characters."); sLog.outDetail("Daily quests reset for all characters.");
CharacterDatabase.Execute("DELETE FROM character_queststatus_daily"); CharacterDatabase.Execute("DELETE FROM character_queststatus_daily");
for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if(itr->second->GetPlayer()) if (itr->second->GetPlayer())
itr->second->GetPlayer()->ResetDailyQuestStatus(); itr->second->GetPlayer()->ResetDailyQuestStatus();
} }
void World::SetPlayerLimit( int32 limit, bool needUpdate ) void World::SetPlayerLimit( int32 limit, bool needUpdate )
{ {
if(limit < -SEC_ADMINISTRATOR) if (limit < -SEC_ADMINISTRATOR)
limit = -SEC_ADMINISTRATOR; limit = -SEC_ADMINISTRATOR;
// lock update need // lock update need
@ -1929,7 +1932,7 @@ void World::SetPlayerLimit( int32 limit, bool needUpdate )
m_playerLimit = limit; m_playerLimit = limit;
if(db_update_need) if (db_update_need)
loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID);
} }

View file

@ -164,6 +164,7 @@ enum TimeConstants
MINUTE = 60, MINUTE = 60,
HOUR = MINUTE*60, HOUR = MINUTE*60,
DAY = HOUR*24, DAY = HOUR*24,
WEEK = DAY*7,
MONTH = DAY*30, MONTH = DAY*30,
YEAR = MONTH*12, YEAR = MONTH*12,
IN_MILLISECONDS = 1000 IN_MILLISECONDS = 1000

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9684" #define REVISION_NR "9685"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__