Tbonehunter
Cowpoke
StardewValley.Menus CharacterCustomization.cs file has what appears to be a copy/paste error which does not manifest in vanilla game play but does show up when the number of selectable farm types exceeds the 12-farm display, rolling to a second selection screen.
The pagination is set up as 12 farms per page — a 2-column × 6-row grid. Line 1186 computes _farmPages using 12 as the divisor:
csharp_farmPages = (int)Math.Floor((float)(farmTypeButtonNames.Count - 1) / 12f) + 1;
And RefreshFarmTypeButtons at line 1194 populates the visible page starting from _currentFarmPage * 12:
csharpint index = _currentFarmPage * 12;
Then it does twelve unrolled Add calls, incrementing index between each, laying out the buttons in two columns of six. That part is correct — the farmTypeButtons list contains the right names, tooltips, and icons for the current page, and each button's bounds sits at the right spot on screen.
The click path (line 2071-2082) then uses only the button's own .name — no re-indexing.
The error is in the draw method, line 2963, "int index = i + _currentFarmPage * 6;" which should read "int index = i + _currentFarmPage * 12;". The entire section is copied below:
csharpfor (int i = 0; i < farmTypeButtons.Count; i++)
{
farmTypeButtons.draw(b, ...);
...
bool farm_is_selected = false;
int index = i + _currentFarmPage * 6; // ← wrong: should be * 12
if (Game1.whichFarm == 7)
{
if ("ModFarm_" + Game1.whichModFarm.Id == farmTypeButtonNames[index])
{
farm_is_selected = true;
}
}
else if (Game1.whichFarm == index)
{
farm_is_selected = true;
}
if (farm_is_selected)
{
IClickableMenu.drawTextureBox(b, ..., farmTypeButtons.bounds.X, ...);
}
}
Every other pagination expression in the file multiplies _currentFarmPage by 12; only this one uses 6. On page 0 the two happen to give the same result (both zero), so no bug is visible. On page 1, the highlight-check reads names from farmTypeButtonNames[i+6] when the visible button i is actually showing farmTypeButtonNames[i+12] — off by 6 slots. On page 2 it's off by 12, and so on. Since the visible layout is a 2×6 grid where i=0..5 fills the left column and i=6..11 fills the right column, a 6-slot offset within a page maps to "same row, adjacent column".
This manifested when using a farm type manager mod, "CP Farm Registrar." That mod has been updated with a harmony patch to change the 6 to a 12, but the underlying error in the original game code still exists.
I could not post this bug report without selecting a prefix, but the issue exists in all OS iterations, not just Windows.
The pagination is set up as 12 farms per page — a 2-column × 6-row grid. Line 1186 computes _farmPages using 12 as the divisor:
csharp_farmPages = (int)Math.Floor((float)(farmTypeButtonNames.Count - 1) / 12f) + 1;
And RefreshFarmTypeButtons at line 1194 populates the visible page starting from _currentFarmPage * 12:
csharpint index = _currentFarmPage * 12;
Then it does twelve unrolled Add calls, incrementing index between each, laying out the buttons in two columns of six. That part is correct — the farmTypeButtons list contains the right names, tooltips, and icons for the current page, and each button's bounds sits at the right spot on screen.
The click path (line 2071-2082) then uses only the button's own .name — no re-indexing.
The error is in the draw method, line 2963, "int index = i + _currentFarmPage * 6;" which should read "int index = i + _currentFarmPage * 12;". The entire section is copied below:
csharpfor (int i = 0; i < farmTypeButtons.Count; i++)
{
farmTypeButtons.draw(b, ...);
...
bool farm_is_selected = false;
int index = i + _currentFarmPage * 6; // ← wrong: should be * 12
if (Game1.whichFarm == 7)
{
if ("ModFarm_" + Game1.whichModFarm.Id == farmTypeButtonNames[index])
{
farm_is_selected = true;
}
}
else if (Game1.whichFarm == index)
{
farm_is_selected = true;
}
if (farm_is_selected)
{
IClickableMenu.drawTextureBox(b, ..., farmTypeButtons.bounds.X, ...);
}
}
Every other pagination expression in the file multiplies _currentFarmPage by 12; only this one uses 6. On page 0 the two happen to give the same result (both zero), so no bug is visible. On page 1, the highlight-check reads names from farmTypeButtonNames[i+6] when the visible button i is actually showing farmTypeButtonNames[i+12] — off by 6 slots. On page 2 it's off by 12, and so on. Since the visible layout is a 2×6 grid where i=0..5 fills the left column and i=6..11 fills the right column, a 6-slot offset within a page maps to "same row, adjacent column".
This manifested when using a farm type manager mod, "CP Farm Registrar." That mod has been updated with a harmony patch to change the 6 to a 12, but the underlying error in the original game code still exists.
I could not post this bug report without selecting a prefix, but the issue exists in all OS iterations, not just Windows.
Attachments
-
15.9 KB Views: 22