예제 #1
0
 public static MaplePakcet CheckAccount(string Name, bool Success)
 {
     using (MapleBuffer buff = new MapleBuffer())
     {
         buff.add <string>(Name);
         buff.add <bool>(Success);
         return(new MaplePakcet(buff.ToArray()));
     }
 }
예제 #2
0
 public static MaplePakcet CharNameResponse(string Name, bool ret)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <string>(Name);
         buffer.add <bool>(ret);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #3
0
 //TODO:道具基础头部(100%)
 public static void AddBaseItemHeader(MapleBuffer buffer, CItem item)
 {
     buffer.add <int>(item.ItemId);
     buffer.add <byte>(item.Uniqueid > 0 ? (byte)1 : (byte)0);
     if (item.Uniqueid > 0)
     {
         buffer.add <long>(item.Uniqueid);
     }
     buffer.addTime(Common.constants.GameConstants.getTime(item.Expiredate));            //到期时间
 }
예제 #4
0
 public static MaplePakcet ShowNumber()
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(1);
         buffer.add <int>(5);
         buffer.add <int>(5 + (3 - 5 % 3));
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #5
0
 public static MaplePakcet GetChatText(int cid, string Text, bool whiteBG = false)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <int>(cid);
         buffer.add <byte>(whiteBG ? (byte)1 : (byte)0);//是否显示说话对话框
         buffer.add <string>(Text);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #6
0
 public static MaplePakcet getLoginFailed(byte type)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(type);
         buffer.add <byte>(0);
         buffer.add(new byte[1000]);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #7
