Skip to content

Commit e41467c

Browse files
committed
Merge branch 'develop' into stable
2 parents 83fa286 + 9544e5a commit e41467c

4 files changed

Lines changed: 66 additions & 3 deletions

File tree

ContentPatcher/ContentPatcher.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>2.7.0</Version>
3+
<Version>2.7.1</Version>
44
<RootNamespace>ContentPatcher</RootNamespace>
55
</PropertyGroup>
66

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Diagnostics.CodeAnalysis;
3+
using ContentPatcher.Framework.ConfigModels;
4+
using Newtonsoft.Json.Linq;
5+
using StardewModdingAPI;
6+
using StardewValley.GameData.Characters;
7+
8+
namespace ContentPatcher.Framework.Migrations;
9+
10+
/// <summary>Migrates patches to format version 2.6.</summary>
11+
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Named for clarity.")]
12+
internal class Migration_2_7 : BaseMigration
13+
{
14+
/*********
15+
** Public methods
16+
*********/
17+
/// <summary>Construct an instance.</summary>
18+
public Migration_2_7()
19+
: base(new SemanticVersion(2, 7, 0)) { }
20+
21+
/// <inheritdoc />
22+
public override bool TryMigrate(ref PatchConfig[] patches, [NotNullWhen(false)] out string? error)
23+
{
24+
if (!base.TryMigrate(ref patches, out error))
25+
return false;
26+
27+
// 2.7 fixes a bug where you could set an enum field to a boolean value. This would previously be converted
28+
// numerically (like true -> 1 -> "MainGroup"), so match that logic for affected fields.
29+
//
30+
// This is based on the known affected content packs; it's not intended to cover every possible scenario (e.g.
31+
// patches which target "Data\Characters" or use 'Fields' instead).
32+
foreach (PatchConfig patch in patches)
33+
{
34+
if (patch.Entries.Count > 0 && string.Equals(patch.Target, "Data/Characters", StringComparison.OrdinalIgnoreCase))
35+
{
36+
foreach (JToken? rawEntry in patch.Entries.Values)
37+
{
38+
if (rawEntry is not JObject entry)
39+
continue;
40+
41+
JProperty? property = entry.Property(nameof(CharacterData.EndSlideShow), StringComparison.OrdinalIgnoreCase);
42+
if (property is null)
43+
continue;
44+
45+
string? rawValue = property.Value.Value<string>();
46+
if (string.Equals(rawValue, bool.TrueString, StringComparison.OrdinalIgnoreCase))
47+
property.Value = nameof(EndSlideShowBehavior.MainGroup);
48+
else if (string.Equals(rawValue, bool.FalseString, StringComparison.OrdinalIgnoreCase))
49+
property.Value = nameof(EndSlideShowBehavior.Hidden);
50+
}
51+
}
52+
}
53+
54+
return true;
55+
}
56+
}

ContentPatcher/ModEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ internal class ModEntry : Mod
7979
new Migration_2_4(),
8080
new Migration_2_5(),
8181
new Migration_2_6(),
82-
new EmptyMigration(2, 7)
82+
new Migration_2_7()
8383
];
8484

8585
/// <summary>The special validation logic to apply to assets affected by patches.</summary>

ContentPatcher/docs/release-notes.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ When releasing a format change, don't forget to update the smapi.io/json schema!
99
1010
1111
-->
12+
## 2.7.1
13+
Released 28 May 2025 for SMAPI 4.1.10 or later.
14+
15+
* Fixed content packs which incorrectly set `EndSlideShow` in `Data/Characters` to a true/false value.
16+
_Content Patcher 2.7.0 fixed a bug that allowed setting enum fields to a boolean value; 2.7.1 adds a format migration so older content packs will work like before._
17+
1218
## 2.7.0
13-
Released 27 May 2025 for SMAPI 4.1.10 or later.
19+
Released 27 May 2025 for SMAPI 4.1.10 or later. See [release highlights](https://www.patreon.com/posts/130042997).
1420

1521
* The `Priority` patch field is now sent to SMAPI to influence patch order relative to non-Content Patcher mods too (thanks to ichortower!).
1622
* The `patch export` command now auto-detects the type for all vanilla top-level data assets (thanks to SinZ!).
1723
* Fixed `EditData` patches appending to a list/dictionary field instead of replacing it in some cases.
1824
* Fixed `EditData`'s handling of certain Windows-only data formats when playing on Android/Linux/macOS.
1925
* Fixed `EditData`'s handling of data model fields with tokens in both the name and value (thanks to SinZ!).
26+
* Fixed `EditData` incorrectly allowing true/false values for enum fields and mapping them transitively (like `true``1``"MainGroup"`).
2027
* Clarified in [token docs](author-guide/tokens.md) that tokens use NPCs' internal names (thanks to DenisSilent!).
2128

2229
**Update notes for players:**

0 commit comments

Comments
 (0)