public static void HandleCreateListing(GameSession session, PacketReader packet) { string partyName = packet.ReadUnicodeString(); bool approval = packet.ReadBool(); int memberCountRecruit = packet.ReadInt(); Party party = GameServer.PartyManager.GetPartyByLeader(session.Player); if (party == null) { Party newParty = new(partyName, approval, session.Player, memberCountRecruit); GameServer.PartyManager.AddParty(newParty); session.Send(PartyPacket.Create(newParty, false)); session.Send(PartyPacket.UpdateHitpoints(session.Player)); session.Player.Party = newParty; party = newParty; } else { if (party.Members.Count >= memberCountRecruit) { return; } party.PartyFinderId = GuidGenerator.Long(); party.Name = partyName; party.Approval = approval; party.RecruitMemberCount = memberCountRecruit; } party.BroadcastPacketParty(MatchPartyPacket.CreateListing(party)); party.BroadcastPacketParty(PartyPacket.MatchParty(party, true)); }
private void JoinParty(GameSession session, string leaderName, bool accept, int unknown) { Player partyLeader = GameServer.Storage.GetPlayerByName(leaderName); if (partyLeader == null) { return; } GameSession leaderSession = partyLeader.Session; if (!accept) { //Send Decline message to inviting player leaderSession.Send(ChatPacket.Send(partyLeader, session.Player.Name + " declined the invitation.", ChatType.NoticeAlert2)); return; } Party party = GameServer.PartyManager.GetPartyByLeader(partyLeader); if (party != null) { //Existing party, add joining player to all other party members. party.BroadcastPacketParty(PartyPacket.Join(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player)); party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(session.Player)); party.AddMember(session.Player); if (party.PartyFinderId != 0) { if (party.Members.Count >= party.MaxMembers) { party.PartyFinderId = 0; //Hide from party finder if full party.BroadcastPacketParty(MatchPartyPacket.RemoveListing(party)); party.BroadcastPacketParty( MatchPartyPacket.SendListings(GameServer.PartyManager.GetPartyFinderList())); party.BroadcastPacketParty(PartyPacket.MatchParty(null)); } else { session.Send( MatchPartyPacket.CreateListing(party)); //Add recruitment listing for newly joining player session.Send(PartyPacket.MatchParty(party)); } } } else { //Create new party Party newParty = new(10, new List <Player> { partyLeader, session.Player }); GameServer.PartyManager.AddParty(newParty); //Send the party leader all the stuff for the joining player leaderSession.Send(PartyPacket.Join(session.Player)); leaderSession.Send(PartyPacket.UpdatePlayer(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(session.Player)); leaderSession.Send(PartyPacket.UpdateHitpoints(partyLeader)); party = newParty; } //Create existing party based on the list of party members session.Send(PartyPacket.CreateExisting(partyLeader, party.Members)); session.Send(PartyPacket.UpdatePlayer(session.Player)); foreach (Player partyMember in party.Members) { //Skip first character because of the scuffed Create packet. For now this is a workaround and functions the same. if (partyMember.CharacterId != party.Members.First().CharacterId) { //Adds the party member to the UI session.Send(PartyPacket.Join(partyMember)); } //Update the HP for each party member. session.Send(PartyPacket.UpdateHitpoints(partyMember)); } }