Пример #1
0
        public void On_CMSG_ADD_IGNORE(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length - 1 < 6)
            {
                return;
            }
            packet.GetInt16();
            var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS);
            var name     = packet.GetString();
            var guid     = 0UL;

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_ADD_IGNORE [{2}]", client.IP, client.Port, name);

            // DONE: Get GUID from DB
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT char_guid FROM characters WHERE char_name = \"{0}\";", name), ref q);
            if (q.Rows.Count > 0)
            {
                guid = (ulong)q.Rows[0].As <long>("char_guid");
                q.Clear();
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE flags = {0}", Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q);
                var numberOfFriends = q.Rows.Count;
                q.Clear();
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM character_social WHERE guid = {0} AND friend = {1} AND flags = {2};", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)), ref q);
                if (guid == client.Character.Guid)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_SELF);
                    response.AddUInt64(guid);
                }
                else if (q.Rows.Count > 0)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ALREADY);
                    response.AddUInt64(guid);
                }
                else if (numberOfFriends >= (int)SocialList.MAX_IGNORES_ON_LIST)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ALREADY);
                    response.AddUInt64(guid);
                }
                else
                {
                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_ADDED);
                    response.AddUInt64(guid);
                    _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_IGNORED)));
                    client.Character.IgnoreList.Add(guid);
                }
            }
            else
            {
                response.AddInt8((byte)FriendResult.FRIEND_IGNORE_NOT_FOUND);
                response.AddUInt64(guid);
            }

            client.Send(response);
            response.Dispose();
            q.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port);
        }
Пример #2
0
            public void SendGroupList()
            {
                var groupCount = GetMembersCount();

                for (byte i = 0, loopTo = (byte)(Members.Length - 1); i <= loopTo; i++)
                {
                    if (Members[i] is object)
                    {
                        var packet = new PacketClass(Opcodes.SMSG_GROUP_LIST);
                        packet.AddInt8((byte)Type);                                    // GroupType 0:Party 1:Raid
                        var memberFlags = (byte)(i / _clusterServiceLocator.GlobalConstants.GROUP_SUBGROUPSIZE);
                        // If Members(i).GroupAssistant Then MemberFlags = MemberFlags Or &H1
                        packet.AddInt8(memberFlags);
                        packet.AddInt32(groupCount - 1);
                        for (byte j = 0, loopTo1 = (byte)(Members.Length - 1); j <= loopTo1; j++)
                        {
                            if (Members[j] is object && !ReferenceEquals(Members[j], Members[i]))
                            {
                                packet.AddString(Members[j].Name);
                                packet.AddUInt64(Members[j].Guid);
                                if (Members[j].IsInWorld)
                                {
                                    packet.AddInt8(1);                           // CharOnline?
                                }
                                else
                                {
                                    packet.AddInt8(0);
                                }                           // CharOnline?

                                memberFlags = (byte)(j / _clusterServiceLocator.GlobalConstants.GROUP_SUBGROUPSIZE);
                                // If Members(j).GroupAssistant Then MemberFlags = MemberFlags Or &H1
                                packet.AddInt8(memberFlags);
                            }
                        }

                        packet.AddUInt64(Members[Leader].Guid);
                        packet.AddInt8((byte)LootMethod);
                        if (_lootMaster != 255)
                        {
                            packet.AddUInt64(Members[_lootMaster].Guid);
                        }
                        else
                        {
                            packet.AddUInt64(0UL);
                        }
                        packet.AddInt8((byte)LootThreshold);
                        packet.AddInt16(0);
                        if (Members[i].Client is object)
                        {
                            Members[i].Client.Send(packet);
                        }

                        packet.Dispose();
                    }
                }
            }
Пример #3
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);
        }
