(Performance) Corpse drag will now fetch entity by ID

This commit is contained in:
Michael Cook (mackal) 2014-02-20 01:35:59 -05:00
parent 754d70d513
commit 808977f69a
5 changed files with 21 additions and 20 deletions

View File

@ -6045,11 +6045,10 @@ void Client::NPCSpawn(NPC *target_npc, const char *identifier, uint32 extra)
} }
} }
bool Client::IsDraggingCorpse(const char *CorpseName) bool Client::IsDraggingCorpse(uint16 CorpseID)
{ {
for(std::list<std::string>::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) for (auto It = DraggedCorpses.begin(); It != DraggedCorpses.end(); ++It) {
{ if (It->second == CorpseID)
if(!strcasecmp((*Iterator).c_str(), CorpseName))
return true; return true;
} }
@ -6058,20 +6057,22 @@ bool Client::IsDraggingCorpse(const char *CorpseName)
void Client::DragCorpses() void Client::DragCorpses()
{ {
for(std::list<std::string>::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) for (auto It = DraggedCorpses.begin(); It != DraggedCorpses.end(); ++It) {
{ Mob *corpse = entity_list.GetMob(It->second);
Mob* corpse = entity_list.GetMob((*Iterator).c_str());
if(corpse && corpse->IsPlayerCorpse() && (DistNoRootNoZ(*corpse) <= RuleR(Character, DragCorpseDistance))) if (corpse && corpse->IsPlayerCorpse() &&
(DistNoRootNoZ(*corpse) <= RuleR(Character, DragCorpseDistance)))
continue; continue;
if(!corpse || !corpse->IsPlayerCorpse() || corpse->CastToCorpse()->IsBeingLooted() || !corpse->CastToCorpse()->Summon(this, false, false)) if (!corpse || !corpse->IsPlayerCorpse() ||
{ corpse->CastToCorpse()->IsBeingLooted() ||
!corpse->CastToCorpse()->Summon(this, false, false)) {
Message_StringID(MT_DefaultText, CORPSEDRAG_STOP); Message_StringID(MT_DefaultText, CORPSEDRAG_STOP);
Iterator = DraggedCorpses.erase(Iterator); It = DraggedCorpses.erase(It);
} }
} }
} }
void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_override, int pet_count, int pet_duration) void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_override, int pet_count, int pet_duration)
{ {
if(!target || !IsValidSpell(spell_id) || this->GetID() == target->GetID()) if(!target || !IsValidSpell(spell_id) || this->GetID() == target->GetID())

View File

@ -1078,7 +1078,7 @@ public:
void ClearHover(); void ClearHover();
inline bool IsBlockedBuff(int16 SpellID) { return PlayerBlockedBuffs.find(SpellID) != PlayerBlockedBuffs.end(); } inline bool IsBlockedBuff(int16 SpellID) { return PlayerBlockedBuffs.find(SpellID) != PlayerBlockedBuffs.end(); }
inline bool IsBlockedPetBuff(int16 SpellID) { return PetBlockedBuffs.find(SpellID) != PetBlockedBuffs.end(); } inline bool IsBlockedPetBuff(int16 SpellID) { return PetBlockedBuffs.find(SpellID) != PetBlockedBuffs.end(); }
bool IsDraggingCorpse(const char* CorpseName); bool IsDraggingCorpse(uint16 CorpseID);
inline bool IsDraggingCorpse() { return (DraggedCorpses.size() > 0); } inline bool IsDraggingCorpse() { return (DraggedCorpses.size() > 0); }
void DragCorpses(); void DragCorpses();
inline void ClearDraggedCorpses() { DraggedCorpses.clear(); } inline void ClearDraggedCorpses() { DraggedCorpses.clear(); }
@ -1481,7 +1481,7 @@ private:
std::set<uint32> PlayerBlockedBuffs; std::set<uint32> PlayerBlockedBuffs;
std::set<uint32> PetBlockedBuffs; std::set<uint32> PetBlockedBuffs;
std::list<std::string> DraggedCorpses; std::list<std::pair<std::string, uint16> > DraggedCorpses;
uint8 MaxXTargets; uint8 MaxXTargets;
bool XTargetAutoAddHaters; bool XTargetAutoAddHaters;

View File

@ -12379,7 +12379,7 @@ void Client::Handle_OP_CorpseDrag(const EQApplicationPacket *app)
if(!corpse || !corpse->IsPlayerCorpse() || corpse->CastToCorpse()->IsBeingLooted()) if(!corpse || !corpse->IsPlayerCorpse() || corpse->CastToCorpse()->IsBeingLooted())
return; return;
Client *c = entity_list.FindCorpseDragger(cds->CorpseName); Client *c = entity_list.FindCorpseDragger(corpse->GetID());
if(c) if(c)
{ {
@ -12394,7 +12394,7 @@ void Client::Handle_OP_CorpseDrag(const EQApplicationPacket *app)
if(!corpse->CastToCorpse()->Summon(this, false, true)) if(!corpse->CastToCorpse()->Summon(this, false, true))
return; return;
DraggedCorpses.push_back(cds->CorpseName); DraggedCorpses.push_back(std::pair<std::string, uint16>(cds->CorpseName, corpse->GetID()));
Message_StringID(MT_DefaultText, CORPSEDRAG_BEGIN, cds->CorpseName); Message_StringID(MT_DefaultText, CORPSEDRAG_BEGIN, cds->CorpseName);
} }
@ -12408,9 +12408,9 @@ void Client::Handle_OP_CorpseDrop(const EQApplicationPacket *app)
return; return;
} }
for(std::list<std::string>::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) for (auto Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator)
{ {
if(!strcasecmp((*Iterator).c_str(), (const char *)app->pBuffer)) if(!strcasecmp(Iterator->first.c_str(), (const char *)app->pBuffer))
{ {
Message_StringID(MT_DefaultText, CORPSEDRAG_STOP); Message_StringID(MT_DefaultText, CORPSEDRAG_STOP);
Iterator = DraggedCorpses.erase(Iterator); Iterator = DraggedCorpses.erase(Iterator);

View File

@ -4512,11 +4512,11 @@ void EntityList::GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height,
} }
} }
Client *EntityList::FindCorpseDragger(const char *CorpseName) Client *EntityList::FindCorpseDragger(uint16 CorpseID)
{ {
auto it = client_list.begin(); auto it = client_list.begin();
while (it != client_list.end()) { while (it != client_list.end()) {
if (it->second->IsDraggingCorpse(CorpseName)) if (it->second->IsDraggingCorpse(CorpseID))
return it->second; return it->second;
++it; ++it;
} }

View File

@ -167,7 +167,7 @@ public:
Spawn2* GetSpawnByID(uint32 id); Spawn2* GetSpawnByID(uint32 id);
Client* FindCorpseDragger(const char *CorpseName); Client* FindCorpseDragger(uint16 CorpseID);
inline Object *GetObjectByID(uint16 id) inline Object *GetObjectByID(uint16 id)
{ return object_list.count(id) ? object_list.at(id) : nullptr; } { return object_list.count(id) ? object_list.at(id) : nullptr; }