Esempio n. 1
0
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            MapSearchResult mapSearchResult = new MapSearchResult(searchArgs);


            return(mapSearchResult);
        }
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            if (!Started)
            {
                return(null);
            }

            if (searchArgs == null)
            {
                throw new ArgumentException(nameof(searchArgs));
            }

            var result = new MapSearchResult(searchArgs);

            if (!Started || !_settings.Get <bool>(_names.EnableMemoryScanner))
            {
                return(result);
            }

            var mods = ReadMods(searchArgs.Status);

            result.Mods = GetModsEx(mods);

            Logger?.Log($">Got mods from memory: {result.Mods.ShownMods}({mods})", LogLevel.Advanced);

            Mods eMods = result.Mods?.Mods ?? Mods.Omod;

            if (Helpers.IsInvalidCombination(eMods))
            {
                Logger?.Log("Sanity check tiggered - invalidating last result", LogLevel.Advanced);
                result.Mods = null;
            }

            return(result);
        }
        private void NewOsuEvent(object sender, MapSearchArgs mapSearchArgs)
        {
            if (mapSearchArgs == null)
            {
                return;
            }
            var eventData = new
            {
                mapId      = mapSearchArgs.MapId.ToString(),
                raw        = mapSearchArgs.Raw,
                hash       = mapSearchArgs.MapHash,
                playMode   = mapSearchArgs.PlayMode?.ToString() ?? "null",
                eventType  = mapSearchArgs.EventType,
                sourceName = mapSearchArgs.SourceName
            }.ToString();

            _logger.Log($"Received event: {eventData}", LogLevel.Debug);
            //TODO: priority system for IOsuEventSource
            if (mapSearchArgs.SourceName.Contains("OsuMemory"))
            {
                TasksMemory.Clear();
                _logger.SetContextData("OsuMemory_event", eventData);

                TasksMemory.Push(mapSearchArgs);
            }
            else
            {
                TasksMsn.Clear();
                TasksMsn.Push(mapSearchArgs);
            }
        }
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            var      result  = new MapSearchResult(searchArgs);
            IBeatmap beatmap = null;

            if (!string.IsNullOrEmpty(searchArgs.MapHash))
            {
                beatmap = _sqliteControler.GetBeatmap(searchArgs.MapHash);
            }

            if (!IsValidBeatmap(beatmap) && searchArgs.MapId > 0)
            {
                beatmap = _sqliteControler.GetBeatmap(searchArgs.MapId);
            }

            if (!IsValidBeatmap(beatmap))
            {
                if (!(string.IsNullOrEmpty(searchArgs.Artist) && string.IsNullOrEmpty(searchArgs.Title)) || !string.IsNullOrEmpty(searchArgs.Raw))
                {
                    beatmap = _sqliteControler.GetBeatmap(searchArgs.Artist, searchArgs.Title, searchArgs.Diff, searchArgs.Raw);
                }
            }

            if (IsValidBeatmap(beatmap))
            {
                result.BeatmapsFound.Add(beatmap);
            }
            return(result);
        }
        private void NewOsuEvent(object sender, MapSearchArgs mapSearchArgs)
        {
            if (mapSearchArgs == null)
            {
                return;
            }
            //TODO: priority system for IOsuEventSource
            if (mapSearchArgs.SourceName == "OsuMemory")
            {
                TasksMemory.Clear();
                _logger.SetContextData("OsuMemory_event", new
                {
                    mapId    = mapSearchArgs.MapId.ToString(),
                    raw      = mapSearchArgs.Raw,
                    hash     = mapSearchArgs.MapHash,
                    playMode = mapSearchArgs.PlayMode?.ToString() ?? "null"
                }.ToString());

                TasksMemory.Push(mapSearchArgs);
            }
            else
            {
                TasksMsn.Clear();
                TasksMsn.Push(mapSearchArgs);
            }
        }
Esempio n. 6
0
        public MapSearchResult FindMapData(MapSearchArgs searchArgs)
        {
            MapSearchResult      mapSearchResult = null;
            Tuple <Mods, string> foundMods       = null;

            for (int i = 0; i < _mapDataFinders.Count; i++)
            {
                if ((_mapDataFinders[i].SearchModes & searchArgs.Status) == 0)
                {
                    continue;
                }

                mapSearchResult = _mapDataFinders[i].FindBeatmap(searchArgs);
                if (mapSearchResult.FoundBeatmaps)
                {
                    if (mapSearchResult.Mods == null && foundMods != null)
                    {
                        mapSearchResult.Mods = foundMods;
                    }
                    _logger.Log(string.Format(">Found data using \"{0}\" ID: {1}", _mapDataFinders[i].SearcherName, mapSearchResult.BeatmapsFound[0]?.MapId), LogLevel.Advanced);
                    break;
                }
                if (mapSearchResult.Mods != null)
                {
                    foundMods = mapSearchResult.Mods;
                }
            }
            if (mapSearchResult == null)
            {
                mapSearchResult = new MapSearchResult();
            }
            mapSearchResult.Action = searchArgs.Status;
            return(mapSearchResult);
        }
