2019-06-18 22:55:32 -04:00
|
|
|
|
/*
|
|
|
|
|
===========================================================================
|
|
|
|
|
Copyright (C) 2015-2019 Project Meteor Dev Team
|
|
|
|
|
|
|
|
|
|
This file is part of Project Meteor Server.
|
|
|
|
|
|
|
|
|
|
Project Meteor Server is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
Project Meteor Server is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
|
|
|
|
===========================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
2016-12-15 12:19:44 -05:00
|
|
|
|
using System;
|
2016-12-12 19:03:25 -05:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2019-06-19 00:05:18 -04:00
|
|
|
|
using Meteor.Common;
|
|
|
|
|
using Meteor.World.Packets.Send.Subpackets.Groups;
|
|
|
|
|
|
|
|
|
|
namespace Meteor.World.DataObjects.Group
|
2016-12-12 19:03:25 -05:00
|
|
|
|
{
|
|
|
|
|
class Group
|
|
|
|
|
{
|
2016-12-15 12:19:44 -05:00
|
|
|
|
public const uint PlayerPartyGroup = 10001;
|
2016-12-18 09:50:23 -05:00
|
|
|
|
public const uint CompanyGroup = 20002;
|
2016-12-15 12:19:44 -05:00
|
|
|
|
|
|
|
|
|
public const uint GroupInvitationRelationGroup = 50001;
|
|
|
|
|
public const uint TradeRelationGroup = 50002;
|
2017-09-05 12:37:23 -04:00
|
|
|
|
public const uint RetainerMeetingRelationGroup = 50003;
|
2016-12-15 12:19:44 -05:00
|
|
|
|
public const uint BazaarBuyItemRelationGroup = 50009;
|
2016-12-12 19:03:25 -05:00
|
|
|
|
|
2016-12-15 12:19:44 -05:00
|
|
|
|
public const uint RetainerGroup = 80001;
|
|
|
|
|
|
|
|
|
|
public readonly ulong groupIndex;
|
|
|
|
|
|
2016-12-12 19:03:25 -05:00
|
|
|
|
public Group(ulong groupIndex)
|
|
|
|
|
{
|
|
|
|
|
this.groupIndex = groupIndex;
|
|
|
|
|
}
|
2016-12-15 12:19:44 -05:00
|
|
|
|
|
|
|
|
|
public virtual int GetMemberCount()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual uint GetTypeId()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual string GetGroupName()
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual int GetGroupLocalizedName()
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-21 21:49:50 -05:00
|
|
|
|
public virtual List<GroupMember> BuildMemberList(uint id)
|
2016-12-15 12:19:44 -05:00
|
|
|
|
{
|
|
|
|
|
return new List<GroupMember>();
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:35:11 -05:00
|
|
|
|
public void SendGroupPacketsAll(params uint[] sessionIds)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sessionIds.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
Session session = Server.GetServer().GetSession(sessionIds[i]);
|
|
|
|
|
|
|
|
|
|
if (session != null)
|
|
|
|
|
SendGroupPackets(session);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-21 18:02:50 -05:00
|
|
|
|
public void SendGroupPacketsAll(List<uint> sessionIds)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sessionIds.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Session session = Server.GetServer().GetSession(sessionIds[i]);
|
|
|
|
|
|
|
|
|
|
if (session != null)
|
|
|
|
|
SendGroupPackets(session);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:35:11 -05:00
|
|
|
|
public void SendDeletePackets(params uint[] sessionIds)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sessionIds.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
Session session = Server.GetServer().GetSession(sessionIds[i]);
|
|
|
|
|
|
|
|
|
|
if (session != null)
|
|
|
|
|
SendDeletePacket(session);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SendDeletePackets(List<uint> sessionIds)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sessionIds.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Session session = Server.GetServer().GetSession(sessionIds[i]);
|
|
|
|
|
|
|
|
|
|
if (session != null)
|
|
|
|
|
SendDeletePacket(session);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 12:19:44 -05:00
|
|
|
|
public void SendGroupPackets(Session session)
|
|
|
|
|
{
|
|
|
|
|
ulong time = Utils.MilisUnixTimeStampUTC();
|
2016-12-21 21:49:50 -05:00
|
|
|
|
List<GroupMember> members = BuildMemberList(session.sessionId);
|
2016-12-15 12:19:44 -05:00
|
|
|
|
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupHeaderPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
|
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersBeginPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
|
2016-12-15 12:19:44 -05:00
|
|
|
|
|
|
|
|
|
int currentIndex = 0;
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2019-05-29 23:20:15 -07:00
|
|
|
|
int memberCount = Math.Min(GetMemberCount(), members.Count);
|
|
|
|
|
if (memberCount - currentIndex >= 64)
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersX64Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
|
2019-05-29 23:20:15 -07:00
|
|
|
|
else if (memberCount - currentIndex >= 32)
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersX32Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
|
2019-05-29 23:20:15 -07:00
|
|
|
|
else if (memberCount - currentIndex >= 16)
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersX16Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
|
2019-05-29 23:20:15 -07:00
|
|
|
|
else if (memberCount - currentIndex > 0)
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersX08Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
|
2016-12-15 12:19:44 -05:00
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(GroupMembersEndPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
|
2016-12-15 12:19:44 -05:00
|
|
|
|
|
|
|
|
|
}
|
2016-12-16 20:06:17 -05:00
|
|
|
|
|
2017-01-02 14:35:11 -05:00
|
|
|
|
public void SendDeletePacket(Session session)
|
|
|
|
|
{
|
2017-01-09 00:12:11 -05:00
|
|
|
|
if (session != null)
|
2017-06-27 17:31:17 -04:00
|
|
|
|
session.clientConnection.QueuePacket(DeleteGroupPacket.buildPacket(session.sessionId, this));
|
2017-01-02 14:35:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-16 20:06:17 -05:00
|
|
|
|
public virtual void SendInitWorkValues(Session session)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2016-12-12 19:03:25 -05:00
|
|
|
|
}
|
|
|
|
|
}
|