1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-25 08:13:45 +00:00

Fix build issues caused by int64 handling

This commit is contained in:
EliteMasterEric 2023-08-03 22:22:29 -04:00
parent 1caf905ef8
commit 49622f2441
3 changed files with 35 additions and 1 deletions

View file

@ -11,6 +11,7 @@ using Lambda;
using StringTools;
using funkin.util.tools.ArrayTools;
using funkin.util.tools.ArraySortTools;
using funkin.util.tools.Int64Tools;
using funkin.util.tools.IteratorTools;
using funkin.util.tools.MapTools;
using funkin.util.tools.StringTools;

View file

@ -2326,7 +2326,8 @@ class PlayState extends MusicBeatSubState
vocals.playerVolume = 1;
// Calculate the input latency (do this as late as possible).
var inputLatencyMs:Float = haxe.Int64.toInt(PreciseInputManager.getCurrentTimestamp() - input.timestamp) / 1000.0 / 1000.0;
var currentTimestampNs:Int64 = PreciseInputManager.getCurrentTimestamp();
var inputLatencyMs:Float = haxe.Int64.toInt(currentTimestampNs - input.timestamp) / Constants.NS_PER_MS;
trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
// Get the offset and compensate for input latency.

View file

@ -0,0 +1,32 @@
package funkin.util.tools;
/**
* @see https://github.com/fponticelli/thx.core/blob/master/src/thx/Int64s.hx
*/
class Int64Tools
{
static var min = haxe.Int64.make(0x80000000, 0);
static var one = haxe.Int64.make(0, 1);
static var two = haxe.Int64.ofInt(2);
static var zero = haxe.Int64.make(0, 0);
static var ten = haxe.Int64.ofInt(10);
public static function toFloat(i:haxe.Int64):Float
{
var isNegative = false;
if (i < 0)
{
if (i < min) return -9223372036854775808.0; // most -ve value can't be made +ve
isNegative = true;
i = -i;
}
var multiplier = 1.0, ret = 0.0;
for (_ in 0...64)
{
if (haxe.Int64.and(i, one) != zero) ret += multiplier;
multiplier *= 2.0;
i = haxe.Int64.shr(i, 1);
}
return (isNegative ? -1 : 1) * ret;
}
}