The paging loop in AdvancedSearchGump.Build assumed a full MaxEntries page: on a partial last page in descending mode, the first iteration's index already overflowed SearchResults.Length, and the break early-out killed the whole loop, rendering zero rows. Add a VisibleCount(total, displayFrom, maxEntries) helper and bound the loop to it instead of MaxEntries, generalizing the descending offset formula (MaxEntries - 1 - i -> visibleCount - 1 - i) so it stays valid for partial pages while being identical to the old formula on full pages.
17 lines
523 B
C#
17 lines
523 B
C#
using Server.Engines.AdvancedSearch;
|
|
using Xunit;
|
|
|
|
namespace UOContent.Tests;
|
|
|
|
public class AdvancedSearchPagingTests
|
|
{
|
|
[Theory]
|
|
[InlineData(20, 0, 18, 18)] // full first page
|
|
[InlineData(20, 18, 18, 2)] // partial last page -> 2 visible (bug rendered 0 in descending)
|
|
[InlineData(5, 0, 18, 5)]
|
|
[InlineData(0, 0, 18, 0)]
|
|
public void VisibleCount_IsCorrect(int total, int from, int max, int expected)
|
|
{
|
|
Assert.Equal(expected, AdvancedSearchGump.VisibleCount(total, from, max));
|
|
}
|
|
}
|