Exemplo n.º 1
0
            static bool OnGuildInfo(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild tguild = client.Character.Guild;

                tguild.GuildInfo = data.ReadString();
                DataServer.Database.SaveObject(tguild);
                BinWriter gpkg = LoginClient.NewPacket(SMSG.GUILD_INFO);

                gpkg.Write(tguild.ObjectId);
                gpkg.Write(tguild.GuildInfo);
//				gpkg.Write(rankname);
                client.Send(gpkg);

                return(true);
            }             //OnGuildRoster
Exemplo n.º 2
0
        static bool BankBuySlot(LoginClient client, CMSG msgID, BinReader data)
        {
            //TODO SLOT 63 TO 70 ARE NOT WORKING (PURCHASABLE SLOTS ON BANK)

            ulong vendorGUID = data.ReadUInt64();
            uint  slot       = data.ReadUInt32();

            //BinWriter pkg = LoginClient.NewPacket(SMSG.BUY_BANK_SLOT_RESULT);
            //pkg.Write(0);
            //client.Send(pkg);

            Chat.System(client, "Buying Bank Slot Number " + slot + " on banker " + vendorGUID);

            return(true);
        }
Exemplo n.º 3
0
 static void OnWorldPortAck(WorldClient client, CMSG msgID, BinReader data)
 {
     if (client.Player.MapTile == null)
     {
         client.CreatePlayerObject();
         MapInstance map = GetMap(client.Player.WorldMapID);
         if (map == null)
         {
             Console.WriteLine("Error worldserver received MOVE_WORLDPORT_ACK for a worldmap it wasn't handling.");
             client.LeaveWorld();
             return;
         }
         map.Enter(client.Player);
     }
 }
        static void OnStandStateChange(WorldClient client, CMSG msgID, BinReader data)
        {
            if (client.Player.MountDisplayID != 0)
            {
                return;
            }

            if (data.BaseStream.Length > (data.BaseStream.Position + 8))
            {
                data.BaseStream.Position += 8;

                client.Player.StandState = (UNITSTANDSTATE)data.ReadByte();
                client.Player.UpdateData();
            }
        }
Exemplo n.º 5
0
        static bool OnMessageChat(LoginClient client, CMSG msgID, BinReader data)
        {
            CHATMESSAGETYPE type = (CHATMESSAGETYPE)data.ReadInt32();

            /*int language =*/ data.ReadInt32();
            string target = string.Empty;

            if (type == CHATMESSAGETYPE.WHISPER)
            {
                target = data.ReadString(0x100);
            }
            string msg = data.ReadString(0x100);

            if (msg.StartsWith("!") || msg.StartsWith("%"))
            {
                return(OnChatCommand(client, msg.Substring(1)));
            }
            switch (type)
            {
            case CHATMESSAGETYPE.SAY:
            case CHATMESSAGETYPE.YELL:
            case CHATMESSAGETYPE.EMOTE:
                return(false);                        // let worldserver handle it

            case CHATMESSAGETYPE.WHISPER:
            {
                DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBCharacter), "Name = '" + target + "'");
                if (objs.Length == 0)
                {
                    Chat.System(client, "No such player.");
                    return(true);
                }
                LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(objs[0].ObjectId);
                if (targetClient == null || targetClient.Character == null)
                {
                    Chat.System(client, "That player is not online.");
                    return(true);
                }
                Chat.Whisper(client, targetClient, msg);
                break;
            }

            default:
                Chat.System(client, "Received " + type + ": " + msg);
                break;
            }
            return(true);
        }
Exemplo n.º 6
0
        static bool TaxiActivate(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong taxiGUID  = data.ReadUInt64();
            uint  startnode = data.ReadUInt32();
            uint  destnode  = data.ReadUInt32();

            BinWriter pkg = LoginClient.NewPacket(SMSG.ACTIVATETAXIREPLY);

            pkg.Write((int)10);             // Code*

            client.Send(pkg);

            Chat.System(client, "Activate Taxi Working...");

            return(true);
        }
Exemplo n.º 7
0
        static bool GroupDecline(LoginClient client, CMSG msgID, BinReader data)
        {
            LoginClient inviter = LoginServer.GetLoginClientByCharacterID(client.Character.LastGroupInviterID);

            client.Character.LastGroupInviterID = 0;
            if (inviter == null)
            {
                return(true);
            }

            BinWriter pkg = LoginClient.NewPacket(SMSG.GROUP_DECLINE);

            pkg.Write(client.Character.Name);
            inviter.Send(pkg);
            return(true);
        }
Exemplo n.º 8
0
            static bool OnGuildMOTD(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild tguild = client.Character.Guild;

                if ((tguild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.SET_MOTD) != (uint)GUILDFLAGS.SET_MOTD)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                tguild.MOTD = data.ReadString();
                DataServer.Database.SaveObject(tguild);
                SendRoster(client, tguild);
                GuildMessage(tguild, "MOTD: " + tguild.MOTD);
                return(true);
            }             //OnGuildRoster
Exemplo n.º 9
0
        static bool TaxiQueryNodes(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong taxiGUID = data.ReadUInt64();

            BinWriter pkg = LoginClient.NewPacket(SMSG.SHOWTAXINODES);

            pkg.Write((int)1);                          // Show Map
            pkg.Write(taxiGUID);
            pkg.Write((int)11);                         // Node Location*

            client.Send(pkg);

            Chat.System(client, "Query Avaliable Nodes Working");

            return(true);
        }
Exemplo n.º 10
0
        static bool ClearTradeItem(LoginClient client, CMSG msgID, BinReader data)
        {
            uint inviteeGUID = client.Character.LastTradeID;

            uint count = client.Character.TradeItemCount--;

            LoginClient invitee = LoginServer.GetLoginClientByCharacterID((uint)inviteeGUID);

            byte slot = data.ReadByte();

            Chat.System(client, "Clear Trade Item from slot " + slot + " Working");

            invitee.Character.TradeCompleted = false;

            return(true);
        }
Exemplo n.º 11
0
            static bool OnGuildAddRank(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild tguild = client.Character.Guild;

                if (tguild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }
                tguild.MaxRank++;
                tguild.setRankName(tguild.MaxRank, data.ReadString());
                DataServer.Database.SaveObject(tguild);
                UpdateGuild(client);
                SendRoster(client, tguild);
                return(true);
            }             //OnGuildAddRank
Exemplo n.º 12
0
        static bool BuyItemVendor(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong vendorGUID2 = data.ReadUInt64();
            int   itembuy     = data.ReadInt32();
            byte  targetslot  = 0;

            if (msgID == CMSG.BUY_ITEM_IN_SLOT)
            {
                data.ReadUInt64();
                targetslot = data.ReadByte();
            }
            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + vendorGUID2 + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }

            DBVendor tvendor = (DBVendor)obj[0];

            foreach (DBVendorItem item in tvendor.VendorItems)
            {
                if (item.TemplateID == itembuy)
                {
                    DBItem newItem = new DBItem();
                    newItem.OwnerID    = client.Character.ObjectId;
                    newItem.OwnerSlot  = targetslot;                    //temp, checks for open slot on world side
                    newItem.TemplateID = item.TemplateID;
                    newItem.Template   = item.Template;
                    DataServer.Database.AddNewObject(newItem);
                    client.WorldConnection.Send(newItem);

                    ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM);

                    Item.Write(client.Character.ObjectId);
                    Item.Write(newItem.ObjectId);
                    Item.Write(item.Price);
//					Item.Write(23); // NEED TO MAKE THE SCRIPT SEND TO NEXT-FREE-SLOT, INSTEAD OF FIRST
                    client.WorldConnection.Send(Item);

//					Chat.System(client, "Buy Item Working, Vendor GUI = "+vendorGUID2+" and item = "+itembuy+" on LoginServer");
                    return(true);
                }
            }
            Chat.System(client, "Item not found on this vendor");
            return(true);
        }
Exemplo n.º 13
0
        public override void OnClientData(ClientBase aClient, byte[] data)
        {
            LoginClient client = aClient as LoginClient;
            BinReader   read   = new BinReader(data);

            read.BaseStream.Position += 2;             // skip len
            CMSG msgID = (CMSG)read.ReadInt32();

            if (!LoginPacketManager.HandlePacket(client, msgID, read))
            {
                if (client.WorldConnection != null)
                {
                    ClientPacket pkg = new ClientPacket(msgID, client.Character.ObjectId, data, 6, data.Length - 6);
                    client.SendWorldServer(pkg);
                }
            }
        }
 public static void HandlePacket(WorldClient client, CMSG msgID, BinReader data)
 {
     try {
         IWorldClientPacketHandler handler = (IWorldClientPacketHandler)worldClientHandlers[msgID];
         if (handler != null)
         {
             handler.HandlePacket(client, msgID, data);
         }
         WorldClientPacketDelegate wcpd = (WorldClientPacketDelegate)worldClientDelegates[(int)msgID];
         if (wcpd != null)
         {
             wcpd(client, msgID, data);
         }
     } catch (Exception exp) {
         DebugLogger.Log("", exp);
     }
 }
