예제 #1
0
        public static void FFXIVCheckThread()
        {
            Thread.CurrentThread.IsBackground = true;

            while (true)
            {
#if !asdf
                if (MemoryHandler.Instance.IsAttached)
                {
                    continue;
                }
#endif
                TrayContext.UpdateStatus(STATUS.NOTFOUND);

#if asdf
                Player.Name = "Ffxiv Finalfantasy";
                MainLoop();
#else
                //check for any FFXIV processes and make sure that they're actually running the game and not something like ffxiv_mediaplayer
                foreach (var process in Process.GetProcesses())
                {
                    if (process.MainWindowTitle != "FINAL FANTASY XIV")
                    {
                        continue;
                    }
                    switch (process.ProcessName)
                    {
                    case "ffxiv":
                        Exit("DirectX 9 mode not supported.");
                        break;

                    case "ffxiv_dx11":
                        //check version
                        var gamedir = Path.GetDirectoryName(process.MainModule.FileName);
                        if (string.IsNullOrEmpty(gamedir))
                        {
                            Exit($"Unable to use GetDirectoryName on {process.MainModule.FileName} (report this on github)");
                            break;
                        }

                        var verfile = Path.Combine(gamedir, "ffxivgame.ver");
                        if (!File.Exists(verfile))
                        {
                            Exit("Unable to find version file - are you sure you're running the real game?");
                            break;
                        }

                        var version = File.ReadAllText(verfile);
                        if (version != REQUIRED_VERSION)
                        {
                            Exit($"Version mismatch: only works with {REQUIRED_VERSION} and your client is {version}");
                            continue;
                        }

                        MemoryHandler.Instance.SetProcess(new ProcessModel
                        {
                            Process = process,
                        });

READNAME:
                        Player.Name = Reader.GetPlayerInfo().PlayerEntity.Name;
                        if (string.IsNullOrEmpty(Player.Name))
                        {
                            TrayContext.UpdateStatus(STATUS.CANTREADCHARACTER);
                            Thread.Sleep(1000);
                            goto READNAME;
                        }

                        MainLoop();

                        break;

                    default:
                        Exit($"This isn't FINAL FANTASY XIV?\n{process.MainWindowTitle}\n{Path.GetDirectoryName(process.MainModule.FileName)}");
                        break;
                    }

                    break;
                }
#endif
                Thread.Sleep(5000);
            }
        }
예제 #2
0
        public static void MainLoop()
        {
#if asdf
            Player.Location = GetRandomLocation();
#endif
            TrayContext.UpdateCharacterName();

            DiscordRpc.Initialize(APPID, ref handlers, false, null);

            while (Attached())
            {
                var characterFound = false;

#if asdf
                Player.Job    = Actor.Job.FSH;
                Player.Level  = rand.Next(1, 70);
                Player.Status = Actor.Icon.InDuty;
                if (Player._changed)
                {
                    Log(Player.ToString());
                }

                characterFound = true;
#else
                foreach (var pc in Reader.GetActors().PCEntities.Values)
                {
                    if (pc.Name != Player.Name)
                    {
                        continue;
                    }
                    Player.Job   = pc.Job;
                    Player.Level = pc.Level;
                    //This becomes ??? if you're loading something
                    Player.Location = pc.Location;
                    //None and Online are the same thing pretty much
                    Player.Status  = pc.OnlineStatus == Actor.Icon.None ? Actor.Icon.Online : pc.OnlineStatus;
                    characterFound = Player.Job != 0 && Player.Level != 0 && Player.Status != 0 && !string.IsNullOrEmpty(Player.Location);
                    break;
                }
#endif

                if (!characterFound)
                {
                    TrayContext.UpdateStatus(STATUS.CANTFINDCHARACTER);
                    Thread.Sleep(5000);
                    continue;
                }

                TrayContext.UpdateStatus(STATUS.RUNNING);

                if (Player._changed)
                {
                    UpdatePresence();
                }

                Player._changed = false;

                Player._locationChanged = false;

                Thread.Sleep(1000);
            }
        }