mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Fix playersInView miscount for dead mobs
This commit is contained in:
parent
fd965fbf03
commit
48fb510b53
@ -92,6 +92,12 @@ void Chunking::addEntityToChunks(std::set<Chunk*> chnks, const EntityRef& ref) {
|
||||
if (ref.type == EntityType::PLAYER && other->isAlive()) {
|
||||
other->enterIntoViewOf(ref.sock);
|
||||
}
|
||||
|
||||
// for mobs, increment playersInView
|
||||
if (ref.type == EntityType::MOB && otherRef.type == EntityType::PLAYER)
|
||||
((Mob*)ent)->playersInView++;
|
||||
if (otherRef.type == EntityType::MOB && ref.type == EntityType::PLAYER)
|
||||
((Mob*)other)->playersInView++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,6 +124,12 @@ void Chunking::removeEntityFromChunks(std::set<Chunk*> chnks, const EntityRef& r
|
||||
if (ref.type == EntityType::PLAYER && other->isAlive()) {
|
||||
other->disappearFromViewOf(ref.sock);
|
||||
}
|
||||
|
||||
// for mobs, decrement playersInView
|
||||
if (ref.type == EntityType::MOB && otherRef.type == EntityType::PLAYER)
|
||||
((Mob*)ent)->playersInView--;
|
||||
if (otherRef.type == EntityType::MOB && ref.type == EntityType::PLAYER)
|
||||
((Mob*)other)->playersInView--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,6 @@ void BaseNPC::enterIntoViewOf(CNSocket *sock) {
|
||||
sock->sendPacket(pkt, P_FE2CL_NPC_ENTER);
|
||||
}
|
||||
|
||||
void Mob::enterIntoViewOf(CNSocket *sock) {
|
||||
this->BaseNPC::enterIntoViewOf(sock);
|
||||
playersInView++;
|
||||
}
|
||||
|
||||
void Bus::enterIntoViewOf(CNSocket *sock) {
|
||||
INITSTRUCT(sP_FE2CL_TRANSPORTATION_ENTER, pkt);
|
||||
|
||||
@ -102,11 +97,6 @@ void BaseNPC::disappearFromViewOf(CNSocket *sock) {
|
||||
sock->sendPacket(pkt, P_FE2CL_NPC_EXIT);
|
||||
}
|
||||
|
||||
void Mob::disappearFromViewOf(CNSocket *sock) {
|
||||
this->BaseNPC::disappearFromViewOf(sock);
|
||||
playersInView--;
|
||||
}
|
||||
|
||||
void Bus::disappearFromViewOf(CNSocket *sock) {
|
||||
INITSTRUCT(sP_FE2CL_TRANSPORTATION_EXIT, pkt);
|
||||
pkt.eTT = 3;
|
||||
|
@ -95,9 +95,6 @@ struct Mob : public CombatNPC {
|
||||
auto operator[](std::string s) {
|
||||
return data[s];
|
||||
}
|
||||
|
||||
virtual void enterIntoViewOf(CNSocket *sock) override;
|
||||
virtual void disappearFromViewOf(CNSocket *sock) override;
|
||||
};
|
||||
|
||||
namespace MobAI {
|
||||
|
Loading…
Reference in New Issue
Block a user