Beispiel #1
0
 private bool AnyProblems()
 {
     if (Program.mem == null || !Program.mem.ValidateProcess() || Program.mem.GetSelfCombatant() == null || Program.mem.Process.Id != (int?)ProcessComboBox.SelectedValue)
     {
         HuntConnectionTextBlock.Text = string.Format(Properties.Resources.FormNoProcess, FFXIVProcessHelper.DX9ExeName + (Environment.Is64BitProcess ? "/" + FFXIVProcessHelper.DX11ExeName : string.Empty));
         if (ProcessComboBox.SelectedValue != null && FFXIVProcessHelper.GetFFXIVProcess((int)ProcessComboBox.SelectedValue) != null)
         {
             if (Program.mem != null)
             {
                 Program.mem.OnNewCommand -= ProcessChatCommand;
                 Program.mem.Dispose();
                 hunts?.LeaveGroup();
             }
             Program.mem = null;
             Program.mem = new FFXIVMemory(FFXIVProcessHelper.GetFFXIVProcess((int)ProcessComboBox.SelectedValue));
             Program.mem.OnNewCommand += ProcessChatCommand;
             PersistentNamedPipeServer.Restart();
         }
         hunts?.LeaveGroup();
         HuntNotifyGroupBox.IsEnabled = false;
         return(true);
     }
     else
     {
         if (hunts == null && Program.mem != null && Program.mem.ValidateProcess())
         {
             hunts = new FFXIVHunts(this);
         }
         HuntNotifyGroupBox.IsEnabled = true;
     }
     return(false);
 }
Beispiel #2
0
        internal async Task PlayAsync(int pid, CancellationToken cts)
        {
            PipeMessage noteOff = new PipeMessage(pid, PMCommand.PlayNote)
            {
                Parameter = 0
            };

            foreach (Note n in Sheet)
            {
                PersistentNamedPipeServer.SendPipeMessage(new PipeMessage(pid, PMCommand.PlayNote)
                {
                    Parameter = n.Id
                });
                await Task.Delay((int)n.Length);

                PersistentNamedPipeServer.SendPipeMessage(noteOff);
                TimeSpan untilNextNote = TimeSpan.FromMilliseconds((int)n.Wait - (int)n.Length);
                if (untilNextNote.TotalMilliseconds > 0)
                {
                    await Task.Delay(untilNextNote);
                }
                if (cts.IsCancellationRequested)
                {
                    break;
                }
            }
        }
Beispiel #3
0
        internal async Task PlayMML(ImplementedPlayer p, CancellationToken cts)
        {
            p.Unmute();
            p.Play();
            if (!PersistentNamedPipeServer.Instance.IsConnected)
            {
                await TryInject();
            }
            PipeMessage noteOff = new PipeMessage(Process.Id, PMCommand.PlayNote)
            {
                Parameter = 0
            };

            foreach (var track in p.Tracks)
            {
                new Thread(() =>
                {
                    TimeSpan ts = new TimeSpan(0);
                    foreach (TextPlayer.Note note in track.notes)
                    {
                        TimeSpan w = note.TimeSpan - ts;
                        if (w.TotalMilliseconds > 0)
                        {
                            Thread.Sleep(w);
                        }
                        if (cts.IsCancellationRequested)
                        {
                            return;
                        }
                        PersistentNamedPipeServer.SendPipeMessage(new PipeMessage(Process.Id, PMCommand.PlayNote)
                        {
                            Parameter = note.GetStep()
                        });
                        Thread.Sleep(note.Length);
                        PersistentNamedPipeServer.SendPipeMessage(noteOff);
                        ts = note.TimeSpan + note.Length;
                    }
                })
                {
                    Priority     = ThreadPriority.Highest,
                    IsBackground = true
                }.Start();
            }
        }
