From f41fa753c99d814e26c8286c6a38c27a3bee533c Mon Sep 17 00:00:00 2001 From: pnwparksfan Date: Fri, 13 Dec 2024 00:20:30 -0800 Subject: [PATCH 1/5] Fixed pattern for CVehicle_AudVehicleAudioEntityOffset --- DLSv2/Utils/Game/SirenSounds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DLSv2/Utils/Game/SirenSounds.cs b/DLSv2/Utils/Game/SirenSounds.cs index 37be5ff..fea616f 100644 --- a/DLSv2/Utils/Game/SirenSounds.cs +++ b/DLSv2/Utils/Game/SirenSounds.cs @@ -25,7 +25,7 @@ public static void MemoryInit() InitAudSoundSet = Marshal.GetDelegateForFunctionPointer(address); } - address = Game.FindPattern("48 8B 8B ?? ?? 00 00 E8 ?? ?? ?? ?? 48 8B 8B 70 13 00 00"); + address = Game.FindPattern("48 8B 8B ?? ?? 00 00 E8 ?? ?? ?? ?? 48 8B 8B ?? 13 00 00"); if (Memory.AssertAddress(address, nameof(CVehicle_AudVehicleAudioEntityOffset))) { CVehicle_AudVehicleAudioEntityOffset = Marshal.ReadInt32(address + 3); From 7abafb66780227d07eb6c371ba5ea8d4ac154dd7 Mon Sep 17 00:00:00 2001 From: pnwparksfan Date: Fri, 13 Dec 2024 00:22:22 -0800 Subject: [PATCH 2/5] Updated version number --- DLSv2/Properties/AssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DLSv2/Properties/AssemblyInfo.cs b/DLSv2/Properties/AssemblyInfo.cs index 88c3ed3..d2562de 100644 --- a/DLSv2/Properties/AssemblyInfo.cs +++ b/DLSv2/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DLS")] -[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyCopyright("Copyright © 2024 TheMaybeast & PNWParksFan")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -14,5 +14,5 @@ [assembly: Guid("64295692-3277-4187-bccf-0af4cb1f9350")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.0.0.1")] +[assembly: AssemblyFileVersion("2.0.0.1")] \ No newline at end of file From e762b5141faad7d773bf8a733a6fa5950d06b9a4 Mon Sep 17 00:00:00 2001 From: pnwparksfan Date: Fri, 13 Dec 2024 00:23:39 -0800 Subject: [PATCH 3/5] Made pattern more future-proof --- DLSv2/Utils/Game/SirenSounds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DLSv2/Utils/Game/SirenSounds.cs b/DLSv2/Utils/Game/SirenSounds.cs index fea616f..449bb8d 100644 --- a/DLSv2/Utils/Game/SirenSounds.cs +++ b/DLSv2/Utils/Game/SirenSounds.cs @@ -25,7 +25,7 @@ public static void MemoryInit() InitAudSoundSet = Marshal.GetDelegateForFunctionPointer(address); } - address = Game.FindPattern("48 8B 8B ?? ?? 00 00 E8 ?? ?? ?? ?? 48 8B 8B ?? 13 00 00"); + address = Game.FindPattern("48 8B 8B ?? ?? 00 00 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? 00 00"); if (Memory.AssertAddress(address, nameof(CVehicle_AudVehicleAudioEntityOffset))) { CVehicle_AudVehicleAudioEntityOffset = Marshal.ReadInt32(address + 3); From 8284abbe89dfb0fe9bc187bd770a4d203836ab36 Mon Sep 17 00:00:00 2001 From: pnwparksfan Date: Sat, 14 Dec 2024 13:06:21 -0800 Subject: [PATCH 4/5] Fixed pattern further --- DLSv2/Utils/Game/SirenSounds.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DLSv2/Utils/Game/SirenSounds.cs b/DLSv2/Utils/Game/SirenSounds.cs index 449bb8d..8626516 100644 --- a/DLSv2/Utils/Game/SirenSounds.cs +++ b/DLSv2/Utils/Game/SirenSounds.cs @@ -24,8 +24,8 @@ public static void MemoryInit() { InitAudSoundSet = Marshal.GetDelegateForFunctionPointer(address); } - - address = Game.FindPattern("48 8B 8B ?? ?? 00 00 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? 00 00"); + + address = Game.FindPattern("48 8B 8B ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B D3"); if (Memory.AssertAddress(address, nameof(CVehicle_AudVehicleAudioEntityOffset))) { CVehicle_AudVehicleAudioEntityOffset = Marshal.ReadInt32(address + 3); From a1dd21259ffc151d82b9a503dd30255a9c0b0b73 Mon Sep 17 00:00:00 2001 From: pnwparksfan Date: Wed, 8 Jan 2025 00:27:01 -0800 Subject: [PATCH 5/5] Fixed crashes on startup for vehicles without default siren settings or when using SSLA with <32 sirens on the default siren settings --- DLSv2/Properties/AssemblyInfo.cs | 6 +- DLSv2/Utils/DLSExtensions.cs | 118 +++++++++++++++++-------------- 2 files changed, 68 insertions(+), 56 deletions(-) diff --git a/DLSv2/Properties/AssemblyInfo.cs b/DLSv2/Properties/AssemblyInfo.cs index d2562de..8b3daa7 100644 --- a/DLSv2/Properties/AssemblyInfo.cs +++ b/DLSv2/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DLS")] -[assembly: AssemblyCopyright("Copyright © 2024 TheMaybeast & PNWParksFan")] +[assembly: AssemblyCopyright("Copyright © 2025 TheMaybeast & PNWParksFan")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -14,5 +14,5 @@ [assembly: Guid("64295692-3277-4187-bccf-0af4cb1f9350")] -[assembly: AssemblyVersion("2.0.0.1")] -[assembly: AssemblyFileVersion("2.0.0.1")] \ No newline at end of file +[assembly: AssemblyVersion("2.0.0.2")] +[assembly: AssemblyFileVersion("2.0.0.2")] \ No newline at end of file diff --git a/DLSv2/Utils/DLSExtensions.cs b/DLSv2/Utils/DLSExtensions.cs index 46b7fdc..b1a2fb0 100644 --- a/DLSv2/Utils/DLSExtensions.cs +++ b/DLSv2/Utils/DLSExtensions.cs @@ -46,9 +46,13 @@ public static LightMode GetEmptyMode(this Vehicle veh) }; } + private static EmergencyLighting blankEL = EmergencyLighting.GetByName("DLS_EMPTY_LIGHTING_DO_NOT_EDIT") ?? new EmergencyLighting() { Name = "DLS_EMPTY_LIGHTING_DO_NOT_EDIT" }; + internal static SirenSetting GetDefaultSirenSetting(this Vehicle veh) { - var defaultEl = veh.DefaultEmergencyLighting; + // Use a blank EmergencyLighting instance if the vehicle does not have a default + var defaultEl = veh.DefaultEmergencyLighting ?? blankEL; + return new SirenSetting() { TimeMultiplier = defaultEl.TimeMultiplier, @@ -69,52 +73,60 @@ internal static SirenSetting GetDefaultSirenSetting(this Vehicle veh) RightTailLightSequencer = new SequencerWrapper(defaultEl.RightTailLightSequence), RightTailLightMultiples = defaultEl.RightTailLightMultiples, - Sirens = Enumerable.Range(0, EmergencyLighting.MaxLights).Select(i => new SirenEntry(i + 1) - { - // Main Light Settings - LightColor = defaultEl.Lights[i].Color, - Intensity = defaultEl.Lights[i].Intensity, - LightGroup = defaultEl.Lights[i].LightGroup, - Rotate = defaultEl.Lights[i].Rotate, - Scale = defaultEl.Lights[i].Scale, - ScaleFactor = defaultEl.Lights[i].ScaleFactor, - Flash = defaultEl.Lights[i].Flash, - SpotLight = defaultEl.Lights[i].SpotLight, - CastShadows = defaultEl.Lights[i].CastShadows, - Light = defaultEl.Lights[i].Light, - - // Rotation Settings - Rotation = new LightDetailEntry() - { - DeltaDeg = defaultEl.Lights[i].RotationDelta, - StartDeg = defaultEl.Lights[i].RotationStart, - Speed = defaultEl.Lights[i].RotationSpeed, - Sequence = new Sequencer(defaultEl.Lights[i].RotationSequence), - Multiples = defaultEl.Lights[i].RotationMultiples, - Direction = defaultEl.Lights[i].RotationDirection, - SyncToBPM = defaultEl.Lights[i].RotationSynchronizeToBpm - }, - - // Flashiness Settings - Flashiness = new LightDetailEntry + Sirens = Enumerable.Range(0, EmergencyLighting.MaxLights).Select(i => { + + // Copy settings from default for all sirens that exist on the setting, and pull in + // blank entries for any that don't (which can happen for built-in siren settings that + // have only 20 entries even if SSLA is installed) + var light = (i < defaultEl.Lights.Length) ? defaultEl.Lights[i] : blankEL.Lights[0]; + + return new SirenEntry(i + 1) { - DeltaDeg = defaultEl.Lights[i].FlashinessDelta, - StartDeg = defaultEl.Lights[i].FlashinessStart, - Speed = defaultEl.Lights[i].FlashinessSpeed, - Sequence = new Sequencer(defaultEl.Lights[i].FlashinessSequence), - Multiples = defaultEl.Lights[i].FlashinessMultiples, - Direction = defaultEl.Lights[i].FlashinessDirection, - SyncToBPM = defaultEl.Lights[i].FlashinessSynchronizeToBpm - }, - - // Corona Settings - Corona = new CoronaEntry() - { - CoronaIntensity = defaultEl.Lights[i].CoronaIntensity, - CoronaSize = defaultEl.Lights[i].CoronaSize, - CoronaPull = defaultEl.Lights[i].CoronaPull, - CoronaFaceCamera = defaultEl.Lights[i].CoronaFaceCamera, - } + // Main Light Settings + LightColor = light.Color, + Intensity = light.Intensity, + LightGroup = light.LightGroup, + Rotate = light.Rotate, + Scale = light.Scale, + ScaleFactor = light.ScaleFactor, + Flash = light.Flash, + SpotLight = light.SpotLight, + CastShadows = light.CastShadows, + Light = light.Light, + + // Rotation Settings + Rotation = new LightDetailEntry() + { + DeltaDeg = light.RotationDelta, + StartDeg = light.RotationStart, + Speed = light.RotationSpeed, + Sequence = new Sequencer(light.RotationSequence), + Multiples = light.RotationMultiples, + Direction = light.RotationDirection, + SyncToBPM = light.RotationSynchronizeToBpm + }, + + // Flashiness Settings + Flashiness = new LightDetailEntry + { + DeltaDeg = light.FlashinessDelta, + StartDeg = light.FlashinessStart, + Speed = light.FlashinessSpeed, + Sequence = new Sequencer(light.FlashinessSequence), + Multiples = light.FlashinessMultiples, + Direction = light.FlashinessDirection, + SyncToBPM = light.FlashinessSynchronizeToBpm + }, + + // Corona Settings + Corona = new CoronaEntry() + { + CoronaIntensity = light.CoronaIntensity, + CoronaSize = light.CoronaSize, + CoronaPull = light.CoronaPull, + CoronaFaceCamera = light.CoronaFaceCamera, + } + }; }).ToArray() }; } @@ -140,16 +152,16 @@ public static void ApplyLightModes(this ManagedVehicle managedVehicle, List