Пример #4
0
 public void On_MSG_RAID_READY_CHECK(PacketClass packet, ClientClass client)
 {
     _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_RAID_READY_CHECK", client.IP, client.Port);
     if (client.Character.IsGroupLeader)
     {
         client.Character.Group.BroadcastToOther(packet, client.Character);
     }
     else
     {
         if (packet.Data.Length - 1 < 6)
         {
             return;
         }
         packet.GetInt16();
         var result = packet.GetInt8();
         if (result == 0)
         {
             // DONE: Not ready
             client.Character.Group.GetLeader().Client.Send(packet);
         }
         else
         {
             // DONE: Ready
             var response = new PacketClass(Opcodes.MSG_RAID_READY_CHECK);
             response.AddUInt64(client.Character.Guid);
             client.Character.Group.GetLeader().Client.Send(response);
             response.Dispose();
         }
     }
 }
Пример #5
0
        public void On_MSG_RANDOM_ROLL(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length - 1 < 13)
            {
                return;
            }
            packet.GetInt16();
            var minRoll = packet.GetInt32();
            var maxRoll = packet.GetInt32();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_RANDOM_ROLL [min={2} max={3}]", client.IP, client.Port, minRoll, maxRoll);
            var response = new PacketClass(Opcodes.MSG_RANDOM_ROLL);

            response.AddInt32(minRoll);
            response.AddInt32(maxRoll);
            response.AddInt32(_clusterServiceLocator.WorldCluster.Rnd.Next(minRoll, maxRoll));
            response.AddUInt64(client.Character.Guid);
            if (client.Character.IsInGroup)
            {
                client.Character.Group.Broadcast(response);
            }
            else
            {
                client.SendMultiplyPackets(response);
            }

            response.Dispose();
        }
Пример #6
0
 public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref ItemObject updateObject)
 {
     checked
     {
         packet.AddInt8((byte)updateType);
         packet.AddPackGUID(updateObject.GUID);
         if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT)
         {
             if (WorldServiceLocator._WorldServer.ITEMDatabase[updateObject.ItemEntry].ContainerSlots > 0)
             {
                 packet.AddInt8(2);
             }
             else
             {
                 packet.AddInt8(1);
             }
             packet.AddInt8(24);
             packet.AddUInt64(updateObject.GUID);
         }
         if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_VALUES)
         {
             var updateCount = 0;
             var num         = UpdateMask.Count - 1;
             for (var j = 0; j <= num; j++)
             {
                 if (UpdateMask.Get(j))
                 {
                     updateCount = j;
                 }
             }
             packet.AddInt8((byte)(checked (updateCount + 32) / 32));
             packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4);
             var num2 = UpdateMask.Count - 1;
             for (var i = 0; i <= num2; i++)
             {
                 if (UpdateMask.Get(i))
                 {
                     if (UpdateData[i] is uint)
                     {
                         packet.AddUInt32(Conversions.ToUInteger(UpdateData[i]));
                     }
                     else if (UpdateData[i] is float)
                     {
                         packet.AddSingle(Conversions.ToSingle(UpdateData[i]));
                     }
                     else
                     {
                         packet.AddInt32(Conversions.ToInteger(UpdateData[i]));
                     }
                 }
             }
             UpdateMask.SetAll(value: false);
         }
         if (packet is UpdatePacketClass @class)
         {
             @class.UpdatesCount++;
         }
     }
 }
