mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-04 13:54:22 +00:00
Make sure timestamps are consistent with use of Int64.
This commit is contained in:
parent
49622f2441
commit
13671cf290
|
@ -84,6 +84,11 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from int to Int64.
|
||||
*/
|
||||
static final NS_PER_MS:Int64 = Constants.NS_PER_MS;
|
||||
|
||||
/**
|
||||
* Returns a precise timestamp, measured in nanoseconds.
|
||||
* Timestamp is only useful for comparing against other timestamps.
|
||||
|
@ -97,11 +102,11 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
|
|||
// NOTE: This timestamp isn't that precise on standard HTML5 builds.
|
||||
// This is because of browser safeguards against timing attacks.
|
||||
// See https://web.dev/coop-coep to enable headers which allow for more precise timestamps.
|
||||
return haxe.Int64.fromFloat(js.Browser.window.performance.now() * Constants.NS_PER_MS);
|
||||
return haxe.Int64.fromFloat(js.Browser.window.performance.now()) * NS_PER_MS;
|
||||
#elseif cpp
|
||||
// NOTE: If the game hard crashes on this line, rebuild Lime!
|
||||
// `lime rebuild windows -clean`
|
||||
return lime._internal.backend.native.NativeCFFI.lime_sdl_get_ticks() * Constants.NS_PER_MS;
|
||||
return lime._internal.backend.native.NativeCFFI.lime_sdl_get_ticks() * NS_PER_MS;
|
||||
#else
|
||||
throw "Eric didn't implement precise timestamps on this platform!";
|
||||
#end
|
||||
|
|
|
@ -2326,8 +2326,7 @@ class PlayState extends MusicBeatSubState
|
|||
vocals.playerVolume = 1;
|
||||
|
||||
// Calculate the input latency (do this as late as possible).
|
||||
var currentTimestampNs:Int64 = PreciseInputManager.getCurrentTimestamp();
|
||||
var inputLatencyMs:Float = haxe.Int64.toInt(currentTimestampNs - input.timestamp) / Constants.NS_PER_MS;
|
||||
var inputLatencyMs:Float = haxe.Int64.toInt(PreciseInputManager.getCurrentTimestamp() - input.timestamp) / 1000.0 / 1000.0;
|
||||
trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
|
||||
|
||||
// Get the offset and compensate for input latency.
|
||||
|
|
Loading…
Reference in a new issue