Exemplo n.º 1
0
        public void On_CMSG_REQUEST_RAID_INFO(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_REQUEST_RAID_INFO", client.IP, client.Port);
            var q = new DataTable();

            if (client.Character is object)
            {
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters_instances WHERE char_guid = {0};", client.Character.Guid), ref q);
            }

            var response = new PacketClass(Opcodes.SMSG_RAID_INSTANCE_INFO);

            response.AddInt32(q.Rows.Count);                                 // Instances Counts
            var i = 0;

            foreach (DataRow r in q.Rows)
            {
                response.AddUInt32(Conversions.ToUInteger(r["map"]));                                                                            // MapID
                response.AddUInt32((uint)(Conversions.ToInteger(r["expire"]) - _clusterServiceLocator.Functions.GetTimestamp(DateAndTime.Now))); // TimeLeft
                response.AddUInt32(Conversions.ToUInteger(r["instance"]));                                                                       // InstanceID
                response.AddUInt32((uint)i);                                                                                                     // Counter
                i += 1;
            }

            client.Send(response);
            response.Dispose();
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public void On_MSG_MOVE_START_FORWARD(PacketClass packet, ClientClass client)
        {
            try
            {
                client.Character.GetWorld.ClientPacket(client.Index, packet.Data);
                _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_MOVE_START_FOWARD [{2}]", client.IP, client.Port, client.Character.Map);
            }
            catch
            {
                _clusterServiceLocator.WcNetwork.WorldServer.Disconnect("NULL", new List <uint> {
                    client.Character.Map
                });
                _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.WARNING, "[{0}:{1}] MSG_MOVE_START_FOWARD error occured [{2}]", client.IP, client.Port, client.Character.Map);
                return;
            }

            // DONE: Save location on cluster
            client.Character.PositionX = packet.GetFloat(); // (15)
            client.Character.PositionY = packet.GetFloat();
            client.Character.PositionZ = packet.GetFloat();

            // DONE: Sync your location to other party / raid members
            if (client.Character.IsInGroup)
            {
                var statsPacket = new PacketClass(Opcodes.UMSG_UPDATE_GROUP_MEMBERS)
                {
                    Data = client.Character.GetWorld.GroupMemberStats(client.Character.Guid, (int)Functions.PartyMemberStatsFlag.GROUP_UPDATE_FLAG_POSITION + (int)Functions.PartyMemberStatsFlag.GROUP_UPDATE_FLAG_ZONE)
                };
                client.Character.Group.BroadcastToOutOfRange(statsPacket, client.Character);
                statsPacket.Dispose();
            }
        }
Exemplo n.º 4
0
        public void On_CMSG_GMTICKET_CREATE(PacketClass packet, ClientClass client)
        {
            packet.GetInt16();
            var ticketMap   = packet.GetUInt32();
            var ticketX     = packet.GetFloat();
            var ticketY     = packet.GetFloat();
            var ticketZ     = packet.GetFloat();
            var ticketText  = _clusterServiceLocator.Functions.EscapeString(packet.GetString());
            var mySqlResult = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters_tickets WHERE char_guid = {0};", client.Character.Guid), ref mySqlResult);
            var smsgGmticketCreate = new PacketClass(Opcodes.SMSG_GMTICKET_CREATE);

            if (mySqlResult.Rows.Count > 0)
            {
                _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GMTICKET_CREATE", client.IP, client.Port);
                smsgGmticketCreate.AddInt32((int)GmTicketCreateResult.GMTICKET_ALREADY_HAVE);
            }
            else
            {
                _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GMTICKET_CREATE [{2}]", client.IP, client.Port, ticketText);
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("INSERT INTO characters_tickets (char_guid, ticket_text, ticket_x, ticket_y, ticket_z, ticket_map) VALUES ({0} , \"{1}\", {2}, {3}, {4}, {5});", client.Character.Guid, ticketText, Strings.Trim(Conversion.Str(ticketX)), Strings.Trim(Conversion.Str(ticketY)), Strings.Trim(Conversion.Str(ticketZ)), ticketMap));
                smsgGmticketCreate.AddInt32((int)GmTicketCreateResult.GMTICKET_CREATE_OK);
            }

            client.Send(smsgGmticketCreate);
            smsgGmticketCreate.Dispose();
        }
