aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlaymoira <none@none>2009-02-13 23:53:06 +0100
committerBlaymoira <none@none>2009-02-13 23:53:06 +0100
commit29f3d67fb8d47ea25291fa040f1cfd33b53c9da6 (patch)
tree6cd473f8fff6f083d3a8b1cafdf47c943fefe69d /src
parentffb5fb7445e7766c6eca0b4b2c4d254a89d91d0e (diff)
*Prevent entering in instances if zone in combat - by Iskander
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Group.cpp6
-rw-r--r--src/game/Map.cpp2
-rw-r--r--src/game/MapInstanced.cpp8
-rw-r--r--src/game/MapInstanced.h1
4 files changed, 14 insertions, 3 deletions
diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index 829538f8af7..908a610e7a2 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -1389,8 +1389,10 @@ bool Group::InCombatToInstance(uint32 instanceId)
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *pPlayer = itr->getSource();
- if(pPlayer->getAttackers().size() && pPlayer->GetInstanceId() == instanceId)
- return true;
+ if(pPlayer && pPlayer->getAttackers().size() && pPlayer->GetInstanceId() == instanceId && (pPlayer->GetMap()->IsRaid() || pPlayer->GetMap()->IsHeroic()))
+ for(std::set<Unit*>::const_iterator i = pPlayer->getAttackers().begin(); i!=pPlayer->getAttackers().end(); ++i)
+ if((*i) && (*i)->GetTypeId() == TYPEID_UNIT && ((Creature*)(*i))->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
+ return true;
}
return false;
}
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index dd62f1e1c9f..66542030464 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1762,7 +1762,7 @@ bool InstanceMap::CanEnter(Player *player)
// cannot enter while players in the instance are in combat
Group *pGroup = player->GetGroup();
- if(!player->isGameMaster() && pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->isAlive() && player->GetMapId() != GetId())
+ if(!player->isGameMaster() && pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->GetMapId() != GetId())
{
player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT);
return false;
diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp
index 841d366b6c5..1a58eb2e74e 100644
--- a/src/game/MapInstanced.cpp
+++ b/src/game/MapInstanced.cpp
@@ -266,3 +266,11 @@ void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
delete itr->second;
m_InstancedMaps.erase(itr++);
}
+
+bool MapInstanced::CanEnter(Player *player)
+{
+ if(Map* map = GetInstance(player))
+ return map->CanEnter(player);
+
+ return false;
+}
diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h
index cde37f9f3ff..0efe5034dfa 100644
--- a/src/game/MapInstanced.h
+++ b/src/game/MapInstanced.h
@@ -39,6 +39,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map
void RemoveAllObjectsInRemoveList();
bool RemoveBones(uint64 guid, float x, float y);
void UnloadAll(bool pForce);
+ bool CanEnter(Player* player);
Map* GetInstance(const WorldObject* obj);
Map* FindMap(uint32 InstanceId) { return _FindMap(InstanceId); }