Ejemplo n.º 1
0
            /// <summary>
            /// Joins the specified obj char.
            /// </summary>
            /// <param name="objCharacter">The obj char.</param>
            /// <returns></returns>
            public void Join(WcHandlerCharacter.CharacterObject objCharacter)
            {
                if (_invitedTeam1.Contains(objCharacter) || _invitedTeam2.Contains(objCharacter))
                {
                    if (_invitedTeam1.Contains(objCharacter))
                    {
                        _membersTeam1.Add(objCharacter);
                        _invitedTeam1.Remove(objCharacter);
                    }

                    if (_invitedTeam2.Contains(objCharacter))
                    {
                        _membersTeam2.Add(objCharacter);
                        _invitedTeam2.Remove(objCharacter);
                    }

                    SendBattlegroundStatus(objCharacter, 0);
                    {
                        var withBlock = _clusterServiceLocator.WsDbcDatabase.WorldSafeLocs[_clusterServiceLocator.WsDbcDatabase.Battlegrounds[(byte)MapType].AllianceStartLoc];
                        // TODO: WTF? characters_locations table? when?
                        // Dim q As New DataTable
                        // _WorldCluster.CharacterDatabase.Query(String.Format("SELECT char_guid FROM characters_locations WHERE char_guid = {0};", objCharacter.GUID), q)
                        // If q.Rows.Count = 0 Then
                        // 'Save only first BG location
                        // _WorldCluster.CharacterDatabase.Update(String.Format("INSERT INTO characters_locations(char_guid, char_positionX, char_positionY, char_positionZ, char_zone_id, char_map_id, char_orientation) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6});", _
                        // objCharacter.GUID, Trim(Str(objCharacter.PositionX)), Trim(Str(objCharacter.PositionY)), Trim(Str(objCharacter.PositionZ)), objCharacter.Zone, objCharacter.Map, 0))
                        // End If
                        objCharacter.Transfer(withBlock.X, withBlock.Y, withBlock.Z, _clusterServiceLocator.WsDbcDatabase.Battlegrounds[(byte)MapType].AllianceStartO, (int)withBlock.Map);
                    }
                }
            }
Ejemplo n.º 2
0
        public void SendIgnoreList(ClientClass client, WcHandlerCharacter.CharacterObject character)
        {
            // DONE: Query DB
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND (flags & {1}) > 0;", character.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q);

            // DONE: Make the packet
            var smsgIgnoreList = new PacketClass(Opcodes.SMSG_IGNORE_LIST);

            if (q.Rows.Count > 0)
            {
                smsgIgnoreList.AddInt8((byte)q.Rows.Count);
                foreach (DataRow row in q.Rows)
                {
                    smsgIgnoreList.AddUInt64(row.As <ulong>("friend"));                    // Player GUID
                }
            }
            else
            {
                smsgIgnoreList.AddInt8(0);
            }

            client.Send(smsgIgnoreList);
            smsgIgnoreList.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_IGNORE_LIST", client.IP, client.Port);
        }
Ejemplo n.º 3
0
            public void SendChatMessage(WcHandlerCharacter.CharacterObject sender, string message, LANGUAGES language, ChatMsg thisType)
            {
                var packet = _clusterServiceLocator.Functions.BuildChatMessage(sender.Guid, message, thisType, language, (byte)sender.ChatFlag);

                Broadcast(packet);
                packet.Dispose();
            }
Ejemplo n.º 4
0
 public void BroadcastToOther(PacketClass packet, WcHandlerCharacter.CharacterObject objCharacter)
 {
     for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
     {
         if (Members[i] is object && !ReferenceEquals(Members[i], objCharacter) && Members[i].Client is object)
         {
             Members[i].Client.SendMultiplyPackets(packet);
         }
     }
 }
Ejemplo n.º 5
0
 public void BroadcastToOutOfRange(PacketClass packet, WcHandlerCharacter.CharacterObject objCharacter)
 {
     for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
     {
         if (Members[i] is object && !ReferenceEquals(Members[i], objCharacter) && Members[i].Client is object)
         {
             if (objCharacter.Map != Members[i].Map || Math.Sqrt(Math.Pow(objCharacter.PositionX - Members[i].PositionX, 2d) + Math.Pow(objCharacter.PositionY - Members[i].PositionY, 2d)) > _clusterServiceLocator.GlobalConstants.DEFAULT_DISTANCE_VISIBLE)
             {
                 Members[i].Client.SendMultiplyPackets(packet);
             }
         }
     }
 }
