XNFSMusicPlayer icon indicating copy to clipboard operation
XNFSMusicPlayer copied to clipboard

[MW] PlaybackMode & track randomizer not working properly in large playlists

Open AJLethal opened this issue 2 years ago • 4 comments

In playlists with more than 32 songs, PlaybackMode settings stop working (they start playing in both menu and in-race as if they were set to AL); this is noticeable in rather large playlists

AJLethal avatar Mar 27 '22 04:03 AJLethal

This is an issue with the track randomizer. It seems to be poorly written by the original developers.

Due do some bit-shifting shenanigans going on in the function SFXObj_PFEATrax::GenNextMusicTrackID() it loses bits during some calculations.

So for example: setting the track 38 (0x26) to be the ONLY enabled track will cause the game to play track 38 (0x26) and 6 at certain intervals.

Why? Simple, bit 6 gets lost somewhere during game checks.

(As far as I can see, there are arrays with some counters denoting how many are in which mode (IG, FE, AL, OF) in game memory starting from 008F2080)

This will need some deeper investigation.

xan1242 avatar Aug 21 '22 21:08 xan1242

Just to note a few things before I forget:

  1. This is a problem caused by bitmasks - the game uses 3 integer bitmasks in order to determine which song to play in which mode
  2. A solution to this would be to rewrite this entirely. It shouldn't be too hard to do because we can easily track the game state via the GameFlowManager.

xan1242 avatar Nov 04 '22 12:11 xan1242

The solution is here:

https://github.com/xan1242/NFS_CustomJukebox/blob/3a36ca50be9d3d7ddc1da60224cfc135537787e0/NFSPS_CustomJukebox/dllmain.cpp#L707

It needs to be backported to this player in order to fully solve these issues (this especially includes Carbon despite it avoiding the issue via recursion).

I will make a CustomJukebox plugin for MW and Carbon, so I'll also try to apply that code here (since it's basically the same part anyways).

xan1242 avatar Dec 02 '22 00:12 xan1242

I have the same problem when I tried to make own soundtrack

RostovShev03 avatar Nov 10 '23 07:11 RostovShev03