Scripts/Commands: Fix a crash on summon when no group is avaible

Port From (https://github.com/TrinityCore/TrinityCore/commit/e43d81cd687a0c18ebec3f320f53a780d950843d)
This commit is contained in:
hondacrx
2020-08-22 14:54:58 -04:00
parent 0d8743a1b5
commit 74cbb0fdf4
+8 -3
View File
@@ -678,17 +678,22 @@ namespace Game.Chat
}
else if (map.Instanceable())
{
Group targetGroup = target.GetGroup();
Map targetMap = target.GetMap();
Player targetGroupLeader = Global.ObjAccessor.GetPlayer(map, targetGroup.GetLeaderGUID());
Player targetGroupLeader = null;
Group targetGroup = target.GetGroup();
if (targetGroup != null)
targetGroupLeader = Global.ObjAccessor.GetPlayer(map, targetGroup.GetLeaderGUID());
// check if far teleport is allowed
if (!targetGroupLeader || (targetGroupLeader.GetMapId() != map.GetId()) || (targetGroupLeader.GetInstanceId() != map.GetInstanceId()))
if (targetGroupLeader == null || (targetGroupLeader.GetMapId() != map.GetId()) || (targetGroupLeader.GetInstanceId() != map.GetInstanceId()))
{
if ((targetMap.GetId() != map.GetId()) || (targetMap.GetInstanceId() != map.GetInstanceId()))
{
handler.SendSysMessage(CypherStrings.CannotSummonToInst);
return false;
}
}
// check if we're already in a different instance of the same map
if ((targetMap.GetId() == map.GetId()) && (targetMap.GetInstanceId() != map.GetInstanceId()))