Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/NosCore.Controllers/DefaultPacketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,13 @@ public void Preq(PreqPacket _)
if ((SystemTime.Now() - Session.Character.LastPortal).TotalSeconds < 4 ||
Session.Character.LastPortal > Session.Character.LastMove)
{
Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(LanguageKey.PORTAL_DELAY, Session.Account.Language), SayColorType.Yellow));
return;
}

var portal = Session.Character.MapInstance.Portals.Find(port =>
Heuristic.Octile(Math.Abs(Session.Character.PositionX - port.SourceX),
Math.Abs(Session.Character.PositionY - port.SourceY)) <= 1);
Math.Abs(Session.Character.PositionY - port.SourceY)) <= 2);
if (portal == null)
{
return;
Expand Down
9 changes: 5 additions & 4 deletions src/NosCore.Controllers/GroupPacketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void ManageGroup(PjoinPacket pjoinPacket)
Broadcaster.Instance.GetCharacter(s =>
s.VisualId == member.Item2.VisualId);
session?.SendPacket(currentGroup.GeneratePinit());
session?.SendPackets(currentGroup.GeneratePst());
session?.SendPackets(currentGroup.GeneratePst().Where(p=>p.VisualId != session.VisualId));
}

GroupAccess.Instance.Groups[currentGroup.GroupId] = currentGroup;
Expand Down Expand Up @@ -328,9 +328,10 @@ public void LeaveGroup(PleavePacket __)

if (group.Count > 2)
{
var isLeader = group.IsGroupLeader(Session.Character.CharacterId);
Session.Character.LeaveGroup();

if (group.IsGroupLeader(Session.Character.CharacterId))
if (isLeader)
{
var session = Broadcaster.Instance.GetCharacter(s =>
s.VisualId == group.Values.First().Item2.VisualId);
Expand All @@ -340,10 +341,10 @@ public void LeaveGroup(PleavePacket __)
return;
}

Broadcaster.Instance.Sessions.SendPacket(new InfoPacket
session.SendPacket(new InfoPacket
{
Message = Language.Instance.GetMessageFromKey(LanguageKey.NEW_LEADER, Session.Account.Language)
}, new EveryoneBut(session.Channel.Id));
});
}

if (group.Type != GroupType.Group)
Expand Down
1 change: 1 addition & 0 deletions src/NosCore.Data/Enumerations/I18N/LanguageKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,6 @@ public enum LanguageKey
TOO_RICH_SELLER,
UPDATE_GOLD,
SP_ADDPOINTS_FULL,
PORTAL_DELAY
}
}
2 changes: 1 addition & 1 deletion src/NosCore.GameObject/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<PstPacket> GeneratePst()
{
var i = 0;

return Values.Select(s => s.Item2).Select(member => new PstPacket
return Values.OrderBy(s => s.Item1).Select(s => s.Item2).Select(member => new PstPacket
{
Type = member.VisualType,
VisualId = member.VisualId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public bool CheckExchange(long visualId)
public long? GetTargetId(long visualId)
{
var id = _exchangeRequests.FirstOrDefault(k => k.Key == visualId || k.Value == visualId);
if (id.Equals(default))
if (id.Equals(default(KeyValuePair<long, long>)))
{
return null;
}
Expand Down