Exemplo n.º 1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn      gSPacketIn = new GSPacketIn(110, client.Player.PlayerCharacter.ID);
            bool            flag       = false;
            int             num        = packet.ReadInt();
            int             num2       = packet.ReadInt();
            List <ItemInfo> list       = new List <ItemInfo>();

            new List <ItemInfo>();
            List <eBageType> list2         = new List <eBageType>();
            StringBuilder    stringBuilder = new StringBuilder();
            int num3 = 25;

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.locked", new object[0]));
                return(1);
            }
            for (int i = 0; i < num2; i++)
            {
                eBageType eBageType = (eBageType)packet.ReadInt();
                int       place     = packet.ReadInt();
                ItemInfo  itemAt    = client.Player.GetItemAt(eBageType, place);
                if (itemAt != null)
                {
                    if (list.Contains(itemAt))
                    {
                        client.Out.SendMessage(eMessageType.Normal, "Bad Input");
                        return(1);
                    }
                    if (itemAt.IsBinds)
                    {
                        flag = true;
                    }
                    stringBuilder.Append(string.Concat(new object[]
                    {
                        itemAt.ItemID,
                        ":",
                        itemAt.TemplateID,
                        ","
                    }));
                    list.Add(itemAt);
                    list2.Add(eBageType);
                }
            }
            eBageType bagType = (eBageType)packet.ReadInt();
            int       place2  = packet.ReadInt();
            ItemInfo  itemAt2 = client.Player.GetItemAt(bagType, place2);

            if (itemAt2 != null)
            {
                stringBuilder.Append(string.Concat(new object[]
                {
                    itemAt2.ItemID,
                    ":",
                    itemAt2.TemplateID,
                    ","
                }));
            }
            eBageType bagType2 = (eBageType)packet.ReadInt();
            int       place3   = packet.ReadInt();
            ItemInfo  itemAt3  = client.Player.GetItemAt(bagType2, place3);
            bool      flag2    = itemAt3 != null;

            if (num2 != 4 || itemAt2 == null)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.ItemNotEnough", new object[0]));
                return(1);
            }
            bool flag3 = false;
            bool flag4 = false;

            if (num == 0)
            {
                ItemTemplateInfo itemTemplateInfo = RefineryMgr.Refinery(client.Player, list, itemAt2, flag2, num, ref flag3, ref num3, ref flag4);
                if (itemTemplateInfo != null)
                {
                    client.Out.SendRefineryPreview(client.Player, itemTemplateInfo.TemplateID, flag, itemAt2);
                }
                return(0);
            }
            int num4 = 10000;

            if (client.Player.PlayerCharacter.Gold > num4)
            {
                client.Player.RemoveGold(num4);
                ItemTemplateInfo itemTemplateInfo2 = RefineryMgr.Refinery(client.Player, list, itemAt2, flag2, num, ref flag3, ref num3, ref flag4);
                if (itemTemplateInfo2 != null && flag4 && flag3)
                {
                    stringBuilder.Append("Success");
                    flag3 = true;
                    if (flag3)
                    {
                        ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo2, 1, 114);
                        if (itemInfo != null)
                        {
                            client.Player.OnItemMelt(itemAt2.Template.CategoryID);
                            itemInfo.IsBinds = flag;
                            AbstractInventory itemInventory = client.Player.GetItemInventory(itemTemplateInfo2);
                            if (!itemInventory.AddItem(itemInfo, itemInventory.BeginSlot))
                            {
                                stringBuilder.Append("NoPlace");
                                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0]));
                            }
                            gSPacketIn.WriteByte(0);
                            itemAt2.Count--;
                            client.Player.UpdateItem(itemAt2);
                        }
                    }
                    else
                    {
                        stringBuilder.Append("false");
                    }
                }
                else
                {
                    gSPacketIn.WriteByte(1);
                }
                if (flag2)
                {
                    itemAt3.Count--;
                    client.Player.UpdateItem(itemAt3);
                }
                for (int j = 0; j < list.Count; j++)
                {
                    client.Player.UpdateItem(list[j]);
                    if (list[j].Count <= 0)
                    {
                        client.Player.RemoveItem(list[j]);
                    }
                }
                client.Player.RemoveItem(list[list.Count - 1]);
                client.Player.Out.SendTCP(gSPacketIn);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemRefineryHandler.NoGold", new object[0]));
            }
            return(1);
        }
