Magic numbers cleanup:

- Replace many magic numbers with constants
- Use enum for vehicle flags/seat flags
- Correct structure for ItemRandomSuffixEntry

--HG--
branch : trunk
This commit is contained in:
Shocker
2010-09-28 08:21:51 +03:00
parent 192e972a59
commit 78803c9f09
44 changed files with 245 additions and 194 deletions
+4 -4
View File
@@ -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)
{
+2 -2
View File
@@ -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)
{
+4 -4
View File
@@ -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)
{
+12 -12
View File
@@ -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;