Alter how game teleports are detected

This commit is contained in:
pizzaboxer 2023-07-20 22:40:38 +01:00
parent 9d7f9f7ba3
commit 5205287f36
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 15 additions and 7 deletions

View File

@ -117,7 +117,7 @@ namespace Bloxstrap.Integrations
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Setting presence for Place ID {_activityWatcher.ActivityPlaceId}");
var universeIdResponse = await Utility.Http.GetJson<UniverseIdResponse>($"https://apis.roblox.com/universes/v1/places/{_activityWatcher.ActivityPlaceId}/universe");
var universeIdResponse = await Http.GetJson<UniverseIdResponse>($"https://apis.roblox.com/universes/v1/places/{_activityWatcher.ActivityPlaceId}/universe");
if (universeIdResponse is null)
{
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe ID!");
@ -131,10 +131,9 @@ namespace Bloxstrap.Integrations
if (_timeStartedUniverse is null || !_activityWatcher.ActivityIsTeleport || universeId != _currentUniverseId)
_timeStartedUniverse = DateTime.UtcNow;
_activityWatcher.ActivityIsTeleport = false;
_currentUniverseId = universeId;
var gameDetailResponse = await Utility.Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={universeId}");
var gameDetailResponse = await Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={universeId}");
if (gameDetailResponse is null || !gameDetailResponse.Data.Any())
{
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe info!");
@ -144,7 +143,7 @@ namespace Bloxstrap.Integrations
GameDetailResponse universeDetails = gameDetailResponse.Data.ToArray()[0];
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Got Universe details");
var universeThumbnailResponse = await Utility.Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/games/icons?universeIds={universeId}&returnPolicy=PlaceHolder&size=512x512&format=Png&isCircular=false");
var universeThumbnailResponse = await Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/games/icons?universeIds={universeId}&returnPolicy=PlaceHolder&size=512x512&format=Png&isCircular=false");
if (universeThumbnailResponse is null || !universeThumbnailResponse.Data.Any())
{
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe thumbnail info!");

View File

@ -16,6 +16,7 @@
private const string GameJoinedEntryPattern = @"serverId: ([0-9\.]+)\|[0-9]+";
private int _logEntriesRead = 0;
private bool _teleportMarker = false;
public event EventHandler<string>? OnLogEntry;
public event EventHandler? OnGameJoin;
@ -27,8 +28,6 @@
public string LogFilename = null!;
// these are values to use assuming the player isn't currently in a game
// keep in mind ActivityIsTeleport is only reset by DiscordRichPresence when it's done accessing it
// because of the weird chronology of where the teleporting entry is outputted, there's no way to reset it in here
public bool ActivityInGame = false;
public long ActivityPlaceId = 0;
public string ActivityJobId = "";
@ -130,6 +129,16 @@
ActivityJobId = match.Groups[1].Value;
ActivityMachineAddress = match.Groups[3].Value;
if (_teleportMarker)
{
ActivityIsTeleport = true;
_teleportMarker = false;
}
else
{
ActivityIsTeleport = false;
}
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Joining Game ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
}
else if (!ActivityInGame && ActivityPlaceId != 0)
@ -184,7 +193,7 @@
else if (entry.Contains(GameTeleportingEntry))
{
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Initiating teleport to server ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
ActivityIsTeleport = true;
_teleportMarker = true;
}
else if (entry.Contains(GameMessageEntry))
{