Пример #7
0
 public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_Corpses.CorpseObject updateObject)
 {
     checked
     {
         packet.AddInt8((byte)updateType);
         packet.AddPackGUID(updateObject.GUID);
         if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT)
         {
             packet.AddInt8(7);
             packet.AddInt8(88);
             packet.AddSingle(updateObject.positionX);
             packet.AddSingle(updateObject.positionY);
             packet.AddSingle(updateObject.positionZ);
             packet.AddSingle(updateObject.orientation);
             packet.AddUInt64(updateObject.GUID);
         }
         if (updateType == ObjectUpdateType.UPDATETYPE_CREATE_OBJECT || updateType == ObjectUpdateType.UPDATETYPE_VALUES)
         {
             int updateCount = 0;
             int num         = UpdateMask.Count - 1;
             for (int j = 0; j <= num; j++)
             {
                 if (UpdateMask.Get(j))
                 {
                     updateCount = j;
                 }
             }
             packet.AddInt8((byte)(checked (updateCount + 32) / 32));
             packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4);
             int num2 = UpdateMask.Count - 1;
             for (int i = 0; i <= num2; i++)
             {
                 if (UpdateMask.Get(i))
                 {
                     if (UpdateData[i] is uint)
                     {
                         packet.AddUInt32(Conversions.ToUInteger(UpdateData[i]));
                     }
                     else if (UpdateData[i] is float)
                     {
                         packet.AddSingle(Conversions.ToSingle(UpdateData[i]));
                     }
                     else
                     {
                         packet.AddInt32(Conversions.ToInteger(UpdateData[i]));
                     }
                 }
             }
             UpdateMask.SetAll(value: false);
         }
         if (packet is UpdatePacketClass @class)
         {
             @class.UpdatesCount++;
         }
     }
 }
Пример #8
0
        public void On_MSG_RAID_ICON_TARGET(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length < 7)
            {
                return; // Too short packet
            }
            if (client.Character.Group is null)
            {
                return;
            }
            packet.GetInt16();
            var icon = packet.GetInt8();

            if (icon == 255)
            {
                // DONE: Send icon target list
                var response = new PacketClass(Opcodes.MSG_RAID_ICON_TARGET);
                response.AddInt8(1); // Target list
                for (byte i = 0; i <= 7; i++)
                {
                    if (client.Character.Group.TargetIcons[i] == 0m)
                    {
                        continue;
                    }
                    response.AddInt8(i);
                    response.AddUInt64(client.Character.Group.TargetIcons[i]);
                }

                client.Send(response);
                response.Dispose();
            }
            else
            {
                if (icon > 7)
                {
                    return; // Not a valid icon
                }
                if (packet.Data.Length < 15)
                {
                    return; // Too short packet
                }
                var guid = packet.GetUInt64();

                // DONE: Set the raid icon target
                client.Character.Group.TargetIcons[icon] = guid;
                var response = new PacketClass(Opcodes.MSG_RAID_ICON_TARGET);
                response.AddInt8(0); // Set target
                response.AddInt8(icon);
                response.AddUInt64(guid);
                client.Character.Group.Broadcast(response);
                response.Dispose();
            }
        }
Пример #9
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);
        }
Пример #10
0
        public void On_MSG_MINIMAP_PING(PacketClass packet, ClientClass client)
        {
            packet.GetInt16();
            var x = packet.GetFloat();
            var y = packet.GetFloat();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_MINIMAP_PING [{2}:{3}]", client.IP, client.Port, x, y);
            if (client.Character.IsInGroup)
            {
                var response = new PacketClass(Opcodes.MSG_MINIMAP_PING);
                response.AddUInt64(client.Character.Guid);
                response.AddSingle(x);
                response.AddSingle(y);
                client.Character.Group.Broadcast(response);
                response.Dispose();
            }
        }
Пример #11
0
        public void On_CMSG_DEL_IGNORE(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_DEL_IGNORE", client.IP, client.Port);
            if (packet.Data.Length - 1 < 13)
            {
                return;
            }
            packet.GetInt16();
            var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS);
            var guid     = packet.GetUInt64();

            try
            {
                var q = new DataTable();
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE guid = {0} AND friend = {1};", client.Character.Guid, guid), ref q);
                if (q.Rows.Count > 0)
                {
                    var flags    = q.Rows[0].As <int>("flags");
                    var newFlags = (SocialFlag)flags ^ SocialFlag.SOCIAL_FLAG_IGNORED;
                    if ((newFlags & (SocialFlag.SOCIAL_FLAG_FRIEND | SocialFlag.SOCIAL_FLAG_IGNORED)) == 0)
                    {
                        _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("DELETE FROM character_social WHERE friend = {1} AND guid = {0};", client.Character.Guid, guid));
                    }
                    else
                    {
                        _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE character_social SET flags = {2} WHERE friend = {1} AND guid = {0};", client.Character.Guid, guid, newFlags));
                    }

                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_REMOVED);
                }
                else
                {
                    response.AddInt8((byte)FriendResult.FRIEND_IGNORE_NOT_FOUND);
                }
            }
            catch
            {
                response.AddInt8((byte)FriendResult.FRIEND_DB_ERROR);
            }

            response.AddUInt64(guid);
            client.Send(response);
            response.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port);
        }
