Core: Clean up here and there.
*replase postfix iterator increment\decrement with prefix in cycles *replase strlen(*char) != 0 with *char[0] != '\0' *replase strlen(rStr.c_str()) with rStr.length()
This commit is contained in:
@@ -235,7 +235,7 @@ void SmartAI::EndPath(bool fail)
|
||||
}
|
||||
}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)))
|
||||
{
|
||||
@@ -401,7 +401,7 @@ bool SmartAI::IsEscortInvokerInRange()
|
||||
}
|
||||
}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)))
|
||||
{
|
||||
|
||||
@@ -1153,7 +1153,6 @@ struct SmartScriptHolder
|
||||
runOnce = false;
|
||||
link = 0;
|
||||
entryOrGuid = 0;
|
||||
link = 0;
|
||||
event_id = 0;
|
||||
enableTimed = false;
|
||||
}
|
||||
|
||||
@@ -1664,7 +1664,7 @@ void Battleground::SendWarningToAll(int32 entry, ...)
|
||||
data << (uint32)1;
|
||||
data << (uint8)0;
|
||||
data << (uint64)0;
|
||||
data << (uint32)(strlen(msg.c_str())+1);
|
||||
data << (uint32)(msg.length() + 1);
|
||||
data << msg.c_str();
|
||||
data << (uint8)0;
|
||||
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 (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))
|
||||
{
|
||||
|
||||
@@ -653,7 +653,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
|
||||
continue;
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -694,7 +694,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
|
||||
|
||||
SetSentErrorMessage(false);
|
||||
// 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)
|
||||
{
|
||||
|
||||
@@ -301,7 +301,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
|
||||
bool noPriorityTargetFound = false;
|
||||
|
||||
std::list<HostileReference*>::const_iterator lastRef = iThreatList.end();
|
||||
lastRef--;
|
||||
--lastRef;
|
||||
|
||||
for (std::list<HostileReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;)
|
||||
{
|
||||
|
||||
@@ -239,7 +239,7 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt
|
||||
if (FILE* f = fopen(dbcFilename.c_str(), "rb"))
|
||||
{
|
||||
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);
|
||||
fclose(f);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
// fill data
|
||||
for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++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();
|
||||
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc");
|
||||
|
||||
@@ -1003,7 +1003,7 @@ void Group::EndRoll(Loot *pLoot)
|
||||
itr = RollId.begin();
|
||||
}
|
||||
else
|
||||
itr++;
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -678,7 +678,7 @@ void WorldSession::HandlePetAbandon(WorldPacket & recv_data)
|
||||
if (pet->GetGUID() == _player->GetPetGUID())
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
if (!(m_targets.GetUnitTarget() && ((m_targets.GetUnitTarget()->GetEntry() == 26125 && m_targets.GetUnitTarget()->GetOwnerGUID() == m_caster->GetGUID())
|
||||
|| (m_targets.GetUnitTarget()->getDeathState() == CORPSE
|
||||
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()
|
||||
&& m_targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT
|
||||
&& !(m_targets.GetUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)
|
||||
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()))))
|
||||
|
||||
@@ -999,7 +999,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
}
|
||||
case 47170: // Impale Leviroth
|
||||
{
|
||||
if (!unitTarget && unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95))
|
||||
if (!unitTarget || (unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95)))
|
||||
return;
|
||||
|
||||
m_caster->DealDamage(unitTarget, unitTarget->CountPctFromMaxHealth(93));
|
||||
|
||||
@@ -176,7 +176,7 @@ bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint
|
||||
return true; // not an error
|
||||
|
||||
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
|
||||
snprintf(chritem, 20, "%d", newGuid);
|
||||
snprintf(chritem, 20, "%u", newGuid);
|
||||
|
||||
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
|
||||
|
||||
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
|
||||
snprintf(chritem, 20, "%d", newGuid);
|
||||
snprintf(chritem, 20, "%u", newGuid);
|
||||
|
||||
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
|
||||
|
||||
snprintf(newguid, 20, "%d", guid);
|
||||
snprintf(chraccount, 20, "%d", account);
|
||||
snprintf(newpetid, 20, "%d", sObjectMgr->GeneratePetNumber());
|
||||
snprintf(newguid, 20, "%u", guid);
|
||||
snprintf(chraccount, 20, "%u", account);
|
||||
snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber());
|
||||
snprintf(lastpetid, 20, "%s", "");
|
||||
|
||||
std::map<uint32, uint32> items;
|
||||
|
||||
@@ -1754,7 +1754,7 @@ void World::DetectDBCLang()
|
||||
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
|
||||
if (race->name[i][0] != '\0') // check by race names
|
||||
{
|
||||
default_locale = i;
|
||||
m_availableDbcLocaleMask |= (1 << i);
|
||||
|
||||
Reference in New Issue
Block a user