Resolve the SM5 sync drift issue

Summary of changes

1) Fix issues in RageTimer and RageSoundPosMap
2) Calculate seconds from microseconds more accurately
3) Replace lrint(x) with static_cast<int>(x+0.5) for better performance
4) Replace C style casting with C++ style casting
5) Make important values 64-bit wide
6) Update RageUtil.cpp (timer conversion RStrings had some math which needed to be fixed after fixing RageTimer's math)
7) Ensure floating point math is done as floating point
8) Improve code commentary all around
9) Improve clarity and efficiency of RageSoundPosMap "return closest position" error logging
This commit is contained in:
sukibaby
2024-05-12 08:05:41 -07:00
committed by teejusb
parent b365dcd65d
commit 705a069400
5 changed files with 118 additions and 139 deletions
+3 -2
View File
@@ -14,8 +14,9 @@ public:
pos_map_queue( const pos_map_queue &cpy );
pos_map_queue &operator=( const pos_map_queue &rhs );
/* Insert a mapping from iSourceFrame to iDestFrame, containing iFrames. */
void Insert( std::int64_t iSourceFrame, int iFrames, std::int64_t iDestFrame, float fSourceToDestRatio = 1.0f );
/* Insert a mapping from iSourceFrame to iDestFrame, containing iFrames.
* The double type is used to prevent precision loss leading to sync drift the longer the game runs. -sukibaby */
void Insert( std::int64_t iSourceFrame, std::int64_t iFrames, std::int64_t iDestFrame, double fSourceToDestRatio = 1.0 );
/* Return the iDestFrame for the given iSourceFrame. */
std::int64_t Search( std::int64_t iSourceFrame, bool *bApproximate ) const;