Пример #12
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();
        }
Пример #13
0
        public void On_CMSG_NAME_QUERY(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length - 1 < 13)
            {
                return;
            }
            packet.GetInt16();
            var guid = packet.GetUInt64();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_NAME_QUERY [GUID={2:X}]", client.IP, client.Port, guid);
            if (_clusterServiceLocator.CommonGlobalFunctions.GuidIsPlayer(guid) && _clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid))
            {
                var smsgNameQueryResponse = new PacketClass(Opcodes.SMSG_NAME_QUERY_RESPONSE);
                smsgNameQueryResponse.AddUInt64(guid);
                smsgNameQueryResponse.AddString(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Name);
                smsgNameQueryResponse.AddInt32((byte)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Race);
                smsgNameQueryResponse.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Gender);
                smsgNameQueryResponse.AddInt32((byte)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe);
                smsgNameQueryResponse.AddInt8(0);
                client.Send(smsgNameQueryResponse);
                smsgNameQueryResponse.Dispose();
            }
            else
            {
                // DONE: Send it to the world server if it wasn't found in the cluster
                try
                {
                    client.Character.GetWorld.ClientPacket(client.Index, packet.Data);
                }
                catch
                {
                    _clusterServiceLocator.WcNetwork.WorldServer.Disconnect("NULL", new List <uint> {
                        client.Character.Map
                    });
                }
            }
        }
Пример #14
0
        public void SendGuildRoster(WcHandlerCharacter.CharacterObject objCharacter)
        {
            if (!objCharacter.IsInGuild)
            {
                return;
            }

            // DONE: Count the ranks
            byte guildRanksCount = 0;

            for (var i = 0; i <= 9; i++)
            {
                if (!string.IsNullOrEmpty(objCharacter.Guild.Ranks[i]))
                {
                    guildRanksCount = (byte)(guildRanksCount + 1);
                }
            }

            // DONE: Count the members
            var members = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query("SELECT char_online, char_guid, char_name, char_class, char_level, char_zone_id, char_logouttime, char_guildRank, char_guildPNote, char_guildOffNote FROM characters WHERE char_guildId = " + objCharacter.Guild.Id + ";", ref members);
            var response = new PacketClass(Opcodes.SMSG_GUILD_ROSTER);

            response.AddInt32(members.Rows.Count);
            response.AddString(objCharacter.Guild.Motd);
            response.AddString(objCharacter.Guild.Info);
            response.AddInt32(guildRanksCount);
            for (var i = 0; i <= 9; i++)
            {
                if (!string.IsNullOrEmpty(objCharacter.Guild.Ranks[i]))
                {
                    response.AddUInt32(objCharacter.Guild.RankRights[i]);
                }
            }

            var officer = objCharacter.IsGuildRightSet(GuildRankRights.GR_RIGHT_VIEWOFFNOTE);

            for (int i = 0, loopTo = members.Rows.Count - 1; i <= loopTo; i++)
            {
                if (members.Rows[i].As <byte>("char_online") == 1)
                {
                    response.AddUInt64(members.Rows[i].As <ulong>("char_guid"));
                    response.AddInt8(1);                         // OnlineFlag
                    response.AddString(members.Rows[i].As <string>("char_name"));
                    response.AddInt32(members.Rows[i].As <int>("char_guildRank"));
                    response.AddInt8(members.Rows[i].As <byte>("char_level"));
                    response.AddInt8(members.Rows[i].As <byte>("char_class"));
                    response.AddInt32(members.Rows[i].As <int>("char_zone_id"));
                    response.AddString(members.Rows[i].As <string>("char_guildPNote"));
                    if (officer)
                    {
                        response.AddString(members.Rows[i].As <string>("char_guildOffNote"));
                    }
                    else
                    {
                        response.AddInt8(0);
                    }
                }
                else
                {
                    response.AddUInt64(members.Rows[i].As <ulong>("char_guid"));
                    response.AddInt8(0);                         // OfflineFlag
                    response.AddString(members.Rows[i].As <string>("char_name"));
                    response.AddInt32(members.Rows[i].As <int>("char_guildRank"));
                    response.AddInt8(members.Rows[i].As <byte>("char_level"));
                    response.AddInt8(members.Rows[i].As <byte>("char_class"));
                    response.AddInt32(members.Rows[i].As <int>("char_zone_id"));
                    // 0 = < 1 hour / 0.1 = 2.4 hours / 1 = 24 hours (1 day)
                    // (Time logged out / 86400) = Days offline
                    var daysOffline = (float)((_clusterServiceLocator.Functions.GetTimestamp(DateAndTime.Now) - members.Rows[i].As <uint>("char_logouttime")) / (double)DateInterval.Day);
                    response.AddSingle(daysOffline); // Days offline
                    response.AddString(members.Rows[i].As <string>("char_guildPNote"));
                    if (officer)
                    {
                        response.AddString(members.Rows[i].As <string>("char_guildOffNote"));
                    }
                    else
                    {
                        response.AddInt8(0);
                    }
                }
            }

            objCharacter.Client.Send(response);
            response.Dispose();
        }