Ejemplo n.º 6
0
        /* TODO ERROR: Skipped RegionDirectiveTrivia */
        public void LoadIgnoreList(WcHandlerCharacter.CharacterObject objCharacter)
        {
            // DONE: Query DB
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND flags = {1};", objCharacter.Guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q);

            // DONE: Add to list
            foreach (DataRow row in q.Rows)
            {
                objCharacter.IgnoreList.Add(row.As <ulong>("friend"));
            }
        }
Ejemplo n.º 7
0
            /// <summary>
            /// Enqueues the specified obj char.
            /// </summary>
            /// <param name="objCharacter">The obj char.</param>
            /// <returns></returns>
            public void Enqueue(WcHandlerCharacter.CharacterObject objCharacter)
            {
                if (_clusterServiceLocator.Functions.GetCharacterSide((byte)objCharacter.Race))
                {
                    _queueTeam1.Add(objCharacter);
                }
                else
                {
                    _queueTeam2.Add(objCharacter);
                }

                SendBattlegroundStatus(objCharacter, 0);
            }
Ejemplo n.º 8
0
        public void SendFriendList(ClientClass client, WcHandlerCharacter.CharacterObject character)
        {
            // DONE: Query DB
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND (flags & {1}) > 0;", character.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q);

            // DONE: Make the packet
            var smsgFriendList = new PacketClass(Opcodes.SMSG_FRIEND_LIST);

            if (q.Rows.Count > 0)
            {
                smsgFriendList.AddInt8((byte)q.Rows.Count);
                foreach (DataRow row in q.Rows)
                {
                    var guid = row.As <ulong>("friend");
                    smsgFriendList.AddUInt64(guid);                    // Player GUID
                    if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid) && _clusterServiceLocator.WorldCluster.CharacteRs[guid].IsInWorld)
                    {
                        if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Dnd)
                        {
                            smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_DND);
                        }
                        else if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Afk)
                        {
                            smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_AFK);
                        }
                        else
                        {
                            smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_ONLINE);
                        }

                        smsgFriendList.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Zone);   // Area
                        smsgFriendList.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Level);       // Level
                        smsgFriendList.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe); // Class
                    }
                    else
                    {
                        smsgFriendList.AddInt8((byte)FriendStatus.FRIEND_STATUS_OFFLINE);
                    }
                }
            }
            else
            {
                smsgFriendList.AddInt8(0);
            }

            client.Send(smsgFriendList);
            smsgFriendList.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_LIST", client.IP, client.Port);
        }
Ejemplo n.º 9
0
            public void SetLootMaster(WcHandlerCharacter.CharacterObject objCharacter)
            {
                _lootMaster = Leader;
                for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
                {
                    if (ReferenceEquals(Members[i], objCharacter))
                    {
                        _lootMaster = i;
                        break;
                    }
                }

                SendGroupList();
            }
Ejemplo n.º 10
0
            /* TODO ERROR: Skipped EndRegionDirectiveTrivia */
            public void Join(WcHandlerCharacter.CharacterObject objCharacter)
            {
                for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
                {
                    if (Members[i] is null)
                    {
                        Members[i]                  = objCharacter;
                        objCharacter.Group          = this;
                        objCharacter.GroupAssistant = false;
                        break;
                    }
                }

                _clusterServiceLocator.WcNetwork.WorldServer.GroupSendUpdate(Id);
                objCharacter.GetWorld.ClientSetGroup(objCharacter.Client.Index, Id);
                SendGroupList();
            }
Ejemplo n.º 11
0
 public Group(WcHandlerCharacter.CharacterObject objCharacter, ClusterServiceLocator clusterServiceLocator)
 {
     _clusterServiceLocator = clusterServiceLocator;
     Members = new WcHandlerCharacter.CharacterObject[_clusterServiceLocator.GlobalConstants.GROUP_SIZE + 1];
     Id      = Interlocked.Increment(ref _clusterServiceLocator.WcHandlersGroup._groupCounter);
     _clusterServiceLocator.WcHandlersGroup.GrouPs.Add(Id, this);
     Members[0]                  = objCharacter;
     Members[1]                  = null;
     Members[2]                  = null;
     Members[3]                  = null;
     Members[4]                  = null;
     Leader                      = 0;
     _lootMaster                 = 255;
     objCharacter.Group          = this;
     objCharacter.GroupAssistant = false;
     objCharacter.GetWorld.ClientSetGroup(objCharacter.Client.Index, Id);
 }
