Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newNetState"></param>
        internal static void WorldInitializeNetState(object sender, NetStateInitEventArgs netStateInit)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_InitializeNetState...... 0");

            if (netStateInit.NetStateInit != null)
            {
                // 初始化客户端
                WorldExtendData extendData = new WorldExtendData();

                // 客户端保存的扩展数据
                netStateInit.NetStateInit.RegisterComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID, extendData);

                // 加解密数据的接口
                netStateInit.NetStateInit.PacketEncoder = extendData;

                // 开始发送服务端随机的种子给客户端
                netStateInit.NetStateInit.EventConnect += new EventHandler <NetStateConnectEventArgs>(WorldInitConnect);

                // 截获输出的信息包
                netStateInit.NetStateInit.EventSendPacket += new EventHandler <NetStateSendPacketEventArgs>(WorldSendPacket);
            }
            else
            {
                Debug.WriteLine("ProcessNet.World_InitializeNetState(...) - newNetState != null && newNetState.ExtendData == null error!");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 保存世界服务
        /// </summary>
        internal void OnSave()
        {
            if (SpinLockEx.QuickTryEnter(ref m_LockSave) == false)
            {
                LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.BaseWorldString003);
                return;
            }
            else
            {
                // 保存数据
                EventHandler <BaseWorldEventArgs> tempEvent = m_EventSaveWorld;
                if (tempEvent != null)
                {
                    // 保存数据中......
                    m_Saving = true;

                    LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.BaseWorldString001);

                    BaseWorldEventArgs worldEventArgs = new BaseWorldEventArgs(this);
                    tempEvent(this, worldEventArgs);

                    LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.BaseWorldString002);

                    // 保存数据结束......
                    m_Saving = false;
                }
            }
            m_LockSave.Exit();
        }
        internal static void World_HandleCharDelete(NetState netState, PacketReader packetReader)
        {
            LOGs.WriteLine(LogMessageType.MSG_ERROR, "World_HandleCharDelete!");

            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            ulong iGuid = packetReader.ReadULong64();

            CharDeleteSQL charEnumSQL = new CharDeleteSQL(extendData, netState, (long)iGuid);
            WaitExecuteInfo <CharDeleteSQL> waitExecuteInfo = new WaitExecuteInfo <CharDeleteSQL>(charEnumSQL, WorldPacketHandlers.SQL_HandleCharDelete);

            ProcessServer.WowZoneCluster.World.WaitExecute.JoinWaitExecuteQueue(waitExecuteInfo);
        }
