mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
Fix an issue causing an overflow error when using gamepad (WINDOWS ONLY)
This commit is contained in:
parent
59999aa8fd
commit
043fb553f6
4 changed files with 36 additions and 23 deletions
|
@ -111,6 +111,7 @@
|
|||
<haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->
|
||||
<haxelib name="thx.semver" /> <!-- Version string handling -->
|
||||
|
||||
<haxelib name="hmm" /> <!-- Read library version data at compile time so it can be baked into logs -->
|
||||
<haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support -->
|
||||
|
||||
<!--Disable the Flixel core focus lost screen-->
|
||||
|
@ -130,8 +131,8 @@
|
|||
<haxedef name="message-reporting" value="pretty" />
|
||||
|
||||
<!-- _________________________________ Custom _______________________________ -->
|
||||
<!-- Disable trace() calls in release builds to bump up performance. -->
|
||||
<haxeflag name="--no-traces" unless="debug" />
|
||||
<!-- Disable trace() calls in release builds to bump up performance.
|
||||
<haxeflag name="- -no-traces" unless="debug" />-->
|
||||
<!-- HScript relies heavily on Reflection, which means we can't use DCE. -->
|
||||
<haxeflag name="-dce no" />
|
||||
<!-- Ensure all Funkin' classes are available at runtime. -->
|
||||
|
|
2
hmm.json
2
hmm.json
|
@ -107,7 +107,7 @@
|
|||
"name": "lime",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "737b86f121cdc90358d59e2e527934f267c94a2c",
|
||||
"ref": "17086ec7fa4535ddb54d01fdc00a318bb8ce6413",
|
||||
"url": "https://github.com/FunkinCrew/lime"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -2270,8 +2270,10 @@ 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;
|
||||
trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
|
||||
// trace('Compare: ${PreciseInputManager.getCurrentTimestamp()} - ${input.timestamp}');
|
||||
var inputLatencyNs:Int64 = PreciseInputManager.getCurrentTimestamp() - input.timestamp;
|
||||
var inputLatencyMs:Float = inputLatencyNs.toFloat() / Constants.NS_PER_MS;
|
||||
// trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
|
||||
|
||||
// Get the offset and compensate for input latency.
|
||||
// Round inward (trim remainder) for consistency.
|
||||
|
|
|
@ -1,32 +1,42 @@
|
|||
package funkin.util.tools;
|
||||
|
||||
import haxe.Int64;
|
||||
|
||||
/**
|
||||
* @see https://github.com/fponticelli/thx.core/blob/master/src/thx/Int64s.hx
|
||||
* Why `haxe.Int64` doesn't have a built-in `toFloat` function is beyond me.
|
||||
*/
|
||||
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);
|
||||
private inline static var MAX_32_PRECISION:Float = 4294967296.0;
|
||||
|
||||
public static function toFloat(i:haxe.Int64):Float
|
||||
public static function fromFloat(f:Float):Int64
|
||||
{
|
||||
var isNegative = false;
|
||||
if (i < 0)
|
||||
var h = Std.int(f / MAX_32_PRECISION);
|
||||
var l = Std.int(f);
|
||||
return Int64.make(h, l);
|
||||
}
|
||||
|
||||
public static function toFloat(i:Int64):Float
|
||||
{
|
||||
var f:Float = Int64.getLow(i);
|
||||
if (f < 0) f += MAX_32_PRECISION;
|
||||
return (Int64.getHigh(i) * MAX_32_PRECISION + f);
|
||||
}
|
||||
|
||||
public static function isToIntSafe(i:Int64):Bool
|
||||
{
|
||||
return i.high != i.low >> 31;
|
||||
}
|
||||
|
||||
public static function toIntSafe(i:Int64):Int
|
||||
{
|
||||
try
|
||||
{
|
||||
if (i < min) return -9223372036854775808.0; // most -ve value can't be made +ve
|
||||
isNegative = true;
|
||||
i = -i;
|
||||
return Int64.toInt(i);
|
||||
}
|
||||
var multiplier = 1.0, ret = 0.0;
|
||||
for (_ in 0...64)
|
||||
catch (e:Dynamic)
|
||||
{
|
||||
if (haxe.Int64.and(i, one) != zero) ret += multiplier;
|
||||
multiplier *= 2.0;
|
||||
i = haxe.Int64.shr(i, 1);
|
||||
throw 'Could not represent value "${Int64.toStr(i)}" as an integer.';
|
||||
}
|
||||
return (isNegative ? -1 : 1) * ret;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue