Core/GameEvent: Minor code optimization. (Also cosmetic changes in other unrelated files)
This commit is contained in:
@@ -167,42 +167,42 @@ bool Condition::Meets(Player* player, Unit* invoker)
|
||||
condMeets = !player->HasItemCount(mConditionValue1, 1, mConditionValue2 ? true : false);
|
||||
break;
|
||||
case CONDITION_LEVEL:
|
||||
{
|
||||
switch (mConditionValue2)
|
||||
{
|
||||
switch (mConditionValue2)
|
||||
{
|
||||
case LVL_COND_EQ:
|
||||
condMeets = player->getLevel() == mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_HIGH:
|
||||
condMeets = player->getLevel() > mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_LOW:
|
||||
condMeets = player->getLevel() < mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_HIGH_EQ:
|
||||
condMeets = player->getLevel() >= mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_LOW_EQ:
|
||||
condMeets = player->getLevel() <= mConditionValue1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LVL_COND_EQ:
|
||||
condMeets = player->getLevel() == mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_HIGH:
|
||||
condMeets = player->getLevel() > mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_LOW:
|
||||
condMeets = player->getLevel() < mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_HIGH_EQ:
|
||||
condMeets = player->getLevel() >= mConditionValue1;
|
||||
break;
|
||||
case LVL_COND_LOW_EQ:
|
||||
condMeets = player->getLevel() <= mConditionValue1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_DRUNKENSTATE:
|
||||
{
|
||||
condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= mConditionValue1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= mConditionValue1;
|
||||
break;
|
||||
}
|
||||
case CONDITION_NEAR_CREATURE:
|
||||
{
|
||||
condMeets = GetClosestCreatureWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||
break;
|
||||
}
|
||||
{
|
||||
condMeets = GetClosestCreatureWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||
break;
|
||||
}
|
||||
case CONDITION_NEAR_GAMEOBJECT:
|
||||
{
|
||||
condMeets = GetClosestGameObjectWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||
break;
|
||||
}
|
||||
{
|
||||
condMeets = GetClosestGameObjectWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
condMeets = false;
|
||||
refId = 0;
|
||||
@@ -382,7 +382,7 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outErrorDb(">> Loaded 0 conditions. DB table `groups` is empty!");
|
||||
sLog->outErrorDb(">> Loaded 0 conditions. DB table `conditions` is empty!");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
@@ -979,40 +979,32 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
|
||||
break;
|
||||
}
|
||||
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
|
||||
if (!sObjectMgr->GetQuestTemplate(cond->mSourceEntry))
|
||||
{
|
||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mSourceEntry);
|
||||
if (!Quest)
|
||||
{
|
||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_ACCEPT specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_ACCEPT specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK:
|
||||
if (!sObjectMgr->GetQuestTemplate(cond->mSourceEntry))
|
||||
{
|
||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mSourceEntry);
|
||||
if (!Quest)
|
||||
{
|
||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
||||
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceGroup))
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceGroup))
|
||||
{
|
||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
|
||||
return false;
|
||||
}
|
||||
SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->mSourceEntry);
|
||||
if (!spellProto)
|
||||
{
|
||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sSpellMgr->GetSpellInfo(cond->mSourceEntry))
|
||||
{
|
||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->mSourceEntry);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
case CONDITION_SOURCE_TYPE_NONE:
|
||||
@@ -1138,8 +1130,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
case CONDITION_QUEST_NONE:
|
||||
case CONDITION_QUEST_COMPLETE:
|
||||
{
|
||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mConditionValue1);
|
||||
if (!Quest)
|
||||
if (!sObjectMgr->GetQuestTemplate(cond->mConditionValue1))
|
||||
{
|
||||
sLog->outErrorDb("Quest condition specifies non-existing quest (%u), skipped", cond->mConditionValue1);
|
||||
return false;
|
||||
@@ -1341,23 +1332,23 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
break;
|
||||
}
|
||||
case CONDITION_LEVEL:
|
||||
{
|
||||
if (cond->mConditionValue2 >= LVL_COND_MAX)
|
||||
{
|
||||
if (cond->mConditionValue2 >= LVL_COND_MAX)
|
||||
{
|
||||
sLog->outErrorDb("Level condition has invalid option (%u), skipped", cond->mConditionValue2);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
sLog->outErrorDb("Level condition has invalid option (%u), skipped", cond->mConditionValue2);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_DRUNKENSTATE:
|
||||
{
|
||||
if (cond->mConditionValue1 > DRUNKEN_SMASHED)
|
||||
{
|
||||
if (cond->mConditionValue1 > DRUNKEN_SMASHED)
|
||||
{
|
||||
sLog->outErrorDb("DrunkState condition has invalid state (%u), skipped", cond->mConditionValue1);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
sLog->outErrorDb("DrunkState condition has invalid state (%u), skipped", cond->mConditionValue1);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_NEAR_CREATURE:
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(cond->mConditionValue1))
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define TRINITY_CONDITIONMGR_H
|
||||
|
||||
#include "LootMgr.h"
|
||||
#include <ace/Singleton.h>
|
||||
|
||||
class Player;
|
||||
class Unit;
|
||||
@@ -63,12 +64,12 @@ enum ConditionType
|
||||
|
||||
enum LevelConditionType
|
||||
{
|
||||
LVL_COND_EQ = 0,
|
||||
LVL_COND_HIGH = 1,
|
||||
LVL_COND_LOW = 2,
|
||||
LVL_COND_HIGH_EQ = 3,
|
||||
LVL_COND_LOW_EQ = 4,
|
||||
LVL_COND_MAX = 5,
|
||||
LVL_COND_EQ,
|
||||
LVL_COND_HIGH,
|
||||
LVL_COND_LOW,
|
||||
LVL_COND_HIGH_EQ,
|
||||
LVL_COND_LOW_EQ,
|
||||
LVL_COND_MAX
|
||||
};
|
||||
|
||||
enum ConditionSourceType
|
||||
@@ -141,11 +142,12 @@ typedef std::map<uint32, ConditionList > ConditionReferenceMap;//only used for r
|
||||
class ConditionMgr
|
||||
{
|
||||
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
|
||||
ConditionMgr();
|
||||
~ConditionMgr();
|
||||
|
||||
private:
|
||||
ConditionMgr();
|
||||
~ConditionMgr();
|
||||
|
||||
public:
|
||||
|
||||
void LoadConditions(bool isReload = false);
|
||||
bool isConditionTypeValid(Condition* cond);
|
||||
ConditionList GetConditionReferences(uint32 refId);
|
||||
@@ -154,14 +156,7 @@ class ConditionMgr
|
||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
||||
|
||||
protected:
|
||||
|
||||
ConditionMap m_ConditionMap;
|
||||
ConditionReferenceMap m_ConditionReferenceMap;
|
||||
VehicleSpellConditionMap m_VehicleSpellConditions;
|
||||
|
||||
private:
|
||||
|
||||
bool isSourceTypeValid(Condition* cond);
|
||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||
bool addToGossipMenus(Condition* cond);
|
||||
@@ -189,6 +184,10 @@ class ConditionMgr
|
||||
|
||||
void Clean(); // free up resources
|
||||
std::list<Condition*> m_AllocatedMemory; // some garbage collection :)
|
||||
|
||||
ConditionMap m_ConditionMap;
|
||||
ConditionReferenceMap m_ConditionReferenceMap;
|
||||
VehicleSpellConditionMap m_VehicleSpellConditions;
|
||||
};
|
||||
|
||||
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "SpellMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "OutdoorPvP.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "VMapManager2.h"
|
||||
|
||||
DisableMgr::DisableMgr()
|
||||
@@ -77,7 +77,6 @@ void DisableMgr::LoadDisables()
|
||||
switch (type)
|
||||
{
|
||||
case DISABLE_TYPE_SPELL:
|
||||
{
|
||||
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
|
||||
{
|
||||
sLog->outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
@@ -104,7 +103,7 @@ void DisableMgr::LoadDisables()
|
||||
data.params[1].insert(atoi(tokens[i++]));
|
||||
}
|
||||
|
||||
} break;
|
||||
break;
|
||||
// checked later
|
||||
case DISABLE_TYPE_QUEST:
|
||||
break;
|
||||
@@ -217,7 +216,7 @@ void DisableMgr::LoadDisables()
|
||||
|
||||
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
||||
++total_count;
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -313,7 +312,7 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit,
|
||||
uint8 disabledModes = itr->second.flags;
|
||||
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
|
||||
GetDownscaledMapDifficultyData(entry, targetDifficulty);
|
||||
switch(targetDifficulty)
|
||||
switch (targetDifficulty)
|
||||
{
|
||||
case DUNGEON_DIFFICULTY_NORMAL:
|
||||
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
|
||||
|
||||
Reference in New Issue
Block a user