Beispiel #4
0
        /// <summary>
        /// 开始发送服务端随机的种子给客户端
        /// </summary>
        private static void WorldInitConnect(object sender, NetStateConnectEventArgs eventArgs)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_InitConnect...... 0");

            NetState netState = eventArgs.NetStateConnect;

            if (netState == null)
            {
                Debug.WriteLine("ProcessNet.World_InitConnect(...) - netState == null error!");
            }
            else
            {
                // 发送服务端随机的种子信息
                if (netState.Running)
                {
                    WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);
                    if (extendData == null)
                    {
                        Debug.WriteLine("ProcessNet.World_InitConnect(...) - extendData == null error!");
                        return;
                    }

                    netState.Send(new Word_AuthChallenge(extendData.ServerSeed));
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 人物技能模板信息和魔法模板信息
        /// </summary>
        private void LoadSkillTemplateAndSpellTemplate()
        {
            //////////////////////////////////////////////////////////////////////////
            // 开始人物技能模板信息和魔法模板信息

            for (uint iIndex = 0; iIndex < DBCInstances.SkillLineEntry.Count; ++iIndex)
            {
                SkillLineEntry skillLineEntry = DBCInstances.SkillLineEntry.LookupRowEntry(iIndex);
                if (skillLineEntry == null)
                {
                    continue;
                }

                WowSkillTemplate wowSkillTemplate = new WowSkillTemplate();
                wowSkillTemplate.Serial = skillLineEntry.ID;

                m_GlobalSkillTemplates.AddSkillTemplate(wowSkillTemplate.Serial, wowSkillTemplate);
            }

            for (uint iIndex = 0; iIndex < DBCInstances.SpellEntry.Count; ++iIndex)
            {
                SpellEntry spellEntry = DBCInstances.SpellEntry.LookupRowEntry(iIndex);
                if (spellEntry == null)
                {
                    continue;
                }

                WowSpellTemplate wowSpellTemplate = new WowSpellTemplate();
                wowSpellTemplate.Serial = spellEntry.ID;

                m_GlobalSpellTemplates.AddSpellTemplate(wowSpellTemplate.Serial, wowSpellTemplate);
            }

            LOGs.WriteLine(LogMessageType.MSG_INFO, "Wow世界:读取脚本内全部的 人物技能模板信息和魔法模板信息 完成");
        }
Beispiel #6
0
        /// <summary>
        /// 保存世界的数据
        /// </summary>
        public void Save()
        {
            // 保存世界的数据必须要成功才返回
            m_LockSave.Enter();
            {
                // 保存数据中......
                m_Saving = true;

                LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.BaseWorldString001);

                // 保存数据
                EventHandler <BaseWorldEventArgs> tempEvent = m_EventSaveWorld;
                if (tempEvent != null)
                {
                    BaseWorldEventArgs worldEventArgs = new BaseWorldEventArgs(this);
                    tempEvent(this, worldEventArgs);
                }

                LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.BaseWorldString002);

                // 保存数据结束......
                m_Saving = false;
            }
            m_LockSave.Exit();
        }
        /// <summary>
        ///
        /// </summary>
        private static void SQL_ReloadAccount(ExecuteInfoNull sqlInfo)
        {
            s_UnitOfWork.ReloadChangedObjects();

            XPQuery <Account> accounts = new XPQuery <Account>(s_UnitOfWork);

            var accountList = from account in accounts
                              select account;

            // 账号是不会删除的,人物会删除,所以只需要添加即可。
            foreach (Account account in accountList)
            {
                WowAccount wowAccount = new WowAccount();
                wowAccount.AccountGuid = account.Oid;
                wowAccount.AccountName = account.AccountName.ToUpper();
                wowAccount.Password    = account.Password;
                wowAccount.Locked      = account.IsLocked;
                wowAccount.Banned      = account.IsBanned;

                wowAccount.AccessLevel = (AccessLevel)account.GMLevel;
                wowAccount.IsTBC       = account.IsTBC;

                s_WowAccountManager.Add(wowAccount.AccountName, wowAccount);
            }

            LOGs.WriteLine(LogMessageType.MSG_INFO, "Wow帐号:读取数据库内的 Wow 帐号完成");
        }
