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:
parent
1caf905ef8
commit
49622f2441
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
32
source/funkin/util/tools/Int64Tools.hx
Normal file
32
source/funkin/util/tools/Int64Tools.hx
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue