diff --git a/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs b/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs index 84216646..5fe1d34f 100644 --- a/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs +++ b/CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs @@ -206,18 +206,14 @@ private static void PreventEmoteMod(ILCursor ilCursor, ILContext ilContext) { ins => ins.OpCode == OpCodes.Callvirt, ins => ins.OpCode == OpCodes.Callvirt && ins.Operand.ToString().Contains("::get_Count()") )) { - object getSettings = ilCursor.Next.Operand; - object getEmoteWheelBindingSettings = ilCursor.Next.Next.Operand; - ilCursor.Index += 4; - ilCursor - .Emit(OpCodes.Call, getSettings) - .Emit(OpCodes.Callvirt, getEmoteWheelBindingSettings) - .EmitDelegate(IsEmoteWheelBindingPressed); + ilCursor.Index += 2; + ilCursor.Emit(OpCodes.Dup); + ilCursor.Index += 2; + ilCursor.EmitDelegate(IsEmoteWheelBindingPressed); } - } - private static int IsEmoteWheelBindingPressed(int count, ButtonBinding binding) { + private static int IsEmoteWheelBindingPressed(ButtonBinding binding, int count) { return binding.Pressed ? count : 0; } } \ No newline at end of file diff --git a/CelesteTAS-EverestInterop/Source/EverestInterop/InfoHUD/InfoSubPixelIndicator.cs b/CelesteTAS-EverestInterop/Source/EverestInterop/InfoHUD/InfoSubPixelIndicator.cs index 49eb78dc..bba1a52a 100644 --- a/CelesteTAS-EverestInterop/Source/EverestInterop/InfoHUD/InfoSubPixelIndicator.cs +++ b/CelesteTAS-EverestInterop/Source/EverestInterop/InfoHUD/InfoSubPixelIndicator.cs @@ -1,5 +1,7 @@ using System; +using System.Linq; using Celeste; +using Celeste.Pico8; using Microsoft.Xna.Framework; using Monocle; using TAS.Utils; @@ -20,14 +22,18 @@ public static void DrawIndicator(float y, float padding, float alpha) { float subPixelBottom = 0.5f; int decimals = TasSettings.SubpixelIndicatorDecimals; - Player player = Engine.Scene.Tracker.GetEntity(); - if (player != null) { - subPixelLeft = (float) Math.Round(player.movementCounter.X + 0.5f, decimals, MidpointRounding.AwayFromZero); - subPixelTop = (float) Math.Round(player.movementCounter.Y + 0.5f, decimals, MidpointRounding.AwayFromZero); - subPixelRight = 1f - subPixelLeft; - subPixelBottom = 1f - subPixelTop; + Vector2 remainder = Engine.Scene.Tracker.GetEntity()?.movementCounter ?? Vector2.Zero; + if (Engine.Scene is Level level && level.GetPlayer() is { } player) { + remainder = player.movementCounter; + } else if (Engine.Scene is Emulator emulator && emulator.game?.objects.FirstOrDefault(o => o is Classic.player) is Classic.player classicPlayer) { + remainder = classicPlayer.rem; } + subPixelLeft = (float) Math.Round(remainder.X + 0.5f, decimals, MidpointRounding.AwayFromZero); + subPixelTop = (float) Math.Round(remainder.Y + 0.5f, decimals, MidpointRounding.AwayFromZero); + subPixelRight = 1f - subPixelLeft; + subPixelBottom = 1f - subPixelTop; + Vector2 textSize = GetSubPixelTextSize(); float textWidth = textSize.X; float textHeight = textSize.Y; @@ -39,7 +45,6 @@ public static void DrawIndicator(float y, float padding, float alpha) { Draw.Rect(x + (rectSide - thickness) * subPixelLeft, y + (rectSide - thickness) * subPixelTop, thickness, thickness, Color.Red * alpha); - Vector2 remainder = player?.movementCounter ?? Vector2.One; int hDecimals = Math.Abs(remainder.X) switch { 0.5f => 0, _ => decimals diff --git a/CelesteTAS-EverestInterop/Source/Module/CelesteTasSettings.cs b/CelesteTAS-EverestInterop/Source/Module/CelesteTasSettings.cs index 3fc1a6f3..fe2ebba5 100644 --- a/CelesteTAS-EverestInterop/Source/Module/CelesteTasSettings.cs +++ b/CelesteTAS-EverestInterop/Source/Module/CelesteTasSettings.cs @@ -181,16 +181,7 @@ public SimplifiedGraphicsFeature.SolidTilesStyle SimplifiedSolidTilesStyle { public bool EnableInfoHudFirstTime = true; public bool InfoGame { get; set; } = true; public bool InfoTasInput { get; set; } = true; - - [YamlMember(Alias = "InfoSubpixelIndicator")] - public bool _InfoSubpixelIndicator { get; set; } = true; - - [YamlIgnore] - public bool InfoSubpixelIndicator { - get => _InfoSubpixelIndicator && Engine.Scene is Level; - set => _InfoSubpixelIndicator = value; - } - + public bool InfoSubpixelIndicator { get; set; } = true; public HudOptions InfoCustom { get; set; } = HudOptions.Off; public HudOptions InfoWatchEntity { get; set; } = HudOptions.Both; public WatchEntityType InfoWatchEntityType { get; set; } = WatchEntityType.Position; diff --git a/CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs b/CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs index 03c1a999..68484d1a 100644 --- a/CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs +++ b/CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs @@ -335,9 +335,8 @@ public static void Update(bool updateVel = false) { Classic.player player = emulator.game.objects.FirstOrDefault(o => o is Classic.player) as Classic.player; if (player != null) { stringBuilder.AppendLine($"Pos: {player.x}, {player.y}"); - stringBuilder.AppendLine($"Rem: {player.rem.ToSimpleString(3)}"); - stringBuilder.AppendLine($"Speed: {player.spd.ToSimpleString(3)}"); - + stringBuilder.AppendLine($"Rem: {player.rem.ToSimpleString(TasSettings.PositionDecimals)}"); + stringBuilder.AppendLine($"Speed: {player.spd.ToSimpleString(TasSettings.SpeedDecimals)}"); } stringBuilder.AppendLine($"Seed: {Pico8Fixer.Seed}");