Beispiel #8
0
        /// <summary>
        /// 开始服务
        /// </summary>
        /// <param name="strHostNamePort">地址和端口</param>
        /// <returns></returns>
        public bool StartServer(string strHostNamePort)
        {
            if (string.IsNullOrEmpty(strHostNamePort) == true)
            {
                throw new ArgumentException("Listener.StartServer(...) - string.IsNullOrEmpty(...) == true error!", "strHostNamePort");
            }

            if (m_SocketServer.IsListened == true)
            {
                throw new Exception("Listener.StartServer(...) - m_SocketServer.IsConnected == true error!");
            }

            if (m_SocketServer.StartServer(strHostNamePort) == true)
            {
                // 初始化Disposed
                m_LockDisposed.SetValid();

                LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.ListenerString002, strHostNamePort);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 调用ClientSocketHandler.CloseSocket(...)的时候会产生此调用
        /// </summary>
        internal void OnDisconnect()
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "OnDisconnect...... 0");

            // 默认是有效地,只检测有没有已经断开,如果已经断开,则不继续处理
            if (m_Running.SetInvalid() == false)
            {
                return;
            }

            LOGs.WriteLine(LogMessageType.MSG_HACK, "OnDisconnect...... 1");

            m_Socket.Free();

            // 如果还存在需要发送的数据,则直接清空
            if (m_SendQueue.IsEmpty == false)
            {
                m_SendQueue.Clear(); // 内部已经有锁定
            }
            // 断开的通知事件
            EventHandler <NetStateDisconnectEventArgs> tempEvent = m_EventDisconnect;

            if (tempEvent != null)
            {
                NetStateDisconnectEventArgs netStateDisconnectEventArgs = new NetStateDisconnectEventArgs(this);
                tempEvent(this, netStateDisconnectEventArgs);
            }

            // 放入无效客户端的集合内,等待处理
            m_World.DisposedNetStates(this);

            LOGs.WriteLine(LogMessageType.MSG_INFO, LanguageString.SingletonInstance.NetStateString002, this);
        }
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void Realm_HandleRegisterRealmResult(NetState netState, PacketReader packetReader)
        {
            RealmExtendData extendData = netState.GetComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRegisterRealmResult(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == true)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRegisterRealmResult(...) - extendData.IsLoggedIn == true error!");
                return;
            }

            uint iRealmSerial = packetReader.ReadUInt32();

            extendData.RegisterRealmResult.Serial = new Serial(iRealmSerial);

            // 已经登陆
            extendData.IsLoggedIn = true;

            // 3分钟 向服务端发一次心跳信号
            TimeSlice.StartTimeSlice(TimerPriority.Lowest, TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(3), new TimeSliceCallback(SendPing));

            LOGs.WriteLine(LogMessageType.MSG_INFO, "RealmServer:登陆RealmServer服务器成功 返回的标示ID({0})", extendData.RegisterRealmResult.Serial.ToString());
        }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        private bool ListenerDomainServer()
        {
            if (m_ConfigDomain == null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.DomainString001);

                return(false);
            }

            //////////////////////////////////////////////////////////////////////////
            // 开始监听端口

            if (m_ConfigDomain.DomainHost == string.Empty)
            {
                if (m_Listener.StartServer(m_ConfigDomain.DomainPort) == false)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.DomainString002, m_ConfigDomain.DomainPort);

                    return(false);
                }
            }
            else
            {
                string strHostNamePort = m_ConfigDomain.DomainHost + ":" + m_ConfigDomain.DomainPort;

                if (m_Listener.StartServer(strHostNamePort) == false)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.DomainString003, strHostNamePort);

                    return(false);
                }
            }

            return(true);
        }
Beispiel #12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public GameEntityT CreateNewInstance <GameEntityT>() where GameEntityT : WorldEntity
        {
            if (m_ConstructorInstance != null)
            {
                object returnObject = m_ConstructorInstance.Invoke();

                GameEntityT creature = returnObject as GameEntityT;
                if (creature == null)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.CreateNewInstance(...) - creature == null error!");
                    return(null);
                }

                return(creature);
            }
            else
            {
                m_ConstructorInstance = DynamicCalls.GetInstanceCreator(GetType());
                if (m_ConstructorInstance == null)
                {
                    throw new Exception("GameEntity.CreateNewInstance(...) - m_ConstructorInstance == null error!");
                }

                GameEntityT creature = m_ConstructorInstance.Invoke() as GameEntityT;
                if (creature == null)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.CreateNewInstance(...) - creature == null error!");
                    return(null);
                }

                return(creature);
            }
        }
Beispiel #13
0
        /// <summary>
        /// 开始连接服务端
        /// </summary>
        /// <param name="strHostNamePort">地址和端口</param>
        /// <returns></returns>
        public bool StartConnectServer(string strHostNamePort)
        {
            if (string.IsNullOrEmpty(strHostNamePort) == true)
            {
                throw new ArgumentException("Connecter.StartConnectServer(...) - string.IsNullOrEmpty(...) == true error!", "strHostNamePort");
            }

            if (m_World == null)
            {
                throw new Exception("Connecter.StartConnectServer(...) - m_World == null error!");
            }

            if (m_SocketClient.IsConnected == true)
            {
                throw new Exception("Connecter.StartConnectServer(...) - m_SocketClient.IsConnected == true error!");
            }

            if (m_SocketClient.StartConnectServer(strHostNamePort) == true)
            {
                // 初始化Disposed
                m_LockDisposed.SetValid();
                m_IsNeedSlice = true;

                LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.ConnecterString001, m_ClientSocketManager.Address);

                // 有新的连接出去需要发送全局信号处理新的连接
                m_World.SetWorldSignal();

                return(true);
            }

            return(false);
        }
