xan1242 / XNFSMusicPlayer

Xan's NFS Music Player - Custom music player replacement and a BASS library interface for NFS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

AJLethal opened this issue · 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

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.

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.

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).

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