mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Change emptiness checks to empty() from size() [clang-tidy]
This has two benefits, it's clear what we are checking and size() isn't always constant time, where empty is (performance!)
This commit is contained in:
parent
c43d436b1f
commit
cdbeb24a05
@ -939,7 +939,7 @@ EQApplicationPacket *EQStream::PopPacket()
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
if (InboundQueue.size()) {
|
||||
if (!InboundQueue.empty()) {
|
||||
std::vector<EQRawApplicationPacket *>::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<EQRawApplicationPacket *>::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<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
||||
p=*itr;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ std::shared_ptr<EQStream> EQStreamFactory::Pop()
|
||||
{
|
||||
std::shared_ptr<EQStream> s = nullptr;
|
||||
MNewStreams.lock();
|
||||
if (NewStreams.size()) {
|
||||
if (!NewStreams.empty()) {
|
||||
s = NewStreams.front();
|
||||
NewStreams.pop();
|
||||
s->PutInUse();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -227,7 +227,7 @@ bool EQWParser::dosub(const char * subname, const std::vector<std::string> &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())));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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()));
|
||||
|
||||
@ -5656,7 +5656,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
|
||||
{
|
||||
std::deque<int> pathlist = zone->pathing->FindRoute(Start, End);
|
||||
|
||||
if (pathlist.size() == 0)
|
||||
if (pathlist.empty())
|
||||
{
|
||||
EQApplicationPacket outapp(OP_FindPersonReply, 0);
|
||||
QueuePacket(&outapp);
|
||||
|
||||
@ -278,7 +278,7 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
if(args && args->size())
|
||||
if(args && !args->empty())
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator i = args->begin(); i != args->end(); ++i)
|
||||
{
|
||||
|
||||
@ -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<int> 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)];
|
||||
|
||||
@ -137,7 +137,7 @@ void Mob::CalculateNewFearpoint()
|
||||
|
||||
std::deque<int> 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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<Timer>(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();
|
||||
|
||||
@ -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];
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ std::deque<int> 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<int> 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<int> 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.");
|
||||
|
||||
|
||||
@ -714,7 +714,7 @@ void ClientTaskState::EnableTask(int characterID, int taskCount, int *tasks) {
|
||||
for(unsigned int i=0; i<EnabledTasks.size(); i++)
|
||||
Log.Out(Logs::General, Logs::Tasks, "[UPDATE] %i", EnabledTasks[i]);
|
||||
|
||||
if(tasksEnabled.size() == 0 )
|
||||
if(tasksEnabled.empty() )
|
||||
return;
|
||||
|
||||
std::stringstream queryStream("REPLACE INTO character_enabledtasks (charid, taskid) VALUES ");
|
||||
@ -758,7 +758,7 @@ void ClientTaskState::DisableTask(int charID, int taskCount, int *taskList) {
|
||||
for(unsigned int i=0; i<EnabledTasks.size(); i++)
|
||||
Log.Out(Logs::General, Logs::Tasks, "[UPDATE] %i", EnabledTasks[i]);
|
||||
|
||||
if(tasksDisabled.size() == 0)
|
||||
if(tasksDisabled.empty())
|
||||
return;
|
||||
|
||||
std::stringstream queryStream(StringFormat("DELETE FROM character_enabledtasks WHERE charid = %i AND (", charID));
|
||||
@ -848,7 +848,7 @@ int TaskManager::FirstTaskInSet(int TaskSetID) {
|
||||
|
||||
if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return 0;
|
||||
|
||||
if(TaskSets[TaskSetID].size() == 0) return 0;
|
||||
if(TaskSets[TaskSetID].empty()) return 0;
|
||||
|
||||
std::vector<int>::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<TaskSets[TaskSetID].size(); i++) {
|
||||
if(TaskSets[TaskSetID][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.
|
||||
|
||||
|
||||
@ -672,13 +672,13 @@ void Zone::Shutdown(bool quite)
|
||||
entity_list.StopMobAI();
|
||||
|
||||
std::map<uint32,NPCType *>::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<uint32,LDoNTrapTemplate*>::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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user