Ejemplo n.º 12
0
            public void NewLeader(WcHandlerCharacter.CharacterObject leaver = null)
            {
                byte chosenMember  = 255;
                var  newLootMaster = false;

                for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
                {
                    if (Members[i] is object && Members[i].Client is object)
                    {
                        if (leaver is object && ReferenceEquals(leaver, Members[i]))
                        {
                            if (i == _lootMaster)
                            {
                                newLootMaster = true;
                            }
                            if (chosenMember != 255)
                            {
                                break;
                            }
                        }
                        else if (Members[i].GroupAssistant && chosenMember == 255)
                        {
                            chosenMember = i;
                        }
                        else if (chosenMember == 255)
                        {
                            chosenMember = i;
                        }
                    }
                }

                if (chosenMember != 255)
                {
                    Leader = chosenMember;
                    if (newLootMaster)
                    {
                        _lootMaster = Leader;
                    }
                    var response = new PacketClass(Opcodes.SMSG_GROUP_SET_LEADER);
                    response.AddString(Members[Leader].Name);
                    Broadcast(response);
                    response.Dispose();
                    _clusterServiceLocator.WcNetwork.WorldServer.GroupSendUpdate(Id);
                }
            }
Ejemplo n.º 13
0
            public void SetLeader(WcHandlerCharacter.CharacterObject objCharacter)
            {
                for (byte i = 0, loopTo = (byte)Members.Length; i <= loopTo; i++)
                {
                    if (ReferenceEquals(Members[i], objCharacter))
                    {
                        Leader = i;
                        break;
                    }
                }

                var packet = new PacketClass(Opcodes.SMSG_GROUP_SET_LEADER);

                packet.AddString(objCharacter.Name);
                Broadcast(packet);
                packet.Dispose();
                _clusterServiceLocator.WcNetwork.WorldServer.GroupSendUpdate(Id);
                SendGroupList();
            }
Ejemplo n.º 14
0
        /// <summary>
        /// Sends the battleground group joined.
        /// </summary>
        /// <param name="objCharacter">The objCharacter.</param>
        /// <returns></returns>
        public void SendBattlegroundGroupJoined(WcHandlerCharacter.CharacterObject objCharacter)
        {
            // 0 - Your group has joined a battleground queue, but you are not eligible
            // 1 - Your group has joined the queue for AV
            // 2 - Your group has joined the queue for WS
            // 3 - Your group has joined the queue for AB


            var p = new PacketClass(Opcodes.SMSG_GROUP_JOINED_BATTLEGROUND);

            try
            {
                p.AddUInt32(0xFFFFFFFEU);
                objCharacter.Client.Send(p);
            }
            finally
            {
                p.Dispose();
            }
        }
Ejemplo n.º 15
0
            public void Leave(WcHandlerCharacter.CharacterObject objCharacter)
            {
                if (GetMembersCount() == 2)
                {
                    Dispose();
                    return;
                }

                for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
                {
                    if (ReferenceEquals(Members[i], objCharacter))
                    {
                        objCharacter.Group = null;
                        Members[i]         = null;

                        // DONE: If current is leader then choose new
                        if (i == Leader)
                        {
                            NewLeader();
                        }

                        // DONE: If current is lootMaster then choose new
                        if (i == _lootMaster)
                        {
                            _lootMaster = Leader;
                        }
                        if (objCharacter.Client is object)
                        {
                            var packet = new PacketClass(Opcodes.SMSG_GROUP_UNINVITE);
                            objCharacter.Client.Send(packet);
                            packet.Dispose();
                        }

                        break;
                    }
                }

                _clusterServiceLocator.WcNetwork.WorldServer.GroupSendUpdate(Id);
                objCharacter.GetWorld.ClientSetGroup(objCharacter.Client.Index, -1);
                CheckMembers();
            }
Ejemplo n.º 16
0
        public void NotifyFriendStatus(WcHandlerCharacter.CharacterObject objCharacter, FriendStatus s)
        {
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT guid FROM character_social WHERE friend = {0} AND (flags & {1}) > 0;", objCharacter.Guid, Conversions.ToInteger(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q);

            // DONE: Send "Friend offline/online"
            var friendpacket = new PacketClass(Opcodes.SMSG_FRIEND_STATUS);

            friendpacket.AddInt8((byte)s);
            friendpacket.AddUInt64(objCharacter.Guid);
            foreach (DataRow row in q.Rows)
            {
                var guid = row.As <ulong>("guid");
                if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid) && _clusterServiceLocator.WorldCluster.CharacteRs[guid].Client is object)
                {
                    _clusterServiceLocator.WorldCluster.CharacteRs[guid].Client.SendMultiplyPackets(friendpacket);
                }
            }

            friendpacket.Dispose();
        }
