mackal

entity "list"

Feb 3rd, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 209.17 KB | None | 0 0
  1. diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp
  2. index 0ce9483..8c6a40e 100644
  3. --- a/zone/MobAI.cpp
  4. +++ b/zone/MobAI.cpp
  5. @@ -371,9 +371,8 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float
  6.  
  7.  
  8.     //Only iterate through NPCs
  9. -   LinkedListIterator<NPC*> iterator(npc_list);
  10. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  11. -       NPC* mob = iterator.GetData();
  12. +   for (auto it = npc_list.begin(); it != npc_list.end(); ++it) {
  13. +       NPC* mob = it->second;
  14.  
  15.         //Since >90% of mobs will always be out of range, try to
  16.         //catch them with simple bounding box checks first. These
  17. diff --git a/zone/aggro.cpp b/zone/aggro.cpp
  18. index b2f5ed7..8fa426a 100644
  19. --- a/zone/aggro.cpp
  20. +++ b/zone/aggro.cpp
  21. @@ -32,23 +32,18 @@ extern Zone* zone;
  22.  //#define LOSDEBUG 6
  23.  
  24.  //look around a client for things which might aggro the client.
  25. -void EntityList::CheckClientAggro(Client *around) {
  26. -
  27. -   LinkedListIterator<Mob*> iterator(mob_list);
  28. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  29. -       Mob* mob = iterator.GetData();
  30. -       if(mob->IsClient()) //also ensures that mob != around
  31. +void EntityList::CheckClientAggro(Client *around)
  32. +{
  33. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  34. +       Mob *mob = it->second;
  35. +       if (mob->IsClient())    //also ensures that mob != around
  36.             continue;
  37.  
  38. -       if(mob->CheckWillAggro(around)) {
  39. -           if(mob->IsEngaged())
  40. -           {
  41. +       if (mob->CheckWillAggro(around)) {
  42. +           if (mob->IsEngaged())
  43.                 mob->AddToHateList(around);
  44. -           }
  45.             else
  46. -           {
  47.                 mob->AddToHateList(around, mob->GetLevel());
  48. -           }
  49.         }
  50.     }
  51.  }
  52. @@ -84,23 +79,21 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo
  53.         towho->Message(0, ".. I am on faction %s (%d)\n", namebuf, my_primary);
  54.     }
  55.  
  56. -   LinkedListIterator<Mob*> iterator(mob_list);
  57. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  58. -       Mob* mob = iterator.GetData();
  59. -       if(mob->IsClient()) //also ensures that mob != around
  60. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  61. +       Mob *mob = it->second;
  62. +       if (mob->IsClient())    //also ensures that mob != around
  63.             continue;
  64.  
  65. -       if(mob->DistNoRoot(*from_who) > d2)
  66. +       if (mob->DistNoRoot(*from_who) > d2)
  67.             continue;
  68.  
  69. -       if(engaged) {
  70. +       if (engaged) {
  71.             uint32 amm = from_who->GetHateAmount(mob);
  72. -           if(amm == 0) {
  73. +           if (amm == 0)
  74.                 towho->Message(0, "... %s is not on my hate list.", mob->GetName());
  75. -           } else {
  76. +           else
  77.                 towho->Message(0, "... %s is on my hate list with value %lu", mob->GetName(), (unsigned long)amm);
  78. -           }
  79. -       } else if(!check_npcs && mob->IsNPC()) {
  80. +       } else if (!check_npcs && mob->IsNPC()) {
  81.                 towho->Message(0, "... %s is an NPC and my npc_aggro is disabled.", mob->GetName());
  82.         } else {
  83.             from_who->DescribeAggro(towho, mob, verbose);
  84. @@ -369,59 +362,57 @@ Mob* EntityList::AICheckCloseAggro(Mob* sender, float iAggroRange, float iAssist
  85.  
  86.  #ifdef REVERSE_AGGRO
  87.     //with reverse aggro, npc->client is checked elsewhere, no need to check again
  88. -   LinkedListIterator<NPC*> iterator(npc_list);
  89. +   auto it = npc_list.begin();
  90. +   while (it != npc_list.end()) {
  91.  #else
  92. -   LinkedListIterator<Mob*> iterator(mob_list);
  93. +   auto it = mob_list.begin();
  94. +   while (it != mob_list.end()) {
  95.  #endif
  96. -   iterator.Reset();
  97. -   //float distZ;
  98. -   while(iterator.MoreElements()) {
  99. -       Mob* mob = iterator.GetData();
  100. -
  101. -       if(sender->CheckWillAggro(mob)) {
  102. -           return(mob);
  103. -       }
  104. +       Mob *mob = it->second;
  105.  
  106. -       iterator.Advance();
  107. +       if (sender->CheckWillAggro(mob))
  108. +           return mob;
  109. +       ++it;
  110.     }
  111.     //LogFile->write(EQEMuLog::Debug, "Check aggro for %s no target.", sender->GetName());
  112. -   return(nullptr);
  113. +   return nullptr;
  114.  }
  115.  
  116. -int EntityList::GetHatedCount(Mob *attacker, Mob *exclude) {
  117. -
  118. +int EntityList::GetHatedCount(Mob *attacker, Mob *exclude)
  119. +{
  120.     // Return a list of how many non-feared, non-mezzed, non-green mobs, within aggro range, hate *attacker
  121. -
  122. -   if(!attacker) return 0;
  123. +   if (!attacker)
  124. +       return 0;
  125.  
  126.     int Count = 0;
  127.  
  128. -   LinkedListIterator<NPC*> iterator(npc_list);
  129. -
  130. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  131. -
  132. -       NPC* mob = iterator.GetData();
  133. -
  134. -       if(!mob || (mob == exclude)) continue;
  135. +   for (auto it = npc_list.begin(); it != npc_list.end(); ++it) {
  136. +       NPC *mob = it->second;
  137. +       if (!mob || (mob == exclude))
  138. +           continue;
  139.  
  140. -       if(!mob->IsEngaged()) continue;
  141. +       if (!mob->IsEngaged())
  142. +           continue;
  143.  
  144. -       if(mob->IsFeared() || mob->IsMezzed()) continue;
  145. +       if (mob->IsFeared() || mob->IsMezzed())
  146. +           continue;
  147.  
  148. -       if(attacker->GetLevelCon(mob->GetLevel()) == CON_GREEN) continue;
  149. +       if (attacker->GetLevelCon(mob->GetLevel()) == CON_GREEN)
  150. +           continue;
  151.  
  152. -       if(!mob->CheckAggro(attacker)) continue;
  153. +       if (!mob->CheckAggro(attacker))
  154. +           continue;
  155.  
  156.         float AggroRange = mob->GetAggroRange();
  157.  
  158.         // Square it because we will be using DistNoRoot
  159.  
  160. -       AggroRange = AggroRange * AggroRange;
  161. +       AggroRange *= AggroRange;
  162.  
  163. -       if(mob->DistNoRoot(*attacker) > AggroRange) continue;
  164. +       if (mob->DistNoRoot(*attacker) > AggroRange)
  165. +           continue;
  166.  
  167.         Count++;
  168. -
  169.     }
  170.  
  171.     return Count;
  172. @@ -434,13 +425,11 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) {
  173.     if (sender->GetPrimaryFaction() == 0 )
  174.         return; // well, if we dont have a faction set, we're gonna be indiff to everybody
  175.  
  176. -   LinkedListIterator<NPC*> iterator(npc_list);
  177. -
  178. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  179. -       NPC* mob = iterator.GetData();
  180. -       if(!mob){
  181. +   for (auto it = npc_list.begin(); it != npc_list.end(); ++it) {
  182. +       NPC *mob = it->second;
  183. +       if (!mob)
  184.             continue;
  185. -       }
  186. +
  187.         float r = mob->GetAssistRange();
  188.         r = r * r;
  189.  
  190. diff --git a/zone/effects.cpp b/zone/effects.cpp
  191. index d446852..c03f3b2 100644
  192. --- a/zone/effects.cpp
  193. +++ b/zone/effects.cpp
  194. @@ -696,31 +696,27 @@ bool Client::UseDiscipline(uint32 spell_id, uint32 target) {
  195.     return(true);
  196.  }
  197.  
  198. -void EntityList::AETaunt(Client* taunter, float range) {
  199. -   LinkedListIterator<NPC*> iterator(npc_list);
  200. -
  201. -   if(range == 0) {
  202. +void EntityList::AETaunt(Client* taunter, float range)
  203. +{
  204. +   if (range == 0)
  205.         range = 100;        //arbitrary default...
  206. -   }
  207.  
  208.     range = range * range;
  209.  
  210. -   iterator.Reset();
  211. -   while(iterator.MoreElements())
  212. -   {
  213. -       NPC * them = iterator.GetData();
  214. +   auto it = npc_list.begin();
  215. +   while (it != npc_list.end()) {
  216. +       NPC *them = it->second;
  217.         float zdiff = taunter->GetZ() - them->GetZ();
  218.         if (zdiff < 0)
  219.             zdiff *= -1;
  220.         if (zdiff < 10
  221. -           && taunter->IsAttackAllowed(them)
  222. -           && taunter->DistNoRootNoZ(*them) <= range) {
  223. -
  224. +               && taunter->IsAttackAllowed(them)
  225. +               && taunter->DistNoRootNoZ(*them) <= range) {
  226.             if (taunter->CheckLosFN(them)) {
  227.                 taunter->Taunt(them, true);
  228.             }
  229.         }
  230. -       iterator.Advance();
  231. +       ++it;
  232.     }
  233.  }
  234.  
  235. @@ -729,7 +725,6 @@ void EntityList::AETaunt(Client* taunter, float range) {
  236.  // NPC spells will only affect other NPCs with compatible faction
  237.  void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster, int16 resist_adjust)
  238.  {
  239. -   LinkedListIterator<Mob*> iterator(mob_list);
  240.     Mob *curmob;
  241.  
  242.     float dist = caster->GetAOERange(spell_id);
  243. @@ -740,66 +735,59 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_
  244.     const int MAX_TARGETS_ALLOWED = 4;
  245.     int iCounter = 0;
  246.  
  247. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  248. -   {
  249. -       curmob = iterator.GetData();
  250. -       if(curmob == center)    //do not affect center
  251. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  252. +       curmob = it->second;
  253. +       if (curmob == center)   //do not affect center
  254.             continue;
  255. -       if(curmob == caster && !affect_caster)  //watch for caster too
  256. +       if (curmob == caster && !affect_caster) //watch for caster too
  257.             continue;
  258. -       if(center->DistNoRoot(*curmob) > dist2) //make sure they are in range
  259. +       if (center->DistNoRoot(*curmob) > dist2)    //make sure they are in range
  260.             continue;
  261. -       if(isnpc && curmob->IsNPC()) {  //check npc->npc casting
  262. +       if (isnpc && curmob->IsNPC()) { //check npc->npc casting
  263.             FACTION_VALUE f = curmob->GetReverseFactionCon(caster);
  264. -           if(bad) {
  265. +           if (bad) {
  266.                 //affect mobs that are on our hate list, or
  267.                 //which have bad faction with us
  268. -               if( ! (caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
  269. +               if (!(caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
  270.                     continue;
  271.             } else {
  272.                 //only affect mobs we would assist.
  273. -               if( ! (f <= FACTION_AMIABLE))
  274. +               if (!(f <= FACTION_AMIABLE))
  275.                     continue;
  276.             }
  277.         }
  278.         //finally, make sure they are within range
  279. -       if(bad) {
  280. -           if(!caster->IsAttackAllowed(curmob, true))
  281. +       if (bad) {
  282. +           if (!caster->IsAttackAllowed(curmob, true))
  283.                 continue;
  284. -           if(!center->CheckLosFN(curmob))
  285. +           if (!center->CheckLosFN(curmob))
  286.                 continue;
  287. -       }
  288. -       else { // check to stop casting beneficial ae buffs (to wit: bard songs) on enemies...
  289. +       } else { // check to stop casting beneficial ae buffs (to wit: bard songs) on enemies...
  290.             // This does not check faction for beneficial AE buffs..only agro and attackable.
  291.             // I've tested for spells that I can find without problem, but a faction-based
  292.             // check may still be needed. Any changes here should also reflect in BardAEPulse() -U
  293. -           if(caster->IsAttackAllowed(curmob, true))
  294. +           if (caster->IsAttackAllowed(curmob, true))
  295.                 continue;
  296. -           if(caster->CheckAggro(curmob))
  297. +           if (caster->CheckAggro(curmob))
  298.                 continue;
  299.         }
  300.  
  301.         //if we get here... cast the spell.
  302. -       if(IsTargetableAESpell(spell_id) && bad)
  303. -       {
  304. -           if(iCounter < MAX_TARGETS_ALLOWED)
  305. -           {
  306. +       if (IsTargetableAESpell(spell_id) && bad) {
  307. +           if (iCounter < MAX_TARGETS_ALLOWED) {
  308.                 caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
  309.             }
  310. -       }
  311. -       else
  312. -       {
  313. +       } else {
  314.             caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
  315.         }
  316.  
  317. -       if(!isnpc) //npcs are not target limited...
  318. +       if (!isnpc) //npcs are not target limited...
  319.             iCounter++;
  320.     }
  321.  }
  322.  
  323.  void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster)
  324.  {
  325. -   LinkedListIterator<Mob*> iterator(mob_list);
  326.     Mob *curmob;
  327.  
  328.     float dist = caster->GetAOERange(spell_id);
  329. @@ -807,35 +795,28 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a
  330.  
  331.     bool bad = IsDetrimentalSpell(spell_id);
  332.  
  333. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  334. -   {
  335. -       curmob = iterator.GetData();
  336. -       if(curmob == center)    //do not affect center
  337. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  338. +       curmob = it->second;
  339. +       if (curmob == center)   //do not affect center
  340.             continue;
  341. -       if(curmob == caster && !affect_caster)  //watch for caster too
  342. +       if (curmob == caster && !affect_caster) //watch for caster too
  343.             continue;
  344. -       if(center->DistNoRoot(*curmob) > dist2) //make sure they are in range
  345. +       if (center->DistNoRoot(*curmob) > dist2)    //make sure they are in range
  346.             continue;
  347.  
  348.         //Only npcs mgb should hit are client pets...
  349. -       if(curmob->IsNPC())
  350. -       {
  351. +       if (curmob->IsNPC()) {
  352.             Mob *owner = curmob->GetOwner();
  353. -           if(owner)
  354. -           {
  355. -               if(!owner->IsClient())
  356. -               {
  357. +           if (owner) {
  358. +               if (!owner->IsClient()) {
  359.                     continue;
  360.                 }
  361. -           }
  362. -           else
  363. -           {
  364. +           } else {
  365.                 continue;
  366.             }
  367.         }
  368.  
  369. -       if(bad)
  370. -       {
  371. +       if (bad) {
  372.             continue;
  373.         }
  374.  
  375. @@ -848,7 +829,6 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a
  376.  // NPC spells will only affect other NPCs with compatible faction
  377.  void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster)
  378.  {
  379. -   LinkedListIterator<Mob*> iterator(mob_list);
  380.     Mob *curmob;
  381.  
  382.     float dist = caster->GetAOERange(spell_id);
  383. @@ -857,45 +837,43 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff
  384.     bool bad = IsDetrimentalSpell(spell_id);
  385.     bool isnpc = caster->IsNPC();
  386.  
  387. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  388. -   {
  389. -       curmob = iterator.GetData();
  390. -       if(curmob == center)    //do not affect center
  391. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  392. +       curmob = it->second;
  393. +       if (curmob == center)   //do not affect center
  394.             continue;
  395. -       if(curmob == caster && !affect_caster)  //watch for caster too
  396. +       if (curmob == caster && !affect_caster) //watch for caster too
  397.             continue;
  398. -       if(center->DistNoRoot(*curmob) > dist2) //make sure they are in range
  399. +       if (center->DistNoRoot(*curmob) > dist2)    //make sure they are in range
  400.             continue;
  401. -       if(isnpc && curmob->IsNPC()) {  //check npc->npc casting
  402. +       if (isnpc && curmob->IsNPC()) { //check npc->npc casting
  403.             FACTION_VALUE f = curmob->GetReverseFactionCon(caster);
  404. -           if(bad) {
  405. +           if (bad) {
  406.                 //affect mobs that are on our hate list, or
  407.                 //which have bad faction with us
  408. -               if( ! (caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
  409. +               if (!(caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
  410.                     continue;
  411.             } else {
  412.                 //only affect mobs we would assist.
  413. -               if( ! (f <= FACTION_AMIABLE))
  414. +               if (!(f <= FACTION_AMIABLE))
  415.                     continue;
  416.             }
  417.         }
  418.         //finally, make sure they are within range
  419. -       if(bad) {
  420. -           if(!center->CheckLosFN(curmob))
  421. +       if (bad) {
  422. +           if (!center->CheckLosFN(curmob))
  423.                 continue;
  424. -       }
  425. -       else { // check to stop casting beneficial ae buffs (to wit: bard songs) on enemies...
  426. +       } else { // check to stop casting beneficial ae buffs (to wit: bard songs) on enemies...
  427.             // See notes in AESpell() above for more info.
  428. -           if(caster->IsAttackAllowed(curmob, true))
  429. +           if (caster->IsAttackAllowed(curmob, true))
  430.                 continue;
  431. -           if(caster->CheckAggro(curmob))
  432. +           if (caster->CheckAggro(curmob))
  433.                 continue;
  434.         }
  435.  
  436.         //if we get here... cast the spell.
  437.         curmob->BardPulse(spell_id, caster);
  438.     }
  439. -   if(caster->IsClient())
  440. +   if (caster->IsClient())
  441.         caster->CastToClient()->CheckSongSkillIncrease(spell_id);
  442.  }
  443.  
  444. @@ -903,24 +881,23 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff
  445.  //NPCs handle it differently in Mob::Rampage
  446.  void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool IsFromSpell) {
  447.  //Dook- Will need tweaking, currently no pets or players or horses
  448. -   LinkedListIterator<Mob*> iterator(mob_list);
  449.     Mob *curmob;
  450.  
  451.     float dist2 = dist * dist;
  452.  
  453.     int hit = 0;
  454.  
  455. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {
  456. -       curmob = iterator.GetData();
  457. -       if(curmob->IsNPC()
  458. -           && curmob != attacker //this is not needed unless NPCs can use this
  459. -           &&(attacker->IsAttackAllowed(curmob))
  460. -           && curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */
  461. -           && (curmob->DistNoRoot(*attacker) <= dist2)
  462. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  463. +       curmob = it->second;
  464. +       if (curmob->IsNPC()
  465. +               && curmob != attacker //this is not needed unless NPCs can use this
  466. +               &&(attacker->IsAttackAllowed(curmob))
  467. +               && curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */
  468. +               && (curmob->DistNoRoot(*attacker) <= dist2)
  469.         ) {
  470.             attacker->Attack(curmob, Hand, false, false, IsFromSpell);
  471.             hit++;
  472. -           if(count != 0 && hit >= count)
  473. +           if (count != 0 && hit >= count)
  474.                 return;
  475.         }
  476.     }
  477. diff --git a/zone/entity.cpp b/zone/entity.cpp
  478. index 222fcc6..d056e2f 100644
  479. --- a/zone/entity.cpp
  480. +++ b/zone/entity.cpp
  481. @@ -51,7 +51,7 @@
  482.     #define strcasecmp  _stricmp
  483.  #endif
  484.  
  485. -extern Zone* zone;
  486. +extern Zone *zone;
  487.  extern volatile bool ZoneLoaded;
  488.  extern WorldServer worldserver;
  489.  extern NetConnection net;
  490. @@ -62,100 +62,104 @@ extern DBAsync *dbasync;
  491.  extern char errorname[32];
  492.  extern uint16 adverrornum;
  493.  
  494. -Entity::Entity() {
  495. +Entity::Entity()
  496. +{
  497.     id = 0;
  498.     pDBAsyncWorkID = 0;
  499.  }
  500.  
  501. -Entity::~Entity() {
  502. +Entity::~Entity()
  503. +{
  504.     dbasync->CancelWork(pDBAsyncWorkID);
  505.  }
  506.  
  507. -void Entity::SetID(uint16 set_id) {
  508. -   id = set_id;
  509. -}
  510. -
  511. -Client* Entity::CastToClient() {
  512. -   if(this==0x00){
  513. +Client *Entity::CastToClient()
  514. +{
  515. +   if (this == 0x00) {
  516.         std::cout << "CastToClient error (nullptr)" << std::endl;
  517.         DebugBreak();
  518.         return 0;
  519.     }
  520.  #ifdef _EQDEBUG
  521. -   if(!IsClient()) {
  522. +   if (!IsClient()) {
  523.         std::cout << "CastToClient error (not client?)" << std::endl;
  524.         DebugBreak();
  525.         return 0;
  526.     }
  527.  #endif
  528. -   return static_cast<Client*>(this);
  529. +   return static_cast<Client *>(this);
  530.  }
  531.  
  532. -NPC* Entity::CastToNPC() {
  533. +NPC *Entity::CastToNPC()
  534. +{
  535.  #ifdef _EQDEBUG
  536. -   if(!IsNPC()) {
  537. +   if (!IsNPC()) {
  538.         std::cout << "CastToNPC error" << std::endl;
  539.         DebugBreak();
  540.         return 0;
  541.     }
  542.  #endif
  543. -   return static_cast<NPC*>(this);
  544. +   return static_cast<NPC *>(this);
  545.  }
  546.  
  547. -Mob* Entity::CastToMob() {
  548. +Mob *Entity::CastToMob()
  549. +{
  550.  #ifdef _EQDEBUG
  551. -   if(!IsMob()) {
  552. +   if (!IsMob()) {
  553.         std::cout << "CastToMob error" << std::endl;
  554.         DebugBreak();
  555.         return 0;
  556.     }
  557.  #endif
  558. -   return static_cast<Mob*>(this);
  559. +   return static_cast<Mob *>(this);
  560.  }
  561.  
  562. -Merc* Entity::CastToMerc() {
  563. +Merc *Entity::CastToMerc()
  564. +{
  565.  #ifdef _EQDEBUG
  566. -   if(!IsMerc()) {
  567. +   if (!IsMerc()) {
  568.         std::cout << "CastToMerc error" << std::endl;
  569.         DebugBreak();
  570.         return 0;
  571.     }
  572.  #endif
  573. -   return static_cast<Merc*>(this);
  574. +   return static_cast<Merc *>(this);
  575.  }
  576.  
  577.  
  578. -Trap* Entity::CastToTrap()
  579. +Trap *Entity::CastToTrap()
  580.  {
  581.  #ifdef DEBUG
  582. -   if(!IsTrap())
  583. -   {
  584. +   if (!IsTrap()) {
  585.         //std::cout << "CastToTrap error" << std::endl;
  586.         return 0;
  587.     }
  588.  #endif
  589. -   return static_cast<Trap*>(this);
  590. +   return static_cast<Trap *>(this);
  591.  }
  592.  
  593. -Corpse* Entity::CastToCorpse() {
  594. +Corpse *Entity::CastToCorpse()
  595. +{
  596.  #ifdef _EQDEBUG
  597. -   if(!IsCorpse()) {
  598. +   if (!IsCorpse()) {
  599.         std::cout << "CastToCorpse error" << std::endl;
  600.         DebugBreak();
  601.         return 0;
  602.     }
  603.  #endif
  604. -   return static_cast<Corpse*>(this);
  605. +   return static_cast<Corpse *>(this);
  606.  }
  607. -Object* Entity::CastToObject() {
  608. +
  609. +Object *Entity::CastToObject()
  610. +{
  611.  #ifdef _EQDEBUG
  612. -   if(!IsObject()) {
  613. +   if (!IsObject()) {
  614.         std::cout << "CastToObject error" << std::endl;
  615.         DebugBreak();
  616.         return 0;
  617.     }
  618.  #endif
  619. -   return static_cast<Object*>(this);
  620. +   return static_cast<Object *>(this);
  621.  }
  622.  
  623.  /*Group* Entity::CastToGroup() {
  624. @@ -169,141 +173,153 @@ Object* Entity::CastToObject() {
  625.     return static_cast<Group*>(this);
  626.  }*/
  627.  
  628. -Doors* Entity::CastToDoors() {
  629. -return static_cast<Doors*>(this);
  630. +Doors *Entity::CastToDoors()
  631. +{
  632. +   return static_cast<Doors *>(this);
  633.  }
  634.  
  635. -Beacon* Entity::CastToBeacon() {
  636. -   return static_cast<Beacon*>(this);
  637. +Beacon *Entity::CastToBeacon()
  638. +{
  639. +   return static_cast<Beacon *>(this);
  640.  }
  641.  
  642. -const Client* Entity::CastToClient() const {
  643. -   if(this==0x00){
  644. +const Client *Entity::CastToClient() const
  645. +{
  646. +   if (this == 0x00) {
  647.         std::cout << "CastToClient error (nullptr)" << std::endl;
  648.         DebugBreak();
  649.         return 0;
  650.     }
  651.  #ifdef _EQDEBUG
  652. -   if(!IsClient()) {
  653. +   if (!IsClient()) {
  654.         std::cout << "CastToClient error (not client?)" << std::endl;
  655.         DebugBreak();
  656.         return 0;
  657.     }
  658.  #endif
  659. -   return static_cast<const Client*>(this);
  660. +   return static_cast<const Client *>(this);
  661.  }
  662.  
  663. -const NPC* Entity::CastToNPC() const {
  664. +const NPC *Entity::CastToNPC() const
  665. +{
  666.  #ifdef _EQDEBUG
  667. -   if(!IsNPC()) {
  668. +   if (!IsNPC()) {
  669.         std::cout << "CastToNPC error" << std::endl;
  670.         DebugBreak();
  671.         return 0;
  672.     }
  673.  #endif
  674. -   return static_cast<const NPC*>(this);
  675. +   return static_cast<const NPC *>(this);
  676.  }
  677.  
  678. -const Mob* Entity::CastToMob() const {
  679. +const Mob *Entity::CastToMob() const
  680. +{
  681.  #ifdef _EQDEBUG
  682. -   if(!IsMob()) {
  683. +   if (!IsMob()) {
  684.         std::cout << "CastToMob error" << std::endl;
  685.         DebugBreak();
  686.         return 0;
  687.     }
  688.  #endif
  689. -   return static_cast<const Mob*>(this);
  690. +   return static_cast<const Mob *>(this);
  691.  }
  692.  
  693. -const Merc* Entity::CastToMerc() const {
  694. +const Merc *Entity::CastToMerc() const
  695. +{
  696.  #ifdef _EQDEBUG
  697. -   if(!IsMerc()) {
  698. +   if (!IsMerc()) {
  699.         std::cout << "CastToMerc error" << std::endl;
  700.         DebugBreak();
  701.         return 0;
  702.     }
  703.  #endif
  704. -   return static_cast<const Merc*>(this);
  705. +   return static_cast<const Merc *>(this);
  706.  }
  707.  
  708. -const Trap* Entity::CastToTrap() const {
  709. +const Trap *Entity::CastToTrap() const
  710. +{
  711.  #ifdef DEBUG
  712. -   if(!IsTrap())
  713. -   {
  714. +   if (!IsTrap()) {
  715.         //std::cout << "CastToTrap error" << std::endl;
  716.         return 0;
  717.     }
  718.  #endif
  719. -   return static_cast<const Trap*>(this);
  720. +   return static_cast<const Trap *>(this);
  721.  }
  722.  
  723. -const Corpse* Entity::CastToCorpse() const {
  724. +const Corpse *Entity::CastToCorpse() const
  725. +{
  726.  #ifdef _EQDEBUG
  727. -   if(!IsCorpse()) {
  728. +   if (!IsCorpse()) {
  729.         std::cout << "CastToCorpse error" << std::endl;
  730.         DebugBreak();
  731.         return 0;
  732.     }
  733.  #endif
  734. -   return static_cast<const Corpse*>(this);
  735. +   return static_cast<const Corpse *>(this);
  736.  }
  737.  
  738. -const Object* Entity::CastToObject() const {
  739. +const Object *Entity::CastToObject() const
  740. +{
  741.  #ifdef _EQDEBUG
  742. -   if(!IsObject()) {
  743. +   if (!IsObject()) {
  744.         std::cout << "CastToObject error" << std::endl;
  745.         DebugBreak();
  746.         return 0;
  747.     }
  748.  #endif
  749. -   return static_cast<const Object*>(this);
  750. +   return static_cast<const Object *>(this);
  751.  }
  752.  
  753. -const Doors* Entity::CastToDoors() const {
  754. -return static_cast<const Doors*>(this);
  755. +const Doors *Entity::CastToDoors() const
  756. +{
  757. +   return static_cast<const Doors *>(this);
  758.  }
  759.  
  760. -const Beacon* Entity::CastToBeacon() const {
  761. -   return static_cast<const Beacon*>(this);
  762. +const Beacon* Entity::CastToBeacon() const
  763. +{
  764. +   return static_cast<const Beacon *>(this);
  765.  }
  766.  
  767.  #ifdef BOTS
  768. -Bot* Entity::CastToBot() {
  769. +Bot *Entity::CastToBot()
  770. +{
  771.  #ifdef _EQDEBUG
  772. -   if(!IsBot()) {
  773. +   if (!IsBot()) {
  774.         std::cout << "CastToBot error" << std::endl;
  775.         DebugBreak();
  776.         return 0;
  777.     }
  778.  #endif
  779. -   return static_cast<Bot*>(this);
  780. +   return static_cast<Bot *>(this);
  781.  }
  782.  #endif
  783.  
  784. -EntityList::EntityList() {
  785. +EntityList::EntityList()
  786. +{
  787.     last_insert_id = 0;
  788.  }
  789.  
  790. -EntityList::~EntityList() {
  791. +EntityList::~EntityList()
  792. +{
  793.     //must call this before the list is destroyed, or else it will try to
  794.     //delete the NPCs in the list, which it cannot do.
  795.     RemoveAllLocalities();
  796.  }
  797.  
  798. -bool EntityList::CanAddHateForMob(Mob *p) {
  799. -   LinkedListIterator<NPC*> iterator(npc_list);
  800. +bool EntityList::CanAddHateForMob(Mob *p)
  801. +{
  802.     int count = 0;
  803.  
  804. -   iterator.Reset();
  805. -   while( iterator.MoreElements())
  806. -   {
  807. -       NPC *npc=iterator.GetData();
  808. +   auto it = npc_list.begin();
  809. +   while (it != npc_list.end()) {
  810. +       NPC *npc = it->second;
  811.         if (npc->IsOnHatelist(p))
  812.             count++;
  813.         // no need to continue if we already hit the limit
  814.         if (count > 3)
  815.             return false;
  816. -       iterator.Advance();
  817. +       ++it;
  818.     }
  819.  
  820.     if (count <= 2)
  821. @@ -311,33 +327,33 @@ bool EntityList::CanAddHateForMob(Mob *p) {
  822.     return false;
  823.  }
  824.  
  825. -void EntityList::AddClient(Client* client) {
  826. +void EntityList::AddClient(Client *client)
  827. +{
  828.     client->SetID(GetFreeID());
  829. -   client_list.Insert(client);
  830. -   mob_list.Insert(client);
  831. -   if(!client_list.dont_delete)
  832. -       client_list.dont_delete=true;
  833. +   client_list.insert(std::pair<uint16, Client *>(client->GetID(), client));
  834. +   mob_list.insert(std::pair<uint16, Mob *>(client->GetID(), client));
  835.  }
  836.  
  837.  
  838. -void EntityList::TrapProcess() {
  839. -   if(numclients < 1)
  840. +void EntityList::TrapProcess()
  841. +{
  842. +   if (numclients < 1)
  843.         return;
  844.  
  845. -   LinkedListIterator<Trap*> iterator(trap_list);
  846. -   iterator.Reset();
  847. -   uint32 count=0;
  848. -   while(iterator.MoreElements())
  849. -   {
  850. -       count++;
  851. -       if(!iterator.GetData()->Process()){
  852. -           iterator.RemoveCurrent();
  853. +   if (trap_list.empty()) {
  854. +       net.trap_timer.Disable();
  855. +       return;
  856. +   }
  857. +
  858. +   auto it = trap_list.begin();
  859. +   while (it != trap_list.end()) {
  860. +       if (!it->second->Process()) {
  861. +           safe_delete(it->second);
  862. +           it = trap_list.erase(it);
  863. +       } else {
  864. +           ++it;
  865.         }
  866. -       else
  867. -           iterator.Advance();
  868.     }
  869. -   if(count==0)
  870. -       net.trap_timer.Disable();//No traps in list, disable until one is added
  871.  }
  872.  
  873.  
  874. @@ -357,193 +373,176 @@ void EntityList::CheckGroupList (const char *fname, const int fline)
  875.     }
  876.  }
  877.  
  878. -void EntityList::GroupProcess() {
  879. -   std::list<Group *>::iterator iterator;
  880. -   uint32 count = 0;
  881. +void EntityList::GroupProcess()
  882. +{
  883. +   if (numclients < 1)
  884. +       return;
  885.  
  886. -   if(numclients < 1)
  887. +   if (group_list.empty()) {
  888. +       net.group_timer.Disable();
  889.         return;
  890. +   }
  891.  
  892. -   iterator = group_list.begin();
  893. -   while(iterator != group_list.end())
  894. -   {
  895. -       count++;
  896. -       (*iterator)->Process();
  897. -       /*
  898. -       if(!iterator.GetData()->Process()){
  899. -           iterator.RemoveCurrent();
  900. -       }
  901. -       else
  902. -           iterator.Advance();
  903. -       */
  904. -       iterator++;
  905. +   auto it = group_list.begin();
  906. +   while (it != group_list.end()) {
  907. +       (*it)->Process();
  908. +       ++it;
  909.     }
  910. -   if(count == 0)
  911. -       net.group_timer.Disable();//No groups in list, disable until one is added
  912.  
  913.  #if EQDEBUG >= 5
  914.     CheckGroupList (__FILE__, __LINE__);
  915.  #endif
  916.  }
  917.  
  918. -void EntityList::QueueToGroupsForNPCHealthAA(Mob* sender, const EQApplicationPacket* app)
  919. +void EntityList::QueueToGroupsForNPCHealthAA(Mob *sender, const EQApplicationPacket *app)
  920.  {
  921. -
  922. -   std::list<Group *>::iterator iterator = group_list.begin();
  923. -
  924. -   while(iterator != group_list.end())
  925. -   {
  926. -       (*iterator)->QueueHPPacketsForNPCHealthAA(sender, app);
  927. -       ++iterator;
  928. +   auto it = group_list.begin();
  929. +   while (it != group_list.end()) {
  930. +       (*it)->QueueHPPacketsForNPCHealthAA(sender, app);
  931. +       ++it;
  932.     }
  933.  }
  934.  
  935. -void EntityList::RaidProcess() {
  936. -   std::list<Raid *>::iterator iterator;
  937. -   uint32 count = 0;
  938. +void EntityList::RaidProcess()
  939. +{
  940. +   if (numclients < 1)
  941. +       return;
  942.  
  943. -   if(numclients < 1)
  944. +   if (raid_list.empty()) {
  945. +       net.raid_timer.Disable();
  946.         return;
  947. +   }
  948.  
  949. -   iterator = raid_list.begin();
  950. -   while(iterator != raid_list.end())
  951. -   {
  952. -       count++;
  953. -       (*iterator)->Process();
  954. -       ++iterator;
  955. +   auto it = raid_list.begin();
  956. +   while (it != raid_list.end()) {
  957. +       (*it)->Process();
  958. +       ++it;
  959.     }
  960. -   if(count == 0)
  961. -       net.raid_timer.Disable();//No groups in list, disable until one is added
  962.  }
  963.  
  964. -void EntityList::DoorProcess() {
  965. +void EntityList::DoorProcess()
  966. +{
  967.  #ifdef IDLE_WHEN_EMPTY
  968. -   if(numclients < 1)
  969. +   if (numclients < 1)
  970.         return;
  971.  #endif
  972. -   LinkedListIterator<Doors*> iterator(door_list);
  973. -   iterator.Reset();
  974. -   uint32 count=0;
  975. -   while(iterator.MoreElements())
  976. -   {
  977. -       count++;
  978. -       if(!iterator.GetData()->Process()){
  979. -           iterator.RemoveCurrent();
  980. +   if (door_list.empty()) {
  981. +       net.door_timer.Disable();
  982. +       return;
  983. +   }
  984. +
  985. +   auto it = door_list.begin();
  986. +   while (it != door_list.end()) {
  987. +       if (!it->second->Process()) {
  988. +           safe_delete(it->second);
  989. +           it = door_list.erase(it);
  990.         }
  991. -       else
  992. -           iterator.Advance();
  993. +       ++it;
  994.     }
  995. -   if (count==0)
  996. -       net.door_timer.Disable();//No doors in list, disable until one is added
  997.  }
  998.  
  999. -void EntityList::ObjectProcess() {
  1000. -   LinkedListIterator<Object*> iterator(object_list);
  1001. -   iterator.Reset();
  1002. -   uint32 count=0;
  1003. -   while(iterator.MoreElements())
  1004. -   {
  1005. -       count++;
  1006. -       if(!iterator.GetData()->Process()){
  1007. -           iterator.RemoveCurrent();
  1008. +void EntityList::ObjectProcess()
  1009. +{
  1010. +   if (object_list.empty()) {
  1011. +       net.object_timer.Disable();
  1012. +       return;
  1013. +   }
  1014. +
  1015. +   auto it = object_list.begin();
  1016. +   while (it != object_list.end()) {
  1017. +       if (it->second->Process()) {
  1018. +           safe_delete(it->second);
  1019. +           it = object_list.erase(it);
  1020. +       } else {
  1021. +           ++it;
  1022.         }
  1023. -       else
  1024. -           iterator.Advance();
  1025.     }
  1026. -   if(count==0)
  1027. -       net.object_timer.Disable();//No objects in list, disable until one is added
  1028.  }
  1029.  
  1030. -void EntityList::CorpseProcess() {
  1031. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  1032. -   iterator.Reset();
  1033. -   uint32 count=0;
  1034. -   while(iterator.MoreElements())
  1035. -   {
  1036. -       count++;
  1037. -       if(!iterator.GetData()->Process()){
  1038. -           iterator.RemoveCurrent();
  1039. +void EntityList::CorpseProcess()
  1040. +{
  1041. +   if (corpse_list.empty()) {
  1042. +       net.corpse_timer.Disable(); // No corpses in list
  1043. +       return;
  1044. +   }
  1045. +
  1046. +   auto it = corpse_list.begin();
  1047. +   while (it != corpse_list.end()) {
  1048. +       if (!it->second->Process()) {
  1049. +           safe_delete(it->second);
  1050. +           it = corpse_list.erase(it);
  1051. +       } else {
  1052. +           ++it;
  1053.         }
  1054. -       else
  1055. -           iterator.Advance();
  1056.     }
  1057. -   if(count==0)
  1058. -       net.corpse_timer.Disable();//No corpses in list, disable until one is added
  1059.  }
  1060.  
  1061. -void EntityList::MobProcess() {
  1062. +void EntityList::MobProcess()
  1063. +{
  1064.  #ifdef IDLE_WHEN_EMPTY
  1065. -   if(numclients < 1)
  1066. +   if (numclients < 1)
  1067.         return;
  1068.  #endif
  1069. -   LinkedListIterator<Mob*> iterator(mob_list);
  1070. -   iterator.Reset();
  1071. -   while(iterator.MoreElements())
  1072. -   {
  1073. -       if(!iterator.GetData())
  1074. -       {
  1075. -           iterator.Advance();
  1076. -           continue;
  1077. -       }
  1078. -       if(!iterator.GetData()->Process()){
  1079. -           Mob* mob=iterator.GetData();
  1080. -           if(mob->IsNPC())
  1081. -               entity_list.RemoveNPC(mob->CastToNPC()->GetID());
  1082. -           else if(mob->IsMerc()) {
  1083. -               entity_list.RemoveMerc(mob->CastToMerc()->GetID());
  1084. -           }
  1085. +   auto it = mob_list.begin();
  1086. +   while (it != mob_list.end()) {
  1087. +       if (!it->second->Process()) {
  1088. +           Mob *mob = it->second;
  1089. +           if (mob->IsNPC()) {
  1090. +               entity_list.RemoveNPC(mob->GetID());
  1091. +           } else if (mob->IsMerc()) {
  1092. +               entity_list.RemoveMerc(mob->GetID());
  1093.  #ifdef BOTS
  1094. -           else if(mob->IsBot()) {
  1095. -               entity_list.RemoveBot(mob->CastToBot()->GetID());
  1096. -           }
  1097. +           } else if (mob->IsBot()) {
  1098. +               entity_list.RemoveBot(mob->GetID());
  1099.  #endif
  1100. -           else{
  1101. +           } else {
  1102.  #ifdef _WINDOWS
  1103. -                   struct in_addr  in;
  1104. -                   in.s_addr = mob->CastToClient()->GetIP();
  1105. -                   std::cout << "Dropping client: Process=false, ip=" << inet_ntoa(in) << ", port=" << mob->CastToClient()->GetPort() << std::endl;
  1106. +               struct in_addr in;
  1107. +               in.s_addr = mob->CastToClient()->GetIP();
  1108. +               std::cout << "Dropping client: Process=false, ip=" << inet_ntoa(in) << ", port=" << mob->CastT     oClient()->GetPort() << std::endl;
  1109.  #endif
  1110. -                   zone->StartShutdownTimer();
  1111. -                   Group *g = GetGroupByMob(mob);
  1112. -                   if(g) {
  1113. -                       LogFile->write(EQEMuLog::Error, "About to delete a client still in a group.");
  1114. -                       g->DelMember(mob);
  1115. -                   }
  1116. -                   Raid *r = entity_list.GetRaidByClient(mob->CastToClient());
  1117. -                   if(r) {
  1118. -                       LogFile->write(EQEMuLog::Error, "About to delete a client still in a raid.");
  1119. -                       r->MemberZoned(mob->CastToClient());
  1120. -                   }
  1121. -                   entity_list.RemoveClient(mob->GetID());
  1122. +               zone->StartShutdownTimer();
  1123. +               Group *g = GetGroupByMob(mob);
  1124. +               if (g) {
  1125. +                   LogFile->write(EQEMuLog::Error, "About to delete a client still in a group.");
  1126. +                   g->DelMember(mob);
  1127. +               }
  1128. +               Raid *r = entity_list.GetRaidByClient(mob->CastToClient());
  1129. +               if (r) {
  1130. +                   LogFile->write(EQEMuLog::Error, "About to delete a client still in a raid.");
  1131. +                   r->MemberZoned(mob->CastToClient());
  1132. +               }
  1133.             }
  1134. -           iterator.RemoveCurrent();
  1135. +           safe_delete(mob);
  1136. +           it = mob_list.erase(it);
  1137. +       } else {
  1138. +           ++it;
  1139.         }
  1140. -       else
  1141. -           iterator.Advance();
  1142.     }
  1143.  }
  1144.  
  1145. -void EntityList::BeaconProcess() {
  1146. -   LinkedListIterator<Beacon *> iterator(beacon_list);
  1147. -   int count;
  1148. -
  1149. -   for(iterator.Reset(), count = 0; iterator.MoreElements(); count++)
  1150. -   {
  1151. -       if(!iterator.GetData()->Process())
  1152. -           iterator.RemoveCurrent();
  1153. -       else
  1154. -           iterator.Advance();
  1155. +void EntityList::BeaconProcess()
  1156. +{
  1157. +   auto it = beacon_list.begin();
  1158. +   while (it != beacon_list.end()) {
  1159. +       if (!it->second->Process()) {
  1160. +           safe_delete(it->second);
  1161. +           it = beacon_list.erase(it);
  1162. +       } else {
  1163. +           ++it;
  1164. +       }
  1165.     }
  1166.  }
  1167.  
  1168. -
  1169. -void EntityList::AddGroup(Group* group) {
  1170. -   if(group == nullptr)    //this seems to be happening somehow...
  1171. +void EntityList::AddGroup(Group *group)
  1172. +{
  1173. +   if (group == nullptr)   //this seems to be happening somehow...
  1174.         return;
  1175.  
  1176.     uint32 gid = worldserver.NextGroupID();
  1177. -   if(gid == 0) {
  1178. -       LogFile->write(EQEMuLog::Error, "Unable to get new group ID from world server. group is going to be broken.");
  1179. +   if (gid == 0) {
  1180. +       LogFile->write(EQEMuLog::Error,
  1181. +               "Unable to get new group ID from world server. group is going to be broken.");
  1182.         return;
  1183.     }
  1184.  
  1185. @@ -553,39 +552,43 @@ void EntityList::AddGroup(Group* group) {
  1186.  #endif
  1187.  }
  1188.  
  1189. -
  1190. -void EntityList::AddGroup(Group* group, uint32 gid) {
  1191. +void EntityList::AddGroup(Group *group, uint32 gid)
  1192. +{
  1193.     group->SetID(gid);
  1194. -   //group_list.Insert(group);
  1195.     group_list.push_back(group);
  1196. -   if(!net.group_timer.Enabled())
  1197. +   if (!net.group_timer.Enabled())
  1198.         net.group_timer.Start();
  1199.  #if EQDEBUG >= 5
  1200. -   CheckGroupList (__FILE__, __LINE__);
  1201. +   CheckGroupList(__FILE__, __LINE__);
  1202.  #endif
  1203.  }
  1204.  
  1205. -void EntityList::AddRaid(Raid* raid) {
  1206. -   if(raid == nullptr)
  1207. +void EntityList::AddRaid(Raid *raid)
  1208. +{
  1209. +   if (raid == nullptr)
  1210.         return;
  1211.  
  1212.     uint32 gid = worldserver.NextGroupID();
  1213. -   if(gid == 0) {
  1214. -       LogFile->write(EQEMuLog::Error, "Unable to get new group ID from world server. group is going to be broken.");
  1215. +   if (gid == 0) {
  1216. +       LogFile->write(EQEMuLog::Error,
  1217. +               "Unable to get new group ID from world server. group is going to be broken.");
  1218.         return;
  1219.     }
  1220.  
  1221.     AddRaid(raid, gid);
  1222.  }
  1223. -void EntityList::AddRaid(Raid* raid, uint32 gid) {
  1224. +
  1225. +void EntityList::AddRaid(Raid *raid, uint32 gid)
  1226. +{
  1227.     raid->SetID(gid);
  1228.     raid_list.push_back(raid);
  1229. -   if(!net.raid_timer.Enabled())
  1230. +   if (!net.raid_timer.Enabled())
  1231.         net.raid_timer.Start();
  1232.  }
  1233.  
  1234.  
  1235. -void EntityList::AddCorpse(Corpse* corpse, uint32 in_id) {
  1236. +void EntityList::AddCorpse(Corpse *corpse, uint32 in_id)
  1237. +{
  1238.     if (corpse == 0)
  1239.         return;
  1240.  
  1241. @@ -593,60 +596,60 @@ void EntityList::AddCorpse(Corpse* corpse, uint32 in_id) {
  1242.         corpse->SetID(GetFreeID());
  1243.     else
  1244.         corpse->SetID(in_id);
  1245. +
  1246.     corpse->CalcCorpseName();
  1247. -   corpse_list.Insert(corpse);
  1248. -   if(!net.corpse_timer.Enabled())
  1249. +   corpse_list.insert(std::pair<uint16, Corpse *>(corpse->GetID(), corpse));
  1250. +
  1251. +   if (!net.corpse_timer.Enabled())
  1252.         net.corpse_timer.Start();
  1253.  }
  1254.  
  1255. -void EntityList::AddNPC(NPC* npc, bool SendSpawnPacket, bool dontqueue) {
  1256. +void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
  1257. +{
  1258.     npc->SetID(GetFreeID());
  1259.     parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0);
  1260.  
  1261.     uint16 emoteid = npc->GetEmoteID();
  1262. -   if(emoteid != 0)
  1263. -       npc->DoNPCEmote(ONSPAWN,emoteid);
  1264. +   if (emoteid != 0)
  1265. +       npc->DoNPCEmote(ONSPAWN, emoteid);
  1266.  
  1267.     if (SendSpawnPacket) {
  1268.         if (dontqueue) { // aka, SEND IT NOW BITCH!
  1269. -           EQApplicationPacket* app = new EQApplicationPacket;
  1270. -           npc->CreateSpawnPacket(app,npc);
  1271. +           EQApplicationPacket *app = new EQApplicationPacket;
  1272. +           npc->CreateSpawnPacket(app, npc);
  1273.             QueueClients(npc, app);
  1274.             safe_delete(app);
  1275. -       }
  1276. -       else {
  1277. -           NewSpawn_Struct* ns = new NewSpawn_Struct;
  1278. +       } else {
  1279. +           NewSpawn_Struct *ns = new NewSpawn_Struct;
  1280.             memset(ns, 0, sizeof(NewSpawn_Struct));
  1281.             npc->FillSpawnStruct(ns, 0);    // Not working on player newspawns, so it's safe to use a ForWho of 0
  1282.             AddToSpawnQueue(npc->GetID(), &ns);
  1283.             safe_delete(ns);
  1284.         }
  1285. -       if(npc->IsFindable())
  1286. +       if (npc->IsFindable())
  1287.             UpdateFindableNPCState(npc, false);
  1288.     }
  1289.  
  1290. -   npc_list.Insert(npc);
  1291. -   if(!npc_list.dont_delete)
  1292. -       npc_list.dont_delete=true;
  1293. -   mob_list.Insert(npc);
  1294. +   npc_list.insert(std::pair<uint16, NPC *>(npc->GetID(), npc));
  1295. +   mob_list.insert(std::pair<uint16, Mob *>(npc->GetID(), npc));
  1296.  }
  1297.  
  1298. -void EntityList::AddMerc(Merc* merc, bool SendSpawnPacket, bool dontqueue) {
  1299. -   if(merc) {
  1300. +void EntityList::AddMerc(Merc *merc, bool SendSpawnPacket, bool dontqueue)
  1301. +{
  1302. +   if (merc) {
  1303.         merc->SetID(GetFreeID());
  1304.  
  1305. -       if(SendSpawnPacket) {
  1306. -           if(dontqueue) {
  1307. +       if (SendSpawnPacket) {
  1308. +           if (dontqueue) {
  1309.                 // Send immediately
  1310. -               EQApplicationPacket* outapp = new EQApplicationPacket();
  1311. +               EQApplicationPacket *outapp = new EQApplicationPacket();
  1312.                 merc->CreateSpawnPacket(outapp);
  1313.                 outapp->priority = 6;
  1314.                 QueueClients(merc, outapp, true);
  1315.                 safe_delete(outapp);
  1316. -           }
  1317. -           else {
  1318. +           } else {
  1319.                 // Queue the packet
  1320. -               NewSpawn_Struct* ns = new NewSpawn_Struct;
  1321. +               NewSpawn_Struct *ns = new NewSpawn_Struct;
  1322.                 memset(ns, 0, sizeof(NewSpawn_Struct));
  1323.                 merc->FillSpawnStruct(ns, merc);
  1324.                 AddToSpawnQueue(merc->GetID(), &ns);
  1325. @@ -656,15 +659,15 @@ void EntityList::AddMerc(Merc* merc, bool SendSpawnPacket, bool dontqueue) {
  1326.             //parse->EventMERC(EVENT_SPAWN, merc, nullptr, "", 0);
  1327.         }
  1328.  
  1329. -       merc_list.Insert(merc);
  1330. -       mob_list.Insert(merc);
  1331. -       if(!merc_list.dont_delete)
  1332. -           merc_list.dont_delete=true;
  1333. +       merc_list.insert(std::pair<uint16, Merc *>(merc->GetID(), merc));
  1334. +       mob_list.insert(std::pair<uint16, Mob *>(merc->GetID(), merc));
  1335.     }
  1336.  }
  1337.  
  1338. -void EntityList::AddObject(Object* obj, bool SendSpawnPacket) {
  1339. +void EntityList::AddObject(Object *obj, bool SendSpawnPacket)
  1340. +{
  1341.     obj->SetID(GetFreeID());
  1342. +
  1343.     if (SendSpawnPacket) {
  1344.         EQApplicationPacket app;
  1345.         obj->CreateSpawnPacket(&app);
  1346. @@ -673,34 +676,40 @@ void EntityList::AddObject(Object* obj, bool SendSpawnPacket) {
  1347.         #endif
  1348.         QueueClients(0, &app,false);
  1349.     }
  1350. -   object_list.Insert(obj);
  1351. -   if(!net.object_timer.Enabled())
  1352. +
  1353. +   object_list.insert(std::pair<uint16, Object *>(obj->GetID(), obj));
  1354. +
  1355. +   if (!net.object_timer.Enabled())
  1356.         net.object_timer.Start();
  1357.  }
  1358.  
  1359. -void EntityList::AddDoor(Doors* door) {
  1360. +void EntityList::AddDoor(Doors *door)
  1361. +{
  1362.     door->SetEntityID(GetFreeID());
  1363. -   door_list.Insert(door);
  1364. -   if(!net.door_timer.Enabled())
  1365. +   door_list.insert(std::pair<uint16, Doors *>(door->GetID(), door));
  1366. +
  1367. +   if (!net.door_timer.Enabled())
  1368.         net.door_timer.Start();
  1369.  }
  1370.  
  1371. -void EntityList::AddTrap(Trap* trap) {
  1372. +void EntityList::AddTrap(Trap *trap)
  1373. +{
  1374.     trap->SetID(GetFreeID());
  1375. -   trap_list.Insert(trap);
  1376. -   if(!net.trap_timer.Enabled())
  1377. +   trap_list.insert(std::pair<uint16, Trap *>(trap->GetID(), trap));
  1378. +   if (!net.trap_timer.Enabled())
  1379.         net.trap_timer.Start();
  1380.  }
  1381.  
  1382.  void EntityList::AddBeacon(Beacon *beacon)
  1383.  {
  1384.     beacon->SetID(GetFreeID());
  1385. -   beacon_list.Insert(beacon);
  1386. +   beacon_list.insert(std::pair<uint16, Beacon *>(beacon->GetID(), beacon));
  1387.  }
  1388.  
  1389. -void EntityList::AddToSpawnQueue(uint16 entityid, NewSpawn_Struct** ns) {
  1390. +void EntityList::AddToSpawnQueue(uint16 entityid, NewSpawn_Struct **ns)
  1391. +{
  1392.     uint32 count;
  1393. -   if((count=(client_list.Count()))==0)
  1394. +   if ((count = (client_list.size())) == 0)
  1395.         return;
  1396.     SpawnQueue.Append(*ns);
  1397.     NumSpawnsOnQueue++;
  1398. @@ -709,74 +718,38 @@ void EntityList::AddToSpawnQueue(uint16 entityid, NewSpawn_Struct** ns) {
  1399.     *ns = nullptr;
  1400.  }
  1401.  
  1402. -void EntityList::CheckSpawnQueue() {
  1403. +void EntityList::CheckSpawnQueue()
  1404. +{
  1405.     // Send the stuff if the oldest packet on the queue is older than 50ms -Quagmire
  1406.     if (tsFirstSpawnOnQueue != 0xFFFFFFFF && (Timer::GetCurrentTime() - tsFirstSpawnOnQueue) > 50) {
  1407. -           LinkedListIterator<NewSpawn_Struct*> iterator(SpawnQueue);
  1408. -           EQApplicationPacket* outapp = 0;
  1409. -
  1410. -           iterator.Reset();
  1411. -           while(iterator.MoreElements()) {
  1412. -               outapp = new EQApplicationPacket;
  1413. -               Mob::CreateSpawnPacket(outapp, iterator.GetData());
  1414. -               QueueClients(0, outapp);
  1415. -               safe_delete(outapp);
  1416. -               iterator.RemoveCurrent();
  1417. -           }
  1418. -       tsFirstSpawnOnQueue = 0xFFFFFFFF;
  1419. -       NumSpawnsOnQueue = 0;
  1420. -   }
  1421. -}
  1422. -
  1423. -Doors* EntityList::FindDoor(uint8 door_id)
  1424. -{
  1425. -   if (door_id == 0)
  1426. -       return 0;
  1427. -
  1428. -   LinkedListIterator<Doors*> iterator(door_list);
  1429. -   iterator.Reset();
  1430. -
  1431. -   while(iterator.MoreElements())
  1432. -   {
  1433. -       Doors* door=iterator.GetData();
  1434. -       if (door->GetDoorID() == door_id)
  1435. -       {
  1436. -           return door;
  1437. -       }
  1438. -       iterator.Advance();
  1439. -   }
  1440. -   return 0;
  1441. -}
  1442. -
  1443. -Object* EntityList::FindObject(uint32 object_id)
  1444. -{
  1445. -   LinkedListIterator<Object*> iterator(object_list);
  1446. -   iterator.Reset();
  1447. +       LinkedListIterator<NewSpawn_Struct *> iterator(SpawnQueue);
  1448. +       EQApplicationPacket *outapp = 0;
  1449.  
  1450. -   while(iterator.MoreElements())
  1451. -   {
  1452. -       Object* object=iterator.GetData();
  1453. -       if (object->GetDBID() == object_id)
  1454. -       {
  1455. -           return object;
  1456. +       iterator.Reset();
  1457. +       while(iterator.MoreElements()) {
  1458. +           outapp = new EQApplicationPacket;
  1459. +           Mob::CreateSpawnPacket(outapp, iterator.GetData());
  1460. +           QueueClients(0, outapp);
  1461. +           safe_delete(outapp);
  1462. +           iterator.RemoveCurrent();
  1463.         }
  1464. -       iterator.Advance();
  1465. +       tsFirstSpawnOnQueue = 0xFFFFFFFF;
  1466. +       NumSpawnsOnQueue = 0;
  1467.     }
  1468. -   return nullptr;
  1469.  }
  1470.  
  1471. -Object* EntityList::FindNearbyObject(float x, float y, float z, float radius)
  1472. +Object *EntityList::FindNearbyObject(float x, float y, float z, float radius)
  1473.  {
  1474. -   LinkedListIterator<Object*> iterator(object_list);
  1475. -   iterator.Reset();
  1476. +   if (object_list.empty())
  1477. +       return nullptr;
  1478.  
  1479.     float ox;
  1480.     float oy;
  1481.     float oz;
  1482.  
  1483. -   while(iterator.MoreElements())
  1484. -   {
  1485. -       Object* object=iterator.GetData();
  1486. +   auto it = object_list.begin();
  1487. +   while (it != object_list.end()) {
  1488. +       Object *object = it->second;
  1489.  
  1490.         object->GetLocation(&ox, &oy, &oz);
  1491.  
  1492. @@ -785,49 +758,45 @@ Object* EntityList::FindNearbyObject(float x, float y, float z, float radius)
  1493.         oz = (z < oz) ? (oz - z) : (z - oz);
  1494.  
  1495.         if ((ox <= radius) && (oy <= radius) && (oz <= radius))
  1496. -       {
  1497.             return object;
  1498. -       }
  1499. -       iterator.Advance();
  1500. -   }
  1501.  
  1502. +       ++it;
  1503. +   }
  1504.  
  1505.     return nullptr;
  1506.  }
  1507.  
  1508. -
  1509. -bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket* app, Client *client)
  1510. +bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
  1511.  {
  1512. +   if (door_list.empty())
  1513. +       return false;
  1514. +
  1515.     uint32 mask_test = client->GetClientVersionBit();
  1516.     int count = 0;
  1517. -   LinkedListIterator<Doors*> iterator(door_list);
  1518. -   iterator.Reset();
  1519. -   while(iterator.MoreElements())
  1520. -   {
  1521. -       if((iterator.GetData()->GetClientVersionMask() & mask_test) && strlen(iterator.GetData()->GetDoorName()) > 3)
  1522. -       {
  1523. +
  1524. +   auto it = door_list.begin();
  1525. +   while (it != door_list.end()) {
  1526. +       if ((it->second->GetClientVersionMask() & mask_test) &&
  1527. +               strlen(it->second->GetDoorName()) > 3)
  1528.             count++;
  1529. -       }
  1530. -       iterator.Advance();
  1531. +       ++it;
  1532.     }
  1533.  
  1534.     if(count == 0 || count > 500)
  1535. -   {
  1536.         return false;
  1537. -   }
  1538. +
  1539.     uint32 length = count * sizeof(Door_Struct);
  1540. -   uchar* packet_buffer = new uchar[length];
  1541. +   uchar *packet_buffer = new uchar[length];
  1542.     memset(packet_buffer, 0, length);
  1543. -   uchar* ptr = packet_buffer;
  1544. +   uchar *ptr = packet_buffer;
  1545.     Doors *door;
  1546.     Door_Struct nd;
  1547.  
  1548. -   iterator.Reset();
  1549. -   while(iterator.MoreElements())
  1550. -   {
  1551. -       door = iterator.GetData();
  1552. -       if(door && (door->GetClientVersionMask() & mask_test) && strlen(door->GetDoorName()) > 3)
  1553. -       {
  1554. +   it = door_list.begin();
  1555. +   while (it != door_list.end()) {
  1556. +       door = it->second;
  1557. +       if (door && (door->GetClientVersionMask() & mask_test) &&
  1558. +               strlen(door->GetDoorName()) > 3) {
  1559.             memset(&nd, 0, sizeof(nd));
  1560.             memcpy(nd.name, door->GetDoorName(), 32);
  1561.             nd.xPos = door->GetX();
  1562. @@ -846,7 +815,7 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket* app, Client *client)
  1563.             *(ptr-1)=0x01;
  1564.             *(ptr-3)=0x01;
  1565.         }
  1566. -       iterator.Advance();
  1567. +       ++it;
  1568.     }
  1569.  
  1570.     app->SetOpcode(OP_SpawnDoor);
  1571. @@ -854,387 +823,231 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket* app, Client *client)
  1572.     app->pBuffer = packet_buffer;
  1573.     return true;
  1574.  }
  1575. -Entity* EntityList::GetEntityMob(uint16 id){
  1576. -   LinkedListIterator<Mob*> iterator(mob_list);
  1577. -   iterator.Reset();
  1578. -   while(iterator.MoreElements())
  1579. -   {
  1580. -       if (iterator.GetData()->GetID() == id)
  1581. -       {
  1582. -           return iterator.GetData();
  1583. -       }
  1584. -       iterator.Advance();
  1585. -   }
  1586. -   return 0;
  1587. +
  1588. +Entity *EntityList::GetEntityMob(uint16 id)
  1589. +{
  1590. +   return mob_list.count(id) ? mob_list.at(id) : nullptr;
  1591.  }
  1592. -Entity* EntityList::GetEntityMerc(uint16 id){
  1593. -   LinkedListIterator<Merc*> iterator(merc_list);
  1594. -   iterator.Reset();
  1595. -   while(iterator.MoreElements())
  1596. -   {
  1597. -       if (iterator.GetData()->GetID() == id)
  1598. -       {
  1599. -           return iterator.GetData();
  1600. -       }
  1601. -       iterator.Advance();
  1602. -   }
  1603. -   return 0;
  1604. +
  1605. +Entity *EntityList::GetEntityMerc(uint16 id)
  1606. +{
  1607. +   return merc_list.count(id) ? merc_list.at(id) : nullptr;
  1608.  }
  1609. -Entity* EntityList::GetEntityMob(const char *name)
  1610. +
  1611. +Entity *EntityList::GetEntityMob(const char *name)
  1612.  {
  1613. -   if (name == 0)
  1614. +   if (name == 0 || mob_list.empty())
  1615.         return 0;
  1616.  
  1617. -   LinkedListIterator<Mob*> iterator(mob_list);
  1618. -
  1619. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  1620. -   {
  1621. -       if (strcasecmp(iterator.GetData()->GetName(), name) == 0)
  1622. -       {
  1623. -           return iterator.GetData();
  1624. -       }
  1625. +   auto it = mob_list.begin();
  1626. +   while (it != mob_list.end()) {
  1627. +       if (strcasecmp(it->second->GetName(), name) == 0)
  1628. +           return it->second;
  1629. +       ++it;
  1630.     }
  1631. -   return 0;
  1632. +
  1633. +   return nullptr;
  1634.  }
  1635. -Entity* EntityList::GetEntityDoor(uint16 id){
  1636. -   LinkedListIterator<Doors*> iterator(door_list);
  1637. -   iterator.Reset();
  1638. -   while(iterator.MoreElements())
  1639. -   {
  1640. -       if (iterator.GetData()->GetID() == id)
  1641. -       {
  1642. -           return iterator.GetData();
  1643. -       }
  1644. -       iterator.Advance();
  1645. -   }
  1646. -   return 0;
  1647. +
  1648. +Entity *EntityList::GetEntityDoor(uint16 id)
  1649. +{
  1650. +   return door_list.count(id) ? door_list.at(id) : nullptr;
  1651.  }
  1652. -Entity* EntityList::GetEntityCorpse(uint16 id){
  1653. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  1654. -   iterator.Reset();
  1655. -   while(iterator.MoreElements())
  1656. -   {
  1657. -       if (iterator.GetData()->GetID() == id)
  1658. -       {
  1659. -           return iterator.GetData();
  1660. -       }
  1661. -       iterator.Advance();
  1662. -   }
  1663. -   return 0;
  1664. -}
  1665. -Entity* EntityList::GetEntityCorpse(const char *name)
  1666. +
  1667. +Entity *EntityList::GetEntityCorpse(uint16 id)
  1668.  {
  1669. -   if (name == 0)
  1670. -       return 0;
  1671. +   return corpse_list.count(id) ? corpse_list.at(id) : nullptr;
  1672. +}
  1673.  
  1674. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  1675. +Entity *EntityList::GetEntityCorpse(const char *name)
  1676. +{
  1677. +   if (name == 0 || corpse_list.empty())
  1678. +       return nullptr;
  1679.  
  1680. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  1681. -   {
  1682. -       if (strcasecmp(iterator.GetData()->GetName(), name) == 0)
  1683. -       {
  1684. -           return iterator.GetData();
  1685. -       }
  1686. +   auto it = corpse_list.begin();
  1687. +   while (it != corpse_list.end()) {
  1688. +       if (strcasecmp(it->second->GetName(), name) == 0)
  1689. +           return it->second;
  1690. +       ++it;
  1691.     }
  1692. -   return 0;
  1693. -}
  1694.  
  1695. -Entity* EntityList::GetEntityTrap(uint16 id){
  1696. -   LinkedListIterator<Trap*> iterator(trap_list);
  1697. -   iterator.Reset();
  1698. -   while(iterator.MoreElements())
  1699. -   {
  1700. -       if (iterator.GetData()->GetID() == id)
  1701. -       {
  1702. -           return iterator.GetData();
  1703. -       }
  1704. -       iterator.Advance();
  1705. -   }
  1706. -   return 0;
  1707. +   return nullptr;
  1708.  }
  1709.  
  1710. -Entity* EntityList::GetEntityObject(uint16 id){
  1711. -   LinkedListIterator<Object*> iterator(object_list);
  1712. -   iterator.Reset();
  1713. -   while(iterator.MoreElements())
  1714. -   {
  1715. -       if (iterator.GetData()->GetID() == id)
  1716. -       {
  1717. -           return iterator.GetData();
  1718. -       }
  1719. -       iterator.Advance();
  1720. -   }
  1721. -   return 0;
  1722. +Entity *EntityList::GetEntityTrap(uint16 id)
  1723. +{
  1724. +   return trap_list.count(id) ? trap_list.at(id) : nullptr;
  1725.  }
  1726. -/*
  1727. -Entity* EntityList::GetEntityGroup(uint16 id){
  1728. -   LinkedListIterator<Group*> iterator(group_list);
  1729. -   iterator.Reset();
  1730. -   while(iterator.MoreElements())
  1731. -   {
  1732. -       if (iterator.GetData()->GetID() == id)
  1733. -       {
  1734. -           return iterator.GetData();
  1735. -       }
  1736. -       iterator.Advance();
  1737. -   }
  1738. -   return 0;
  1739. +
  1740. +Entity *EntityList::GetEntityObject(uint16 id)
  1741. +{
  1742. +   return object_list.count(id) ? object_list.at(id) : nullptr;
  1743.  }
  1744. -*/
  1745. -Entity* EntityList::GetEntityBeacon(uint16 id) {
  1746. -   LinkedListIterator<Beacon*> iterator(beacon_list);
  1747. -   iterator.Reset();
  1748. -   while(iterator.MoreElements())
  1749. -   {
  1750. -       if (iterator.GetData()->GetID() == id)
  1751. -       {
  1752. -           return iterator.GetData();
  1753. -       }
  1754. -       iterator.Advance();
  1755. -   }
  1756. -   return 0;
  1757. +
  1758. +Entity *EntityList::GetEntityBeacon(uint16 id)
  1759. +{
  1760. +   return beacon_list.count(id) ? beacon_list.at(id) : nullptr;
  1761.  }
  1762. -Entity* EntityList::GetID(uint16 get_id)
  1763. +
  1764. +Entity *EntityList::GetID(uint16 get_id)
  1765.  {
  1766. -   Entity* ent=0;
  1767. -   if((ent=entity_list.GetEntityMob(get_id))!=0)
  1768. +   Entity *ent = 0;
  1769. +   if ((ent = entity_list.GetEntityMob(get_id)) != 0)
  1770.         return ent;
  1771. -   else if((ent=entity_list.GetEntityDoor(get_id))!=0)
  1772. +   else if ((ent=entity_list.GetEntityDoor(get_id)) != 0)
  1773.         return ent;
  1774. -   else if((ent=entity_list.GetEntityCorpse(get_id))!=0)
  1775. +   else if ((ent=entity_list.GetEntityCorpse(get_id)) != 0)
  1776.         return ent;
  1777. -// else if((ent=entity_list.GetEntityGroup(get_id))!=0)
  1778. -//     return ent;
  1779. -   else if((ent=entity_list.GetEntityObject(get_id))!=0)
  1780. +   else if ((ent=entity_list.GetEntityObject(get_id)) != 0)
  1781.         return ent;
  1782. -   else if((ent=entity_list.GetEntityTrap(get_id))!=0)
  1783. +   else if ((ent=entity_list.GetEntityTrap(get_id)) != 0)
  1784.         return ent;
  1785. -   else if((ent=entity_list.GetEntityBeacon(get_id))!=0)
  1786. +   else if ((ent=entity_list.GetEntityBeacon(get_id)) != 0)
  1787.         return ent;
  1788.     else
  1789.         return 0;
  1790.  }
  1791.  
  1792. -NPC* EntityList::GetNPCByID(uint16 id) {
  1793. -   LinkedListIterator<NPC*> iterator(npc_list);
  1794. -
  1795. -   iterator.Reset();
  1796. -   while(iterator.MoreElements())
  1797. -   {
  1798. -       if (iterator.GetData())
  1799. -       {
  1800. -           if (iterator.GetData()->GetID() == id) {
  1801. -               return iterator.GetData();
  1802. -           }
  1803. -       }
  1804. -       iterator.Advance();
  1805. -   }
  1806. -   return 0;
  1807. -}
  1808. -
  1809. -NPC* EntityList::GetNPCByNPCTypeID(uint32 npc_id)
  1810. +NPC *EntityList::GetNPCByNPCTypeID(uint32 npc_id)
  1811.  {
  1812. -   if (npc_id == 0)
  1813. -       return 0;
  1814. -   LinkedListIterator<NPC*> iterator(npc_list);
  1815. +   if (npc_id == 0 || npc_list.empty())
  1816. +       return nullptr;
  1817.  
  1818. -   iterator.Reset();
  1819. -   while(iterator.MoreElements())
  1820. -   {
  1821. -       if (iterator.GetData()->GetNPCTypeID() == npc_id)
  1822. -       {
  1823. -           return iterator.GetData();
  1824. -       }
  1825. -       iterator.Advance();
  1826. +   auto it = npc_list.begin();
  1827. +   while (it != npc_list.end()) {
  1828. +       if (it->second->GetNPCTypeID() == npc_id)
  1829. +           return it->second;
  1830. +       ++it;
  1831.     }
  1832. -   return 0;
  1833. -}
  1834.  
  1835. -Merc* EntityList::GetMercByID(uint16 id) {
  1836. -   LinkedListIterator<Merc*> iterator(merc_list);
  1837. -
  1838. -   iterator.Reset();
  1839. -   while(iterator.MoreElements())
  1840. -   {
  1841. -       if (iterator.GetData())
  1842. -       {
  1843. -           if (iterator.GetData()->GetID() == id) {
  1844. -               return iterator.GetData();
  1845. -           }
  1846. -       }
  1847. -       iterator.Advance();
  1848. -   }
  1849. -   return 0;
  1850. +   return nullptr;
  1851.  }
  1852.  
  1853. -Mob* EntityList::GetMob(uint16 get_id)
  1854. +Mob *EntityList::GetMob(uint16 get_id)
  1855.  {
  1856. -   Entity* ent=0;
  1857. +   Entity *ent = nullptr;
  1858.  
  1859.     if (get_id == 0)
  1860. -       return 0;
  1861. +       return nullptr;
  1862.  
  1863. -   if((ent=entity_list.GetEntityMob(get_id))!=0)
  1864. +   if ((ent = entity_list.GetEntityMob(get_id)))
  1865.         return ent->CastToMob();
  1866. -   else if((ent=entity_list.GetEntityCorpse(get_id))!=0)
  1867. +   else if ((ent = entity_list.GetEntityCorpse(get_id)))
  1868.         return ent->CastToMob();
  1869.  
  1870. -   return 0;
  1871. +   return nullptr;
  1872.  }
  1873.  
  1874. -Mob* EntityList::GetMob(const char* name)
  1875. +Mob *EntityList::GetMob(const char *name)
  1876.  {
  1877. -   Entity* ent=0;
  1878. +   Entity* ent = nullptr;
  1879.  
  1880.     if (name == 0)
  1881. -       return 0;
  1882. +       return nullptr;
  1883.  
  1884. -   if((ent=entity_list.GetEntityMob(name))!=0)
  1885. +   if ((ent = entity_list.GetEntityMob(name)))
  1886.         return ent->CastToMob();
  1887. -   else if((ent=entity_list.GetEntityCorpse(name))!=0)
  1888. +   else if ((ent = entity_list.GetEntityCorpse(name)))
  1889.         return ent->CastToMob();
  1890.  
  1891. -   return 0;
  1892. +   return nullptr;
  1893.  }
  1894.  
  1895. -Mob* EntityList::GetMobByNpcTypeID(uint32 get_id)
  1896. +Mob *EntityList::GetMobByNpcTypeID(uint32 get_id)
  1897.  {
  1898. -   if (get_id == 0)
  1899. +   if (get_id == 0 || mob_list.empty())
  1900.         return 0;
  1901. -   LinkedListIterator<Mob*> iterator(mob_list);
  1902.  
  1903. -   iterator.Reset();
  1904. -   while(iterator.MoreElements())
  1905. -   {
  1906. -       if (iterator.GetData()->GetNPCTypeID() == get_id)
  1907. -       {
  1908. -           return iterator.GetData();
  1909. -       }
  1910. -       iterator.Advance();
  1911. +   auto it = mob_list.begin();
  1912. +   while (it != mob_list.end()) {
  1913. +       if (it->second->GetNPCTypeID() == get_id)
  1914. +           return it->second;
  1915. +       ++it;
  1916.     }
  1917. -   return 0;
  1918. +   return nullptr;
  1919.  }
  1920.  
  1921. -Object* EntityList::GetObjectByDBID(uint32 id)
  1922. +Object *EntityList::GetObjectByDBID(uint32 id)
  1923.  {
  1924. -   if (id == 0)
  1925. -       return 0;
  1926. -
  1927. -   LinkedListIterator<Object*> iterator(object_list);
  1928. +   if (id == 0 || object_list.empty())
  1929. +       return nullptr;
  1930.  
  1931. -   iterator.Reset();
  1932. -   while(iterator.MoreElements())
  1933. -   {
  1934. -       if (iterator.GetData())
  1935. -       {
  1936. -           if (iterator.GetData()->CastToObject()->GetDBID() == id)
  1937. -           {
  1938. -               return iterator.GetData();
  1939. -           }
  1940. -       }
  1941. -       iterator.Advance();
  1942. +   auto it = object_list.begin();
  1943. +   while (it != object_list.end()) {
  1944. +       if (it->second->GetDBID() == id)
  1945. +           return it->second;
  1946. +       ++it;
  1947.     }
  1948. -   return 0;
  1949. +   return nullptr;
  1950.  }
  1951.  
  1952. -Object* EntityList::GetObjectByID(uint16 id)
  1953. +Object *EntityList::GetObjectByID(uint16 id)
  1954.  {
  1955. -   if (id == 0)
  1956. -       return 0;
  1957. -
  1958. -   LinkedListIterator<Object*> iterator(object_list);
  1959. +   if (id == 0 || object_list.empty())
  1960. +       return nullptr;
  1961.  
  1962. -   iterator.Reset();
  1963. -   while(iterator.MoreElements())
  1964. -   {
  1965. -       if (iterator.GetData())
  1966. -       {
  1967. -           if (iterator.GetData()->CastToObject()->GetID() == id)
  1968. -           {
  1969. -               return iterator.GetData();
  1970. -           }
  1971. -       }
  1972. -       iterator.Advance();
  1973. +   auto it = object_list.begin();
  1974. +   while (it != object_list.end()) {
  1975. +       if (it->second->CastToObject()->GetID() == id)
  1976. +           return it->second;
  1977. +       ++it;
  1978.     }
  1979. -   return 0;
  1980. +   return nullptr;
  1981.  }
  1982.  
  1983. -Doors* EntityList::GetDoorsByID(uint16 id)
  1984. +Doors *EntityList::GetDoorsByID(uint16 id)
  1985.  {
  1986. -   if (id == 0)
  1987. -       return 0;
  1988. -
  1989. -   LinkedListIterator<Doors*> iterator(door_list);
  1990. +   if (id == 0 || door_list.empty())
  1991. +       return nullptr;
  1992.  
  1993. -   iterator.Reset();
  1994. -   while(iterator.MoreElements())
  1995. -   {
  1996. -       if (iterator.GetData())
  1997. -       {
  1998. -           if (iterator.GetData()->CastToDoors()->GetEntityID() == id)
  1999. -           {
  2000. -               return iterator.GetData();
  2001. -           }
  2002. -       }
  2003. -       iterator.Advance();
  2004. +   auto it = door_list.begin();
  2005. +   while (it != door_list.end()) {
  2006. +       if (it->second->CastToDoors()->GetEntityID() == id)
  2007. +           return it->second;
  2008. +       ++it;
  2009.     }
  2010. -   return 0;
  2011. +
  2012. +   return nullptr;
  2013.  }
  2014.  
  2015. -Doors* EntityList::GetDoorsByDBID(uint32 id)
  2016. +Doors *EntityList::GetDoorsByDBID(uint32 id)
  2017.  {
  2018. -   if (id == 0)
  2019. -       return 0;
  2020. -
  2021. -   LinkedListIterator<Doors*> iterator(door_list);
  2022. +   if (id == 0 || door_list.empty())
  2023. +       return nullptr;
  2024.  
  2025. -   iterator.Reset();
  2026. -   while(iterator.MoreElements())
  2027. -   {
  2028. -       if (iterator.GetData())
  2029. -       {
  2030. -           if (iterator.GetData()->CastToDoors()->GetDoorDBID() == id)
  2031. -           {
  2032. -               return iterator.GetData();
  2033. -           }
  2034. -       }
  2035. -       iterator.Advance();
  2036. +   auto it = door_list.begin();
  2037. +   while (it != door_list.end()) {
  2038. +       if (it->second->GetDoorDBID() == id)
  2039. +           return it->second;
  2040. +       ++it;
  2041.     }
  2042. -   return 0;
  2043. +
  2044. +   return nullptr;
  2045.  }
  2046.  
  2047. -Doors* EntityList::GetDoorsByDoorID(uint32 id)
  2048. +Doors *EntityList::GetDoorsByDoorID(uint32 id)
  2049.  {
  2050. -   if (id == 0)
  2051. -       return 0;
  2052. -
  2053. -   LinkedListIterator<Doors*> iterator(door_list);
  2054. +   if (id == 0 || door_list.empty())
  2055. +       return nullptr;
  2056.  
  2057. -   iterator.Reset();
  2058. -   while(iterator.MoreElements())
  2059. -   {
  2060. -       if (iterator.GetData())
  2061. -       {
  2062. -           if (iterator.GetData()->CastToDoors()->GetDoorID() == id)
  2063. -           {
  2064. -               return iterator.GetData();
  2065. -           }
  2066. -       }
  2067. -       iterator.Advance();
  2068. +   auto it = door_list.begin();
  2069. +   while (it != door_list.end()) {
  2070. +       if (it->second->CastToDoors()->GetDoorID() == id)
  2071. +           return it->second;
  2072. +       ++it;
  2073.     }
  2074. -   return 0;
  2075. +
  2076. +   return nullptr;
  2077.  }
  2078.  
  2079.  uint16 EntityList::GetFreeID()
  2080.  {
  2081. -   if(last_insert_id > 1500)
  2082. +   if (last_insert_id > 1500)
  2083.         last_insert_id = 0;
  2084. -   uint16 getid=last_insert_id;
  2085. -   while(1)
  2086. -   {
  2087. +   uint16 getid = last_insert_id;
  2088. +   while (1) {
  2089.         getid++;
  2090. -       if (GetID(getid) == 0)
  2091. -       {
  2092. +       if (GetID(getid) == 0) {
  2093.             last_insert_id = getid;
  2094.             return getid;
  2095.         }
  2096. @@ -1242,12 +1055,14 @@ uint16 EntityList::GetFreeID()
  2097.  }
  2098.  
  2099.  // if no language skill is specified, sent with 100 skill
  2100. -void EntityList::ChannelMessage(Mob* from, uint8 chan_num, uint8 language, const char* message, ...) {
  2101. +void EntityList::ChannelMessage(Mob *from, uint8 chan_num, uint8 language, const char *message, ...)
  2102. +{
  2103.     ChannelMessage(from, chan_num, language, 100, message);
  2104.  }
  2105.  
  2106. -void EntityList::ChannelMessage(Mob* from, uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, ...) {
  2107. -   LinkedListIterator<Client*> iterator(client_list);
  2108. +void EntityList::ChannelMessage(Mob *from, uint8 chan_num, uint8 language,
  2109. +       uint8 lang_skill, const char *message, ...)
  2110. +{
  2111.     va_list argptr;
  2112.     char buffer[4096];
  2113.  
  2114. @@ -1255,85 +1070,72 @@ void EntityList::ChannelMessage(Mob* from, uint8 chan_num, uint8 language, uint8
  2115.     vsnprintf(buffer, 4096, message, argptr);
  2116.     va_end(argptr);
  2117.  
  2118. -   iterator.Reset();
  2119. -   while(iterator.MoreElements())
  2120. -   {
  2121. -       Client* client = iterator.GetData();
  2122. +   auto it = client_list.begin();
  2123. +   while(it != client_list.end()) {
  2124. +       Client *client = it->second;
  2125.         eqFilterType filter = FilterNone;
  2126. -       if(chan_num==3)//shout
  2127. -           filter=FilterShouts;
  2128. -       else if(chan_num==4) //auction
  2129. -           filter=FilterAuctions;
  2130. -
  2131. -       if (chan_num != 8 || client->Dist(*from) < 200) // Only say is limited in range
  2132. -       {
  2133. -           if(filter==FilterNone || client->GetFilter(filter)!=FilterHide)
  2134. +       if (chan_num == 3) //shout
  2135. +           filter = FilterShouts;
  2136. +       else if (chan_num == 4) //auction
  2137. +           filter = FilterAuctions;
  2138. +       //
  2139. +       // Only say is limited in range
  2140. +       if (chan_num != 8 || client->Dist(*from) < 200)
  2141. +           if (filter == FilterNone || client->GetFilter(filter) != FilterHide)
  2142.                 client->ChannelMessageSend(from->GetName(), 0, chan_num, language, lang_skill, buffer);
  2143. -       }
  2144. -       iterator.Advance();
  2145. +       ++it;
  2146.     }
  2147.  }
  2148.  
  2149. -void EntityList::ChannelMessageSend(Mob* to, uint8 chan_num, uint8 language, const char* message, ...) {
  2150. -   LinkedListIterator<Client*> iterator(client_list);
  2151. +void EntityList::ChannelMessageSend(Mob *to, uint8 chan_num, uint8 language, const char *message, ...)
  2152. +{
  2153.     va_list argptr;
  2154.     char buffer[4096];
  2155. +
  2156.     va_start(argptr, message);
  2157.     vsnprintf(buffer, 4096, message, argptr);
  2158.     va_end(argptr);
  2159. -   iterator.Reset();
  2160. -   while(iterator.MoreElements())
  2161. -   {
  2162. -       Client* client = iterator.GetData();
  2163. -       if (client->GetID() == to->GetID()) {
  2164. -           client->ChannelMessageSend(0, 0, chan_num, language, buffer);
  2165. -           break;
  2166. -       }
  2167. -       iterator.Advance();
  2168. -   }
  2169. +
  2170. +   if (client_list.count(to->GetID()))
  2171. +       client_list.at(to->GetID())->ChannelMessageSend(0, 0, chan_num, language, buffer);
  2172.  }
  2173.  
  2174. -void EntityList::SendZoneSpawns(Client* client)
  2175. +void EntityList::SendZoneSpawns(Client *client)
  2176.  {
  2177. -   LinkedListIterator<Mob*> iterator(mob_list);
  2178. -
  2179. -   EQApplicationPacket* app;
  2180. -   iterator.Reset();
  2181. -   while(iterator.MoreElements()) {
  2182. -       Mob* ent = iterator.GetData();
  2183. -       if (!( ent->InZone() ) || (ent->IsClient()))
  2184. -       {
  2185. -           if(ent->CastToClient()->GMHideMe(client) || ent->CastToClient()->IsHoveringForRespawn())
  2186. -           {
  2187. -               iterator.Advance();
  2188. +   EQApplicationPacket *app;
  2189. +   auto it = mob_list.begin();
  2190. +   while (it != mob_list.end()) {
  2191. +       Mob *ent = it->second;
  2192. +       if (!(ent->InZone()) || (ent->IsClient())) {
  2193. +           if (ent->CastToClient()->GMHideMe(client) ||
  2194. +                   ent->CastToClient()->IsHoveringForRespawn()) {
  2195. +               ++it;
  2196.                 continue;
  2197.             }
  2198.         }
  2199. +
  2200.         app = new EQApplicationPacket;
  2201. -       iterator.GetData()->CastToMob()->CreateSpawnPacket(app); // TODO: Use zonespawns opcode instead
  2202. +       it->second->CastToMob()->CreateSpawnPacket(app); // TODO: Use zonespawns opcode instead
  2203.         client->QueuePacket(app, true, Client::CLIENT_CONNECTED);
  2204.         safe_delete(app);
  2205. -       iterator.Advance();
  2206. +       ++it;
  2207.     }
  2208.  }
  2209.  
  2210. -void EntityList::SendZoneSpawnsBulk(Client* client)
  2211. +void EntityList::SendZoneSpawnsBulk(Client *client)
  2212.  {
  2213. -   //float rate = client->Connection()->GetDataRate();
  2214. -   LinkedListIterator<Mob*> iterator(mob_list);
  2215.     NewSpawn_Struct ns;
  2216.     Mob *spawn;
  2217. -   uint32 maxspawns=100;
  2218. -
  2219. -   if(maxspawns > mob_list.Count())
  2220. -       maxspawns = mob_list.Count();
  2221. -   BulkZoneSpawnPacket* bzsp = new BulkZoneSpawnPacket(client, maxspawns);
  2222. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  2223. -   {
  2224. -       spawn = iterator.GetData();
  2225. -       if(spawn && spawn->InZone())
  2226. -       {
  2227. -           if(spawn->IsClient() && (spawn->CastToClient()->GMHideMe(client) || spawn->CastToClient()->IsHoveringForRespawn()))
  2228. +   uint32 maxspawns = 100;
  2229. +
  2230. +   if (maxspawns > mob_list.size())
  2231. +       maxspawns = mob_list.size();
  2232. +   BulkZoneSpawnPacket *bzsp = new BulkZoneSpawnPacket(client, maxspawns);
  2233. +   for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
  2234. +       spawn = it->second;
  2235. +       if (spawn && spawn->InZone()) {
  2236. +           if (spawn->IsClient() && (spawn->CastToClient()->GMHideMe(client) ||
  2237. +                   spawn->CastToClient()->IsHoveringForRespawn()))
  2238.                 continue;
  2239.             memset(&ns, 0, sizeof(NewSpawn_Struct));
  2240.             spawn->FillSpawnStruct(&ns, client);
  2241. @@ -1344,26 +1146,23 @@ void EntityList::SendZoneSpawnsBulk(Client* client)
  2242.  }
  2243.  
  2244.  //this is a hack to handle a broken spawn struct
  2245. -void EntityList::SendZonePVPUpdates(Client *to) {
  2246. -   LinkedListIterator<Client*> iterator(client_list);
  2247. -
  2248. -   iterator.Reset();
  2249. -   while(iterator.MoreElements()) {
  2250. -       Client *c = iterator.GetData();
  2251. +void EntityList::SendZonePVPUpdates(Client *to)
  2252. +{
  2253. +   auto it = client_list.begin();
  2254. +   while (it != client_list.end()) {
  2255. +       Client *c = it->second;
  2256.         if(c->GetPVP())
  2257.             c->SendAppearancePacket(AT_PVP, c->GetPVP(), true, false, to);
  2258. -       iterator.Advance();
  2259. +       ++it;
  2260.     }
  2261.  }
  2262.  
  2263. -void EntityList::SendZoneCorpses(Client* client)
  2264. +void EntityList::SendZoneCorpses(Client *client)
  2265.  {
  2266. -   EQApplicationPacket* app;
  2267. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2268. +   EQApplicationPacket *app;
  2269.  
  2270. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  2271. -   {
  2272. -       Corpse *ent = iterator.GetData();
  2273. +   for (auto it = corpse_list.begin(); it != corpse_list.end(); ++it) {
  2274. +       Corpse *ent = it->second;
  2275.         app = new EQApplicationPacket;
  2276.         ent->CreateSpawnPacket(app);
  2277.         client->QueuePacket(app, true, Client::CLIENT_CONNECTED);
  2278. @@ -1371,20 +1170,17 @@ void EntityList::SendZoneCorpses(Client* client)
  2279.     }
  2280.  }
  2281.  
  2282. -void EntityList::SendZoneCorpsesBulk(Client* client) {
  2283. -   //float rate = client->Connection()->GetDataRate();
  2284. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2285. +void EntityList::SendZoneCorpsesBulk(Client *client)
  2286. +{
  2287.     NewSpawn_Struct ns;
  2288.     Corpse *spawn;
  2289. -   uint32 maxspawns=100;
  2290. +   uint32 maxspawns = 100;
  2291.  
  2292. -   BulkZoneSpawnPacket* bzsp = new BulkZoneSpawnPacket(client, maxspawns);
  2293. +   BulkZoneSpawnPacket *bzsp = new BulkZoneSpawnPacket(client, maxspawns);
  2294.  
  2295. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  2296. -   {
  2297. -       spawn = iterator.GetData();
  2298. -       if(spawn && spawn->InZone())
  2299. -       {
  2300. +   for (auto it = corpse_list.begin(); it != corpse_list.end(); ++it) {
  2301. +       spawn = it->second;
  2302. +       if (spawn && spawn->InZone()) {
  2303.             memset(&ns, 0, sizeof(NewSpawn_Struct));
  2304.             spawn->FillSpawnStruct(&ns, client);
  2305.             bzsp->AddSpawn(&ns);
  2306. @@ -1393,131 +1189,96 @@ void EntityList::SendZoneCorpsesBulk(Client* client) {
  2307.     safe_delete(bzsp);
  2308.  }
  2309.  
  2310. -void EntityList::SendZoneObjects(Client* client)
  2311. +void EntityList::SendZoneObjects(Client *client)
  2312.  {
  2313. -   LinkedListIterator<Object*> iterator(object_list);
  2314. -   iterator.Reset();
  2315. -   while(iterator.MoreElements())
  2316. -   {
  2317. +   auto it = object_list.begin();
  2318. +   while (it != object_list.end()) {
  2319.         EQApplicationPacket *app = new EQApplicationPacket;
  2320. -       iterator.GetData()->CreateSpawnPacket(app);
  2321. +       it->second->CreateSpawnPacket(app);
  2322.         client->FastQueuePacket(&app);
  2323. -       iterator.Advance();
  2324. +       ++it;
  2325.     }
  2326.  }
  2327.  
  2328.  void EntityList::Save()
  2329.  {
  2330. -   LinkedListIterator<Client*> iterator(client_list);
  2331. -
  2332. -   iterator.Reset();
  2333. -   while(iterator.MoreElements())
  2334. -   {
  2335. -       iterator.GetData()->Save();
  2336. -       iterator.Advance();
  2337. +   auto it = client_list.begin();
  2338. +   while (it != client_list.end()) {
  2339. +       it->second->Save();
  2340. +       ++it;
  2341.     }
  2342.  }
  2343.  
  2344. -void EntityList::ReplaceWithTarget(Mob* pOldMob, Mob*pNewTarget)
  2345. +void EntityList::ReplaceWithTarget(Mob *pOldMob, Mob *pNewTarget)
  2346.  {
  2347. -   if(!pNewTarget)
  2348. +   if (!pNewTarget)
  2349.         return;
  2350. -   LinkedListIterator<Mob*> iterator(mob_list);
  2351.  
  2352. -   iterator.Reset();
  2353. -   while(iterator.MoreElements()) {
  2354. -       if (iterator.GetData()->IsAIControlled()) {
  2355. +   auto it = mob_list.begin();
  2356. +   while (it != mob_list.end()) {
  2357. +       if (it->second->IsAIControlled()) {
  2358.             // replace the old mob with the new one
  2359. -           if (iterator.GetData()->RemoveFromHateList(pOldMob))
  2360. -                   iterator.GetData()->AddToHateList(pNewTarget, 1, 0);
  2361. +           if (it->second->RemoveFromHateList(pOldMob))
  2362. +                   it->second->AddToHateList(pNewTarget, 1, 0);
  2363.         }
  2364. -       iterator.Advance();
  2365. +       ++it;
  2366.     }
  2367.  }
  2368.  
  2369. -void EntityList::RemoveFromTargets(Mob* mob, bool RemoveFromXTargets)
  2370. +void EntityList::RemoveFromTargets(Mob *mob, bool RemoveFromXTargets)
  2371.  {
  2372. -   LinkedListIterator<Mob*> iterator(mob_list);
  2373. -
  2374. -   iterator.Reset();
  2375. -   while(iterator.MoreElements())
  2376. -   {
  2377. -       Mob *m = iterator.GetData();
  2378. -       iterator.Advance();
  2379. +   auto it = mob_list.begin();
  2380. +   while (it != mob_list.end()) {
  2381. +       Mob *m = it->second;
  2382. +       ++it;
  2383.  
  2384. -       if(!m)
  2385. +       if (!m)
  2386.             continue;
  2387.  
  2388.         m->RemoveFromHateList(mob);
  2389.  
  2390. -       if(RemoveFromXTargets)
  2391. -       {
  2392. -           if(m->IsClient())
  2393. +       if (RemoveFromXTargets) {
  2394. +           if (m->IsClient())
  2395.                 m->CastToClient()->RemoveXTarget(mob, false);
  2396.             // FadingMemories calls this function passing the client.
  2397. -           else if(mob->IsClient())
  2398. +           else if (mob->IsClient())
  2399.                 mob->CastToClient()->RemoveXTarget(m, false);
  2400.         }
  2401. -
  2402.     }
  2403.  }
  2404.  
  2405. -void EntityList::RemoveFromXTargets(Mob* mob)
  2406. +void EntityList::RemoveFromXTargets(Mob *mob)
  2407.  {
  2408. -   LinkedListIterator<Mob*> iterator(mob_list);
  2409. -
  2410. -   iterator.Reset();
  2411. -   while(iterator.MoreElements())
  2412. -   {
  2413. -       Mob *m = iterator.GetData();
  2414. -       iterator.Advance();
  2415. -
  2416. -       if(!m)
  2417. -           continue;
  2418. -
  2419. -       if(m->IsClient())
  2420. -           m->CastToClient()->RemoveXTarget(mob, false);
  2421. -
  2422. +   auto it = client_list.begin();
  2423. +   while (it != client_list.end()) {
  2424. +       it->second->RemoveXTarget(mob, false);
  2425. +       ++it;
  2426.     }
  2427.  }
  2428.  
  2429. -void EntityList::RemoveFromAutoXTargets(Mob* mob)
  2430. +void EntityList::RemoveFromAutoXTargets(Mob *mob)
  2431.  {
  2432. -   LinkedListIterator<Mob*> iterator(mob_list);
  2433. -
  2434. -   iterator.Reset();
  2435. -   while(iterator.MoreElements())
  2436. -   {
  2437. -       Mob *m = iterator.GetData();
  2438. -       iterator.Advance();
  2439. -
  2440. -       if(!m)
  2441. -           continue;
  2442. -
  2443. -       if(m->IsClient())
  2444. -           m->CastToClient()->RemoveXTarget(mob, true);
  2445. -
  2446. +   auto it = client_list.begin();
  2447. +   while (it != client_list.end()) {
  2448. +       it->second->RemoveXTarget(mob, true);
  2449. +       ++it;
  2450.     }
  2451.  }
  2452.  
  2453.  void EntityList::RefreshAutoXTargets(Client *c)
  2454.  {
  2455. -   if(!c)
  2456. +   if (!c)
  2457.         return;
  2458.  
  2459. -   LinkedListIterator<Mob*> iterator(mob_list);
  2460. +   auto it = mob_list.begin();
  2461. +   while (it != mob_list.end()) {
  2462. +       Mob *m = it->second;
  2463. +       ++it;
  2464.  
  2465. -   iterator.Reset();
  2466. -   while(iterator.MoreElements())
  2467. -   {
  2468. -       Mob *m = iterator.GetData();
  2469. -       iterator.Advance();
  2470. -
  2471. -       if(!m || m->GetHP() <= 0)
  2472. +       if (!m || m->GetHP() <= 0)
  2473.             continue;
  2474.  
  2475. -       if(m->CheckAggro(c) && !c->IsXTarget(m))
  2476. -       {
  2477. +       if (m->CheckAggro(c) && !c->IsXTarget(m)) {
  2478.             c->AddAutoXTarget(m);
  2479.             break;
  2480.         }
  2481. @@ -1527,184 +1288,157 @@ void EntityList::RefreshAutoXTargets(Client *c)
  2482.  
  2483.  void EntityList::RefreshClientXTargets(Client *c)
  2484.  {
  2485. -   if(!c)
  2486. +   if (!c)
  2487.         return;
  2488.  
  2489. -   LinkedListIterator<Client*> iterator(client_list);
  2490. +   auto it = client_list.begin();
  2491. +   while (it != client_list.end()) {
  2492. +       Client *c2 = it->second;
  2493. +       ++it;
  2494.  
  2495. -   iterator.Reset();
  2496. -   while(iterator.MoreElements())
  2497. -   {
  2498. -       Client *c2 = iterator.GetData();
  2499. -       iterator.Advance();
  2500. -
  2501. -       if(!c2)
  2502. +       if (!c2)
  2503.             continue;
  2504.  
  2505. -       if(c2->IsClientXTarget(c))
  2506. +       if (c2->IsClientXTarget(c))
  2507.             c2->UpdateClientXTarget(c);
  2508.     }
  2509.  }
  2510.  
  2511. -void EntityList::QueueClientsByTarget(Mob* sender, const EQApplicationPacket* app, bool iSendToSender, Mob* SkipThisMob, bool ackreq, bool HoTT,
  2512. -                       uint32 ClientVersionBits)
  2513. +void EntityList::QueueClientsByTarget(Mob *sender, const EQApplicationPacket *app,
  2514. +       bool iSendToSender, Mob *SkipThisMob, bool ackreq, bool HoTT, uint32 ClientVersionBits)
  2515.  {
  2516. -   LinkedListIterator<Client*> iterator(client_list);
  2517. -
  2518. -   iterator.Reset();
  2519. -
  2520. -   while(iterator.MoreElements())
  2521. -   {
  2522. -       Client *c = iterator.GetData();
  2523. -
  2524. -       iterator.Advance();
  2525. +   auto it = client_list.begin();
  2526. +   while (it != client_list.end()) {
  2527. +       Client *c = it->second;
  2528. +       ++it;
  2529.  
  2530.         Mob *Target = c->GetTarget();
  2531.  
  2532. -       if(!Target)
  2533. +       if (!Target)
  2534.             continue;
  2535.  
  2536.         Mob *TargetsTarget = nullptr;
  2537.  
  2538. -       if(Target)
  2539. +       if (Target)
  2540.             TargetsTarget = Target->GetTarget();
  2541.  
  2542.         bool Send = false;
  2543.  
  2544. -       if(c == SkipThisMob)
  2545. +       if (c == SkipThisMob)
  2546.             continue;
  2547.  
  2548. -       if(iSendToSender)
  2549. -           if(c == sender)
  2550. +       if (iSendToSender)
  2551. +           if (c == sender)
  2552.                 Send = true;
  2553.  
  2554. -       if(c != sender)
  2555. -       {
  2556. -           if(Target == sender)
  2557. -           {
  2558. +       if (c != sender) {
  2559. +           if (Target == sender)
  2560.                 Send = true;
  2561. -           }
  2562. -           else if(HoTT)
  2563. -           {
  2564. -               if(TargetsTarget == sender)
  2565. +           else if (HoTT)
  2566. +               if (TargetsTarget == sender)
  2567.                     Send = true;
  2568. -           }
  2569.         }
  2570.  
  2571. -       if(Send && (c->GetClientVersionBit() & ClientVersionBits))
  2572. +       if (Send && (c->GetClientVersionBit() & ClientVersionBits))
  2573.             c->QueuePacket(app, ackreq);
  2574.     }
  2575.  }
  2576.  
  2577. -void EntityList::QueueClientsByXTarget(Mob* sender, const EQApplicationPacket* app, bool iSendToSender)
  2578. +void EntityList::QueueClientsByXTarget(Mob *sender, const EQApplicationPacket *app, bool iSendToSender)
  2579.  {
  2580. -   LinkedListIterator<Client*> iterator(client_list);
  2581. -
  2582. -   iterator.Reset();
  2583. -
  2584. -   while(iterator.MoreElements())
  2585. -   {
  2586. -       Client *c = iterator.GetData();
  2587. -
  2588. -       iterator.Advance();
  2589. +   auto it = client_list.begin();
  2590. +   while (it != client_list.end()) {
  2591. +       Client *c = it->second;
  2592. +       ++it;
  2593.  
  2594. -       if(!c || ((c == sender) && !iSendToSender))
  2595. +       if (!c || ((c == sender) && !iSendToSender))
  2596.             continue;
  2597.  
  2598. -       if(!c->IsXTarget(sender))
  2599. +       if (!c->IsXTarget(sender))
  2600.             continue;
  2601.  
  2602.         c->QueuePacket(app);
  2603.     }
  2604.  }
  2605.  
  2606. -void EntityList::QueueCloseClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, float dist, Mob* SkipThisMob, bool ackreq, eqFilterType filter) {
  2607. +void EntityList::QueueCloseClients(Mob *sender, const EQApplicationPacket *app,
  2608. +       bool ignore_sender, float dist, Mob *SkipThisMob, bool ackreq, eqFilterType filter)
  2609. +{
  2610.     if (sender == nullptr) {
  2611.         QueueClients(sender, app, ignore_sender);
  2612.         return;
  2613.     }
  2614. -   if(dist <= 0) {
  2615. +
  2616. +   if (dist <= 0)
  2617.         dist = 600;
  2618. -   }
  2619.     float dist2 = dist * dist; //pow(dist, 2);
  2620.  
  2621. -   LinkedListIterator<Client*> iterator(client_list);
  2622. -
  2623. -   iterator.Reset();
  2624. -   while(iterator.MoreElements()) {
  2625. -
  2626. -       Client* ent = iterator.GetData();
  2627. +   auto it = client_list.begin();
  2628. +   while (it != client_list.end()) {
  2629. +       Client *ent = it->second;
  2630.  
  2631.         if ((!ignore_sender || ent != sender) && (ent != SkipThisMob)) {
  2632.             eqFilterMode filter2 = ent->GetFilter(filter);
  2633.             if(ent->Connected() &&
  2634. -               (filter==FilterNone
  2635. +               (filter == FilterNone
  2636.                 || filter2 == FilterShow
  2637.                 || (filter2 == FilterShowGroupOnly && (sender == ent ||
  2638.                     (ent->GetGroup() && ent->GetGroup()->IsGroupMember(sender))))
  2639. -               || (filter2 == FilterShowSelfOnly && ent==sender))
  2640. +               || (filter2 == FilterShowSelfOnly && ent == sender))
  2641.             && (ent->DistNoRoot(*sender) <= dist2)) {
  2642.                 ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
  2643.             }
  2644.         }
  2645. -       iterator.Advance();
  2646. +       ++it;
  2647.     }
  2648.  }
  2649.  
  2650.  //sender can be null
  2651. -void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
  2652. -   LinkedListIterator<Client*> iterator(client_list);
  2653. -
  2654. -   iterator.Reset();
  2655. -   while(iterator.MoreElements())
  2656. -   {
  2657. -       Client* ent = iterator.GetData();
  2658. +void EntityList::QueueClients(Mob *sender, const EQApplicationPacket *app,
  2659. +       bool ignore_sender, bool ackreq)
  2660. +{
  2661. +   auto it = client_list.begin();
  2662. +   while (it != client_list.end()) {
  2663. +       Client *ent = it->second;
  2664.  
  2665.         if ((!ignore_sender || ent != sender))
  2666. -       {
  2667.             ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
  2668. -       }
  2669. -       iterator.Advance();
  2670. +
  2671. +       ++it;
  2672.     }
  2673.  }
  2674.  
  2675. -void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
  2676. -   LinkedListIterator<Client*> iterator(client_list);
  2677. -
  2678. -   iterator.Reset();
  2679. -   while(iterator.MoreElements())
  2680. -   {
  2681. -       Client* ent = iterator.GetData();
  2682. +void EntityList::QueueManaged(Mob *sender, const EQApplicationPacket *app,
  2683. +       bool ignore_sender, bool ackreq)
  2684. +{
  2685. +   auto it = client_list.begin();
  2686. +   while (it != client_list.end()) {
  2687. +       Client *ent = it->second;
  2688.  
  2689.         if ((!ignore_sender || ent != sender))
  2690. -       {
  2691.             ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
  2692. -       }
  2693. -       iterator.Advance();
  2694. +
  2695. +       ++it;
  2696.     }
  2697.  }
  2698.  
  2699.  
  2700. -void EntityList::QueueClientsStatus(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, uint8 minstatus, uint8 maxstatus)
  2701. +void EntityList::QueueClientsStatus(Mob *sender, const EQApplicationPacket *app,
  2702. +       bool ignore_sender, uint8 minstatus, uint8 maxstatus)
  2703.  {
  2704. -   LinkedListIterator<Client*> iterator(client_list);
  2705. +   auto it = client_list.begin();
  2706. +   while (it != client_list.end()) {
  2707. +       if ((!ignore_sender || it->second != sender) &&
  2708. +               (it->second->Admin() >= minstatus && it->second->Admin() <= maxstatus))
  2709. +           it->second->QueuePacket(app);
  2710.  
  2711. -   iterator.Reset();
  2712. -   while(iterator.MoreElements())
  2713. -   {
  2714. -       if ((!ignore_sender || iterator.GetData() != sender) && (iterator.GetData()->Admin() >= minstatus && iterator.GetData()->Admin() <= maxstatus))
  2715. -       {
  2716. -           iterator.GetData()->QueuePacket(app);
  2717. -       }
  2718. -       iterator.Advance();
  2719. +       ++it;
  2720.     }
  2721.  }
  2722.  
  2723. -void EntityList::DuelMessage(Mob* winner, Mob* loser, bool flee) {
  2724. -   LinkedListIterator<Client*> iterator(client_list);
  2725. -
  2726. -   if(winner->GetLevelCon(winner->GetLevel(), loser->GetLevel()) > 2)
  2727. -   {
  2728. +void EntityList::DuelMessage(Mob *winner, Mob *loser, bool flee)
  2729. +{
  2730. +   if (winner->GetLevelCon(winner->GetLevel(), loser->GetLevel()) > 2) {
  2731.         std::vector<void*> args;
  2732.         args.push_back(winner);
  2733.         args.push_back(loser);
  2734. @@ -1713,163 +1447,124 @@ void EntityList::DuelMessage(Mob* winner, Mob* loser, bool flee) {
  2735.         parse->EventPlayer(EVENT_DUEL_LOSE, loser->CastToClient(), winner->GetName(), winner->CastToClient()->CharacterID(), &args);
  2736.     }
  2737.  
  2738. -   iterator.Reset();
  2739. -   while(iterator.MoreElements()) {
  2740. -       Client *cur = iterator.GetData();
  2741. +   auto it = client_list.begin();
  2742. +   while (it != client_list.end()) {
  2743. +       Client *cur = it->second;
  2744.         //might want some sort of distance check in here?
  2745. -       if (cur != winner && cur != loser)
  2746. -       {
  2747. +       if (cur != winner && cur != loser) {
  2748.             if (flee)
  2749.                 cur->Message_StringID(15, DUEL_FLED, winner->GetName(),loser->GetName(),loser->GetName());
  2750.             else
  2751.                 cur->Message_StringID(15, DUEL_FINISHED, winner->GetName(),loser->GetName());
  2752.         }
  2753. -       iterator.Advance();
  2754. +       ++it;
  2755.     }
  2756.  }
  2757.  
  2758. -Client* EntityList::GetClientByName(const char *checkname) {
  2759. -   LinkedListIterator<Client*> iterator(client_list);
  2760. -
  2761. -   iterator.Reset();
  2762. -   while(iterator.MoreElements())
  2763. -   {
  2764. -       if (strcasecmp(iterator.GetData()->GetName(), checkname) == 0) {
  2765. -           return iterator.GetData();
  2766. -       }
  2767. -       iterator.Advance();
  2768. +Client *EntityList::GetClientByName(const char *checkname)
  2769. +{
  2770. +   auto it = client_list.begin();
  2771. +   while (it != client_list.end()) {
  2772. +       if (strcasecmp(it->second->GetName(), checkname) == 0)
  2773. +           return it->second;
  2774. +       ++it;
  2775.     }
  2776. -   return 0;
  2777. +   return nullptr;
  2778.  }
  2779.  
  2780. -Client* EntityList::GetClientByCharID(uint32 iCharID) {
  2781. -   LinkedListIterator<Client*> iterator(client_list);
  2782. -
  2783. -   iterator.Reset();
  2784. -   while(iterator.MoreElements()) {
  2785. -       if (iterator.GetData()->CharacterID() == iCharID) {
  2786. -
  2787. -           return iterator.GetData();
  2788. -       }
  2789. -       iterator.Advance();
  2790. +Client *EntityList::GetClientByCharID(uint32 iCharID)
  2791. +{
  2792. +   auto it = client_list.begin();
  2793. +   while (it != client_list.end()) {
  2794. +       if (it->second->CharacterID() == iCharID)
  2795. +           return it->second;
  2796. +       ++it;
  2797.     }
  2798. -   return 0;
  2799. +   return nullptr;
  2800.  }
  2801.  
  2802. -Client* EntityList::GetClientByWID(uint32 iWID) {
  2803. -   LinkedListIterator<Client*> iterator(client_list);
  2804. -
  2805. -   iterator.Reset();
  2806. -   while(iterator.MoreElements()) {
  2807. -       if (iterator.GetData()->GetWID() == iWID) {
  2808. -           return iterator.GetData();
  2809. +Client *EntityList::GetClientByWID(uint32 iWID)
  2810. +{
  2811. +   auto it = client_list.begin();
  2812. +   while (it != client_list.end()) {
  2813. +       if (it->second->GetWID() == iWID) {
  2814. +           return it->second;
  2815.         }
  2816. -       iterator.Advance();
  2817. +       ++it;
  2818.     }
  2819. -   return 0;
  2820. +   return nullptr;
  2821.  }
  2822.  
  2823. -Client* EntityList::GetRandomClient(float x, float y, float z, float Distance, Client* ExcludeClient)
  2824. +Client *EntityList::GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient)
  2825.  {
  2826. -   std::vector<Client*> ClientsInRange;
  2827. -
  2828. -   LinkedListIterator<Client*> iterator(client_list);
  2829. -
  2830. -   iterator.Reset();
  2831. -   while(iterator.MoreElements())
  2832. -   {
  2833. -       if((iterator.GetData() != ExcludeClient) && (iterator.GetData()->DistNoRoot(x, y, z) <= Distance))
  2834. -       {
  2835. -           ClientsInRange.push_back(iterator.GetData());
  2836. -       }
  2837. +   std::vector<Client *> ClientsInRange;
  2838.  
  2839. -       iterator.Advance();
  2840. +   auto it = client_list.begin();
  2841. +   while (it != client_list.end()) {
  2842. +       if ((it->second != ExcludeClient) && (it->second->DistNoRoot(x, y, z) <= Distance))
  2843. +           ClientsInRange.push_back(it->second);
  2844. +       ++it;
  2845.     }
  2846.  
  2847. -   if(ClientsInRange.size() == 0)
  2848. +   if (ClientsInRange.empty())
  2849.         return nullptr;
  2850.  
  2851.     return ClientsInRange[MakeRandomInt(0, ClientsInRange.size() - 1)];
  2852.  }
  2853.  
  2854. -Corpse*    EntityList::GetCorpseByOwner(Client* client){
  2855. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2856. -
  2857. -   iterator.Reset();
  2858. -   while(iterator.MoreElements())
  2859. -   {
  2860. -       if (iterator.GetData()->IsPlayerCorpse())
  2861. -       {
  2862. -           if (strcasecmp(iterator.GetData()->GetOwnerName(), client->GetName()) == 0) {
  2863. -               return iterator.GetData();
  2864. -           }
  2865. -       }
  2866. -       iterator.Advance();
  2867. -   }
  2868. -   return 0;
  2869. -}
  2870. -
  2871. -Corpse*    EntityList::GetCorpseByOwnerWithinRange(Client* client, Mob* center, int range){
  2872. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2873. -
  2874. -   iterator.Reset();
  2875. -   while(iterator.MoreElements())
  2876. -   {
  2877. -       if (iterator.GetData()->IsPlayerCorpse())
  2878. -       {
  2879. -           if (center->DistNoRootNoZ(*iterator.GetData()) < range && strcasecmp(iterator.GetData()->GetOwnerName(), client->GetName()) == 0) {
  2880. -               return iterator.GetData();
  2881. -           }
  2882. -       }
  2883. -       iterator.Advance();
  2884. +Corpse *EntityList::GetCorpseByOwner(Client *client)
  2885. +{
  2886. +   auto it = corpse_list.begin();
  2887. +   while (it != corpse_list.end()) {
  2888. +       if (it->second->IsPlayerCorpse())
  2889. +           if (strcasecmp(it->second->GetOwnerName(), client->GetName()) == 0)
  2890. +               return it->second;
  2891. +       ++it;
  2892.     }
  2893. -   return 0;
  2894. +   return nullptr;
  2895.  }
  2896.  
  2897. -Corpse* EntityList::GetCorpseByID(uint16 id){
  2898. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2899. -   iterator.Reset();
  2900. -   while(iterator.MoreElements())
  2901. -   {
  2902. -       if (iterator.GetData()->id == id) {
  2903. -           return iterator.GetData();
  2904. -       }
  2905. -       iterator.Advance();
  2906. +Corpse *EntityList::GetCorpseByOwnerWithinRange(Client *client, Mob *center, int range)
  2907. +{
  2908. +   auto it = corpse_list.begin();
  2909. +   while (it != corpse_list.end()) {
  2910. +       if (it->second->IsPlayerCorpse())
  2911. +           if (center->DistNoRootNoZ(*it->second) < range &&
  2912. +                   strcasecmp(it->second->GetOwnerName(), client->GetName()) == 0)
  2913. +               return it->second;
  2914. +       ++it;
  2915.     }
  2916. -   return 0;
  2917. +   return nullptr;
  2918.  }
  2919.  
  2920. -Corpse* EntityList::GetCorpseByDBID(uint32 dbid){
  2921. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2922. -   iterator.Reset();
  2923. -   while(iterator.MoreElements())
  2924. -   {
  2925. -       if (iterator.GetData()->GetDBID() == dbid) {
  2926. -           return iterator.GetData();
  2927. -       }
  2928. -       iterator.Advance();
  2929. +Corpse *EntityList::GetCorpseByDBID(uint32 dbid)
  2930. +{
  2931. +   auto it = corpse_list.begin();
  2932. +   while (it != corpse_list.end()) {
  2933. +       if (it->second->GetDBID() == dbid)
  2934. +           return it->second;
  2935. +       ++it;
  2936.     }
  2937. -   return 0;
  2938. +   return nullptr;
  2939.  }
  2940.  
  2941. -Corpse* EntityList::GetCorpseByName(const char* name){
  2942. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2943. -   iterator.Reset();
  2944. -   while(iterator.MoreElements())
  2945. -   {
  2946. -       if (strcmp(iterator.GetData()->GetName(),name)==0) {
  2947. -           return iterator.GetData();
  2948. -       }
  2949. -       iterator.Advance();
  2950. +Corpse *EntityList::GetCorpseByName(const char *name)
  2951. +{
  2952. +   auto it = corpse_list.begin();
  2953. +   while (it != corpse_list.end()) {
  2954. +       if (strcmp(it->second->GetName(), name) == 0)
  2955. +           return it->second;
  2956. +       ++it;
  2957.     }
  2958. -   return 0;
  2959. +   return nullptr;
  2960.  }
  2961.  
  2962. -Spawn2* EntityList::GetSpawnByID(uint32 id) {
  2963. -   if(!zone)
  2964. +Spawn2 *EntityList::GetSpawnByID(uint32 id)
  2965. +{
  2966. +   if (!zone)
  2967.         return nullptr;
  2968.  
  2969. -   LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
  2970. +   LinkedListIterator<Spawn2 *> iterator(zone->spawn2_list);
  2971.     iterator.Reset();
  2972.     while(iterator.MoreElements())
  2973.     {
  2974. @@ -1884,27 +1579,27 @@ Spawn2* EntityList::GetSpawnByID(uint32 id) {
  2975.  
  2976.  void EntityList::RemoveAllCorpsesByCharID(uint32 charid)
  2977.  {
  2978. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  2979. -   iterator.Reset();
  2980. -   while(iterator.MoreElements())
  2981. -   {
  2982. -       if (iterator.GetData()->GetCharID() == charid)
  2983. -           iterator.RemoveCurrent();
  2984. -       else
  2985. -           iterator.Advance();
  2986. +   auto it = corpse_list.begin();
  2987. +   while (it != corpse_list.end()) {
  2988. +       if (it->second->GetCharID() == charid) {
  2989. +           safe_delete(it->second);
  2990. +           it = corpse_list.erase(it);
  2991. +       } else {
  2992. +           ++it;
  2993. +       }
  2994.     }
  2995.  }
  2996.  
  2997.  void EntityList::RemoveCorpseByDBID(uint32 dbid)
  2998.  {
  2999. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  3000. -   iterator.Reset();
  3001. -   while(iterator.MoreElements())
  3002. -   {
  3003. -       if (iterator.GetData()->GetDBID() == dbid)
  3004. -           iterator.RemoveCurrent();
  3005. -       else
  3006. -           iterator.Advance();
  3007. +   auto it = corpse_list.begin();
  3008. +   while (it != corpse_list.end()) {
  3009. +       if (it->second->GetDBID() == dbid) {
  3010. +           safe_delete(it->second);
  3011. +           it = corpse_list.erase(it);
  3012. +       } else {
  3013. +           ++it;
  3014. +       }
  3015.     }
  3016.  }
  3017.  
  3018. @@ -1912,219 +1607,188 @@ int EntityList::RezzAllCorpsesByCharID(uint32 charid)
  3019.  {
  3020.     int RezzExp = 0;
  3021.  
  3022. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  3023. -   iterator.Reset();
  3024. -   while(iterator.MoreElements())
  3025. -   {
  3026. -       if (iterator.GetData()->GetCharID() == charid)
  3027. -       {
  3028. -           RezzExp += iterator.GetData()->GetRezzExp();
  3029. -           iterator.GetData()->Rezzed(true);
  3030. -           iterator.GetData()->CompleteRezz();
  3031. +   auto it = corpse_list.begin();
  3032. +   while (it != corpse_list.end()) {
  3033. +       if (it->second->GetCharID() == charid) {
  3034. +           RezzExp += it->second->GetRezzExp();
  3035. +           it->second->Rezzed(true);
  3036. +           it->second->CompleteRezz();
  3037.         }
  3038. -       iterator.Advance();
  3039. +       ++it;
  3040.     }
  3041.     return RezzExp;
  3042.  }
  3043.  
  3044. -Group* EntityList::GetGroupByMob(Mob* mob)
  3045. +Group *EntityList::GetGroupByMob(Mob *mob)
  3046.  {
  3047.     std::list<Group *>::iterator iterator;
  3048.  
  3049.     iterator = group_list.begin();
  3050.  
  3051. -   while(iterator != group_list.end())
  3052. -   {
  3053. -       if ((*iterator)->IsGroupMember(mob)) {
  3054. +   while (iterator != group_list.end()) {
  3055. +       if ((*iterator)->IsGroupMember(mob))
  3056.             return *iterator;
  3057. -       }
  3058.         ++iterator;
  3059.     }
  3060.  #if EQDEBUG >= 5
  3061.     CheckGroupList (__FILE__, __LINE__);
  3062.  #endif
  3063. -   return 0;
  3064. +   return nullptr;
  3065.  }
  3066.  
  3067. -Group* EntityList::GetGroupByLeaderName(const char* leader){
  3068. +Group *EntityList::GetGroupByLeaderName(const char *leader)
  3069. +{
  3070.     std::list<Group *>::iterator iterator;
  3071.  
  3072.     iterator = group_list.begin();
  3073.  
  3074. -   while(iterator != group_list.end())
  3075. -   {
  3076. -       if (!strcmp((*iterator)->GetLeaderName(), leader)) {
  3077. +   while (iterator != group_list.end()) {
  3078. +       if (!strcmp((*iterator)->GetLeaderName(), leader))
  3079.             return *iterator;
  3080. -       }
  3081.         ++iterator;
  3082.     }
  3083.  #if EQDEBUG >= 5
  3084.     CheckGroupList (__FILE__, __LINE__);
  3085.  #endif
  3086. -   return 0;
  3087. +   return nullptr;
  3088.  }
  3089. -Group* EntityList::GetGroupByID(uint32 group_id){
  3090. +
  3091. +Group *EntityList::GetGroupByID(uint32 group_id)
  3092. +{
  3093.     std::list<Group *>::iterator iterator;
  3094.  
  3095.     iterator = group_list.begin();
  3096.  
  3097. -   while(iterator != group_list.end())
  3098. -   {
  3099. -       if ((*iterator)->GetID() == group_id) {
  3100. +   while (iterator != group_list.end()) {
  3101. +       if ((*iterator)->GetID() == group_id)
  3102.             return *iterator;
  3103. -       }
  3104.         ++iterator;
  3105.     }
  3106.  #if EQDEBUG >= 5
  3107.     CheckGroupList (__FILE__, __LINE__);
  3108.  #endif
  3109. -   return 0;
  3110. +   return nullptr;
  3111.  }
  3112. -Group* EntityList::GetGroupByClient(Client* client)
  3113. +
  3114. +Group *EntityList::GetGroupByClient(Client *client)
  3115.  {
  3116.     std::list <Group *>::iterator iterator;
  3117.  
  3118.     iterator = group_list.begin();
  3119.  
  3120. -   while(iterator != group_list.end())
  3121. -   {
  3122. -       if ((*iterator)->IsGroupMember(client->CastToMob())) {
  3123. +   while (iterator != group_list.end()) {
  3124. +       if ((*iterator)->IsGroupMember(client->CastToMob()))
  3125.             return *iterator;
  3126. -       }
  3127.         ++iterator;
  3128.     }
  3129.  #if EQDEBUG >= 5
  3130.     CheckGroupList (__FILE__, __LINE__);
  3131.  #endif
  3132. -   return 0;
  3133. +   return nullptr;
  3134.  }
  3135.  
  3136. -Raid* EntityList::GetRaidByLeaderName(const char *leader){
  3137. +Raid *EntityList::GetRaidByLeaderName(const char *leader)
  3138. +{
  3139.     std::list<Raid *>::iterator iterator;
  3140.  
  3141.     iterator = raid_list.begin();
  3142.  
  3143. -   while(iterator != raid_list.end())
  3144. -   {
  3145. -       if((*iterator)->GetLeader()){
  3146. -           if(strcmp((*iterator)->GetLeader()->GetName(), leader) == 0){
  3147. +   while (iterator != raid_list.end()) {
  3148. +       if ((*iterator)->GetLeader())
  3149. +           if(strcmp((*iterator)->GetLeader()->GetName(), leader) == 0)
  3150.                 return *iterator;
  3151. -   }
  3152. -}
  3153.         ++iterator;
  3154.     }
  3155. -   return 0;
  3156. +   return nullptr;
  3157.  }
  3158. -Raid* EntityList::GetRaidByID(uint32 id){
  3159. +
  3160. +Raid *EntityList::GetRaidByID(uint32 id)
  3161. +{
  3162.     std::list<Raid *>::iterator iterator;
  3163.  
  3164.     iterator = raid_list.begin();
  3165.  
  3166. -   while(iterator != raid_list.end())
  3167. -   {
  3168. -       if ((*iterator)->GetID() == id) {
  3169. +   while (iterator != raid_list.end()) {
  3170. +       if ((*iterator)->GetID() == id)
  3171.             return *iterator;
  3172. -       }
  3173.         ++iterator;
  3174.     }
  3175. -   return 0;
  3176. +   return nullptr;
  3177.  }
  3178.  
  3179. -Raid* EntityList::GetRaidByClient(Client* client)
  3180. +Raid *EntityList::GetRaidByClient(Client* client)
  3181.  {
  3182.     std::list<Raid *>::iterator iterator;
  3183.  
  3184.     iterator = raid_list.begin();
  3185.  
  3186. -   while(iterator != raid_list.end())
  3187. -   {
  3188. -       for(int x = 0; x < MAX_RAID_MEMBERS; x++)
  3189. -       {
  3190. -           if((*iterator)->members[x].member){
  3191. +   while (iterator != raid_list.end()) {
  3192. +       for (int x = 0; x < MAX_RAID_MEMBERS; x++)
  3193. +           if ((*iterator)->members[x].member)
  3194.                 if((*iterator)->members[x].member == client)
  3195.                     return *iterator;
  3196. -           }
  3197. -       }
  3198.         ++iterator;
  3199.     }
  3200. -   return 0;
  3201. +   return nullptr;
  3202.  }
  3203.  
  3204. -Raid* EntityList::GetRaidByMob(Mob* mob) {
  3205. +Raid *EntityList::GetRaidByMob(Mob *mob)
  3206. +{
  3207.     std::list<Raid *>::iterator iterator;
  3208.  
  3209.     iterator = raid_list.begin();
  3210.  
  3211. -   while(iterator != raid_list.end())
  3212. -   {
  3213. -       for(int x = 0; x < MAX_RAID_MEMBERS; x++)
  3214. -       {
  3215. +   while (iterator != raid_list.end()) {
  3216. +       for(int x = 0; x < MAX_RAID_MEMBERS; x++) {
  3217.             // TODO: Implement support for Mob objects in Raid class
  3218. -           /*if((*iterator)->members[x].member){
  3219. -               if((*iterator)->members[x].member == mob)
  3220. -                   return *iterator;
  3221. -           }*/
  3222. -       }
  3223. -       ++iterator;
  3224. -   }
  3225. -   return 0;
  3226. -}
  3227. -
  3228. -Client* EntityList::GetClientByAccID(uint32 accid)
  3229. -{
  3230. -   LinkedListIterator<Client*> iterator(client_list);
  3231. -
  3232. -   iterator.Reset();
  3233. -   while(iterator.MoreElements())
  3234. -   {
  3235. -       if (iterator.GetData()->AccountID() == accid) {
  3236. -           return iterator.GetData();
  3237. +           /*if((*iterator)->members[x].member){
  3238. +               if((*iterator)->members[x].member == mob)
  3239. +                   return *iterator;
  3240. +           }*/
  3241.         }
  3242. -       iterator.Advance();
  3243. +       ++iterator;
  3244.     }
  3245. -   return 0;
  3246. +   return nullptr;
  3247.  }
  3248. -Client* EntityList::GetClientByID(uint16 id) {
  3249. -   LinkedListIterator<Client*> iterator(client_list);
  3250.  
  3251. -   iterator.Reset();
  3252. -   while(iterator.MoreElements())
  3253. -   {
  3254. -       if (iterator.GetData())
  3255. -       {
  3256. -           if (iterator.GetData()->GetID() == id) {
  3257. -               return iterator.GetData();
  3258. -           }
  3259. -       }
  3260. -       iterator.Advance();
  3261. +Client *EntityList::GetClientByAccID(uint32 accid)
  3262. +{
  3263. +   auto it = client_list.begin();
  3264. +   while (it != client_list.end()) {
  3265. +       if (it->second->AccountID() == accid)
  3266. +           return it->second;
  3267. +       ++it;
  3268.     }
  3269. -   return 0;
  3270. +   return nullptr;
  3271.  }
  3272.  
  3273. -void EntityList::ChannelMessageFromWorld(const char* from, const char* to, uint8 chan_num, uint32 guild_id, uint8 language, const char* message) {
  3274. -
  3275. -   LinkedListIterator<Client*> iterator(client_list);
  3276. +Client *EntityList::GetClientByID(uint16 id)
  3277. +{
  3278. +   return client_list.count(id) ? client_list.at(id) : nullptr;
  3279. +}
  3280.  
  3281. -   iterator.Reset();
  3282. -   for(; iterator.MoreElements(); iterator.Advance())
  3283. -   {
  3284. -       Client* client = iterator.GetData();
  3285. -       if(chan_num == 0) {
  3286. -           if(!client->IsInGuild(guild_id))
  3287. +void EntityList::ChannelMessageFromWorld(const char *from, const char *to,
  3288. +       uint8 chan_num, uint32 guild_id, uint8 language, const char *message)
  3289. +{
  3290. +   for (auto it = client_list.begin(); it != client_list.end(); ++it) {
  3291. +       Client *client = it->second;
  3292. +       if (chan_num == 0) {
  3293. +           if (!client->IsInGuild(guild_id))
  3294.                 continue;
  3295. -           if(!guild_mgr.CheckPermission(guild_id, client->GuildRank(), GUILD_HEAR))
  3296. +           if (!guild_mgr.CheckPermission(guild_id, client->GuildRank(), GUILD_HEAR))
  3297.                 continue;
  3298. -           if(client->GetFilter(FilterGuildChat) == FilterHide)
  3299. +           if (client->GetFilter(FilterGuildChat) == FilterHide)
  3300.                 continue;
  3301. -       } else if(chan_num == 5) {
  3302. -           if(client->GetFilter(FilterOOC) == FilterHide)
  3303. +       } else if (chan_num == 5) {
  3304. +           if (client->GetFilter(FilterOOC) == FilterHide)
  3305.                 continue;
  3306.         }
  3307.         client->ChannelMessageSend(from, to, chan_num, language, message);
  3308.     }
  3309.  }
  3310.  
  3311. -void EntityList::Message(uint32 to_guilddbid, uint32 type, const char* message, ...) {
  3312. +void EntityList::Message(uint32 to_guilddbid, uint32 type, const char *message, ...)
  3313. +{
  3314.     va_list argptr;
  3315.     char buffer[4096];
  3316.  
  3317. @@ -2132,27 +1796,24 @@ void EntityList::Message(uint32 to_guilddbid, uint32 type, const char* message,
  3318.     vsnprintf(buffer, 4096, message, argptr);
  3319.     va_end(argptr);
  3320.  
  3321. -   LinkedListIterator<Client*> iterator(client_list);
  3322. -
  3323. -   iterator.Reset();
  3324. -   while(iterator.MoreElements())
  3325. -   {
  3326. -       Client* client = iterator.GetData();
  3327. +   auto it = client_list.begin();
  3328. +   while (it != client_list.end()) {
  3329. +       Client *client = it->second;
  3330.         if (to_guilddbid == 0 || client->IsInGuild(to_guilddbid))
  3331.             client->Message(type, buffer);
  3332. -       iterator.Advance();
  3333. +       ++it;
  3334.     }
  3335.  }
  3336.  
  3337. -void EntityList::QueueClientsGuild(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, uint32 guild_id){
  3338. -   LinkedListIterator<Client*> iterator(client_list);
  3339. -   iterator.Reset();
  3340. -   while(iterator.MoreElements())
  3341. -   {
  3342. -       Client* client = iterator.GetData()->CastToClient();
  3343. +void EntityList::QueueClientsGuild(Mob *sender, const EQApplicationPacket *app,
  3344. +       bool ignore_sender, uint32 guild_id)
  3345. +{
  3346. +   auto it = client_list.begin();
  3347. +   while (it != client_list.end()) {
  3348. +       Client *client = it->second;
  3349.         if (client->IsInGuild(guild_id))
  3350.             client->QueuePacket(app);
  3351. -       iterator.Advance();
  3352. +       ++it;
  3353.     }
  3354.  }
  3355.  
  3356. @@ -2166,28 +1827,24 @@ void EntityList::QueueClientsGuildBankItemUpdate(const GuildBankItemUpdate_Struc
  3357.  
  3358.     const Item_Struct *Item = database.GetItem(gbius->ItemID);
  3359.  
  3360. -   LinkedListIterator<Client*> iterator(client_list);
  3361. -
  3362. -   iterator.Reset();
  3363. -
  3364. -   while(iterator.MoreElements())
  3365. -   {
  3366. -       Client* client = iterator.GetData()->CastToClient();
  3367. +   auto it = client_list.begin();
  3368. +   while (it != client_list.end()) {
  3369. +       Client *client = it->second;
  3370.  
  3371. -       if (client->IsInGuild(GuildID))
  3372. -       {
  3373. -           if(Item && (gbius->Permissions == GuildBankPublicIfUsable))
  3374. +       if (client->IsInGuild(GuildID)) {
  3375. +           if (Item && (gbius->Permissions == GuildBankPublicIfUsable))
  3376.                 outgbius->Useable = Item->IsEquipable(client->GetBaseRace(), client->GetBaseClass());
  3377.  
  3378.             client->QueuePacket(outapp);
  3379.         }
  3380.  
  3381. -       iterator.Advance();
  3382. +       ++it;
  3383.     }
  3384.     safe_delete(outapp);
  3385.  }
  3386.  
  3387. -void EntityList::MessageStatus(uint32 to_guild_id, int to_minstatus, uint32 type, const char* message, ...) {
  3388. +void EntityList::MessageStatus(uint32 to_guild_id, int to_minstatus, uint32 type, const char *message, ...)
  3389. +{
  3390.     va_list argptr;
  3391.     char buffer[4096];
  3392.  
  3393. @@ -2195,14 +1852,12 @@ void EntityList::MessageStatus(uint32 to_guild_id, int to_minstatus, uint32 type
  3394.     vsnprintf(buffer, 4096, message, argptr);
  3395.     va_end(argptr);
  3396.  
  3397. -   LinkedListIterator<Client*> iterator(client_list);
  3398. -
  3399. -   iterator.Reset();
  3400. -   while(iterator.MoreElements()) {
  3401. -       Client* client = iterator.GetData();
  3402. +   auto it = client_list.begin();
  3403. +   while (it != client_list.end()) {
  3404. +       Client *client = it->second;
  3405.         if ((to_guild_id == 0 || client->IsInGuild(to_guild_id)) && client->Admin() >= to_minstatus)
  3406.             client->Message(type, buffer);
  3407. -       iterator.Advance();
  3408. +       ++it;
  3409.     }
  3410.  }
  3411.  
  3412. @@ -2210,13 +1865,10 @@ void EntityList::MessageStatus(uint32 to_guild_id, int to_minstatus, uint32 type
  3413.  void EntityList::MessageClose_StringID(Mob *sender, bool skipsender, float dist, uint32 type, uint32 string_id, const char* message1,const char* message2,const char* message3,const char* message4,const char* message5,const char* message6,const char* message7,const char* message8,const char* message9)
  3414.  {
  3415.     Client *c;
  3416. -   LinkedListIterator<Client*> iterator(client_list);
  3417.     float dist2 = dist * dist;
  3418.  
  3419. -
  3420. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  3421. -   {
  3422. -       c = iterator.GetData();
  3423. +   for (auto it = client_list.begin(); it != client_list.end(); ++it) {
  3424. +       c = it->second;
  3425.         if(c && c->DistNoRoot(*sender) <= dist2 && (!skipsender || c != sender))
  3426.             c->Message_StringID(type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9);
  3427.     }
  3428. @@ -2225,18 +1877,16 @@ void EntityList::MessageClose_StringID(Mob *sender, bool skipsender, float dist,
  3429.  void EntityList::Message_StringID(Mob *sender, bool skipsender, uint32 type, uint32 string_id, const char* message1,const char* message2,const char* message3,const char* message4,const char* message5,const char* message6,const char* message7,const char* message8,const char* message9)
  3430.  {
  3431.     Client *c;
  3432. -   LinkedListIterator<Client*> iterator(client_list);
  3433.  
  3434. -
  3435. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  3436. -   {
  3437. -       c = iterator.GetData();
  3438. +   for (auto it = client_list.begin(); it != client_list.end(); ++it) {
  3439. +       c = it->second;
  3440.         if(c && (!skipsender || c != sender))
  3441.             c->Message_StringID(type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9);
  3442.     }
  3443.  }
  3444.  
  3445. -void EntityList::MessageClose(Mob* sender, bool skipsender, float dist, uint32 type, const char* message, ...) {
  3446. +void EntityList::MessageClose(Mob* sender, bool skipsender, float dist, uint32 type, const char* message, ...)
  3447. +{
  3448.     va_list argptr;
  3449.     char buffer[4096];
  3450.  
  3451. @@ -2246,46 +1896,43 @@ void EntityList::MessageClose(Mob* sender, bool skipsender, float dist, uint32 t
  3452.  
  3453.     float dist2 = dist * dist;
  3454.  
  3455. -   LinkedListIterator<Client*> iterator(client_list);
  3456. -
  3457. -   iterator.Reset();
  3458. -   while(iterator.MoreElements())
  3459. -   {
  3460. -       if (iterator.GetData()->DistNoRoot(*sender) <= dist2 && (!skipsender || iterator.GetData() != sender)) {
  3461. -           iterator.GetData()->Message(type, buffer);
  3462. -       }
  3463. -       iterator.Advance();
  3464. +   auto it = client_list.begin();
  3465. +   while (it != client_list.end()) {
  3466. +       if (it->second->DistNoRoot(*sender) <= dist2 && (!skipsender || it->second != sender))
  3467. +           it->second->Message(type, buffer);
  3468. +       ++it;
  3469.     }
  3470.  }
  3471.  
  3472. -void EntityList::RemoveAllMobs(){
  3473. -   LinkedListIterator<Mob*> iterator(mob_list);
  3474. -   iterator.Reset();
  3475. -   while(iterator.MoreElements())
  3476. -       iterator.RemoveCurrent();
  3477. +void EntityList::RemoveAllMobs()
  3478. +{
  3479. +   auto it = mob_list.begin();
  3480. +   while (it != mob_list.end()) {
  3481. +       safe_delete(it->second);
  3482. +       it = mob_list.erase(it);
  3483. +   }
  3484.  }
  3485. -void EntityList::RemoveAllClients(){
  3486. -   LinkedListIterator<Client*> iterator(client_list);
  3487. -   iterator.Reset();
  3488. -   while(iterator.MoreElements())
  3489. -       iterator.RemoveCurrent(false);
  3490. +
  3491. +void EntityList::RemoveAllClients()
  3492. +{
  3493. +   // doesn't clear the data
  3494. +   client_list.clear();
  3495.  }
  3496. -void EntityList::RemoveAllNPCs(){
  3497. -   LinkedListIterator<NPC*> iterator(npc_list);
  3498. -   iterator.Reset();
  3499. -   while(iterator.MoreElements()) {
  3500. -       iterator.RemoveCurrent(false);
  3501. -   }
  3502. +
  3503. +void EntityList::RemoveAllNPCs()
  3504. +{
  3505. +   // doesn't clear the data
  3506. +   npc_list.clear();
  3507.     npc_limit_list.clear();
  3508.  }
  3509. -void EntityList::RemoveAllMercs(){
  3510. -   LinkedListIterator<Merc*> iterator(merc_list);
  3511. -   iterator.Reset();
  3512. -   while(iterator.MoreElements()) {
  3513. -       iterator.RemoveCurrent(false);
  3514. -   }
  3515. +
  3516. +void EntityList::RemoveAllMercs()
  3517. +{
  3518. +   merc_list.clear();
  3519.  }
  3520. -void EntityList::RemoveAllGroups(){
  3521. +
  3522. +void EntityList::RemoveAllGroups()
  3523. +{
  3524.     while (group_list.size())
  3525.         group_list.pop_front();
  3526.  #if EQDEBUG >= 5
  3527. @@ -2293,207 +1940,200 @@ void EntityList::RemoveAllGroups(){
  3528.  #endif
  3529.  }
  3530.  
  3531. -void EntityList::RemoveAllRaids(){
  3532. +void EntityList::RemoveAllRaids()
  3533. +{
  3534.     while (raid_list.size())
  3535.         raid_list.pop_front();
  3536.  }
  3537.  
  3538. -void EntityList::RemoveAllDoors(){
  3539. -   LinkedListIterator<Doors*> iterator(door_list);
  3540. -   iterator.Reset();
  3541. -   while(iterator.MoreElements())
  3542. -       iterator.RemoveCurrent();
  3543. +void EntityList::RemoveAllDoors()
  3544. +{
  3545. +   auto it = door_list.begin();
  3546. +   while (it != door_list.end()) {
  3547. +       safe_delete(it->second);
  3548. +       it = door_list.erase(it);
  3549. +   }
  3550.     DespawnAllDoors();
  3551.  }
  3552.  
  3553. -void EntityList::DespawnAllDoors(){
  3554. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_RemoveAllDoors, 0);
  3555. +void EntityList::DespawnAllDoors()
  3556. +{
  3557. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_RemoveAllDoors, 0);
  3558.     this->QueueClients(0,outapp);
  3559.     safe_delete(outapp);
  3560.  }
  3561.  
  3562. -void EntityList::RespawnAllDoors(){
  3563. -   LinkedListIterator<Client*> iterator(client_list);
  3564. -   iterator.Reset();
  3565. -   while(iterator.MoreElements())
  3566. -   {
  3567. -       if(iterator.GetData() != 0)
  3568. -       {
  3569. -       EQApplicationPacket* outapp = new EQApplicationPacket();
  3570. -       MakeDoorSpawnPacket(outapp, iterator.GetData());
  3571. -       iterator.GetData()->FastQueuePacket(&outapp);
  3572. +void EntityList::RespawnAllDoors()
  3573. +{
  3574. +   auto it = client_list.begin();
  3575. +   while (it != client_list.end()) {
  3576. +       if (it->second) {
  3577. +           EQApplicationPacket *outapp = new EQApplicationPacket();
  3578. +           MakeDoorSpawnPacket(outapp, it->second);
  3579. +           it->second->FastQueuePacket(&outapp);
  3580.         }
  3581. -       iterator.Advance();
  3582. +       ++it;
  3583.     }
  3584.  }
  3585.  
  3586. -void EntityList::RemoveAllCorpses(){
  3587. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  3588. -   iterator.Reset();
  3589. -   while(iterator.MoreElements())
  3590. -       iterator.RemoveCurrent();
  3591. +void EntityList::RemoveAllCorpses()
  3592. +{
  3593. +   auto it = corpse_list.begin();
  3594. +   while (it != corpse_list.end()) {
  3595. +       safe_delete(it->second);
  3596. +       it = corpse_list.erase(it);
  3597. +   }
  3598.  }
  3599. -void EntityList::RemoveAllObjects(){
  3600. -   LinkedListIterator<Object*> iterator(object_list);
  3601. -   iterator.Reset();
  3602. -   while(iterator.MoreElements())
  3603. -       iterator.RemoveCurrent();
  3604. +
  3605. +void EntityList::RemoveAllObjects()
  3606. +{
  3607. +   auto it = object_list.begin();
  3608. +   while (it != object_list.end()) {
  3609. +       safe_delete(it->second);
  3610. +       it = object_list.erase(it);
  3611. +   }
  3612.  }
  3613. +
  3614.  void EntityList::RemoveAllTraps(){
  3615. -   LinkedListIterator<Trap*> iterator(trap_list);
  3616. -   iterator.Reset();
  3617. -   while(iterator.MoreElements())
  3618. -       iterator.RemoveCurrent();
  3619. +   auto it = trap_list.begin();
  3620. +   while (it != trap_list.end()) {
  3621. +       safe_delete(it->second);
  3622. +       it = trap_list.erase(it);
  3623. +   }
  3624.  }
  3625. -bool EntityList::RemoveMob(uint16 delete_id){
  3626. -   if(delete_id==0)
  3627. +
  3628. +bool EntityList::RemoveMob(uint16 delete_id)
  3629. +{
  3630. +   if (delete_id == 0)
  3631. +       return true;
  3632. +
  3633. +   auto it = mob_list.find(delete_id);
  3634. +   if (it != mob_list.end()) {
  3635. +       if (it->second->IsNPC())
  3636. +           entity_list.RemoveNPC(delete_id);
  3637. +       else if (it->second->IsClient())
  3638. +           entity_list.RemoveClient(delete_id);
  3639. +       safe_delete(it->second);
  3640. +       mob_list.erase(it);
  3641.         return true;
  3642. -   LinkedListIterator<Mob*> iterator(mob_list);
  3643. -   iterator.Reset();
  3644. -   while(iterator.MoreElements())
  3645. -   {
  3646. -       if(iterator.GetData()->GetID()==delete_id){
  3647. -           if(iterator.GetData()->IsNPC())
  3648. -               entity_list.RemoveNPC(delete_id);
  3649. -           else if(iterator.GetData()->IsClient())
  3650. -               entity_list.RemoveClient(delete_id);
  3651. -           iterator.RemoveCurrent();
  3652. -           return true;
  3653. -       }
  3654. -       iterator.Advance();
  3655.     }
  3656.     return false;
  3657.  }
  3658.  
  3659. -bool EntityList::RemoveMob(Mob *delete_mob) {
  3660. -   if(delete_mob==0)
  3661. +// This is for if the ID is deleted for some reason
  3662. +bool EntityList::RemoveMob(Mob *delete_mob)
  3663. +{
  3664. +   if (delete_mob == 0)
  3665.         return true;
  3666. -   LinkedListIterator<Mob*> iterator(mob_list);
  3667. -   iterator.Reset();
  3668. -   while(iterator.MoreElements())
  3669. -   {
  3670. -       if(iterator.GetData()==delete_mob){
  3671. -           iterator.RemoveCurrent();
  3672. +
  3673. +   auto it = mob_list.begin();
  3674. +   while (it != mob_list.end()) {
  3675. +       if (it->second == delete_mob) {
  3676. +           safe_delete(it->second);
  3677. +           mob_list.erase(it);
  3678.             return true;
  3679.         }
  3680. -       iterator.Advance();
  3681. +       ++it;
  3682.     }
  3683.     return false;
  3684.  }
  3685.  
  3686. -bool EntityList::RemoveNPC(uint16 delete_id){
  3687. -   LinkedListIterator<NPC*> iterator(npc_list);
  3688. -   iterator.Reset();
  3689. -   while(iterator.MoreElements())
  3690. -   {
  3691. -       if(iterator.GetData()->GetID()==delete_id){
  3692. -           //make sure its proximity is removed
  3693. -           RemoveProximity(iterator.GetData()->GetID());
  3694. -           //take it out of the list
  3695. -           iterator.RemoveCurrent(false);//Already Deleted
  3696. -           //take it out of our limit list
  3697. -           if(npc_limit_list.count(delete_id) == 1)
  3698. -               npc_limit_list.erase(delete_id);
  3699. -           return true;
  3700. -       }
  3701. -       iterator.Advance();
  3702. +bool EntityList::RemoveNPC(uint16 delete_id)
  3703. +{
  3704. +   auto it = npc_list.find(delete_id);
  3705. +   if (it != npc_list.end()) {
  3706. +       // make sure its proximity is removed
  3707. +       RemoveProximity(delete_id);
  3708. +       // remove from the list
  3709. +       npc_list.erase(it);
  3710. +       // remove from limit list if needed
  3711. +       if (npc_limit_list.count(delete_id))
  3712. +           npc_limit_list.erase(delete_id);
  3713. +       return true;
  3714.     }
  3715.     return false;
  3716.  }
  3717. -bool EntityList::RemoveMerc(uint16 delete_id){
  3718. -   LinkedListIterator<Merc*> iterator(merc_list);
  3719. -   iterator.Reset();
  3720. -   while(iterator.MoreElements())
  3721. -   {
  3722. -       if(iterator.GetData()->GetID()==delete_id){
  3723. -           iterator.RemoveCurrent(false);//Already Deleted
  3724. -           return true;
  3725. -       }
  3726. -       iterator.Advance();
  3727. +
  3728. +bool EntityList::RemoveMerc(uint16 delete_id)
  3729. +{
  3730. +   auto it = merc_list.find(delete_id);
  3731. +   if (it != merc_list.end()) {
  3732. +       merc_list.erase(it); // Already Deleted
  3733. +       return true;
  3734.     }
  3735.     return false;
  3736.  }
  3737. -bool EntityList::RemoveClient(uint16 delete_id){
  3738. -   LinkedListIterator<Client*> iterator(client_list);
  3739. -   iterator.Reset();
  3740. -   while(iterator.MoreElements())
  3741. -   {
  3742. -       if(iterator.GetData()->GetID()==delete_id){
  3743. -           iterator.RemoveCurrent(false);//Already Deleted
  3744. -           return true;
  3745. -       }
  3746. -       iterator.Advance();
  3747. +
  3748. +bool EntityList::RemoveClient(uint16 delete_id)
  3749. +{
  3750. +   auto it = client_list.find(delete_id);
  3751. +   if (it != client_list.end()) {
  3752. +       client_list.erase(it); // Already deleted
  3753. +       return true;
  3754.     }
  3755.     return false;
  3756.  }
  3757.  
  3758. -bool EntityList::RemoveClient(Client *delete_client){
  3759. -   LinkedListIterator<Client*> iterator(client_list);
  3760. -   iterator.Reset();
  3761. -   while(iterator.MoreElements())
  3762. -   {
  3763. -       if(iterator.GetData()==delete_client){
  3764. -           iterator.RemoveCurrent(false);//Already Deleted
  3765. +// If our ID was deleted already
  3766. +bool EntityList::RemoveClient(Client *delete_client)
  3767. +{
  3768. +   auto it = client_list.begin();
  3769. +   while (it != client_list.end()) {
  3770. +       if (it->second == delete_client) {
  3771. +           client_list.erase(it);
  3772.             return true;
  3773.         }
  3774. -       iterator.Advance();
  3775. +       ++it;
  3776.     }
  3777.     return false;
  3778.  }
  3779.  
  3780. -bool EntityList::RemoveObject(uint16 delete_id){
  3781. -   LinkedListIterator<Object*> iterator(object_list);
  3782. -   iterator.Reset();
  3783. -   while(iterator.MoreElements())
  3784. -   {
  3785. -       if(iterator.GetData()->GetID()==delete_id){
  3786. -           iterator.RemoveCurrent();
  3787. -           return true;
  3788. -       }
  3789. -       iterator.Advance();
  3790. +bool EntityList::RemoveObject(uint16 delete_id)
  3791. +{
  3792. +   auto it = object_list.find(delete_id);
  3793. +   if (it != object_list.end()) {
  3794. +       safe_delete(it->second);
  3795. +       object_list.erase(it);
  3796. +       return true;
  3797.     }
  3798.     return false;
  3799.  }
  3800. -bool EntityList::RemoveTrap(uint16 delete_id){
  3801. -   LinkedListIterator<Trap*> iterator(trap_list);
  3802. -   iterator.Reset();
  3803. -   while(iterator.MoreElements())
  3804. -   {
  3805. -       if(iterator.GetData()->GetID()==delete_id){
  3806. -           iterator.RemoveCurrent();
  3807. -           return true;
  3808. -       }
  3809. -       iterator.Advance();
  3810. +
  3811. +bool EntityList::RemoveTrap(uint16 delete_id)
  3812. +{
  3813. +   auto it = trap_list.find(delete_id);
  3814. +   if (it != trap_list.end()) {
  3815. +       safe_delete(it->second);
  3816. +       trap_list.erase(it);
  3817. +       return true;
  3818.     }
  3819.     return false;
  3820.  }
  3821. -bool EntityList::RemoveDoor(uint16 delete_id){
  3822. -   LinkedListIterator<Doors*> iterator(door_list);
  3823. -   iterator.Reset();
  3824. -   while(iterator.MoreElements())
  3825. -   {
  3826. -       if(iterator.GetData()->GetID()==delete_id){
  3827. -           iterator.RemoveCurrent();
  3828. -           return true;
  3829. -       }
  3830. -       iterator.Advance();
  3831. +
  3832. +bool EntityList::RemoveDoor(uint16 delete_id)
  3833. +{
  3834. +   auto it = door_list.find(delete_id);
  3835. +   if (it != door_list.end()) {
  3836. +       safe_delete(it->second);
  3837. +       door_list.erase(it);
  3838. +       return true;
  3839.     }
  3840.     return false;
  3841.  }
  3842. -bool EntityList::RemoveCorpse(uint16 delete_id){
  3843. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  3844. -   iterator.Reset();
  3845. -   while(iterator.MoreElements())
  3846. -   {
  3847. -       if(iterator.GetData()->GetID()==delete_id){
  3848. -           iterator.RemoveCurrent();
  3849. -           return true;
  3850. -       }
  3851. -       iterator.Advance();
  3852. +
  3853. +bool EntityList::RemoveCorpse(uint16 delete_id)
  3854. +{
  3855. +   auto it = corpse_list.find(delete_id);
  3856. +   if (it != corpse_list.end()) {
  3857. +       safe_delete(it->second);
  3858. +       corpse_list.erase(it);
  3859. +       return true;
  3860.     }
  3861.     return false;
  3862.  }
  3863. -bool EntityList::RemoveGroup(uint32 delete_id){
  3864. +
  3865. +bool EntityList::RemoveGroup(uint32 delete_id)
  3866. +{
  3867.     std::list<Group *>::iterator iterator;
  3868.  
  3869.     iterator = group_list.begin();
  3870. @@ -2515,7 +2155,8 @@ bool EntityList::RemoveGroup(uint32 delete_id){
  3871.     return false;
  3872.  }
  3873.  
  3874. -bool EntityList::RemoveRaid(uint32 delete_id){
  3875. +bool EntityList::RemoveRaid(uint32 delete_id)
  3876. +{
  3877.     std::list<Raid *>::iterator iterator;
  3878.  
  3879.     iterator = raid_list.begin();
  3880. @@ -2546,10 +2187,10 @@ void EntityList::Clear()
  3881.     last_insert_id = 0;
  3882.  }
  3883.  
  3884. -void EntityList::UpdateWho(bool iSendFullUpdate) {
  3885. +void EntityList::UpdateWho(bool iSendFullUpdate)
  3886. +{
  3887.     if ((!worldserver.Connected()) || !ZoneLoaded)
  3888.         return;
  3889. -   LinkedListIterator<Client*> iterator(client_list);
  3890.     uint32 tmpNumUpdates = numclients + 5;
  3891.     ServerPacket* pack = 0;
  3892.     ServerClientListKeepAlive_Struct* sclka = 0;
  3893. @@ -2558,14 +2199,12 @@ void EntityList::UpdateWho(bool iSendFullUpdate) {
  3894.         sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer;
  3895.     }
  3896.  
  3897. -   iterator.Reset();
  3898. -   while(iterator.MoreElements()) {
  3899. -       if (iterator.GetData()->InZone()) {
  3900. +   auto it = client_list.begin();
  3901. +   while (it != client_list.end()) {
  3902. +       if (it->second->InZone()) {
  3903.             if (iSendFullUpdate) {
  3904. -               iterator.GetData()->UpdateWho();
  3905. -           }
  3906. -           else {
  3907. -
  3908. +               it->second->UpdateWho();
  3909. +           } else {
  3910.                 if (sclka->numupdates >= tmpNumUpdates) {
  3911.                     tmpNumUpdates += 10;
  3912.                     uint8* tmp = pack->pBuffer;
  3913. @@ -2575,11 +2214,11 @@ void EntityList::UpdateWho(bool iSendFullUpdate) {
  3914.                     pack->size = sizeof(ServerClientListKeepAlive_Struct) + (tmpNumUpdates * 4);
  3915.                     safe_delete_array(tmp);
  3916.                 }
  3917. -               sclka->wid[sclka->numupdates] = iterator.GetData()->GetWID();
  3918. +               sclka->wid[sclka->numupdates] = it->second->GetWID();
  3919.                 sclka->numupdates++;
  3920.             }
  3921.         }
  3922. -       iterator.Advance();
  3923. +       ++it;
  3924.     }
  3925.     if (!iSendFullUpdate) {
  3926.         pack->size = sizeof(ServerClientListKeepAlive_Struct) + (sclka->numupdates * 4);
  3927. @@ -2592,22 +2231,22 @@ void EntityList::RemoveEntity(uint16 id)
  3928.  {
  3929.     if (id == 0)
  3930.         return;
  3931. -   if(entity_list.RemoveMob(id))
  3932. +   if (entity_list.RemoveMob(id))
  3933.         return;
  3934. -   else if(entity_list.RemoveCorpse(id))
  3935. +   else if (entity_list.RemoveCorpse(id))
  3936.         return;
  3937. -   else if(entity_list.RemoveDoor(id))
  3938. +   else if (entity_list.RemoveDoor(id))
  3939.         return;
  3940. -   else if(entity_list.RemoveGroup(id))
  3941. +   else if (entity_list.RemoveGroup(id))
  3942.         return;
  3943. -   else if(entity_list.RemoveTrap(id))
  3944. +   else if (entity_list.RemoveTrap(id))
  3945.         return;
  3946. -   else if(entity_list.RemoveMerc(id))
  3947. +   else if (entity_list.RemoveMerc(id))
  3948.         return;
  3949.  
  3950.  #ifdef BOTS
  3951.     // This block of code is necessary to clean up bot objects
  3952. -   else if(entity_list.RemoveBot(id))
  3953. +   else if (entity_list.RemoveBot(id))
  3954.         return;
  3955.  #endif //BOTS
  3956.  
  3957. @@ -2620,129 +2259,114 @@ void EntityList::Process()
  3958.     CheckSpawnQueue();
  3959.  }
  3960.  
  3961. -void EntityList::CountNPC(uint32* NPCCount, uint32* NPCLootCount, uint32* gmspawntype_count) {
  3962. -   LinkedListIterator<NPC*> iterator(npc_list);
  3963. +void EntityList::CountNPC(uint32 *NPCCount, uint32 *NPCLootCount, uint32 *gmspawntype_count)
  3964. +{
  3965.     *NPCCount = 0;
  3966.     *NPCLootCount = 0;
  3967.  
  3968. -   iterator.Reset();
  3969. -   while(iterator.MoreElements())
  3970. -   {
  3971. +   auto it = npc_list.begin();
  3972. +   while (it != npc_list.end()) {
  3973.         (*NPCCount)++;
  3974. -       (*NPCLootCount) += iterator.GetData()->CastToNPC()->CountLoot();
  3975. -       if (iterator.GetData()->CastToNPC()->GetNPCTypeID() == 0)
  3976. +       (*NPCLootCount) += it->second->CountLoot();
  3977. +       if (it->second->GetNPCTypeID() == 0)
  3978.             (*gmspawntype_count)++;
  3979. -       iterator.Advance();
  3980. +       ++it;
  3981.     }
  3982.  }
  3983.  
  3984. -void EntityList::Depop(bool StartSpawnTimer) {
  3985. -   LinkedListIterator<NPC*> iterator(npc_list);
  3986. -
  3987. -   iterator.Reset();
  3988. -   for(; iterator.MoreElements(); iterator.Advance())
  3989. -   {
  3990. -       NPC *it = iterator.GetData();
  3991. -       if(it) {
  3992. -           Mob *own = it->GetOwner();
  3993. +void EntityList::Depop(bool StartSpawnTimer)
  3994. +{
  3995. +   for (auto it = npc_list.begin(); it != npc_list.end(); ++it) {
  3996. +       NPC *pnpc = it->second;
  3997. +       if (pnpc) {
  3998. +           Mob *own = pnpc->GetOwner();
  3999.             //do not depop player's pets...
  4000. -           if(own && own->IsClient())
  4001. +           if (own && own->IsClient())
  4002.                 continue;
  4003.  
  4004. -           if(it->IsFindable())
  4005. -               UpdateFindableNPCState(it, true);
  4006. +           if (pnpc->IsFindable())
  4007. +               UpdateFindableNPCState(pnpc, true);
  4008.  
  4009. -           it->Depop(StartSpawnTimer);
  4010. +           pnpc->Depop(StartSpawnTimer);
  4011.         }
  4012.     }
  4013.  }
  4014.  
  4015. -void EntityList::DepopAll(int NPCTypeID, bool StartSpawnTimer) {
  4016. -   LinkedListIterator<NPC*> iterator(npc_list);
  4017. -
  4018. -   iterator.Reset();
  4019. -   for(; iterator.MoreElements(); iterator.Advance())
  4020. -   {
  4021. -       NPC *it = iterator.GetData();
  4022. -       if(it && (it->GetNPCTypeID() == (uint32)NPCTypeID))
  4023. -           it->Depop(StartSpawnTimer);
  4024. +void EntityList::DepopAll(int NPCTypeID, bool StartSpawnTimer)
  4025. +{
  4026. +   for (auto it = npc_list.begin(); it != npc_list.end(); ++it) {
  4027. +       NPC *pnpc = it->second;
  4028. +       if (pnpc && (pnpc->GetNPCTypeID() == (uint32)NPCTypeID))
  4029. +           pnpc->Depop(StartSpawnTimer);
  4030.     }
  4031.  }
  4032.  
  4033. -void EntityList::SendTraders(Client* client){
  4034. -   LinkedListIterator<Client*> iterator(client_list);
  4035. -   iterator.Reset();
  4036. -   Client* trader;
  4037. -   while(iterator.MoreElements()) {
  4038. -       trader=iterator.GetData();
  4039. -       if(trader->IsTrader())
  4040. +void EntityList::SendTraders(Client *client)
  4041. +{
  4042. +   Client *trader = nullptr;
  4043. +   auto it = client_list.begin();
  4044. +   while (it != client_list.end()) {
  4045. +       trader = it->second;
  4046. +       if (trader->IsTrader())
  4047.             client->SendTraderPacket(trader);
  4048.  
  4049. -       if(trader->IsBuyer())
  4050. +       if (trader->IsBuyer())
  4051.             client->SendBuyerPacket(trader);
  4052.  
  4053. -       iterator.Advance();
  4054. +       ++it;
  4055.     }
  4056.  }
  4057.  
  4058. -void EntityList::RemoveFromHateLists(Mob* mob, bool settoone) {
  4059. -   LinkedListIterator<NPC*> iterator(npc_list);
  4060. -
  4061. -   iterator.Reset();
  4062. -   while(iterator.MoreElements()) {
  4063. -       if (iterator.GetData()->CheckAggro(mob)) {
  4064. +void EntityList::RemoveFromHateLists(Mob *mob, bool settoone)
  4065. +{
  4066. +   auto it = npc_list.begin();
  4067. +   while (it != npc_list.end()) {
  4068. +       if (it->second->CheckAggro(mob)) {
  4069.             if (!settoone)
  4070. -           {
  4071. -               iterator.GetData()->RemoveFromHateList(mob);
  4072. -           }
  4073. +               it->second->RemoveFromHateList(mob);
  4074.             else
  4075. -           {
  4076. -               iterator.GetData()->SetHate(mob,1);
  4077. -           }
  4078. +               it->second->SetHate(mob, 1);
  4079.         }
  4080. -       iterator.Advance();
  4081. +       ++it;
  4082.     }
  4083.  }
  4084.  
  4085. -void EntityList::RemoveDebuffs(Mob* caster)
  4086. +void EntityList::RemoveDebuffs(Mob *caster)
  4087.  {
  4088. -   LinkedListIterator<Mob*> iterator(mob_list);
  4089. -
  4090. -   iterator.Reset();
  4091. -   while(iterator.MoreElements())
  4092. -   {
  4093. -       iterator.GetData()->BuffFadeDetrimentalByCaster(caster);
  4094. -       iterator.Advance();
  4095. +   auto it = mob_list.begin();
  4096. +   while (it != mob_list.end()) {
  4097. +       it->second->BuffFadeDetrimentalByCaster(caster);
  4098. +       ++it;
  4099.     }
  4100.  }
  4101.  
  4102. -
  4103.  // Currently, a new packet is sent per entity.
  4104.  // @todo: Come back and use FLAG_COMBINED to pack
  4105.  // all updates into one packet.
  4106. -void EntityList::SendPositionUpdates(Client* client, uint32 cLastUpdate, float range, Entity* alwayssend, bool iSendEvenIfNotChanged) {
  4107. +void EntityList::SendPositionUpdates(Client *client, uint32 cLastUpdate,
  4108. +       float range, Entity *alwayssend, bool iSendEvenIfNotChanged)
  4109. +{
  4110.     range = range * range;
  4111. -   LinkedListIterator<Mob*> iterator(mob_list);
  4112.  
  4113. -   EQApplicationPacket* outapp = 0;
  4114. -   PlayerPositionUpdateServer_Struct* ppu = 0;
  4115. -   Mob* mob = 0;
  4116. +   EQApplicationPacket *outapp = 0;
  4117. +   PlayerPositionUpdateServer_Struct *ppu = 0;
  4118. +   Mob *mob = 0;
  4119.  
  4120. -   iterator.Reset();
  4121. -   while(iterator.MoreElements()) {
  4122. +   auto it = mob_list.begin();
  4123. +   while (it != mob_list.end()) {
  4124.         if (outapp == 0) {
  4125.             outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
  4126.             ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer;
  4127.         }
  4128. -       mob = iterator.GetData()->CastToMob();
  4129. -       if (mob && !mob->IsCorpse() && (iterator.GetData() != client)
  4130. +       mob = it->second;
  4131. +       if (mob && !mob->IsCorpse() && (it->second != client)
  4132.             && (mob->IsClient() || iSendEvenIfNotChanged || (mob->LastChange() >= cLastUpdate))
  4133. -           && (!iterator.GetData()->IsClient() || !iterator.GetData()->CastToClient()->GMHideMe(client))) {
  4134. +           && (!it->second->IsClient() || !it->second->CastToClient()->GMHideMe(client))) {
  4135.  
  4136.             //bool Grouped = client->HasGroup() && mob->IsClient() && (client->GetGroup() == mob->CastToClient()->GetGroup());
  4137.  
  4138.             //if (range == 0 || (iterator.GetData() == alwayssend) || Grouped || (mob->DistNoRootNoZ(*client) <= range)) {
  4139. -           if (range == 0 || (iterator.GetData() == alwayssend) || mob->IsClient() || (mob->DistNoRoot(*client) <= range)) {
  4140. +           if (range == 0 || (it->second == alwayssend) || mob->IsClient() || (mob->DistNoRoot(*client) <= range)) {
  4141.                 mob->MakeSpawnUpdate(ppu);
  4142.             }
  4143.             if(mob && mob->IsClient() && mob->GetID()>0) {
  4144. @@ -2751,30 +2375,30 @@ void EntityList::SendPositionUpdates(Client* client, uint32 cLastUpdate, float r
  4145.         }
  4146.         safe_delete(outapp);
  4147.         outapp = 0;
  4148. -       iterator.Advance();
  4149. +       ++it;
  4150.     }
  4151.  
  4152.     safe_delete(outapp);
  4153.  }
  4154.  
  4155. -char* EntityList::MakeNameUnique(char* name) {
  4156. +char *EntityList::MakeNameUnique(char *name)
  4157. +{
  4158.     bool used[300];
  4159.     memset(used, 0, sizeof(used));
  4160.     name[61] = 0; name[62] = 0; name[63] = 0;
  4161.  
  4162. -   LinkedListIterator<Mob*> iterator(mob_list);
  4163.  
  4164. -   iterator.Reset();
  4165.     int len = strlen(name);
  4166. -   while(iterator.MoreElements()) {
  4167. -       if (iterator.GetData()->IsMob()) {
  4168. -           if (strncasecmp(iterator.GetData()->CastToMob()->GetName(), name, len) == 0) {
  4169. -               if (Seperator::IsNumber(&iterator.GetData()->CastToMob()->GetName()[len])) {
  4170. -                   used[atoi(&iterator.GetData()->CastToMob()->GetName()[len])] = true;
  4171. +   auto it = mob_list.begin();
  4172. +   while (it != mob_list.end()) {
  4173. +       if (it->second->IsMob()) {
  4174. +           if (strncasecmp(it->second->CastToMob()->GetName(), name, len) == 0) {
  4175. +               if (Seperator::IsNumber(&it->second->CastToMob()->GetName()[len])) {
  4176. +                   used[atoi(&it->second->CastToMob()->GetName()[len])] = true;
  4177.                 }
  4178.             }
  4179.         }
  4180. -       iterator.Advance();
  4181. +       ++it;
  4182.     }
  4183.     for (int i=0; i < 300; i++) {
  4184.         if (!used[i]) {
  4185. @@ -2797,8 +2421,9 @@ char* EntityList::MakeNameUnique(char* name) {
  4186.     return MakeNameUnique(name);
  4187.  }
  4188.  
  4189. -char* EntityList::RemoveNumbers(char* name) {
  4190. -   char    tmp[64];
  4191. +char *EntityList::RemoveNumbers(char *name)
  4192. +{
  4193. +   char tmp[64];
  4194.     memset(tmp, 0, sizeof(tmp));
  4195.     int k = 0;
  4196.     for (unsigned int i=0; i<strlen(name) && i<sizeof(tmp); i++) {
  4197. @@ -2808,154 +2433,147 @@ char* EntityList::RemoveNumbers(char* name) {
  4198.     strn0cpy(name, tmp, sizeof(tmp));
  4199.     return name;
  4200.  }
  4201. -void EntityList::ListNPCs(Client* client, const char* arg1, const char* arg2, uint8 searchtype) {
  4202. +
  4203. +void EntityList::ListNPCs(Client* client, const char *arg1, const char *arg2, uint8 searchtype)
  4204. +{
  4205.     if (arg1 == 0)
  4206.         searchtype = 0;
  4207.     else if (arg2 == 0 && searchtype >= 2)
  4208.         searchtype = 0;
  4209. -   LinkedListIterator<NPC*> iterator(npc_list);
  4210.     uint32 x = 0;
  4211.     uint32 z = 0;
  4212.     char sName[36];
  4213.  
  4214. -   iterator.Reset();
  4215. +   auto it = npc_list.begin();
  4216.     client->Message(0, "NPCs in the zone:");
  4217. -   if(searchtype == 0) {
  4218. -       while(iterator.MoreElements())
  4219. -       {
  4220. -           NPC *n = iterator.GetData();
  4221. +   if (searchtype == 0) {
  4222. +       while (it != npc_list.end()) {
  4223. +           NPC *n = it->second;
  4224.  
  4225.             client->Message(0, "  %5d: %s (%.0f, %0.f, %.0f)", n->GetID(), n->GetName(), n->GetX(), n->GetY(), n->GetZ());
  4226.             x++;
  4227.             z++;
  4228. -           iterator.Advance();
  4229. +           ++it;
  4230.         }
  4231. -   }
  4232. -   else if(searchtype == 1) {
  4233. +   } else if (searchtype == 1) {
  4234.         client->Message(0, "Searching by name method. (%s)",arg1);
  4235.         char* tmp = new char[strlen(arg1) + 1];
  4236.         strcpy(tmp, arg1);
  4237.         strupr(tmp);
  4238. -       while(iterator.MoreElements()) {
  4239. +       while (it != npc_list.end()) {
  4240.             z++;
  4241. -           strcpy(sName, iterator.GetData()->GetName());
  4242. +           strcpy(sName, it->second->GetName());
  4243.             strupr(sName);
  4244.             if (strstr(sName, tmp)) {
  4245. -               NPC *n = iterator.GetData();
  4246. +               NPC *n = it->second;
  4247.                 client->Message(0, "  %5d: %s (%.0f, %.0f, %.0f)", n->GetID(), n->GetName(), n->GetX(), n->GetY(), n->GetZ());
  4248.                 x++;
  4249.             }
  4250. -           iterator.Advance();
  4251. +           ++it;
  4252.         }
  4253.         safe_delete_array(tmp);
  4254. -   }
  4255. -   else if(searchtype == 2) {
  4256. +   } else if (searchtype == 2) {
  4257.         client->Message(0, "Searching by number method. (%s %s)",arg1,arg2);
  4258. -       while(iterator.MoreElements()) {
  4259. +       while (it != npc_list.end()) {
  4260.             z++;
  4261. -           if ((iterator.GetData()->GetID() >= atoi(arg1)) && (iterator.GetData()->GetID() <= atoi(arg2)) && (atoi(arg1) <= atoi(arg2))) {
  4262. -               client->Message(0, "  %5d: %s", iterator.GetData()->GetID(), iterator.GetData()->GetName());
  4263. +           if ((it->second->GetID() >= atoi(arg1)) && (it->second->GetID() <= atoi(arg2)) && (atoi(arg1) <= atoi(arg2))) {
  4264. +               client->Message(0, "  %5d: %s", it->second->GetID(), it->second->GetName());
  4265.                 x++;
  4266.             }
  4267. -           iterator.Advance();
  4268. +           ++it;
  4269.         }
  4270.     }
  4271.     client->Message(0, "%d npcs listed. There is a total of %d npcs in this zone.", x, z);
  4272.  }
  4273.  
  4274. -void EntityList::ListNPCCorpses(Client* client) {
  4275. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  4276. +void EntityList::ListNPCCorpses(Client *client)
  4277. +{
  4278.     uint32 x = 0;
  4279.  
  4280. -   iterator.Reset();
  4281. +   auto it = corpse_list.begin();
  4282.     client->Message(0, "NPC Corpses in the zone:");
  4283. -   while(iterator.MoreElements()) {
  4284. -       if (iterator.GetData()->IsNPCCorpse()) {
  4285. -           client->Message(0, "  %5d: %s", iterator.GetData()->GetID(), iterator.GetData()->GetName());
  4286. +   while (it != corpse_list.end()) {
  4287. +       if (it->second->IsNPCCorpse()) {
  4288. +           client->Message(0, "  %5d: %s", it->first, it->second->GetName());
  4289.             x++;
  4290.         }
  4291. -       iterator.Advance();
  4292. +       ++it;
  4293.     }
  4294.     client->Message(0, "%d npc corpses listed.", x);
  4295.  }
  4296.  
  4297. -void EntityList::ListPlayerCorpses(Client* client) {
  4298. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  4299. +void EntityList::ListPlayerCorpses(Client *client)
  4300. +{
  4301.     uint32 x = 0;
  4302.  
  4303. -   iterator.Reset();
  4304. +   auto it = corpse_list.begin();
  4305.     client->Message(0, "Player Corpses in the zone:");
  4306. -   while(iterator.MoreElements()) {
  4307. -       if (iterator.GetData()->IsPlayerCorpse()) {
  4308. -           client->Message(0, "  %5d: %s", iterator.GetData()->GetID(), iterator.GetData()->GetName());
  4309. +   while (it != corpse_list.end()) {
  4310. +       if (it->second->IsPlayerCorpse()) {
  4311. +           client->Message(0, "  %5d: %s", it->first, it->second->GetName());
  4312.             x++;
  4313.         }
  4314. -       iterator.Advance();
  4315. +       ++it;
  4316.     }
  4317.     client->Message(0, "%d player corpses listed.", x);
  4318.  }
  4319.  
  4320.  void EntityList::FindPathsToAllNPCs()
  4321.  {
  4322. -   if(!zone->pathing)
  4323. +   if (!zone->pathing)
  4324.         return;
  4325.  
  4326. -   LinkedListIterator<NPC*> Iterator(npc_list);
  4327. -
  4328. -   Iterator.Reset();
  4329. -
  4330. -   while(Iterator.MoreElements())
  4331. -   {
  4332. +   auto it = npc_list.begin();
  4333. +   while (it != npc_list.end()) {
  4334.         VERTEX Node0 = zone->pathing->GetPathNodeCoordinates(0, false);
  4335. -       VERTEX Dest(Iterator.GetData()->GetX(), Iterator.GetData()->GetY(), Iterator.GetData()->GetZ());
  4336. +       VERTEX Dest(it->second->GetX(), it->second->GetY(), it->second->GetZ());
  4337.         std::list<int> Route = zone->pathing->FindRoute(Node0, Dest);
  4338. -       if(Route.size() == 0)
  4339. -           printf("Unable to find a route to %s\n", Iterator.GetData()->GetName());
  4340. +       if (Route.size() == 0)
  4341. +           printf("Unable to find a route to %s\n", it->second->GetName());
  4342.         else
  4343. -           printf("Found a route to %s\n", Iterator.GetData()->GetName());
  4344. -
  4345. -       Iterator.Advance();
  4346. +           printf("Found a route to %s\n", it->second->GetName());
  4347. +       ++it;
  4348.     }
  4349.  
  4350.     fflush(stdout);
  4351. -
  4352.  }
  4353.  
  4354.  // returns the number of corpses deleted. A negative number indicates an error code.
  4355. -int32 EntityList::DeleteNPCCorpses() {
  4356. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  4357. +int32 EntityList::DeleteNPCCorpses()
  4358. +{
  4359.     int32 x = 0;
  4360.  
  4361. -   iterator.Reset();
  4362. -   while(iterator.MoreElements()) {
  4363. -       if (iterator.GetData()->IsNPCCorpse()) {
  4364. -           iterator.GetData()->Depop();
  4365. +   auto it = corpse_list.begin();
  4366. +   while (it != corpse_list.end()) {
  4367. +       if (it->second->IsNPCCorpse()) {
  4368. +           it->second->Depop();
  4369.             x++;
  4370.         }
  4371. -       iterator.Advance();
  4372. +       ++it;
  4373.     }
  4374.     return x;
  4375.  }
  4376.  
  4377.  // returns the number of corpses deleted. A negative number indicates an error code.
  4378. -int32 EntityList::DeletePlayerCorpses() {
  4379. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  4380. +int32 EntityList::DeletePlayerCorpses()
  4381. +{
  4382.     int32 x = 0;
  4383.  
  4384. -   iterator.Reset();
  4385. -   while(iterator.MoreElements()) {
  4386. -       if (iterator.GetData()->IsPlayerCorpse()) {
  4387. -           iterator.GetData()->CastToCorpse()->Delete();
  4388. +   auto it = corpse_list.begin();
  4389. +   while (it != corpse_list.end()) {
  4390. +       if (it->second->IsPlayerCorpse()) {
  4391. +           it->second->CastToCorpse()->Delete();
  4392.             x++;
  4393.         }
  4394. -       iterator.Advance();
  4395. +       ++it;
  4396.     }
  4397.     return x;
  4398.  }
  4399. -void EntityList::SendPetitionToAdmins(){
  4400. -   LinkedListIterator<Client*> iterator(client_list);
  4401. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4402. -   PetitionUpdate_Struct* pcus = (PetitionUpdate_Struct*) outapp->pBuffer;
  4403. +
  4404. +void EntityList::SendPetitionToAdmins()
  4405. +{
  4406. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4407. +   PetitionUpdate_Struct *pcus = (PetitionUpdate_Struct*) outapp->pBuffer;
  4408.     pcus->petnumber = 0;        // Petition Number
  4409.     pcus->color = 0;
  4410.     pcus->status = 0xFFFFFFFF;
  4411. @@ -2963,19 +2581,19 @@ void EntityList::SendPetitionToAdmins(){
  4412.     strcpy(pcus->accountid, "");
  4413.     strcpy(pcus->gmsenttoo, "");
  4414.     pcus->quetotal=0;
  4415. -   iterator.Reset();
  4416. -   while(iterator.MoreElements()) {
  4417. -       if (iterator.GetData()->CastToClient()->Admin() >= 80)
  4418. -           iterator.GetData()->CastToClient()->QueuePacket(outapp);
  4419. -       iterator.Advance();
  4420. +   auto it = client_list.begin();
  4421. +   while (it != client_list.end()) {
  4422. +       if (it->second->CastToClient()->Admin() >= 80)
  4423. +           it->second->CastToClient()->QueuePacket(outapp);
  4424. +       ++it;
  4425.     }
  4426.     safe_delete(outapp);
  4427.  }
  4428. -void EntityList::SendPetitionToAdmins(Petition* pet) {
  4429. -   LinkedListIterator<Client*> iterator(client_list);
  4430.  
  4431. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4432. -   PetitionUpdate_Struct* pcus = (PetitionUpdate_Struct*) outapp->pBuffer;
  4433. +void EntityList::SendPetitionToAdmins(Petition *pet)
  4434. +{
  4435. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4436. +   PetitionUpdate_Struct *pcus = (PetitionUpdate_Struct*) outapp->pBuffer;
  4437.     pcus->petnumber = pet->GetID();     // Petition Number
  4438.     if (pet->CheckedOut()) {
  4439.         pcus->color = 0x00;
  4440. @@ -2983,8 +2601,7 @@ void EntityList::SendPetitionToAdmins(Petition* pet) {
  4441.         pcus->senttime = pet->GetSentTime();
  4442.         strcpy(pcus->accountid, "");
  4443.         strcpy(pcus->gmsenttoo, "");
  4444. -   }
  4445. -   else {
  4446. +   } else {
  4447.         pcus->color = pet->GetUrgency();    // 0x00 = green, 0x01 = yellow, 0x02 = red
  4448.         pcus->status = pet->GetSentTime();
  4449.         pcus->senttime = pet->GetSentTime();            // 4 has to be 0x1F
  4450. @@ -2992,23 +2609,24 @@ void EntityList::SendPetitionToAdmins(Petition* pet) {
  4451.         strcpy(pcus->charname, pet->GetCharName());
  4452.     }
  4453.     pcus->quetotal = petition_list.GetTotalPetitions();
  4454. -   iterator.Reset();
  4455. -   while(iterator.MoreElements()) {
  4456. -       if (iterator.GetData()->CastToClient()->Admin() >= 80) {
  4457. +   auto it = client_list.begin();
  4458. +   while (it != client_list.end()) {
  4459. +       if (it->second->CastToClient()->Admin() >= 80) {
  4460.             if (pet->CheckedOut())
  4461.                 strcpy(pcus->gmsenttoo, "");
  4462.             else
  4463. -               strcpy(pcus->gmsenttoo, iterator.GetData()->CastToClient()->GetName());
  4464. -           iterator.GetData()->CastToClient()->QueuePacket(outapp);
  4465. +               strcpy(pcus->gmsenttoo, it->second->CastToClient()->GetName());
  4466. +           it->second->CastToClient()->QueuePacket(outapp);
  4467.         }
  4468. -       iterator.Advance();
  4469. +       ++it;
  4470.     }
  4471.     safe_delete(outapp);
  4472.  }
  4473.  
  4474. -void EntityList::ClearClientPetitionQueue() {
  4475. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4476. -   PetitionUpdate_Struct* pet = (PetitionUpdate_Struct*) outapp->pBuffer;
  4477. +void EntityList::ClearClientPetitionQueue()
  4478. +{
  4479. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_PetitionUpdate,sizeof(PetitionUpdate_Struct));
  4480. +   PetitionUpdate_Struct *pet = (PetitionUpdate_Struct*) outapp->pBuffer;
  4481.     pet->color = 0x00;
  4482.     pet->status = 0xFFFFFFFF;
  4483.     pet->senttime = 0;
  4484. @@ -3016,45 +2634,45 @@ void EntityList::ClearClientPetitionQueue() {
  4485.     strcpy(pet->gmsenttoo, "");
  4486.     strcpy(pet->charname, "");
  4487.     pet->quetotal = petition_list.GetTotalPetitions();
  4488. -   LinkedListIterator<Client*> iterator(client_list);
  4489. -   iterator.Reset();
  4490. -   while(iterator.MoreElements())
  4491. -   {
  4492. -       if (iterator.GetData()->CastToClient()->Admin() >= 100) {
  4493. +   auto it = client_list.begin();
  4494. +   while (it != client_list.end()) {
  4495. +       if (it->second->CastToClient()->Admin() >= 100) {
  4496.             int x = 0;
  4497. -           for (x=0;x<64;x++) {
  4498. +           for (x = 0; x < 64; x++) {
  4499.                 pet->petnumber = x;
  4500. -               iterator.GetData()->CastToClient()->QueuePacket(outapp);
  4501. +               it->second->CastToClient()->QueuePacket(outapp);
  4502.             }
  4503.         }
  4504. -       iterator.Advance();
  4505. +       ++it;
  4506.     }
  4507.     safe_delete(outapp);
  4508.     return;
  4509.  }
  4510.  
  4511. -void EntityList::WriteEntityIDs() {
  4512. -   LinkedListIterator<Mob*> iterator(mob_list);
  4513. -   iterator.Reset();
  4514. -   while(iterator.MoreElements())
  4515. -   {
  4516. -       std::cout << "ID: " << iterator.GetData()->GetID() << "  Name: " << iterator.GetData()->GetName() << std::endl;
  4517. -       iterator.Advance();
  4518. +void EntityList::WriteEntityIDs()
  4519. +{
  4520. +   auto it = mob_list.begin();
  4521. +   while (it != mob_list.end()) {
  4522. +       std::cout << "ID: " << it->first << "  Name: " << it->second->GetName() << std::endl;
  4523. +       ++it;
  4524.     }
  4525.  }
  4526.  
  4527. -BulkZoneSpawnPacket::BulkZoneSpawnPacket(Client* iSendTo, uint32 iMaxSpawnsPerPacket) {
  4528. +BulkZoneSpawnPacket::BulkZoneSpawnPacket(Client *iSendTo, uint32 iMaxSpawnsPerPacket)
  4529. +{
  4530.     data = 0;
  4531.     pSendTo = iSendTo;
  4532.     pMaxSpawnsPerPacket = iMaxSpawnsPerPacket;
  4533.  }
  4534.  
  4535. -BulkZoneSpawnPacket::~BulkZoneSpawnPacket() {
  4536. +BulkZoneSpawnPacket::~BulkZoneSpawnPacket()
  4537. +{
  4538.     SendBuffer();
  4539.     safe_delete_array(data)
  4540.  }
  4541.  
  4542. -bool BulkZoneSpawnPacket::AddSpawn(NewSpawn_Struct* ns) {
  4543. +bool BulkZoneSpawnPacket::AddSpawn(NewSpawn_Struct *ns)
  4544. +{
  4545.     if (!data) {
  4546.         data = new NewSpawn_Struct[pMaxSpawnsPerPacket];
  4547.         memset(data, 0, sizeof(NewSpawn_Struct) * pMaxSpawnsPerPacket);
  4548. @@ -3086,195 +2704,171 @@ void BulkZoneSpawnPacket::SendBuffer() {
  4549.     index = 0;
  4550.  }
  4551.  
  4552. -void EntityList::DoubleAggro(Mob* who)
  4553. +void EntityList::DoubleAggro(Mob *who)
  4554.  {
  4555. -   LinkedListIterator<NPC*> iterator(npc_list);
  4556. -   iterator.Reset();
  4557. -   while(iterator.MoreElements())
  4558. -   {
  4559. -       if (iterator.GetData()->CheckAggro(who))
  4560. -               iterator.GetData()->SetHate(who,iterator.GetData()->CastToNPC()->GetHateAmount(who),iterator.GetData()->CastToNPC()->GetHateAmount(who)*2);
  4561. -       iterator.Advance();
  4562. +   auto it = npc_list.begin();
  4563. +   while (it != npc_list.end()) {
  4564. +       if (it->second->CheckAggro(who))
  4565. +           it->second->SetHate(who, it->second->CastToNPC()->GetHateAmount(who),
  4566. +                   it->second->CastToNPC()->GetHateAmount(who) * 2);
  4567. +       ++it;
  4568.     }
  4569.  }
  4570.  
  4571. -void EntityList::HalveAggro(Mob* who)
  4572. +void EntityList::HalveAggro(Mob *who)
  4573.  {
  4574. -   LinkedListIterator<NPC*> iterator(npc_list);
  4575. -   iterator.Reset();
  4576. -   while(iterator.MoreElements())
  4577. -   {
  4578. -       if (iterator.GetData()->CastToNPC()->CheckAggro(who))
  4579. -               iterator.GetData()->CastToNPC()->SetHate(who,iterator.GetData()->CastToNPC()->GetHateAmount(who)/2);
  4580. -       iterator.Advance();
  4581. +   auto it = npc_list.begin();
  4582. +   while (it != npc_list.end()) {
  4583. +       if (it->second->CastToNPC()->CheckAggro(who))
  4584. +           it->second->CastToNPC()->SetHate(who, it->second->CastToNPC()->GetHateAmount(who) / 2);
  4585. +       ++it;
  4586.     }
  4587.  }
  4588.  
  4589. -
  4590.  void EntityList::Evade(Mob *who)
  4591.  {
  4592.     uint32 flatval = who->GetLevel() * 13;
  4593.     int amt = 0;
  4594. -   LinkedListIterator<NPC*> iterator(npc_list);
  4595. -   iterator.Reset();
  4596. -   while(iterator.MoreElements())
  4597. -   {
  4598. -       if (iterator.GetData()->CastToNPC()->CheckAggro(who)){
  4599. -           amt = iterator.GetData()->CastToNPC()->GetHateAmount(who);
  4600. +   auto it = npc_list.begin();
  4601. +   while (it != npc_list.end()) {
  4602. +       if (it->second->CastToNPC()->CheckAggro(who)) {
  4603. +           amt = it->second->CastToNPC()->GetHateAmount(who);
  4604.             amt -= flatval;
  4605. -           if(amt > 0)
  4606. -               iterator.GetData()->CastToNPC()->SetHate(who, amt);
  4607. +           if (amt > 0)
  4608. +               it->second->CastToNPC()->SetHate(who, amt);
  4609.             else
  4610. -               iterator.GetData()->CastToNPC()->SetHate(who, 0);
  4611. +               it->second->CastToNPC()->SetHate(who, 0);
  4612.         }
  4613. -       iterator.Advance();
  4614. +       ++it;
  4615.     }
  4616.  }
  4617.  
  4618.  //removes "targ" from all hate lists, including feigned, in the zone
  4619. -void EntityList::ClearAggro(Mob* targ) {
  4620. -   LinkedListIterator<NPC*> iterator(npc_list);
  4621. -   iterator.Reset();
  4622. -   while(iterator.MoreElements()) {
  4623. -       if (iterator.GetData()->CheckAggro(targ))
  4624. -           iterator.GetData()->RemoveFromHateList(targ);
  4625. -       iterator.GetData()->RemoveFromFeignMemory(targ->CastToClient()); //just in case we feigned
  4626. -       iterator.Advance();
  4627. +void EntityList::ClearAggro(Mob* targ)
  4628. +{
  4629. +   auto it = npc_list.begin();
  4630. +   while (it != npc_list.end()) {
  4631. +       if (it->second->CheckAggro(targ))
  4632. +           it->second->RemoveFromHateList(targ);
  4633. +       it->second->RemoveFromFeignMemory(targ->CastToClient()); //just in case we feigned
  4634. +       ++it;
  4635.     }
  4636.  }
  4637.  
  4638. -void EntityList::ClearFeignAggro(Mob* targ)
  4639. +void EntityList::ClearFeignAggro(Mob *targ)
  4640.  {
  4641. -   LinkedListIterator<NPC*> iterator(npc_list);
  4642. -   iterator.Reset();
  4643. -   while(iterator.MoreElements())
  4644. -   {
  4645. -       if (iterator.GetData()->CheckAggro(targ))
  4646. -       {
  4647. -           if(iterator.GetData()->GetSpecialAbility(IMMUNE_FEIGN_DEATH))
  4648. -           {
  4649. -               iterator.Advance();
  4650. +   auto it = npc_list.begin();
  4651. +   while (it != npc_list.end()) {
  4652. +       if (it->second->CheckAggro(targ)) {
  4653. +           if (it->second->GetSpecialAbility(IMMUNE_FEIGN_DEATH)) {
  4654. +               ++it;
  4655.                 continue;
  4656.             }
  4657.  
  4658. -           if(targ->IsClient()) {
  4659. +           if (targ->IsClient()) {
  4660.                 std::vector<void*> args;
  4661. -               args.push_back(iterator.GetData());
  4662. +               args.push_back(it->second);
  4663.                 int i = parse->EventPlayer(EVENT_FEIGN_DEATH, targ->CastToClient(), "", 0, &args);
  4664. -               if(i != 0) {
  4665. -                   iterator.Advance();
  4666. +               if (i != 0) {
  4667. +                   ++it;
  4668.                     continue;
  4669.                 }
  4670.  
  4671. -               if(iterator.GetData()->IsNPC()) {
  4672. -                   int i = parse->EventNPC(EVENT_FEIGN_DEATH, iterator.GetData()->CastToNPC(), targ, "", 0);
  4673. -                   if(i != 0) {
  4674. -                       iterator.Advance();
  4675. +               if (it->second->IsNPC()) {
  4676. +                   int i = parse->EventNPC(EVENT_FEIGN_DEATH, it->second->CastToNPC(), targ, "", 0);
  4677. +                   if (i != 0) {
  4678. +                       ++it;
  4679.                         continue;
  4680.                     }
  4681.                 }
  4682.             }
  4683.  
  4684. -           iterator.GetData()->RemoveFromHateList(targ);
  4685. -           if(targ->IsClient()){
  4686. -               if (iterator.GetData()->GetLevel() >= 35 && MakeRandomInt(1, 100) <= 60){
  4687. -                   iterator.GetData()->AddFeignMemory(targ->CastToClient());
  4688. -               } else {
  4689. -                   targ->CastToClient()->RemoveXTarget(iterator.GetData(), false);
  4690. -               }
  4691. +           it->second->RemoveFromHateList(targ);
  4692. +           if (targ->IsClient()) {
  4693. +               if (it->second->GetLevel() >= 35 && MakeRandomInt(1, 100) <= 60)
  4694. +                   it->second->AddFeignMemory(targ->CastToClient());
  4695. +               else
  4696. +                   targ->CastToClient()->RemoveXTarget(it->second, false);
  4697.             }
  4698.         }
  4699. -       iterator.Advance();
  4700. +       ++it;
  4701.     }
  4702.  }
  4703.  
  4704. -void EntityList::ClearZoneFeignAggro(Client* targ)
  4705. +void EntityList::ClearZoneFeignAggro(Client *targ)
  4706.  {
  4707. -   LinkedListIterator<NPC*> iterator(npc_list);
  4708. -   iterator.Reset();
  4709. -   while(iterator.MoreElements())
  4710. -   {
  4711. -       iterator.GetData()->RemoveFromFeignMemory(targ);
  4712. -       targ->CastToClient()->RemoveXTarget(iterator.GetData(), false);
  4713. -       iterator.Advance();
  4714. +   auto it = npc_list.begin();
  4715. +   while (it != npc_list.end()) {
  4716. +       it->second->RemoveFromFeignMemory(targ);
  4717. +       targ->CastToClient()->RemoveXTarget(it->second, false);
  4718. +       ++it;
  4719.     }
  4720.  }
  4721.  
  4722. -void EntityList::AggroZone(Mob* who, int hate) {
  4723. -   LinkedListIterator<NPC*> iterator(npc_list);
  4724. -   iterator.Reset();
  4725. -   while(iterator.MoreElements())
  4726. -   {
  4727. -       iterator.GetData()->AddToHateList(who, hate);
  4728. -       iterator.Advance();
  4729. +void EntityList::AggroZone(Mob *who, int hate)
  4730. +{
  4731. +   auto it = npc_list.begin();
  4732. +   while (it != npc_list.end()) {
  4733. +       it->second->AddToHateList(who, hate);
  4734. +       ++it;
  4735.     }
  4736.  }
  4737.  
  4738.  // Signal Quest command function
  4739.  void EntityList::SignalMobsByNPCID(uint32 snpc, int signal_id)
  4740.  {
  4741. -   LinkedListIterator<NPC*> iterator(npc_list);
  4742. -
  4743. -   iterator.Reset();
  4744. -   while(iterator.MoreElements())
  4745. -   {
  4746. -       NPC *it = iterator.GetData();
  4747. -       if (it->GetNPCTypeID() == snpc)
  4748. -       {
  4749. -           it->SignalNPC(signal_id);
  4750. -       }
  4751. -       iterator.Advance();
  4752. +   auto it = npc_list.begin();
  4753. +   while (it != npc_list.end()) {
  4754. +       NPC *pit = it->second;
  4755. +       if (pit->GetNPCTypeID() == snpc)
  4756. +           pit->SignalNPC(signal_id);
  4757. +       ++it;
  4758.     }
  4759.  }
  4760.  
  4761. -
  4762. -bool EntityList::MakeTrackPacket(Client* client)
  4763. +bool EntityList::MakeTrackPacket(Client *client)
  4764.  {
  4765.     uint32 distance = 0;
  4766.     float MobDistance;
  4767.  
  4768. -   if(client->GetClass() == DRUID)
  4769. -       distance = (client->GetSkill(SkillTracking)*10);
  4770. -   else if(client->GetClass() == RANGER)
  4771. -       distance = (client->GetSkill(SkillTracking)*12);
  4772. -   else if(client->GetClass() == BARD)
  4773. -       distance = (client->GetSkill(SkillTracking)*7);
  4774. -   if(distance <= 0)
  4775. +   if (client->GetClass() == DRUID)
  4776. +       distance = (client->GetSkill(SkillTracking) * 10);
  4777. +   else if (client->GetClass() == RANGER)
  4778. +       distance = (client->GetSkill(SkillTracking) * 12);
  4779. +   else if (client->GetClass() == BARD)
  4780. +       distance = (client->GetSkill(SkillTracking) * 7);
  4781. +   if (distance <= 0)
  4782.         return false;
  4783. -   if(distance<300)
  4784. -       distance=300;
  4785. +   if (distance < 300)
  4786. +       distance = 300;
  4787.  
  4788.     uint32 spe= 0;
  4789.     bool ret = false;
  4790.  
  4791. -   spe = mob_list.Count() + 50;
  4792. +   spe = mob_list.size() + 50;
  4793.  
  4794. -   uchar* buffer1 = new uchar[sizeof(Track_Struct)];
  4795. -   Track_Struct* track_ent = (Track_Struct*) buffer1;
  4796. +   uchar *buffer1 = new uchar[sizeof(Track_Struct)];
  4797. +   Track_Struct *track_ent = (Track_Struct*) buffer1;
  4798.  
  4799. -   uchar* buffer2 = new uchar[sizeof(Track_Struct)*spe];
  4800. -   Tracking_Struct* track_array = (Tracking_Struct*) buffer2;
  4801. +   uchar *buffer2 = new uchar[sizeof(Track_Struct)*spe];
  4802. +   Tracking_Struct *track_array = (Tracking_Struct*) buffer2;
  4803.     memset(track_array, 0, sizeof(Track_Struct)*spe);
  4804.  
  4805.     uint32 array_counter = 0;
  4806.  
  4807. -   LinkedListIterator<Mob*> iterator(mob_list);
  4808. -   iterator.Reset();
  4809. -
  4810.     Group *g = client->GetGroup();
  4811.  
  4812. -   while(iterator.MoreElements())
  4813. -   {
  4814. -       if (iterator.GetData() && ((MobDistance = iterator.GetData()->DistNoZ(*client))<=distance))
  4815. -       {
  4816. -           if((iterator.GetData() != client) && iterator.GetData()->IsTrackable()) {
  4817. +   auto it = mob_list.begin();
  4818. +   while (it != mob_list.end()) {
  4819. +       if (it->second && ((MobDistance = it->second->DistNoZ(*client)) <= distance)) {
  4820. +           if ((it->second != client) && it->second->IsTrackable()) {
  4821.                 memset(track_ent, 0, sizeof(Track_Struct));
  4822. -               Mob* cur_entity = iterator.GetData();
  4823. +               Mob *cur_entity = it->second;
  4824.                 track_ent->entityid = cur_entity->GetID();
  4825.                 track_ent->distance = MobDistance;
  4826.                 track_ent->level = cur_entity->GetLevel();
  4827.                 track_ent->NPC = !cur_entity->IsClient();
  4828. -               if(g && cur_entity->IsClient() && g->IsGroupMember(cur_entity->CastToMob()))
  4829. +               if (g && cur_entity->IsClient() && g->IsGroupMember(cur_entity->CastToMob()))
  4830.                     track_ent->GroupMember = 1;
  4831.                 else
  4832.                     track_ent->GroupMember = 0;
  4833. @@ -3284,18 +2878,17 @@ bool EntityList::MakeTrackPacket(Client* client)
  4834.             }
  4835.         }
  4836.  
  4837. -       iterator.Advance();
  4838. +       ++it;
  4839.     }
  4840.  
  4841. -   if(array_counter <= spe) {
  4842. +   if (array_counter <= spe) {
  4843.         EQApplicationPacket* outapp = new EQApplicationPacket(OP_Track,sizeof(Track_Struct)*(array_counter));
  4844.         memcpy(outapp->pBuffer, track_array,sizeof(Track_Struct)*(array_counter));
  4845.         outapp->priority = 6;
  4846.         client->QueuePacket(outapp);
  4847.         safe_delete(outapp);
  4848.         ret = true;
  4849. -   }
  4850. -   else {
  4851. +   } else {
  4852.         LogFile->write(EQEMuLog::Status, "ERROR: Unable to transmit a Tracking_Struct packet. Mobs in zone = %i. Mobs in packet = %i", array_counter, spe);
  4853.     }
  4854.  
  4855. @@ -3305,7 +2898,8 @@ bool EntityList::MakeTrackPacket(Client* client)
  4856.     return ret;
  4857.  }
  4858.  
  4859. -void EntityList::MessageGroup(Mob* sender, bool skipclose, uint32 type, const char* message, ...) {
  4860. +void EntityList::MessageGroup(Mob *sender, bool skipclose, uint32 type, const char *message, ...)
  4861. +{
  4862.     va_list argptr;
  4863.     char buffer[4096];
  4864.  
  4865. @@ -3318,135 +2912,110 @@ void EntityList::MessageGroup(Mob* sender, bool skipclose, uint32 type, const ch
  4866.     if (skipclose)
  4867.         dist2 = 0;
  4868.  
  4869. -   LinkedListIterator<Client*> iterator(client_list);
  4870. -
  4871. -   iterator.Reset();
  4872. -   while(iterator.MoreElements())
  4873. -   {
  4874. -       if (iterator.GetData() != sender && (iterator.GetData()->Dist(*sender) <= dist2 || iterator.GetData()->GetGroup() == sender->CastToClient()->GetGroup())) {
  4875. -           iterator.GetData()->Message(type, buffer);
  4876. +   auto it = client_list.begin();
  4877. +   while (it != client_list.end()) {
  4878. +       if (it->second != sender && (it->second->Dist(*sender) <= dist2 || it->second->GetGroup() == sender->CastToClient()->GetGroup())) {
  4879. +           it->second->Message(type, buffer);
  4880.         }
  4881. -       iterator.Advance();
  4882. +       ++it;
  4883.     }
  4884.  }
  4885.  
  4886. -
  4887. -bool EntityList::Fighting(Mob* targ) {
  4888. -   LinkedListIterator<NPC*> iterator(npc_list);
  4889. -   iterator.Reset();
  4890. -   while(iterator.MoreElements())
  4891. -   {
  4892. -       if (iterator.GetData()->CheckAggro(targ))
  4893. -       {
  4894. +bool EntityList::Fighting(Mob *targ)
  4895. +{
  4896. +   auto it = npc_list.begin();
  4897. +   while (it != npc_list.end()) {
  4898. +       if (it->second->CheckAggro(targ))
  4899.             return true;
  4900. -       }
  4901. -       iterator.Advance();
  4902. +       ++it;
  4903.     }
  4904.     return false;
  4905.  }
  4906.  
  4907. -void EntityList::AddHealAggro(Mob* target, Mob* caster, uint16 thedam)
  4908. +void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 thedam)
  4909.  {
  4910. -   LinkedListIterator<NPC*> iterator(npc_list);
  4911. -
  4912. -   iterator.Reset();
  4913.     NPC *cur = nullptr;
  4914.     uint16 count = 0;
  4915. -   while(iterator.MoreElements())
  4916. -   {
  4917. -       cur = iterator.GetData();
  4918. +   auto it = npc_list.begin();
  4919. +   while (it != npc_list.end()) {
  4920. +       cur = it->second;
  4921.  
  4922. -       if(!cur->CheckAggro(target))
  4923. -       {
  4924. -           iterator.Advance();
  4925. +       if (!cur->CheckAggro(target)) {
  4926. +           ++it;
  4927.             continue;
  4928.         }
  4929. -       if (!cur->IsMezzed() && !cur->IsStunned() && !cur->IsFeared())
  4930. -       {
  4931. +       if (!cur->IsMezzed() && !cur->IsStunned() && !cur->IsFeared()) {
  4932.             ++count;
  4933.         }
  4934. -       iterator.Advance();
  4935. +       ++it;
  4936.     }
  4937.  
  4938. -   if(thedam > 1)
  4939. -   {
  4940. -       if(count > 0)
  4941. -           thedam = (thedam / count);
  4942. +   if (thedam > 1) {
  4943. +       if (count > 0)
  4944. +           thedam /= count;
  4945.  
  4946. -       if(thedam < 1)
  4947. +       if (thedam < 1)
  4948.             thedam = 1;
  4949.     }
  4950.  
  4951.     cur = nullptr;
  4952. -   iterator.Reset();
  4953. -   while(iterator.MoreElements())
  4954. -   {
  4955. -       cur = iterator.GetData();
  4956. -       if(!cur->CheckAggro(target)){
  4957. -           iterator.Advance();
  4958. +   it = npc_list.begin();
  4959. +   while (it != npc_list.end()) {
  4960. +       cur = it->second;
  4961. +       if (!cur->CheckAggro(target)) {
  4962. +           ++it;
  4963.             continue;
  4964.         }
  4965.  
  4966. -       if (!cur->IsMezzed() && !cur->IsStunned() && !cur->IsFeared())
  4967. -       {
  4968. -           if(cur->IsPet()){
  4969. -               if(caster){
  4970. -                   if(cur->CheckAggro(caster))
  4971. -                   {
  4972. +       if (!cur->IsMezzed() && !cur->IsStunned() && !cur->IsFeared()) {
  4973. +           if (cur->IsPet()) {
  4974. +               if (caster) {
  4975. +                   if (cur->CheckAggro(caster)) {
  4976.                         cur->AddToHateList(caster, thedam);
  4977.                     }
  4978.                 }
  4979. -           }
  4980. -           else{
  4981. -               if(caster){
  4982. -                   if(cur->CheckAggro(caster))
  4983. -                   {
  4984. +           } else {
  4985. +               if (caster) {
  4986. +                   if (cur->CheckAggro(caster)) {
  4987.                         cur->AddToHateList(caster, thedam);
  4988. -                   }
  4989. -                   else
  4990. -                   {
  4991. -                       cur->AddToHateList(caster, thedam*0.33);
  4992. +                   } else {
  4993. +                       cur->AddToHateList(caster, thedam * 0.33);
  4994.                     }
  4995.                 }
  4996.             }
  4997.         }
  4998. -       iterator.Advance();
  4999. +       ++it;
  5000.     }
  5001.  }
  5002.  
  5003. -void EntityList::OpenDoorsNear(NPC* who)
  5004. +void EntityList::OpenDoorsNear(NPC *who)
  5005.  {
  5006. -   LinkedListIterator<Doors*> iterator(door_list);
  5007. -   iterator.Reset();
  5008. -   while(iterator.MoreElements()) {
  5009. -       Doors *cdoor = iterator.GetData();
  5010. -       if(cdoor && !cdoor->IsDoorOpen()) {
  5011. +   auto it = door_list.begin();
  5012. +   while (it != door_list.end()) {
  5013. +       Doors *cdoor = it->second;
  5014. +       if (cdoor && !cdoor->IsDoorOpen()) {
  5015.             float zdiff = who->GetZ() - cdoor->GetZ();
  5016. -           if(zdiff < 0)
  5017. +           if (zdiff < 0)
  5018.                 zdiff = 0 - zdiff;
  5019.             float curdist = 0;
  5020.             float tmp = who->GetX() - cdoor->GetX();
  5021.             curdist += tmp * tmp;
  5022.             tmp = who->GetY() - cdoor->GetY();
  5023.             curdist += tmp * tmp;
  5024. -           if (zdiff < 10 && curdist <= 100) {
  5025. +           if (zdiff < 10 && curdist <= 100)
  5026.                 cdoor->NPCOpen(who);
  5027. -           }
  5028.         }
  5029. -       iterator.Advance();
  5030. +       ++it;
  5031.     }
  5032.  }
  5033.  
  5034. -void EntityList::SendAlarm(Trap* trap, Mob* currenttarget, uint8 kos)
  5035. +void EntityList::SendAlarm(Trap *trap, Mob *currenttarget, uint8 kos)
  5036.  {
  5037. -   LinkedListIterator<NPC*> iterator(npc_list);
  5038. -   iterator.Reset();
  5039. -
  5040.     float val2 = trap->effectvalue * trap->effectvalue;
  5041.  
  5042. -   while(iterator.MoreElements())
  5043. -   {
  5044. -       NPC *cur = iterator.GetData();
  5045. +   auto it = npc_list.begin();
  5046. +   while (it != npc_list.end()) {
  5047. +       NPC *cur = it->second;
  5048.         float curdist = 0;
  5049.         float tmp = cur->GetX() - trap->x;
  5050.         curdist += tmp*tmp;
  5051. @@ -3459,24 +3028,21 @@ void EntityList::SendAlarm(Trap* trap, Mob* currenttarget, uint8 kos)
  5052.             !cur->IsEngaged() &&
  5053.             curdist <= val2 )
  5054.         {
  5055. -           if(kos)
  5056. -           {
  5057. +           if (kos) {
  5058.                 uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
  5059. -               if(factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS)
  5060. -               {
  5061. +               if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
  5062.                     cur->AddToHateList(currenttarget,1);
  5063.                 }
  5064. -           }
  5065. -           else
  5066. -           {
  5067. +           } else {
  5068.                 cur->AddToHateList(currenttarget,1);
  5069.             }
  5070.         }
  5071. -       iterator.Advance();
  5072. +       ++it;
  5073.     }
  5074.  }
  5075.  
  5076. -void EntityList::AddProximity(NPC *proximity_for) {
  5077. +void EntityList::AddProximity(NPC *proximity_for)
  5078. +{
  5079.     RemoveProximity(proximity_for->GetID());
  5080.  
  5081.     proximity_list.push_back(proximity_for);
  5082. @@ -3484,11 +3050,12 @@ void EntityList::AddProximity(NPC *proximity_for) {
  5083.     proximity_for->proximity = new NPCProximity;
  5084.  }
  5085.  
  5086. -bool EntityList::RemoveProximity(uint16 delete_npc_id) {
  5087. +bool EntityList::RemoveProximity(uint16 delete_npc_id)
  5088. +{
  5089.     auto iter = proximity_list.begin();
  5090.  
  5091. -   while(iter != proximity_list.end()) {
  5092. -       if((*iter)->GetID() == delete_npc_id) {
  5093. +   while (iter != proximity_list.end()) {
  5094. +       if ((*iter)->GetID() == delete_npc_id) {
  5095.             proximity_list.erase(iter);
  5096.             return true;
  5097.         }
  5098. @@ -3497,7 +3064,8 @@ bool EntityList::RemoveProximity(uint16 delete_npc_id) {
  5099.     return false;
  5100.  }
  5101.  
  5102. -void EntityList::RemoveAllLocalities() {
  5103. +void EntityList::RemoveAllLocalities()
  5104. +{
  5105.     proximity_list.clear();
  5106.  }
  5107.  
  5108. @@ -3509,34 +3077,35 @@ struct quest_proximity_event {
  5109.     int area_type;
  5110.  };
  5111.  
  5112. -void EntityList::ProcessMove(Client *c, float x, float y, float z) {
  5113. +void EntityList::ProcessMove(Client *c, float x, float y, float z)
  5114. +{
  5115.     float last_x = c->ProximityX();
  5116.     float last_y = c->ProximityY();
  5117.     float last_z = c->ProximityZ();
  5118.  
  5119.     std::list<quest_proximity_event> events;
  5120. -   for(auto iter = proximity_list.begin(); iter != proximity_list.end(); ++iter) {
  5121. +   for (auto iter = proximity_list.begin(); iter != proximity_list.end(); ++iter) {
  5122.         NPC *d = (*iter);
  5123.         NPCProximity *l = d->proximity;
  5124. -       if(l == nullptr)
  5125. +       if (l == nullptr)
  5126.             continue;
  5127. -  
  5128. +
  5129.         //check both bounding boxes, if either coords pairs
  5130.         //cross a boundary, send the event.
  5131.         bool old_in = true;
  5132.         bool new_in = true;
  5133. -       if(last_x < l->min_x || last_x > l->max_x ||
  5134. -           last_y < l->min_y || last_y > l->max_y ||
  5135. -           last_z < l->min_z || last_z > l->max_z ) {
  5136. +       if (last_x < l->min_x || last_x > l->max_x ||
  5137. +               last_y < l->min_y || last_y > l->max_y ||
  5138. +               last_z < l->min_z || last_z > l->max_z) {
  5139.             old_in = false;
  5140.         }
  5141. -       if(x < l->min_x || x > l->max_x ||
  5142. -           y < l->min_y || y > l->max_y ||
  5143. -           z < l->min_z || z > l->max_z ) {
  5144. +       if (x < l->min_x || x > l->max_x ||
  5145. +               y < l->min_y || y > l->max_y ||
  5146. +               z < l->min_z || z > l->max_z) {
  5147.             new_in = false;
  5148.         }
  5149. -  
  5150. -       if(old_in && !new_in) {
  5151. +
  5152. +       if (old_in && !new_in) {
  5153.             quest_proximity_event evt;
  5154.             evt.event_id = EVENT_EXIT;
  5155.             evt.client = c;
  5156. @@ -3544,7 +3113,7 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z) {
  5157.             evt.area_id = 0;
  5158.             evt.area_type = 0;
  5159.             events.push_back(evt);
  5160. -       } else if(new_in && !old_in) {
  5161. +       } else if (new_in && !old_in) {
  5162.             quest_proximity_event evt;
  5163.             evt.event_id = EVENT_ENTER;
  5164.             evt.client = c;
  5165. @@ -3554,26 +3123,24 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z) {
  5166.             events.push_back(evt);
  5167.         }
  5168.     }
  5169. -  
  5170. -   for(auto iter = area_list.begin(); iter != area_list.end(); ++iter) {
  5171. +
  5172. +   for (auto iter = area_list.begin(); iter != area_list.end(); ++iter) {
  5173.         Area& a = (*iter);
  5174.         bool old_in = true;
  5175.         bool new_in = true;
  5176. -       if(last_x < a.min_x || last_x > a.max_x ||
  5177. -           last_y < a.min_y || last_y > a.max_y ||
  5178. -           last_z < a.min_z || last_z > a.max_z )
  5179. -       {
  5180. +       if (last_x < a.min_x || last_x > a.max_x ||
  5181. +               last_y < a.min_y || last_y > a.max_y ||
  5182. +               last_z < a.min_z || last_z > a.max_z) {
  5183.             old_in = false;
  5184.         }
  5185. -  
  5186. -       if(x < a.min_x || x > a.max_x ||
  5187. -           y < a.min_y || y > a.max_y ||
  5188. -           z < a.min_z || z > a.max_z )
  5189. -       {
  5190. +
  5191. +       if (x < a.min_x || x > a.max_x ||
  5192. +               y < a.min_y || y > a.max_y ||
  5193. +               z < a.min_z || z > a.max_z ) {
  5194.             new_in = false;
  5195.         }
  5196. -  
  5197. -       if(old_in && !new_in) {
  5198. +
  5199. +       if (old_in && !new_in) {
  5200.             //were in but are no longer.
  5201.             quest_proximity_event evt;
  5202.             evt.event_id = EVENT_LEAVE_AREA;
  5203. @@ -3594,9 +3161,9 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z) {
  5204.         }
  5205.     }
  5206.  
  5207. -   for(auto iter = events.begin(); iter != events.end(); ++iter) {
  5208. +   for (auto iter = events.begin(); iter != events.end(); ++iter) {
  5209.         quest_proximity_event& evt = (*iter);
  5210. -       if(evt.npc) {
  5211. +       if (evt.npc) {
  5212.             parse->EventNPC(evt.event_id, evt.npc, evt.client, "", 0);
  5213.         } else {
  5214.             std::vector<void*> args;
  5215. @@ -3607,31 +3174,30 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z) {
  5216.     }
  5217.  }
  5218.  
  5219. -void EntityList::ProcessMove(NPC *n, float x, float y, float z) {
  5220. +void EntityList::ProcessMove(NPC *n, float x, float y, float z)
  5221. +{
  5222.     float last_x = n->GetX();
  5223.     float last_y = n->GetY();
  5224.     float last_z = n->GetZ();
  5225. -  
  5226. +
  5227.     std::list<quest_proximity_event> events;
  5228. -   for(auto iter = area_list.begin(); iter != area_list.end(); ++iter) {
  5229. +   for (auto iter = area_list.begin(); iter != area_list.end(); ++iter) {
  5230.         Area& a = (*iter);
  5231.         bool old_in = true;
  5232.         bool new_in = true;
  5233. -       if(last_x < a.min_x || last_x > a.max_x ||
  5234. -           last_y < a.min_y || last_y > a.max_y ||
  5235. -           last_z < a.min_z || last_z > a.max_z )
  5236. -       {
  5237. +       if (last_x < a.min_x || last_x > a.max_x ||
  5238. +               last_y < a.min_y || last_y > a.max_y ||
  5239. +               last_z < a.min_z || last_z > a.max_z) {
  5240.             old_in = false;
  5241.         }
  5242. -  
  5243. -       if(x < a.min_x || x > a.max_x ||
  5244. -           y < a.min_y || y > a.max_y ||
  5245. -           z < a.min_z || z > a.max_z )
  5246. -       {
  5247. +
  5248. +       if (x < a.min_x || x > a.max_x ||
  5249. +               y < a.min_y || y > a.max_y ||
  5250. +               z < a.min_z || z > a.max_z) {
  5251.             new_in = false;
  5252.         }
  5253. -  
  5254. -       if(old_in && !new_in) {
  5255. +
  5256. +       if (old_in && !new_in) {
  5257.             //were in but are no longer.
  5258.             quest_proximity_event evt;
  5259.             evt.event_id = EVENT_LEAVE_AREA;
  5260. @@ -3652,7 +3218,7 @@ void EntityList::ProcessMove(NPC *n, float x, float y, float z) {
  5261.         }
  5262.     }
  5263.  
  5264. -   for(auto iter = events.begin(); iter != events.end(); ++iter) {
  5265. +   for (auto iter = events.begin(); iter != events.end(); ++iter) {
  5266.         quest_proximity_event& evt = (*iter);
  5267.         std::vector<void*> args;
  5268.         args.push_back(&evt.area_id);
  5269. @@ -3661,12 +3227,14 @@ void EntityList::ProcessMove(NPC *n, float x, float y, float z) {
  5270.     }
  5271.  }
  5272.  
  5273. -void EntityList::AddArea(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z) {
  5274. +void EntityList::AddArea(int id, int type, float min_x, float max_x, float min_y,
  5275. +       float max_y, float min_z, float max_z)
  5276. +{
  5277.     RemoveArea(id);
  5278.     Area a;
  5279.     a.id = id;
  5280.     a.type = type;
  5281. -   if(min_x > max_x) {
  5282. +   if (min_x > max_x) {
  5283.         a.min_x = max_x;
  5284.         a.max_x = min_x;
  5285.     } else {
  5286. @@ -3674,7 +3242,7 @@ void EntityList::AddArea(int id, int type, float min_x, float max_x, float min_y
  5287.         a.max_x = max_x;
  5288.     }
  5289.  
  5290. -   if(min_y > max_y) {
  5291. +   if (min_y > max_y) {
  5292.         a.min_y = max_y;
  5293.         a.max_y = min_y;
  5294.     } else {
  5295. @@ -3682,7 +3250,7 @@ void EntityList::AddArea(int id, int type, float min_x, float max_x, float min_y
  5296.         a.max_y = max_y;
  5297.     }
  5298.  
  5299. -   if(min_z > max_z) {
  5300. +   if (min_z > max_z) {
  5301.         a.min_z = max_z;
  5302.         a.max_z = min_z;
  5303.     } else {
  5304. @@ -3693,7 +3261,8 @@ void EntityList::AddArea(int id, int type, float min_x, float max_x, float min_y
  5305.     area_list.push_back(a);
  5306.  }
  5307.  
  5308. -void EntityList::RemoveArea(int id) {
  5309. +void EntityList::RemoveArea(int id)
  5310. +{
  5311.     auto iter = area_list.begin();
  5312.     while(iter != area_list.end()) {
  5313.         if((*iter).id == id) {
  5314. @@ -3704,85 +3273,79 @@ void EntityList::RemoveArea(int id) {
  5315.     }
  5316.  }
  5317.  
  5318. -void EntityList::ClearAreas() {
  5319. +void EntityList::ClearAreas()
  5320. +{
  5321.     area_list.clear();
  5322.  }
  5323.  
  5324. -void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 language) {
  5325. -
  5326. -   if(!Message || !c)
  5327. +void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 language)
  5328. +{
  5329. +   if (!Message || !c)
  5330.         return;
  5331.  
  5332.     auto iter = proximity_list.begin();
  5333. -   for(; iter != proximity_list.end(); ++iter) {
  5334. +   for (; iter != proximity_list.end(); ++iter) {
  5335.         NPC *d = (*iter);
  5336.         NPCProximity *l = d->proximity;
  5337. -       if(l == nullptr || !l->say)
  5338. +       if (l == nullptr || !l->say)
  5339.             continue;
  5340.  
  5341. -       if(c->GetX() < l->min_x || c->GetX() > l->max_x
  5342. -       || c->GetY() < l->min_y || c->GetY() > l->max_y
  5343. -       || c->GetZ() < l->min_z || c->GetZ() > l->max_z )
  5344. +       if (c->GetX() < l->min_x || c->GetX() > l->max_x
  5345. +               || c->GetY() < l->min_y || c->GetY() > l->max_y
  5346. +               || c->GetZ() < l->min_z || c->GetZ() > l->max_z)
  5347.             continue;
  5348.  
  5349.         parse->EventNPC(EVENT_PROXIMITY_SAY, d, c, Message, language);
  5350.     }
  5351.  }
  5352.  
  5353. -void EntityList::SaveAllClientsTaskState() {
  5354. -
  5355. -   if(!taskmanager) return;
  5356. +void EntityList::SaveAllClientsTaskState()
  5357. +{
  5358. +   if (!taskmanager)
  5359. +       return;
  5360.  
  5361. -   LinkedListIterator<Client*> iterator(client_list);
  5362. -   iterator.Reset();
  5363. -   while(iterator.MoreElements())
  5364. -   {
  5365. -       Client* client = iterator.GetData();
  5366. -       if(client->IsTaskStateLoaded()) {
  5367. +   auto it = client_list.begin();
  5368. +   while (it != client_list.end()) {
  5369. +       Client *client = it->second;
  5370. +       if (client->IsTaskStateLoaded())
  5371.             client->SaveTaskState();
  5372. -       }
  5373.  
  5374. -       iterator.Advance();
  5375. +       ++it;
  5376.     }
  5377.  }
  5378.  
  5379. -void EntityList::ReloadAllClientsTaskState(int TaskID) {
  5380. -
  5381. -   if(!taskmanager) return;
  5382. +void EntityList::ReloadAllClientsTaskState(int TaskID)
  5383. +{
  5384. +   if (!taskmanager)
  5385. +       return;
  5386.  
  5387. -   LinkedListIterator<Client*> iterator(client_list);
  5388. -   iterator.Reset();
  5389. -   while(iterator.MoreElements())
  5390. -   {
  5391. -       Client* client = iterator.GetData();
  5392. -       if(client->IsTaskStateLoaded()) {
  5393. +   auto it = client_list.begin();
  5394. +   while (it != client_list.end()) {
  5395. +       Client *client = it->second;
  5396. +       if (client->IsTaskStateLoaded()) {
  5397.             // If we have been passed a TaskID, only reload the client state if they have
  5398.             // that Task active.
  5399. -           if((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) {
  5400. +           if ((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) {
  5401.                 _log(TASKS__CLIENTLOAD, "Reloading Task State For Client %s", client->GetName());
  5402.                 client->RemoveClientTaskState();
  5403.                 client->LoadClientTaskState();
  5404.                 taskmanager->SendActiveTasksToClient(client);
  5405.             }
  5406.         }
  5407. -       iterator.Advance();
  5408. +       ++it;
  5409.     }
  5410.  }
  5411.  
  5412. -bool EntityList::IsMobInZone(Mob *who) {
  5413. -   LinkedListIterator<Mob*> iterator(mob_list);
  5414. -   iterator.Reset();
  5415. -   while(iterator.MoreElements())
  5416. -   {
  5417. -       if(who == iterator.GetData())
  5418. -           return(true);
  5419. -       iterator.Advance();
  5420. -   }
  5421. -   return(false);
  5422. +bool EntityList::IsMobInZone(Mob *who)
  5423. +{
  5424. +   auto it = mob_list.find(who->GetID());
  5425. +   if (it != mob_list.end())
  5426. +       return who == it->second;
  5427. +   return false;
  5428.  }
  5429.  
  5430.  /*
  5431. -Code to limit the ammount of certain NPCs in a given zone.
  5432. +Code to limit the amount of certain NPCs in a given zone.
  5433.  Primarily used to make a named mob unique within the zone, but written
  5434.  to be more generic allowing limits larger than 1.
  5435.  
  5436. @@ -3790,8 +3353,9 @@ Maintain this stuff in a seperate list since the number
  5437.  of limited NPCs will most likely be much smaller than the number
  5438.  of NPCs in the entire zone.
  5439.  */
  5440. -void EntityList::LimitAddNPC(NPC *npc) {
  5441. -   if(!npc)
  5442. +void EntityList::LimitAddNPC(NPC *npc)
  5443. +{
  5444. +   if (!npc)
  5445.         return;
  5446.  
  5447.     SpawnLimitRecord r;
  5448. @@ -3803,8 +3367,9 @@ void EntityList::LimitAddNPC(NPC *npc) {
  5449.     npc_limit_list[eid] = r;
  5450.  }
  5451.  
  5452. -void EntityList::LimitRemoveNPC(NPC *npc) {
  5453. -   if(!npc)
  5454. +void EntityList::LimitRemoveNPC(NPC *npc)
  5455. +{
  5456. +   if (!npc)
  5457.         return;
  5458.  
  5459.     uint16 eid = npc->GetID();
  5460. @@ -3813,160 +3378,156 @@ void EntityList::LimitRemoveNPC(NPC *npc) {
  5461.  
  5462.  //check a limit over the entire zone.
  5463.  //returns true if the limit has not been reached
  5464. -bool EntityList::LimitCheckType(uint32 npc_type, int count) {
  5465. -   if(count < 1)
  5466. -       return(true);
  5467. +bool EntityList::LimitCheckType(uint32 npc_type, int count)
  5468. +{
  5469. +   if (count < 1)
  5470. +       return true;
  5471.  
  5472.     std::map<uint16, SpawnLimitRecord>::iterator cur,end;
  5473.     cur = npc_limit_list.begin();
  5474.     end = npc_limit_list.end();
  5475.  
  5476. -   for(; cur != end; ++cur) {
  5477. -       if(cur->second.npc_type == npc_type) {
  5478. +   for (; cur != end; ++cur) {
  5479. +       if (cur->second.npc_type == npc_type) {
  5480.             count--;
  5481. -           if(count == 0) {
  5482. -               return(false);
  5483. +           if (count == 0) {
  5484. +               return false;
  5485.             }
  5486.         }
  5487.     }
  5488. -   return(true);
  5489. +   return true;
  5490.  }
  5491.  
  5492.  //check limits on an npc type in a given spawn group.
  5493.  //returns true if the limit has not been reached
  5494. -bool EntityList::LimitCheckGroup(uint32 spawngroup_id, int count) {
  5495. -   if(count < 1)
  5496. -       return(true);
  5497. +bool EntityList::LimitCheckGroup(uint32 spawngroup_id, int count)
  5498. +{
  5499. +   if (count < 1)
  5500. +       return true;
  5501.  
  5502.     std::map<uint16, SpawnLimitRecord>::iterator cur,end;
  5503.     cur = npc_limit_list.begin();
  5504.     end = npc_limit_list.end();
  5505.  
  5506. -   for(; cur != end; ++cur) {
  5507. -       if(cur->second.spawngroup_id == spawngroup_id) {
  5508. +   for (; cur != end; ++cur) {
  5509. +       if (cur->second.spawngroup_id == spawngroup_id) {
  5510.             count--;
  5511. -           if(count == 0) {
  5512. -               return(false);
  5513. +           if (count == 0) {
  5514. +               return false;
  5515.             }
  5516.         }
  5517.     }
  5518. -   return(true);
  5519. +   return true;
  5520.  }
  5521.  
  5522.  //check limits on an npc type in a given spawn group, and
  5523.  //checks limits on the entire zone in one pass.
  5524.  //returns true if neither limit has been reached
  5525. -bool EntityList::LimitCheckBoth(uint32 npc_type, uint32 spawngroup_id, int group_count, int type_count) {
  5526. -   if(group_count < 1 && type_count < 1)
  5527. -       return(true);
  5528. +bool EntityList::LimitCheckBoth(uint32 npc_type, uint32 spawngroup_id, int group_count, int type_count)
  5529. +{
  5530. +   if (group_count < 1 && type_count < 1)
  5531. +       return true;
  5532.  
  5533.     std::map<uint16, SpawnLimitRecord>::iterator cur,end;
  5534.     cur = npc_limit_list.begin();
  5535.     end = npc_limit_list.end();
  5536.  
  5537. -   for(; cur != end; ++cur) {
  5538. -       if(cur->second.npc_type == npc_type) {
  5539. +   for (; cur != end; ++cur) {
  5540. +       if (cur->second.npc_type == npc_type) {
  5541.             type_count--;
  5542. -           if(type_count == 0) {
  5543. -               return(false);
  5544. +           if (type_count == 0) {
  5545. +               return false;
  5546.             }
  5547.         }
  5548. -       if(cur->second.spawngroup_id == spawngroup_id) {
  5549. +       if (cur->second.spawngroup_id == spawngroup_id) {
  5550.             group_count--;
  5551. -           if(group_count == 0) {
  5552. -               return(false);
  5553. +           if (group_count == 0) {
  5554. +               return false;
  5555.             }
  5556.         }
  5557.     }
  5558. -   return(true);
  5559. +   return true;
  5560.  }
  5561.  
  5562.  bool EntityList::LimitCheckName(const char *npc_name)
  5563.  {
  5564. -   LinkedListIterator<NPC*> iterator(npc_list);
  5565. -   iterator.Reset();
  5566. -   while(iterator.MoreElements())
  5567. -   {
  5568. -       NPC* npc = iterator.GetData();
  5569. -       if(npc)
  5570. -       {
  5571. -           if(strcasecmp(npc_name, npc->GetRawNPCTypeName()) == 0)
  5572. -           {
  5573. +   auto it = npc_list.begin();
  5574. +   while (it != npc_list.end()) {
  5575. +       NPC* npc = it->second;
  5576. +       if (npc)
  5577. +           if (strcasecmp(npc_name, npc->GetRawNPCTypeName()) == 0)
  5578.                 return false;
  5579. -           }
  5580. -       }
  5581. -       iterator.Advance();
  5582. +       ++it;
  5583.     }
  5584.     return true;
  5585.  }
  5586.  
  5587. -void EntityList::RadialSetLogging(Mob *around, bool enabled, bool clients, bool non_clients, float range) {
  5588. +void EntityList::RadialSetLogging(Mob *around, bool enabled, bool clients,
  5589. +       bool non_clients, float range)
  5590. +{
  5591.     float range2 = range * range;
  5592.  
  5593. -   LinkedListIterator<Mob*> iterator(mob_list);
  5594. -   iterator.Reset();
  5595. -   while(iterator.MoreElements()) {
  5596. -       Mob* mob = iterator.GetData();
  5597. +   auto it = mob_list.begin();
  5598. +   while (it != mob_list.end()) {
  5599. +       Mob *mob = it->second;
  5600.  
  5601. -       iterator.Advance();
  5602. +       ++it;
  5603.  
  5604. -       if(mob->IsClient()) {
  5605. -           if(!clients)
  5606. +       if (mob->IsClient()) {
  5607. +           if (!clients)
  5608.                 continue;
  5609.         } else {
  5610. -           if(!non_clients)
  5611. +           if (!non_clients)
  5612.                 continue;
  5613.         }
  5614.  
  5615. -       if(around->DistNoRoot(*mob) > range2)
  5616. +       if (around->DistNoRoot(*mob) > range2)
  5617.             continue;
  5618.  
  5619. -       if(enabled)
  5620. +       if (enabled)
  5621.             mob->EnableLogging();
  5622.         else
  5623.             mob->DisableLogging();
  5624.     }
  5625.  }
  5626.  
  5627. -void EntityList::UpdateHoTT(Mob* target) {
  5628. -   LinkedListIterator<Client*> iterator(client_list);
  5629. -   iterator.Reset();
  5630. -   while(iterator.MoreElements())
  5631. -   {
  5632. -       Client* c = iterator.GetData();
  5633. +void EntityList::UpdateHoTT(Mob *target)
  5634. +{
  5635. +   auto it = client_list.begin();
  5636. +   while (it != client_list.end()) {
  5637. +       Client *c = it->second;
  5638.         if (c->GetTarget() == target) {
  5639. -           if (target->GetTarget()) c->SetHoTT(target->GetTarget()->GetID());
  5640. -           else c->SetHoTT(0);
  5641. +           if (target->GetTarget())
  5642. +               c->SetHoTT(target->GetTarget()->GetID());
  5643. +           else
  5644. +               c->SetHoTT(0);
  5645.  
  5646.             c->UpdateXTargetType(TargetsTarget, target->GetTarget());
  5647.         }
  5648. -       iterator.Advance();
  5649. +       ++it;
  5650.     }
  5651.  }
  5652.  
  5653.  void EntityList::DestroyTempPets(Mob *owner)
  5654.  {
  5655. -   LinkedListIterator<NPC*> iterator(npc_list);
  5656. -   iterator.Reset();
  5657. -   while(iterator.MoreElements())
  5658. -   {
  5659. -       NPC* n = iterator.GetData();
  5660. -       if(n->GetSwarmInfo())
  5661. -       {
  5662. -           if(n->GetSwarmInfo()->owner_id == owner->GetID())
  5663. -           {
  5664. +   auto it = npc_list.begin();
  5665. +   while (it != npc_list.end()) {
  5666. +       NPC* n = it->second;
  5667. +       if (n->GetSwarmInfo()) {
  5668. +           if (n->GetSwarmInfo()->owner_id == owner->GetID()) {
  5669.                 n->Depop();
  5670.             }
  5671.         }
  5672. -       iterator.Advance();
  5673. +       ++it;
  5674.     }
  5675.  }
  5676.  
  5677. -bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z, float trg_x, float trg_y, float trg_z, float perwalk)
  5678. +bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z,
  5679. +       float trg_x, float trg_y, float trg_z, float perwalk)
  5680.  {
  5681. -   if(zone->zonemap == nullptr) {
  5682. -       return(true);
  5683. -   }
  5684. +   if (zone->zonemap == nullptr)
  5685. +       return true;
  5686. +
  5687.     VERTEX myloc;
  5688.     VERTEX oloc;
  5689.     VERTEX hit;
  5690. @@ -3989,55 +3550,48 @@ bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z, float
  5691.     return false;
  5692.  }
  5693.  
  5694. -void EntityList::QuestJournalledSayClose(Mob *sender, Client *QuestInitiator, float dist, const char* mobname, const char* message)
  5695. +void EntityList::QuestJournalledSayClose(Mob *sender, Client *QuestInitiator,
  5696. +       float dist, const char* mobname, const char* message)
  5697.  {
  5698. -   Client *c;
  5699. -   LinkedListIterator<Client*> iterator(client_list);
  5700. +   Client *c = nullptr;
  5701.     float dist2 = dist * dist;
  5702.  
  5703.     // Send the message to the quest initiator such that the client will enter it into the NPC Quest Journal
  5704. -   if(QuestInitiator) {
  5705. +   if (QuestInitiator) {
  5706.         char *buf = new char[strlen(mobname) + strlen(message) + 10];
  5707.         sprintf(buf, "%s says, '%s'", mobname, message);
  5708.         QuestInitiator->QuestJournalledMessage(mobname, buf);
  5709.         safe_delete_array(buf);
  5710.     }
  5711.     // Use the old method for all other nearby clients
  5712. -   for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
  5713. -   {
  5714. -       c = iterator.GetData();
  5715. +   for (auto it = client_list.begin(); it != client_list.end(); ++it) {
  5716. +       c = it->second;
  5717.         if(c && (c != QuestInitiator) && c->DistNoRoot(*sender) <= dist2)
  5718.             c->Message_StringID(10, GENERIC_SAY, mobname, message);
  5719.     }
  5720.  }
  5721.  
  5722. -Corpse* EntityList::GetClosestCorpse(Mob* sender, const char* Name)
  5723. +Corpse *EntityList::GetClosestCorpse(Mob *sender, const char *Name)
  5724.  {
  5725. -   if(!sender)
  5726. +   if (!sender)
  5727.         return nullptr;
  5728.  
  5729.     uint32 CurrentDistance, ClosestDistance = 4294967295u;
  5730. -
  5731.     Corpse *CurrentCorpse, *ClosestCorpse = nullptr;
  5732.  
  5733. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  5734. -
  5735. -   iterator.Reset();
  5736. -
  5737. -   while(iterator.MoreElements())
  5738. -   {
  5739. -       CurrentCorpse = iterator.GetData();
  5740. +   auto it = corpse_list.begin();
  5741. +   while (it != corpse_list.end()) {
  5742. +       CurrentCorpse = it->second;
  5743.  
  5744. -       iterator.Advance();
  5745. +       ++it;
  5746.  
  5747. -       if(Name && strcasecmp(CurrentCorpse->GetOwnerName(), Name))
  5748. +       if (Name && strcasecmp(CurrentCorpse->GetOwnerName(), Name))
  5749.             continue;
  5750.  
  5751.         CurrentDistance = ((CurrentCorpse->GetY() - sender->GetY()) * (CurrentCorpse->GetY() - sender->GetY())) +
  5752.                     ((CurrentCorpse->GetX() - sender->GetX()) * (CurrentCorpse->GetX() - sender->GetX()));
  5753.  
  5754. -       if(CurrentDistance < ClosestDistance)
  5755. -       {
  5756. +       if (CurrentDistance < ClosestDistance) {
  5757.             ClosestDistance = CurrentDistance;
  5758.  
  5759.             ClosestCorpse = CurrentCorpse;
  5760. @@ -4047,116 +3601,108 @@ Corpse* EntityList::GetClosestCorpse(Mob* sender, const char* Name)
  5761.     return ClosestCorpse;
  5762.  }
  5763.  
  5764. -void EntityList::ForceGroupUpdate(uint32 gid) {
  5765. -   LinkedListIterator<Client*> iterator(client_list);
  5766. -
  5767. -   iterator.Reset();
  5768. -   while(iterator.MoreElements()) {
  5769. -       if(iterator.GetData()){
  5770. +void EntityList::ForceGroupUpdate(uint32 gid)
  5771. +{
  5772. +   auto it = client_list.begin();
  5773. +   while (it != client_list.end()) {
  5774. +       if (it->second){
  5775.             Group *g = nullptr;
  5776. -           g = iterator.GetData()->GetGroup();
  5777. -           if(g){
  5778. -               if(g->GetID() == gid)
  5779. -               {
  5780. -                   database.RefreshGroupFromDB(iterator.GetData());
  5781. +           g = it->second->GetGroup();
  5782. +           if (g) {
  5783. +               if (g->GetID() == gid) {
  5784. +                   database.RefreshGroupFromDB(it->second);
  5785.                 }
  5786.             }
  5787.         }
  5788. -       iterator.Advance();
  5789. +       ++it;
  5790.     }
  5791.  }
  5792.  
  5793. -void EntityList::SendGroupLeave(uint32 gid, const char *name) {
  5794. -   LinkedListIterator<Client*> iterator(client_list);
  5795. -   iterator.Reset();
  5796. -   while(iterator.MoreElements()) {
  5797. -       Client *c = iterator.GetData();
  5798. -       if(c){
  5799. +void EntityList::SendGroupLeave(uint32 gid, const char *name)
  5800. +{
  5801. +   auto it = client_list.begin();
  5802. +   while (it != client_list.end()) {
  5803. +       Client *c = it->second;
  5804. +       if (c) {
  5805.             Group *g = nullptr;
  5806.             g = c->GetGroup();
  5807. -           if(g){
  5808. -               if(g->GetID() == gid)
  5809. -               {
  5810. +           if (g) {
  5811. +               if (g->GetID() == gid) {
  5812.                     EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct));
  5813.                     GroupJoin_Struct* gj = (GroupJoin_Struct*) outapp->pBuffer;
  5814.                     strcpy(gj->membername, name);
  5815.                     gj->action = groupActLeave;
  5816.                     strcpy(gj->yourname, c->GetName());
  5817.                     Mob *Leader = g->GetLeader();
  5818. -                   if(Leader)
  5819. +                   if (Leader)
  5820.                         Leader->CastToClient()->GetGroupAAs(&gj->leader_aas);
  5821.                     c->QueuePacket(outapp);
  5822.                     safe_delete(outapp);
  5823.                     g->DelMemberOOZ(name);
  5824. -                   if(g->IsLeader(c) && c->IsLFP())
  5825. +                   if (g->IsLeader(c) && c->IsLFP())
  5826.                         c->UpdateLFP();
  5827.                 }
  5828.             }
  5829.         }
  5830. -       iterator.Advance();
  5831. +       ++it;
  5832.     }
  5833.  }
  5834.  
  5835. -void EntityList::SendGroupJoin(uint32 gid, const char *name) {
  5836. -   LinkedListIterator<Client*> iterator(client_list);
  5837. -   iterator.Reset();
  5838. -   while(iterator.MoreElements()) {
  5839. -       if(iterator.GetData()){
  5840. +void EntityList::SendGroupJoin(uint32 gid, const char *name)
  5841. +{
  5842. +   auto it = client_list.begin();
  5843. +   while (it != client_list.end()) {
  5844. +       if (it->second){
  5845.             Group *g = nullptr;
  5846. -           g = iterator.GetData()->GetGroup();
  5847. -           if(g){
  5848. -               if(g->GetID() == gid)
  5849. -               {
  5850. +           g = it->second->GetGroup();
  5851. +           if (g) {
  5852. +               if (g->GetID() == gid) {
  5853.                     EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct));
  5854.                     GroupJoin_Struct* gj = (GroupJoin_Struct*) outapp->pBuffer;
  5855.                     strcpy(gj->membername, name);
  5856.                     gj->action = groupActJoin;
  5857. -                   strcpy(gj->yourname, iterator.GetData()->GetName());
  5858. +                   strcpy(gj->yourname, it->second->GetName());
  5859.                     Mob *Leader = g->GetLeader();
  5860. -                   if(Leader)
  5861. +                   if (Leader)
  5862.                         Leader->CastToClient()->GetGroupAAs(&gj->leader_aas);
  5863.  
  5864. -                   iterator.GetData()->QueuePacket(outapp);
  5865. +                   it->second->QueuePacket(outapp);
  5866.                     safe_delete(outapp);
  5867.                 }
  5868.             }
  5869.         }
  5870. -       iterator.Advance();
  5871. +       ++it;
  5872.     }
  5873.  }
  5874.  
  5875.  void EntityList::GroupMessage(uint32 gid, const char *from, const char *message)
  5876.  {
  5877. -   LinkedListIterator<Client*> iterator(client_list);
  5878. -   iterator.Reset();
  5879. -   while(iterator.MoreElements()) {
  5880. -       if(iterator.GetData()){
  5881. +   auto it = client_list.begin();
  5882. +   while (it != client_list.end()) {
  5883. +       if (it->second) {
  5884.             Group *g = nullptr;
  5885. -           g = iterator.GetData()->GetGroup();
  5886. -           if(g){
  5887. -               if(g->GetID() == gid)
  5888. -               {
  5889. -                   iterator.GetData()->ChannelMessageSend(from, iterator.GetData()->GetName(),2,0,message);
  5890. -               }
  5891. +           g = it->second->GetGroup();
  5892. +           if (g) {
  5893. +               if (g->GetID() == gid)
  5894. +                   it->second->ChannelMessageSend(from, it->second->GetName(), 2, 0, message);
  5895.             }
  5896.         }
  5897. -       iterator.Advance();
  5898. +       ++it;
  5899.     }
  5900.  }
  5901.  
  5902. -uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time)
  5903. +uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z,
  5904. +       float heading, uint32 decay_time)
  5905.  {
  5906. -   const Item_Struct* is = database.GetItem(itemid);
  5907. -   if(is)
  5908. -   {
  5909. +   const Item_Struct *is = database.GetItem(itemid);
  5910. +   if (is) {
  5911.         ItemInst *i = new ItemInst(is, is->MaxCharges);
  5912. -       if(i)
  5913. -       {
  5914. -           Object* object = new Object(i,x,y,z,heading,decay_time);
  5915. +       if (i) {
  5916. +           Object *object = new Object(i, x, y, z, heading,decay_time);
  5917.             entity_list.AddObject(object, true);
  5918.  
  5919.             safe_delete(i);
  5920. -           if(object)
  5921. +           if (object)
  5922.                 return object->GetID();
  5923.         }
  5924.         return 0; // fell through itemstruct
  5925. @@ -4164,245 +3710,205 @@ uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z,
  5926.     return 0; // fell through everything, this is bad/incomplete from perl
  5927.  }
  5928.  
  5929. -uint16 EntityList::CreateGroundObjectFromModel(const char *model, float x, float y, float z, float heading, uint8 type, uint32 decay_time)
  5930. +uint16 EntityList::CreateGroundObjectFromModel(const char *model, float x,
  5931. +       float y, float z, float heading, uint8 type, uint32 decay_time)
  5932.  {
  5933. -   if(model)
  5934. -   {
  5935. -           Object* object = new Object(model,x,y,z,heading,type);
  5936. +   if (model) {
  5937. +           Object *object = new Object(model, x, y, z, heading, type);
  5938.             entity_list.AddObject(object, true);
  5939.  
  5940. -           if(object)
  5941. +           if (object)
  5942.                 return object->GetID();
  5943.     }
  5944.     return 0; // fell through everything, this is bad/incomplete from perl
  5945.  }
  5946.  
  5947. -uint16 EntityList::CreateDoor(const char *model, float x, float y, float z, float heading, uint8 opentype, uint16 size)
  5948. +uint16 EntityList::CreateDoor(const char *model, float x, float y, float z,
  5949. +       float heading, uint8 opentype, uint16 size)
  5950.  {
  5951. -   if(model)
  5952. -   {
  5953. -           Doors* door = new Doors(model,x,y,z,heading,opentype, size);
  5954. +   if (model) {
  5955. +           Doors *door = new Doors(model, x, y, z, heading, opentype, size);
  5956.             RemoveAllDoors();
  5957.             zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
  5958.             entity_list.AddDoor(door);
  5959.             entity_list.RespawnAllDoors();
  5960.  
  5961. -           if(door)
  5962. +           if (door)
  5963.                 return door->GetEntityID();
  5964.     }
  5965.     return 0; // fell through everything, this is bad/incomplete from perl
  5966.  }
  5967.  
  5968.  
  5969. -Mob* EntityList::GetTargetForMez(Mob* caster)
  5970. +Mob *EntityList::GetTargetForMez(Mob *caster)
  5971.  {
  5972. -   if(!caster)
  5973. +   if (!caster)
  5974.         return nullptr;
  5975.  
  5976. -   LinkedListIterator<Mob*> iterator(mob_list);
  5977. -   iterator.Reset();
  5978. +   auto it = mob_list.begin();
  5979.     //TODO: make this smarter and not mez targets being damaged by dots
  5980. -   while(iterator.MoreElements()) {
  5981. -       Mob* d = iterator.GetData();
  5982. -       if(d){
  5983. -           if(d == caster){ //caster can't pick himself
  5984. -               iterator.Advance();
  5985. +   while (it != mob_list.end()) {
  5986. +       Mob *d = it->second;
  5987. +       if (d) {
  5988. +           if (d == caster) { //caster can't pick himself
  5989. +               ++it;
  5990.                 continue;
  5991.             }
  5992.  
  5993. -           if(caster->GetTarget() == d){ //caster can't pick his target
  5994. -               iterator.Advance();
  5995. +           if (caster->GetTarget() == d) { //caster can't pick his target
  5996. +               ++it;
  5997.                 continue;
  5998.             }
  5999.  
  6000. -           if(!caster->CheckAggro(d)){ //caster can't pick targets that aren't aggroed on himself
  6001. -               iterator.Advance();
  6002. +           if (!caster->CheckAggro(d)) { //caster can't pick targets that aren't aggroed on himself
  6003. +               ++it;
  6004.                 continue;
  6005.             }
  6006.  
  6007. -           if(caster->DistNoRoot(*d) > 22250){ //only pick targets within 150 range
  6008. -               iterator.Advance();
  6009. +           if (caster->DistNoRoot(*d) > 22250) { //only pick targets within 150 range
  6010. +               ++it;
  6011.                 continue;
  6012.             }
  6013.  
  6014. -           if(!caster->CheckLosFN(d)){ //this is wasteful but can't really think of another way to do it
  6015. -               iterator.Advance();     //that wont have us trying to los the same target every time
  6016. -               continue;               //it's only in combat so it's impact should be minimal.. but stil.
  6017. +           if (!caster->CheckLosFN(d)) {   //this is wasteful but can't really think of another way to do it
  6018. +               ++it;                       //that wont have us trying to los the same target every time
  6019. +               continue;                   //it's only in combat so it's impact should be minimal.. but stil.
  6020.             }
  6021.             return d;
  6022.         }
  6023. -       iterator.Advance();
  6024. +       ++it;
  6025.     }
  6026.     return nullptr;
  6027.  }
  6028.  
  6029.  void EntityList::SendZoneAppearance(Client *c)
  6030.  {
  6031. -   if(!c)
  6032. +   if (!c)
  6033.         return;
  6034.  
  6035. -   LinkedListIterator<Mob*> iterator(mob_list);
  6036. -   iterator.Reset();
  6037. -   while(iterator.MoreElements()) {
  6038. -       Mob *cur = iterator.GetData();
  6039. +   auto it = mob_list.begin();
  6040. +   while (it != mob_list.end()) {
  6041. +       Mob *cur = it->second;
  6042.  
  6043. -       if(cur)
  6044. -       {
  6045. -           if(cur == c)
  6046. -           {
  6047. -               iterator.Advance();
  6048. +       if (cur) {
  6049. +           if (cur == c) {
  6050. +               ++it;
  6051.                 continue;
  6052.             }
  6053. -           if(cur->GetAppearance() != eaStanding)
  6054. -           {
  6055. +           if (cur->GetAppearance() != eaStanding) {
  6056.                 cur->SendAppearancePacket(AT_Anim, cur->GetAppearanceValue(cur->GetAppearance()), false, true, c);
  6057.             }
  6058. -           if(cur->GetSize() != cur->GetBaseSize())
  6059. -           {
  6060. +           if (cur->GetSize() != cur->GetBaseSize()) {
  6061.                 cur->SendAppearancePacket(AT_Size, (uint32)cur->GetSize(), false, true, c);
  6062.             }
  6063.         }
  6064. -       iterator.Advance();
  6065. +       ++it;
  6066.     }
  6067.  }
  6068.  
  6069.  void EntityList::SendNimbusEffects(Client *c)
  6070.  {
  6071. -   if(!c)
  6072. +   if (!c)
  6073.         return;
  6074.  
  6075. -   LinkedListIterator<Mob*> iterator(mob_list);
  6076. -   iterator.Reset();
  6077. -   while(iterator.MoreElements()) {
  6078. -       Mob *cur = iterator.GetData();
  6079. +   auto it = mob_list.begin();
  6080. +   while (it != mob_list.end()) {
  6081. +       Mob *cur = it->second;
  6082.  
  6083. -       if(cur)
  6084. -       {
  6085. -           if(cur == c)
  6086. -           {
  6087. -               iterator.Advance();
  6088. +       if (cur) {
  6089. +           if (cur == c) {
  6090. +               ++it;
  6091.                 continue;
  6092.             }
  6093. -           if(cur->GetNimbusEffect1() != 0)
  6094. -           {
  6095. +           if (cur->GetNimbusEffect1() != 0) {
  6096.                 cur->SendSpellEffect(cur->GetNimbusEffect1(), 1000, 0, 1, 3000, false, c);
  6097.             }
  6098. -           if(cur->GetNimbusEffect2() != 0)
  6099. -           {
  6100. +           if (cur->GetNimbusEffect2() != 0) {
  6101.                 cur->SendSpellEffect(cur->GetNimbusEffect2(), 2000, 0, 1, 3000, false, c);
  6102.             }
  6103. -           if(cur->GetNimbusEffect3() != 0)
  6104. -           {
  6105. +           if (cur->GetNimbusEffect3() != 0) {
  6106.                 cur->SendSpellEffect(cur->GetNimbusEffect3(), 3000, 0, 1, 3000, false, c);
  6107.             }
  6108.         }
  6109. -       iterator.Advance();
  6110. +       ++it;
  6111.     }
  6112.  }
  6113.  
  6114.  void EntityList::SendUntargetable(Client *c)
  6115.  {
  6116. -   if(!c)
  6117. +   if (!c)
  6118.         return;
  6119.  
  6120. -   LinkedListIterator<Mob*> iterator(mob_list);
  6121. -   iterator.Reset();
  6122. -   while(iterator.MoreElements()) {
  6123. -       Mob *cur = iterator.GetData();
  6124. +   auto it = mob_list.begin();
  6125. +   while (it != mob_list.end()) {
  6126. +       Mob *cur = it->second;
  6127.  
  6128. -       if(cur)
  6129. -       {
  6130. -           if(cur == c)
  6131. -           {
  6132. -               iterator.Advance();
  6133. +       if (cur) {
  6134. +           if (cur == c) {
  6135. +               ++it;
  6136.                 continue;
  6137.             }
  6138. -           if(!cur->IsTargetable()) {
  6139. +           if (!cur->IsTargetable())
  6140.                 cur->SendTargetable(false, c);
  6141. -           }
  6142.         }
  6143. -       iterator.Advance();
  6144. +       ++it;
  6145.     }
  6146.  }
  6147.  
  6148. -void EntityList::ZoneWho(Client *c, Who_All_Struct* Who) {
  6149. -
  6150. +void EntityList::ZoneWho(Client *c, Who_All_Struct *Who)
  6151. +{
  6152.     // This is only called for SoF clients, as regular /who is now handled server-side for that client.
  6153. -   //
  6154.     uint32 PacketLength = 0;
  6155. -
  6156.     uint32 Entries = 0;
  6157. -
  6158.     uint8 WhomLength = strlen(Who->whom);
  6159.  
  6160. -   LinkedListIterator<Client*> iterator(client_list);
  6161. +   std::list<Client *> client_sub_list;
  6162. +   auto it = client_list.begin();
  6163. +   while (it != client_list.end()) {
  6164. +       Client *ClientEntry = it->second;
  6165. +       ++it;
  6166.  
  6167. -   iterator.Reset();
  6168. -
  6169. -   while(iterator.MoreElements()) {
  6170. -
  6171. -       Client *ClientEntry = iterator.GetData();
  6172. -
  6173. -       iterator.Advance();
  6174. -
  6175. -       if(ClientEntry) {
  6176. -
  6177. -           if(ClientEntry->GMHideMe(c))
  6178. +       if (ClientEntry) {
  6179. +           if (ClientEntry->GMHideMe(c))
  6180.                 continue;
  6181. -
  6182. -           if((Who->wrace != 0xFFFFFFFF) && (ClientEntry->GetRace() != Who->wrace))
  6183. +           if ((Who->wrace != 0xFFFFFFFF) && (ClientEntry->GetRace() != Who->wrace))
  6184.                 continue;
  6185. -
  6186. -           if((Who->wclass != 0xFFFFFFFF) && (ClientEntry->GetClass() != Who->wclass))
  6187. +           if ((Who->wclass != 0xFFFFFFFF) && (ClientEntry->GetClass() != Who->wclass))
  6188.                 continue;
  6189. -
  6190. -           if((Who->lvllow != 0xFFFFFFFF) && (ClientEntry->GetLevel() < Who->lvllow))
  6191. +           if ((Who->lvllow != 0xFFFFFFFF) && (ClientEntry->GetLevel() < Who->lvllow))
  6192.                 continue;
  6193. -
  6194. -           if((Who->lvlhigh != 0xFFFFFFFF) && (ClientEntry->GetLevel() > Who->lvlhigh))
  6195. +           if ((Who->lvlhigh != 0xFFFFFFFF) && (ClientEntry->GetLevel() > Who->lvlhigh))
  6196.                 continue;
  6197. -
  6198. -           if(Who->guildid != 0xFFFFFFFF) {
  6199. -
  6200. -               if((Who->guildid == 0xFFFFFFFC) && !ClientEntry->IsTrader())
  6201. +           if (Who->guildid != 0xFFFFFFFF) {
  6202. +               if ((Who->guildid == 0xFFFFFFFC) && !ClientEntry->IsTrader())
  6203.                     continue;
  6204. -
  6205. -               if((Who->guildid == 0xFFFFFFFB) && !ClientEntry->IsBuyer())
  6206. +               if ((Who->guildid == 0xFFFFFFFB) && !ClientEntry->IsBuyer())
  6207.                     continue;
  6208. -
  6209. -               if(Who->guildid != ClientEntry->GuildID())
  6210. +               if (Who->guildid != ClientEntry->GuildID())
  6211.                     continue;
  6212.             }
  6213. -
  6214. -           if(WhomLength && strncasecmp(Who->whom, ClientEntry->GetName(), WhomLength) &&
  6215. +           if (WhomLength && strncasecmp(Who->whom, ClientEntry->GetName(), WhomLength) &&
  6216.                     strncasecmp(guild_mgr.GetGuildName(ClientEntry->GuildID()), Who->whom, WhomLength))
  6217.                 continue;
  6218.  
  6219.             Entries++;
  6220. +           client_sub_list.push_back(ClientEntry);
  6221.  
  6222.             PacketLength = PacketLength + strlen(ClientEntry->GetName());
  6223.  
  6224. -           if(strlen(guild_mgr.GetGuildName(ClientEntry->GuildID())) > 0)
  6225. +           if (strlen(guild_mgr.GetGuildName(ClientEntry->GuildID())) > 0)
  6226.                 PacketLength = PacketLength + strlen(guild_mgr.GetGuildName(ClientEntry->GuildID())) + 2;
  6227.         }
  6228.     }
  6229.  
  6230.     PacketLength = PacketLength + sizeof(WhoAllReturnStruct) + (47 * Entries);
  6231. -
  6232. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_WhoAllResponse, PacketLength);
  6233. -
  6234. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_WhoAllResponse, PacketLength);
  6235.     char *Buffer = (char *)outapp->pBuffer;
  6236. -
  6237.     WhoAllReturnStruct *WARS = (WhoAllReturnStruct *)Buffer;
  6238. -
  6239.     WARS->id = 0;
  6240. -
  6241.     WARS->playerineqstring = 5001;
  6242. -
  6243.     strncpy(WARS->line, "---------------------------", sizeof(WARS->line));
  6244. -
  6245.     WARS->unknown35 = 0x0a;
  6246. -
  6247.     WARS->unknown36 = 0;
  6248.  
  6249.     switch(Entries) {
  6250. @@ -4417,144 +3923,96 @@ void EntityList::ZoneWho(Client *c, Who_All_Struct* Who) {
  6251.     }
  6252.  
  6253.     WARS->unknown44[0] = 0;
  6254. -
  6255.     WARS->unknown44[1] = 0;
  6256. -
  6257.     WARS->unknown52 = Entries;
  6258. -
  6259.     WARS->unknown56 = Entries;
  6260. -
  6261.     WARS->playercount = Entries;
  6262. -
  6263.     Buffer += sizeof(WhoAllReturnStruct);
  6264.  
  6265. -   iterator.Reset();
  6266. -
  6267. -   while(iterator.MoreElements()) {
  6268. -
  6269. -       Client *ClientEntry = iterator.GetData();
  6270. +   auto sit = client_sub_list.begin();
  6271. +   while (sit != client_sub_list.end()) {
  6272. +       Client *ClientEntry = *sit;
  6273. +       ++sit;
  6274.  
  6275. -       iterator.Advance();
  6276. -
  6277. -       if(ClientEntry) {
  6278. -
  6279. -           if(ClientEntry->GMHideMe(c)) continue;
  6280. -
  6281. -           if((Who->wrace != 0xFFFFFFFF) && (ClientEntry->GetRace() != Who->wrace))
  6282. +       if (ClientEntry) {
  6283. +           if (ClientEntry->GMHideMe(c))
  6284.                 continue;
  6285. -
  6286. -           if((Who->wclass != 0xFFFFFFFF) && (ClientEntry->GetClass() != Who->wclass))
  6287. +           if ((Who->wrace != 0xFFFFFFFF) && (ClientEntry->GetRace() != Who->wrace))
  6288.                 continue;
  6289. -
  6290. -           if((Who->lvllow != 0xFFFFFFFF) && (ClientEntry->GetLevel() < Who->lvllow))
  6291. +           if ((Who->wclass != 0xFFFFFFFF) && (ClientEntry->GetClass() != Who->wclass))
  6292.                 continue;
  6293. -
  6294. -           if((Who->lvlhigh != 0xFFFFFFFF) && (ClientEntry->GetLevel() > Who->lvlhigh))
  6295. +           if ((Who->lvllow != 0xFFFFFFFF) && (ClientEntry->GetLevel() < Who->lvllow))
  6296.                 continue;
  6297. -
  6298. -           if(Who->guildid != 0xFFFFFFFF) {
  6299. -
  6300. -               if((Who->guildid == 0xFFFFFFFC) && !ClientEntry->IsTrader())
  6301. +           if ((Who->lvlhigh != 0xFFFFFFFF) && (ClientEntry->GetLevel() > Who->lvlhigh))
  6302. +               continue;
  6303. +           if (Who->guildid != 0xFFFFFFFF) {
  6304. +               if ((Who->guildid == 0xFFFFFFFC) && !ClientEntry->IsTrader())
  6305.                     continue;
  6306. -
  6307. -               if((Who->guildid == 0xFFFFFFFB) && !ClientEntry->IsBuyer())
  6308. +               if ((Who->guildid == 0xFFFFFFFB) && !ClientEntry->IsBuyer())
  6309.                     continue;
  6310. -
  6311. -               if(Who->guildid != ClientEntry->GuildID())
  6312. +               if (Who->guildid != ClientEntry->GuildID())
  6313.                     continue;
  6314.             }
  6315. -
  6316. -           if(WhomLength && strncasecmp(Who->whom, ClientEntry->GetName(), WhomLength) &&
  6317. +           if (WhomLength && strncasecmp(Who->whom, ClientEntry->GetName(), WhomLength) &&
  6318.                     strncasecmp(guild_mgr.GetGuildName(ClientEntry->GuildID()), Who->whom, WhomLength))
  6319.                 continue;
  6320. -
  6321.             std::string GuildName;
  6322. -
  6323. -           if((ClientEntry->GuildID() != GUILD_NONE) && (ClientEntry->GuildID() > 0)) {
  6324. -
  6325. +           if ((ClientEntry->GuildID() != GUILD_NONE) && (ClientEntry->GuildID() > 0)) {
  6326.                 GuildName = "<";
  6327. -
  6328.                 GuildName += guild_mgr.GetGuildName(ClientEntry->GuildID());
  6329. -
  6330.                 GuildName += ">";
  6331.             }
  6332. -
  6333. -           uint32 FormatMSGID=5025; // 5025 %T1[%2 %3] %4 (%5) %6 %7 %8 %9
  6334. -
  6335. -           if(ClientEntry->GetAnon() == 1)
  6336. +           uint32 FormatMSGID = 5025; // 5025 %T1[%2 %3] %4 (%5) %6 %7 %8 %9
  6337. +           if (ClientEntry->GetAnon() == 1)
  6338.                 FormatMSGID = 5024; // 5024 %T1[ANONYMOUS] %2 %3
  6339. -           else if(ClientEntry->GetAnon() == 2)
  6340. +           else if (ClientEntry->GetAnon() == 2)
  6341.                 FormatMSGID = 5023; // 5023 %T1[ANONYMOUS] %2 %3 %4
  6342. -
  6343.             uint32 PlayerClass = 0;
  6344. -
  6345.             uint32 PlayerLevel = 0;
  6346. -
  6347.             uint32 PlayerRace = 0;
  6348. -
  6349.             uint32 ZoneMSGID = 0xFFFFFFFF;
  6350.  
  6351. -           if(ClientEntry->GetAnon()==0) {
  6352. -
  6353. +           if (ClientEntry->GetAnon()==0) {
  6354.                 PlayerClass = ClientEntry->GetClass();
  6355. -
  6356.                 PlayerLevel = ClientEntry->GetLevel();
  6357. -
  6358.                 PlayerRace = ClientEntry->GetRace();
  6359.             }
  6360.  
  6361.             WhoAllPlayerPart1* WAPP1 = (WhoAllPlayerPart1*)Buffer;
  6362. -
  6363.             WAPP1->FormatMSGID = FormatMSGID;
  6364. -
  6365.             WAPP1->PIDMSGID = 0xFFFFFFFF;
  6366. -
  6367.             strcpy(WAPP1->Name, ClientEntry->GetName());
  6368. -
  6369.             Buffer += sizeof(WhoAllPlayerPart1) + strlen(WAPP1->Name);
  6370. -
  6371.             WhoAllPlayerPart2* WAPP2 = (WhoAllPlayerPart2*)Buffer;
  6372.  
  6373. -           if(ClientEntry->IsTrader())
  6374. +           if (ClientEntry->IsTrader())
  6375.                 WAPP2->RankMSGID = 12315;
  6376. -           else if(ClientEntry->IsBuyer())
  6377. +           else if (ClientEntry->IsBuyer())
  6378.                 WAPP2->RankMSGID = 6056;
  6379. -           else if(ClientEntry->Admin() >= 10)
  6380. +           else if (ClientEntry->Admin() >= 10)
  6381.                 WAPP2->RankMSGID = 12312;
  6382.             else
  6383.                 WAPP2->RankMSGID = 0xFFFFFFFF;
  6384.  
  6385.             strcpy(WAPP2->Guild, GuildName.c_str());
  6386. -
  6387.             Buffer += sizeof(WhoAllPlayerPart2) + strlen(WAPP2->Guild);
  6388. -
  6389.             WhoAllPlayerPart3* WAPP3 = (WhoAllPlayerPart3*)Buffer;
  6390. -
  6391.             WAPP3->Unknown80[0] = 0xFFFFFFFF;
  6392.  
  6393. -           if(ClientEntry->IsLD())
  6394. +           if (ClientEntry->IsLD())
  6395.                 WAPP3->Unknown80[1] = 12313; // LinkDead
  6396.             else
  6397.                 WAPP3->Unknown80[1] = 0xFFFFFFFF;
  6398.  
  6399.             WAPP3->ZoneMSGID = ZoneMSGID;
  6400. -
  6401.             WAPP3->Zone = 0;
  6402. -
  6403.             WAPP3->Class_ = PlayerClass;
  6404. -
  6405.             WAPP3->Level = PlayerLevel;
  6406. -
  6407.             WAPP3->Race = PlayerRace;
  6408. -
  6409.             WAPP3->Account[0] = 0;
  6410. -
  6411.             Buffer += sizeof(WhoAllPlayerPart3);
  6412. -
  6413.             WhoAllPlayerPart4* WAPP4 = (WhoAllPlayerPart4*)Buffer;
  6414. -
  6415.             WAPP4->Unknown100 = 0;
  6416. -
  6417.             Buffer += sizeof(WhoAllPlayerPart4);
  6418.         }
  6419.  
  6420. @@ -4571,184 +4029,123 @@ void EntityList::UnMarkNPC(uint16 ID)
  6421.     // each group to remove the dead mobs entity ID from the groups list of NPCs marked via the
  6422.     // Group Leadership AA Mark NPC ability.
  6423.     //
  6424. -   LinkedListIterator<Client*> iterator(client_list);
  6425. -
  6426. -   iterator.Reset();
  6427. -
  6428. -   while(iterator.MoreElements())
  6429. -   {
  6430. -       if(iterator.GetData())
  6431. -       {
  6432. +   auto it = client_list.begin();
  6433. +   while (it != client_list.end()) {
  6434. +       if (it->second) {
  6435.             Group *g = nullptr;
  6436. +           g = it->second->GetGroup();
  6437.  
  6438. -           g = iterator.GetData()->GetGroup();
  6439. -
  6440. -           if(g)
  6441. +           if (g)
  6442.                 g->UnMarkNPC(ID);
  6443.         }
  6444. -       iterator.Advance();
  6445. +       ++it;
  6446.     }
  6447.  }
  6448.  
  6449.  uint32 EntityList::CheckNPCsClose(Mob *center)
  6450.  {
  6451. -   LinkedListIterator<NPC*> iterator(npc_list);
  6452.     uint32 count = 0;
  6453.  
  6454. -   iterator.Reset();
  6455. -   while(iterator.MoreElements())
  6456. -   {
  6457. -       NPC *current = iterator.GetData();
  6458. -       if(!current)
  6459. -       {
  6460. -           iterator.Advance();
  6461. -           continue;
  6462. -       }
  6463. -
  6464. -       if(current == center)
  6465. -       {
  6466. -           iterator.Advance();
  6467. -           continue;
  6468. -       }
  6469. -
  6470. -       if(current->IsPet())
  6471. -       {
  6472. -           iterator.Advance();
  6473. -           continue;
  6474. -       }
  6475. -
  6476. -       if(current->GetClass() == LDON_TREASURE)
  6477. -       {
  6478. -           iterator.Advance();
  6479. -           continue;
  6480. -       }
  6481. -
  6482. -       if(current->GetBodyType() == BT_NoTarget ||
  6483. -           current->GetBodyType() == BT_Special)
  6484. -       {
  6485. -           iterator.Advance();
  6486. +   auto it = npc_list.begin();
  6487. +   while (it != npc_list.end()) {
  6488. +       NPC *cur = it->second;
  6489. +       if (!cur || cur == center || cur->IsPet() || cur->GetClass() == LDON_TREASURE ||
  6490. +               cur->GetBodyType() == BT_NoTarget || cur->GetBodyType() == BT_Special) {
  6491. +           ++it;
  6492.             continue;
  6493.         }
  6494.  
  6495. -       float xDiff = current->GetX() - center->GetX();
  6496. -       float yDiff = current->GetY() - center->GetY();
  6497. -       float zDiff = current->GetZ() - center->GetZ();
  6498. +       float xDiff = cur->GetX() - center->GetX();
  6499. +       float yDiff = cur->GetY() - center->GetY();
  6500. +       float zDiff = cur->GetZ() - center->GetZ();
  6501.         float dist = ((xDiff * xDiff) + (yDiff * yDiff) + (zDiff * zDiff));
  6502.  
  6503. -       if(dist <= RuleR(Adventure, DistanceForRescueAccept))
  6504. -       {
  6505. +       if (dist <= RuleR(Adventure, DistanceForRescueAccept))
  6506.             count++;
  6507. -       }
  6508. -       iterator.Advance();
  6509. +       ++it;
  6510.     }
  6511.     return count;
  6512.  }
  6513.  
  6514.  void EntityList::GateAllClients()
  6515.  {
  6516. -   LinkedListIterator<Client*> iterator(client_list);
  6517. -   iterator.Reset();
  6518. -   while(iterator.MoreElements())
  6519. -   {
  6520. -       Client *c = iterator.GetData();
  6521. -       if(c)
  6522. -       {
  6523. +   auto it = client_list.begin();
  6524. +   while (it != client_list.end()) {
  6525. +       Client *c = it->second;
  6526. +       if (c)
  6527.             c->GoToBind();
  6528. -       }
  6529. -       iterator.Advance();
  6530. +       ++it;
  6531.     }
  6532.  }
  6533.  
  6534.  void EntityList::SignalAllClients(uint32 data)
  6535.  {
  6536. -   LinkedListIterator<Client*> iterator(client_list);
  6537. -   iterator.Reset();
  6538. -   while(iterator.MoreElements())
  6539. -   {
  6540. -       Client *ent = iterator.GetData();
  6541. -       if(ent)
  6542. -       {
  6543. +   auto it = client_list.begin();
  6544. +   while (it != client_list.end()) {
  6545. +       Client *ent = it->second;
  6546. +       if (ent)
  6547.             ent->Signal(data);
  6548. -       }
  6549. -       iterator.Advance();
  6550. +       ++it;
  6551.     }
  6552.  }
  6553.  
  6554. -void EntityList::GetMobList(std::list<Mob*> &m_list)
  6555. +void EntityList::GetMobList(std::list<Mob *> &m_list)
  6556.  {
  6557.     m_list.clear();
  6558. -   LinkedListIterator<Mob*> iterator(mob_list);
  6559. -   iterator.Reset();
  6560. -   while(iterator.MoreElements())
  6561. -   {
  6562. -       Mob *ent = iterator.GetData();
  6563. -       m_list.push_back(ent);
  6564. -       iterator.Advance();
  6565. +   auto it = mob_list.begin();
  6566. +   while (it != mob_list.end()) {
  6567. +       m_list.push_back(it->second);
  6568. +       ++it;
  6569.     }
  6570.  }
  6571.  
  6572. -void EntityList::GetNPCList(std::list<NPC*> &n_list)
  6573. +void EntityList::GetNPCList(std::list<NPC *> &n_list)
  6574.  {
  6575.     n_list.clear();
  6576. -   LinkedListIterator<NPC*> iterator(npc_list);
  6577. -   iterator.Reset();
  6578. -   while(iterator.MoreElements())
  6579. -   {
  6580. -       NPC *ent = iterator.GetData();
  6581. -       n_list.push_back(ent);
  6582. -       iterator.Advance();
  6583. +   auto it = npc_list.begin();
  6584. +   while (it != npc_list.end()) {
  6585. +       n_list.push_back(it->second);
  6586. +       ++it;
  6587.     }
  6588.  }
  6589.  
  6590. -void EntityList::GetClientList(std::list<Client*> &c_list)
  6591. +void EntityList::GetClientList(std::list<Client *> &c_list)
  6592.  {
  6593.     c_list.clear();
  6594. -   LinkedListIterator<Client*> iterator(client_list);
  6595. -   iterator.Reset();
  6596. -   while(iterator.MoreElements())
  6597. -   {
  6598. -       Client *ent = iterator.GetData();
  6599. -       c_list.push_back(ent);
  6600. -       iterator.Advance();
  6601. +   auto it = client_list.begin();
  6602. +   while (it != client_list.end()) {
  6603. +       c_list.push_back(it->second);
  6604. +       ++it;
  6605.     }
  6606.  }
  6607.  
  6608. -void EntityList::GetCorpseList(std::list<Corpse*> &c_list)
  6609. +void EntityList::GetCorpseList(std::list<Corpse *> &c_list)
  6610.  {
  6611.     c_list.clear();
  6612. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  6613. -   iterator.Reset();
  6614. -   while(iterator.MoreElements())
  6615. -   {
  6616. -       Corpse *ent = iterator.GetData();
  6617. -       c_list.push_back(ent);
  6618. -       iterator.Advance();
  6619. +   auto it = corpse_list.begin();
  6620. +   while (it != corpse_list.end()) {
  6621. +       c_list.push_back(it->second);
  6622. +       ++it;
  6623.     }
  6624.  }
  6625.  
  6626. -void EntityList::GetObjectList(std::list<Object*> &o_list)
  6627. +void EntityList::GetObjectList(std::list<Object *> &o_list)
  6628.  {
  6629.     o_list.clear();
  6630. -   LinkedListIterator<Object*> iterator(object_list);
  6631. -   iterator.Reset();
  6632. -   while(iterator.MoreElements())
  6633. -   {
  6634. -       Object *ent = iterator.GetData();
  6635. -       o_list.push_back(ent);
  6636. -       iterator.Advance();
  6637. +   auto it = object_list.begin();
  6638. +   while (it != object_list.end()) {
  6639. +       o_list.push_back(it->second);
  6640. +       ++it;
  6641.     }
  6642.  }
  6643.  
  6644.  void EntityList::GetDoorsList(std::list<Doors*> &o_list)
  6645.  {
  6646.     o_list.clear();
  6647. -   LinkedListIterator<Doors*> iterator(door_list);
  6648. -   iterator.Reset();
  6649. -   while(iterator.MoreElements())
  6650. -   {
  6651. -       Doors *ent = iterator.GetData();
  6652. -       o_list.push_back(ent);
  6653. -       iterator.Advance();
  6654. +   auto it = door_list.begin();
  6655. +   while (it != door_list.end()) {
  6656. +       o_list.push_back(it->second);
  6657. +       ++it;
  6658.     }
  6659.  }
  6660.  
  6661. @@ -4769,76 +4166,54 @@ void EntityList::GetSpawnList(std::list<Spawn2*> &o_list)
  6662.  
  6663.  void EntityList::UpdateQGlobal(uint32 qid, QGlobal newGlobal)
  6664.  {
  6665. -   LinkedListIterator<Mob*> iterator(mob_list);
  6666. -   iterator.Reset();
  6667. -   while(iterator.MoreElements())
  6668. -   {
  6669. -       Mob *ent = iterator.GetData();
  6670. +   auto it = mob_list.begin();
  6671. +   while (it != mob_list.end()) {
  6672. +       Mob *ent = it->second;
  6673.  
  6674. -       if(ent->IsClient())
  6675. -       {
  6676. +       if (ent->IsClient()) {
  6677.             QGlobalCache *qgc = ent->CastToClient()->GetQGlobals();
  6678. -           if(qgc)
  6679. -           {
  6680. +           if (qgc) {
  6681.                 uint32 char_id = ent->CastToClient()->CharacterID();
  6682. -               if(newGlobal.char_id == char_id && newGlobal.npc_id == 0)
  6683. -               {
  6684. +               if (newGlobal.char_id == char_id && newGlobal.npc_id == 0)
  6685.                     qgc->AddGlobal(qid, newGlobal);
  6686. -               }
  6687.             }
  6688. -       }
  6689. -       else if(ent->IsNPC())
  6690. -       {
  6691. +       } else if (ent->IsNPC()) {
  6692.             QGlobalCache *qgc = ent->CastToNPC()->GetQGlobals();
  6693. -           if(qgc)
  6694. -           {
  6695. +           if (qgc) {
  6696.                 uint32 npc_id = ent->GetNPCTypeID();
  6697. -               if(newGlobal.npc_id == npc_id)
  6698. -               {
  6699. +               if (newGlobal.npc_id == npc_id)
  6700.                     qgc->AddGlobal(qid, newGlobal);
  6701. -               }
  6702.             }
  6703.         }
  6704. -
  6705. -       iterator.Advance();
  6706. +       ++it;
  6707.     }
  6708.  }
  6709.  
  6710.  void EntityList::DeleteQGlobal(std::string name, uint32 npcID, uint32 charID, uint32 zoneID)
  6711.  {
  6712. -   LinkedListIterator<Mob*> iterator(mob_list);
  6713. -   iterator.Reset();
  6714. -   while(iterator.MoreElements())
  6715. -   {
  6716. -       Mob *ent = iterator.GetData();
  6717. +   auto it = mob_list.begin();
  6718. +   while (it != mob_list.end()) {
  6719. +       Mob *ent = it->second;
  6720.  
  6721. -       if(ent->IsClient())
  6722. -       {
  6723. +       if (ent->IsClient()) {
  6724.             QGlobalCache *qgc = ent->CastToClient()->GetQGlobals();
  6725. -           if(qgc)
  6726. -           {
  6727. +           if (qgc)
  6728.                 qgc->RemoveGlobal(name, npcID, charID, zoneID);
  6729. -           }
  6730. -       }
  6731. -       else if(ent->IsNPC())
  6732. -       {
  6733. +       } else if (ent->IsNPC()) {
  6734.             QGlobalCache *qgc = ent->CastToNPC()->GetQGlobals();
  6735. -           if(qgc)
  6736. -           {
  6737. +           if (qgc)
  6738.                 qgc->RemoveGlobal(name, npcID, charID, zoneID);
  6739. -           }
  6740.         }
  6741. -
  6742. -       iterator.Advance();
  6743. +       ++it;
  6744.     }
  6745.  }
  6746.  
  6747.  void EntityList::SendFindableNPCList(Client *c)
  6748.  {
  6749. -   if(!c)
  6750. +   if (!c)
  6751.         return;
  6752.  
  6753. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
  6754. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
  6755.  
  6756.     FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
  6757.  
  6758. @@ -4848,18 +4223,12 @@ void EntityList::SendFindableNPCList(Client *c)
  6759.  
  6760.     fnpcs->Action = 0;
  6761.  
  6762. +   auto it = npc_list.begin();
  6763. +   while (it != npc_list.end()) {
  6764. +       if (it->second) {
  6765. +           NPC *n = it->second;
  6766.  
  6767. -   LinkedListIterator<NPC*> iterator(npc_list);
  6768. -
  6769. -   iterator.Reset();
  6770. -   while(iterator.MoreElements())
  6771. -   {
  6772. -       if (iterator.GetData())
  6773. -       {
  6774. -           NPC *n = iterator.GetData();
  6775. -
  6776. -           if(n->IsFindable())
  6777. -           {
  6778. +           if (n->IsFindable()) {
  6779.                 fnpcs->EntityID = n->GetID();
  6780.                 strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
  6781.                 strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
  6782. @@ -4868,19 +4237,18 @@ void EntityList::SendFindableNPCList(Client *c)
  6783.  
  6784.                 c->QueuePacket(outapp);
  6785.             }
  6786. -
  6787.         }
  6788. -       iterator.Advance();
  6789. +       ++it;
  6790.     }
  6791.     safe_delete(outapp);
  6792.  }
  6793.  
  6794.  void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
  6795.  {
  6796. -   if(!n || !n->IsFindable())
  6797. +   if (!n || !n->IsFindable())
  6798.         return;
  6799.  
  6800. -   EQApplicationPacket* outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
  6801. +   EQApplicationPacket *outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
  6802.  
  6803.     FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
  6804.  
  6805. @@ -4889,28 +4257,19 @@ void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
  6806.     fnpcs->Unknown111 = 0x24;
  6807.  
  6808.     fnpcs->Action = Remove ? 1: 0;
  6809. -
  6810.     fnpcs->EntityID = n->GetID();
  6811. -
  6812.     strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
  6813. -
  6814.     strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
  6815. -
  6816.     fnpcs->Race = n->GetRace();
  6817. -
  6818.     fnpcs->Class = n->GetClass();
  6819.  
  6820. -   LinkedListIterator<Client*> iterator(client_list);
  6821. -
  6822. -   iterator.Reset();
  6823. -
  6824. -   while(iterator.MoreElements())
  6825. -   {
  6826. -       Client *c = iterator.GetData();
  6827. -       if(c && (c->GetClientVersion() >= EQClientSoD))
  6828. +   auto it = client_list.begin();
  6829. +   while (it != client_list.end()) {
  6830. +       Client *c = it->second;
  6831. +       if (c && (c->GetClientVersion() >= EQClientSoD))
  6832.             c->QueuePacket(outapp);
  6833.  
  6834. -       iterator.Advance();
  6835. +       ++it;
  6836.     }
  6837.  
  6838.     safe_delete(outapp);
  6839. @@ -4918,87 +4277,67 @@ void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
  6840.  
  6841.  void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode)
  6842.  {
  6843. -   if(!c)
  6844. +   if (!c)
  6845.         return;
  6846.  
  6847. -   if(NewMode == HideCorpseNone)
  6848. -   {
  6849. +   if (NewMode == HideCorpseNone) {
  6850.         SendZoneCorpses(c);
  6851.         return;
  6852.     }
  6853.  
  6854.     Group *g = nullptr;
  6855.  
  6856. -   if(NewMode == HideCorpseAllButGroup)
  6857. -   {
  6858. +   if (NewMode == HideCorpseAllButGroup) {
  6859.         g = c->GetGroup();
  6860.  
  6861. -       if(!g)
  6862. +       if (!g)
  6863.             NewMode = HideCorpseAll;
  6864.     }
  6865.  
  6866. -   LinkedListIterator<Corpse*> iterator(corpse_list);
  6867. -
  6868. -   iterator.Reset();
  6869. -
  6870. -   while(iterator.MoreElements())
  6871. -   {
  6872. -       Corpse *b = iterator.GetData();
  6873. +   auto it = corpse_list.begin();
  6874. +   while (it != corpse_list.end()) {
  6875. +       Corpse *b = it->second;
  6876.  
  6877. -       if(b && (b->GetCharID() != c->CharacterID()))
  6878. -       {
  6879. -           if((NewMode == HideCorpseAll) || ((NewMode == HideCorpseNPC) && (b->IsNPCCorpse())))
  6880. -           {
  6881. +       if (b && (b->GetCharID() != c->CharacterID())) {
  6882. +           if ((NewMode == HideCorpseAll) || ((NewMode == HideCorpseNPC) && (b->IsNPCCorpse()))) {
  6883.                 EQApplicationPacket outapp;
  6884.                     b->CreateDespawnPacket(&outapp, false);
  6885.                 c->QueuePacket(&outapp);
  6886. -           }
  6887. -           else if(NewMode == HideCorpseAllButGroup)
  6888. -           {
  6889. -               if(!g->IsGroupMember(b->GetOwnerName()))
  6890. -               {
  6891. +           } else if(NewMode == HideCorpseAllButGroup) {
  6892. +               if (!g->IsGroupMember(b->GetOwnerName())) {
  6893.                     EQApplicationPacket outapp;
  6894.                         b->CreateDespawnPacket(&outapp, false);
  6895.                     c->QueuePacket(&outapp);
  6896. -               }
  6897. -               else if((CurrentMode == HideCorpseAll))
  6898. -               {
  6899. +               } else if((CurrentMode == HideCorpseAll)) {
  6900.                     EQApplicationPacket outapp;
  6901.                         b->CreateSpawnPacket(&outapp);
  6902.                     c->QueuePacket(&outapp);
  6903.                 }
  6904.             }
  6905. -
  6906.         }
  6907. -       iterator.Advance();
  6908. +       ++it;
  6909.     }
  6910.  }
  6911.  
  6912.  void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
  6913.  {
  6914. -   if(count == 0)
  6915. +   if (count == 0)
  6916.         return;
  6917.  
  6918.     int npc_count = 0;
  6919. -   LinkedListIterator<NPC*> iterator(npc_list);
  6920. -   iterator.Reset();
  6921. -   while(iterator.MoreElements())
  6922. -   {
  6923. -       if(!iterator.GetData()->IsPet()
  6924. -           && iterator.GetData()->GetClass() != LDON_TREASURE
  6925. -           && iterator.GetData()->GetBodyType() != BT_NoTarget
  6926. -           && iterator.GetData()->GetBodyType() != BT_NoTarget2
  6927. -           && iterator.GetData()->GetBodyType() != BT_Special)
  6928. -       {
  6929. +   auto it = npc_list.begin();
  6930. +   while (it != npc_list.end()) {
  6931. +       if (!it->second->IsPet()
  6932. +               && it->second->GetClass() != LDON_TREASURE
  6933. +               && it->second->GetBodyType() != BT_NoTarget
  6934. +               && it->second->GetBodyType() != BT_NoTarget2
  6935. +               && it->second->GetBodyType() != BT_Special)
  6936.             npc_count++;
  6937. -       }
  6938. -       iterator.Advance();
  6939. +       ++it;
  6940.     }
  6941.  
  6942. -   if(npc_count == 0)
  6943. -   {
  6944. +   if (npc_count == 0)
  6945.         return;
  6946. -   }
  6947.  
  6948.     NPC **npcs = new NPC*[npc_count];
  6949.     int *counts = new int[npc_count];
  6950. @@ -5007,31 +4346,24 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
  6951.     memset(marked, 0, sizeof(bool) * npc_count);
  6952.  
  6953.     int i = 0;
  6954. -   iterator.Reset();
  6955. -   while(iterator.MoreElements())
  6956. -   {
  6957. -       if(!iterator.GetData()->IsPet()
  6958. -           && iterator.GetData()->GetClass() != LDON_TREASURE
  6959. -           && iterator.GetData()->GetBodyType() != BT_NoTarget
  6960. -           && iterator.GetData()->GetBodyType() != BT_NoTarget2
  6961. -           && iterator.GetData()->GetBodyType() != BT_Special)
  6962. -       {
  6963. -           npcs[i++] = iterator.GetData();
  6964. -       }
  6965. -       iterator.Advance();
  6966. -   }
  6967. -
  6968. -   while(count > 0)
  6969. -   {
  6970. +   it = npc_list.begin();
  6971. +   while (it != npc_list.end()) {
  6972. +       if (!it->second->IsPet()
  6973. +               && it->second->GetClass() != LDON_TREASURE
  6974. +               && it->second->GetBodyType() != BT_NoTarget
  6975. +               && it->second->GetBodyType() != BT_NoTarget2
  6976. +               && it->second->GetBodyType() != BT_Special)
  6977. +           npcs[i++] = it->second;
  6978. +       ++it;
  6979. +   }
  6980. +
  6981. +   while (count > 0) {
  6982.         std::vector<int> selection;
  6983.         selection.reserve(npc_count);
  6984. -       for(int j = 0; j < npc_count; ++j)
  6985. -       {
  6986. +       for (int j = 0; j < npc_count; ++j)
  6987.             selection.push_back(j);
  6988. -       }
  6989.  
  6990. -       while(selection.size() > 0 && count > 0)
  6991. -       {
  6992. +       while (selection.size() > 0 && count > 0) {
  6993.             int k = MakeRandomInt(0, selection.size() - 1);
  6994.             counts[selection[k]]++;
  6995.             count--;
  6996. @@ -5039,23 +4371,18 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
  6997.         }
  6998.     }
  6999.  
  7000. -   for(int j = 0; j < npc_count; ++j)
  7001. -   {
  7002. -       if(counts[j] > 0)
  7003. -       {
  7004. -           for(int k = 0; k < counts[j]; ++k)
  7005. -           {
  7006. +   for (int j = 0; j < npc_count; ++j)
  7007. +       if (counts[j] > 0)
  7008. +           for (int k = 0; k < counts[j]; ++k)
  7009.                 npcs[j]->AddItem(item_id, 1);
  7010. -           }
  7011. -       }
  7012. -   }
  7013.  
  7014.     safe_delete_array(npcs);
  7015.     safe_delete_array(counts);
  7016.     safe_delete_array(marked);
  7017.  }
  7018.  
  7019. -void EntityList::CameraEffect(uint32 duration, uint32 intensity) {
  7020. +void EntityList::CameraEffect(uint32 duration, uint32 intensity)
  7021. +{
  7022.     EQApplicationPacket* outapp = new EQApplicationPacket(OP_CameraEffect, sizeof(Camera_Struct));
  7023.     memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer));
  7024.     Camera_Struct* cs = (Camera_Struct*) outapp->pBuffer;
  7025. @@ -5066,29 +4393,25 @@ void EntityList::CameraEffect(uint32 duration, uint32 intensity) {
  7026.  }
  7027.  
  7028.  
  7029. -NPC* EntityList::GetClosestBanker(Mob* sender, uint32 &distance)
  7030. +NPC *EntityList::GetClosestBanker(Mob *sender, uint32 &distance)
  7031.  {
  7032. -   if(!sender)
  7033. +   if (!sender)
  7034.         return nullptr;
  7035.  
  7036.     distance = 4294967295u;
  7037. -   NPC* nc = nullptr;
  7038. -
  7039. -   LinkedListIterator<NPC*> iterator(npc_list);
  7040. -   iterator.Reset();
  7041. -
  7042. -   while(iterator.MoreElements())
  7043. -   {
  7044. -       if(iterator.GetData()->GetClass() == BANKER)
  7045. -       {
  7046. -           uint32 nd = ((iterator.GetData()->GetY() - sender->GetY()) * (iterator.GetData()->GetY() - sender->GetY())) +
  7047. -               ((iterator.GetData()->GetX() - sender->GetX()) * (iterator.GetData()->GetX() - sender->GetX()));
  7048. -           if(nd < distance){
  7049. +   NPC *nc = nullptr;
  7050. +
  7051. +   auto it = npc_list.begin();
  7052. +   while (it != npc_list.end()) {
  7053. +       if (it->second->GetClass() == BANKER) {
  7054. +           uint32 nd = ((it->second->GetY() - sender->GetY()) * (it->second->GetY() - sender->GetY())) +
  7055. +               ((it->second->GetX() - sender->GetX()) * (it->second->GetX() - sender->GetX()));
  7056. +           if (nd < distance){
  7057.                 distance = nd;
  7058. -               nc = iterator.GetData();
  7059. +               nc = it->second;
  7060.             }
  7061.         }
  7062. -       iterator.Advance();
  7063. +       ++it;
  7064.     }
  7065.     return nc;
  7066.  }
  7067. @@ -5099,48 +4422,37 @@ void EntityList::ExpeditionWarning(uint32 minutes_left)
  7068.     ExpeditionExpireWarning *ew = (ExpeditionExpireWarning*)outapp->pBuffer;
  7069.     ew->minutes_remaining = minutes_left;
  7070.  
  7071. -   LinkedListIterator<Client*> iterator(client_list);
  7072. -   iterator.Reset();
  7073. -   while(iterator.MoreElements())
  7074. -   {
  7075. -       iterator.GetData()->Message_StringID(15, EXPEDITION_MIN_REMAIN, itoa((int)minutes_left));
  7076. -       iterator.GetData()->QueuePacket(outapp);
  7077. -       iterator.Advance();
  7078. +   auto it = client_list.begin();
  7079. +   while (it != client_list.end()) {
  7080. +       it->second->Message_StringID(15, EXPEDITION_MIN_REMAIN, itoa((int)minutes_left));
  7081. +       it->second->QueuePacket(outapp);
  7082. +       ++it;
  7083.     }
  7084.  }
  7085.  
  7086. -Mob* EntityList::GetClosestMobByBodyType(Mob* sender, bodyType BodyType)
  7087. +Mob *EntityList::GetClosestMobByBodyType(Mob *sender, bodyType BodyType)
  7088.  {
  7089.  
  7090. -   if(!sender)
  7091. +   if (!sender)
  7092.         return nullptr;
  7093.  
  7094.     uint32 CurrentDistance, ClosestDistance = 4294967295u;
  7095. -
  7096.     Mob *CurrentMob, *ClosestMob = nullptr;
  7097.  
  7098. -   LinkedListIterator<Mob*> iterator(mob_list);
  7099. -
  7100. -   iterator.Reset();
  7101. -
  7102. -   while(iterator.MoreElements())
  7103. -   {
  7104. -       CurrentMob = iterator.GetData();
  7105. -
  7106. -       iterator.Advance();
  7107. +   auto it = mob_list.begin();
  7108. +   while (it != mob_list.end()) {
  7109. +       CurrentMob = it->second;
  7110. +       ++it;
  7111.  
  7112. -       if(CurrentMob->GetBodyType() != BodyType)
  7113. +       if (CurrentMob->GetBodyType() != BodyType)
  7114.             continue;
  7115.  
  7116.         CurrentDistance = ((CurrentMob->GetY() - sender->GetY()) * (CurrentMob->GetY() - sender->GetY())) +
  7117.                     ((CurrentMob->GetX() - sender->GetX()) * (CurrentMob->GetX() - sender->GetX()));
  7118.  
  7119. -       if(CurrentDistance < ClosestDistance)
  7120. -       {
  7121. +       if (CurrentDistance < ClosestDistance) {
  7122.             ClosestDistance = CurrentDistance;
  7123. -
  7124.             ClosestMob = CurrentMob;
  7125. -
  7126.         }
  7127.     }
  7128.     return ClosestMob;
  7129. @@ -5148,14 +4460,11 @@ Mob* EntityList::GetClosestMobByBodyType(Mob* sender, bodyType BodyType)
  7130.  
  7131.  void EntityList::GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, std::list<Mob*> &m_list)
  7132.  {
  7133. -   LinkedListIterator<Mob*> iterator(mob_list);
  7134. -   iterator.Reset();
  7135. -   while(iterator.MoreElements())
  7136. -   {
  7137. -       Mob *ptr = iterator.GetData();
  7138. -       if(ptr == start)
  7139. -       {
  7140. -           iterator.Advance();
  7141. +   auto it = mob_list.begin();
  7142. +   while (it !=  mob_list.end()) {
  7143. +       Mob *ptr = it->second;
  7144. +       if (ptr == start) {
  7145. +           ++it;
  7146.             continue;
  7147.         }
  7148.         int32 x_diff = ptr->GetX() - start->GetX();
  7149. @@ -5166,78 +4475,65 @@ void EntityList::GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height,
  7150.         y_diff *= y_diff;
  7151.         z_diff *= z_diff;
  7152.  
  7153. -       if((x_diff + y_diff) <= (radius * radius))
  7154. -       {
  7155. +       if ((x_diff + y_diff) <= (radius * radius))
  7156.             if(z_diff <= (height * height))
  7157. -           {
  7158.                 m_list.push_back(ptr);
  7159. -           }
  7160. -       }
  7161.  
  7162. -       iterator.Advance();
  7163. +       ++it;
  7164.     }
  7165.  }
  7166.  
  7167. -Client* EntityList::FindCorpseDragger(const char *CorpseName)
  7168. +Client *EntityList::FindCorpseDragger(const char *CorpseName)
  7169.  {
  7170. -   LinkedListIterator<Client*> iterator(client_list);
  7171. -
  7172. -   iterator.Reset();
  7173. -
  7174. -   while(iterator.MoreElements())
  7175. -   {
  7176. -       if (iterator.GetData()->IsDraggingCorpse(CorpseName))
  7177. -       {
  7178. -           return iterator.GetData();
  7179. -       }
  7180. -       iterator.Advance();
  7181. +   auto it = client_list.begin();
  7182. +   while (it != client_list.end()) {
  7183. +       if (it->second->IsDraggingCorpse(CorpseName))
  7184. +           return it->second;
  7185. +       ++it;
  7186.     }
  7187. -   return 0;
  7188. +   return nullptr;
  7189.  }
  7190.  
  7191. -Mob* EntityList::GetTargetForVirus(Mob* spreader)
  7192. +Mob *EntityList::GetTargetForVirus(Mob *spreader)
  7193.  {
  7194.     int max_spread_range = RuleI(Spells, VirusSpreadDistance);
  7195.  
  7196. -   std::vector<Mob*> TargetsInRange;
  7197. -   LinkedListIterator<Mob*> iterator(mob_list);
  7198. +   std::vector<Mob *> TargetsInRange;
  7199.  
  7200. -   iterator.Reset();
  7201. -   while(iterator.MoreElements())
  7202. -   {
  7203. +   auto it = mob_list.begin();
  7204. +   while (it != mob_list.end()) {
  7205.         // Make sure the target is in range, has los and is not the mob doing the spreading
  7206. -       if ((iterator.GetData()->GetID() != spreader->GetID()) &&
  7207. -           (iterator.GetData()->CalculateDistance(spreader->GetX(), spreader->GetY(), spreader->GetZ()) <= max_spread_range) &&
  7208. -           (spreader->CheckLosFN(iterator.GetData())))
  7209. -       {
  7210. +       if ((it->second->GetID() != spreader->GetID()) &&
  7211. +               (it->second->CalculateDistance(spreader->GetX(), spreader->GetY(),
  7212. +                   spreader->GetZ()) <= max_spread_range) &&
  7213. +               (spreader->CheckLosFN(it->second))) {
  7214.             // If the spreader is an npc it can only spread to other npc controlled mobs
  7215. -           if (spreader->IsNPC() && !spreader->IsPet() && iterator.GetData()->IsNPC()) {
  7216. -               TargetsInRange.push_back(iterator.GetData());
  7217. +           if (spreader->IsNPC() && !spreader->IsPet() && it->second->IsNPC()) {
  7218. +               TargetsInRange.push_back(it->second);
  7219.             }
  7220.             // If the spreader is an npc controlled pet it can spread to any other npc or an npc controlled pet
  7221.             else if (spreader->IsNPC() && spreader->IsPet() && spreader->GetOwner()->IsNPC()) {
  7222. -               if(iterator.GetData()->IsNPC() && !iterator.GetData()->IsPet()) {
  7223. -                   TargetsInRange.push_back(iterator.GetData());
  7224. -               }
  7225. -               else if(iterator.GetData()->IsNPC() && iterator.GetData()->IsPet() && iterator.GetData()->GetOwner()->IsNPC()) {
  7226. -                   TargetsInRange.push_back(iterator.GetData());
  7227. +               if (it->second->IsNPC() && !it->second->IsPet()) {
  7228. +                   TargetsInRange.push_back(it->second);
  7229. +               } else if (it->second->IsNPC() && it->second->IsPet() && it->second->GetOwner()->IsNPC()) {
  7230. +                   TargetsInRange.push_back(it->second);
  7231.                 }
  7232.             }
  7233.             // if the spreader is anything else(bot, pet, etc) then it should spread to everything but non client controlled npcs
  7234. -           else if(!spreader->IsNPC() && !iterator.GetData()->IsNPC()) {
  7235. -               TargetsInRange.push_back(iterator.GetData());
  7236. +           else if (!spreader->IsNPC() && !it->second->IsNPC()) {
  7237. +               TargetsInRange.push_back(it->second);
  7238.             }
  7239.             // if its a pet we need to determine appropriate targets(pet to client, pet to pet, pet to bot, etc)
  7240.             else if (spreader->IsNPC() && spreader->IsPet() && !spreader->GetOwner()->IsNPC()) {
  7241. -               if(!iterator.GetData()->IsNPC()) {
  7242. -                   TargetsInRange.push_back(iterator.GetData());
  7243. +               if (!it->second->IsNPC()) {
  7244. +                   TargetsInRange.push_back(it->second);
  7245.                 }
  7246. -               else if (iterator.GetData()->IsNPC() && iterator.GetData()->IsPet() && !iterator.GetData()->GetOwner()->IsNPC()) {
  7247. -                   TargetsInRange.push_back(iterator.GetData());
  7248. +               else if (it->second->IsNPC() && it->second->IsPet() && !it->second->GetOwner()->IsNPC()) {
  7249. +                   TargetsInRange.push_back(it->second);
  7250.                 }
  7251.             }
  7252.         }
  7253. -       iterator.Advance();
  7254. +       ++it;
  7255.     }
  7256.  
  7257.     if(TargetsInRange.size() == 0)
  7258. diff --git a/zone/entity.h b/zone/entity.h
  7259. index 0292543..361ea9f 100644
  7260. --- a/zone/entity.h
  7261. +++ b/zone/entity.h
  7262. @@ -75,25 +75,25 @@ public:
  7263.     virtual bool Save() { return true; }
  7264.     virtual void Depop(bool StartSpawnTimer = false) {}
  7265.  
  7266. -   Client* CastToClient();
  7267. -   NPC*    CastToNPC();
  7268. -   Mob*    CastToMob();
  7269. -   Merc*   CastToMerc();
  7270. -   Corpse* CastToCorpse();
  7271. -   Object* CastToObject();
  7272. -   Doors*  CastToDoors();
  7273. -   Trap*   CastToTrap();
  7274. -   Beacon* CastToBeacon();
  7275. -
  7276. -   const Client* CastToClient() const;
  7277. -   const NPC*      CastToNPC() const;
  7278. -   const Mob*      CastToMob() const;
  7279. -   const Merc*     CastToMerc() const;
  7280. -   const Corpse*   CastToCorpse() const;
  7281. -   const Object*   CastToObject() const;
  7282. -   const Doors*    CastToDoors() const;
  7283. -   const Trap*     CastToTrap() const;
  7284. -   const Beacon*   CastToBeacon() const;
  7285. +   Client  *CastToClient();
  7286. +   NPC     *CastToNPC();
  7287. +   Mob     *CastToMob();
  7288. +   Merc    *CastToMerc();
  7289. +   Corpse  *CastToCorpse();
  7290. +   Object  *CastToObject();
  7291. +   Doors   *CastToDoors();
  7292. +   Trap    *CastToTrap();
  7293. +   Beacon  *CastToBeacon();
  7294. +
  7295. +   const Client    *CastToClient() const;
  7296. +   const NPC       *CastToNPC() const;
  7297. +   const Mob       *CastToMob() const;
  7298. +   const Merc      *CastToMerc() const;
  7299. +   const Corpse    *CastToCorpse() const;
  7300. +   const Object    *CastToObject() const;
  7301. +   const Doors     *CastToDoors() const;
  7302. +   const Trap      *CastToTrap() const;
  7303. +   const Beacon    *CastToBeacon() const;
  7304.  
  7305.     inline const uint16& GetID() const { return id; }
  7306.  
  7307. @@ -108,7 +108,7 @@ public:
  7308.  
  7309.  protected:
  7310.     friend class EntityList;
  7311. -   virtual void SetID(uint16 set_id);
  7312. +   inline virtual void SetID(uint16 set_id) { id = set_id; }
  7313.     uint32 pDBAsyncWorkID;
  7314.  private:
  7315.     uint16 id;
  7316. @@ -134,9 +134,11 @@ public:
  7317.     Mob*    GetMob(const char* name);
  7318.     Mob*    GetMobByNpcTypeID(uint32 get_id);
  7319.     Mob*    GetTargetForVirus(Mob* spreader);
  7320. -   NPC*    GetNPCByID(uint16 id);
  7321. +   inline NPC *GetNPCByID(uint16 id)
  7322. +       { return npc_list.count(id) ? npc_list.at(id) : nullptr; }
  7323.     NPC*    GetNPCByNPCTypeID(uint32 npc_id);
  7324. -   Merc*   GetMercByID(uint16 id);
  7325. +   inline Merc *GetMercByID(uint16 id)
  7326. +       { return merc_list.count(id) ? merc_list.at(id) : nullptr; }
  7327.     Client* GetClientByName(const char *name);
  7328.     Client* GetClientByAccID(uint32 accid);
  7329.     Client* GetClientByID(uint16 id);
  7330. @@ -155,7 +157,8 @@ public:
  7331.  
  7332.     Corpse* GetCorpseByOwner(Client* client);
  7333.     Corpse* GetCorpseByOwnerWithinRange(Client* client, Mob* center, int range);
  7334. -   Corpse* GetCorpseByID(uint16 id);
  7335. +   inline Corpse *GetCorpseByID(uint16 id)
  7336. +       { return corpse_list.count(id) ? corpse_list.at(id) : nullptr; }
  7337.     Corpse* GetCorpseByDBID(uint32 dbid);
  7338.     Corpse* GetCorpseByName(const char* name);
  7339.  
  7340. @@ -163,7 +166,7 @@ public:
  7341.  
  7342.     Client* FindCorpseDragger(const char *CorpseName);
  7343.  
  7344. -   Object* GetObjectByID(uint16 id);
  7345. +   Object *GetObjectByID(uint16 id);
  7346.     Object* GetObjectByDBID(uint32 id);
  7347.     Doors*  GetDoorsByID(uint16 id);
  7348.     Doors* GetDoorsByDoorID(uint32 id);
  7349. @@ -195,8 +198,10 @@ public:
  7350.     void    ClearAreas();
  7351.     void    ProcessProximitySay(const char *Message, Client *c, uint8 language = 0);
  7352.     void    SendAATimer(uint32 charid,UseAA_Struct* uaa);
  7353. -   Doors*  FindDoor(uint8 door_id);
  7354. -   Object* FindObject(uint32 object_id);
  7355. +   inline Doors *FindDoor(uint16 id)
  7356. +       { return door_list.count(id) ? door_list.at(id) : nullptr; }
  7357. +   inline Object *FindObject(uint16 id)
  7358. +       { return object_list.count(id) ? object_list.at(id) : nullptr; }
  7359.     Object* FindNearbyObject(float x, float y, float z, float radius);
  7360.     bool    MakeDoorSpawnPacket(EQApplicationPacket* app, Client *client);
  7361.     bool    MakeTrackPacket(Client* client);
  7362. @@ -242,15 +247,15 @@ public:
  7363.     void    RemoveAllLocalities();
  7364.     void    RemoveAllRaids();
  7365.     void    DestroyTempPets(Mob *owner);
  7366. -   Entity* GetEntityMob(uint16 id);
  7367. -   Entity* GetEntityMob(const char *name);
  7368. -   Entity* GetEntityMerc(uint16 id);
  7369. -   Entity* GetEntityDoor(uint16 id);
  7370. -   Entity* GetEntityObject(uint16 id);
  7371. -   Entity* GetEntityCorpse(uint16 id);
  7372. -   Entity* GetEntityCorpse(const char *name);
  7373. -   Entity* GetEntityTrap(uint16 id);
  7374. -   Entity* GetEntityBeacon(uint16 id);
  7375. +   Entity *GetEntityMob(uint16 id);
  7376. +   Entity *GetEntityMerc(uint16 id);
  7377. +   Entity *GetEntityDoor(uint16 id);
  7378. +   Entity *GetEntityObject(uint16 id);
  7379. +   Entity *GetEntityCorpse(uint16 id);
  7380. +   Entity *GetEntityTrap(uint16 id);
  7381. +   Entity *GetEntityBeacon(uint16 id);
  7382. +   Entity *GetEntityMob(const char *name);
  7383. +   Entity *GetEntityCorpse(const char *name);
  7384.  
  7385.     void DescribeAggro(Client *towho, NPC *from_who, float dist, bool verbose);
  7386.  
  7387. @@ -419,17 +424,17 @@ private:
  7388.     uint32  NumSpawnsOnQueue;
  7389.     LinkedList<NewSpawn_Struct*> SpawnQueue;
  7390.  
  7391. -   LinkedList<Client*> client_list;
  7392. -   LinkedList<Mob*> mob_list;
  7393. -   LinkedList<NPC*> npc_list;
  7394. -   LinkedList<Merc *> merc_list;
  7395. -   std::list<Group*> group_list;
  7396. -   LinkedList<Corpse*> corpse_list;
  7397. -   LinkedList<Object*> object_list;
  7398. -   LinkedList<Doors*> door_list;
  7399. -   LinkedList<Trap*> trap_list;
  7400. -   LinkedList<Beacon*> beacon_list;
  7401. -   std::list<NPC*> proximity_list;
  7402. +   std::map<uint16, Client *> client_list;
  7403. +   std::map<uint16, Mob *> mob_list;
  7404. +   std::map<uint16, NPC *> npc_list;
  7405. +   std::map<uint16, Merc *> merc_list;
  7406. +   std::map<uint16, Corpse *> corpse_list;
  7407. +   std::map<uint16, Object *> object_list;
  7408. +   std::map<uint16, Doors *> door_list;
  7409. +   std::map<uint16, Trap *> trap_list;
  7410. +   std::map<uint16, Beacon *> beacon_list;
  7411. +   std::list<NPC *> proximity_list;
  7412. +   std::list<Group *> group_list;
  7413.     std::list<Raid *> raid_list;
  7414.     std::list<Area> area_list;
  7415.     uint16 last_insert_id;
  7416. diff --git a/zone/guild.cpp b/zone/guild.cpp
  7417. index 8d041a3..66ff494 100644
  7418. --- a/zone/guild.cpp
  7419. +++ b/zone/guild.cpp
  7420. @@ -230,44 +230,41 @@ void Client::RefreshGuildInfo()
  7421.  void EntityList::SendGuildMOTD(uint32 guild_id) {
  7422.     if(guild_id == GUILD_NONE)
  7423.         return;
  7424. -   LinkedListIterator<Client*> iterator(client_list);
  7425. -   iterator.Reset();
  7426. -   while(iterator.MoreElements()) {
  7427. -       Client* client = iterator.GetData();
  7428. +   auto it = client_list.begin();
  7429. +   while (it != client_list.end()) {
  7430. +       Client *client = it->second;
  7431.         if (client->GuildID() == guild_id) {
  7432.             client->SendGuildMOTD();
  7433.             client->SendGuildURL();
  7434.             client->SendGuildChannel();
  7435.         }
  7436. -       iterator.Advance();
  7437. +       ++it;
  7438.     }
  7439.  }
  7440.  
  7441.  void EntityList::SendGuildSpawnAppearance(uint32 guild_id) {
  7442.     if(guild_id == GUILD_NONE)
  7443.         return;
  7444. -   LinkedListIterator<Client*> iterator(client_list);
  7445. -   iterator.Reset();
  7446. -   while(iterator.MoreElements()) {
  7447. -       Client* client = iterator.GetData();
  7448. +   auto it = client_list.begin();
  7449. +   while (it != client_list.end()) {
  7450. +       Client *client = it->second;
  7451.         if (client->GuildID() == guild_id) {
  7452.             client->SendGuildSpawnAppearance();
  7453.         }
  7454. -       iterator.Advance();
  7455. +       ++it;
  7456.     }
  7457.  }
  7458.  
  7459.  void EntityList::RefreshAllGuildInfo(uint32 guild_id) {
  7460.     if(guild_id == GUILD_NONE)
  7461.         return;
  7462. -   LinkedListIterator<Client*> iterator(client_list);
  7463. -   iterator.Reset();
  7464. -   while(iterator.MoreElements()) {
  7465. -       Client* client = iterator.GetData();
  7466. +   auto it = client_list.begin();
  7467. +   while (it != client_list.end()) {
  7468. +       Client *client = it->second;
  7469.         if (client->GuildID() == guild_id) {
  7470.             client->RefreshGuildInfo();
  7471.         }
  7472. -       iterator.Advance();
  7473. +       ++it;
  7474.     }
  7475.  }
  7476.  
  7477. @@ -278,24 +275,22 @@ void EntityList::SendGuildMembers(uint32 guild_id) {
  7478.     //this could be optimized a bit to only build the member's packet once
  7479.     //and then keep swapping out the name in the packet on each send.
  7480.  
  7481. -   LinkedListIterator<Client*> iterator(client_list);
  7482. -   iterator.Reset();
  7483. -   while(iterator.MoreElements()) {
  7484. -       Client* client = iterator.GetData();
  7485. +   auto it = client_list.begin();
  7486. +   while (it != client_list.end()) {
  7487. +       Client *client = it->second;
  7488.         if (client->GuildID() == guild_id) {
  7489.             client->SendGuildMembers();
  7490.         }
  7491. -       iterator.Advance();
  7492. +       ++it;
  7493.     }
  7494.  }
  7495.  
  7496.  void EntityList::SendGuildList() {
  7497. -   LinkedListIterator<Client*> iterator(client_list);
  7498. -   iterator.Reset();
  7499. -   while(iterator.MoreElements()) {
  7500. -       Client* client = iterator.GetData();
  7501. +   auto it = client_list.begin();
  7502. +   while (it != client_list.end()) {
  7503. +       Client *client = it->second;
  7504.         client->SendGuildList();
  7505. -       iterator.Advance();
  7506. +       ++it;
  7507.     }
  7508.  }
  7509.  
  7510. diff --git a/zone/trap.cpp b/zone/trap.cpp
  7511. index 8d3b601..2ab431c 100644
  7512. --- a/zone/trap.cpp
  7513. +++ b/zone/trap.cpp
  7514. @@ -203,16 +203,14 @@ void Trap::Trigger(Mob* trigger)
  7515.  }
  7516.  
  7517.  Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) {
  7518. -   LinkedListIterator<Trap*> iterator(trap_list);
  7519. -   iterator.Reset();
  7520.     float dist = 999999;
  7521.     Trap* current_trap = nullptr;
  7522.  
  7523.     float max_dist2 = max_dist*max_dist;
  7524.     Trap *cur;
  7525. -   while(iterator.MoreElements())
  7526. -   {
  7527. -       cur = iterator.GetData();
  7528. +   auto it = trap_list.begin();
  7529. +   while (it != trap_list.end()) {
  7530. +       cur = it->second;
  7531.         if(!cur->disarmed) {
  7532.             float curdist = 0;
  7533.             float tmp = searcher->GetX() - cur->x;
  7534. @@ -228,23 +226,21 @@ Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) {
  7535.                 current_trap = cur;
  7536.             }
  7537.         }
  7538. -       iterator.Advance();
  7539. +       ++it;
  7540.     }
  7541.     return current_trap;
  7542.  }
  7543.  
  7544.  Mob* EntityList::GetTrapTrigger(Trap* trap) {
  7545. -   LinkedListIterator<Client*> iterator(client_list);
  7546. -
  7547.     Mob* savemob = 0;
  7548. -   iterator.Reset();
  7549.  
  7550.     float xdiff, ydiff, zdiff;
  7551.  
  7552.     float maxdist = trap->radius * trap->radius;
  7553.  
  7554. -   while(iterator.MoreElements()) {
  7555. -       Client* cur = iterator.GetData();
  7556. +   auto it = client_list.begin();
  7557. +   while (it != client_list.end()) {
  7558. +       Client* cur = it->second;
  7559.         zdiff = cur->GetZ() - trap->z;
  7560.         if(zdiff < 0)
  7561.             zdiff = 0 - zdiff;
  7562. @@ -259,7 +255,7 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
  7563.             else
  7564.                 savemob = cur;
  7565.         }
  7566. -       iterator.Advance();
  7567. +       ++it;
  7568.     }
  7569.     return savemob;
  7570.  }
Advertisement
Add Comment
Please, Sign In to add comment