aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp452
-rw-r--r--src/server/game/Conditions/ConditionMgr.h19
2 files changed, 249 insertions, 222 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 094a8345395..081e91546ee 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -29,6 +29,79 @@
#include "SpellMgr.h"
#include "Spell.h"
+char const* ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] =
+{
+ "None",
+ "Creature Loot",
+ "Disenchant Loot",
+ "Fishing Loot",
+ "GameObject Loot",
+ "Item Loot",
+ "Mail Loot",
+ "Milling Loot",
+ "Pickpocketing Loot",
+ "Prospecting Loot",
+ "Reference Loot",
+ "Skinning Loot",
+ "Spell Loot",
+ "Spell Impl. Target",
+ "Gossip Menu",
+ "Gossip Menu Option",
+ "Creature Vehicle",
+ "Spell Expl. Target",
+ "Spell Click Event",
+ "Quest Accept",
+ "Quest Show Mark",
+ "Vehicle Spell",
+ "SmartScript",
+ "Npc Vendor",
+ "Spell Proc",
+ "Phase Def"
+};
+
+ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
+{
+ { "None", false, false, false },
+ { "Aura", true, true, true },
+ { "Item Stored", true, true, true },
+ { "Item Equipped", true, false, false },
+ { "Zone", true, false, false },
+ { "Reputation", true, true, false },
+ { "Team", true, false, false },
+ { "Skill", true, true, false },
+ { "Quest Rewarded", true, false, false },
+ { "Quest Taken", true, false, false },
+ { "Drunken", true, false, false },
+ { "WorldState", true, true, false },
+ { "Active Event", true, false, false },
+ { "Instance Info", true, true, true },
+ { "Quest None", true, false, false },
+ { "Class", true, false, false },
+ { "Race", true, false, false },
+ { "Achievement", true, false, false },
+ { "Title", true, false, false },
+ { "SpawnMask", true, false, false },
+ { "Gender", true, false, false },
+ { "Unit State", true, false, false },
+ { "Map", true, false, false },
+ { "Area", true, false, false },
+ { "CreatureType", true, false, false },
+ { "Spell Known", true, false, false },
+ { "PhaseMask", true, false, false },
+ { "Level", true, true, false },
+ { "Quest Completed", true, false, false },
+ { "Near Creature", true, true, false },
+ { "Near GameObject", true, true, false },
+ { "Object Entry or Guid", true, true, true },
+ { "Object TypeMask", true, false, false },
+ { "Relation", true, true, false },
+ { "Reaction", true, true, false },
+ { "Distance", true, true, true },
+ { "Alive", false, false, false },
+ { "Health Value", true, true, false },
+ { "Health Pct", true, true, false }
+};
+
// Checks if object meets the condition
// Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI)
bool Condition::Meets(ConditionSourceInfo& sourceInfo)
@@ -38,7 +111,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
// object not present, return false
if (!object)
{
- TC_LOG_DEBUG("condition", "Condition object not found for condition (Entry: %u Type: %u Group: %u)", SourceEntry, SourceType, SourceGroup);
+ TC_LOG_DEBUG("condition", "Condition object not found for %s", ToString().c_str());
return false;
}
bool condMeets = false;
@@ -535,6 +608,34 @@ uint32 Condition::GetMaxAvailableConditionTargets()
}
}
+std::string Condition::ToString(bool ext /*= false*/) const
+{
+ std::ostringstream ss;
+ ss << "[Condition ";
+ ss << "SourceType: " << SourceType;
+ if (SourceType < CONDITION_SOURCE_TYPE_MAX)
+ ss << " (" << ConditionMgr::StaticSourceTypeData[SourceType] << ")";
+ else
+ ss << " (Unknown)";
+ if (ConditionMgr::CanHaveSourceGroupSet(SourceType))
+ ss << ", SourceGroup: " << SourceGroup;
+ ss << ", SourceEntry: " << SourceEntry;
+ if (ConditionMgr::CanHaveSourceIdSet(SourceType))
+ ss << ", SourceId: " << SourceId;
+
+ if (ext)
+ {
+ ss << ", ConditionType: " << ConditionType;
+ if (ConditionType < CONDITION_MAX)
+ ss << " (" << ConditionMgr::StaticConditionTypeData[ConditionType].Name << ")";
+ else
+ ss << " (Unknown)";
+ }
+
+ ss << "]";
+ return ss.str();
+}
+
ConditionMgr::ConditionMgr() { }
ConditionMgr::~ConditionMgr()
@@ -597,7 +698,7 @@ bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo,
std::map<uint32, bool> ElseGroupStore;
for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
{
- TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->ConditionType, (*i)->ConditionValue1);
+ TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", (*i)->ToString().c_str(), (*i)->ConditionValue1);
if ((*i)->isLoaded())
{
//! Find ElseGroup in ElseGroupStore
@@ -618,8 +719,8 @@ bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo,
}
else
{
- TC_LOG_DEBUG("condition", "IsPlayerMeetToConditionList: Reference template -%u not found",
- (*i)->ReferenceId);//checked at loading, should never happen
+ TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s Reference template -%u not found",
+ (*i)->ToString().c_str(), (*i)->ReferenceId); // checked at loading, should never happen
}
}
@@ -658,7 +759,7 @@ bool ConditionMgr::IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, Con
return IsObjectMeetToConditionList(sourceInfo, conditions);
}
-bool ConditionMgr::CanHaveSourceGroupSet(ConditionSourceType sourceType) const
+bool ConditionMgr::CanHaveSourceGroupSet(ConditionSourceType sourceType)
{
return (sourceType == CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE ||
sourceType == CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE ||
@@ -681,7 +782,7 @@ bool ConditionMgr::CanHaveSourceGroupSet(ConditionSourceType sourceType) const
sourceType == CONDITION_SOURCE_TYPE_NPC_VENDOR);
}
-bool ConditionMgr::CanHaveSourceIdSet(ConditionSourceType sourceType) const
+bool ConditionMgr::CanHaveSourceIdSet(ConditionSourceType sourceType)
{
return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
}
@@ -715,7 +816,7 @@ ConditionList ConditionMgr::GetConditionsForSpellClickEvent(uint32 creatureId, u
if (i != (*itr).second.end())
{
cond = (*i).second;
- TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry %u spell %u", creatureId, spellId);
+ TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId);
}
}
return cond;
@@ -747,7 +848,7 @@ ConditionList ConditionMgr::GetConditionsForSmartEvent(int32 entryOrGuid, uint32
if (i != (*itr).second.end())
{
cond = (*i).second;
- TC_LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid %d event_id %u", entryOrGuid, eventId);
+ TC_LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid %d eventId %u", entryOrGuid, eventId);
}
}
return cond;
@@ -895,26 +996,26 @@ void ConditionMgr::LoadConditions(bool isReload)
//Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
{
- TC_LOG_ERROR("sql.sql", "Condition type %u has not allowed value of SourceGroup = %u!", uint32(cond->SourceType), cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s has not allowed value of SourceGroup = %u!", cond->ToString().c_str(), cond->SourceGroup);
delete cond;
continue;
}
if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
{
- TC_LOG_ERROR("sql.sql", "Condition type %u has not allowed value of SourceId = %u!", uint32(cond->SourceType), cond->SourceId);
+ TC_LOG_ERROR("sql.sql", "%s has not allowed value of SourceId = %u!", cond->ToString().c_str(), cond->SourceId);
delete cond;
continue;
}
if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
{
- TC_LOG_ERROR("sql.sql", "Condition type %u entry %i can't have ErrorType (%u), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
+ TC_LOG_ERROR("sql.sql", "%s can't have ErrorType (%u), set to 0!", cond->ToString().c_str(), cond->ErrorType);
cond->ErrorType = 0;
}
if (cond->ErrorTextId && !cond->ErrorType)
{
- TC_LOG_ERROR("sql.sql", "Condition type %u entry %i has any ErrorType, ErrorTextId (%u) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
+ TC_LOG_ERROR("sql.sql", "%s has any ErrorType, ErrorTextId (%u) is set, set to 0!", cond->ToString().c_str(), cond->ErrorTextId);
cond->ErrorTextId = 0;
}
@@ -1005,7 +1106,7 @@ void ConditionMgr::LoadConditions(bool isReload)
if (!valid)
{
- TC_LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup %u", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s Not handled grouped condition.", cond->ToString().c_str());
delete cond;
}
else
@@ -1038,21 +1139,20 @@ void ConditionMgr::LoadConditions(bool isReload)
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
-
}
bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot)
{
if (!loot)
{
- TC_LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate %u not found", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s LootTemplate %u not found.", cond->ToString().c_str(), cond->SourceGroup);
return false;
}
if (loot->addConditionItem(cond))
return true;
- TC_LOG_ERROR("sql.sql", "ConditionMgr: Item %u not found in LootTemplate %u", cond->SourceEntry, cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s Item %u not found in LootTemplate %u.", cond->ToString().c_str(), cond->SourceEntry, cond->SourceGroup);
return false;
}
@@ -1072,7 +1172,7 @@ bool ConditionMgr::addToGossipMenus(Condition* cond)
}
}
- TC_LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu %u not found", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s GossipMenu %u not found.", cond->ToString().c_str(), cond->SourceGroup);
return false;
}
@@ -1091,7 +1191,7 @@ bool ConditionMgr::addToGossipMenuItems(Condition* cond)
}
}
- TC_LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId %u Item %u not found", cond->SourceGroup, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s GossipMenuId %u Item %u not found.", cond->ToString().c_str(), cond->SourceGroup, cond->SourceEntry);
return false;
}
@@ -1116,12 +1216,12 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
continue;
// build new shared mask with found effect
- uint32 sharedMask = (1<<i);
+ uint32 sharedMask = (1 << i);
ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
for (uint8 effIndex = i+1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
- sharedMask |= 1<<effIndex;
+ sharedMask |= 1 << effIndex;
}
sharedMasks.push_back(sharedMask);
}
@@ -1148,8 +1248,8 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
// we have overlapping masks in db
if (conditionEffMask != *itr)
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, has incorrect SourceGroup %u (spell effectMask) set - "
- "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.", cond->SourceEntry, cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect SourceGroup %u (spell effectMask) set - "
+ "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.", cond->ToString().c_str(), cond->SourceGroup);
return false;
}
}
@@ -1182,7 +1282,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (cond->SourceType == CONDITION_SOURCE_TYPE_NONE || cond->SourceType >= CONDITION_SOURCE_TYPE_MAX)
{
- TC_LOG_ERROR("sql.sql", "Invalid ConditionSourceType %u in `condition` table, ignoring.", uint32(cond->SourceType));
+ TC_LOG_ERROR("sql.sql", "%s Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1192,7 +1292,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Creature.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1200,7 +1300,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1209,7 +1309,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Disenchant.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1217,7 +1317,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1226,7 +1326,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Fishing.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1234,7 +1334,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1243,7 +1343,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Gameobject.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1251,7 +1351,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1260,7 +1360,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Item.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1268,7 +1368,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1277,7 +1377,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Mail.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1285,7 +1385,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1294,7 +1394,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Milling.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1302,7 +1402,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1311,7 +1411,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Pickpocketing.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1319,7 +1419,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1328,7 +1428,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Prospecting.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1336,7 +1436,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1345,7 +1445,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Reference.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1353,7 +1453,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1362,7 +1462,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Skinning.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1370,7 +1470,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1379,7 +1479,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!LootTemplates_Spell.HaveLootFor(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceGroup %u in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1387,7 +1487,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!pItemProto && !loot->isReference(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1397,13 +1497,13 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
if (!spellInfo)
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
return false;
}
if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, has incorrect SourceGroup %u (spell effectMask) set, ignoring.", cond->SourceEntry, cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, has incorrect SourceGroup %u (spell effectMask) set, ignoring.", cond->ToString().c_str());
return false;
}
@@ -1435,7 +1535,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
}
TC_LOG_ERROR("sql.sql", "SourceEntry %u SourceGroup %u in `condition` table - spell %u does not have implicit targets of types: _AREA_, _CONE_, _NEARBY_ for effect %u, SourceGroup needs correction, ignoring.", cond->SourceEntry, origGroup, cond->SourceEntry, uint32(i));
- cond->SourceGroup &= ~(1<<i);
+ cond->SourceGroup &= ~(1 << i);
}
// all effects were removed, no need to add the condition at all
if (!cond->SourceGroup)
@@ -1446,7 +1546,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1457,7 +1557,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
if (!spellProto)
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1465,40 +1565,40 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_ACCEPT specifies non-existing quest (%u), skipped", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s specifies non-existing quest (%u), skipped.", cond->ToString().c_str());
return false;
}
break;
case CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK:
if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK specifies non-existing quest (%u), skipped", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s specifies non-existing quest (%u), skipped.", cond->ToString().c_str());
return false;
}
break;
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
return false;
}
if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
return false;
}
break;
case CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT:
if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
return false;
}
if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1506,13 +1606,13 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
{
if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
return false;
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
if (!itemTemplate)
{
- TC_LOG_ERROR("sql.sql", "SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
@@ -1537,13 +1637,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (cond->ConditionType == CONDITION_NONE || cond->ConditionType >= CONDITION_MAX)
{
- TC_LOG_ERROR("sql.sql", "Invalid ConditionType %u at SourceEntry %u in `condition` table, ignoring.", uint32(cond->ConditionType), cond->SourceEntry);
+ TC_LOG_ERROR("sql.sql", "%s Invalid ConditionType in `condition` table, ignoring.", cond->ToString().c_str());
return false;
}
if (cond->ConditionTarget >= cond->GetMaxAvailableConditionTargets())
{
- TC_LOG_ERROR("sql.sql", "SourceType %u, SourceEntry %u, SourceGroup %u in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry, cond->SourceGroup);
+ TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->ToString(true).c_str());
return false;
}
@@ -1553,17 +1653,15 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "Aura condition has non existing spell (Id: %d), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing spell (Id: %d), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue2 > EFFECT_2)
{
- TC_LOG_ERROR("sql.sql", "Aura condition has non existing effect index (%u) (must be 0..2), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has non existing effect index (%u) (must be 0..2), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Aura condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_ITEM:
@@ -1571,13 +1669,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
if (!proto)
{
- TC_LOG_ERROR("sql.sql", "Item condition has non existing item (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s Item (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (!cond->ConditionValue2)
{
- TC_LOG_ERROR("sql.sql", "Item condition has 0 set for item count in value2 (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s Zero item count in ConditionValue2, skipped.", cond->ToString(true).c_str());
return false;
}
break;
@@ -1587,14 +1685,9 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
if (!proto)
{
- TC_LOG_ERROR("sql.sql", "ItemEquipped condition has non existing item (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s Item (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_ZONEID:
@@ -1602,20 +1695,15 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(cond->ConditionValue1);
if (!areaEntry)
{
- TC_LOG_ERROR("sql.sql", "ZoneID condition has non existing area (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s Area (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (areaEntry->zone != 0)
{
- TC_LOG_ERROR("sql.sql", "ZoneID condition requires to be in area (%u) which is a subzone but zone expected, skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s requires to be in area (%u) which is a subzone but zone expected, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "ZoneID condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "ZoneID condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_REPUTATION_RANK:
@@ -1623,25 +1711,18 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
if (!factionEntry)
{
- TC_LOG_ERROR("sql.sql", "Reputation condition has non existing faction (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing faction (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Reputation condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_TEAM:
{
if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
{
- TC_LOG_ERROR("sql.sql", "Team condition specifies unknown team (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s specifies unknown team (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Team condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Team condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_SKILL:
@@ -1649,17 +1730,15 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
if (!pSkill)
{
- TC_LOG_ERROR("sql.sql", "Skill condition specifies non-existing skill (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s specifies non-existing skill (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
{
- TC_LOG_ERROR("sql.sql", "Skill condition specifies skill (%u) with invalid value (%u), skipped", cond->ConditionValue1, cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s specifies skill (%u) with invalid value (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1, cond->ConditionValue2);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Skill condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_QUESTREWARDED:
@@ -1669,30 +1748,19 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "Quest condition (Type: %u) points to non-existing quest (%u) for Source Entry %u. SourceGroup: %u, SourceTypeOrReferenceId: %u",
- cond->ConditionType, cond->ConditionValue1, cond->SourceEntry, cond->SourceGroup, cond->SourceType);
+ TC_LOG_ERROR("sql.sql", "%s points to non-existing quest (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2 > 1)
- TC_LOG_ERROR("sql.sql", "Quest condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Quest condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_ACTIVE_EVENT:
{
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
- if (cond->ConditionValue1 >=events.size() || !events[cond->ConditionValue1].isValid())
+ if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
{
- TC_LOG_ERROR("sql.sql", "ActiveEvent condition has non existing event id (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing event id (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_ACHIEVEMENT:
@@ -1700,56 +1768,36 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
AchievementEntry const* achievement = sAchievementMgr->GetAchievement(cond->ConditionValue1);
if (!achievement)
{
- TC_LOG_ERROR("sql.sql", "Achivement condition has non existing achivement id (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing achivement id (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Achivement condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Achivement condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_CLASS:
{
if (!(cond->ConditionValue1 & CLASSMASK_ALL_PLAYABLE))
{
- TC_LOG_ERROR("sql.sql", "Class condition has non existing classmask (%u), skipped", cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
+ TC_LOG_ERROR("sql.sql", "%s has non existing classmask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Class condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Class condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_RACE:
{
if (!(cond->ConditionValue1 & RACEMASK_ALL_PLAYABLE))
{
- TC_LOG_ERROR("sql.sql", "Race condition has non existing racemask (%u), skipped", cond->ConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
+ TC_LOG_ERROR("sql.sql", "%s has non existing racemask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Race condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Race condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_GENDER:
{
if (!Player::IsValidGender(uint8(cond->ConditionValue1)))
{
- TC_LOG_ERROR("sql.sql", "Gender condition has invalid gender (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has invalid gender (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Gender condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Gender condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_MAPID:
@@ -1757,77 +1805,54 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
MapEntry const* me = sMapStore.LookupEntry(cond->ConditionValue1);
if (!me)
{
- TC_LOG_ERROR("sql.sql", "Map condition has non existing map (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing map (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Map condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Map condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_SPELL:
{
if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "Spell condition has non existing spell (Id: %d), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing spell (Id: %d), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
-
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Spell condition has useless data (spell Id: %d) in value2 (%u)!", cond->ConditionValue1, cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Spell condition has useless data (spell Id: %d) in value3 (%u)!", cond->ConditionValue1, cond->ConditionValue3);
break;
}
case CONDITION_LEVEL:
{
if (cond->ConditionValue2 >= COMP_TYPE_MAX)
{
- TC_LOG_ERROR("sql.sql", "Level condition has invalid ComparisionType (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Level condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_DRUNKENSTATE:
{
if (cond->ConditionValue1 > DRUNKEN_SMASHED)
{
- TC_LOG_ERROR("sql.sql", "DrunkState condition has invalid state (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has invalid state (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
- if (cond->ConditionValue2)
- {
- TC_LOG_ERROR("sql.sql", "DrunkState condition has useless data in value2 (%u)!", cond->ConditionValue2);
- return false;
- }
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "DrunkState condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_NEAR_CREATURE:
{
if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "NearCreature condition has non existing creature template entry (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing creature template entry (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "NearCreature condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_NEAR_GAMEOBJECT:
{
if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "NearGameObject condition has non existing gameobject template entry (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing gameobject template entry (%u), skipped.", cond->ToString().c_str(), cond->ConditionValue1);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "NearGameObject condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_OBJECT_ENTRY_GUID:
@@ -1837,7 +1862,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
case TYPEID_UNIT:
if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has non existing creature template entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
if (cond->ConditionValue3)
@@ -1846,13 +1871,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (cond->ConditionValue2 && creatureData->id != cond->ConditionValue2)
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match creature entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has guid %u set but does not match creature entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3, cond->ConditionValue2);
return false;
}
}
else
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid (%u), skipped", cond->ConditionValue3);
+ TC_LOG_ERROR("sql.sql", "%s has non existing creature guid (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
return false;
}
}
@@ -1860,7 +1885,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
case TYPEID_GAMEOBJECT:
if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has non existing gameobject template entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
if (cond->ConditionValue3)
@@ -1869,13 +1894,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match gameobject entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has guid %u set but does not match gameobject entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3, cond->ConditionValue2);
return false;
}
}
else
{
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid (%u), skipped", cond->ConditionValue3);
+ TC_LOG_ERROR("sql.sql", "%s has non existing gameobject guid (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
return false;
}
}
@@ -1883,12 +1908,12 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
case TYPEID_PLAYER:
case TYPEID_CORPSE:
if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 (%u)!", cond->ConditionValue2);
+ LogUselessConditionValue(cond, 2, cond->ConditionValue2);
if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 (%u)!", cond->ConditionValue3);
+ LogUselessConditionValue(cond, 3, cond->ConditionValue3);
break;
default:
- TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has wrong typeid set (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
break;
@@ -1897,51 +1922,45 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (!cond->ConditionValue1 || (cond->ConditionValue1 & ~(TYPEMASK_UNIT | TYPEMASK_PLAYER | TYPEMASK_GAMEOBJECT | TYPEMASK_CORPSE)))
{
- TC_LOG_ERROR("sql.sql", "TypeMask condition has invalid typemask set (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid typemask set (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "TypeMask condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "TypeMask condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_RELATION_TO:
{
if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
{
- TC_LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue1(ConditionTarget selection) (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue1 == cond->ConditionTarget)
{
- TC_LOG_ERROR("sql.sql", "RelationTo condition has ConditionValue1(ConditionTarget selection) set to self (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue2 >= RELATION_MAX)
{
- TC_LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue2(RelationType) (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue2(RelationType) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "RelationTo condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_REACTION_TO:
{
if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
{
- TC_LOG_ERROR("sql.sql", "ReactionTo condition has invalid ConditionValue1(ConditionTarget selection) (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue1 == cond->ConditionTarget)
{
- TC_LOG_ERROR("sql.sql", "ReactionTo condition has ConditionValue1(ConditionTarget selection) set to self (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (!cond->ConditionValue2)
{
- TC_LOG_ERROR("sql.sql", "mConditionValue2 condition has invalid ConditionValue2(rankMask) (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue2(rankMask) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
break;
@@ -1950,78 +1969,55 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
{
- TC_LOG_ERROR("sql.sql", "DistanceTo condition has invalid ConditionValue1(ConditionTarget selection) (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue1 == cond->ConditionTarget)
{
- TC_LOG_ERROR("sql.sql", "DistanceTo condition has ConditionValue1(ConditionTarget selection) set to self (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue3 >= COMP_TYPE_MAX)
{
- TC_LOG_ERROR("sql.sql", "DistanceTo condition has invalid ComparisionType (%u), skipped", cond->ConditionValue3);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
return false;
}
break;
}
- case CONDITION_ALIVE:
- {
- if (cond->ConditionValue1)
- TC_LOG_ERROR("sql.sql", "Alive condition has useless data in value1 (%u)!", cond->ConditionValue1);
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Alive condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Alive condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
case CONDITION_HP_VAL:
{
if (cond->ConditionValue2 >= COMP_TYPE_MAX)
{
- TC_LOG_ERROR("sql.sql", "HpVal condition has invalid ComparisionType (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "HpVal condition has useless data in value3 (%u)!", cond->ConditionValue3);
+ TC_LOG_ERROR("sql.sql", "%s has useless data in value3 (%u)!", cond->ToString(true).c_str(), cond->ConditionValue3);
break;
}
case CONDITION_HP_PCT:
{
if (cond->ConditionValue1 > 100)
{
- TC_LOG_ERROR("sql.sql", "HpPct condition has too big percent value (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has too big percent value (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
if (cond->ConditionValue2 >= COMP_TYPE_MAX)
{
- TC_LOG_ERROR("sql.sql", "HpPct condition has invalid ComparisionType (%u), skipped", cond->ConditionValue2);
+ TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "HpPct condition has useless data in value3 (%u)!", cond->ConditionValue3);
+ TC_LOG_ERROR("sql.sql", "%s has useless data in value3 (%u)!", cond->ToString().c_str(), cond->ConditionValue3);
break;
}
- case CONDITION_AREAID:
- case CONDITION_INSTANCE_INFO:
- break;
case CONDITION_WORLD_STATE:
{
if (!sWorld->getWorldState(cond->ConditionValue1))
{
- TC_LOG_ERROR("sql.sql", "World state condition has non existing world state in value1 (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing world state in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "World state condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
- case CONDITION_PHASEMASK:
- {
- if (cond->ConditionValue2)
- TC_LOG_ERROR("sql.sql", "Phasemask condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- TC_LOG_ERROR("sql.sql", "Phasemask condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_TITLE:
@@ -2029,7 +2025,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
if (!titleEntry)
{
- TC_LOG_ERROR("sql.sql", "Title condition has non existing title in value1 (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing title in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
break;
@@ -2038,7 +2034,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (cond->ConditionValue1 > SPAWNMASK_RAID_ALL)
{
- TC_LOG_ERROR("sql.sql", "SpawnMask condition has non existing SpawnMask in value1 (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing SpawnMask in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
break;
@@ -2047,7 +2043,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (!(cond->ConditionValue1 & UNIT_STATE_ALL_STATE_SUPPORTED))
{
- TC_LOG_ERROR("sql.sql", "UnitState condition has non existing UnitState in value1 (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing UnitState in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
break;
@@ -2056,17 +2052,35 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
{
if (!cond->ConditionValue1 || cond->ConditionValue1 > CREATURE_TYPE_GAS_CLOUD)
{
- TC_LOG_ERROR("sql.sql", "CreatureType condition has non existing CreatureType in value1 (%u), skipped", cond->ConditionValue1);
+ TC_LOG_ERROR("sql.sql", "%s has non existing CreatureType in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
}
break;
}
+ case CONDITION_INSTANCE_INFO:
+ case CONDITION_AREAID:
+ case CONDITION_PHASEMASK:
+ case CONDITION_ALIVE:
+ break;
default:
break;
}
+
+ if (cond->ConditionValue1 && !StaticConditionTypeData[cond->ConditionType].HasConditionValue1)
+ LogUselessConditionValue(cond, 1, cond->ConditionValue1);
+ if (cond->ConditionValue2 && !StaticConditionTypeData[cond->ConditionType].HasConditionValue2)
+ LogUselessConditionValue(cond, 2, cond->ConditionValue2);
+ if (cond->ConditionValue3 && !StaticConditionTypeData[cond->ConditionType].HasConditionValue3)
+ LogUselessConditionValue(cond, 3, cond->ConditionValue3);
+
return true;
}
+void ConditionMgr::LogUselessConditionValue(Condition* cond, uint8 index, uint32 value)
+{
+ TC_LOG_ERROR("sql.sql", "%s has useless data in ConditionValue%u (%u)!", cond->ToString(true).c_str(), index, value);
+}
+
void ConditionMgr::Clean()
{
for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 24e44c662ba..621da355b7b 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -210,6 +210,8 @@ struct Condition
uint32 GetSearcherTypeMaskForCondition();
bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; }
uint32 GetMaxAvailableConditionTargets();
+
+ std::string ToString(bool ext = false) const; /// For logging purpose
};
typedef std::list<Condition*> ConditionList;
@@ -228,7 +230,6 @@ class ConditionMgr
~ConditionMgr();
public:
-
static ConditionMgr* instance()
{
static ConditionMgr instance;
@@ -243,14 +244,24 @@ class ConditionMgr
bool IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions);
bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions);
bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
- bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const;
- bool CanHaveSourceIdSet(ConditionSourceType sourceType) const;
+ static bool CanHaveSourceGroupSet(ConditionSourceType sourceType);
+ static bool CanHaveSourceIdSet(ConditionSourceType sourceType);
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
ConditionList GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId);
ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType);
ConditionList GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId);
ConditionList GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId);
+ struct ConditionTypeInfo
+ {
+ char const* Name;
+ bool HasConditionValue1;
+ bool HasConditionValue2;
+ bool HasConditionValue3;
+ };
+ static char const* StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
+ static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX];
+
private:
bool isSourceTypeValid(Condition* cond);
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
@@ -259,6 +270,8 @@ class ConditionMgr
bool addToSpellImplicitTargetConditions(Condition* cond);
bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
+ static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value);
+
void Clean(); // free up resources
std::list<Condition*> AllocatedMemoryStore; // some garbage collection :)