aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShocker <none@none>2010-09-28 08:21:51 +0300
committerShocker <none@none>2010-09-28 08:21:51 +0300
commit78803c9f09feff5213a394a84e28b8245f7e2efa (patch)
tree7e58d15fabfb5f3ebbe7364ad6424f548caacf24 /src
parent192e972a594afb020e6639de7cce617e7f4655ad (diff)
Magic numbers cleanup:
- Replace many magic numbers with constants - Use enum for vehicle flags/seat flags - Correct structure for ItemRandomSuffixEntry --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.cpp2
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp2
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h6
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp6
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp2
-rw-r--r--src/server/game/Chat/Chat.cpp8
-rw-r--r--src/server/game/Chat/Commands/Level1.cpp4
-rw-r--r--src/server/game/Chat/Commands/Level2.cpp8
-rw-r--r--src/server/game/Chat/Commands/Level3.cpp24
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp6
-rw-r--r--src/server/game/DataStores/DBCEnums.h2
-rw-r--r--src/server/game/DataStores/DBCStores.cpp4
-rw-r--r--src/server/game/DataStores/DBCStores.h2
-rw-r--r--src/server/game/DataStores/DBCStructure.h76
-rw-r--r--src/server/game/DataStores/DBCfmt.h4
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp4
-rw-r--r--src/server/game/Entities/Creature/Creature.h4
-rw-r--r--src/server/game/Entities/Creature/GossipDef.cpp14
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp2
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h4
-rw-r--r--src/server/game/Entities/Item/Item.cpp16
-rw-r--r--src/server/game/Entities/Item/Item.h2
-rw-r--r--src/server/game/Entities/Player/Player.cpp38
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp6
-rw-r--r--src/server/game/Entities/Unit/Unit.h4
-rw-r--r--src/server/game/Entities/Vehicle/Vehicle.cpp8
-rw-r--r--src/server/game/Entities/Vehicle/Vehicle.h19
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp36
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp2
-rw-r--r--src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Server/Protocol/Handlers/NPCHandler.h8
-rw-r--r--src/server/game/Server/Protocol/Handlers/PetHandler.cpp2
-rw-r--r--src/server/game/Server/Protocol/Handlers/QueryHandler.cpp16
-rw-r--r--src/server/game/Server/WorldSession.cpp8
-rw-r--r--src/server/game/Server/WorldSession.h2
-rw-r--r--src/server/game/Server/WorldSocket.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp10
-rw-r--r--src/server/game/Spells/Spell.h2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp13
-rw-r--r--src/server/game/Spells/SpellMgr.cpp24
-rw-r--r--src/server/game/Spells/SpellMgr.h10
-rw-r--r--src/server/game/World/World.cpp12
-rw-r--r--src/server/shared/Common.cpp4
-rw-r--r--src/server/shared/Common.h7
44 files changed, 245 insertions, 194 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index a156ec573d9..ae0263d6149 100644
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -273,7 +273,7 @@ void UnitAI::FillAISpellInfo()
UPDATE_TARGET(AITARGET_SELF)
else
{
- for (uint32 j = 0; j < 3; ++j)
+ for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
uint32 targetType = spellInfo->EffectImplicitTargetA[j];
diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp
index 864de9288a1..524d4148d71 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp
@@ -205,7 +205,7 @@ void SimpleAI::UpdateAI(const uint32 diff)
return;
//Spells
- for (uint32 i = 0; i < 10; ++i)
+ for (uint32 i = 0; i < MAX_SIMPLEAI_SPELLS; ++i)
{
//Spell not valid
if (!Spell[i].Enabled || !Spell[i].Spell_Id)
diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h
index c4689ff3fab..c448b9ba4da 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h
@@ -19,6 +19,8 @@ enum CastTarget
CAST_JUSTDIED_KILLER, //Only works within JustDied function
};
+#define MAX_SIMPLEAI_SPELLS 10
+
struct SimpleAI : public ScriptedAI
{
SimpleAI(Creature *c);// : ScriptedAI(c);
@@ -61,10 +63,10 @@ public:
//3 texts to many?
int32 TextId[3];
uint32 Text_Sound[3];
- }Spell[10];
+ }Spell[MAX_SIMPLEAI_SPELLS];
protected:
- uint32 Spell_Timer[10];
+ uint32 Spell_Timer[MAX_SIMPLEAI_SPELLS];
};
#endif
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index cd52a24c427..c214e3bb106 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -1132,7 +1132,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue;
// additional requirements
- if (achievementCriteria->additionalRequrements[0].additionalRequirement_type == ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE)
+ if (achievementCriteria->additionalRequrements[0].additionalRequirement_type == ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE)
{
// those requirements couldn't be found in the dbc
AchievementCriteriaDataSet const* data = sAchievementMgr.GetCriteriaDataSet(achievementCriteria);
@@ -2199,7 +2199,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL: // any cases
break;
case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA: // need skip generic cases
- if (criteria->additionalRequrements[0].additionalRequirement_type != ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE)
+ if (criteria->additionalRequrements[0].additionalRequirement_type != ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE)
continue;
break;
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM: // any cases
@@ -2422,7 +2422,7 @@ void AchievementGlobalMgr::LoadRewardLocales()
AchievementRewardLocale& data = m_achievementRewardLocales[entry];
- for (int i = 1; i < MAX_LOCALE; ++i)
+ for (int i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
std::string str = fields[1 + 2 * (i - 1)].GetString();
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 9acca669e48..f77728babd5 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -810,7 +810,7 @@ void Battleground::EndBattleground(uint32 winner)
loser_arena_team->MemberLost(plr, winner_matchmaker_rating, loser_change);
// Arena lost => reset the win_rated_arena having the "no_loose" condition
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE);
+ plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE);
}
}
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 94c33a08585..17cf95b1cc8 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -1616,7 +1616,7 @@ valid examples:
return false;
}
- for (uint8 i=0; i<MAX_LOCALE; ++i)
+ for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
uint32 skillLineNameLength = strlen(skillLine->name[i]);
if (skillLineNameLength > 0 && strncmp(skillLine->name[i], buffer, skillLineNameLength) == 0)
@@ -1629,7 +1629,7 @@ valid examples:
}
}
bool foundName = false;
- for (uint8 i=0; i<MAX_LOCALE; ++i)
+ for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
if (*linkedSpell->SpellName[i] && strcmp(linkedSpell->SpellName[i], buffer) == 0)
{
@@ -1688,7 +1688,7 @@ valid examples:
ItemLocale const *il = sObjectMgr.GetItemLocale(linkedItem->ItemId);
bool foundName = false;
- for (uint8 dbIndex = LOCALE_koKR; dbIndex < MAX_LOCALE; ++dbIndex)
+ for (uint8 dbIndex = LOCALE_koKR; dbIndex < TOTAL_LOCALES; ++dbIndex)
{
if (il == NULL || dbIndex >= il->Name.size())
// using strange database/client combinations can lead to this case
@@ -1718,7 +1718,7 @@ valid examples:
else if (linkedAchievement)
{
bool foundName = false;
- for (uint8 i=0; i<MAX_LOCALE; ++i)
+ for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
if (*linkedAchievement->name[i] && strcmp(linkedAchievement->name[i], buffer) == 0)
{
diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp
index e8d85bc6d2d..84f29260ec9 100644
--- a/src/server/game/Chat/Commands/Level1.cpp
+++ b/src/server/game/Chat/Commands/Level1.cpp
@@ -1871,7 +1871,7 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args)
if (!Utf8FitTo (name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale ())
continue;
@@ -1885,7 +1885,7 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index a8be083982e..3abdc308b3c 100644
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -3749,7 +3749,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3763,7 +3763,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
targetSkillInfo = skillInfo;
break;
@@ -4319,7 +4319,7 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -4333,7 +4333,7 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && counter == maxResults)
{
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index b831d8b6294..20f49673131 100644
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -3124,7 +3124,7 @@ bool ChatHandler::HandleLookupItemSetCommand(const char *args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3138,7 +3138,7 @@ bool ChatHandler::HandleLookupItemSetCommand(const char *args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
@@ -3197,7 +3197,7 @@ bool ChatHandler::HandleLookupSkillCommand(const char *args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3211,7 +3211,7 @@ bool ChatHandler::HandleLookupSkillCommand(const char *args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
@@ -3284,7 +3284,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char *args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3298,7 +3298,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char *args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
@@ -3682,7 +3682,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char *args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3696,7 +3696,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char *args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
@@ -3780,7 +3780,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
if (!Utf8FitTo(name, wnamepart))
{
loc = 0;
- for (; loc < MAX_LOCALE; ++loc)
+ for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale())
continue;
@@ -3794,7 +3794,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
@@ -3851,7 +3851,7 @@ bool ChatHandler::HandleLookupMapCommand(const char *args)
if (!Utf8FitTo(name, wnamepart))
{
loc = LOCALE_enUS;
- for (; loc < MAX_LOCALE; loc++)
+ for (; loc < TOTAL_LOCALES; loc++)
{
if (m_session && loc == m_session->GetSessionDbcLocale())
continue;
@@ -3865,7 +3865,7 @@ bool ChatHandler::HandleLookupMapCommand(const char *args)
}
}
- if (loc < MAX_LOCALE)
+ if (loc < TOTAL_LOCALES)
{
// send map in "id - [name][Continent][Instance/Battleground/Arena][Raid reset time:][Heroic reset time:][Mountable]" format
std::ostringstream ss;
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 41fe265161d..ea4f49767f9 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -102,7 +102,7 @@ bool Condition::Meets(Player * player, Unit* invoker)
{
Unit::AuraApplicationMap const& auras = player->GetAppliedAuras();
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
- if ((itr->second->GetBase()->GetSpellProto()->Attributes & 0x1000010) && itr->second->GetBase()->GetSpellProto()->SpellVisual[0] == 3580)
+ if ((itr->second->GetBase()->GetSpellProto()->Attributes & (SPELL_ATTR_UNK4 | SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) && itr->second->GetBase()->GetSpellProto()->SpellVisual[0] == 3580)
{
condMeets = true;
break;
@@ -792,7 +792,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
}
bool targetfound = false;
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellProto->EffectImplicitTargetA[i] == TARGET_UNIT_AREA_ENTRY_SRC ||
spellProto->EffectImplicitTargetB[i] == TARGET_UNIT_AREA_ENTRY_SRC ||
@@ -875,7 +875,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
if (!conditions.empty())
break;
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (pSpellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_TARGET_ENEMY ||
pSpellInfo->EffectImplicitTargetB[j] == TARGET_UNIT_TARGET_ENEMY ||
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index 5eac08654d5..c65d52cabd3 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -77,7 +77,7 @@ enum AchievementCriteriaCondition
ACHIEVEMENT_CRITERIA_CONDITION_NO_DEATH = 1, // reset progress on death
ACHIEVEMENT_CRITERIA_CONDITION_UNK1 = 2, // only used in "Complete a daily quest every day for five consecutive days"
ACHIEVEMENT_CRITERIA_CONDITION_MAP = 3, // requires you to be on specific map, reset at change
- ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE = 4, // only used in "Win 10 arenas without losing"
+ ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE = 4, // only used in "Win 10 arenas without losing"
ACHIEVEMENT_CRITERIA_CONDITION_UNK2 = 9, // unk
ACHIEVEMENT_CRITERIA_CONDITION_UNK3 = 13, // unk
};
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index 8f772431d4c..a092276e0b8 100644
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -214,7 +214,7 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList
if (storage.Load(dbc_filename.c_str(), sql))
{
bar.step();
- for (uint8 i = 0; i < MAX_LOCALE; ++i)
+ for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
if (!(availableDbcLocales & (1 << i)))
continue;
@@ -517,7 +517,7 @@ void LoadDBCStores(const std::string& dataPath)
std::set<uint32> spellPaths;
for (uint32 i = 1; i < sSpellStore.GetNumRows (); ++i)
if (SpellEntry const* sInfo = sSpellStore.LookupEntry (i))
- for (int j=0; j < 3; ++j)
+ for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
if (sInfo->Effect[j] == SPELL_EFFECT_SEND_TAXI)
spellPaths.insert(sInfo->EffectMiscValue[j]);
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 49042e398cd..1856ecb921d 100644
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -60,7 +60,7 @@ typedef std::map<uint32/*pair32(map,diff)*/,MapDifficulty> MapDifficultyMap;
MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);
MapDifficulty const* GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty);
-uint32 const* /*[3]*/ GetTalentTabPages(uint8 cls);
+uint32 const* /*[MAX_TALENT_TABS]*/ GetTalentTabPages(uint8 cls);
PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 level);
PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id);
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index e9297f29cfb..70549e6cc42 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -26,6 +26,7 @@
#include "Define.h"
#include "Path.h"
#include "Util.h"
+#include "Vehicle.h"
#include <map>
#include <set>
@@ -533,10 +534,12 @@ struct AreaTableEntry
}
};
+#define MAX_GROUP_AREA_IDS 6
+
struct AreaGroupEntry
{
uint32 AreaGroupId; // 0
- uint32 AreaId[6]; // 1-6
+ uint32 AreaId[MAX_GROUP_AREA_IDS]; // 1-6
uint32 nextGroup; // 7 index of next group
};
@@ -831,6 +834,8 @@ struct FactionEntry
// 56 string flags
};
+#define MAX_FACTION_RELATIONS 4
+
struct FactionTemplateEntry
{
uint32 ID; // 0 m_ID
@@ -839,8 +844,8 @@ struct FactionTemplateEntry
uint32 ourMask; // 3 m_factionGroup
uint32 friendlyMask; // 4 m_friendGroup
uint32 hostileMask; // 5 m_enemyGroup
- uint32 enemyFaction[4]; // 6 m_enemies[4]
- uint32 friendFaction[4]; // 10 m_friend[4]
+ uint32 enemyFaction[MAX_FACTION_RELATIONS]; // 6 m_enemies[MAX_FACTION_RELATIONS]
+ uint32 friendFaction[MAX_FACTION_RELATIONS]; // 10 m_friend[MAX_FACTION_RELATIONS]
//------------------------------------------------------- end structure
// helpers
@@ -850,10 +855,10 @@ struct FactionTemplateEntry
return true;
if (entry.faction)
{
- for (int i = 0; i < 4; ++i)
+ for (int i = 0; i < MAX_FACTION_RELATIONS; ++i)
if (enemyFaction[i] == entry.faction)
return false;
- for (int i = 0; i < 4; ++i)
+ for (int i = 0; i < MAX_FACTION_RELATIONS; ++i)
if (friendFaction[i] == entry.faction)
return true;
}
@@ -865,10 +870,10 @@ struct FactionTemplateEntry
return false;
if (entry.faction)
{
- for (int i = 0; i < 4; ++i)
+ for (int i = 0; i < MAX_FACTION_RELATIONS; ++i)
if (enemyFaction[i] == entry.faction)
return true;
- for (int i = 0; i < 4; ++i)
+ for (int i = 0; i < MAX_FACTION_RELATIONS; ++i)
if (friendFaction[i] == entry.faction)
return false;
}
@@ -877,7 +882,7 @@ struct FactionTemplateEntry
bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; }
bool IsNeutralToAll() const
{
- for (int i = 0; i < 4; ++i)
+ for (int i = 0; i < MAX_FACTION_RELATIONS; ++i)
if (enemyFaction[i] != 0)
return false;
return hostileMask == 0 && friendlyMask == 0;
@@ -1052,15 +1057,17 @@ struct ItemDisplayInfoEntry
// uint32 arenaseason; // arena season number(1-4)
//};
+#define MAX_ITEM_EXTENDED_COST_REQUIREMENTS 5
+
struct ItemExtendedCostEntry
{
- uint32 ID; // 0 extended-cost entry id
- uint32 reqhonorpoints; // 1 required honor points
- uint32 reqarenapoints; // 2 required arena points
- uint32 reqarenaslot; // 4 arena slot restrctions (min slot value)
- uint32 reqitem[5]; // 5-8 required item id
- uint32 reqitemcount[5]; // 9-13 required count of 1st item
- uint32 reqpersonalarenarating; // 14 required personal arena rating};
+ uint32 ID; // 0 extended-cost entry id
+ uint32 reqhonorpoints; // 1 required honor points
+ uint32 reqarenapoints; // 2 required arena points
+ uint32 reqarenaslot; // 3 arena slot restrctions (min slot value)
+ uint32 reqitem[MAX_ITEM_EXTENDED_COST_REQUIREMENTS]; // 4-8 required item id
+ uint32 reqitemcount[MAX_ITEM_EXTENDED_COST_REQUIREMENTS]; // 9-14 required count of 1st item
+ uint32 reqpersonalarenarating; // 15 required personal arena rating};
};
struct ItemLimitCategoryEntry
@@ -1072,12 +1079,15 @@ struct ItemLimitCategoryEntry
uint32 mode; // 19, 0 = have, 1 = equip (enum ItemLimitCategoryMode)
};
+#define MAX_ITEM_ENCHANTMENT_EFFECTS 3
+
struct ItemRandomPropertiesEntry
{
uint32 ID; // 0 m_ID
//char* internalName // 1 m_Name
- uint32 enchant_id[5]; // 2-6 m_Enchantment
- char* nameSuffix[16]; // 7-22 m_name_lang
+ uint32 enchant_id[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 2-4 m_Enchantment
+ // 5-6 unused
+ char* nameSuffix[16]; // 7-22 m_name_lang
// 23 name flags
};
@@ -1087,11 +1097,15 @@ struct ItemRandomSuffixEntry
char* nameSuffix[16]; // 1-16 m_name_lang
// 17, name flags
// 18 m_internalName
- uint32 enchant_id[5]; // 19-21 m_enchantment
- uint32 prefix[5]; // 22-24 m_allocationPct
+ uint32 enchant_id[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 19-21 m_enchantment
+ //uint32 unk1[2] // 22-23 unknown
+ uint32 prefix[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 24-26 m_allocationPct
+ //uint32 unk2[2] // 27-28 unknown
};
#define MAX_ITEM_SET_ITEMS 10
+#define MAX_ITEM_SET_SPELLS 8
+
struct ItemSetEntry
{
//uint32 id // 0 m_ID
@@ -1099,8 +1113,8 @@ struct ItemSetEntry
// 17 string flags, unused
uint32 itemId[MAX_ITEM_SET_ITEMS]; // 18-27 m_itemID
//uint32 unknown[7]; // 28-34 unk, all 0
- uint32 spells[8]; // 35-42 m_setSpellID
- uint32 items_to_triggerspell[8]; // 43-50 m_setThreshold
+ uint32 spells[MAX_ITEM_SET_SPELLS]; // 35-42 m_setSpellID
+ uint32 items_to_triggerspell[MAX_ITEM_SET_SPELLS]; // 43-50 m_setThreshold
uint32 required_skill_id; // 51 m_requiredSkill
uint32 required_skill_value; // 52 m_requiredSkillRank
};
@@ -1409,6 +1423,7 @@ struct SoundEntriesEntry
#define MAX_SPELL_EFFECTS 3
#define MAX_EFFECT_MASK 7
+#define MAX_SPELL_REAGENTS 8
struct SpellEntry
{
@@ -1463,8 +1478,8 @@ struct SpellEntry
//uint32 modalNextSpell; // 48 m_modalNextSpell not used
uint32 StackAmount; // 49 m_cumulativeAura
uint32 Totem[2]; // 50-51 m_totem
- int32 Reagent[8]; // 52-59 m_reagent
- uint32 ReagentCount[8]; // 60-67 m_reagentCount
+ int32 Reagent[MAX_SPELL_REAGENTS]; // 52-59 m_reagent
+ uint32 ReagentCount[MAX_SPELL_REAGENTS]; // 60-67 m_reagentCount
int32 EquippedItemClass; // 68 m_equippedItemClass (value)
int32 EquippedItemSubClassMask; // 69 m_equippedItemSubclass (mask)
int32 EquippedItemInventoryTypeMask; // 70 m_equippedItemInvTypes (mask)
@@ -1614,10 +1629,10 @@ struct SpellItemEnchantmentEntry
{
uint32 ID; // 0 m_ID
//uint32 charges; // 1 m_charges
- uint32 type[3]; // 2-4 m_effect[3]
- uint32 amount[3]; // 5-7 m_effectPointsMin[3]
- //uint32 amount2[3] // 8-10 m_effectPointsMax[3]
- uint32 spellid[3]; // 11-13 m_effectArg[3]
+ uint32 type[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 2-4 m_effect[MAX_ITEM_ENCHANTMENT_EFFECTS]
+ uint32 amount[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 5-7 m_effectPointsMin[MAX_ITEM_ENCHANTMENT_EFFECTS]
+ //uint32 amount2[MAX_ITEM_ENCHANTMENT_EFFECTS] // 8-10 m_effectPointsMax[MAX_ITEM_ENCHANTMENT_EFFECTS]
+ uint32 spellid[MAX_ITEM_ENCHANTMENT_EFFECTS]; // 11-13 m_effectArg[MAX_ITEM_ENCHANTMENT_EFFECTS]
char* description[16]; // 14-29 m_name_lang[16]
//uint32 descriptionFlags; // 30 name flags
uint32 aura_id; // 31 m_itemVisual
@@ -1660,6 +1675,7 @@ struct SummonPropertiesEntry
#define MAX_TALENT_RANK 5
#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK
+#define MAX_TALENT_TABS 3
struct TalentEntry
{
@@ -1735,6 +1751,8 @@ struct TotemCategoryEntry
uint32 categoryMask; // 19 (compatibility mask for same type: different for totems, compatible from high to low for rods)
};
+#define MAX_VEHICLE_SEATS 8
+
struct VehicleEntry
{
uint32 m_ID; // 0
@@ -1743,7 +1761,7 @@ struct VehicleEntry
float m_pitchSpeed; // 3
float m_pitchMin; // 4
float m_pitchMax; // 5
- uint32 m_seatID[8]; // 6-13
+ uint32 m_seatID[MAX_VEHICLE_SEATS]; // 6-13
float m_mouseLookOffsetPitch; // 14
float m_cameraFadeDistScalarMin; // 15
float m_cameraFadeDistScalarMax; // 16
@@ -1822,7 +1840,7 @@ struct VehicleSeatEntry
uint32 m_flagsB; // 45
// 46-57 added in 3.1, floats mostly
- bool IsUsable() const { return m_flags & 0x2000000; }
+ bool IsUsable() const { return m_flags & VEHICLE_SEAT_FLAG_USABLE; }
};
struct WMOAreaTableEntry
diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h
index 7d7120dbed1..22d5ab64673 100644
--- a/src/server/game/DataStores/DBCfmt.h
+++ b/src/server/game/DataStores/DBCfmt.h
@@ -70,8 +70,8 @@ const char ItemBagFamilyfmt[]="nxxxxxxxxxxxxxxxxx";
//const char ItemCondExtCostsEntryfmt[]="xiii";
const char ItemExtendedCostEntryfmt[]="niiiiiiiiiiiiiix";
const char ItemLimitCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
-const char ItemRandomPropertiesfmt[]="nxiiiiissssssssssssssssx";
-const char ItemRandomSuffixfmt[]="nssssssssssssssssxxiiiiiiiiii";
+const char ItemRandomPropertiesfmt[]="nxiiixxssssssssssssssssx";
+const char ItemRandomSuffixfmt[]="nssssssssssssssssxxiiixxiiixx";
const char ItemSetEntryfmt[]="dssssssssssssssssxiiiiiiiiiixxxxxxxiiiiiiiiiiiiiiiiii";
const char LFGDungeonEntryfmt[]="nxxxxxxxxxxxxxxxxxiiiiiiixixxixixxxxxxxxxxxxxxxxx";
const char LockEntryfmt[]="niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx";
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 899782ae2d3..bc9f74ab5ed 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1678,7 +1678,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
}
bool bcontinue = true;
- for (uint32 j=0; j<3; j++)
+ for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
if ((spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE) ||
(spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) ||
@@ -1728,7 +1728,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
}
bool bcontinue = true;
- for (uint32 j=0; j<3; j++)
+ for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL))
{
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 2c997cd8df7..d8a8b13b208 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -68,6 +68,8 @@ enum CreatureFlagsExtra
#define MAX_KILL_CREDIT 2
#define CREATURE_REGEN_INTERVAL 2 * IN_MILLISECONDS
+#define MAX_CREATURE_QUEST_ITEMS 6
+
// from `creature_template` table
struct CreatureInfo
{
@@ -133,7 +135,7 @@ struct CreatureInfo
float ModMana;
float ModArmor;
bool RacialLeader;
- uint32 questItems[6];
+ uint32 questItems[MAX_CREATURE_QUEST_ITEMS];
uint32 movementId;
bool RegenHealth;
uint32 equipmentId;
diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp
index ff93089fcb2..ab59be5ec82 100644
--- a/src/server/game/Entities/Creature/GossipDef.cpp
+++ b/src/server/game/Entities/Creature/GossipDef.cpp
@@ -240,7 +240,7 @@ void PlayerMenu::SendTalking(uint32 textID)
if (!pGossip)
{
- for (uint32 i = 0; i < 8; ++i)
+ for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << float(0);
data << "Greetings $N";
@@ -256,8 +256,8 @@ void PlayerMenu::SendTalking(uint32 textID)
}
else
{
- std::string Text_0[8], Text_1[8];
- for (int i = 0; i < 8; ++i)
+ std::string Text_0[MAX_LOCALES], Text_1[MAX_LOCALES];
+ for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
Text_0[i] = pGossip->Options[i].Text_0;
Text_1[i] = pGossip->Options[i].Text_1;
@@ -267,14 +267,14 @@ void PlayerMenu::SendTalking(uint32 textID)
{
if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID))
{
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_LOCALES; ++i)
{
sObjectMgr.GetLocaleString(nl->Text_0[i], loc_idx, Text_0[i]);
sObjectMgr.GetLocaleString(nl->Text_1[i], loc_idx, Text_1[i]);
}
}
}
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << pGossip->Options[i].Probability;
@@ -290,7 +290,7 @@ void PlayerMenu::SendTalking(uint32 textID)
data << pGossip->Options[i].Language;
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
{
data << pGossip->Options[i].Emotes[j]._Delay;
data << pGossip->Options[i].Emotes[j]._Emote;
@@ -306,7 +306,7 @@ void PlayerMenu::SendTalking(char const * title, char const * text)
{
WorldPacket data(SMSG_NPC_TEXT_UPDATE, 50); // guess size
data << uint32(0);
- for (uint32 i = 0; i < 8; ++i)
+ for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << float(0);
data << title;
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 4b65fc7aabf..34e2c1d179f 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1565,7 +1565,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
return;
bool self = false;
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
{
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 6ae7aebd2f0..eb9d1b8c2e7 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -34,6 +34,8 @@
#pragma pack(push,1)
#endif
+#define MAX_GAMEOBJECT_QUEST_ITEMS 6
+
// from `gameobject_template`
struct GameObjectInfo
{
@@ -47,7 +49,7 @@ struct GameObjectInfo
uint32 faction;
uint32 flags;
float size;
- uint32 questItems[6];
+ uint32 questItems[MAX_GAMEOBJECT_QUEST_ITEMS];
union // different GO types have different data field
{
//0 GAMEOBJECT_TYPE_DOOR
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index fee4ce25fe4..df0a0294c19 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -76,7 +76,7 @@ void AddItemsSetItem(Player*player,Item *item)
++eff->item_count;
- for (uint32 x=0; x<8; x++)
+ for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++)
{
if (!set->spells [x])
continue;
@@ -84,16 +84,16 @@ void AddItemsSetItem(Player*player,Item *item)
if (set->items_to_triggerspell[x] > eff->item_count)
continue;
- uint32 z=0;
- for (; z<8; z++)
+ uint32 z = 0;
+ for (; z < MAX_ITEM_SET_SPELLS; z++)
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
break;
- if (z < 8)
+ if (z < MAX_ITEM_SET_SPELLS)
continue;
//new spell
- for (uint32 y=0; y<8; y++)
+ for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; y++)
{
if (!eff->spells[y]) // free slot
{
@@ -142,7 +142,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
--eff->item_count;
- for (uint32 x=0; x<8; x++)
+ for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++)
{
if (!set->spells[x])
continue;
@@ -151,7 +151,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
if (set->items_to_triggerspell[x] <= eff->item_count)
continue;
- for (uint32 z=0; z<8; z++)
+ for (uint32 z = 0; z < MAX_ITEM_SET_SPELLS; z++)
{
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
{
@@ -918,7 +918,7 @@ void Item::ClearEnchantment(EnchantmentSlot slot)
if (!GetEnchantmentId(slot))
return;
- for (uint8 x = 0; x < 3; ++x)
+ for (uint8 x = 0; x < MAX_ITEM_ENCHANTMENT_EFFECTS; ++x)
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
SetState(ITEM_CHANGED, GetOwner());
}
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index 1caef195262..ba1b5d8788b 100644
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -211,6 +211,8 @@ enum ItemRequiredTargetType
#define MAX_ITEM_REQ_TARGET_TYPE 2
+#define MAX_ITEM_SPELLS 5
+
struct ItemRequiredTarget
{
ItemRequiredTarget(ItemRequiredTargetType uiType, uint32 uiTargetEntry) : m_uiType(uiType), m_uiTargetEntry(uiTargetEntry) {}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index bc0b67f2089..31adb2ddb17 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7791,7 +7791,7 @@ void Player::UpdateEquipSpellsAtFormChange()
if (!eff)
continue;
- for (uint32 y=0; y<8; ++y)
+ for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; ++y)
{
SpellEntry const* spellInfo = eff->spells[y];
if (!spellInfo)
@@ -7844,7 +7844,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
{
- for (uint8 i = 0; i < 5; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i)
{
_Spell const& spellData = proto->Spells[i];
@@ -7902,7 +7902,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!pEnchant) continue;
- for (uint8 s = 0; s < 3; ++s)
+ for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
continue;
@@ -8022,7 +8022,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!pEnchant)
continue;
- for (uint8 s = 0; s < 3; ++s)
+ for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_USE_SPELL)
continue;
@@ -13094,7 +13094,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
if (!item->IsBroken())
{
- for (int s = 0; s < 3; ++s)
+ for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
uint32 enchant_display_type = pEnchant->type[s];
uint32 enchant_amount = pEnchant->amount[s];
@@ -13128,7 +13128,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
if (item_rand)
{
// Search enchant_amount
- for (int k = 0; k < 3; ++k)
+ for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand->enchant_id[k] == enchant_id)
{
@@ -13154,7 +13154,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if (item_rand)
{
- for (int k = 0; k < 3; ++k)
+ for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand->enchant_id[k] == enchant_id)
{
@@ -13174,7 +13174,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if (item_rand_suffix)
{
- for (int k = 0; k < 3; ++k)
+ for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand_suffix->enchant_id[k] == enchant_id)
{
@@ -18637,7 +18637,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if (spellInfo)
{
- for (uint32 i = 0; i < 7; ++i)
+ for (uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i)
{
if (spellInfo->Reagent[i] > 0)
{
@@ -19716,7 +19716,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
if (iece->reqarenapoints)
ModifyArenaPoints(- int32(iece->reqarenapoints * count));
- for (uint8 i = 0; i < 5; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
if (iece->reqitem[i])
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
@@ -19843,7 +19843,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
// item base price
- for (uint8 i = 0; i < 5; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
{
@@ -20020,7 +20020,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
{
if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId))
{
- for (uint8 idx = 0; idx < 5; ++idx)
+ for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx)
{
if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id)
{
@@ -20132,7 +20132,7 @@ void Player::UpdatePotionCooldown(Spell* spell)
{
// spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions)
if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId))
- for (uint8 idx = 0; idx < 5; ++idx)
+ for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx)
if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE)
if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId))
SendCooldownEvent(spellInfo,m_lastPotionId);
@@ -21227,7 +21227,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
// check learned spells state
bool found = false;
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i]))
{
@@ -23481,7 +23481,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
// find class talent tabs (all players have 3 talent tabs)
uint32 const* talentTabIds = GetTalentTabPages(getClass());
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_TALENT_TABS; ++i)
{
uint32 talentTabId = talentTabIds[i];
@@ -24152,7 +24152,7 @@ void Player::SendRefundInfo(Item *item)
data << uint32(item->GetPaidMoney()); // money cost
data << uint32(iece->reqhonorpoints); // honor point cost
data << uint32(iece->reqarenapoints); // arena point cost
- for (uint8 i = 0; i < 5; ++i) // item cost data
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
{
data << uint32(iece->reqitem[i]);
data << uint32(iece->reqitemcount[i]);
@@ -24218,7 +24218,7 @@ void Player::RefundItem(Item *item)
}
bool store_error = false;
- for (uint8 i = 0; i < 5; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
uint32 count = iece->reqitemcount[i];
uint32 itemid = iece->reqitem[i];
@@ -24250,7 +24250,7 @@ void Player::RefundItem(Item *item)
data << uint32(item->GetPaidMoney()); // money cost
data << uint32(iece->reqhonorpoints); // honor point cost
data << uint32(iece->reqarenapoints); // arena point cost
- for (uint8 i = 0; i < 5; ++i) // item cost data
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
{
data << iece->reqitem[i];
data << (iece->reqitemcount[i]);
@@ -24264,7 +24264,7 @@ void Player::RefundItem(Item *item)
DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
// Grant back extendedcost items
- for (uint8 i = 0; i < 5; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
uint32 count = iece->reqitemcount[i];
uint32 itemid = iece->reqitem[i];
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index c13aa68b825..79e31d3e76e 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -2742,7 +2742,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (!IsPositiveSpell(spell->Id))
{
bool bNegativeAura = false;
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spell->EffectApplyAuraName[i] != 0)
{
@@ -4191,7 +4191,7 @@ void Unit::RemoveArenaAuras(bool onleave)
{
AuraApplication const * aurApp = iter->second;
Aura const * aura = aurApp->GetBase();
- if (!(aura->GetSpellProto()->AttributesEx4 & (1<<21)) // don't remove stances, shadowform, pally/hunter auras
+ if (!(aura->GetSpellProto()->AttributesEx4 & SPELL_ATTR_EX4_UNK21) // don't remove stances, shadowform, pally/hunter auras
&& !aura->IsPassive() // don't remove passive auras
&& (!(aura->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || !(aura->GetSpellProto()->Attributes & SPELL_ATTR_UNK8)) // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable)
&& (aurApp->IsPositive() ^ onleave)) // remove positive buffs on enter, negative buffs on leave
@@ -11191,7 +11191,7 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo)
return true;
}
- for (int i=0;i<3;++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
// State/effect immunities applied by aura expect full spell immunity
// Ignore effects with mechanic, they are supposed to be checked separately
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index f3ee81cc39d..cb61f498c8b 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -681,8 +681,8 @@ enum MovementFlags
enum MovementFlags2
{
MOVEMENTFLAG2_NONE = 0x00000000,
- MOVEMENTFLAG2_UNK1 = 0x00000001,
- MOVEMENTFLAG2_UNK2 = 0x00000002,
+ MOVEMENTFLAG2_NO_STRAFE = 0x00000001,
+ MOVEMENTFLAG2_NO_JUMPING = 0x00000002,
MOVEMENTFLAG2_UNK3 = 0x00000004,
MOVEMENTFLAG2_FULL_SPEED_TURNING = 0x00000008,
MOVEMENTFLAG2_FULL_SPEED_PITCHING = 0x00000010,
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index 16bf80aa8be..ecc50a7b45c 100644
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -29,7 +29,7 @@
Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0), m_bonusHP(0)
{
- for (uint32 i = 0; i < 8; ++i)
+ for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i)
{
if (uint32 seatId = m_vehicleInfo->m_seatID[i])
if (VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(seatId))
@@ -305,7 +305,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
}
}
- if (seat->second.seatInfo->m_flags && !(seat->second.seatInfo->m_flags & 0x400))
+ if (seat->second.seatInfo->m_flags && !(seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_UNK11))
unit->addUnitState(UNIT_STAT_ONVEHICLE);
unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
@@ -319,7 +319,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
if (me->GetTypeId() == TYPEID_UNIT
&& unit->GetTypeId() == TYPEID_PLAYER
- && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) // not right
+ && seat->first == 0 && seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
{
if (!me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
ASSERT(false);
@@ -391,7 +391,7 @@ void Vehicle::RemovePassenger(Unit *unit)
if (me->GetTypeId() == TYPEID_UNIT
&& unit->GetTypeId() == TYPEID_PLAYER
- && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800)
+ && seat->first == 0 && seat->second.seatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
{
me->RemoveCharmedBy(unit);
diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h
index 23872483637..43c0b114d4f 100644
--- a/src/server/game/Entities/Vehicle/Vehicle.h
+++ b/src/server/game/Entities/Vehicle/Vehicle.h
@@ -33,6 +33,25 @@ enum PowerType
POWER_BLOOD = 141
};
+enum VehicleFlags
+{
+ VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable
+ VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800, // Lua_IsVehicleAimPowerAdjustable
+ VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2
+};
+
+enum VehicleSeatFlags
+{
+ VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden
+ VEHICLE_SEAT_FLAG_UNK11 = 0x00000400,
+ VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
+ VEHICLE_SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle?
+ VEHICLE_SEAT_FLAG_USABLE = 0x02000000, // Lua_CanExitVehicle
+ VEHICLE_SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats
+ VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI
+};
+
+
struct VehicleSeat
{
explicit VehicleSeat(VehicleSeatEntry const *_seatInfo) : seatInfo(_seatInfo), passenger(NULL) {}
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 219a696526b..765599d6711 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -442,7 +442,7 @@ void ObjectMgr::LoadCreatureLocales()
CreatureLocale& data = mCreatureLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
std::string str = fields[1 + 2 * (i - 1)].GetString();
@@ -483,7 +483,7 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
GossipMenuItemsLocale& data = mGossipMenuItemsLocaleMap[MAKE_PAIR32(menuId,id)];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
std::string str = fields[2 + 2 * (i - 1)].GetString();
@@ -518,7 +518,7 @@ void ObjectMgr::LoadPointOfInterestLocales()
PointOfInterestLocale& data = mPointOfInterestLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
std::string str = fields[i].GetString();
AddLocaleString(str, LocaleConstant(i), data.IconName);
@@ -1954,7 +1954,7 @@ void ObjectMgr::LoadItemLocales()
ItemLocale& data = mItemLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
std::string str = fields[1 + 2 * (i - 1)].GetString();
@@ -2450,7 +2450,7 @@ void ObjectMgr::LoadItemSetNameLocales()
ItemSetNameLocale& data = mItemSetNameLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
std::string str = fields[i].GetString();
AddLocaleString(str, LocaleConstant(i), data.Name);
@@ -4318,7 +4318,7 @@ void ObjectMgr::LoadQuests()
if (!qinfo->ReqCreatureOrGOId[j])
{
bool found = false;
- for (uint8 k = 0; k < 3; ++k)
+ for (uint8 k = 0; k < MAX_SPELL_EFFECTS; ++k)
{
if ((spellInfo->Effect[k] == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k]) == qinfo->QuestId) ||
spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT)
@@ -4591,7 +4591,7 @@ void ObjectMgr::LoadQuests()
if (!spellInfo)
continue;
- for (uint8 j = 0; j < 3; ++j)
+ for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE)
continue;
@@ -4648,7 +4648,7 @@ void ObjectMgr::LoadQuestLocales()
QuestLocale& data = mQuestLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
std::string str = fields[1 + 11 * (i - 1)].GetString();
@@ -5087,7 +5087,7 @@ void ObjectMgr::LoadEventScripts()
SpellEntry const * spell = sSpellStore.LookupEntry(i);
if (spell)
{
- for (uint8 j=0; j<3; ++j)
+ for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT)
{
@@ -5326,7 +5326,7 @@ void ObjectMgr::LoadPageTextLocales()
PageTextLocale& data = mPageTextLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
std::string str = fields[i].GetString();
AddLocaleString(str, LocaleConstant(i), data.Text);
@@ -5417,7 +5417,7 @@ void ObjectMgr::LoadGossipText()
GossipText& gText = mGossipText[Text_ID];
- for (int i=0; i< 8; i++)
+ for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++)
{
gText.Options[i].Text_0 = fields[cic++].GetString();
gText.Options[i].Text_1 = fields[cic++].GetString();
@@ -5425,7 +5425,7 @@ void ObjectMgr::LoadGossipText()
gText.Options[i].Language = fields[cic++].GetUInt32();
gText.Options[i].Probability = fields[cic++].GetFloat();
- for (uint8 j=0; j < 3; ++j)
+ for (uint8 j=0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
{
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt32();
gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt32();
@@ -5466,10 +5466,10 @@ void ObjectMgr::LoadNpcTextLocales()
NpcTextLocale& data = mNpcTextLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
LocaleConstant locale = (LocaleConstant) i;
- for (uint8 j = 0; j < 8; ++j)
+ for (uint8 j = 0; j < MAX_LOCALES; ++j)
{
std::string str0 = fields[1 + 8 * 2 * (i - 1) + 2 * j].GetString();
AddLocaleString(str0, locale, data.Text_0[j]);
@@ -6527,15 +6527,15 @@ void ObjectMgr::LoadGameObjectLocales()
GameObjectLocale& data = mGameObjectLocaleMap[entry];
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
std::string str = fields[i].GetString();
AddLocaleString(str, LocaleConstant(i), data.Name);
}
- for (uint8 i = 1; i < MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
{
- std::string str = fields[i + (MAX_LOCALE - 1)].GetString();
+ std::string str = fields[i + (TOTAL_LOCALES - 1)].GetString();
AddLocaleString(str, LocaleConstant(i), data.CastBarCaption);
}
@@ -7979,7 +7979,7 @@ bool ObjectMgr::LoadTrinityStrings(char const* table, int32 min_value, int32 max
data.Content.resize(1);
++count;
- for (uint8 i = 0; i < MAX_LOCALE; ++i)
+ for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
std::string str = fields[i + 1].GetString();
AddLocaleString(str, LocaleConstant(i), data.Content);
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index c016f50ab9c..08c3f181c4b 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -223,7 +223,7 @@ void ScriptMgr::FillSpellSummary()
if (!pTempSpell)
continue;
- for (uint32 j = 0; j < 3; ++j)
+ for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
//Spell targets self
if (pTempSpell->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER)
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index c9831f926d9..34963c9bf12 100644
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -967,13 +967,13 @@ void WorldSession::HandleTutorialFlag(WorldPacket & recv_data)
void WorldSession::HandleTutorialClear(WorldPacket & /*recv_data*/)
{
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_CHARACTER_TUTORIAL_VALUES; ++i)
SetTutorialInt(i, 0xFFFFFFFF);
}
void WorldSession::HandleTutorialReset(WorldPacket & /*recv_data*/)
{
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_CHARACTER_TUTORIAL_VALUES; ++i)
SetTutorialInt(i, 0x00000000);
}
diff --git a/src/server/game/Server/Protocol/Handlers/NPCHandler.h b/src/server/game/Server/Protocol/Handlers/NPCHandler.h
index 00edb9abeab..2c969e5fd02 100644
--- a/src/server/game/Server/Protocol/Handlers/NPCHandler.h
+++ b/src/server/game/Server/Protocol/Handlers/NPCHandler.h
@@ -49,18 +49,22 @@ struct QEmote
uint32 _Delay;
};
+#define MAX_GOSSIP_TEXT_EMOTES 3
+
struct GossipTextOption
{
std::string Text_0;
std::string Text_1;
uint32 Language;
float Probability;
- QEmote Emotes[3];
+ QEmote Emotes[MAX_GOSSIP_TEXT_EMOTES];
};
+#define MAX_GOSSIP_TEXT_OPTIONS 8
+
struct GossipText
{
- GossipTextOption Options[8];
+ GossipTextOption Options[MAX_GOSSIP_TEXT_OPTIONS];
};
struct PageTextLocale
diff --git a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
index 78694992bd4..fa01bc44671 100644
--- a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
@@ -264,7 +264,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
if (pet->ToCreature()->GetGlobalCooldown() > 0)
return;
- for (uint32 i = 0; i < 3; ++i)
+ for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_AREA_ENEMY_SRC || spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_AREA_ENEMY_DST || spellInfo->EffectImplicitTargetA[i] == TARGET_DEST_DYNOBJ_ENEMY)
return;
diff --git a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
index 85aa0e55e64..4a1a1ef8864 100644
--- a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
@@ -195,7 +195,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket & recv_data)
data << float(ci->ModHealth); // dmg/hp modifier
data << float(ci->ModMana); // dmg/mana modifier
data << uint8(ci->RacialLeader);
- for (uint32 i = 0; i < 6; ++i)
+ for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
data << uint32(ci->questItems[i]); // itemId[6], quest drop
data << uint32(ci->movementId); // CreatureMovementInfo.dbc
SendPacket(&data);
@@ -252,7 +252,7 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recv_data)
data << info->unk1; // 2.0.3, string
data.append(info->raw.data, 24);
data << float(info->size); // go size
- for (uint32 i = 0; i < 6; ++i)
+ for (uint32 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i)
data << uint32(info->questItems[i]); // itemId[6], quest drop
SendPacket(&data);
sLog.outDebug("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
@@ -337,7 +337,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
if (!pGossip)
{
- for (uint32 i = 0; i < 8; ++i)
+ for (uint32 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << float(0);
data << "Greetings $N";
@@ -353,8 +353,8 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
}
else
{
- std::string Text_0[8], Text_1[8];
- for (int i = 0; i < 8; ++i)
+ std::string Text_0[MAX_LOCALES], Text_1[MAX_LOCALES];
+ for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
Text_0[i]=pGossip->Options[i].Text_0;
Text_1[i]=pGossip->Options[i].Text_1;
@@ -365,7 +365,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
{
if (NpcTextLocale const *nl = sObjectMgr.GetNpcTextLocale(textID))
{
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_LOCALES; ++i)
{
sObjectMgr.GetLocaleString(nl->Text_0[i], loc_idx, Text_0[i]);
sObjectMgr.GetLocaleString(nl->Text_1[i], loc_idx, Text_1[i]);
@@ -373,7 +373,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
}
}
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
{
data << pGossip->Options[i].Probability;
@@ -389,7 +389,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data)
data << pGossip->Options[i].Language;
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j)
{
data << pGossip->Options[i].Emotes[j]._Delay;
data << pGossip->Options[i].Emotes[j]._Emote;
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index cdd8470854d..db0b1608733 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -666,7 +666,7 @@ void WorldSession::SendAccountDataTimes(uint32 mask)
void WorldSession::LoadTutorialsData()
{
- for (int aX = 0 ; aX < 8 ; ++aX)
+ for (int aX = 0 ; aX < MAX_CHARACTER_TUTORIAL_VALUES ; ++aX)
m_Tutorials[ aX ] = 0;
QueryResult result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId());
@@ -677,7 +677,7 @@ void WorldSession::LoadTutorialsData()
{
Field *fields = result->Fetch();
- for (int iI = 0; iI < 8; ++iI)
+ for (int iI = 0; iI < MAX_CHARACTER_TUTORIAL_VALUES; ++iI)
m_Tutorials[iI] = fields[iI].GetUInt32();
}
while (result->NextRow());
@@ -687,8 +687,8 @@ void WorldSession::LoadTutorialsData()
void WorldSession::SendTutorialsData()
{
- WorldPacket data(SMSG_TUTORIAL_FLAGS, 4*8);
- for (uint32 i = 0; i < 8; ++i)
+ WorldPacket data(SMSG_TUTORIAL_FLAGS, 4 * MAX_CHARACTER_TUTORIAL_VALUES);
+ for (uint32 i = 0; i < MAX_CHARACTER_TUTORIAL_VALUES; ++i)
data << m_Tutorials[i];
SendPacket(&data);
}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 8bcf0c1eccf..1e29b37db6d 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -859,7 +859,7 @@ class WorldSession
LocaleConstant m_sessionDbLocaleIndex;
uint32 m_latency;
AccountData m_accountData[NUM_ACCOUNT_DATA_TYPES];
- uint32 m_Tutorials[8];
+ uint32 m_Tutorials[MAX_CHARACTER_TUTORIAL_VALUES];
bool m_TutorialsChanged;
AddonsList m_addonsList;
uint32 recruiterId;
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index e43ab13d2c0..a87f1105d62 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -889,7 +889,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
time_t mutetime = time_t (fields[7].GetUInt64());
locale = LocaleConstant (fields[8].GetUInt8());
- if (locale >= MAX_LOCALE)
+ if (locale >= TOTAL_LOCALES)
locale = LOCALE_enUS;
uint32 recruiter = fields[9].GetUInt32();
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 5da4ee10464..08830fb7b9a 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -418,12 +418,12 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
if (item_rand_suffix)
{
- for (int k=0; k<MAX_SPELL_EFFECTS; k++)
+ for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; k++)
{
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
if (pEnchant)
{
- for (int t=0; t<MAX_SPELL_EFFECTS; t++)
+ for (int t = 0; t < MAX_ITEM_ENCHANTMENT_EFFECTS; t++)
if (pEnchant->spellid[t] == m_spellProto->Id)
{
amount = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000);
@@ -2525,7 +2525,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) continue;
if (itr->first == spellId || itr->first == spellId2) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
- if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7)))) continue;
+ if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | SPELL_ATTR_UNK7))) continue;
if (spellInfo->Stances & (1<<(GetMiscValue()-1)))
target->CastSpell(target, itr->first, true, NULL, this);
}
@@ -4680,8 +4680,8 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const * aurApp, uint8
}
}
- //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
- if ((GetMiscValue() == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
+ //recalculate current HP/MP after applying aura modifications (only for spells with SPELL_ATTR_UNK4 0x00000010 flag)
+ if ((GetMiscValue() == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & SPELL_ATTR_UNK4))
{
uint32 newHPValue = target->CountPctFromMaxHealth(int32(100.0f * curHPValue / maxHPValue));
target->SetHealth(newHPValue);
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index df7d3b7944b..65549c4a36f 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -243,7 +243,7 @@ struct SpellValue
{
explicit SpellValue(SpellEntry const *proto)
{
- for (uint32 i = 0; i < 3; ++i)
+ for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
EffectBasePoints[i] = proto->EffectBasePoints[i];
MaxAffectedTargets = proto->MaxAffectedTargets;
RadiusMod = 1.0f;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index a18011da109..6c9cbabb01d 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3424,9 +3424,8 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (!pEnchant)
return;
- // Prevent applying enchanements with Use: spell on items that already have a Use: effect, this is usually blocked from client side and
- // can only be bypassed with memory manipulation.
- for (int s = 0; s < 3; ++s)
+ // Prevent applying enchantments with Use: spell on items that already have an Use: effect, client-side check is not enough
+ for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL)
{
@@ -3488,7 +3487,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
// support only enchantings with add socket in this slot
{
bool add_socket = false;
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_ENCHANTMENT_EFFECTS; ++i)
{
if (pEnchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET)
{
@@ -3868,7 +3867,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
// multiple weapon dmg effect workaround
// execute only the last weapon damage
// and handle all effects at once
- for (uint32 j = effIndex + 1; j < 3; ++j)
+ for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
{
switch (m_spellInfo->Effect[j])
{
@@ -4077,7 +4076,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
bool normalized = false;
float weaponDamagePercentMod = 1.0;
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
switch(m_spellInfo->Effect[j])
{
@@ -4122,7 +4121,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, true);
// Sequence is important
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
// We assume that a spell have at most one fixed_bonus
// and at most one weaponDamagePercentMod
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 3dd41cce6cd..6c415278ee8 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -514,7 +514,7 @@ SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo)
{
bool food = false;
bool drink = false;
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch(spellInfo->EffectApplyAuraName[i])
{
@@ -650,7 +650,7 @@ SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo)
break;
}
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA)
{
@@ -869,7 +869,7 @@ bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) con
if (spellTriggeredProto)
{
// non-positive targets of main spell return early
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!spellTriggeredProto->Effect[i])
continue;
@@ -909,7 +909,7 @@ bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) con
if (spellproto->EffectImplicitTargetA[effIndex] != TARGET_UNIT_CASTER)
return false;
// but not this if this first effect (didn't find better check)
- if (spellproto->Attributes & 0x4000000 && effIndex == 0)
+ if (spellproto->Attributes & SPELL_ATTR_NEGATIVE_1 && effIndex == 0)
return false;
break;
case SPELL_AURA_MECHANIC_IMMUNITY:
@@ -1010,7 +1010,7 @@ bool SpellMgr::_isPositiveSpell(uint32 spellId, bool deep) const
// spells with at least one negative effect are considered negative
// some self-applied spells have negative effects but in self casting case negative check ignored.
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (!_isPositiveEffect(spellId, i, deep))
return false;
return true;
@@ -1172,7 +1172,7 @@ void SpellMgr::LoadSpellTargetPositions()
}
bool found = false;
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_DST_DB || spellInfo->EffectImplicitTargetB[i] == TARGET_DST_DB)
{
@@ -1210,7 +1210,7 @@ void SpellMgr::LoadSpellTargetPositions()
continue;
bool found = false;
- for (int j = 0; j < 3; ++j)
+ for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
switch(spellInfo->EffectImplicitTargetA[j])
{
@@ -1711,7 +1711,7 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
return false;
// All stance spells. if any better way, change it.
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch(spellInfo->SpellFamilyName)
{
@@ -1927,7 +1927,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell
return spellInfo;
bool needRankSelection = false;
- for (int i=0; i<3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (IsPositiveEffect(spellInfo->Id, i) && (
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
@@ -2375,7 +2375,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const *spellInfo, Player *pl, bool msg)
bool need_check_reagents = false;
// check effects
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch (spellInfo->Effect[i])
{
@@ -2439,7 +2439,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const *spellInfo, Player *pl, bool msg)
if (need_check_reagents)
{
- for (uint8 j = 0; j < 8; ++j)
+ for (uint8 j = 0; j < MAX_SPELL_REAGENTS; ++j)
{
if (spellInfo->Reagent[j] > 0 && !ObjectMgr::GetItemPrototype(spellInfo->Reagent[j]))
{
@@ -2674,7 +2674,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell
AreaGroupEntry const* groupEntry = sAreaGroupStore.LookupEntry(spellInfo->AreaGroupId);
while (groupEntry)
{
- for (uint8 i = 0; i < 6; ++i)
+ for (uint8 i = 0; i < MAX_GROUP_AREA_IDS; ++i)
if (groupEntry->AreaId[i] == zone_id || groupEntry->AreaId[i] == area_id)
found = true;
if (found || !groupEntry->nextGroup)
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index ede63c300c6..c9f54ee9993 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -252,7 +252,7 @@ inline float GetSpellMaxRange(uint32 id, bool positive)
inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect)
{
- for (int i= 0; i < 3; ++i)
+ for (int i= 0; i < MAX_SPELL_EFFECTS; ++i)
if (SpellEffects(spellInfo->Effect[i]) == effect)
return true;
return false;
@@ -260,7 +260,7 @@ inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect)
inline bool IsSpellHaveAura(SpellEntry const *spellInfo, AuraType aura)
{
- for (int i= 0; i < 3; ++i)
+ for (int i= 0; i < MAX_SPELL_EFFECTS; ++i)
if (AuraType(spellInfo->EffectApplyAuraName[i]) == aura)
return true;
return false;
@@ -386,7 +386,7 @@ inline bool IsPositionTarget(uint32 target)
inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo)
{
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
uint32 targetA = spellInfo->EffectImplicitTargetA[i];
if (targetA && !IsCasterSourceTarget(targetA))
@@ -518,7 +518,7 @@ inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo)
uint32 mask = 0;
if (spellInfo->Mechanic)
mask |= 1<<spellInfo->Mechanic;
- for (int i=0; i< 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (spellInfo->Effect[i] && spellInfo->EffectMechanic[i])
mask |= 1<<spellInfo->EffectMechanic[i];
return mask;
@@ -1352,7 +1352,7 @@ class SpellMgr
inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo)
{
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (uint32 target = spellInfo->EffectImplicitTargetA[i])
if (!IsCasterSourceTarget(target))
return false;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index a42d20a4048..065418bfd6b 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1740,9 +1740,9 @@ void World::DetectDBCLang()
{
uint8 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255);
- if (m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE)
+ if (m_lang_confid != 255 && m_lang_confid >= TOTAL_LOCALES)
{
- sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)",MAX_LOCALE);
+ sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", TOTAL_LOCALES);
m_lang_confid = LOCALE_enUS;
}
@@ -1750,8 +1750,8 @@ void World::DetectDBCLang()
std::string availableLocalsStr;
- uint8 default_locale = MAX_LOCALE;
- for (uint8 i = default_locale-1; i < MAX_LOCALE; --i) // -1 will be 255 due to uint8
+ uint8 default_locale = TOTAL_LOCALES;
+ for (uint8 i = default_locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8
{
if (strlen(race->name[i]) > 0) // check by race names
{
@@ -1762,13 +1762,13 @@ void World::DetectDBCLang()
}
}
- if (default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE &&
+ if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES &&
(m_availableDbcLocaleMask & (1 << m_lang_confid)))
{
default_locale = m_lang_confid;
}
- if (default_locale >= MAX_LOCALE)
+ if (default_locale >= TOTAL_LOCALES)
{
sLog.outError("Unable to determine your DBC Locale! (corrupt DBC?)");
exit(1);
diff --git a/src/server/shared/Common.cpp b/src/server/shared/Common.cpp
index 49a45d67131..6393dfa8ed4 100644
--- a/src/server/shared/Common.cpp
+++ b/src/server/shared/Common.cpp
@@ -20,7 +20,7 @@
#include "Common.h"
-char const* localeNames[MAX_LOCALE] = {
+char const* localeNames[TOTAL_LOCALES] = {
"enUS",
"koKR",
"frFR",
@@ -34,7 +34,7 @@ char const* localeNames[MAX_LOCALE] = {
LocaleConstant GetLocaleByName(const std::string& name)
{
- for (uint32 i = 0; i < MAX_LOCALE; ++i)
+ for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
if(name==localeNames[i])
return LocaleConstant(i);
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
index d08ccaca86b..c6b82d22314 100644
--- a/src/server/shared/Common.h
+++ b/src/server/shared/Common.h
@@ -178,10 +178,13 @@ enum LocaleConstant
LOCALE_ruRU = 8
};
-const uint8 MAX_LOCALE = 9;
+const uint8 TOTAL_LOCALES = 9;
const LocaleConstant DEFAULT_LOCALE = LOCALE_enUS;
-extern char const* localeNames[MAX_LOCALE];
+#define MAX_LOCALES 8
+#define MAX_CHARACTER_TUTORIAL_VALUES 8
+
+extern char const* localeNames[TOTAL_LOCALES];
LocaleConstant GetLocaleByName(const std::string& name);