Skip to content

Commit b681bc7

Browse files
committed
Merge branch 'develop'
2 parents 7f9b43e + cc7b3f9 commit b681bc7

27 files changed

Lines changed: 256 additions & 104 deletions

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build releases
2+
on: push
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
permissions:
7+
id-token: write # for attestation
8+
attestations: write # for attestation
9+
10+
steps:
11+
- name: Fetch code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-tags: false
15+
16+
- name: Add build environment
17+
uses: Pathoschild/SMAPI-ModBuildWorkflow/add-build-environment@v1
18+
19+
- name: Build mods
20+
run: dotnet build
21+
22+
- name: Upload release zips
23+
uses: Pathoschild/SMAPI-ModBuildWorkflow/upload-release-artifacts@v1
24+
with:
25+
create_attestations: ${{github.ref_type == 'tag'}}
26+
create_combined_zip: "all-mods"
27+
if: ${{github.ref_type == 'tag'}}

BetterRNG/Framework/MersenneTwister.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public MersenneTwister(int seed)
1919
/// Creates a new pseudo-random number generator with a default seed.
2020
/// </summary>
2121
/// <remarks>
22-
/// <c>new <see cref="System.Random"/>().<see cref="Random.Next()"/></c>
22+
/// <c>new <see cref="System.Random"/>().<see cref="Random.Next()"/></c>
2323
/// is used for the seed.
2424
/// </remarks>
2525
public MersenneTwister() : this(new Random().Next(int.MinValue, int.MaxValue)) /* a default initial seed is used */
@@ -34,7 +34,7 @@ public MersenneTwister(int[] initKey)
3434
{
3535
if (initKey == null)
3636
{
37-
throw new ArgumentNullException("initKey");
37+
throw new ArgumentNullException(nameof(initKey));
3838
}
3939

4040
uint[] initArray = new uint[initKey.Length];
@@ -82,13 +82,13 @@ public override int Next(int maxValue)
8282
}
8383

8484
/// <summary>
85-
/// Returns the next pseudo-random <see cref="Int32"/>
86-
/// at least <paramref name="minValue"/>
85+
/// Returns the next pseudo-random <see cref="Int32"/>
86+
/// at least <paramref name="minValue"/>
8787
/// and up to <paramref name="maxValue"/>.
8888
/// </summary>
8989
/// <param name="minValue">The minimum value of the pseudo-random number to create.</param>
9090
/// <param name="maxValue">The maximum value of the pseudo-random number to create.</param>
91-
/// <returns>A pseudo-random Int32 value which is at least <paramref name="minValue"/> and at
91+
/// <returns>A pseudo-random Int32 value which is at least <paramref name="minValue"/> and at
9292
/// most <paramref name="maxValue"/>.</returns>
9393
/// <exception cref="ArgumentOutOfRangeException">
9494
/// If <c><paramref name="minValue"/> &gt;= <paramref name="maxValue"/></c>.
@@ -137,17 +137,17 @@ public override void NextBytes(byte[] buffer)
137137
/// <returns>A pseudo-random double floating point value.</returns>
138138
/// <remarks>
139139
/// <para>
140-
/// There are two common ways to create a double floating point using MT19937:
141-
/// using <see cref="GenerateUInt32"/> and dividing by 0xFFFFFFFF + 1,
142-
/// or else generating two double words and shifting the first by 26 bits and
140+
/// There are two common ways to create a double floating point using MT19937:
141+
/// using <see cref="GenerateUInt32"/> and dividing by 0xFFFFFFFF + 1,
142+
/// or else generating two double words and shifting the first by 26 bits and
143143
/// adding the second.
144144
/// </para>
145145
/// <para>
146-
/// In a newer measurement of the randomness of MT19937 published in the
146+
/// In a newer measurement of the randomness of MT19937 published in the
147147
/// journal "Monte Carlo Methods and Applications, Vol. 12, No. 5-6, pp. 385 ñ 393 (2006)"
148148
/// entitled "A Repetition Test for Pseudo-Random Number Generators",
149-
/// it was found that the 32-bit version of generating a double fails at the 95%
150-
/// confidence level when measuring for expected repetitions of a particular
149+
/// it was found that the 32-bit version of generating a double fails at the 95%
150+
/// confidence level when measuring for expected repetitions of a particular
151151
/// number in a sequence of numbers generated by the algorithm.
152152
/// </para>
153153
/// <para>
@@ -250,24 +250,23 @@ private void init(uint seed)
250250
for (this._mti = 1; this._mti < MersenneTwister.N; this._mti++)
251251
{
252252
this._mt[this._mti] = (uint)(1812433253u * (this._mt[this._mti - 1] ^ (this._mt[this._mti - 1] >> 30)) + this._mti);
253-
// See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
254-
// In the previous versions, MSBs of the seed affect
255-
// only MSBs of the array _mt[].
256-
// 2002/01/09 modified by Makoto Matsumoto
253+
// See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
254+
// In the previous versions, MSBs of the seed affect
255+
// only MSBs of the array _mt[].
256+
// 2002/01/09 modified by Makoto Matsumoto
257257
this._mt[this._mti] &= 0xffffffffu;
258258
// for >32 bit machines
259259
}
260260
}
261261