Beispiel #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleRealmSplitStateRequest(NetState netState, PacketReader packetReader)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_HandleRealmSplitStateRequest...... {0} ", packetReader.Size);

            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            if (packetReader.Size < 10 /*ProcessNet.WORLD_HEAD_SIZE + 0*/)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData.Size < 10 error!");
                return;
            }

            uint iUnknown = packetReader.ReadUInt32();

            netState.Send(new Word_RealmSplitStateRequest(iUnknown));
            //netState.Send( new Word_CharEnumResponse( new WowCharacterInfo[0] ) );
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static bool BuildDefault()
        {
            try
            {
                LOGs.WriteLine(LogMessageType.MSG_SQL, "SQL: 开始建构SQL领域...");
                s_Domain = new Domain(s_ConnectionUrl, "");

                //LOGs.WriteLine( LogMessageType.MSG_INFO, "SQL: 连接 {0}", s_Domain.ConnectionUrl );
                LOGs.WriteLine(LogMessageType.MSG_SQL, "SQL: 信息 {0}", s_Domain.Driver.Info.Description);

                s_Domain.RegisterCulture(new Culture("US", "U.S. English", new CultureInfo("en-US", false)));
                s_Domain.RegisterCulture(new Culture("CN", "China. Chinese", new CultureInfo("zh-CN", false)));
                s_Domain.RegisterCulture(new Culture("TW", "Taiwan. Chinese", new CultureInfo("zh-TW", false)));
                s_Domain.Cultures["CN"].Default = true;

                s_Domain.RegisterTypes(s_RegisterTypes);

                LOGs.WriteLine(LogMessageType.MSG_SQL, "SQL: 注册 (NameSpace){0}", s_RegisterTypes);

                s_Domain.Build(DomainUpdateMode.Block);
            }
            catch (Exception exception)
            {
                LOGs.WriteLine(LogMessageType.MSG_FATALERROR, "SQL: 无法建构SQL领域 {0}", exception);
                return(false);
            }

            LOGs.WriteLine(LogMessageType.MSG_SQL, "SQL: 完成建构SQL领域");

            return(true);
        }