Пример #15
0
 public void AddToPacket(ref PacketClass packet, ObjectUpdateType updateType, ref WS_PlayerData.CharacterObject updateObject)
 {
     packet.AddInt8(checked ((byte)updateType));
     packet.AddPackGUID(updateObject.GUID);
     if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF)
     {
         packet.AddInt8(4);
     }
     if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF or ObjectUpdateType.UPDATETYPE_MOVEMENT)
     {
         var flags2 = updateObject.charMovementFlags & 0xFF;
         if (updateObject.OnTransport != null)
         {
             flags2 |= 0x2000000;
         }
         packet.AddInt8(112);
         packet.AddInt32(flags2);
         packet.AddInt32(WorldServiceLocator._WS_Network.MsTime());
         packet.AddSingle(updateObject.positionX);
         packet.AddSingle(updateObject.positionY);
         packet.AddSingle(updateObject.positionZ);
         packet.AddSingle(updateObject.orientation);
         if (((uint)flags2 & 0x2000000u) != 0)
         {
             packet.AddUInt64(updateObject.OnTransport.GUID);
             packet.AddSingle(updateObject.transportX);
             packet.AddSingle(updateObject.transportY);
             packet.AddSingle(updateObject.transportZ);
             packet.AddSingle(updateObject.orientation);
         }
         packet.AddInt32(0);
         packet.AddSingle(updateObject.WalkSpeed);
         packet.AddSingle(updateObject.RunSpeed);
         packet.AddSingle(updateObject.RunBackSpeed);
         packet.AddSingle(updateObject.SwimSpeed);
         packet.AddSingle(updateObject.SwimBackSpeed);
         packet.AddSingle(updateObject.TurnRate);
         packet.AddUInt32(WorldServiceLocator._CommonGlobalFunctions.GuidLow(updateObject.GUID));
     }
     checked
     {
         if (updateType is ObjectUpdateType.UPDATETYPE_CREATE_OBJECT or ObjectUpdateType.UPDATETYPE_VALUES or ObjectUpdateType.UPDATETYPE_CREATE_OBJECT_SELF)
         {
             var updateCount = 0;
             var num         = UpdateMask.Count - 1;
             for (var i = 0; i <= num; i++)
             {
                 if (UpdateMask.Get(i))
                 {
                     updateCount = i;
                 }
             }
             packet.AddInt8((byte)(checked (updateCount + 32) / 32));
             packet.AddBitArray(UpdateMask, checked ((byte)(checked (updateCount + 32) / 32)) * 4);
             var num2 = UpdateMask.Count - 1;
             for (var j = 0; j <= num2; j++)
             {
                 if (UpdateMask.Get(j))
                 {
                     if (UpdateData[j] is uint)
                     {
                         packet.AddUInt32(Conversions.ToUInteger(UpdateData[j]));
                     }
                     else if (UpdateData[j] is float)
                     {
                         packet.AddSingle(Conversions.ToSingle(UpdateData[j]));
                     }
                     else
                     {
                         packet.AddInt32(Conversions.ToInteger(UpdateData[j]));
                     }
                 }
             }
             UpdateMask.SetAll(value: false);
         }
         if (packet is UpdatePacketClass @class)
         {
             @class.UpdatesCount++;
         }
     }
 }
