Skip to content

Commit

Permalink
Fix: Don't attempt to read osu! memory values when it's not running
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Apr 11, 2021
1 parent 3610d87 commit 6e381f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion plugins/OsuMemoryEventSource/MemoryListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MemoryListener : IOsuEventSource, IDisposable
private int _lastGameMode = -1;
private int _lastRetries = -1;
private int _lastTime = -1;
private readonly IToken _osuIsRunningToken = OsuMemoryEventSourceBase.LiveTokenSetter("osuIsRunning", false, TokenType.Live, null, false);
private DateTime _nextReplayRetryAllowedAt = DateTime.MinValue;
private OsuMemoryStatus _lastStatus = OsuMemoryStatus.Unknown;
private OsuMemoryStatus _lastStatusLog = OsuMemoryStatus.Unknown;
Expand Down Expand Up @@ -60,7 +61,11 @@ public void Tick(List<StructuredOsuMemoryReader> clientReaders, bool sendEvents)
{
var reader = clientReaders[0];
var osuData = reader.OsuMemoryAddresses;
if (!reader.TryRead(osuData.GeneralData))

var canRead = reader.CanRead;
_osuIsRunningToken.Value = canRead ? 1 : 0;

if (!canRead || !reader.TryRead(osuData.GeneralData))
return;

_currentStatus = osuData.GeneralData.OsuStatus;
Expand Down
2 changes: 1 addition & 1 deletion plugins/OsuMemoryEventSource/OsuMemoryEventSource.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="OsuMemoryDataProvider" Version="0.5.0" />
<PackageReference Include="OsuMemoryDataProvider" Version="0.5.2" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 6e381f9

Please sign in to comment.