Exemplo n.º 5
0
        public void SendGuildQuery(ClientClass client, uint guildId)
        {
            if (guildId == 0L)
            {
                return;
            }
            // WARNING: This opcode is used also in character enum, so there must not be used any references to CharacterObject, only ClientClass

            // DONE: Load the guild if it doesn't exist in the memory
            if (GuilDs.ContainsKey(guildId) == false)
            {
                var tmpGuild = new Guild(guildId);
                GuilDs.Add(guildId, tmpGuild);
            }

            var response = new PacketClass(Opcodes.SMSG_GUILD_QUERY_RESPONSE);

            response.AddUInt32(guildId);
            response.AddString(GuilDs[guildId].Name);
            for (var i = 0; i <= 9; i++)
            {
                response.AddString(GuilDs[guildId].Ranks[i]);
            }
            response.AddInt32(GuilDs[guildId].EmblemStyle);
            response.AddInt32(GuilDs[guildId].EmblemColor);
            response.AddInt32(GuilDs[guildId].BorderStyle);
            response.AddInt32(GuilDs[guildId].BorderColor);
            response.AddInt32(GuilDs[guildId].BackgroundColor);
            response.AddInt32(0);
            client.Send(response);
            response.Dispose();
        }
Exemplo n.º 6
0
        public void On_CMSG_GMTICKET_GETTICKET(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GMTICKET_GETTICKET", client.IP, client.Port);
            var smsgGmticketGetticket = new PacketClass(Opcodes.SMSG_GMTICKET_GETTICKET);
            var mySqlResult           = new DataTable();

            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters_tickets WHERE char_guid = {0};", client.Character.Guid), ref mySqlResult);
            if (mySqlResult.Rows.Count > 0)
            {
                smsgGmticketGetticket.AddInt32((int)GmTicketGetResult.GMTICKET_AVAILABLE);
                smsgGmticketGetticket.AddString(Conversions.ToString(mySqlResult.Rows[0]["ticket_text"]));
            }
            else
            {
                smsgGmticketGetticket.AddInt32((int)GmTicketGetResult.GMTICKET_NOTICKET);
            }

            client.Send(smsgGmticketGetticket);
            smsgGmticketGetticket.Dispose();
            var smsgQueryTimeResponse = new PacketClass(Opcodes.SMSG_QUERY_TIME_RESPONSE);

            smsgQueryTimeResponse.AddInt32(_clusterServiceLocator.NativeMethods.timeGetTime("")); // GetTimestamp(Now))
            client.Send(smsgQueryTimeResponse);
            smsgQueryTimeResponse.Dispose();
        }
Exemplo n.º 7
0
            public void SendChatMessage(WcHandlerCharacter.CharacterObject sender, string message, LANGUAGES language, ChatMsg thisType)
            {
                PacketClass packet = _clusterServiceLocator.Functions.BuildChatMessage(sender.Guid, message, thisType, language, (byte)sender.ChatFlag);

                Broadcast(packet);
                packet.Dispose();
            }
Exemplo n.º 8
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();
         }
     }
 }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
0
        public void On_CMSG_GUILD_LEAVE(PacketClass packet, ClientClass client)
        {
            // packet.GetInt16()

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

            // DONE: Checks
            if (!client.Character.IsInGuild)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD);
                return;
            }

            if (client.Character.IsGuildLeader)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_QUIT_S, GuildError.GUILD_LEADER_LEAVE);
                return;
            }

            _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(client.Character);
            _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_QUIT_S, GuildError.GUILD_PLAYER_NO_MORE_IN_GUILD, client.Character.Name);
            var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT);

            response.AddInt8((byte)GuildEvent.LEFT);
            response.AddInt8(1);
            response.AddString(client.Character.Name);
            var argnotTo = 0UL;

            _clusterServiceLocator.WcGuild.BroadcastToGuild(response, client.Character.Guild, notTo: argnotTo);
            response.Dispose();
        }