Пример #16
0
        public void On_CMSG_ADD_FRIEND(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length - 1 < 6)
            {
                return;
            }
            packet.GetInt16();
            var response = new PacketClass(Opcodes.SMSG_FRIEND_STATUS);
            var name     = packet.GetString();
            var guid     = 0UL;

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_ADD_FRIEND [{2}]", client.IP, client.Port, name);

            // DONE: Get GUID from DB
            var q = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT char_guid, char_race FROM characters WHERE char_name = \"{0}\";", name), ref q);
            if (q.Rows.Count > 0)
            {
                guid = (ulong)q.Rows[0].As <long>("char_guid");
                var friendSide = _clusterServiceLocator.Functions.GetCharacterSide(q.Rows[0].As <byte>("char_race"));
                q.Clear();
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE flags = {0}", Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q);
                var numberOfFriends = q.Rows.Count;
                q.Clear();
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT flags FROM character_social WHERE guid = {0} AND friend = {1} AND flags = {2};", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)), ref q);
                if (guid == client.Character.Guid)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_SELF);
                    response.AddUInt64(guid);
                }
                else if (q.Rows.Count > 0)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_ALREADY);
                    response.AddUInt64(guid);
                }
                else if (numberOfFriends >= (int)SocialList.MAX_FRIENDS_ON_LIST)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_LIST_FULL);
                    response.AddUInt64(guid);
                }
                else if (_clusterServiceLocator.Functions.GetCharacterSide((byte)client.Character.Race) != friendSide)
                {
                    response.AddInt8((byte)FriendResult.FRIEND_ENEMY);
                    response.AddUInt64(guid);
                }
                else if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid))
                {
                    response.AddInt8((byte)FriendResult.FRIEND_ADDED_ONLINE);
                    response.AddUInt64(guid);
                    response.AddString(name);
                    if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Dnd)
                    {
                        response.AddInt8((byte)FriendStatus.FRIEND_STATUS_DND);
                    }
                    else if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].Afk)
                    {
                        response.AddInt8((byte)FriendStatus.FRIEND_STATUS_AFK);
                    }
                    else
                    {
                        response.AddInt8((byte)FriendStatus.FRIEND_STATUS_ONLINE);
                    }

                    response.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Zone);
                    response.AddInt32(_clusterServiceLocator.WorldCluster.CharacteRs[guid].Level);
                    response.AddInt32((int)_clusterServiceLocator.WorldCluster.CharacteRs[guid].Classe);
                    _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)));
                }
                else
                {
                    response.AddInt8((byte)FriendResult.FRIEND_ADDED_OFFLINE);
                    response.AddUInt64(guid);
                    response.AddString(name);
                    _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO character_social (guid, friend, flags) VALUES ({0}, {1}, {2});", client.Character.Guid, guid, Conversions.ToByte(SocialFlag.SOCIAL_FLAG_FRIEND)));
                }
            }
            else
            {
                response.AddInt8((byte)FriendResult.FRIEND_NOT_FOUND);
                response.AddUInt64(guid);
            }

            client.Send(response);
            response.Dispose();
            q.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_FRIEND_STATUS", client.IP, client.Port);
        }