From 6037be404c6e224aa3ebe5223245154ec6e5c695 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 4 Jan 2023 20:22:20 -0800 Subject: [PATCH] Fix bad LaserLok check --- BurnOutSharp/ProtectionType/LaserLok.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/BurnOutSharp/ProtectionType/LaserLok.cs b/BurnOutSharp/ProtectionType/LaserLok.cs index 1ddd64f8..b75ed3e8 100644 --- a/BurnOutSharp/ProtectionType/LaserLok.cs +++ b/BurnOutSharp/ProtectionType/LaserLok.cs @@ -5,7 +5,6 @@ using System.IO; using System.Linq; using BurnOutSharp.Interfaces; using BurnOutSharp.Matching; -using BurnOutSharp.Tools; using BurnOutSharp.Wrappers; namespace BurnOutSharp.ProtectionType @@ -93,6 +92,12 @@ namespace BurnOutSharp.ProtectionType }; containsCheck2 = pex.GetFirstSectionData(".text").FirstPosition(check2, out position2); } + else + { + // Otherwise, we reset the containsCheck2 value + containsCheck2 = false; + + } if (containsCheck && containsCheck2) return $"LaserLok {GetVersion(pex.GetFirstSectionData(".text"), position2)} {GetBuild(pex.GetFirstSectionData(".text"), true)} [Check disc for physical ring]" + (includeDebug ? $" (Index {position}, {position2})" : string.Empty); @@ -184,6 +189,10 @@ namespace BurnOutSharp.ProtectionType private static string GetVersion(byte[] sectionContent, int position) { + // If we have invalid data + if (sectionContent == null) + return null; + return new string(new ArraySegment(sectionContent, position + 76, 4).Select(b => (char)b).ToArray()); }