public void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            // When we login for the first time we get the following for messages in the following order

            if (e.Message.Type == 0xF658) // Character List (we get this when we log out a character as well)
            {
                zonename = Convert.ToString(e.Message["zonename"]);
            }

            if (e.Message.Type == 0xF7E1) // Server Name (we get this when we log out a character as well)
            {
                //getting the Server from the message, but then ignore it and set to the one we know works from the files
                server = Convert.ToString(e.Message["server"]);
                var launchInfo = LaunchControl.GetLaunchInfo();
                server = launchInfo.ServerName;
                log.WriteInfo("Server as retrieved from launchInfo: " + server);
            }

            // F7E5 - Unknown? (we only get this the first time we connect), E5 F7 00 00 01 00 00 00 01 00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 01 00 00 00

            if (e.Message.Type == 0xF7EA) // Unknown? (we only get this the first time we connect), EA F7 00 0
            {
                launcherChooseCharTimer.Start();
            }
        }
예제 #2
0
        public void FilterCore_ClientDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type == 0xF7C8) // Enter Game
            {
                freshLogin = true;
                try
                {
                    LaunchControl.RecordLaunchResponse(DateTime.UtcNow);
                }
                catch
                {
                    log.WriteInfo("FilterCore_ClientDispatch: Exception trying to record launch response");
                }
                Heartbeat.LaunchHeartbeat();
            }

            if (freshLogin && e.Message.Type == 0xF7B1 && Convert.ToInt32(e.Message["action"]) == 0xA1)             // Character Materialize (Any time is done portalling in, login or portal)
            {
                freshLogin = false;

                if (loginMessageQueue.Count > 0)
                {
                    sendingLastEnter = false;
                    CoreManager.Current.RenderFrame += new EventHandler <EventArgs>(Current_RenderFrame);
                }
            }
        }
        void launcherChooseCharTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                // Override - instead of using the plugin xml, use the launch file
                var launchInfo = LaunchControl.GetLaunchInfo();
                if (launchInfo.IsValid)
                {
                    TimeSpan FiveMinutes = new TimeSpan(0, 0, 5, 0);
                    if (DateTime.UtcNow - launchInfo.LaunchTime < FiveMinutes)
                    {
                        var ourCharacter = new DefaultFirstCharacter(launchInfo.ServerName, zonename, launchInfo.CharacterName);

                        if (ourCharacter.ZoneId == zonename && ourCharacter.Server == server)
                        {
                            // Bypass movies/logos
                            if (state == 1 || state == 2)
                            {
                                PostMessageTools.SendMouseClick(350, 100);
                            }

                            if (state == 3)
                            {
                                bool ok = loginCharacterTools.LoginCharacter(ourCharacter.CharacterName);
                                if (ok)
                                {
                                    Heartbeat.RecordCharacterName(ourCharacter.CharacterName);
                                }
                            }
                        }
                    }
                    else
                    {
                        log.WriteInfo("launcherChooseCharTimer_Tick: LaunchInfo too old: " + launchInfo.LaunchTime.ToString());
                    }
                }
                else
                {
                    log.WriteInfo("launcherChooseCharTimer_Tick: LaunchInfo not valid");
                }

                if (state >= 3)
                {
                    launcherChooseCharTimer.Stop();
                }

                state++;
            }
            catch (Exception ex) { Debug.LogException(ex); }
        }
예제 #4
0
        public static void WriteCharacters(string ServerName, string zonename, List <Character> characters)
        {
            var launchInfo = LaunchControl.GetLaunchInfo();

            if (!launchInfo.IsValid)
            {
                log.WriteError("LaunchInfo not valid");
                return;
            }

            if (!IsValidCharacterName(launchInfo.CharacterName))
            {
                try
                {
                    log.WriteInfo("WriteCharacters called with no character name, so writing launch response");
                    LaunchControl.RecordLaunchResponse(DateTime.UtcNow);
                }
                catch
                {
                    log.WriteError("WriteCharacters: Exception trying to record launch response");
                }
            }

            // Pass info to Heartbeat
            Heartbeat.RecordServer(launchInfo.ServerName);
            Heartbeat.RecordAccount(launchInfo.AccountName);

            string key   = GetKey(server: launchInfo.ServerName, accountName: launchInfo.AccountName);
            var    clist = new ServerCharacterListByAccount()
            {
                ZoneId        = zonename,
                CharacterList = characters
            };

            // Create a dictionary of only our characters to save
            Dictionary <string, ServerCharacterListByAccount> solodict = new Dictionary <string, ServerCharacterListByAccount>();

            solodict[key] = clist;

            string contents = JsonConvert.SerializeObject(solodict, Formatting.Indented);
            string path     = FileLocations.GetCharacterFilePath(ServerName: launchInfo.ServerName, AccountName: launchInfo.AccountName);

            using (var file = new StreamWriter(path, append: false))
            {
                file.Write(contents);
            }
        }
예제 #5
0
        /// <summary>
        /// This may be called on timer thread *OR* on external caller's thread
        /// </summary>
        private void SendAndReceiveCommands()
        {
            bool success = true;

            try
            {
                _status.TeamList = _cmdParser.GetTeamList();
                _status.IsOnline = IsOnline();
                _status.LastServerDispatchSecondsAgo = (int)(DateTime.UtcNow - FilterCore.GetLastServerDispatchUtc()).TotalSeconds;
                LaunchControl.RecordHeartbeatStatus(_gameToLauncherFilepath, _status);
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception writing heartbeat status: " + exc.ToString());
            }
            try
            {
                if (_myChannel.NeedsToWrite)
                {
                    var writer = new Channels.ChannelWriter();
                    writer.WriteCommandsToFile(_myChannel);
                }
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception writing command file status: " + exc.ToString());
            }
            try
            {
                ReadAndProcessInboundCommands();
            }
            catch (Exception exc)
            {
                success = false;
                log.WriteError("Exception reading command file status: " + exc + " - " + exc.StackTrace);
            }
            if (success)
            {
                LastSendAndReceive = DateTime.UtcNow;
            }
        }
예제 #6
0
        public void FilterCore_ClientDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type == 0xF7C8) // Enter Game
            {
                freshLogin = true;
            }

            if (freshLogin && e.Message.Type == 0xF7B1 && Convert.ToInt32(e.Message["action"]) == 0xA1) // Character Materialize (Any time is done portalling in, login or portal)
            {
                freshLogin = false;

                string characterName = GameRepo.Game.Character;
                if (string.IsNullOrEmpty(characterName))
                {
                    // Do not know why GameRepo.Game.Character is not yet populated, but it isn't
                    var launchInfo = LaunchControl.GetLaunchInfo();
                    if (launchInfo.IsValid)
                    {
                        characterName = launchInfo.CharacterName;
                    }
                }

                var persister = new LoginCommandPersister(GameRepo.Game.Account, GameRepo.Game.Server, characterName);

                log.WriteDebug("FilterCore_ClientDispatch: Character: '{0}'", GameRepo.Game.Character);

                _loginCmds = persister.ReadAndCombineQueues();

                if (_loginCmds.Commands.Count > 0)
                {
                    loginCompleteTime = DateTime.Now;

                    sendingLastEnter = false;
                    CoreManager.Current.RenderFrame += new EventHandler <EventArgs>(Current_RenderFrame);
                }
            }
        }
예제 #7
0
 private static string EncodeString(string text)
 {
     return(LaunchControl.EncodeString(text));
 }