コード例 #1
0
    private static void HandleNameVoucher(GameSession session, PacketReader packet, Item item)
    {
        string newName = packet.ReadUnicodeString();
        string oldName = session.Player.Name;

        session.Player.Name = newName;

        session.Player.Inventory.ConsumeItem(session, item.Uid, 1);

        session.Send(CharacterListPacket.NameChanged(session.Player.CharacterId, newName));

        // Update name on socials
        foreach (Club club in session.Player.Clubs)
        {
            club.BroadcastPacketClub(ClubPacket.UpdateMemberName(oldName, newName, session.Player.CharacterId));
            if (club.LeaderCharacterId == session.Player.CharacterId)
            {
                club.LeaderName = newName;
            }
        }

        if (session.Player.Guild is not null)
        {
            session.Player.Guild?.BroadcastPacketGuild(GuildPacket.UpdateMemberName(oldName, newName));
            if (session.Player.Guild.LeaderCharacterId == session.Player.CharacterId)
            {
                session.Player.Guild.LeaderName = newName;
            }
        }

        session.Player.Party?.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player));

        // TODO: Needs to redirect player to character selection screen after pop-up
    }