Esempio n. 7
0
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            MapSearchResult mapSearchResult = new MapSearchResult();

            mapSearchResult.MapSearchString = searchArgs.Raw;


            return(mapSearchResult);
        }
Esempio n. 8
0
        public void SetNewMsnString(Dictionary <string, string> osuStatus)
        {
            /*osuStatus["artist"]
            *  osuStatus["title"]
            *  osuStatus["diff"]
            *  osuStatus["status"]*/

            OsuStatus status = osuStatus["status"] == "Listening" ? OsuStatus.Listening
                : osuStatus["status"] == "Playing" ? OsuStatus.Playing
                : osuStatus["status"] == "Watching" ? OsuStatus.Watching
                : osuStatus["status"] == "Editing" ? OsuStatus.Editing
                : OsuStatus.Null;

            osuStatus["raw"] = string.Format("{0} - {1}", osuStatus["title"], osuStatus["artist"]);
            bool isFalsePlay;

            lock (this)
            {
                isFalsePlay = IsFalsePlay(osuStatus["raw"], status, _lastMsnString);
            }
            if (isFalsePlay)
            {
                _logger.Log(">ignoring second MSN string...", LogLevel.Advanced);
            }
            else
            {
                _lastMsnString = osuStatus["raw"];
                _logger.Log("", LogLevel.Advanced);
                string result = ">Got ";
                foreach (var v in osuStatus)
                {
                    if (v.Key != "raw")
                    {
                        result = result + $"{v.Key}: \"{v.Value}\" ";
                    }
                }
                _logger.Log(result, LogLevel.Basic);
                while (_settings.Get <bool>(_names.LoadingRawBeatmaps))
                {
                    Thread.Sleep(200);
                }
                var searchArgs = new MapSearchArgs()
                {
                    Artist = osuStatus["artist"] ?? "",
                    Title  = osuStatus["title"] ?? "",
                    Diff   = osuStatus["diff"] ?? "",
                    Raw    = osuStatus["raw"] ?? "",
                    Status = status,
                };

                //Throw away any unprocessed tasks- I'm only intrested in processing current one.
                TasksMsn.Clear();
                TasksMsn.Push(searchArgs);
            }
        }
Esempio n. 9
0
        private MapSearchArgs CreateArgs(Dictionary <string, string> osuStatus)
        {
            OsuStatus status = osuStatus["status"] == "Listening" ? OsuStatus.Listening
                : osuStatus["status"] == "Playing" ? OsuStatus.Playing
                    : osuStatus["status"] == "Watching" ? OsuStatus.Watching
                        : osuStatus["status"] == "Editing" ? OsuStatus.Editing
                            : OsuStatus.Null;

            osuStatus["raw"] = string.Format("{0} - {1}", osuStatus["title"], osuStatus["artist"]);
            bool isFalsePlay;

            lock (this)
            {
                isFalsePlay = IsFalsePlay(osuStatus["raw"], status, _lastMsnString);
            }
            if (isFalsePlay)
            {
                _logger?.Log(">ignoring second MSN string...", LogLevel.Advanced);
            }
            else
            {
                _lastMsnString = osuStatus["raw"];
                _logger?.Log("", LogLevel.Advanced);
                string result = ">Got ";
                foreach (var v in osuStatus)
                {
                    if (v.Key != "raw")
                    {
                        result = result + $"{v.Key}: \"{v.Value}\" ";
                    }
                }
                _logger?.Log(result, LogLevel.Basic);

                var searchArgs = new MapSearchArgs("Msn", OsuEventType.MapChange)
                {
                    Artist = osuStatus["artist"] ?? "",
                    Title  = osuStatus["title"] ?? "",
                    Diff   = osuStatus["diff"] ?? "",
                    Raw    = osuStatus["raw"] ?? "",
                    Status = status,
                };
                return(searchArgs);
            }
            return(null);
        }
 private void NewOsuEvent(object sender, MapSearchArgs mapSearchArgs)
 {
     if (mapSearchArgs == null)
     {
         return;
     }
     //TODO: priority system for IOsuEventSource
     if (mapSearchArgs.SourceName == "OsuMemory")
     {
         TasksMemory.Clear();
         TasksMemory.Push(mapSearchArgs);
     }
     else
     {
         TasksMsn.Clear();
         TasksMsn.Push(mapSearchArgs);
     }
 }