Exemplo n.º 11
0
        public void On_CMSG_REQUEST_PARTY_MEMBER_STATS(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_REQUEST_PARTY_MEMBER_STATS [{2:X}]", client.IP, client.Port, guid);
            if (!_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(guid))
            {
                // Character is offline
                var response = _clusterServiceLocator.Functions.BuildPartyMemberStatsOffline(guid);
                client.Send(response);
                response.Dispose();
            }
            else if (_clusterServiceLocator.WorldCluster.CharacteRs[guid].IsInWorld == false)
            {
                // Character is offline (not in world)
                var response = _clusterServiceLocator.Functions.BuildPartyMemberStatsOffline(guid);
                client.Send(response);
                response.Dispose();
            }
            else
            {
                // Request information from WorldServer
                var response = new PacketClass(0)
                {
                    Data = _clusterServiceLocator.WorldCluster.CharacteRs[guid].GetWorld.GroupMemberStats(guid, 0)
                };
                client.Send(response);
                response.Dispose();
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void On_CMSG_GMTICKET_SYSTEMSTATUS(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GMTICKET_SYSTEMSTATUS", client.IP, client.Port);
            var smsgGmticketSystemstatus = new PacketClass(Opcodes.SMSG_GMTICKET_SYSTEMSTATUS);

            smsgGmticketSystemstatus.AddInt32((int)GmTicketSystemStatus.GMTICKET_SYSTEMSTATUS_SURVEY);
            client.Send(smsgGmticketSystemstatus);
            smsgGmticketSystemstatus.Dispose();
        }
Exemplo n.º 14
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();
                    }
                }
            }
Exemplo n.º 15
0
        public void SendPartyResult(ClientClass objCharacter, string name, PartyCommand operation, PartyCommandResult result)
        {
            var response = new PacketClass(Opcodes.SMSG_PARTY_COMMAND_RESULT);

            response.AddInt32((byte)operation);
            response.AddString(name);
            response.AddInt32((byte)result);
            objCharacter.Send(response);
            response.Dispose();
        }
Exemplo n.º 16
0
        public void SendGuildResult(ClientClass client, GuildCommand command, GuildError result, string text = "")
        {
            var response = new PacketClass(Opcodes.SMSG_GUILD_COMMAND_RESULT);

            response.AddInt32((int)command);
            response.AddString(text);
            response.AddInt32((int)result);
            client.Send(response);
            response.Dispose();
        }
Exemplo n.º 17
0
        public void On_CMSG_QUERY_TIME(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_QUERY_TIME", client.IP, client.Port);
            var response = new PacketClass(Opcodes.SMSG_QUERY_TIME_RESPONSE);

            response.AddInt32(_clusterServiceLocator.NativeMethods.timeGetTime("")); // GetTimestamp(Now))
            client.Send(response);
            response.Dispose();
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_QUERY_TIME_RESPONSE", client.IP, client.Port);
        }
Exemplo n.º 18
0
        public void On_CMSG_GMTICKET_DELETETICKET(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GMTICKET_DELETETICKET", client.IP, client.Port);
            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("DELETE FROM characters_tickets WHERE char_guid = {0};", client.Character.Guid));
            var smsgGmticketDeleteticket = new PacketClass(Opcodes.SMSG_GMTICKET_DELETETICKET);

            smsgGmticketDeleteticket.AddInt32((int)GmTicketDeleteResult.GMTICKET_DELETE_SUCCESS);
            client.Send(smsgGmticketDeleteticket);
            smsgGmticketDeleteticket.Dispose();
        }
Exemplo n.º 19
0
        public void On_CMSG_PLAYED_TIME(PacketClass packet, ClientClass client)
        {
            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_NAME_QUERY", client.IP, client.Port);
            var response = new PacketClass(Opcodes.SMSG_PLAYED_TIME);

            response.AddInt32(1);
            response.AddInt32(1);
            client.Send(response);
            response.Dispose();
        }
Exemplo n.º 20
0
 public void On_CMSG_GUILD_DECLINE(PacketClass packet, ClientClass client)
 {
     client.Character.GuildInvited = 0U;
     if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey((ulong)Conversions.ToLong(client.Character.GuildInvitedBy)))
     {
         var response = new PacketClass(Opcodes.SMSG_GUILD_DECLINE);
         response.AddString(client.Character.Name);
         _clusterServiceLocator.WorldCluster.CharacteRs[(ulong)Conversions.ToLong(client.Character.GuildInvitedBy)].Client.Send(response);
         response.Dispose();
     }
 }