Beispiel #16
0
        public void WriteLineTest()
        {
            LogMessageType messageFlag = new LogMessageType(); // TODO: 初始化为适当的值
            string         strFormat   = string.Empty;         // TODO: 初始化为适当的值

            LOGs.WriteLine(messageFlag, strFormat);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
Beispiel #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packetBuffer"></param>
        /// <returns></returns>
        public static WOWClientPacketHeader GetClientPacketHeader(byte[] packetBuffer)
        {
            WOWClientPacketHeader returnPacketHeader = new WOWClientPacketHeader();

            returnPacketHeader.m_iPacketSize = (ushort)((packetBuffer[0] << 8) | packetBuffer[1]);
            returnPacketHeader.m_iPacketID   = (uint)((packetBuffer[2]) | packetBuffer[3] << 8 | packetBuffer[4] << 16 | packetBuffer[5] << 24);

            LOGs.WriteLine(LogMessageType.MSG_HACK, "GetClientPacketHeader...... 0 = {0} {1}", returnPacketHeader.m_iPacketSize, returnPacketHeader.m_iPacketID);

            return(returnPacketHeader);
        }
Beispiel #18
0
        /// <summary>
        /// 人物模板信息和物品模板信息
        /// </summary>
        private void LoadItemTemplateAndCreatureTemplate()
        {
            //////////////////////////////////////////////////////////////////////////
            // 开始在编译后的程序集合内获取人物模板信息和物品模板信息

            foreach (Assembly assembly in ProcessServer.ScriptAssemblyInfo.ScriptAssembly)
            {
                TypeCache typeCache = ProcessServer.ScriptAssemblyInfo.GetTypeCache(assembly);
                Type[]    typeArray = typeCache.Types;

                foreach (Type typeItem in typeArray)
                {
                    if (typeItem.IsSubclassOf(typeof(WowCreatureTemplate)))
                    {
                        try
                        {
                            ConstructorInfo[]   infoArray        = typeItem.GetConstructors();
                            WowCreatureTemplate creatureTemplate = (WowCreatureTemplate)infoArray[0].Invoke(null);
                            if (creatureTemplate.Serial == 0)
                            {
                                continue;
                            }

                            this.CreatureTemplateManager.AddCreatureTemplate(creatureTemplate.Serial, creatureTemplate);
                        }
                        catch (Exception)
                        {
                            Debug.WriteLine("Program.LoadItemTemplateAndCreatureTemplate(...) - WowCreatureTemplate constructor of {0} Exception error!", typeItem.ToString());
                        }
                    }
                    else if (typeItem.IsSubclassOf(typeof(WowItemTemplate)))
                    {
                        try
                        {
                            ConstructorInfo[] infoArray    = typeItem.GetConstructors();
                            WowItemTemplate   itemTemplate = (WowItemTemplate)infoArray[0].Invoke(null);

                            if (itemTemplate.Serial == 0)
                            {
                                continue;
                            }

                            this.ItemTemplateManager.AddItemTemplate(itemTemplate.Serial, itemTemplate);
                        }
                        catch (Exception)
                        {
                            Debug.WriteLine("Program.LoadItemTemplateAndCreatureTemplate(...) - WowCreatureTemplate constructor of {0} Exception error!", typeItem.ToString());
                        }
                    }
                }
            }

            LOGs.WriteLine(LogMessageType.MSG_INFO, "Wow世界:读取脚本内全部的 人物模板信息和物品模板信息 完成");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        public static void WorldServerMoveChar(NetState netState, PacketReader packetReader)
        {
            LOGs.WriteLine(LogMessageType.MSG_NONE, " WorldServerMoveChar(...)");

            WorldServerExtendData l_ExtendData = netState.ExtendData as WorldServerExtendData;

            if (l_ExtendData == null)
            {
                Debug.WriteLine("WorldPacketHandlers.WorldServerMoveChar(...) - l_ExtendData == null error!");
                return;
            }

            if (l_ExtendData.ROSEMobile.IsLoggedIn == false)
            {
                Debug.WriteLine("WorldPacketHandlers.WorldServerMoveChar(...) - l_ExtendData.m_bIsLoggedIn == true error!");
                return;
            }

            if (packetReader.Size < 18 /*( 6 + 2 + 4 + 4 + 2)*/)
            {
                Debug.WriteLine("WorldPacketHandlers.WorldServerMoveChar(...) - packetReader.Size < 22 error!");
                return;
            }

            Debug.WriteLine(string.Format("packetReader.Size {0}", packetReader.Size));

            l_ExtendData.ROSEMobile.targetid = packetReader.ReadUInt16();
            l_ExtendData.ROSEMobile.X        = (long)packetReader.ReadFloat() / 100;
            l_ExtendData.ROSEMobile.Y        = (long)packetReader.ReadFloat() / 100;
            ushort Z = packetReader.ReadUInt16();

            netState.Send(new MoveCharAck(l_ExtendData.ROSEMobile));

            Debug.WriteLine(string.Format("WorldServerMoveChar {0}, {1}, {2}", l_ExtendData.ROSEMobile.targetid, l_ExtendData.ROSEMobile.X, l_ExtendData.ROSEMobile.Y));

            IPooledEnumerable pooledEnumerable = netState.Mobile.Map.GetClientsInRange(netState.Mobile.Location);

            if (pooledEnumerable == null)
            {
                return;
            }

            foreach (object client in pooledEnumerable)
            {
                NetState l_NetState = client as NetState;
                if (l_NetState == null)
                {
                    break;
                }

                l_NetState.Send(new MoveCharAck(l_ExtendData.ROSEMobile));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        public bool AddContainer(long lContainerSlot, ContainerT itemContainerT)
        {
            if (itemContainerT == null)
            {
                throw new Exception("BaseBagHandler.AddContainer(...) - itemContainerT == null error!");
            }

            if (itemContainerT.ContainerOwner == null)
            {
                throw new Exception("BaseBagHandler.AddContainer(...) - itemContainerT.Item == null error!");
            }

            if (lContainerSlot > this.MaxSlot || lContainerSlot < this.MinSlot)
            {
                return(false);
            }

            ContainerT findItemContainerT = FindContainerAtSlot(lContainerSlot);

            if (findItemContainerT != null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, "BaseBagHandler.AddContainer(...) - findItemContainerT != null error!");

                return(false);
            }

            EventHandler <BeforeAddItemContainerCallEventArgs <ContainerT, ItemT> > tempBeforeEventArgs = m_ThreadEventBeforeAddItemContainerCall;

            if (tempBeforeEventArgs != null)
            {
                BeforeAddItemContainerCallEventArgs <ContainerT, ItemT> eventArgs = new BeforeAddItemContainerCallEventArgs <ContainerT, ItemT>(itemContainerT, this);
                tempBeforeEventArgs(this, eventArgs);

                if (eventArgs.IsCancel == true)
                {
                    return(false);
                }
            }

            m_ToteContainers.Add(lContainerSlot, itemContainerT);
            itemContainerT.ContainerOwner.SlotId = lContainerSlot;

            EventHandler <AfterAddItemContainerCallEventArgs <ContainerT, ItemT> > tempAfterEventArgs = m_ThreadEventAfterAddItemContainerCall;

            if (tempAfterEventArgs != null)
            {
                AfterAddItemContainerCallEventArgs <ContainerT, ItemT> eventArgs = new AfterAddItemContainerCallEventArgs <ContainerT, ItemT>(itemContainerT, this);
                tempAfterEventArgs(this, eventArgs);
            }

            return(true);
        }
Beispiel #21
0
        /// <summary>
        /// 给出人物范围内的道具
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public IEnumerable <GameEntityT> GetEntitysInRange <GameEntityT>(int iRange) where GameEntityT : WorldEntity
        {
            BaseMap tempMap = this.Map;

            if (tempMap == null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.GetEntitysInRange(...) - tempMap == null error!");

                return(NullEnumerable <GameEntityT> .SingletonInstance);
            }

            return(tempMap.GetEntitysInRange <GameEntityT>(this.Location, iRange));
        }
Beispiel #22
0
        /// <summary>
        /// 给出人物范围内的客户端
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public IEnumerable <CharacterT> GetPlayersInRange <CharacterT>(int iRange) where CharacterT : BaseCharacter
        {
            BaseMap tempMap = this.Map;

            if (tempMap == null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, "GameEntity.GetItemsInRange(...) - tempMap == null error!");

                return(NullEnumerable <CharacterT> .SingletonInstance);
            }

            return(tempMap.GetCreaturesInRange <CharacterT>(this.Location, iRange));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="iContainerSlotForm"></param>
        /// <param name="iItemSlotForm"></param>
        /// <param name="iContainerSlotTo"></param>
        /// <returns></returns>
        public bool MoveSubItemToSpecialContainer(long lContainerSlotForm, long lItemSlotForm, long lContainerSlotTo)
        {
            ContainerT itemContainerFormT = FindContainerAtSlot(lContainerSlotForm);

            if (itemContainerFormT == null)
            {
                return(false);
            }

            ItemT itemFormV = itemContainerFormT.FindSubItemAtSlot(lItemSlotForm);

            if (itemFormV == null)
            {
                return(false);
            }

            ContainerT itemContainerToT = FindContainerAtSlot(lContainerSlotTo);

            if (itemContainerToT == null)
            {
                return(false);
            }

            long lRetrunItemSlot = BaseItem.SlotNotSet;

            if (itemContainerToT.TryFindFreeSlot(ref lRetrunItemSlot) == false)
            {
                return(false);
            }

            if (itemContainerFormT.RemoveSubItem(lItemSlotForm) == false)
            {
                return(false);
            }

            if (itemContainerToT.AddSubItem(lRetrunItemSlot, itemFormV) == false)
            {
                if (itemContainerFormT.AddToFreeSlot(itemFormV) == false)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, "BaseBagHandler.MoveItem(...) - itemContainerFormT.AddToFreeSlot(...) error(No Complete, Lost itemFormV)!");
                    return(false);
                }

                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #24
0
        /// <summary>
        ///
        /// </summary>
        private bool ConnectToDomainServer()
        {
            if (m_ConfigZoneCluster == null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.ZoneClusterString001);

                return(false);
            }

            //////////////////////////////////////////////////////////////////////////
            // 开始监听端口

            if (m_ConfigZoneCluster.ZoneClusterHost == string.Empty)
            {
                if (m_Listener.StartServer(m_ConfigZoneCluster.ZoneClusterPort) == false)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.ZoneClusterString002, m_ConfigZoneCluster.ZoneClusterPort);

                    return(false);
                }
            }
            else
            {
                string strHostNamePort = m_ConfigZoneCluster.ZoneClusterHost + ":" + m_ConfigZoneCluster.ZoneClusterPort;

                if (m_Listener.StartServer(strHostNamePort) == false)
                {
                    LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.ZoneClusterString003, strHostNamePort);

                    return(false);
                }
            }


            //////////////////////////////////////////////////////////////////////////
            // 连接Domain服务端

            string strHostNamePort2 = m_ConfigZoneCluster.DomainHost + ":" + m_ConfigZoneCluster.DomainPort;

            if (m_Connecter.StartConnectServer(strHostNamePort2) == false)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, LanguageString.SingletonInstance.ZoneClusterString004, strHostNamePort2);

                m_Listener.Dispose();
                return(false);
            }

            return(true);
        }