Exemplo n.º 2
0
        public override bool Start()
        {
            if (m_isRunning)
            {
                return(false);
            }
            try
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                Thread.CurrentThread.Priority = ThreadPriority.Normal;

                GameProperties.Refresh();


                if (!InitComponent(RecompileScripts(), "Recompile Scripts"))
                {
                    return(false);
                }

                if (!InitComponent(StartScriptComponents(), "Script components"))
                {
                    return(false);
                }

                if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition))
                {
                    return(false);
                }

                if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port))
                {
                    return(false);
                }

                if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()"))
                {
                    return(false);
                }

                if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(WorldMgr.Init(), "WorldMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MapMgr.Init(), "MapMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemMgr.Init(), "ItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init"))
                {
                    return(false);
                }

                if (!InitComponent(BallMgr.Init(), "BallMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(FusionMgr.Init(), "FusionMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(AwardMgr.Init(), "AwardMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(DropMgr.Init(), "Drop Init"))
                {
                    return(false);
                }

                if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ShopMgr.Init(), "ShopMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(QuestMgr.Init(), "QuestMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup"))
                {
                    return(false);
                }

                if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup"))
                {
                    return(false);
                }

                if (!InitComponent(InitGlobalTimer(), "Init Global Timers"))
                {
                    return(false);
                }

                if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup"))
                {
                    return(false);
                }
                GameEventMgr.Notify(ScriptEvent.Loaded);

                if (!InitComponent(InitLoginServer(), "Login To CenterServer"))
                {
                    return(false);
                }

                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

                if (!InitComponent(base.Start(), "base.Start()"))
                {
                    return(false);
                }



                GameEventMgr.Notify(GameServerEvent.Started, this);

                GC.Collect(GC.MaxGeneration);

                if (log.IsInfoEnabled)
                {
                    log.Info("GameServer is now open for connections!");
                }

                m_isRunning = true;
                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Failed to start the server", e);
                }

                return(false);
            }
        }
Exemplo n.º 3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType           bagType   = (eBageType)packet.ReadInt();
            int                 place     = packet.ReadInt();
            eBageType           bagType2  = (eBageType)packet.ReadInt();
            List <ShopItemInfo> list      = new List <ShopItemInfo>();
            int                 num       = packet.ReadInt();
            int                 operation = packet.ReadInt();
            ItemInfo            itemInfo;

            if (num == -1)
            {
                packet.ReadInt();
                int num2 = packet.ReadInt();
                int num3 = 0;
                int num4 = 0;
                ItemTemplateInfo goods = ItemMgr.FindItemTemplate(34101);
                itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102);
                list     = ShopMgr.FindShopbyTemplatID(34101);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].APrice1 == -1 && list[i].AValue1 != 0)
                    {
                        num4 = list[i].AValue1;
                        itemInfo.ValidDate = list[i].AUnit;
                    }
                }
                if (itemInfo != null)
                {
                    if (num3 <= client.Player.PlayerCharacter.Gold && num4 <= client.Player.PlayerCharacter.Money)
                    {
                        client.Player.RemoveMoney(num4);
                        client.Player.RemoveGold(num3);
                        LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Move, client.Player.PlayerCharacter.ID, num4, client.Player.PlayerCharacter.Money, num3, 0, 0, 0, "牌子编号", itemInfo.TemplateID.ToString(), num2.ToString());
                    }
                    else
                    {
                        itemInfo = null;
                    }
                }
            }
            else
            {
                itemInfo = client.Player.GetItemAt(bagType2, num);
            }
            ItemInfo      itemAt        = client.Player.GetItemAt(bagType, place);
            StringBuilder stringBuilder = new StringBuilder();

            if (itemInfo == null || itemAt == null)
            {
                return(1);
            }
            bool             flag             = false;
            ItemTemplateInfo itemTemplateInfo = RefineryMgr.RefineryTrend(operation, itemAt, ref flag);

            if (flag && itemTemplateInfo != null)
            {
                ItemInfo          itemInfo2     = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 115);
                AbstractInventory itemInventory = client.Player.GetItemInventory(itemTemplateInfo);
                if (itemInventory.AddItem(itemInfo2, itemInventory.BeginSlot))
                {
                    client.Player.UpdateItem(itemInfo2);
                    client.Player.RemoveItem(itemAt);
                    itemInfo.Count--;
                    client.Player.UpdateItem(itemInfo);
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Success", new object[0]));
                }
                else
                {
                    stringBuilder.Append("NoPlace");
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo2.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0]));
                }
                return(1);
            }
            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Fail", new object[0]));
            return(1);
        }