Exemplo n.º 21
0
        public void On_MSG_SAVE_GUILD_EMBLEM(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length < 34)
            {
                return;
            }
            packet.GetInt16();
            var unk0             = packet.GetInt32();
            var unk1             = packet.GetInt32();
            var tEmblemStyle     = packet.GetInt32();
            var tEmblemColor     = packet.GetInt32();
            var tBorderStyle     = packet.GetInt32();
            var tBorderColor     = packet.GetInt32();
            var tBackgroundColor = packet.GetInt32();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_SAVE_GUILD_EMBLEM [{2},{3}] [{4}:{5}:{6}:{7}:{8}]", client.IP, client.Port, unk0, unk1, tEmblemStyle, tEmblemColor, tBorderStyle, tBorderColor, tBackgroundColor);
            if (!client.Character.IsInGuild)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD);
                return;
            }

            if (!client.Character.IsGuildLeader)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS);
                return;

                // TODO: Check if you have enough money
                // ElseIf client.Character.Copper < 100000 Then
                // SendInventoryChangeFailure(Client.Character, InventoryChangeFailure.EQUIP_ERR_NOT_ENOUGH_MONEY, 0, 0)
                // Exit Sub
            }

            client.Character.Guild.EmblemStyle     = (byte)tEmblemStyle;
            client.Character.Guild.EmblemColor     = (byte)tEmblemColor;
            client.Character.Guild.BorderStyle     = (byte)tBorderStyle;
            client.Character.Guild.BorderColor     = (byte)tBorderColor;
            client.Character.Guild.BackgroundColor = (byte)tBackgroundColor;
            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE guilds SET guild_tEmblemStyle = {1}, guild_tEmblemColor = {2}, guild_tBorderStyle = {3}, guild_tBorderColor = {4}, guild_tBackgroundColor = {5} WHERE guild_id = {0};", client.Character.Guild.Id, tEmblemStyle, tEmblemColor, tBorderStyle, tBorderColor, tBackgroundColor));
            _clusterServiceLocator.WcGuild.SendGuildQuery(client, client.Character.Guild.Id);
            var packetEvent = new PacketClass(Opcodes.SMSG_GUILD_EVENT);

            packetEvent.AddInt8((byte)GuildEvent.TABARDCHANGE);
            packetEvent.AddInt32((int)client.Character.Guild.Id);
            var argnotTo = 0UL;

            _clusterServiceLocator.WcGuild.BroadcastToGuild(packetEvent, client.Character.Guild, notTo: argnotTo);
            packetEvent.Dispose();

            // TODO: This tabard design costs 10g!
            // Client.Character.Copper -= 100000
            // Client.Character.SetUpdateFlag(EPlayerFields.PLAYER_FIELD_COINAGE, client.Character.Copper)
            // Client.Character.SendCharacterUpdate(False)
        }
Exemplo n.º 22
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();
            }
        }
Exemplo n.º 23
0
        public void On_CMSG_WHOIS(PacketClass packet, ClientClass client)
        {
            packet.GetInt16();
            var name = packet.GetString();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_WHOIS [{2}]", client.IP, client.Port, name);
            var response = new PacketClass(Opcodes.SMSG_WHOIS);

            response.AddString("This feature is not available yet.");
            client.Send(response);
            response.Dispose();
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        public void On_MSG_BATTLEGROUND_PLAYER_POSITIONS(PacketClass packet, ClientClass client)
        {
            var p = new PacketClass(Opcodes.MSG_BATTLEGROUND_PLAYER_POSITIONS);

            try
            {
                p.AddUInt32(0U);
                p.AddUInt32(0U); // flagCarrierCount
            }
            finally
            {
                p.Dispose();
            }
        }
Exemplo n.º 26
0
        public void On_CMSG_REQUEST_ACCOUNT_DATA(PacketClass packet, ClientClass client)
        {
            if (packet.Data.Length - 1 < 9)
            {
                return;
            }
            packet.GetInt16();
            var dataId = packet.GetUInt32();

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_REQUEST_ACCOUNT_DATA [ID={2}]", client.IP, client.Port, dataId);
            if (dataId > 7L)
            {
                return;
            }

            // Dim AccData As New DataTable
            // _WorldCluster.AccountDatabase.Query(String.Format("SELECT account_id FROM accounts WHERE username = ""{0}"";", client.Account), AccData)
            // If AccData.Rows.Count > 0 Then
            // Dim AccID As Integer = CType(AccData.Rows(0).Item("account_id"), Integer)
            //
            // AccData.Clear()
            // _WorldCluster.AccountDatabase.Query(String.Format("SELECT `account_data{1}` FROM account_data WHERE account_id = {0}", AccID, DataID), AccData)
            // If AccData.Rows.Count > 0 Then FoundData = True
            // End If

            var response = new PacketClass(Opcodes.SMSG_UPDATE_ACCOUNT_DATA);

            response.AddUInt32(dataId);

            // If FoundData = False Then
            response.AddInt32(0); // Uncompressed buffer length
                                  // Else
                                  // Dim AccountData() As Byte = AccData.Rows(0).Item("account_data" & DataID)
                                  // If AccountData.Length > 0 Then
                                  // response.AddInt32(AccountData.Length) 'Uncompressed buffer length
                                  // DONE: Compress buffer if it's longer than 200 bytes
                                  // If AccountData.Length > 200 Then
                                  // Dim CompressedBuffer() As Byte = Compress(AccountData, 0, AccountData.Length)
                                  // response.AddByteArray(CompressedBuffer)
                                  // Else
                                  // response.AddByteArray(AccountData)
                                  // End If
                                  // Else
                                  // response.AddInt32(0) 'Uncompressed buffer length
                                  // End If
                                  // End If

            client.Send(response);
            response.Dispose();
        }
Exemplo n.º 27
0
 public void On_CMSG_GROUP_DECLINE(PacketClass packet, ClientClass client)
 {
     _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GROUP_DECLINE", client.IP, client.Port);
     if (client.Character.GroupInvitedFlag)
     {
         var response = new PacketClass(Opcodes.SMSG_GROUP_DECLINE);
         response.AddString(client.Character.Name);
         client.Character.Group.GetLeader().Client.Send(response);
         response.Dispose();
         client.Character.Group.CheckMembers();
         client.Character.Group            = null;
         client.Character.GroupInvitedFlag = false;
     }
 }
Exemplo n.º 28
0
 // Members Options
 public void SendGuildMotd(WcHandlerCharacter.CharacterObject objCharacter)
 {
     if (objCharacter.IsInGuild)
     {
         if (!string.IsNullOrEmpty(objCharacter.Guild.Motd))
         {
             var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT);
             response.AddInt8((byte)GuildEvent.MOTD);
             response.AddInt8(1);
             response.AddString(objCharacter.Guild.Motd);
             objCharacter.Client.Send(response);
             response.Dispose();
         }
     }
 }
