Ejemplo n.º 1
0
        ObjectGuid CreateBuiltinChannelGuid(uint channelId, AreaTableRecord zoneEntry = null)
        {
            ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
            uint zoneId = zoneEntry != null ? zoneEntry.Id : 0;

            if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.Global | ChannelDBCFlags.CityOnly))
            {
                zoneId = 0;
            }

            ulong high = 0;

            high |= (ulong)HighGuid.ChatChannel << 58;
            high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
            high |= 1ul << 25; // built-in
            if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly2))
            {
                high |= 1ul << 24; // trade
            }
            high |= (ulong)(zoneId) << 10;
            high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;

            ObjectGuid channelGuid = new ObjectGuid();

            channelGuid.SetRawValue(high, channelId);
            return(channelGuid);
        }
Ejemplo n.º 2
0
        public Channel(ObjectGuid guid, string name, Team team = 0)
        {
            _announceEnabled  = true;
            _ownershipEnabled = true;
            _channelFlags     = ChannelFlags.Custom;
            _channelTeam      = team;
            _channelGuid      = guid;
            _channelName      = name;

            // If storing custom channels in the db is enabled either load or save the channel
            if (WorldConfig.GetBoolValue(WorldCfg.PreserveCustomChannels))
            {
                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHANNEL);
                stmt.AddValue(0, _channelName);
                stmt.AddValue(1, _channelTeam);
                SQLResult result = DB.Characters.Query(stmt);

                if (!result.IsEmpty())                           //load
                {
                    _channelName      = result.Read <string>(0); // re-get channel name. MySQL table collation is case insensitive
                    _announceEnabled  = result.Read <bool>(1);
                    _ownershipEnabled = result.Read <bool>(2);
                    _channelPassword  = result.Read <string>(3);
                    string bannedList = result.Read <string>(4);

                    if (string.IsNullOrEmpty(bannedList))
                    {
                        var tokens = new StringArray(bannedList, ' ');
                        for (var i = 0; i < tokens.Length; ++i)
                        {
                            ObjectGuid bannedGuid = new ObjectGuid();
                            if (ulong.TryParse(tokens[i].Substring(0, 16), out ulong highguid) && ulong.TryParse(tokens[i].Substring(16), out ulong lowguid))
                            {
                                bannedGuid.SetRawValue(highguid, lowguid);
                            }

                            if (!bannedGuid.IsEmpty())
                            {
                                Log.outDebug(LogFilter.ChatSystem, "Channel({0}) loaded bannedStore guid:{1}", _channelName, bannedGuid);
                                _bannedStore.Add(bannedGuid);
                            }
                        }
                    }
                }
                else // save
                {
                    stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHANNEL);
                    stmt.AddValue(0, _channelName);
                    stmt.AddValue(1, _channelTeam);
                    DB.Characters.Execute(stmt);
                    Log.outDebug(LogFilter.ChatSystem, "Channel({0}) saved in database", _channelName);
                }

                _persistentChannel = true;
            }
        }
Ejemplo n.º 3
0
        ObjectGuid CreateCustomChannelGuid()
        {
            ulong high = 0;

            high |= (ulong)HighGuid.ChatChannel << 58;
            high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
            high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;

            ObjectGuid channelGuid = new ObjectGuid();

            channelGuid.SetRawValue(high, _guidGenerator.Generate());
            return(channelGuid);
        }
Ejemplo n.º 4
0
        static bool HandleCloseByIdCommand <T>(StringArguments args, CommandHandler handler) where T : Ticket
        {
            if (args.Empty())
            {
                return(false);
            }

            uint ticketId = args.NextUInt32();
            T    ticket   = Global.SupportMgr.GetTicket <T>(ticketId);

            if (ticket == null || ticket.IsClosed())
            {
                handler.SendSysMessage(CypherStrings.CommandTicketnotexist);
                return(true);
            }

            // Ticket should be assigned to the player who tries to close it.
            // Console can override though
            Player player = handler.GetSession() != null?handler.GetSession().GetPlayer() : null;

            if (player && ticket.IsAssignedNotTo(player.GetGUID()))
            {
                handler.SendSysMessage(CypherStrings.CommandTicketcannotclose, ticket.GetId());
                return(true);
            }

            ObjectGuid closedByGuid = ObjectGuid.Empty;

            if (player)
            {
                closedByGuid = player.GetGUID();
            }
            else
            {
                closedByGuid.SetRawValue(0, ulong.MaxValue);
            }

            Global.SupportMgr.CloseTicket <T>(ticket.GetId(), closedByGuid);

            string msg = ticket.FormatViewMessageString(handler, player ? player.GetName() : "Console", null, null, null);

            handler.SendGlobalGMSysMessage(msg);

            return(true);
        }