Beispiel #1
0
        public PacketAPI(EOClient client)
        {
            if (!client.Connected)
            {
                throw new ArgumentException("The client must be connected to the server in order to construct the API!");
            }
            m_client = client;

            //each of these sets up members of the partial PacketAPI class relevant to a particular packet family
            _createAccountMembers();
            _createAdminInteractMembers();
            _createAttackMembers();
            _createAvatarMembers();
            _createCharacterMembers();
            _createChestMembers();
            _createConnectionMembers();
            _createDoorMembers();
            _createFaceMembers();
            _createInitMembers();
            _createItemMembers();
            _createLoginMembers();
            _createMessageMembers();
            _createPaperdollMembers();
            _createPlayersMembers();
            _createNPCMembers();
            _createRecoverMembers();
            _createRefreshMembers();
            _createWalkMembers();
            _createWarpMembers();
            _createWelcomeMembers();
        }
Beispiel #2
0
		public PacketAPI(EOClient client)
		{
			if (!client.Connected)
			{
				throw new ArgumentException("The client must be connected to the server in order to construct the API!");
			}
			m_client = client;

			//each of these sets up members of the partial PacketAPI class relevant to a particular packet family
			_createAccountMembers();
			_createAdminInteractMembers();
			_createAttackMembers();
			_createAvatarMembers();
			_createBankMembers();
			_createCharacterMembers();
			_createChestMembers();
			_createConnectionMembers();
			_createDoorMembers();
			_createEffectMembers();
			_createEmoteMembers();
			_createFaceMembers();
			_createInitMembers();
			_createItemMembers();
			_createLockerMembers();
			_createLoginMembers();
			_createMessageMembers();
			_createMusicMembers();
			_createPaperdollMembers();
			_createPartyMembers();
			_createPlayersMembers();
			_createNPCMembers();
			_createQuestMembers();
			_createRecoverMembers();
			_createRefreshMembers();
			_createShopMembers();
			_createSpellMembers();
			_createStatSkillMembers();
			_createTalkMembers();
			_createTradeMembers();
			_createWalkMembers();
			_createWarpMembers();
			_createWelcomeMembers();
		}
Beispiel #3
0
		//all bots are going to want to do the init handshake with the server
		public virtual void Initialize()
		{
			_client = new EOClient();
			if (!_client.ConnectToServer(_host, _port))
				throw new ArgumentException(string.Format("Bot {0}: Unable to connect to server! Host={1} Port={2}", _index, _host, _port));
			_api = new PacketAPI(_client);

			InitData data;
			if (!_api.Initialize(0, 0, 28, EOLib.HDDSerial.GetHDDSerial(), out data))
				throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index));
			_client.SetInitData(data);

			if (!_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID))
				throw new TimeoutException(string.Format("Bot {0}: Failed initialization handshake with server!", _index));

			if (!_api.Initialized || !_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK)
				throw new InvalidOperationException(string.Format("Bot {0}: Invalid response from server or connection failed! Must receive an OK reply.", _index));

			_initialized = true;
		}
Beispiel #4
0
		private World() //private: don't allow construction of the world using 'new'
		{
			_tryLoadItems();
			_tryLoadNPCs();
			_tryLoadSpells();
			_tryLoadClasses();
			
			//initial capacity of 32: most players won't travel between too many maps in a gaming session
			MapCache = new Dictionary<int, MapFile>(32);
			DataFiles = new Dictionary<DataFiles, EDFFile>(12); //12 files total
			m_player = new Player();
			m_config = new IniReader(@"config\settings.ini");
			if (!m_config.Load())
				throw new WorldLoadException("Unable to load the configuration file!");

			//client construction: logging for when packets are sent/received
			m_client = new EOClient();
			((EOClient) m_client).EventSendData +=
				dte => Logger.Log("SEND thread: Processing       {4} packet Family={0,-13} Action={1,-8} sz={2,-5} data={3}",
					Enum.GetName(typeof (PacketFamily), dte.PacketFamily),
					Enum.GetName(typeof (PacketAction), dte.PacketAction),
					dte.RawByteData.Length,
					dte.ByteDataHexString,
					dte.Type == DataTransferEventArgs.TransferType.Send
						? "ENC"
						: dte.Type == DataTransferEventArgs.TransferType.SendRaw ? "RAW" : "ERR");
			((EOClient) m_client).EventReceiveData +=
				dte => Logger.Log("RECV thread: Processing {0} packet Family={1,-13} Action={2,-8} sz={3,-5} data={4}",
					dte.PacketHandled ? "  handled" : "UNHANDLED",
					Enum.GetName(typeof (PacketFamily), dte.PacketFamily),
					Enum.GetName(typeof (PacketAction), dte.PacketAction),
					dte.RawByteData.Length,
					dte.ByteDataHexString);

			((EOClient) m_client).EventDisconnect += () =>
			{
				EOGame.Instance.ShowLostConnectionDialog();
				EOGame.Instance.ResetWorldElements();
				EOGame.Instance.SetInitialGameState();
			};
		}
Beispiel #5
0
        public EOBot(int index, string host, int port)
        {
            m_index = index + 1;

            m_client = new EOClient();
            if (!m_client.ConnectToServer(host, port))
                throw new ArgumentException();
            m_api = new PacketAPI(m_client);

            InitData data;
            if (!m_api.Initialize(0, 0, 28, EOLib.Win32.GetHDDSerial(), out data))
                throw new TimeoutException();
            m_client.SetInitData(data);

            if (!m_api.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID))
                throw new TimeoutException();

            if (!m_api.Initialized || !m_client.ConnectedAndInitialized || data.ServerResponse != InitReply.INIT_OK)
                throw new InvalidOperationException();

            m_terminationEvent = new AutoResetEvent(false);
        }
Beispiel #6
0
 public void Dispose()
 {
     if (m_client != null)
     {
         m_client.Dispose();
         m_client = null;
     }
     if (m_api != null)
     {
         m_api.Dispose();
         m_api = null;
     }
     if (m_terminationEvent != null)
     {
         m_terminationEvent.Dispose();
         m_terminationEvent = null;
     }
     if (s_partyEvent != null)
     {
         s_partyEvent.Dispose();
         s_partyEvent = null;
     }
 }
Beispiel #7
0
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				Terminate();

				if (_workerThread != null)
					_workerThread.Join();

				if (_client != null)
				{
					_client.Dispose();
					_client = null;
				}

				if (_api != null)
				{
					_api.Dispose();
					_api = null;
				}

				if (_terminationEvent != null)
				{
					_terminationEvent.Dispose();
					_terminationEvent = null;
				}

				if (_cancelTokenSource != null)
				{
					_cancelTokenSource.Dispose();
					_cancelTokenSource = null;
				}
			}
		}