/* The method that will execute OnFrame */ void Pulse(object sender, LSEventArgs e) { /* We have to use a FrameLock to do anything, even OnFrame */ using (new FrameLock(true)) { /* If Login exists, we're going to want to detach OnFrame so that we may do our login work */ _login = new EVE.ISXEVE.Login(); _charSelect = new EVE.ISXEVE.CharSelect(); /* We must do this because trying to check Me validity when it isn't valid crashes, as does attempting * to get a reference to any in-game object */ if (_login.IsValid || _charSelect.IsValid) { Logging.OnLogMessage(this, "Pulse(): At either Login or CharSelect screen; detaching and returning."); DetachEvent(); _logIn.StartLogIn(); return; } /* If we're not at login or char select, we can get a Me reference */ _me = new EVE.ISXEVE.Me(); Logging.OnLogMessage(this, "Pulse(): Got new Me reference, Me.Corporation == " + _me.Corp.ID); } }
internal static void DoLogIn() { /* Flag for controlling the while loop, since return would kill the thread */ bool shouldLoop = true; /* How long I'll wait between steps */ int sleepTimer = 0; /* LogIn and CharSelect local variables */ EVE.ISXEVE.CharSelect charSelect = new EVE.ISXEVE.CharSelect(); EVE.ISXEVE.Login login; while (shouldLoop) { /* Use a new frame lock for every step, waiting at least one frame before re-locking to give EVE a break */ using (new FrameLock(true)) { /* Update the login and reference */ login = new EVE.ISXEVE.Login(); /* If Login is valid, we're sitting at the login screen. */ if (login.IsValid) { Logging.OnLogMessage(_logIn, "DoLogIn(): Login screen. Entering account info and connecting."); /* If we're at the login screen, we should enter our info, connect, wait a while (10 seconds?) * and then do char select. */ login.SetUsername(Settings.ActiveSettings.UserName); login.SetPassword(Settings.ActiveSettings.PassWord); login.Connect(); sleepTimer = 1; } /* If login was not valid, we should either be at charselect or ingame. */ else { /* Update CharSelect reference */ charSelect = new EVE.ISXEVE.CharSelect(); /* If CharSelect also isn't valid, we're either loading or ingame. */ if (!login.IsValid && (!charSelect.IsValid || !charSelect.CharExists(Settings.ActiveSettings.ActiveCharacter.CharId))) { sleepTimer = 0; } else if (charSelect.IsValid) { /* We're at the CharSelect screen, so select a character. */ /* If we specified a character ID, first use it, then Click. */ if (Settings.ActiveSettings.ActiveCharacter.CharId > 0 && !_charSelected) { Logging.OnLogMessage(_logIn, "DoLogIn(): At CharSelect screen, selecting character."); charSelect.ClickCharacter(Settings.ActiveSettings.ActiveCharacter.CharId); /* Set _charSelected flag */ _charSelected = true; /* This should take no more than five seconds */ sleepTimer = -2; } /* If we've either alread specified Character or didn't have one to specify, * enter game. */ else { Logging.OnLogMessage(_logIn, "DoLogIn(): At CharSelect screen, entering game."); /* Click our characte */ charSelect.ClickCharacter((int)charSelect.SelectedCharID); //todo -- don't cast this after the wrapper is fixed /* Entering game could take up to 30 seconds */ sleepTimer = -1; /* 30 seconds was too short, trying 40. */ } } /* If CharSelect was invalid as well, we're ingame. */ else if (LavishScriptAPI.LavishScriptObject.IsNullOrInvalid(login) && LavishScriptAPI.LavishScriptObject.IsNullOrInvalid(charSelect)) { /* So stop looping. */ Logging.OnLogMessage(_logIn, "DoLogIn(): Stopping looping."); shouldLoop = false; break; } } } /* Either wait one frame or a specified length of time, whichever is longer. */ if (sleepTimer > 0) { Logging.OnLogMessage(_logIn, "DoLogIn(): Sleeping until Login is null or invalid."); while (!LavishScriptAPI.LavishScriptObject.IsNullOrInvalid(login)) { Thread.Sleep(0); } } else if (sleepTimer == 0) { Logging.OnLogMessage(_logIn, "DoLogIn(): Waiting a frame."); Frame.Wait(false); } else if (sleepTimer == -1) { Logging.OnLogMessage(_logIn, "DoLogIn(): Sleeping until CharSelect is null or invalid."); while (!LavishScriptAPI.LavishScriptObject.IsNullOrInvalid(charSelect)) { Thread.Sleep(0); } } else { Logging.OnLogMessage(_logIn, "DoLogIn(): Sleeping until CharSelect is valid and CharExists"); } } /* Once outside the while loop, signal that we've finished login. */ Logging.OnLogMessage(_logIn, "DoLogIn(): DoLogIn complete."); OnLogInComplete(); }