Ejemplo n.º 17
0
            /// <summary>
            /// Leaves the specified obj char.
            /// </summary>
            /// <param name="objCharacter">The obj char.</param>
            /// <returns></returns>
            public void Leave(WcHandlerCharacter.CharacterObject objCharacter)
            {
                if (_queueTeam1.Contains(objCharacter) || _queueTeam2.Contains(objCharacter))
                {
                    _queueTeam1.Remove(objCharacter);
                    _queueTeam2.Remove(objCharacter);
                }
                else if (_membersTeam1.Contains(objCharacter) || _membersTeam2.Contains(objCharacter))
                {
                    _membersTeam1.Remove(objCharacter);
                    _membersTeam2.Remove(objCharacter);

                    // TODO: Still.. characters_locations, doesn't exist?
                    // Dim q As New DataTable
                    // _WorldCluster.CharacterDatabase.Query(String.Format("SELECT * FROM characters_locations WHERE char_guid = {0};", objCharacter.GUID), q)
                    // If q.Rows.Count = 0 Then
                    // SendMessageSystem(objCharacter.Client, "You don't have location saved!")
                    // Else
                    // objCharacter.Transfer(q.Rows(0).Item("char_positionX"), q.Rows(0).Item("char_positionY"), q.Rows(0).Item("char_positionZ"), q.Rows(0).Item("char_orientation"), q.Rows(0).Item("char_map_id"))
                    // End If
                }

                SendBattlegroundStatus(objCharacter, 0);
            }
Ejemplo n.º 18
0
 public void Say(string message, int msgLang, WcHandlerCharacter.CharacterObject character)
 {
     if (Muted.Contains(character.Guid))
     {
         var p = BuildChannelNotify(CHANNEL_NOTIFY_FLAGS.CHANNEL_YOUCANTSPEAK, character.Guid, default, default);
Ejemplo n.º 19
0
            /// <summary>
            /// Sends the battleground status.
            /// </summary>
            /// <param name="objCharacter">The obj char.</param>
            /// <param name="slot">The slot.</param>
            /// <returns></returns>
            private void SendBattlegroundStatus(WcHandlerCharacter.CharacterObject objCharacter, byte slot)
            {
                var status = BattlegroundStatus.STATUS_CLEAR;

                if (_queueTeam1.Contains(objCharacter) | _queueTeam2.Contains(objCharacter))
                {
                    status = BattlegroundStatus.STATUS_WAIT_QUEUE;
                }
                else if (_invitedTeam1.Contains(objCharacter) | _invitedTeam2.Contains(objCharacter))
                {
                    status = BattlegroundStatus.STATUS_WAIT_JOIN;
                }
                else if (_membersTeam1.Contains(objCharacter) | _membersTeam2.Contains(objCharacter))
                {
                    status = BattlegroundStatus.STATUS_IN_PROGRESS;
                }

                var p = new PacketClass(Opcodes.SMSG_BATTLEFIELD_STATUS);

                try
                {
                    p.AddUInt32(slot);               // Slot (0, 1 or 2)

                    // p.AddInt8(0)                    'ArenaType
                    p.AddUInt32((uint)MapType);              // MapType
                    // p.AddInt8(&HD)                  'Unk1 (0xD?)
                    // p.AddInt8(0)                    'Unk2
                    // p.AddInt16()                   'Unk3 (String?)
                    p.AddUInt32((uint)Id);                  // ID

                    // p.AddInt32(0)                   'Unk5
                    p.AddInt8(0);                    // alliance/horde for BG and skirmish/rated for Arenas
                    p.AddUInt32((uint)status);
                    switch (status)
                    {
                    case var @case when @case == BattlegroundStatus.STATUS_WAIT_QUEUE:
                    {
                        p.AddUInt32(120000U);             // average wait time, milliseconds
                        p.AddUInt32(1U);                  // time in queue, updated every minute?
                        break;
                    }

                    case var case1 when case1 == BattlegroundStatus.STATUS_WAIT_JOIN:
                    {
                        p.AddUInt32(_map);                // map id
                        p.AddUInt32(60000U);              // time to remove from queue, milliseconds
                        break;
                    }

                    case var case2 when case2 == BattlegroundStatus.STATUS_IN_PROGRESS:
                    {
                        p.AddUInt32(_map);               // map id
                        p.AddUInt32(0U);                 // 0 at bg start, 120000 after bg end, time to bg auto leave, milliseconds
                        p.AddUInt32(1U);                 // time from bg start, milliseconds
                        p.AddInt8(1);                    // unk sometimes 0x0!
                        break;
                    }

                    case var case3 when case3 == BattlegroundStatus.STATUS_CLEAR:
                    {
                        break;
                    }
                        // Do nothing
                    }

                    objCharacter.Client.Send(p);
                }
                finally
                {
                    p.Dispose();
                }
            }