-
Notifications
You must be signed in to change notification settings - Fork 33
Implement detecting and hiding modded planets if preferred #974
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ad6d6e6
Implement detecting and hiding modded planets
Toastbrot236 dec5836
Fix actually detecting modded planets, detect on more out-of-place de…
Toastbrot236 70d5b60
Improve command names, include preference in ApiExtendedGameUserResponse
Toastbrot236 48993fa
Add modded planets tests
Toastbrot236 1893ef7
Revert replacing some Write() calls with SaveChanges() calls
Toastbrot236 2ac2b21
Refactor and deduplicate actual modded planet hiding
Toastbrot236 1c826cf
Add backfill migration to track modded status of already uploaded pla…
Toastbrot236 551a10c
Move UpdatePlanetModdedStatus
Toastbrot236 3049667
Merge branch 'main' into modded-plant
Toastbrot236 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Refresh.Database.Models.Assets; | ||
|
|
||
| namespace Refresh.Database.Extensions; | ||
|
|
||
| public static class GameAssetExtensions | ||
| { | ||
| public static void TraverseDependenciesRecursively(this GameAsset asset, GameDatabaseContext database, Action<string, GameAsset?> callback) | ||
| { | ||
| callback(asset.AssetHash, asset); | ||
| foreach (string internalAssetHash in database.GetAssetDependencies(asset).ToArray()) | ||
| { | ||
| GameAsset? internalAsset = database.GetAssetFromHash(internalAssetHash); | ||
|
|
||
| // Only run this if this is null, since the next recursion will trigger its own callback | ||
| if(internalAsset == null) | ||
| callback(internalAssetHash, internalAsset); | ||
|
|
||
| internalAsset?.TraverseDependenciesRecursively(database, callback); | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
Refresh.Database/Extensions/GameDatabaseContextExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using Refresh.Database.Models.Assets; | ||
| using Refresh.Database.Models.Users; | ||
|
|
||
| namespace Refresh.Database.Extensions; | ||
|
|
||
| public static class GameDatabaseContextExtensions | ||
| { | ||
| public static void UpdatePlanetModdedStatus(this GameDatabaseContext database, GameUser user) | ||
| { | ||
| user.AreLbp2PlanetsModded = database.GetPlanetModdedStatus(user.Lbp2PlanetsHash); | ||
| user.AreLbp3PlanetsModded = database.GetPlanetModdedStatus(user.Lbp3PlanetsHash); | ||
| user.AreVitaPlanetsModded = database.GetPlanetModdedStatus(user.VitaPlanetsHash); | ||
| user.AreBetaPlanetsModded = database.GetPlanetModdedStatus(user.BetaPlanetsHash); | ||
| } | ||
|
|
||
| public static bool GetPlanetModdedStatus(this GameDatabaseContext database, string rootAssetHash) | ||
| { | ||
| bool modded = false; | ||
|
|
||
| GameAsset? rootAsset = database.GetAssetFromHash(rootAssetHash); | ||
| rootAsset?.TraverseDependenciesRecursively(database, (_, asset) => | ||
| { | ||
| if (asset != null && (asset.AssetFlags & (AssetFlags.Modded | AssetFlags.ModdedOnPlanets)) != 0) | ||
| modded = true; | ||
| }); | ||
|
|
||
| return modded; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Refresh.Database/Migrations/20251020102449_TrackModdedPlanets.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| using Microsoft.EntityFrameworkCore.Infrastructure; | ||
| using Microsoft.EntityFrameworkCore.Migrations; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace Refresh.Database.Migrations | ||
| { | ||
| /// <inheritdoc /> | ||
| [DbContext(typeof(GameDatabaseContext))] | ||
| [Migration("20251020102449_TrackModdedPlanets")] | ||
| public partial class TrackModdedPlanets : Migration | ||
| { | ||
| /// <inheritdoc /> | ||
| protected override void Up(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.AddColumn<bool>( | ||
| name: "AreBetaPlanetsModded", | ||
| table: "GameUsers", | ||
| type: "boolean", | ||
| nullable: false, | ||
| defaultValue: false); | ||
|
|
||
| migrationBuilder.AddColumn<bool>( | ||
| name: "AreLbp2PlanetsModded", | ||
| table: "GameUsers", | ||
| type: "boolean", | ||
| nullable: false, | ||
| defaultValue: false); | ||
|
|
||
| migrationBuilder.AddColumn<bool>( | ||
| name: "AreLbp3PlanetsModded", | ||
| table: "GameUsers", | ||
| type: "boolean", | ||
| nullable: false, | ||
| defaultValue: false); | ||
|
|
||
| migrationBuilder.AddColumn<bool>( | ||
| name: "AreVitaPlanetsModded", | ||
| table: "GameUsers", | ||
| type: "boolean", | ||
| nullable: false, | ||
| defaultValue: false); | ||
|
|
||
| migrationBuilder.AddColumn<bool>( | ||
| name: "ShowModdedPlanets", | ||
| table: "GameUsers", | ||
| type: "boolean", | ||
| nullable: false, | ||
| defaultValue: true); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void Down(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.DropColumn( | ||
| name: "AreBetaPlanetsModded", | ||
| table: "GameUsers"); | ||
|
|
||
| migrationBuilder.DropColumn( | ||
| name: "AreLbp2PlanetsModded", | ||
| table: "GameUsers"); | ||
|
|
||
| migrationBuilder.DropColumn( | ||
| name: "AreLbp3PlanetsModded", | ||
| table: "GameUsers"); | ||
|
|
||
| migrationBuilder.DropColumn( | ||
| name: "AreVitaPlanetsModded", | ||
| table: "GameUsers"); | ||
|
|
||
| migrationBuilder.DropColumn( | ||
| name: "ShowModdedPlanets", | ||
| table: "GameUsers"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.