From f97693f8e1b817fcf700b442103d5a8a6f22cfd6 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 19 Jul 2017 14:52:04 -0400 Subject: [PATCH] Work on spawn filtering --- zone/client.h | 1 + zone/entity.cpp | 18 +++++++----------- zone/mob.h | 1 + 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/zone/client.h b/zone/client.h index 640d9dc98..952c98333 100644 --- a/zone/client.h +++ b/zone/client.h @@ -299,6 +299,7 @@ public: const char* GetBuyerWelcomeMessage() { return BuyerWelcomeMessage.c_str(); } void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho); + bool ShouldISpawnFor(Client *c) { return !GMHideMe(c) && !IsHoveringForRespawn(); } virtual bool Process(); void LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32 price, const EQEmu::ItemData* item, bool buying); void SendPacketQueue(bool Block = true); diff --git a/zone/entity.cpp b/zone/entity.cpp index e9d8139a7..344e79a04 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1246,12 +1246,9 @@ void EntityList::SendZoneSpawns(Client *client) auto it = mob_list.begin(); while (it != mob_list.end()) { Mob *ent = it->second; - if (!(ent->InZone()) || (ent->IsClient())) { - if (ent->CastToClient()->GMHideMe(client) || - ent->CastToClient()->IsHoveringForRespawn()) { - ++it; - continue; - } + if (!ent->InZone() || !ent->ShouldISpawnFor(client)) { + ++it; + continue; } app = new EQApplicationPacket; @@ -1279,17 +1276,16 @@ void EntityList::SendZoneSpawnsBulk(Client *client) for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { spawn = it->second; if (spawn && spawn->GetID() > 0 && spawn->Spawned()) { - if (spawn->IsClient() && (spawn->CastToClient()->GMHideMe(client) || - spawn->CastToClient()->IsHoveringForRespawn())) + if (!spawn->ShouldISpawnFor(client)) continue; #if 1 const glm::vec4& spos = spawn->GetPosition(); - + delaypkt = false; if (DistanceSquared(cpos, spos) > dmax || (spawn->IsClient() && (spawn->GetRace() == MINOR_ILL_OBJ || spawn->GetRace() == TREE))) delaypkt = true; - + if (delaypkt) { app = new EQApplicationPacket; spawn->CreateSpawnPacket(app); @@ -2659,7 +2655,7 @@ void EntityList::SendPositionUpdates(Client *client, uint32 cLastUpdate, float u mob && !mob->IsCorpse() && (it->second != client) && (mob->IsClient() || iSendEvenIfNotChanged || (mob->LastChange() >= cLastUpdate)) - && (!it->second->IsClient() || !it->second->CastToClient()->GMHideMe(client)) + && (it->second->ShouldISpawnFor(client)) ) { if ( update_range == 0 diff --git a/zone/mob.h b/zone/mob.h index 4fcc81b5a..0b683ede0 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -549,6 +549,7 @@ public: void SendPosition(); void SetSpawned() { spawned = true; }; bool Spawned() { return spawned; }; + virtual bool ShouldISpawnFor(Client *c) { return true; } void SetFlyMode(uint8 flymode); inline void Teleport(glm::vec3 NewPosition) { m_Position.x = NewPosition.x; m_Position.y = NewPosition.y; m_Position.z = NewPosition.z; };