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"]);
                log.WriteInfo("FilterCore_ServerDispatch: 0xF658");
            }

            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
            {
                defaultFirstCharTimer.Start();
            }
        }
Esempio n. 2
0
        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);
                        log.WriteInfo("Character login requested: " + 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); }
        }
        public void WriteCharacters(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");
                }
            }
            log.WriteDebug("LaunchInfo valid");

            // Pass info to Heartbeat
            Heartbeat.RecordServer(launchInfo.ServerName);
            Heartbeat.RecordAccount(launchInfo.AccountName);
            GameRepo.Game.SetServerAccount(server: launchInfo.ServerName, account: launchInfo.AccountName);

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

            log.WriteInfo("Writing characters: " + clist.ToString());
            this._data[key] = clist;
            string contents = JsonConvert.SerializeObject(_data, Formatting.Indented);
            string path     = FileLocations.GetCharacterFilePath();

            using (var file = new StreamWriter(path, append: false))
            {
                file.Write(contents);
            }
        }
        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);
                }
            }
        }