Merge pull request #273 from FunkinCrew/bugfix/controller-overflow

Gamepad Overflow fix for release builds
This commit is contained in:
Cameron Taylor 2024-01-12 07:48:55 -05:00 committed by GitHub
commit 304cee188a
5 changed files with 39 additions and 27 deletions

View file

@ -111,7 +111,7 @@
<haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->
<haxelib name="thx.semver" /> <!-- Version string handling -->
<haxelib name="hmm" if="debug" /> <!-- Read library version data at compile time -->
<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-->
@ -131,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. -->

View file

@ -107,7 +107,7 @@
"name": "lime",
"type": "git",
"dir": null,
"ref": "737b86f121cdc90358d59e2e527934f267c94a2c",
"ref": "fff39ba6fc64969cd51987ef7491d9345043dc5d",
"url": "https://github.com/FunkinCrew/lime"
},
{

View file

@ -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.

View file

@ -11,12 +11,12 @@ class HaxelibVersions
#else
// `#if display` is used for code completion. In this case returning an
// empty string is good enough; We don't want to call functions on every hint.
var commitHash:String = "";
return macro $v{commitHashSplice};
var commitHash:Array<String> = [];
return macro $v{commitHash};
#end
}
#if (debug && macro)
#if (macro)
static function readHmmData():hmm.HmmConfig
{
return hmm.HmmConfig.HmmConfigs.readHmmJsonOrThrow();

View file

@ -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;
}
}