Sounds: a range's permutation mask without shifts past its bits

A range with no previous permutation (NONE) set the bit NONE as a byte
shifted to, 255.

(cherry picked from commit a35ddbe6bfcd31d5aa0c501dac52721fc295fa50)
(cherry picked from commit cd87b861b1203df530e22e777219255c21408984)
This commit is contained in:
Milenko authored and MrBruh committed 2026-10-10 12:53:23 +13:00
1 parent f38d526e83
commit f7ea5db0e9
1 file changed
+9 -3
+9 -3
View File
@@ -162,13 +162,19 @@ void try_to_reset_permutations(
struct sound_pitch_range *range)
{
short permutation_count = range->actual_permutation_count;
unsigned long all_permutations_mask = (FLAG(permutation_count) - 1);
/* port: the mask of no more permutations than it has bits, and the
previous one's bit only if there was one (NONE shifted by 255) */
unsigned long all_permutations_mask = permutation_count >= 32 ? 0xFFFFFFFFUL :
permutation_count > 0 ? (FLAG(permutation_count) - 1) : 0;
if ((~range->played_permutation_mask & all_permutations_mask) == 0)
{
range->played_permutation_mask = 0;
if (permutation_count > 1)
range->played_permutation_mask = FLAG((byte)range->previous_permutation_index);
if (permutation_count > 1 && range->previous_permutation_index >= 0 &&
range->previous_permutation_index < 32)
{
range->played_permutation_mask = FLAG(range->previous_permutation_index);
}
}
return;