Exemplo n.º 15
0
        static void OnJoin(WorldClient client, CMSG msgID, BinReader data)
        {
            string ChanName = (string)data.ReadString();

            if (ChanName != null)
            {
                Channel Chan;
                if ((Chan = ChanExists(ChanName)) != null)
                {
                    Chan.Join(client);
                }
                else
                {
                    Chan = new Channel(ChanName, client);
                    Channels.Add(Chan);
                }
            }
        }
Exemplo n.º 16
0
        static void OnLootMoney(WorldClient client, CMSG msgID, BinReader data)
        {
            // TODO: Group support and loot order for group
            if (client.Player.Selection == null)
            {
                Chat.System(client, "Invalid corpsetarget.");
            }
            else
            {
                UnitBase target = (UnitBase)client.Player.Selection;
                client.Player.Money += target.Money;
                client.Player.UpdateData();
                Chat.System(client, "You looted " + target.Money + " coins.");
                target.Money = 0;
//				target.UpdateData();
            }
            return;
        }
Exemplo n.º 17
0
            static bool OnGuildAccept(LoginClient client, CMSG msgID, BinReader data)
            {
                LoginClient inviter = LoginServer.GetLoginClientByCharacterID(client.Character.LastGuildInviterID);

                client.Character.LastGuildInviterID = 0;
                if (inviter == null)
                {
                    return(true);
                }
                DBGuild guild = (DBGuild)DataServer.Database.FindObjectByKey(typeof(DBGuild), inviter.Character.GuildID);

                AddMember(client, guild, guild.MaxRank);
                Chat.GuildSay(0, client, "You have joined " + guild.Name, CHATMESSAGETYPE.GUILD);
                //Chat.System(inviter, client.Character.Name+" joins "+guild.Name);
                GuildMessage(guild, client.Character.Name + " has been accepted to the guild by" + inviter.Character.Name);

                return(true);
            }            //OnGuildAccept
Exemplo n.º 18
0
        static void OnMovement(WorldClient client, CMSG msgID, BinReader data)
        {
            if (client.Player.MapTile == null)
            {
                return;
            }
            client.Player.StandState = UNITSTANDSTATE.STANDING;             // If sleeping set standstate to standing...
            long pos = data.BaseStream.Position;

            if (data.Length() >= 60)             // obj size and pkt size unfortunately
            {
                data.BaseStream.Position += 8;   // skipping Guid and Guid_High (added for 1.3.1)
            }
            client.Player.MovementFlags = data.ReadUInt32();
            int unknown1 = data.ReadInt32();             // time tick

            client.Player.Position = data.ReadVector();
            client.Player.Facing   = data.ReadSingle();
            int unknown2 = data.ReadInt32();             // new field for 1.3.1 also found in the A9 (map id?)

            data.BaseStream.Position = pos;
            ServerPacket pkg;

            if (client.Player.MapTile.Map.SetObjectPositionInBounds(client.Player))
            {
                client.Player.MapTile.Map.Move(client.Player);
                pkg = new ServerPacket(SMSG.MONSTER_MOVE);
                pkg.Write((char)0xFF);
                pkg.Write(client.Player.GUID);
                pkg.WriteVector(client.Player.Position);
                pkg.Write(client.Player.Facing);
                pkg.Write((byte)0x01);
                pkg.Finish();
                client.Player.MapTile.SendSurrounding(pkg);
                return;
            }

            client.Player.MapTile.Map.Move(client.Player);
            pkg = new ServerPacket((SMSG)msgID);
            pkg.Write(client.Player.GUID);
            pkg.Write(data.ReadBytes((int)(data.BaseStream.Length - data.BaseStream.Position)));
            pkg.Finish();
            client.Player.MapTile.SendSurrounding(pkg, client.Player);
        }
Exemplo n.º 19
0
        static bool CancelTrade(LoginClient client, CMSG msgID, BinReader data)
        {
            uint inviteeGUID = client.Character.LastTradeID;

            LoginClient invitee = LoginServer.GetLoginClientByCharacterID((uint)inviteeGUID);

            client.Character.LastTradeID  = 0;
            invitee.Character.LastTradeID = 0;

            BinWriter pkg = LoginClient.NewPacket(SMSG.TRADE_STATUS);

            pkg.Write((int)3);

            invitee.Send(pkg);

            invitee.Character.TradeCompleted = false;

            return(true);
        }
Exemplo n.º 20
0
        static bool AcceptTrade(LoginClient client, CMSG msgID, BinReader data)
        {
            uint flag        = data.ReadUInt32();
            uint inviteeGUID = client.Character.LastTradeID;

            LoginClient invitee = LoginServer.GetLoginClientByCharacterID((uint)inviteeGUID);

            BinWriter pkg = LoginClient.NewPacket(SMSG.TRADE_STATUS);

            if (invitee.Character.TradeCompleted == true)
            {
                ScriptPacket Money = new ScriptPacket(SCRMSG.TRADEMONEY);

                Money.Write(client.Character.ObjectId);
                Money.Write(invitee.Character.ObjectId);
                Money.Write(client.Character.TradeMoney);
                Money.Write(invitee.Character.TradeMoney);

                client.WorldConnection.Send(Money);

                pkg.Write((int)8);

                invitee.Send(pkg);
                client.Send(pkg);

                client.Character.LastTradeID    = 0;
                client.Character.TradeMoney     = 0;
                client.Character.TradeCompleted = false;

                invitee.Character.LastTradeID    = 0;
                invitee.Character.TradeMoney     = 0;
                invitee.Character.TradeCompleted = false;
            }
            else
            {
                pkg.Write((int)4);
                client.Character.TradeCompleted = true;

                invitee.Send(pkg);
            }

            return(true);
        }
        /// <summary>
        /// Returns false if the packet should be sent to the loginserver
        /// </summary>
        /// <param name="client"></param>
        /// <param name="msgID"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool HandlePacket(LoginClient client, CMSG msgID, BinReader data)
        {
            DebugLogger.Logger.Log("LoginClient handling packet " + msgID.ToString());

            if (msgID >= CMSG.MAX)
            {
                return(true);
            }

            ILoginClientPacketHandler handler = (ILoginClientPacketHandler)loginClientHandlers[msgID];
            bool wasHandled = false;

            try {
                long position = data.BaseStream.Position;

                if (handler != null)
                {
                    wasHandled = handler.HandlePacket(client, msgID, data);
                }

                data.BaseStream.Position = position;

                LoginClientPacketDelegate wcpd = (LoginClientPacketDelegate)loginClientDelegates[(int)msgID];
                if (wcpd != null)
                {
                    foreach (LoginClientPacketDelegate d in wcpd.GetInvocationList())
                    {
                        if (d != null)
                        {
                            if (d(client, msgID, data))
                            {
                                wasHandled = true;
                            }
                            data.BaseStream.Position = position;
                        }
                    }
                }
                return(wasHandled);
            } catch (Exception exp) {
                DebugLogger.Logger.Log("", exp);
            }
            return(wasHandled);
        }
Exemplo n.º 22
0
        static void OnSetLeader(WorldClient client, CMSG msgID, BinReader data)
        {
            string newleadername = data.ReadString();

            if (client.Player.IsLeader == false)
            {
                Chat.System(client, "Only the leader can set a new leader"); return;
            }
            if (client.Player.Group == null)
            {
                Chat.System(client, "You must be in a group"); return;
            }
            bool SetNew = false;

            for (uint i = 0; i < client.Player.Group.Size; i++)
            {
                if (client.Player.Group.Members[i].Name.ToLower() == newleadername.ToLower())
                {
                    client.Player.IsLeader = false;
                    client.Player.Group.Members[i].IsLeader = true;
                    client.Player.Group.LeaderGUID          = client.Player.Group.Members[i].GUID;
                    client.Player.Group.LootMaster          = client.Player.Group.LeaderGUID;
                    client.Player.Group.LootMasterName      = newleadername;
                    SetNew = true;
                    break;
                }
            }

            if (!SetNew)
            {
                Chat.System(client, "Invalid new leader"); return;
            }
            else
            {
                ServerPacket grp = new ServerPacket(SMSG.GROUP_SET_LEADER);
                grp.Write(newleadername);
//				grp.Write(client.Player.Group.LeaderGUID);
                client.Player.Group.SendToGroup(grp);
            }
            client.Player.Group.SendGroupList();
            return;
        }
