diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index 9655681b6..00f5b1b9a 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -939,7 +939,7 @@ EQApplicationPacket *EQStream::PopPacket() EQRawApplicationPacket *p=nullptr; MInboundQueue.lock(); - if (InboundQueue.size()) { + if (!InboundQueue.empty()) { std::vector::iterator itr=InboundQueue.begin(); p=*itr; InboundQueue.erase(itr); @@ -964,7 +964,7 @@ EQRawApplicationPacket *EQStream::PopRawPacket() EQRawApplicationPacket *p=nullptr; MInboundQueue.lock(); - if (InboundQueue.size()) { + if (!InboundQueue.empty()) { std::vector::iterator itr=InboundQueue.begin(); p=*itr; InboundQueue.erase(itr); @@ -991,7 +991,7 @@ EQRawApplicationPacket *EQStream::PeekPacket() EQRawApplicationPacket *p=nullptr; MInboundQueue.lock(); - if (InboundQueue.size()) { + if (!InboundQueue.empty()) { std::vector::iterator itr=InboundQueue.begin(); p=*itr; } diff --git a/common/eq_stream_factory.cpp b/common/eq_stream_factory.cpp index bc435ef51..6be3017f0 100644 --- a/common/eq_stream_factory.cpp +++ b/common/eq_stream_factory.cpp @@ -120,7 +120,7 @@ std::shared_ptr EQStreamFactory::Pop() { std::shared_ptr s = nullptr; MNewStreams.lock(); - if (NewStreams.size()) { + if (!NewStreams.empty()) { s = NewStreams.front(); NewStreams.pop(); s->PutInUse(); diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index dc96f31e9..47e0eb726 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -2326,7 +2326,7 @@ void Client::SendFriends() { std::string Client::MailBoxName() { - if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1))) + if((Characters.empty()) || (CurrentMailBox > (Characters.size() - 1))) { Log.Out(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i", CurrentMailBox, Characters.size()); @@ -2343,7 +2343,7 @@ std::string Client::MailBoxName() { int Client::GetCharID() { - if(Characters.size() == 0) + if(Characters.empty()) return 0; return Characters[0].CharID; diff --git a/world/eqw_parser.cpp b/world/eqw_parser.cpp index 79e73ac22..e01f3db3b 100644 --- a/world/eqw_parser.cpp +++ b/world/eqw_parser.cpp @@ -227,7 +227,7 @@ bool EQWParser::dosub(const char * subname, const std::vector &args ENTER; // everything created after here SAVETMPS; // ...is a temporary variable PUSHMARK(SP); // remember the stack pointer - if(args.size() > 0) + if(!args.empty()) { for (auto i = args.begin(); i != args.end(); ++i) { /* push the arguments onto the perl stack */ XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length()))); diff --git a/zone/aa.cpp b/zone/aa.cpp index 58d72af55..7828d6654 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -1141,7 +1141,7 @@ void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) { } //make sure it is not a passive - if(rank->effects.size() > 0) { + if(!rank->effects.empty()) { return; } diff --git a/zone/client.cpp b/zone/client.cpp index 7940cf266..77e5e78d6 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -5333,7 +5333,7 @@ void Client::SendRewards() rewards.push_back(cr); } - if(rewards.size() == 0) + if(rewards.empty()) return; EQApplicationPacket *vetapp = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(InternalVeteranReward) * rewards.size())); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index de35ccf2b..5d11f315e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -5656,7 +5656,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) { std::deque pathlist = zone->pathing->FindRoute(Start, End); - if (pathlist.size() == 0) + if (pathlist.empty()) { EQApplicationPacket outapp(OP_FindPersonReply, 0); QueuePacket(&outapp); diff --git a/zone/embperl.cpp b/zone/embperl.cpp index 834a5f0b9..e86a3e187 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -278,7 +278,7 @@ int Embperl::dosub(const char * subname, const std::vector * args, ENTER; SAVETMPS; PUSHMARK(SP); - if(args && args->size()) + if(args && !args->empty()) { for(std::vector::const_iterator i = args->begin(); i != args->end(); ++i) { diff --git a/zone/entity.cpp b/zone/entity.cpp index 4d6ca1459..bdf59d8b0 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2702,7 +2702,7 @@ void EntityList::FindPathsToAllNPCs() glm::vec3 Node0 = zone->pathing->GetPathNodeCoordinates(0, false); glm::vec3 Dest(it->second->GetX(), it->second->GetY(), it->second->GetZ()); std::deque Route = zone->pathing->FindRoute(Node0, Dest); - if (Route.size() == 0) + if (Route.empty()) printf("Unable to find a route to %s\n", it->second->GetName()); else printf("Found a route to %s\n", it->second->GetName()); @@ -4503,7 +4503,7 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count) for (int j = 0; j < npc_count; ++j) selection.push_back(j); - while (selection.size() > 0 && count > 0) { + while (!selection.empty() && count > 0) { int k = zone->random.Int(0, selection.size() - 1); counts[selection[k]]++; count--; @@ -4683,7 +4683,7 @@ Mob *EntityList::GetTargetForVirus(Mob *spreader, int range) ++it; } - if(TargetsInRange.size() == 0) + if(TargetsInRange.empty()) return nullptr; return TargetsInRange[zone->random.Int(0, TargetsInRange.size() - 1)]; diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index bbcf4d4c6..aa369b4c9 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -137,7 +137,7 @@ void Mob::CalculateNewFearpoint() std::deque Route = zone->pathing->FindRoute(CurrentPosition, Loc); - if(Route.size() > 0) + if(!Route.empty()) { m_FearWalkTarget = glm::vec3(Loc.x, Loc.y, Loc.z); currently_fleeing = true; diff --git a/zone/merc.cpp b/zone/merc.cpp index 840c8ac38..369a8ef4f 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1747,7 +1747,7 @@ void Merc::AI_Start(int32 iMoveDelay) { if (!pAIControlled) return; - if (merc_spells.size() == 0) { + if (merc_spells.empty()) { AIautocastspell_timer->SetTimer(1000); AIautocastspell_timer->Disable(); } else { @@ -4688,7 +4688,7 @@ bool Merc::LoadMercSpells() { return a.slot > b.slot; }); - if (merc_spells.size() == 0) + if (merc_spells.empty()) AIautocastspell_timer->Disable(); else { HasAISpell = true; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index b640da2b0..7958035ab 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -516,7 +516,7 @@ void NPC::AI_Start(uint32 iMoveDelay) { if (!pAIControlled) return; - if (AIspells.size() == 0) { + if (AIspells.empty()) { AIautocastspell_timer = std::unique_ptr(new Timer(1000)); AIautocastspell_timer->Disable(); } else { @@ -679,7 +679,7 @@ void Client::AI_SpellCast() spell_to_cast = valid_spells[0]; slot_to_use = slots[0]; } - else if(valid_spells.size() == 0) + else if(valid_spells.empty()) { return; } @@ -2386,7 +2386,7 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { AISpellVar.idle_no_sp_recast_max = (_idle_no_sp_recast_max) ? _idle_no_sp_recast_max : RuleI(Spells, AI_IdleNoSpellMaxRecast); AISpellVar.idle_beneficial_chance = (_idle_beneficial_chance) ? _idle_beneficial_chance : RuleI(Spells, AI_IdleBeneficialChance); - if (AIspells.size() == 0) + if (AIspells.empty()) AIautocastspell_timer->Disable(); else AIautocastspell_timer->Trigger(); diff --git a/zone/net.cpp b/zone/net.cpp index 5c3996959..b173b67a0 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -133,7 +133,7 @@ int main(int argc, char** argv) { worldserver.SetLauncherName(argv[2]); auto zone_port = SplitString(argv[1], ':'); - if(zone_port.size() > 0) { + if(!zone_port.empty()) { z_name = zone_port[0]; } @@ -153,7 +153,7 @@ int main(int argc, char** argv) { worldserver.SetLauncherName(argv[2]); auto zone_port = SplitString(argv[1], ':'); - if(zone_port.size() > 0) { + if(!zone_port.empty()) { z_name = zone_port[0]; } @@ -172,7 +172,7 @@ int main(int argc, char** argv) { worldserver.SetLauncherName("NONE"); auto zone_port = SplitString(argv[1], ':'); - if(zone_port.size() > 0) { + if(!zone_port.empty()) { z_name = zone_port[0]; } diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 8c4b2e605..8c0271c06 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -224,7 +224,7 @@ std::deque PathManager::FindRoute(int startID, int endID) OpenList.push_back(AStarEntry); - while(OpenList.size() > 0) + while(!OpenList.empty()) { // The OpenList is maintained in sorted order, lowest to highest cost. @@ -610,7 +610,7 @@ void PathManager::MeshTest() std::deque Route = FindRoute(PathNodes[i].id, PathNodes[j].id); - if(Route.size() == 0) + if(Route.empty()) { ++NoConnections; printf("FindRoute(%i, %i) **** NO ROUTE FOUND ****\n", PathNodes[i].id, PathNodes[j].id); @@ -637,7 +637,7 @@ void PathManager::SimpleMeshTest() { std::deque Route = FindRoute(PathNodes[0].id, PathNodes[j].id); - if(Route.size() == 0) + if(Route.empty()) { ++NoConnections; printf("FindRoute(%i, %i) **** NO ROUTE FOUND ****\n", PathNodes[0].id, PathNodes[j].id); @@ -683,7 +683,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa { Log.Out(Logs::Detail, Logs::None, "appears to be stuck. Teleporting them to next position.", GetName()); - if(Route.size() == 0) + if(Route.empty()) { Teleport(To); @@ -715,7 +715,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa PathingLastPosition = From; } - if(Route.size() > 0) + if(!Route.empty()) { // If we are already pathing, and the destination is the same as before ... @@ -790,7 +790,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa WaypointChanged = true; // If there are more nodes on the route, return the coords of the next node - if(Route.size() > 0) + if(!Route.empty()) { NextNode = Route.front(); @@ -799,7 +799,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // -1 indicates a teleport to the next node Route.pop_front(); - if(Route.size() == 0) + if(Route.empty()) { Log.Out(Logs::Detail, Logs::None, "Missing node after teleport."); return To; @@ -815,7 +815,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa Route.pop_front(); - if(Route.size() == 0) + if(Route.empty()) return To; NextNode = Route.front(); @@ -965,7 +965,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa WaypointChanged = true; - if(Route.size() > 0) + if(!Route.empty()) { NextNode = Route.front(); @@ -974,7 +974,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // -1 indicates a teleport to the next node Route.pop_front(); - if(Route.size() == 0) + if(Route.empty()) { Log.Out(Logs::Detail, Logs::None, "Missing node after teleport."); return To; @@ -990,7 +990,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa Route.pop_front(); - if(Route.size() == 0) + if(Route.empty()) return To; NextNode = Route.front(); @@ -1061,7 +1061,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa PathingTraversedNodes = 0; - if(Route.size() == 0) + if(Route.empty()) { Log.Out(Logs::Detail, Logs::None, " No route available, running direct."); diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 2c2a1c1b0..8946673a4 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -714,7 +714,7 @@ void ClientTaskState::EnableTask(int characterID, int taskCount, int *tasks) { for(unsigned int i=0; i=MAXTASKSETS)) return 0; - if(TaskSets[TaskSetID].size() == 0) return 0; + if(TaskSets[TaskSetID].empty()) return 0; std::vector::iterator Iterator = TaskSets[TaskSetID].begin(); @@ -865,7 +865,7 @@ int TaskManager::LastTaskInSet(int TaskSetID) { if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0; - if(TaskSets[TaskSetID].size() == 0) return 0; + if(TaskSets[TaskSetID].empty()) return 0; return TaskSets[TaskSetID][TaskSets[TaskSetID].size()-1]; } @@ -874,7 +874,7 @@ int TaskManager::NextTaskInSet(int TaskSetID, int TaskID) { if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0; - if(TaskSets[TaskSetID].size() == 0) return 0; + if(TaskSets[TaskSetID].empty()) return 0; for(unsigned int i=0; i TaskID) return TaskSets[TaskSetID][i]; @@ -927,7 +927,7 @@ void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, i state->EnabledTasks.size()); if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return; - if(TaskSets[TaskSetID].size() > 0) { + if(!TaskSets[TaskSetID].empty()) { // A TaskID of 0 in a TaskSet indicates that all Tasks in the set are enabled for all players. diff --git a/zone/zone.cpp b/zone/zone.cpp index 5523f1e85..6c58bea65 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -672,13 +672,13 @@ void Zone::Shutdown(bool quite) entity_list.StopMobAI(); std::map::iterator itr; - while(zone->npctable.size()) { + while(!zone->npctable.empty()) { itr=zone->npctable.begin(); delete itr->second; zone->npctable.erase(itr); } - while(zone->merctable.size()) { + while(!zone->merctable.empty()) { itr=zone->merctable.begin(); delete itr->second; zone->merctable.erase(itr); @@ -687,7 +687,7 @@ void Zone::Shutdown(bool quite) zone->adventure_entry_list_flavor.clear(); std::map::iterator itr4; - while(zone->ldon_trap_list.size()) + while(!zone->ldon_trap_list.empty()) { itr4 = zone->ldon_trap_list.begin(); delete itr4->second; @@ -1415,7 +1415,7 @@ bool Zone::Depop(bool StartSpawnTimer) { entity_list.Depop(StartSpawnTimer); /* Refresh npctable (cache), getting current info from database. */ - while(npctable.size()) { + while(!npctable.empty()) { itr = npctable.begin(); delete itr->second; npctable.erase(itr);