Beispiel #25
0
        /// <summary>
        ///
        /// </summary>
        public Word_AddonInfo(byte[] unPacked)
            : base((long)WordOpCode.SMSG_ADDON_INFO, 0)
        {
            WriterStream.Write((ushort)0 /* 2 + 4 */);                 // Size
            WriterStream.Write((ushort)WordOpCode.SMSG_ADDON_INFO);    // ID
            //////////////////////////////////////////////////////////////////////////

            string name    = string.Empty;
            ushort Enable  = 0; // based on the parsed files from retool
            uint   crc     = 0;
            uint   unknown = 0;

            PacketReader packetReader = new PacketReader(unPacked, unPacked.Length, 0);

            while (packetReader.Position < packetReader.Size)
            {
                name    = packetReader.ReadUTF8StringSafe();
                Enable  = packetReader.ReadUInt16();
                crc     = packetReader.ReadUInt32();
                unknown = packetReader.ReadUInt32();

                if (name == null || name == string.Empty)
                {
                    continue;
                }

                LOGs.WriteLine(LogMessageType.MSG_HACK, "Word_AddonInfo...... {0} {1} {2} {3} {4} {5}", name, Enable, crc, unknown, packetReader.Position, packetReader.Size);

                // Hacky fix, Yea I know its a hacky fix I will make a proper handler one's I got the crc crap
                //if ( crc != 0x4C1C776D ) // CRC of public key version 2.0.1
                {
                    //LOGs.WriteLine( LogMessageType.MSG_HACK, "Word_AddonInfo...... 0 " );
                    //WriterStream.Write( PublicKey, 0, PublicKey.Length/*264 大小*/ ); // part of the hacky fix
                }
                //else
                {
                    LOGs.WriteLine(LogMessageType.MSG_HACK, "Word_AddonInfo...... 1 ");
                    WriterStream.Write((byte)0x02);
                    WriterStream.Write((byte)0x01);
                    WriterStream.Write((byte)0x00);
                    WriterStream.Write((uint)0x00);
                    WriterStream.Write((byte)0x00);
                }
            }

            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek(0, SeekOrigin.Begin);
            WriterStream.Write((ushort)ByteOrder.NetToHost((ushort)(WriterStream.Length - 2 /*Size本身的大小*/)));
        }
