예제 #1
0
        public bool WelcomeMessage(int id, out WelcomeMessageData data)
        {
            data = null;
            if (!m_client.ConnectedAndInitialized || !Initialized)
            {
                return(false);
            }

            Packet builder = new Packet(PacketFamily.Welcome, PacketAction.Message);

            builder.AddThree(0x00123456);             //?
            builder.AddInt(id);

            if (!m_client.SendPacket(builder))
            {
                return(false);
            }

            if (!m_welcome_responseEvent.WaitOne(Constants.ResponseTimeout))
            {
                return(false);
            }

            data = m_welcome_messageData;
            m_client.IsInGame = true;

            return(true);
        }
예제 #2
0
        private void _createWelcomeMembers()
        {
            m_welcome_responseEvent = new AutoResetEvent(false);
            m_welcome_requestData   = null;
            m_welcome_messageData   = null;

            m_client.AddPacketHandler(new FamilyActionPair(PacketFamily.Welcome, PacketAction.Reply), _handleWelcomeReply, false);
        }
예제 #3
0
        private void _handleWelcomeReply(Packet pkt)
        {
            WelcomeReply reply = (WelcomeReply)pkt.GetShort();

            bool success;

            switch (reply)
            {
            case WelcomeReply.RequestGranted:
                m_welcome_requestData = new WelcomeRequestData(pkt);
                success = pkt.GetByte() == 255;
                break;

            case WelcomeReply.WelcomeMessage:
                if (pkt.GetByte() != 255)
                {
                    return;                                               //error, something is off.
                }
                try
                {
                    m_welcome_messageData = new WelcomeMessageData(pkt);
                    success = true;
                }
                catch { success = false; }
                break;

            default:
                success = false;                         //malformed packet
                break;
            }

            if (success)
            {
                m_welcome_responseEvent.Set();
            }
        }
예제 #4
0
		public void ApplyWelcomeMessage(WelcomeMessageData data)
		{
			MainPlayer.ActiveCharacter.Weight = data.Weight;
			MainPlayer.ActiveCharacter.MaxWeight = data.MaxWeight;

			MainPlayer.ActiveCharacter.Inventory.Clear();
			MainPlayer.ActiveCharacter.Inventory.AddRange(data.Inventory);
			MainPlayer.ActiveCharacter.Spells.Clear();
			MainPlayer.ActiveCharacter.Spells.AddRange(data.Spells);

			if (ActiveMapRenderer.MapRef == null)
				ActiveMapRenderer.SetActiveMap(MapCache[MainPlayer.ActiveCharacter.CurrentMap]);

			ActiveMapRenderer.ClearOtherPlayers();
			ActiveMapRenderer.ClearOtherNPCs();
			ActiveMapRenderer.ClearMapItems();

			var characterList = data.CharacterData.ToList();
			var mainCharacter = characterList.Find(x => x.Name.ToLower() == MainPlayer.ActiveCharacter.Name.ToLower());
			MainPlayer.ActiveCharacter.ApplyData(mainCharacter, false); //do NOT copy paperdoll data over the existing!
			characterList.Remove(mainCharacter);

			foreach (var character in characterList)
				ActiveMapRenderer.AddOtherPlayer(character);
			foreach (var npc in data.NPCData)
				ActiveMapRenderer.AddOtherNPC(npc);
			foreach (var item in data.MapItemData)
				ActiveMapRenderer.AddMapItem(item);
		}
예제 #5
0
        public void ApplyWelcomeMessage(WelcomeMessageData data)
        {
            MainPlayer.ActiveCharacter.Weight = data.Weight;
            MainPlayer.ActiveCharacter.MaxWeight = data.MaxWeight;

            MainPlayer.ActiveCharacter.Inventory.Clear();
            MainPlayer.ActiveCharacter.Inventory.AddRange(data.Inventory);
            MainPlayer.ActiveCharacter.Spells.Clear();
            MainPlayer.ActiveCharacter.Spells.AddRange(data.Spells);

            ActiveMapRenderer.ClearOtherPlayers();
            ActiveMapRenderer.ClearOtherNPCs();
            ActiveMapRenderer.ClearMapItems();

            foreach (var character in data.CharacterData)
            {
                if (character.Name.ToLower() == MainPlayer.ActiveCharacter.Name.ToLower())
                    MainPlayer.ActiveCharacter.ApplyData(character, false); //do NOT copy paperdoll data over the existing!
                else
                    ActiveMapRenderer.AddOtherPlayer(character);
            }

            foreach (var npc in data.NPCData)
                ActiveMapRenderer.AddOtherNPC(npc);
            foreach (var item in data.MapItemData)
                ActiveMapRenderer.AddMapItem(item);
        }
예제 #6
0
		public bool DoWelcomePacketsForFirstCharacter(CharacterRenderData[] loginData, out WelcomeRequestData welcomeReqData, out WelcomeMessageData welcomeMsgData)
		{
			welcomeMsgData = null;

			var res = _api.SelectCharacter(loginData[0].ID, out welcomeReqData);
			if (!res)
			{
				_errorMessage();
				return false;
			}

			Thread.Sleep(500);

			res = _api.WelcomeMessage(welcomeReqData.ActiveCharacterID, out welcomeMsgData);
			if (!res)
			{
				_errorMessage();
				return false;
			}
			return true;
		}
예제 #7
0
		private void _handleWelcomeReply(Packet pkt)
		{
			WelcomeReply reply = (WelcomeReply) pkt.GetShort();
			
			bool success;
			switch (reply)
			{
				case WelcomeReply.RequestGranted:
					m_welcome_requestData = new WelcomeRequestData(pkt);
					success = pkt.GetByte() == 255;
					break;
				case WelcomeReply.WelcomeMessage:
					if (pkt.GetByte() != 255) return; //error, something is off.
					try
					{
						m_welcome_messageData = new WelcomeMessageData(pkt);
						success = true;
					}
					catch { success = false; }
					break;
				default:
					success = false; //malformed packet
					break;
			}

			if(success)
				m_welcome_responseEvent.Set();
		}
예제 #8
0
		public bool WelcomeMessage(int id, out WelcomeMessageData data)
		{
			data = null;
			if (!m_client.ConnectedAndInitialized || !Initialized)
				return false;

			Packet builder = new Packet(PacketFamily.Welcome, PacketAction.Message);
			builder.AddThree(0x00123456); //?
			builder.AddInt(id);

			if (!m_client.SendPacket(builder))
				return false;

			if (!m_welcome_responseEvent.WaitOne(Constants.ResponseTimeout))
				return false;

			data = m_welcome_messageData;
			m_client.IsInGame = true;

			return true;
		}
예제 #9
0
		private void _createWelcomeMembers()
		{
			m_welcome_responseEvent = new AutoResetEvent(false);
			m_welcome_requestData = null;
			m_welcome_messageData = null;

			m_client.AddPacketHandler(new FamilyActionPair(PacketFamily.Welcome, PacketAction.Reply), _handleWelcomeReply, false);
		}
예제 #10
0
		private async Task<bool> FetchFilesAsync()
		{
			if (!await _getMapTask())
				return false;
			if (!await _getEIFTask())
				return false;
			if (!await _getENFTask())
				return false;
			if (!await _getESFTask())
				return false;
			if (!await _getECFTask())
				return false;

			caption.Text = loading;
			WelcomeMessageData data;
			if (!m_api.WelcomeMessage(World.Instance.MainPlayer.ActiveCharacter.ID, out data))
				return false;
			WelcomeData = data;

			await TaskFramework.Delay(1000);
			return true;
		}