Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate memory reader #434

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Daybreak.GWCA/source/InventoryModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
continue;
}

bagContent.Id = item->item_id;
bagContent.Id = item->model_id;
bagContent.Slot = item->slot;
bagContent.Count = item->quantity;
auto modifier = item->mod_struct;
for (auto i = 0; i < item->mod_struct_size; i++) {

Check warning on line 35 in Daybreak.GWCA/source/InventoryModule.cpp

View workflow job for this annotation

GitHub Actions / build (x86)

'<': signed/unsigned mismatch

Check warning on line 35 in Daybreak.GWCA/source/InventoryModule.cpp

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'<': signed/unsigned mismatch
bagContent.Modifiers.push_back((uint32_t)modifier);
bagContent.Modifiers.push_back((uint32_t)(modifier->mod));
modifier++;
}

Expand Down
4 changes: 0 additions & 4 deletions Daybreak/Configuration/Options/FocusViewOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public sealed class FocusViewOptions
[OptionName(Name = "Enabled", Description = "If true, the focus view is enabled, showing live information from the game")]
public bool Enabled { get; set; } = true;

[JsonProperty(nameof(GWCAIntegration))]
[OptionName(Name = "GWCA Integration", Description = "If true, focus view will use the GWCA plugin to read the GuildWars memory. This should be true in almost all cases")]
public bool GWCAIntegration { get; set; } = true;

[OptionName(Name = "Inventory Component Enabled", Description = "If true, the focus view will show a component with the inventory contents")]
public bool InventoryComponentVisible { get; set; }

Expand Down
9 changes: 2 additions & 7 deletions Daybreak/Configuration/ProjectConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public override void RegisterServices(IServiceCollection services)
services.AddSingleton<IPluginsService, PluginsService>();
services.AddSingleton<ISplashScreenService, SplashScreenService>();
services.AddSingleton<IGuildWarsExecutableManager, GuildWarsExecutableManager>();
services.AddSingleton<IGWCAClient, GWCAClient>();
services.AddSingleton<IGuildwarsMemoryReader, GWCAMemoryReader>();
services.AddScoped<ICredentialManager, CredentialManager>();
services.AddScoped<IApplicationLauncher, ApplicationLauncher>();
services.AddScoped<IScreenshotProvider, ScreenshotProvider>();
Expand All @@ -219,7 +221,6 @@ public override void RegisterServices(IServiceCollection services)
services.AddScoped<IScreenManager, ScreenManager>();
services.AddScoped<IGraphClient, GraphClient>();
services.AddScoped<IOnboardingService, OnboardingService>();
services.AddScoped<IMemoryScanner, MemoryScanner>();
services.AddScoped<IExperienceCalculator, ExperienceCalculator>();
services.AddScoped<IAttributePointCalculator, AttributePointCalculator>();
services.AddScoped<IDownloadService, DownloadService>();
Expand All @@ -244,12 +245,6 @@ public override void RegisterServices(IServiceCollection services)
services.AddScoped<IToolboxClient, ToolboxClient>();
services.AddScoped<IProcessInjector, ProcessInjector>();
services.AddScoped<ILaunchConfigurationService, LaunchConfigurationService>();
services.AddScoped<IGWCAClient, GWCAClient>();

//TODO: Composite will be the main reader. Composite will select between GuildwarsMemoryReader and GWCAMemoryReader depending on the options. Remove once GWCA is stable
services.AddScoped<IGuildwarsMemoryReader, CompositeMemoryReader>();
services.AddScoped<GuildwarsMemoryReader>();
services.AddScoped<GWCAMemoryReader>();
}

public override void RegisterViews(IViewProducer viewProducer)
Expand Down
2 changes: 1 addition & 1 deletion Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.8.129</Version>
<Version>0.9.8.130</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
20 changes: 15 additions & 5 deletions Daybreak/Services/Bloogum/BloogumClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Daybreak.Services.Bloogum.Models;
using Daybreak.Models.Guildwars;
using Daybreak.Services.Bloogum.Models;
using Daybreak.Services.Images;
using Daybreak.Services.Scanner;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -65,14 +66,23 @@ private async Task<string> GetImageUri(bool localized)
return GetRandomScreenShot();
}

var worldInfo = await this.guildwarsMemoryCache.ReadWorldData(CancellationToken.None);
if (worldInfo is null)
WorldData? worldInfo = default;
try
{
worldInfo = await this.guildwarsMemoryCache.ReadWorldData(CancellationToken.None);
if (worldInfo is null)
{
return GetRandomScreenShot();
}
}
catch (Exception ex) when (ex is TimeoutException or TaskCanceledException or HttpRequestException)
{
this.logger.LogInformation("Could not retrieve world data. Returning random screenshot");
return GetRandomScreenShot();
}

var validLocations = Location.Locations.Where(l => l.Region == worldInfo.Region).ToList();
var validCategories = validLocations.SelectMany(l => l.Categories).Where(c => c.Map == worldInfo.Map).ToList();
var validLocations = Location.Locations.Where(l => l.Region == worldInfo!.Region).ToList();
var validCategories = validLocations.SelectMany(l => l.Categories).Where(c => c.Map == worldInfo!.Map).ToList();
if (validCategories.None())
{
if (validLocations.None())
Expand Down
182 changes: 0 additions & 182 deletions Daybreak/Services/Scanner/CompositeMemoryReader.cs

This file was deleted.

Loading
Loading