Esempio n. 11
0
        public MapSearchResult FindMapData(MapSearchArgs searchArgs)
        {
            MapSearchResult mapSearchResult = null;
            ModsEx          foundMods       = null;

            for (int i = 0; i < _mapDataFinders.Count; i++)
            {
                if ((_mapDataFinders[i].SearchModes & searchArgs.Status) == 0)
                {
                    continue;
                }
                try
                {
                    mapSearchResult = _mapDataFinders[i].FindBeatmap(searchArgs);
                }
                catch (Exception e)
                {
                    _logger.Log(e, LogLevel.Error);
                    mapSearchResult = null;
                }

                if (mapSearchResult?.FoundBeatmaps == true)
                {
                    if (mapSearchResult.Mods == null && foundMods != null)
                    {
                        mapSearchResult.Mods = foundMods;
                    }
                    _logger.Log(string.Format(">Found data using \"{0}\" ID: {1}", _mapDataFinders[i].SearcherName, mapSearchResult.BeatmapsFound[0]?.MapId), LogLevel.Advanced);
                    break;
                }
                if (mapSearchResult?.Mods != null)
                {
                    foundMods = mapSearchResult.Mods;
                }
            }
            if (mapSearchResult == null)
            {
                mapSearchResult = new MapSearchResult(searchArgs);
            }

            return(mapSearchResult);
        }
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            var     result  = new MapSearchResult();
            Beatmap beatmap = null;

            if (searchArgs.MapId > 0)
            {
                beatmap = _sqliteControler.GetBeatmap(searchArgs.MapId);
            }
            if (beatmap == null || (beatmap.MapId <= 0))
            {
                if (!(string.IsNullOrEmpty(searchArgs.Artist) && string.IsNullOrEmpty(searchArgs.Title)) || !string.IsNullOrEmpty(searchArgs.Raw))
                {
                    beatmap = _sqliteControler.GetBeatmap(searchArgs.Artist, searchArgs.Title, searchArgs.Diff, searchArgs.Raw);
                }
            }

            if (beatmap?.MapId > -1 && !(string.IsNullOrWhiteSpace(beatmap.ArtistRoman) || string.IsNullOrWhiteSpace(beatmap.TitleRoman)))
            {
                result.BeatmapsFound.Add(beatmap);
            }
            result.MapSearchString = searchArgs.Raw;
            return(result);
        }
 public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
 {
     lastMapSearchArgs = searchArgs;
     return(null);
 }
        public MapSearchResult FindBeatmap(MapSearchArgs searchArgs)
        {
            if (!Started)
            {
                return(null);
            }

            if (searchArgs == null)
            {
                throw new ArgumentException(nameof(searchArgs));
            }

            if (!TEMPfatalExceptionTiggered)
            {
                if (_memoryReader == null)
                {
                    TEMPfatalExceptionTiggered = true;
                    throw new Exception("MemoryReader was not initalized");
                }
                if (_settings == null)
                {
                    TEMPfatalExceptionTiggered = true;
                    throw new Exception("Settings were not initalized");
                }
            }

            var result = new MapSearchResult(searchArgs);

            if (!Started || !_settings.Get <bool>(_names.EnableMemoryScanner))
            {
                return(result);
            }

            int mapId = _memoryReader.GetMapId();
            int mods  = 0;

            if (searchArgs.Status == OsuStatus.Playing)
            {
                Thread.Sleep(250);
                mods        = _memoryReader.GetMods();
                result.Mods = GetMods(mods);
            }

            Logger?.Log(">Got {0} & {1} from memory", LogLevel.Advanced, mapId.ToString(), mods.ToString());

            Mods eMods = result.Mods?.Mods ?? Mods.Omod;

            if (mapId > 200_000_000 || mapId < 0 || Helpers.IsInvalidCombination(eMods))
            {
                Logger?.Log("Sanity check tiggered - invalidating last result", LogLevel.Advanced);
                result.Mods = null;
                return(result);
            }

            if (mapId == 0)
            {
                Logger?.Log("Map has no ID", LogLevel.Advanced);
                return(result);
            }

            var b = _sqLiteController?.GetBeatmap(mapId);

            if (b != null)
            {
                result.BeatmapsFound.Add(b);
            }

            return(result);
        }