Esempio n. 1
0
        /// <summary>
        /// Select one of the 3 characters. Sends a WELCOME_REQUEST packet.
        /// </summary>
        /// <param name="id">id of the selected character</param>
        /// <param name="data">returned data from the server</param>
        /// <returns>true on successful transfer, false otherwise</returns>
        public bool SelectCharacter(int id, out WelcomeRequestData data)
        {
            data = null;
            if (!m_client.ConnectedAndInitialized || !Initialized)
            {
                return(false);
            }

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

            builder.AddInt(id);

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

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

            data = m_welcome_requestData;

            return(true);
        }
Esempio n. 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);
        }
Esempio n. 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();
            }
        }
Esempio n. 4
0
		public void ApplyWelcomeRequest(PacketAPI api, WelcomeRequestData data)
		{
			MainPlayer.SetPlayerID(data.PlayerID);
			MainPlayer.SetActiveCharacter(api, data.ActiveCharacterID);
			MainPlayer.ActiveCharacter.CurrentMap = data.MapID;

			CheckMap(data.MapID, data.MapRID, data.MapLen);
			_checkPub(InitFileType.Item, data.EifRid, data.EifLen);
			_checkPub(InitFileType.Npc, data.EnfRid, data.EnfLen);
			_checkPub(InitFileType.Spell, data.EsfRid, data.EsfLen);
			_checkPub(InitFileType.Class, data.EcfRid, data.EcfLen);

			MainPlayer.ActiveCharacter.Name = data.Name;
			MainPlayer.ActiveCharacter.Title = data.Title;
			MainPlayer.ActiveCharacter.GuildName = data.GuildName;
			MainPlayer.ActiveCharacter.GuildRankStr = data.GuildRankStr;
			MainPlayer.ActiveCharacter.GuildRankNum = data.GuildRankNum;
			MainPlayer.ActiveCharacter.Class = data.ClassID;
			MainPlayer.ActiveCharacter.PaddedGuildTag = data.PaddedGuildTag;
			MainPlayer.ActiveCharacter.AdminLevel = data.AdminLevel;

			MainPlayer.ActiveCharacter.Stats = new CharStatData
			{
				Level = data.Level,
				Experience = data.Exp,
				Usage = data.Usage,

				HP = data.HP,
				MaxHP = data.MaxHP,
				TP = data.TP,
				MaxTP = data.MaxTP,
				SP = data.MaxSP,
				MaxSP = data.MaxSP,

				StatPoints = data.StatPoints,
				SkillPoints = data.SkillPoints,
				MinDam = data.MinDam,
				MaxDam = data.MaxDam,
				Karma = data.Karma,
				Accuracy = data.Accuracy,
				Evade = data.Evade,
				Armor = data.Armor,
				Str = data.DispStr,
				Int = data.DispInt,
				Wis = data.DispWis,
				Agi = data.DispAgi,
				Con = data.DispCon,
				Cha = data.DispCha
			};

			Array.Copy(data.PaperDoll, MainPlayer.ActiveCharacter.PaperDoll, (int) EquipLocation.PAPERDOLL_MAX);
			JailMap = data.JailMap;
		}
Esempio n. 5
0
        public void ApplyWelcomeRequest(PacketAPI api, WelcomeRequestData data)
        {
            MainPlayer.SetPlayerID(data.PlayerID);
            MainPlayer.SetActiveCharacter(api, data.ActiveCharacterID);
            MainPlayer.ActiveCharacter.CurrentMap = data.MapID;

            CheckMap(data.MapID, data.MapRID, data.MapLen);
            _checkPub(InitFileType.Item, data.EifRid, data.EifLen);
            _checkPub(InitFileType.Npc, data.EnfRid, data.EnfLen);
            _checkPub(InitFileType.Spell, data.EsfRid, data.EsfLen);
            _checkPub(InitFileType.Class, data.EcfRid, data.EcfLen);

            MainPlayer.ActiveCharacter.Name = data.Name;
            MainPlayer.ActiveCharacter.Title = data.Title;
            MainPlayer.ActiveCharacter.GuildName = data.GuildName;
            MainPlayer.ActiveCharacter.GuildRankStr = data.GuildRankStr;
            MainPlayer.ActiveCharacter.GuildRankNum = data.GuildRankNum;
            MainPlayer.ActiveCharacter.Class = data.ClassID;
            MainPlayer.ActiveCharacter.PaddedGuildTag = data.PaddedGuildTag;
            MainPlayer.ActiveCharacter.AdminLevel = data.AdminLevel;

            MainPlayer.ActiveCharacter.Stats = new CharStatData
            {
                level = data.Level,
                exp = data.Exp,
                usage = data.Usage,

                hp = data.HP,
                maxhp = data.MaxHP,
                tp = data.TP,
                maxtp = data.MaxTP,
                sp = data.MaxSP,
                maxsp = data.MaxSP,

                statpoints = data.StatPoints,
                skillpoints = data.SkillPoints,
                mindam = data.MinDam,
                maxdam = data.MaxDam,
                karma = data.Karma,
                accuracy = data.Accuracy,
                evade = data.Evade,
                armor = data.Armor,
                disp_str = data.DispStr,
                disp_int = data.DispInt,
                disp_wis = data.DispWis,
                disp_agi = data.DispAgi,
                disp_con = data.DispCon,
                disp_cha = data.DispCha
            };

            Array.Copy(data.PaperDoll, MainPlayer.ActiveCharacter.PaperDoll, (int) EquipLocation.PAPERDOLL_MAX);
            JailMap = data.JailMap;
        }
Esempio n. 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;
		}
Esempio n. 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();
		}
Esempio n. 8
0
		/// <summary>
		/// Select one of the 3 characters. Sends a WELCOME_REQUEST packet.
		/// </summary>
		/// <param name="id">id of the selected character</param>
		/// <param name="data">returned data from the server</param>
		/// <returns>true on successful transfer, false otherwise</returns>
		public bool SelectCharacter(int id, out WelcomeRequestData data)
		{
			data = null;
			if (!m_client.ConnectedAndInitialized || !Initialized)
				return false;

			Packet builder = new Packet(PacketFamily.Welcome, PacketAction.Request);
			builder.AddInt(id);

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

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

			data = m_welcome_requestData;

			return true;
		}
Esempio n. 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);
		}