Beispiel #26
0
        /// <summary>
        /// 读取人物等级信息和创建信息
        /// </summary>
        private void LoadPlayerCreateInfoAndLevelInfo()
        {
            //////////////////////////////////////////////////////////////////////////
            // 开始在编译后的程序集合内获取密码
            Type createInfoType = ProcessServer.ScriptAssemblyInfo.FindTypeByFullName("Demo.WOW.Script.Character.InitCreateInfo");

            if (createInfoType != null)
            {
                MethodInfo createInfoMethod = createInfoType.GetMethod("InitWowCharacterCreateInfo", BindingFlags.Static | BindingFlags.Public);
                if (createInfoMethod != null)
                {
                    object[] parameters = new object[1];
                    parameters[0] = this.m_GlobalCreateInfo;
                    createInfoMethod.Invoke(null, parameters);
                }
                else
                {
                    Debug.WriteLine("WowWorld.LoadPlayerCreateInfoAndLevelInfo(...) - createInfoMethod == null error!");
                }
            }
            else
            {
                Debug.WriteLine("WowWorld.LoadPlayerCreateInfoAndLevelInfo(...) - createInfoType == null error!");
            }

            // 速度太慢需要改进
            Type levelInfoType = ProcessServer.ScriptAssemblyInfo.FindTypeByFullName("Demo.WOW.Script.Character.InitLevelInfo");

            if (levelInfoType != null)
            {
                MethodInfo levelInfoMethod = levelInfoType.GetMethod("InitWowCharacterLevelInfo", BindingFlags.Static | BindingFlags.Public);
                if (levelInfoMethod != null)
                {
                    object[] parameters = new object[1];
                    parameters[0] = this.m_GlobalLevelInfo;
                    levelInfoMethod.Invoke(null, parameters);
                }
                else
                {
                    Debug.WriteLine("WowWorld.LoadPlayerCreateInfoAndLevelInfo(...) - levelInfoMethod == null error!");
                }
            }
            else
            {
                Debug.WriteLine("WowWorld.LoadPlayerCreateInfoAndLevelInfo(...) - levelInfoType == null error!");
            }

            LOGs.WriteLine(LogMessageType.MSG_INFO, "Wow世界:读取脚本内全部的 人物等级信息和创建信息 完成");
        }
        /// <summary>
        /// And this method can dump the result of a query
        /// </summary>
        /// <param name="queryResult"></param>
        internal static void Dump( QueryResult queryResult )
        {
            LOGs.WriteLine( LogMessageType.MSG_SQL, "QueryResult: 查询结果开始:" );

            foreach ( DataObject dataObject in queryResult )
            {
                IDumpable dumpable = dataObject as IDumpable;
                if ( dumpable != null )
                    dumpable.Dump( Console.Out );
                else
                    LOGs.WriteLine( LogMessageType.MSG_SQL, "{0}, ID = {1}", dataObject.GetType().BaseType.Name, dataObject.ID );
            }

            LOGs.WriteLine( LogMessageType.MSG_SQL, "QueryResult: 查询结果结束." );
        }