Exemplo n.º 29
0
            public void Transfer(float posX, float posY, float posZ, float ori)
            {
                var p = new PacketClass(Opcodes.SMSG_TRANSFER_PENDING);

                p.AddInt32((int)Map);
                Client.Send(p);
                p.Dispose();

                // Actions Here
                IsInWorld = false;
                GetWorld.ClientDisconnect(Client.Index);
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE characters SET char_positionX = {0}, char_positionY = {1}, char_positionZ = {2}, char_orientation = {3}, char_map_id = {4} WHERE char_guid = {5};", Strings.Trim(Conversion.Str(posX)), Strings.Trim(Conversion.Str(posY)), Strings.Trim(Conversion.Str(posZ)), Strings.Trim(Conversion.Str(ori)), Map, Guid));

                // Do global transfer
                _clusterServiceLocator.WcNetwork.WorldServer.ClientTransfer(Client.Index, posX, posY, posZ, ori, Map);
            }
Exemplo n.º 30
0
        public void On_CMSG_GUILD_DISBAND(PacketClass packet, ClientClass client)
        {
            // packet.GetInt16()

            _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GUILD_DISBAND", client.IP, client.Port);
            if (!client.Character.IsInGuild)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PLAYER_NOT_IN_GUILD);
                return;
            }

            if (!client.Character.IsGuildLeader)
            {
                _clusterServiceLocator.WcGuild.SendGuildResult(client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_PERMISSIONS);
                return;
            }

            // DONE: Clear all members
            var response = new PacketClass(Opcodes.SMSG_GUILD_EVENT);

            response.AddInt8((byte)GuildEvent.DISBANDED);
            response.AddInt8(0);
            var guildId  = (int)client.Character.Guild.Id;
            var tmpArray = client.Character.Guild.Members.ToArray();

            foreach (var member in tmpArray)
            {
                if (_clusterServiceLocator.WorldCluster.CharacteRs.ContainsKey(member))
                {
                    var tmp             = _clusterServiceLocator.WorldCluster.CharacteRs;
                    var argobjCharacter = tmp[member];
                    _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(argobjCharacter);
                    tmp[member] = argobjCharacter;
                    _clusterServiceLocator.WorldCluster.CharacteRs[member].Client.SendMultiplyPackets(response);
                }
                else
                {
                    _clusterServiceLocator.WcGuild.RemoveCharacterFromGuild(member);
                }
            }

            _clusterServiceLocator.WcGuild.GuilDs[(uint)guildId].Dispose();
            response.Dispose();

            // DONE: Delete guild information
            _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update("DELETE FROM guilds WHERE guild_id = " + guildId + ";");
        }