예제 #1
0
        public static void HandleGuildSetMaster(ref PacketReader packet, ref WorldSession session)
        {
            string name = packet.ReadString();

            Player pl    = session.GetPlayer();
            Guild  guild = GuildMgr.GetGuildByGuid(pl.GuildGuid);

            if (guild == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            if (pl.GetGUIDLow() != guild.GetLeaderGuid())
            {
                SendCommandResult(ref session, GuildCommandType.Invite_S, GuildCommandErrors.RankTooLow_S);
                return;
            }

            Guild.Member oldleader = guild.GetMember(pl.GetGUIDLow());
            Guild.Member newleader = guild.GetMember(name);

            if (newleader == null)
            {
                SendCommandResult(ref session, GuildCommandType.Invite_S, GuildCommandErrors.PlayerNotInGuild_S, name);
                return;
            }

            guild.SetLeader(newleader);
            oldleader.ChangeRank((uint)guild.GetLowestRank());
            guild.SendBroadcastEvent(GuildEvents.LeaderChanged, 0, oldleader.Name, name);
        }
예제 #2
0
        public static void HandleGuildSetNote(ref PacketReader packet, ref WorldSession session)
        {
            Player pl    = session.GetPlayer();
            Guild  guild = GuildMgr.GetGuildByGuid(pl.GuildGuid);

            if (guild == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            byte[] guid = new byte[8];
            guid[1] = packet.GetBit();
            guid[4] = packet.GetBit();
            guid[5] = packet.GetBit();
            guid[3] = packet.GetBit();
            guid[0] = packet.GetBit();
            guid[7] = packet.GetBit();

            bool Public = packet.ReadBit();

            guid[6] = packet.GetBit();

            uint noteLen = packet.GetBits <uint>(8);

            guid[2] = packet.GetBit();

            packet.ReadXORByte(guid, 4);
            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(guid, 0);
            packet.ReadXORByte(guid, 3);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 7);

            string note = packet.ReadString(noteLen);

            packet.ReadXORByte(guid, 2);

            if (!guild.HasRankRight(guild.GetMember(pl.GetGUIDLow()).RankId, (uint)(Public ? GuildRankRights.EditPublicNote : GuildRankRights.EditOffNote)))
            {
                SendCommandResult(ref session, GuildCommandType.Invite_S, GuildCommandErrors.RankTooLow_S);
                return;
            }

            ulong Guid = packet.ReadGuid(guid);

            Guild.Member member = guild.GetMember(Guid);

            if (member == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            member.SetNote(Public, note);

            guild.SendRoster();
        }
예제 #3
0
        public static void HandleGuildDemote(ref PacketReader packet, ref WorldSession session)
        {
            string name = packet.ReadString();

            Player pl    = session.GetPlayer();
            Guild  guild = GuildMgr.GetGuildByGuid(pl.GuildGuid);

            if (guild == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            if (!guild.HasRankRight(guild.GetMember(pl.GetGUIDLow()).RankId, (uint)GuildRankRights.Demote))
            {
                SendCommandResult(ref session, GuildCommandType.Invite_S, GuildCommandErrors.RankTooLow_S);
                return;
            }

            Guild.Member member = guild.GetMember(name);

            if (member == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            Guild.Member _member = guild.GetMember(pl.GetGUIDLow());
            if (_member.RankId >= member.RankId)
            {
                SendCommandResult(ref session, GuildCommandType.Invite_S, GuildCommandErrors.RankTooHigh_S);
                return;
            }

            uint newRankId = member.RankId + 1;

            member.ChangeRank(newRankId);

            guild.LogGuildEvent(GuildEventLogTypes.DemotePlayer, pl.GetGUIDLow(), member.CharGuid, newRankId);
            guild.SendBroadcastEvent(GuildEvents.Demotion, 0, _member.Name, member.Name, guild.GetRankName(newRankId));
        }
예제 #4
0
        public static void HandleGuildAssignRank(ref PacketReader packet, ref WorldSession session)
        {
            uint rankId = packet.ReadUInt32();

            var TGuid = new byte[8];
            var Guid  = new byte[8];

            TGuid[1] = packet.GetBit();
            TGuid[7] = packet.GetBit();
            Guid[4]  = packet.GetBit();
            Guid[2]  = packet.GetBit();
            TGuid[4] = packet.GetBit();
            TGuid[5] = packet.GetBit();
            TGuid[6] = packet.GetBit();
            Guid[1]  = packet.GetBit();
            Guid[7]  = packet.GetBit();
            TGuid[2] = packet.GetBit();
            TGuid[3] = packet.GetBit();
            TGuid[0] = packet.GetBit();
            Guid[6]  = packet.GetBit();
            Guid[3]  = packet.GetBit();
            Guid[0]  = packet.GetBit();
            Guid[5]  = packet.GetBit();

            packet.ReadXORByte(TGuid, 0);
            packet.ReadXORByte(Guid, 1);
            packet.ReadXORByte(Guid, 3);
            packet.ReadXORByte(Guid, 5);
            packet.ReadXORByte(TGuid, 7);
            packet.ReadXORByte(TGuid, 3);
            packet.ReadXORByte(Guid, 0);
            packet.ReadXORByte(TGuid, 1);
            packet.ReadXORByte(Guid, 6);
            packet.ReadXORByte(TGuid, 2);
            packet.ReadXORByte(TGuid, 5);
            packet.ReadXORByte(TGuid, 4);
            packet.ReadXORByte(Guid, 2);
            packet.ReadXORByte(Guid, 4);
            packet.ReadXORByte(Guid, 6);
            packet.ReadXORByte(Guid, 7);

            ObjectGuid TargetGuid = new ObjectGuid(TGuid);
            ObjectGuid PlGuid     = new ObjectGuid(Guid);

            Player pl    = ObjMgr.FindPlayer(PlGuid);
            Guild  guild = GuildMgr.GetGuildByGuid(pl.GuildGuid);

            if (guild == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            Guild.Member member = guild.GetMember(TargetGuid);
            if (member == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            bool promote = false;

            if (member.RankId > rankId)
            {
                promote = true;
            }

            member.ChangeRank(rankId);

            guild.LogGuildEvent(promote ? GuildEventLogTypes.PromotePlayer : GuildEventLogTypes.DemotePlayer, pl.GetGUIDLow(), member.CharGuid, rankId);
            guild.SendBroadcastEvent(promote ? GuildEvents.Promotion : GuildEvents.Demotion, 0, pl.GetName(), member.Name, guild.GetRankName(rankId));

            guild.SendRoster();
        }