Beispiel #28
0
        /// <summary>
        /// 再次处理没处理完全的数据(仅调用一次)
        /// </summary>
        /// <param name="netState"></param>
        private void OnceAgainReceive(NetState netState)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "OnceAgainReceive...... 0");

            if (netState.Running)
            {
                LOGs.WriteLine(LogMessageType.MSG_HACK, "OnceAgainReceive...... 1");

                if (netState.ReceiveBuffer.Length > 0)
                {
                    OnReceive(netState);
                }

                LOGs.WriteLine(LogMessageType.MSG_HACK, "OnceAgainReceive...... 2");
            }
        }
Beispiel #29
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public GoldItem Instance()
        {
            GoldItem goldItem = base.Instance <GoldItem>();

            if (goldItem == null)
            {
                LOGs.WriteLine(LogMessageType.MSG_ERROR, "GoldLoot.Instance(...) - goldItem == null error!");

                return(null);
            }
            else
            {
                goldItem.MinGold = m_MinGold;
                goldItem.MaxGold = m_MaxGold;

                return(goldItem);
            }
        }
Beispiel #30
0
        /// <summary>
        /// 检查用户是否在线,根据用户传输数据包的时间来判定
        /// </summary>
        /// <returns></returns>
        internal bool CheckAlive()
        {
            if (this.Running == false)
            {
                return(false);
            }

            if (m_bCheckAlive == false || DateTime.Now < m_NextCheckActivity)
            {
                return(true);
            }

            this.Dispose();

            LOGs.WriteLine(LogMessageType.MSG_NOTICE, LanguageString.SingletonInstance.NetStateString001, this);

            return(false);
        }