From 55bcfad283d778e3180d5746af44d9bb1c901e75 Mon Sep 17 00:00:00 2001 From: Thomas Mathieson Date: Wed, 25 Oct 2023 18:49:55 +0100 Subject: [PATCH] Fixed some minor issues raised by Adam & Improved builld system: - Relaxed target framework requirement - Fixed spelling - Added version number to docs (can't manage to get the automatic version number trtacking to work though...) - Updated copyright and version number - Restricted OmsiHook to x86 - Added dependency on OmsiHookRPCPlugin to OmsiHook - Refactored OmsiHookRPCMethods.cs - Other small build system changes --- OmsiExtensions.sln | 23 ++++++------ OmsiExtensionsCLI/OmsiExtensionsCLI.csproj | 2 +- OmsiHook/OmsiHook.csproj | 35 +++++++++++++++---- OmsiHook/OmsiHookRPCMethods.cs | 13 +++++-- OmsiHook/OmsiRemoteMethods.cs | 15 ++++---- OmsiHook/articles/performance-tips.md | 2 +- OmsiHook/docfx.json | 9 +++-- .../singulinkfx/partials/navbar.tmpl.partial | 1 + .../templates/singulinkfx/styles/main.css | 5 +++ OmsiHookRPCPlugin/OmsiHookRPCPlugin.cs | 9 ----- OmsiHookRPCPlugin/OmsiHookRPCPlugin.csproj | 18 +++++++--- 11 files changed, 87 insertions(+), 45 deletions(-) diff --git a/OmsiExtensions.sln b/OmsiExtensions.sln index c429624..c6129e3 100644 --- a/OmsiExtensions.sln +++ b/OmsiExtensions.sln @@ -25,18 +25,16 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.ActiveCfg = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.Build.0 = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.Build.0 = Debug|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.Build.0 = Release|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x64.ActiveCfg = Release|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x64.Build.0 = Release|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.ActiveCfg = Release|Any CPU - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.Build.0 = Release|Any CPU + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.Build.0 = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.ActiveCfg = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.Build.0 = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.ActiveCfg = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.Build.0 = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.ActiveCfg = Release|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.Build.0 = Release|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x64.ActiveCfg = Release|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.ActiveCfg = Release|x86 {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -90,6 +88,7 @@ Global {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.ActiveCfg = Debug|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.Build.0 = Debug|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.ActiveCfg = Release|x86 + {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.Build.0 = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x64.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.Build.0 = Release|x86 diff --git a/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj b/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj index a04e301..72d3e46 100644 --- a/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj +++ b/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj @@ -2,7 +2,7 @@ Exe - net6.0-windows10.0.17763.0 + net6.0-windows diff --git a/OmsiHook/OmsiHook.csproj b/OmsiHook/OmsiHook.csproj index 0c7d05b..3708a89 100644 --- a/OmsiHook/OmsiHook.csproj +++ b/OmsiHook/OmsiHook.csproj @@ -3,16 +3,16 @@ net6.0-windows Thomas Mathieson et al - Copyright Thomas Mathieson 2022 all rights reserved + Copyright Thomas Mathieson 2023 all rights reserved https://github.com/space928/Omsi-Extensions https://github.com/space928/Omsi-Extensions OmsiHook is a simple library for hooking into Omsi's memory for modding. true false - 2.1.0.1 - 2.1.0.1 - 2.1.0 + 2.2.0.1 + 2.2.0.1 + 2.2.0 LGPL-3.0-only False README.md @@ -20,9 +20,10 @@ true snupkg disable + x86 - + @@ -34,14 +35,33 @@ True \ - + PreserveNewest True - \lib\net5.0 + \lib\net6.0 + + PreserveNewest + True + \lib\net6.0 + + + PreserveNewest + True + \lib\net6.0 + + + PreserveNewest + True + \lib\net6.0 + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -53,6 +73,7 @@ false + diff --git a/OmsiHook/OmsiHookRPCMethods.cs b/OmsiHook/OmsiHookRPCMethods.cs index 9d3a6ba..a9a9a91 100644 --- a/OmsiHook/OmsiHookRPCMethods.cs +++ b/OmsiHook/OmsiHookRPCMethods.cs @@ -4,12 +4,12 @@ namespace OmsiHookRPCPlugin { - public static class OmsiHookRPCMethods + internal static class OmsiHookRPCMethods { public const string PIPE_NAME = @"OmsiHookRPCPipe"; [SuppressMessage("ReSharper", "InconsistentNaming")] - public enum RemoteMethod : int + internal enum RemoteMethod : int { TProgManMakeVehicle, TTempRVListCreate, @@ -17,5 +17,14 @@ public enum RemoteMethod : int GetMem, FreeMem } + + internal static readonly ReadOnlyDictionary RemoteMethodsArgsSizes = new(new Dictionary() + { + { RemoteMethod.TProgManMakeVehicle, 61 }, + { RemoteMethod.TTempRVListCreate, 8 }, + { RemoteMethod.TProgManPlaceRandomBus, 35 }, + { RemoteMethod.GetMem, 4 }, + { RemoteMethod.FreeMem, 4 }, + }); } } diff --git a/OmsiHook/OmsiRemoteMethods.cs b/OmsiHook/OmsiRemoteMethods.cs index d67be98..3acb886 100644 --- a/OmsiHook/OmsiRemoteMethods.cs +++ b/OmsiHook/OmsiRemoteMethods.cs @@ -71,9 +71,10 @@ public static int PlaceRandomBus(int aiType = 0, int group = 1, int type = -1, b return TProgManPlaceRandomBus(memory.ReadMemory(0x00862f28), aiType, group, 0, false, true, type, scheduled, 0, tour, line); #else int argPos = 0; - Span writeBuffer = stackalloc byte[39]; + var method = OmsiHookRPCMethods.RemoteMethod.TProgManPlaceRandomBus; + Span writeBuffer = stackalloc byte[OmsiHookRPCMethods.RemoteMethodsArgsSizes[method]+4]; Span readBuffer = stackalloc byte[4]; - BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)OmsiHookRPCMethods.RemoteMethod.TProgManPlaceRandomBus); + BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)method); BitConverter.TryWriteBytes(writeBuffer[(argPos += 4)..], aiType); BitConverter.TryWriteBytes(writeBuffer[(argPos += 4)..], group); BitConverter.TryWriteBytes(writeBuffer[(argPos += 4)..], 0); @@ -104,9 +105,10 @@ public static int OmsiGetMem(int length) return GetMem(length); #else int argPos = 0; - Span writeBuffer = stackalloc byte[8]; + var method = OmsiHookRPCMethods.RemoteMethod.GetMem; + Span writeBuffer = stackalloc byte[OmsiHookRPCMethods.RemoteMethodsArgsSizes[method]+4]; Span readBuffer = stackalloc byte[4]; - BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)OmsiHookRPCMethods.RemoteMethod.GetMem); + BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)method); BitConverter.TryWriteBytes(writeBuffer[(argPos += 4)..], length); pipe.Write(writeBuffer); pipe.Read(readBuffer); @@ -125,9 +127,10 @@ public static void OmsiFreeMem(int addr) FreeMem(addr); #else int argPos = 0; - Span writeBuffer = stackalloc byte[8]; + var method = OmsiHookRPCMethods.RemoteMethod.FreeMem; + Span writeBuffer = stackalloc byte[OmsiHookRPCMethods.RemoteMethodsArgsSizes[method] + 4]; Span readBuffer = stackalloc byte[4]; - BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)OmsiHookRPCMethods.RemoteMethod.FreeMem); + BitConverter.TryWriteBytes(writeBuffer[(argPos)..], (int)method); BitConverter.TryWriteBytes(writeBuffer[(argPos += 4)..], addr); pipe.Write(writeBuffer); pipe.Read(readBuffer); diff --git a/OmsiHook/articles/performance-tips.md b/OmsiHook/articles/performance-tips.md index a3fd772..b6578e7 100644 --- a/OmsiHook/articles/performance-tips.md +++ b/OmsiHook/articles/performance-tips.md @@ -61,7 +61,7 @@ cached or not. OmsiHook allows you to call remote methods in Omsi, this is a fairly complicated process and as such isn't always very fast. For native Omsi plugins using OmsiHook you don't need to worry much about the performance of remote calls, but for external applications using OmsiHook, these calls are especially -expensive. This is because in this case OmsiHook needs to relty on OmsiHookRPCPlugin, a native Omsi +expensive. This is because in this case OmsiHook needs to rely on OmsiHookRPCPlugin, a native Omsi plugin shipped with OmsiHook which executes remote calls on the behalf of OmsiHook in batches, once per frame. As such, for external applications, remote calls will *always* take at least 1 frame to complete. diff --git a/OmsiHook/docfx.json b/OmsiHook/docfx.json index 533063a..8a9de16 100644 --- a/OmsiHook/docfx.json +++ b/OmsiHook/docfx.json @@ -11,7 +11,9 @@ ], "dest": "api", "disableGitFeatures": true, - "disableDefaultFilter": false + "disableDefaultFilter": false, + "memberLayout": "samePage", + "enumSortOrder": "declaringOrder" } ], "build": { @@ -21,12 +23,13 @@ "_appFaviconPath": "images/favicon.ico", "_appLogoPath": "images/logo.svg", "_appFooter": "DocFX + OmsiHook = ♥", - "_copyrightFooter": "© Thomas/Adam Mathieson. All rights reserved.", + "_copyrightFooter": "© Thomas/Adam Mathieson 2023. All rights reserved.", "_enableSearch": true, "_disableSideFilter": false, "_enableNewTab": true, "_disableContribution": true, - "_disableBreadcrumb": false + "_disableBreadcrumb": false, + "_DocumentationVersion": "2.2.0" }, "content": [ { diff --git a/OmsiHook/templates/singulinkfx/partials/navbar.tmpl.partial b/OmsiHook/templates/singulinkfx/partials/navbar.tmpl.partial index cfddfd8..e80f9bb 100644 --- a/OmsiHook/templates/singulinkfx/partials/navbar.tmpl.partial +++ b/OmsiHook/templates/singulinkfx/partials/navbar.tmpl.partial @@ -7,6 +7,7 @@ {{#_enableSearch}}
+ Version {{{_DocumentationVersion}}}