Beispiel #4
0
        private bool AnyProblems()
        {
            if (Program.mem != null && Program.mem.ValidateProcess() && Program.mem.GetSelfCombatant() != null)
            {
                int id  = Program.mem.Process.Id;
                int?num = (int?)this.ProcessComboBox.SelectedValue;
                if (id == num.GetValueOrDefault() & num != null)
                {
                    if (this.hunts == null && Program.mem != null && Program.mem.ValidateProcess())
                    {
                        this.hunts = new FFXIVHunts(this);
                    }
                    this.MainTabControl.IsEnabled = (this.HuntNotifyGroupBox.IsEnabled = true);
                    return(false);
                }
            }
            this.HuntConnectionTextBlock.Text = string.Format(CultureInfo.CurrentCulture, FFXIV_GameSense.Properties.Resources.FormNoProcess, "ffxiv_dx11.exe");
            if (this.ProcessComboBox.SelectedValue != null && FFXIVProcessHelper.GetFFXIVProcess((int)this.ProcessComboBox.SelectedValue) != null)
            {
                if (Program.mem != null)
                {
                    Program.mem.OnNewCommand -= this.ProcessChatCommand;
                    Program.mem.Dispose();
                    FFXIVHunts ffxivhunts = this.hunts;
                    if (ffxivhunts != null)
                    {
                        ffxivhunts.LeaveGroup();
                    }
                }
                Program.mem = null;
                Program.mem = new FFXIVMemory(FFXIVProcessHelper.GetFFXIVProcess((int)this.ProcessComboBox.SelectedValue));
                Program.mem.OnNewCommand += this.ProcessChatCommand;
                PersistentNamedPipeServer.Restart();
            }
            FFXIVHunts ffxivhunts2 = this.hunts;

            if (ffxivhunts2 != null)
            {
                ffxivhunts2.LeaveGroup();
            }
            this.MainTabControl.IsEnabled = (this.HuntNotifyGroupBox.IsEnabled = false);
            return(true);
        }
        internal async Task Play(int pid, CancellationToken cts)
        {
            PipeMessage noteOff = new PipeMessage(pid, PMCommand.PlayNote, 0);

            foreach (Note i in this.Sheet)
            {
                PersistentNamedPipeServer.SendPipeMessage(new PipeMessage(pid, PMCommand.PlayNote, i.Id));
                await Task.Delay((int)i.Length).ConfigureAwait(false);

                PersistentNamedPipeServer.SendPipeMessage(noteOff);
                TimeSpan untilNextNote = TimeSpan.FromMilliseconds((double)(i.Wait - i.Length));
                if (untilNextNote.TotalMilliseconds > 0.0)
                {
                    await Task.Delay(untilNextNote).ConfigureAwait(false);
                }
                if (cts.IsCancellationRequested)
                {
                    break;
                }
                i = null;
            }
            List <Note> .Enumerator enumerator = default(List <Note> .Enumerator);
        }
Beispiel #6
0
        private async Task WriteChatMessage(byte[] msg)
        {
            await TryInject();

            if (msg.Last() != 0x00)
            {
                msg = msg.Concat(new byte[] { 0x00 }).ToArray();
            }
            ulong tail = Is64Bit ? GetUInt64(chatLogTailAddress) : GetUInt32(chatLogTailAddress);

            NativeMethods.WriteProcessMemory(Process.Handle, (IntPtr)tail, msg, new IntPtr(msg.Length), out uint written);
            if (Is64Bit)
            {
                NativeMethods.WriteProcessMemory(Process.Handle, chatLogTailAddress, BitConverter.GetBytes(tail + Convert.ToUInt64(msg.Length)), new IntPtr(sizeof(ulong)), out written);
            }
            else
            {
                NativeMethods.WriteProcessMemory(Process.Handle, chatLogTailAddress, BitConverter.GetBytes(tail + Convert.ToUInt32(msg.Length)), new IntPtr(sizeof(uint)), out written);
            }
            var SlashInstanceCommand = new PipeMessage(Process.Id, PMCommand.SlashInstance);

            PersistentNamedPipeServer.SendPipeMessage(SlashInstanceCommand);
        }