Add a new playback mode ogg_shuffle == 4, truly random playback.

912b65ff74 changed mode `3` from random
playback to truly random playback, allowing the same track being played
several times in a row. Since some users might prefer the old behavior
move truly random playback to a new mode `4`. Add it to the menu and
finally document the `ogg_shuffle` cvar.

In addition to #1143
This commit is contained in:
Yamagi 2024-09-08 16:56:09 +02:00
parent da15696d23
commit 5acb267630
3 changed files with 19 additions and 0 deletions

View file

@ -291,6 +291,15 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
0. Setting this cvar to `1` disables this behavior, the music keeps 0. Setting this cvar to `1` disables this behavior, the music keeps
playing. playing.
* **ogg_shuffle**: Ogg/Vorbis playback mode. Supported modes are:
`0`: Loop the current track (the default).
`1`: Play the current track once, then stop.
`2`: Play all available tracks in a linear sequence.
`3`: Shuffle through the available tracks, never play the same track
twice in a row.
`4`: Shuffle through the available tracks, may play the same track
multiple times in a row.
* **s_doppler**: If set to `1` doppler effects are enabled. This is only * **s_doppler**: If set to `1` doppler effects are enabled. This is only
supported by the OpenAL sound backend. supported by the OpenAL sound backend.

View file

@ -2371,6 +2371,7 @@ Options_MenuInit(void)
"play once", "play once",
"sequential", "sequential",
"random", "random",
"truly random",
0 0
}; };

View file

@ -530,6 +530,7 @@ OGG_PlayTrack(const char *track, qboolean cdtrack, qboolean immediate)
newtrack = (curtrack + 1) % (ogg_maxfileindex + 1) != 0 ? (curtrack + 1) : 2; newtrack = (curtrack + 1) % (ogg_maxfileindex + 1) != 0 ? (curtrack + 1) : 2;
} break; } break;
case 3: // random case 3: // random
case 4: // random with true randomness
{ {
int retries = 100; int retries = 100;
newtrack = 0; newtrack = 0;
@ -537,6 +538,14 @@ OGG_PlayTrack(const char *track, qboolean cdtrack, qboolean immediate)
while (retries-- > 0 && newtrack < 2) while (retries-- > 0 && newtrack < 2)
{ {
newtrack = randk() % (ogg_maxfileindex + 1); newtrack = randk() % (ogg_maxfileindex + 1);
if (playback == 3)
{
if (newtrack == curtrack)
{
newtrack = 0;
}
}
} }
} break; } break;
} }