Merge pull request #2721 from Chaplain/cleanup

Core: Clean up here and there.
This commit is contained in:
QAston
2011-08-23 21:01:54 -07:00
13 changed files with 18 additions and 20 deletions
+2 -2
View File
@@ -235,7 +235,7 @@ void SmartAI::EndPath(bool fail)
} }
}else }else
{ {
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); iter++) for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{ {
if (GetScript()->IsPlayer((*iter))) if (GetScript()->IsPlayer((*iter)))
{ {
@@ -401,7 +401,7 @@ bool SmartAI::IsEscortInvokerInRange()
} }
}else }else
{ {
for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); iter++) for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter)
{ {
if (GetScript()->IsPlayer((*iter))) if (GetScript()->IsPlayer((*iter)))
{ {
@@ -1153,7 +1153,6 @@ struct SmartScriptHolder
runOnce = false; runOnce = false;
link = 0; link = 0;
entryOrGuid = 0; entryOrGuid = 0;
link = 0;
event_id = 0; event_id = 0;
enableTimed = false; enableTimed = false;
} }
@@ -1664,7 +1664,7 @@ void Battleground::SendWarningToAll(int32 entry, ...)
data << (uint32)1; data << (uint32)1;
data << (uint8)0; data << (uint8)0;
data << (uint64)0; data << (uint64)0;
data << (uint32)(strlen(msg.c_str())+1); data << (uint32)(msg.length() + 1);
data << msg.c_str(); data << msg.c_str();
data << (uint8)0; data << (uint8)0;
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -261,7 +261,7 @@ void BattlegroundSA::StartShips()
for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++) for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++)
{ {
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end();itr++) for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{ {
if (Player* p = ObjectAccessor::FindPlayer(itr->first)) if (Player* p = ObjectAccessor::FindPlayer(itr->first))
{ {
+2 -2
View File
@@ -653,7 +653,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
continue; continue;
bool match = false; bool match = false;
if (strlen(table[i].Name) > strlen(cmd.c_str())) if (strlen(table[i].Name) > cmd.length())
{ {
for (uint32 j = 0; table[j].Name != NULL; ++j) for (uint32 j = 0; table[j].Name != NULL; ++j)
{ {
@@ -694,7 +694,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
SetSentErrorMessage(false); SetSentErrorMessage(false);
// table[i].Name == "" is special case: send original command to handler // table[i].Name == "" is special case: send original command to handler
if ((table[i].Handler)(this, strlen(table[i].Name) != 0 ? text : oldtext)) if ((table[i].Handler)(this, table[i].Name[0] != '\0' ? text : oldtext))
{ {
if (table[i].SecurityLevel > SEC_PLAYER) if (table[i].SecurityLevel > SEC_PLAYER)
{ {
+1 -1
View File
@@ -301,7 +301,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
bool noPriorityTargetFound = false; bool noPriorityTargetFound = false;
std::list<HostileReference*>::const_iterator lastRef = iThreatList.end(); std::list<HostileReference*>::const_iterator lastRef = iThreatList.end();
lastRef--; --lastRef;
for (std::list<HostileReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) for (std::list<HostileReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;)
{ {
+2 -2
View File
@@ -239,7 +239,7 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt
if (FILE* f = fopen(dbcFilename.c_str(), "rb")) if (FILE* f = fopen(dbcFilename.c_str(), "rb"))
{ {
char buf[100]; char buf[100];
snprintf(buf, 100, " (exists, but has %d fields instead of " SIZEFMTD ") Possible wrong client version.", storage.GetFieldCount(), strlen(storage.GetFormat())); snprintf(buf, 100, " (exists, but has %u fields instead of " SIZEFMTD ") Possible wrong client version.", storage.GetFieldCount(), strlen(storage.GetFormat()));
errors.push_back(dbcFilename + buf); errors.push_back(dbcFilename + buf);
fclose(f); fclose(f);
} }
@@ -363,7 +363,7 @@ void LoadDBCStores(const std::string& dataPath)
// fill data // fill data
for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i) for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i)
if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i)) if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i))
sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = MapDifficulty(entry->resetTime, entry->maxPlayers, strlen(entry->areaTriggerText)>0); sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = MapDifficulty(entry->resetTime, entry->maxPlayers, entry->areaTriggerText[0] != '\0');
sMapDifficultyStore.Clear(); sMapDifficultyStore.Clear();
LoadDBC(availableDbcLocales, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc");
+1 -1
View File
@@ -1003,7 +1003,7 @@ void Group::EndRoll(Loot *pLoot)
itr = RollId.begin(); itr = RollId.begin();
} }
else else
itr++; ++itr;
} }
} }
@@ -678,7 +678,7 @@ void WorldSession::HandlePetAbandon(WorldPacket & recv_data)
if (pet->GetGUID() == _player->GetPetGUID()) if (pet->GetGUID() == _player->GetPetGUID())
{ {
uint32 feelty = pet->GetPower(POWER_HAPPINESS); uint32 feelty = pet->GetPower(POWER_HAPPINESS);
pet->SetPower(POWER_HAPPINESS , (feelty-50000) > 0 ?(feelty-50000) : 0); pet->SetPower(POWER_HAPPINESS , feelty > 50000 ? (feelty-50000) : 0);
} }
_player->RemovePet((Pet*)pet, PET_SAVE_AS_DELETED); _player->RemovePet((Pet*)pet, PET_SAVE_AS_DELETED);
-1
View File
@@ -2497,7 +2497,6 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
// Search for ghoul if our ghoul or dead body not valid unit target // Search for ghoul if our ghoul or dead body not valid unit target
if (!(m_targets.GetUnitTarget() && ((m_targets.GetUnitTarget()->GetEntry() == 26125 && m_targets.GetUnitTarget()->GetOwnerGUID() == m_caster->GetGUID()) if (!(m_targets.GetUnitTarget() && ((m_targets.GetUnitTarget()->GetEntry() == 26125 && m_targets.GetUnitTarget()->GetOwnerGUID() == m_caster->GetGUID())
|| (m_targets.GetUnitTarget()->getDeathState() == CORPSE || (m_targets.GetUnitTarget()->getDeathState() == CORPSE
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()
&& m_targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT && m_targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT
&& !(m_targets.GetUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) && !(m_targets.GetUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId())))) && m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()))))
+1 -1
View File
@@ -999,7 +999,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
} }
case 47170: // Impale Leviroth case 47170: // Impale Leviroth
{ {
if (!unitTarget && unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95)) if (!unitTarget || (unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95)))
return; return;
m_caster->DealDamage(unitTarget, unitTarget->CountPctFromMaxHealth(93)); m_caster->DealDamage(unitTarget, unitTarget->CountPctFromMaxHealth(93));
+5 -5
View File
@@ -176,7 +176,7 @@ bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint
return true; // not an error return true; // not an error
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
snprintf(chritem, 20, "%d", newGuid); snprintf(chritem, 20, "%u", newGuid);
return changenth(str, n, chritem, false, nonzero); return changenth(str, n, chritem, false, nonzero);
} }
@@ -189,7 +189,7 @@ bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, u
return true; // not an error return true; // not an error
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
snprintf(chritem, 20, "%d", newGuid); snprintf(chritem, 20, "%u", newGuid);
return changetoknth(str, n, chritem, false, nonzero); return changetoknth(str, n, chritem, false, nonzero);
} }
@@ -421,9 +421,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// name encoded or empty // name encoded or empty
snprintf(newguid, 20, "%d", guid); snprintf(newguid, 20, "%u", guid);
snprintf(chraccount, 20, "%d", account); snprintf(chraccount, 20, "%u", account);
snprintf(newpetid, 20, "%d", sObjectMgr->GeneratePetNumber()); snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber());
snprintf(lastpetid, 20, "%s", ""); snprintf(lastpetid, 20, "%s", "");
std::map<uint32, uint32> items; std::map<uint32, uint32> items;
+1 -1
View File
@@ -1754,7 +1754,7 @@ void World::DetectDBCLang()
uint8 default_locale = TOTAL_LOCALES; uint8 default_locale = TOTAL_LOCALES;
for (uint8 i = default_locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8 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 if (race->name[i][0] != '\0') // check by race names
{ {
default_locale = i; default_locale = i;
m_availableDbcLocaleMask |= (1 << i); m_availableDbcLocaleMask |= (1 << i);