Exemplo n.º 23
0
        static bool QuestDetails(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong quester = data.ReadUInt64();
            int   questid = data.ReadInt32();

            DBQuest quest = null;

            quest = (DBQuest)DataServer.Database.FindObjectByKey(typeof(DBQuest), questid);

            BinWriter q1 = LoginClient.NewPacket(SMSG.QUESTGIVER_QUEST_DETAILS);

            q1.Write(quester);                                  // Quester GUID
            q1.Write(questid);                                  // Quest ID

            q1.Write(quest.Title);                              // Quest Title
            q1.Write(quest.Description);                        // Quest Details
            q1.Write(quest.Objectives);                         // Quest Objectives

            q1.Write((int)0);                                   //?

            q1.Write((int)1);                                   // Choice Reward Item Counter - TODO: ADD ARRAY ON DB

            q1.Write(quest.ChooseRewardID);                     // Choice Reward Item Template_ID
            q1.Write(quest.ChooseQuantity);                     // Choice Reward Item Quantity
            q1.Write(quest.ChooseDisplayID);                    // Choice Reward Item Display_ID

            q1.Write((int)1);                                   // Always Reward Item Counter - TODO: ADD ARRAY ON DB

            q1.Write(quest.AlwaysRewardID);                     // Always Reward Template_ID
            q1.Write(quest.AlwaysRewardQuantity);               // Always Reward Item Quantity
            q1.Write(quest.AlwaysDisplayID);                    // Always Reward Item Display_ID

            q1.Write(quest.MoneyReward);                        // Money Reward
            q1.Write((int)0);                                   // ?
            q1.Write((int)0);                                   // ?

            client.Send(q1);

            Chat.System(client, "Quest Details for quest id " + questid + " from quester " + quester);

            return(true);
        }
Exemplo n.º 24
0
        static bool LearnTalent(LoginClient client, CMSG msgID, BinReader data)
        {
            uint talentid = data.ReadUInt32();

            DBTalents targetTalent = null;

            targetTalent = (DBTalents)DataServer.Database.FindObjectByKey(typeof(DBTalents), talentid);
            if (targetTalent == null)
            {
                Chat.System(client, "Talent " + talentid + " not found on DB"); return(true);
            }
            DBKnownTalents newTalent = null;

            try
            {
                newTalent = (DBKnownTalents)DataServer.Database.FindObjectByKey(typeof(DBKnownTalents), talentid);
            }
            catch (WoWDaemon.Database.DatabaseException e)
            {
                client.Close(e.Message);
                return(true);
            }

            if (newTalent == null)
            {
                newTalent             = new DBKnownTalents();
                newTalent.CharacterID = client.Character.ObjectId;
                newTalent.Talent_Id   = talentid;
                newTalent.TalentLevel = 1;
                DataServer.Database.AddNewObject(newTalent);
                DataServer.Database.FillObjectRelations(client.Character);
            }
            else
            {
                newTalent.TalentLevel++;
                DataServer.Database.SaveObject(newTalent);
            }

            Chat.System(client, "Talent Learned: " + talentid);

            return(true);
        }
Exemplo n.º 25
0
        static void OnAnnouncment(WorldClient client, CMSG msgID, BinReader data)
        {
            string ChanName = (string)data.ReadString();

            if (ChanName != null)
            {
                Channel Chan;
                if ((Chan = ChanExists(ChanName)) != null)
                {
                    if (Chan.announcment)
                    {
                        Chan.AnnouncmentOff(client);
                    }
                    else
                    {
                        Chan.AnnouncmentOn(client);
                    }
                }
            }
        }
Exemplo n.º 26
0
        static bool GossipTextQuery(LoginClient client, CMSG msgID, BinReader data)
        {
            uint  msgid      = data.ReadUInt32();
            ulong vendorGUID = data.ReadUInt64();

            BinWriter pkg = LoginClient.NewPacket(SMSG.NPC_TEXT_UPDATE);

            string topic   = "Out team welcome you!";
            string message = "Please, visit us in irc.gotwow.net #wowcraft";

            pkg.Write(msgid);                                   // Message ID
            pkg.Write(1);                                       // ?
            pkg.Write(topic);                                   // Topic Message
            pkg.Write(message);                                 // Message 1
            pkg.Write((int)0);                                  // Lenguage ID

            client.Send(pkg);

            return(true);
        }
