示例#1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int             num         = packet.ReadInt();
            int             bageType    = packet.ReadInt();
            int             templateId  = packet.ReadInt();
            int             place       = packet.ReadInt();
            int             bagType     = packet.ReadInt();
            int             templateId2 = packet.ReadInt();
            PlayerInventory inventory   = client.Player.GetInventory((eBageType)bageType);
            ItemInfo        itemInfo    = inventory.GetItemAt(num);

            client.Player.GetItemAt((eBageType)bagType, place);
            double num2 = 5.0;
            GoldEquipTemplateLoadInfo goldEquipTemplateLoadInfo = GoldEquipMgr.FindGoldEquipTemplate(templateId);
            GSPacketIn gSPacketIn = new GSPacketIn(106, client.Player.PlayerCharacter.ID);

            if (goldEquipTemplateLoadInfo == null && itemInfo.Template.CategoryID == 7)
            {
                gSPacketIn.WriteInt(5);
            }
            else
            {
                if (!itemInfo.IsGold)
                {
                    if (num2 > (double)WishBeadEquipHandler.random.Next(100))
                    {
                        itemInfo.StrengthenLevel++;
                        itemInfo.IsGold        = true;
                        itemInfo.goldBeginTime = DateTime.Now;
                        itemInfo.goldValidDate = 30;
                        itemInfo.IsBinds       = true;
                        if (goldEquipTemplateLoadInfo != null && itemInfo.Template.CategoryID == 7)
                        {
                            ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(goldEquipTemplateLoadInfo.NewTemplateId);
                            if (itemTemplateInfo != null)
                            {
                                ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116);
                                itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel;
                                itemInfo2.IsGold          = itemInfo.IsGold;
                                itemInfo2.goldBeginTime   = itemInfo.goldBeginTime;
                                itemInfo2.goldValidDate   = itemInfo.goldValidDate;
                                itemInfo2.IsBinds         = itemInfo.IsBinds;
                                ItemInfo.OpenHole(ref itemInfo2);
                                StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2);
                                inventory.RemoveItemAt(num);
                                inventory.AddItemTo(itemInfo2, num);
                                itemInfo = itemInfo2;
                            }
                        }
                        inventory.UpdateItem(itemInfo);
                        gSPacketIn.WriteInt(0);
                        inventory.SaveToDatabase();
                    }
                    else
                    {
                        gSPacketIn.WriteInt(1);
                    }
                    client.Player.RemoveTemplate(templateId2, 1);
                }
                else
                {
                    gSPacketIn.WriteInt(6);
                }
            }
            client.Out.SendTCP(gSPacketIn);
            return(0);
        }
示例#2
0
        public override bool Start()
        {
            if (this.m_running)
            {
                return(false);
            }
            bool result;

            try
            {
                this.m_running = true;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);
                if (!this.InitComponent(this.InitSocket(this.m_config.Ip, this.m_config.Port), "InitSocket Port:" + this.m_config.Port))
                {
                    result = false;
                }
                else
                {
                    if (!this.InitComponent(this.StartScriptComponents(), "Script components"))
                    {
                        result = false;
                    }
                    else
                    {
                        if (!this.InitComponent(ProxyRoomMgr.Setup(), "RoomMgr.Setup"))
                        {
                            result = false;
                        }
                        else
                        {
                            if (!this.InitComponent(GameMgr.Setup(0, 4), "GameMgr.Setup"))
                            {
                                result = false;
                            }
                            else
                            {
                                if (!this.InitComponent(MapMgr.Init(), "MapMgr Init"))
                                {
                                    result = false;
                                }
                                else
                                {
                                    if (!this.InitComponent(ItemMgr.Init(), "ItemMgr Init"))
                                    {
                                        result = false;
                                    }
                                    else
                                    {
                                        if (!this.InitComponent(PropItemMgr.Init(), "PropItemMgr Init"))
                                        {
                                            result = false;
                                        }
                                        else
                                        {
                                            if (!this.InitComponent(BallMgr.Init(), "BallMgr Init"))
                                            {
                                                result = false;
                                            }
                                            else
                                            {
                                                if (!this.InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init"))
                                                {
                                                    result = false;
                                                }
                                                else
                                                {
                                                    if (!this.InitComponent(DropMgr.Init(), "DropMgr Init"))
                                                    {
                                                        result = false;
                                                    }
                                                    else
                                                    {
                                                        if (!this.InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init"))
                                                        {
                                                            result = false;
                                                        }
                                                        else
                                                        {
                                                            if (!this.InitComponent(WindMgr.Init(), "WindMgr Init"))
                                                            {
                                                                result = false;
                                                            }
                                                            else
                                                            {
                                                                if (!this.InitComponent(GoldEquipMgr.Init(), "GoldEquipMgr Init"))
                                                                {
                                                                    result = false;
                                                                }
                                                                else
                                                                {
                                                                    if (!this.InitComponent(LanguageMgr.Setup(""), "LanguageMgr Init"))
                                                                    {
                                                                        result = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        GameEventMgr.Notify(ScriptEvent.Loaded);
                                                                        if (!this.InitComponent(base.Start(), "base.Start()"))
                                                                        {
                                                                            result = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            ProxyRoomMgr.Start();
                                                                            GameMgr.Start();
                                                                            GameEventMgr.Notify(GameServerEvent.Started, this);
                                                                            GC.Collect(GC.MaxGeneration);
                                                                            FightServer.log.Info("GameServer is now open for connections!");
                                                                            result = true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                FightServer.log.Error("Failed to start the server", exception);
                result = false;
            }
            return(result);
        }