0
 public static MaplePakcet getServerStatus(byte status)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(status);
         if (status != 0)
         {
             buffer.add(new byte[6]);
         }
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #8
0
        public static MaplePakcet getServerIP(byte[] IPaddr, short port, int chrid)
        {
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <short>(0);
                buffer.add(IPaddr);
                buffer.add <short>(port);
                buffer.add <int>(chrid);
                buffer.add <byte>(0);

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #9
0
        /// <summary>
        /// 验证版本
        /// </summary>
        /// <returns></returns>
        public static byte[] GetHello(short mapleVersion, byte[] sendIv, byte[] recvIv)
        {
            using (MapleBuffer mapleBuffer = new MapleBuffer())
            {
                mapleBuffer.add((short)0x0E);
                mapleBuffer.add <short>(mapleVersion);
                mapleBuffer.add(recvIv);
                mapleBuffer.add(sendIv);
                mapleBuffer.add(4);

                return(mapleBuffer.ToArray());
            }
        }
예제 #10
0
 public static MaplePakcet ShowPlayList(CMapleClient client, Dictionary <CCharacter, Dictionary <short, CItem> > PlayerList, byte worldid)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(0);
         buffer.add <int>(0);
         buffer.add <byte>((byte)PlayerList.Count);
         foreach (KeyValuePair <CCharacter, Dictionary <short, CItem> > chr in PlayerList)
         {
             addCharEntry(buffer, chr.Key, client, chr.Value);
         }
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #11
0
 public static MaplePakcet GetChannelChange(string Address, short port)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(1);
         string[] adds = Address.Split(".");
         foreach (string add in adds)
         {
             buffer.add(byte.Parse(add.ToString()));//IP地址
         }
         buffer.add <short>(port);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #12
0
 public static MaplePakcet ServerMessage(int type, string Message, int channel = 0, bool megaEar = false)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>((byte)type);
         buffer.add <string>(Message);
         switch (type)
         {
         case 3:
             buffer.add <byte>((byte)channel);
             buffer.add <byte>(megaEar ? (byte)1 : (byte)0);
             break;
         }
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #13
0
 public static MaplePakcet ShowRegister(bool isShow)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <bool>(isShow);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #14
0
 public static MaplePakcet RemovePlayer(int cid)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <int>(cid);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #15
0
        public static MaplePakcet getEndOfServerList()
        {
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <byte>(0xFF);//世界ID

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #16
0
        public static MaplePakcet RegisterAccount(bool Success)
        {
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add(Success);

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #17
0
 public static MaplePakcet AddPlayer(CMapleClient client, CCharacter chr)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <byte>(0);
         addCharEntry(buffer, chr, client);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }
예제 #18
0
        public static MaplePakcet GetCharInfo(int Channelid, CCharacter chr, CMapleClient client)
        {
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <int>(Channelid);//频道
                buffer.add <byte>(0);
                buffer.add <byte>(1);
                buffer.add <int>(new System.Random().Next());
                buffer.add <int>(new System.Random().Next());
                buffer.add <int>(new System.Random().Next());
                buffer.add <int>(0);

                AddCharacterInfo(buffer, chr, client);
                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #19
0
        /// <summary>
        /// 游戏版本封包
        /// </summary>
        /// <param name="mapleVersion"></param>
        /// <param name="sendIv"></param>
        /// <param name="recvIv"></param>
        /// <returns></returns>
        public static MaplePakcet GetHello(short mapleVersion, byte[] sendIv, byte[] recvIv)
        {
            using (MapleBuffer mapleBuffer = new MapleBuffer())
            {
                System.Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
                mapleBuffer.add((short)0x0E);
                mapleBuffer.add <short>(mapleVersion);
                mapleBuffer.add <short>(1);
                mapleBuffer.add <byte>(0x31);
                mapleBuffer.add(recvIv);
                mapleBuffer.add(sendIv);
                mapleBuffer.add <byte>(4);

                return(new MaplePakcet(mapleBuffer.ToArray()));
            }
        }
예제 #20
0
        public static MaplePakcet getServerList()
        {
            //05 00 05 00 C3 B0 58 B5 BA 02 08 00 C0 B6 CE CF C5 A3 2D 31 00 00 00 00 00 00 00 08 00 C0 B6 CE CF C5 A3 2D 32 00 00 00 00 00 01 00
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <byte>(0);       //小区名称(0:蓝蜗牛,1: 蘑菇仔,2: 绿水灵...)
                buffer.add <string>("027"); //世界名称
                buffer.add <byte>(2);       //频道个数
                for (int i = 0; i < 2; i++)
                {
                    buffer.add <string>("Chal1-" + i); //广告牌
                    buffer.add <int>(0);               //在线人数.
                    buffer.add <byte>(0);              //世界ID
                    buffer.add <byte>(0);              //频道ID
                    buffer.add <byte>(0);
                }

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #21
0
        public static MaplePakcet getAuthSuccessRequest(CUser user)
        {
            //01 00 01 00 00 00 00 00 06 00 78 7A 6B 6D 78 64 01 00 00 00 01
            //01 04 01 00 00 00 00 00 06 00 78 7A 6B 6D 78 64 01 00 00 00 01
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <byte>(0);
                buffer.add <int>(user.Id);
                buffer.add <byte>(0);
                buffer.add <byte>((byte)(user.Gm ?? 0));//是否管理员
                buffer.add <string>(user.Name);
                buffer.add <int>(user.Id);
                buffer.add <byte>(0);

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #22
0
        public static MaplePakcet getServerList(WorldInfo worldModel)
        {
            //05 00 05 00 C3 B0 58 B5 BA 02 08 00 C0 B6 CE CF C5 A3 2D 31 00 00 00 00 00 00 00 08 00 C0 B6 CE CF C5 A3 2D 32 00 00 00 00 00 01 00
            using (MapleBuffer buffer = new MapleBuffer())
            {
                buffer.add <byte>((byte)worldModel.WorldId);           //小区名称(0:蓝蜗牛,1: 蘑菇仔,2: 绿水灵...)
                buffer.add <string>("027");                            //世界名称
                buffer.add <byte>((byte)worldModel.channelInfo.Count); //频道个数
                for (int i = 0; i < worldModel.channelInfo.Count; i++)
                {
                    ChannelInfo info = worldModel.channelInfo[i];
                    buffer.add <string>(info.Name + "_" + i);    //广告牌
                    buffer.add <int>(info.Players);              //在线人数.
                    buffer.add <byte>((byte)worldModel.WorldId); //世界ID
                    buffer.add <byte>((byte)i);                  //频道ID
                    buffer.add <byte>(0);
                }

                return(new MaplePakcet(buffer.ToArray()));
            }
        }
예제 #23
0
        //TODO:玩家信息(100%)
        public static void AddCharacterInfo(MapleBuffer buffer, CCharacter chr, CMapleClient client)
        {
            buffer.add <short>(-1);
            AddCharStats(buffer, chr, client);
            buffer.add <byte>(20);
            buffer.add <int>(0);//金币

            //装备与道具
            AddInventoryInfo(buffer, client.CharacterInfo);

            //技能
            buffer.add <short>(0);

            //任务
            buffer.add <short>(0);
            buffer.add <short>(0);
            //戒指
            buffer.add <short>(0);
            for (int i = 0; i < 5; i++)
            {
                buffer.add <int>(0);
            }
        }
예제 #24
0
파일: Program.cs 프로젝트: xzkmxd/YeGoMs
        static void Main(string[] args)
        {
            Console.Clear();

            #region 设置控制台事件
            SetConsoleCtrlHandler(new ConsoleCtrlDelegate((a) =>
            {
                switch (a)
                {
                case CtrlCloseEvent:
                    {
                        Console.WriteLine("正在保存数据中....");
                        if (GameConstants._QuitServer != null)
                        {
                            GameConstants._QuitServer();    //.Invoke();
                        }
                        break;
                    }
                }
                return(true);
            }
                                                          ), true);
            #endregion
#if 测试版本
            #region 测试反射例子
            string path3 = System.IO.Directory.GetCurrentDirectory();

            assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + path3 + "\\LoginServer.dll"));

            while (true)
            {
                MapleBuffer mapleBuffer = new MapleBuffer();
                mapleBuffer.add <int>(50);
                mapleBuffer.add <int>(50);


                HandlerInterface game = (HandlerInterface)assembly.CreateInstance("LoginServer.Handler.TestGame");
                game.Handle(mapleBuffer);
                string cmd = Console.ReadLine();
                switch (cmd)
                {
                case "0":
                {
                    assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + path3 + "\\LoginServer.dll"));
                    break;
                }
                }
            }
            #endregion
#endif
#if !正式版测试
            Console.Title = "启动:" + args[0];
            #region  务端命令
            switch (args[0])
            {
            case "Common":
            case "LoginServer":
            {
                LoadConfig(args[0]).ConfigureAwait(true);
                break;
            }

            case "ChannelServer":
                LoadConfig(args[0], true).Wait();
                break;

            case "WorldServer":
                LoadConfig(args[0], true, true).ConfigureAwait(true);
                break;

            case "GameServer":
            case "DBServer":
            {
                LoadConfig(args[0], true).ConfigureAwait(true);
                break;
            }

            default:
                Console.WriteLine("启动错误!");
                break;
            }

            while (Run)
            {
                string linet = System.Console.ReadLine();
                switch (linet)
                {
                case "Exit":
                    Environment.Exit(0);
                    break;

                case "Test":
                    assembly = Assembly.Load(System.IO.File.ReadAllBytes(@"" + AppPath + "\\" + args[0] + ".dll"));
                    assembly.CreateInstance(args[0] + ".App.ServerInit");
                    break;
                }
            }

            #endregion
#endif
        }
예제 #25
0
        public static void addCharLook(MapleBuffer buffer, CMapleCharacter chr)
        {
            buffer.add <byte>(0);//性别
            buffer.add <byte>((byte)chr.character.Skin);
            buffer.add <int>(chr.character.Face);
            buffer.add <byte>(0);
            buffer.add <int>(chr.character.Hair);

            List <CItem> equipped     = new List <CItem>();
            List <CItem> equippedCash = new List <CItem>();

            //判断是否点装..
            foreach (KeyValuePair <short, CItem> item in chr.GetMapleInventory(Common.Client.Inventory.InventoryType.佩戴).getInventory())
            {
                if (item.Key < 0 && item.Key > -100)
                {
                    equipped.Add(item.Value);
                }
                else if (item.Key <= -100 && item.Key > -1000)
                {
                    equippedCash.Add(item.Value);
                }
            }

            //装备
            foreach (CItem item in equipped)
            {
                buffer.add <byte>((byte)item.Position);
                buffer.add <int>(item.ItemId);
            }
            buffer.add <byte>(0xFF);//1
            //现金装备
            foreach (CItem item in equippedCash)
            {
                buffer.add <byte>((byte)item.Position);
                buffer.add <int>(item.ItemId);
            }
            buffer.add <int>(0);//宠物??
        }
예제 #26
0
        //TODO:道具信息(30%)
        public static void AddItemInfo(MapleBuffer buffer, CItem item)
        {
            //buffer.add<int>
            short Posin = (short)item.Position;

            if (Posin <= -1)
            {
                Posin *= -1;
                if (Posin > 100 && Posin < 1000)
                {
                    Posin -= 100;
                }
            }
            buffer.add <byte>((byte)Posin);

            if (false)//宠物道具信息
            {
            }
            else
            {
                if (item.Type == 0 || item.Type == 1)//0:佩戴,1装备
                {
                    //装备道具数据
                    CEquip equip = Common.Sql.MySqlFactory.GetFactory.Query <CEquip>().Where(a => a.InventoryitemsId == item.Id).FirstOrDefault();
                    if (equip == null)
                    {
                        AddBaseItemHeader(buffer, item);
                        buffer.add <byte>(0);
                        buffer.add <byte>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <short>(0);
                        buffer.add <string>("");
                    }
                    else
                    {
                        AddBaseItemHeader(buffer, item);
                        AddEquipItemInfo(buffer, equip);
                    }
                }
                else
                {
                    //其他道具数据
                    AddOtherItemInfo(buffer, item);
                }
            }
        }
예제 #27
0
 //TODO:装备信息(50%)
 private static void AddEquipItemInfo(MapleBuffer buffer, CEquip equip)
 {
     buffer.add <byte>((byte)equip.UpgradeSlots);
     buffer.add <byte>((byte)equip.Level);
     buffer.add <short>((short)equip.Str);
     buffer.add <short>((short)equip.Dex);
     buffer.add <short>((short)equip.Int);
     buffer.add <short>((short)equip.Luk);
     buffer.add <short>((short)equip.Hp);
     buffer.add <short>((short)equip.Mp);
     buffer.add <short>((short)equip.Watk);
     buffer.add <short>((short)equip.Matk);
     buffer.add <short>((short)equip.Wdef);
     buffer.add <short>((short)equip.Mdef);
     buffer.add <short>((short)equip.Acc);
     buffer.add <short>((short)equip.Avoid);
     buffer.add <short>((short)equip.Hands);
     buffer.add <short>((short)equip.Speed);
     buffer.add <short>((short)equip.Jump);
     buffer.add <string>(equip.Owner);
 }
예제 #28
0
 /// <summary>
 /// 玩家基本消息
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="chr"></param>
 /// <param name="client"></param>
 public static void addCharStats(MapleBuffer buffer, CCharacter chr, CMapleClient client)
 {
     buffer.add <int>(chr.Id);
     buffer.add(chr.Name, 0x13);
     buffer.add <byte>(client.UserInfo.Gender);
     buffer.add <byte>(byte.Parse(chr.Skin.ToString()));
     buffer.add <int>(chr.Face);
     buffer.add <int>(chr.Hair);
     buffer.add <long>(0);
     buffer.add <byte>((byte)chr.Level);
     buffer.add <short>(chr.Job);
     buffer.add <short>(chr.Str);
     buffer.add <short>(chr.Dex);
     buffer.add <short>(chr.Int_);
     buffer.add <short>(chr.Luk);
     buffer.add <short>(chr.Hp);
     buffer.add <short>(chr.Mp);
     buffer.add <short>(chr.Maxhp);
     buffer.add <short>(chr.Maxmp);
     buffer.add <short>(chr.Ap);
     buffer.add <short>(chr.Sp);
     buffer.add <int>(chr.Exp);
     buffer.add <short>(chr.Fame);
     buffer.add <int>(chr.MapId);
     buffer.add <byte>(chr.Spawnpoint);
     buffer.addTime(150842304000000000L);
     buffer.add <long>(0);
 }
예제 #29
0
        public static void addCharEntry(MapleBuffer buffer, CCharacter chr, CMapleClient client, Dictionary <short, CItem> dictionary = null)
        {
            addCharStats(buffer, chr, client);

            if (client.CharacterInfo != null)
            {
                foreach (KeyValuePair <short, CItem> Equip in client.CharacterInfo.GetMapleInventory(Common.Client.Inventory.InventoryType.佩戴).getInventory())
                {
                    short Posint = (short)(Equip.Key * -1);
                    if (Posint < 100)
                    {
                        buffer.add <byte>((byte)(int.Parse(Posint.ToString()) & 0xFF));
                        buffer.add <int>(Equip.Value.ItemId);
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <short, CItem> Equip in dictionary)
                {
                    short Posint = (short)(Equip.Key * -1);
                    if (Posint < 100)
                    {
                        buffer.add <byte>((byte)(int.Parse(Posint.ToString()) & 0xFF));
                        buffer.add <int>(Equip.Value.ItemId);
                    }
                }
            }


            buffer.add <byte>(0);

            if (client.CharacterInfo != null)
            {
                foreach (KeyValuePair <short, CItem> Equip in client.CharacterInfo.GetMapleInventory(Common.Client.Inventory.InventoryType.佩戴).getInventory())
                {
                    short Posint = (short)(Equip.Key * -1);
                    if (Posint > 100)
                    {
                        buffer.add <byte>((byte)(int.Parse(Posint.ToString()) & 0xFF));
                        buffer.add <int>(Equip.Value.ItemId);
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <short, CItem> Equip in dictionary)
                {
                    short Posint = (short)(Equip.Key * -1);
                    if (Posint > 100)
                    {
                        buffer.add <byte>((byte)(int.Parse(Posint.ToString()) & 0xFF));
                        buffer.add <int>(Equip.Value.ItemId);
                    }
                }
            }

            //Dictionary<byte, int> maskedEquip = new Dictionary<byte, int>();
            //maskedEquip.Add(1, 1002067);
            //foreach (KeyValuePair<byte, int> Equip in maskedEquip)
            //{
            //    buffer.add<byte>(Equip.Key);
            //    buffer.add<int>(Equip.Value);
            //}

            buffer.add <byte>(0);
        }
예제 #30
0
 public static MaplePakcet SpawnPlayer(CMapleCharacter chr)
 {
     using (MapleBuffer buffer = new MapleBuffer())
     {
         buffer.add <int>(chr.character.Id + 1);
         buffer.add <string>(chr.character.Name);
         buffer.add <int>(0);//Buffmask
         addCharLook(buffer, chr);
         buffer.add <int>(0);
         buffer.add <int>(0);//getItemEffect
         buffer.add <int>(0);
         buffer.add <short>((short)chr.GetPoint().X);
         buffer.add <short>((short)chr.GetPoint().Y);
         buffer.add <byte>(chr.GetStance());
         buffer.add <short>(0);
         buffer.add(new byte[3]);
         return(new MaplePakcet(buffer.ToArray()));
     }
 }