Exemplo n.º 27
0
        static bool OnItemQuerySingle(LoginClient client, CMSG msgID, BinReader data)
        {
            uint           id       = data.ReadUInt32();
            DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), id);

            if (template == null)
            {
                Console.WriteLine("Client requested an item template that didn't exist:" + id);
                return(true);
            }
            BinWriter w = LoginClient.NewPacket(SMSG.ITEM_QUERY_SINGLE_RESPONSE);

            w.Write(id);
            foreach (SerializeValue value in itemTemplateValues)
            {
                value.Serialize(template, w);
            }
            client.Send(w);
            return(true);
        }
Exemplo n.º 28
0
        static bool VendorLisr(LoginClient client, CMSG msgID, BinReader data)
        {
            BinWriter pkg2 = LoginClient.NewPacket(SMSG.LIST_INVENTORY);

            ulong vendorGUID = data.ReadUInt64();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + vendorGUID + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }

            DBVendor tvendor = (DBVendor)obj[0];

            pkg2.Write(tvendor.GUID);                                                           // Vendor GUID (OK)
            if (tvendor.VendorItems == null)
            {
                pkg2.Write((int)0);
                client.Send(pkg2);
                return(true);
            }
            int Lenght = tvendor.VendorItems.Length;
            int i      = 1;

            pkg2.Write((byte)Lenght);                                                           // item counter (OK)
            foreach (DBVendorItem item in tvendor.VendorItems)
            {
                pkg2.Write((int)i);                                             // item counter number (OK)
                pkg2.Write((int)item.TemplateID);                               // item template (OK)
                pkg2.Write((int)item.Template.DisplayID);                       // item icon display_id (OK)
                pkg2.Write((int)item.CurrentQty);                               // Quantity (OK)
                pkg2.Write((int)item.Price);                                    // Price (OK)
                pkg2.Write(0);                                                  // Dunno
                pkg2.Write((int)item.Template.ReqLevel);                        // Item Level (OK)
                i++;
            }

            client.Send(pkg2);
            return(true);
        }
Exemplo n.º 29
0
        static bool OnNameQuery(LoginClient client, CMSG msgID, BinReader data)
        {
            uint        id    = data.ReadUInt32();
            LoginClient other = LoginServer.GetLoginClientByCharacterID(id);

            if (other == null)
            {
                client.Close("Tried to query a char that wasn't online.");
                return(true);
            }
            BinWriter pkg = LoginClient.NewPacket(SMSG.NAME_QUERY_RESPONSE);

            pkg.Write(other.Character.ObjectId);
            pkg.Write(0);             // high id
            pkg.Write(other.Character.Name);
            pkg.Write((int)other.Character.Race);
            pkg.Write((int)other.Character.Gender);
            pkg.Write((int)other.Character.Class);
            client.Send(pkg);
            return(true);
        }
Exemplo n.º 30
0
        private static void OnLoginServerData(ClientBase client, byte[] data)
        {
            try {
                BinReader read = new BinReader(data);
                read.BaseStream.Position += 4;                 // skip len
                WORLDMSG msgID = (WORLDMSG)read.ReadInt32();

                if (msgID != WORLDMSG.DESERIALIZE_OBJ)
                {
                    Console.WriteLine("OnLoginServerData read {0}", msgID);
                }

                if (msgID == WORLDMSG.CLIENT_MESSAGE)
                {
                    uint        charID       = read.ReadUInt32();
                    CMSG        cmsg         = (CMSG)read.ReadInt32();
                    WorldClient world_client = GetClientByCharacterID(charID);
                    if (client != null)
                    {
                        WorldPacketManager.HandlePacket(world_client, cmsg, read);
                    }
                    else
                    {
                        Console.WriteLine("Client(" + charID + ") was missing when " + cmsg.ToString() + " was received.");
                    }
                }
                else if (msgID == WORLDMSG.SCRIPT_MESSAGE)
                {
                    int msg = read.ReadInt32();
                    Console.WriteLine("Read SMSG: " + msg);
                    Scripts.OnScriptMessage(msg, read);
                }
                else
                {
                    WorldPacketManager.HandlePacket(msgID, read);
                }
            } catch (Exception exp) {
                DebugLogger.ILog("", exp);
            }
        }