262262
private void init(uint[] key)
263263
{
264-
int i, j, k;
265264
this.init(19650218u);
266265

267266
int keyLength = key.Length;
268-
i = 1;
269-
j = 0;
270-
k = (MersenneTwister.N > keyLength ? MersenneTwister.N : keyLength);
267+
int i = 1;
268+
int j = 0;
269+
int k = (MersenneTwister.N > keyLength ? MersenneTwister.N : keyLength);
271270

272271
for (; k > 0; k--)
273272
{
@@ -326,7 +325,7 @@ private double compute53BitRandom(double translate, double scale)
326325
// add another pseudo-random 26 bits (+ b).
327326
return ((a * 67108864.0 + b) + translate) * scale;
328327

329-
// What about the following instead of the above? Is the multiply better?
328+
// What about the following instead of the above? Is the multiply better?
330329
// Why? (Is it the FMUL instruction? Does this count in .Net? Will the JITter notice?)
331330
//return BitConverter.Int64BitsToDouble((a << 26) + b));
332331
}

BetterRNG/Framework/ModConfig.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Runtime.Serialization;
13
using StardewModdingAPI;
24
using StardewModdingAPI.Utilities;
35

@@ -6,6 +8,9 @@ namespace BetterRNG.Framework;
68
/// <summary>The mod configuration.</summary>
79
internal class ModConfig
810
{
11+
/*********
12+
** Accessors
13+
*********/
914
/// <summary>Whether to randomise your daily luck.</summary>
1015
public bool EnableDailyLuckOverride { get; set; }
1116

@@ -29,4 +34,17 @@ internal class ModConfig
2934

3035
/// <summary>The keys which reload the mod config.</summary>
3136
public KeybindList ReloadKey { get; set; } = new(SButton.F5);
37+
38+
39+
/*********
40+
** Private methods
41+
*********/
42+
/// <summary>The method called after the config file is deserialized.</summary>
43+
/// <param name="context">The deserialization context.</param>
44+
[OnDeserialized]
45+
[SuppressMessage("ReSharper", "NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract", Justification = "")]
46+
private void OnDeserializedMethod(StreamingContext context)
47+
{
48+
this.ReloadKey ??= new KeybindList(SButton.None);
49+
}
3250
}

BetterRNG/Framework/Weighted.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
using System;
12
using System.Linq;
23

34
namespace BetterRNG.Framework;
45

56
internal static class Weighted
67
{
7-
public static T Choose<T>(T[] list) where T : IWeighted
8+
public static T Choose<T>(T[] list)
9+
where T : IWeighted
810
{
911
if (!list.Any())
10-
return default;
12+
throw new InvalidOperationException("Can't choose a value because no options were provided.");
1113

12-
int totalweight = list.Sum(c => c.Weight);
13-
int choice = ModEntry.Twister.Next(totalweight);
14+
int totalWeight = list.Sum(c => c.Weight);
15+
int choice = ModEntry.Twister.Next(totalWeight);
1416
int sum = 0;
1517

16-
foreach (var obj in list)
18+
foreach (T obj in list)
1719
{
1820
for (float i = sum; i < obj.Weight + sum; i++)
1921
{

BetterRNG/ModEntry.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@ public class ModEntry : Mod
1414
** Properties
1515
*********/
1616
/// <summary>The mod configuration.</summary>
17-
private ModConfig Config;
17+
private ModConfig Config = null!; // set in Entry
1818

19-
private WeightedGeneric<string>[] Weather;
19+
private WeightedGeneric<string>[] Weather = null!; // set in Entry
2020

2121

2222
/*********
2323
** Accessors
2424
*********/
25-
internal static MersenneTwister Twister { get; private set; }
25+
internal static MersenneTwister Twister { get; private set; } = null!; // set in Entry
2626

2727

2828
/*********
2929
** Public methods
3030
*********/
31-
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
32-
/// <param name="helper">Provides simplified APIs for writing mods.</param>
31+
/// <inheritdoc />
3332
public override void Entry(IModHelper helper)
3433
{
3534
CommonHelper.RemoveObsoleteFiles(this, "BetterRNG.pdb");
@@ -57,18 +56,14 @@ public override void Entry(IModHelper helper)
5756
/*********
5857
** Private methods
5958
*********/
60-
/// <summary>Raised after the player starts a new day.</summary>
61-
/// <param name="sender">The event sender.</param>
62-
/// <param name="e">The event arguments.</param>
63-
private void OnDayStarted(object sender, DayStartedEventArgs e)
59+
/// <inheritdoc cref="IGameLoopEvents.DayStarted" />
60+
private void OnDayStarted(object? sender, DayStartedEventArgs e)
6461
{
6562
this.DetermineRng();
6663
}
6764

68-
/// <inheritdoc cref="IInputEvents.ButtonsChanged"/>
69-
/// <param name="sender">The event sender.</param>
70-
/// <param name="e">The event arguments.</param>
71-
private void OnButtonsChanged(object sender, ButtonsChangedEventArgs e)
65+
/// <inheritdoc cref="IInputEvents.ButtonsChanged" />
66+
private void OnButtonsChanged(object? sender, ButtonsChangedEventArgs e)
7267
{
7368
if (this.Config.ReloadKey.JustPressed())
7469
{

BetterRNG/release-notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
[← back to readme](README.md)
22

33
## Release notes
4+
## 2.9.1
5+
Released 15 March 2026 for SMAPI 4.1.2 or later. Updated by Pathoschild.
6+
7+
* Better RNG downloads are now created via [automated and attested builds](https://www.patreon.com/posts/automated-builds-148417912).
8+
_This guarantees that the download only contains what's in the public source code and hasn't been tampered with._
9+
* Fixed error if the `ReloadKey` config option is set to `null`.
10+
* Internal changes to simplify maintenance.
11+
412
## 2.9.0
513
Released 11 January 2026 for SMAPI 4.1.2 or later. Updated by Pathoschild.
614

CalendarAnywhere/ModEntry.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public class ModEntry : Mod
1313
/*********
1414
** Public methods
1515
*********/
16-
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
17-
/// <param name="helper">Provides simplified APIs for writing mods.</param>
16+
/// <inheritdoc />
1817
public override void Entry(IModHelper helper)
1918
{
2019
CommonHelper.RemoveObsoleteFiles(this, "CalendarAnywhere.pdb");
@@ -26,10 +25,8 @@ public override void Entry(IModHelper helper)
2625
/*********
2726
** Private methods
2827
*********/
29-
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
30-
/// <param name="sender">The event sender.</param>
31-
/// <param name="e">The event arguments.</param>
32-
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
28+
/// <inheritdoc cref="IInputEvents.ButtonPressed" />
29+
private void OnButtonPressed(object? sender, ButtonPressedEventArgs e)
3330
{
3431
if (Context.IsPlayerFree && e.Button.IsUseToolButton() && this.GetTarget().Contains((int)e.Cursor.ScreenPixels.X, (int)e.Cursor.ScreenPixels.Y))
3532
Game1.activeClickableMenu = new Billboard();

CalendarAnywhere/release-notes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
[← back to readme](README.md)
22

33
## Release notes
4+
## 2.9.1
5+
Released 15 March 2026 for SMAPI 4.1.2 or later. Updated by Pathoschild.
6+
7+
* Calendar Anywhere downloads are now created via [automated and attested builds](https://www.patreon.com/posts/automated-builds-148417912).
8+
_This guarantees that the download only contains what's in the public source code and hasn't been tampered with._
9+
* Internal changes to simplify maintenance.
10+
411
## 2.8.5
512
Released 04 November 2024 for SMAPI 4.1.2 or later. Updated by Pathoschild.
613

Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
<RepositoryUrl>https://github.com/Zoryn4163/SMAPI-Mods</RepositoryUrl>
66
<RepositoryType>git</RepositoryType>
77

8-
<Version>2.9.0</Version>
8+
<Version>2.9.1</Version>
99

1010
<TargetFramework>net6.0</TargetFramework>
11+
<Nullable>enable</Nullable>
1112
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1213
<ModZipPath>$(SolutionDir)\_releases</ModZipPath>
1314
</PropertyGroup>

DurableFences/ModEntry.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public class ModEntry : Mod
1111
/*********
1212
** Public methods
1313
*********/
14-
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
15-
/// <param name="helper">Provides simplified APIs for writing mods.</param>
14+
/// <inheritdoc />
1615
public override void Entry(IModHelper helper)
1716
{
1817
CommonHelper.RemoveObsoleteFiles(this, "DurableFences.pdb");
@@ -24,10 +23,8 @@ public override void Entry(IModHelper helper)
2423
/*********
2524
** Private methods
2625
*********/
27-
/// <summary>Raised once per second after the game state is updated.</summary>
28-
/// <param name="sender">The event sender.</param>
29-
/// <param name="e">The event arguments.</param>
30-
private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
26+
/// <inheritdoc cref="IGameLoopEvents.OneSecondUpdateTicked" />
27+
private void OnOneSecondUpdateTicked(object? sender, OneSecondUpdateTickedEventArgs e)
3128
{
3229
Utility.ForEachLocation(location =>
3330
{

0 commit comments

Comments
 (0)