Deny access to instances if other party/user with the same perm id is inside

Fixes #2844

--HG--
branch : trunk
This commit is contained in:
Tartalo
2010-07-07 22:22:16 +02:00
parent 2ccc475aa5
commit 7969723527
+26
View File
@@ -2395,6 +2395,32 @@ bool InstanceMap::CanEnter(Player *player)
return false;
}
// cannot enter if instance is in use by another party/soloer that have a
// permanent save in the same instance id
PlayerList const &playerList = GetPlayers();
Player *firstInsidePlayer = NULL;
if (!playerList.isEmpty())
for (PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
if (Player *iPlayer = i->getSource())
{
if (iPlayer->isGameMaster()) // bypass GMs
continue;
if (!player->GetGroup()) // player has not group and there is someone inside, deny entry
{
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
return false;
}
// player inside instance has no group or his groups is different to entering player's one, deny entry
if (!iPlayer->GetGroup() || iPlayer->GetGroup() != player->GetGroup() )
{
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
return false;
}
break;
}
return Map::CanEnter(player);
}