-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from space928/remote-method-fixes
Various bugfixes for remote methods and textures in local plugins: - OmsiRemoteMethods is no longer static and can be accessed through the instance of OmsiHook/Memory - Updated dependent classes to use the instance of OmsiRemoteMethods - D3DTexture implements IDisposable to prevent memory leaks - Memory and OmsiHook now implement IDisposable to tidy up resources - Implemented fast path for local plugins for all Memory read/write/allocate operations in Memory - Enabled unsafe compilation of OmsiHook to support fast path for Memory operations - Various other local plugin related bug fixes - Fixed dereferencing bug in OmsiCreateTextureAsync when using local plugins - Improved D3D hooking reliability - Implemented small test for D3DTexture usage in a local plugin - Updated DNNE - Added D3DTexture mipmap support - Added RPC method to get texture level count - Added a few null checks to the local plugin path for Memory Read/Write operations to prevent crashes - Fixed some bugs with MonitorStateTask (used for OmsiHook events) in local plugins - Disposing of OmsiRemoteMethods (which is done automatically when disposing of OmsiHook) now closes the RPC session correctly - CloseRPCSession() is now awaitable - Implemented MakeVehicle() and TempRVListCreate() - Added MemArray for TOList - Fixed some broken arrays in OmsiComplObj - Fixed an incorrectly parsed string in OmsiMap - Improved error reporting in Memory.cs - Improved safety/performance of some core methods in Memory.cs - Slightly improved the performance of string reading - Rewrote MarhsalStruct/UnMarshalStruct to make use of compiled Expression Trees to allow for much faster marshalling of data without the need for reflection every time. (A cached reflection based fallback has been implemented as well) - Fixed OmsiAmpelGroup marshalling - Fixed OmsiOFTTex marshalling - Some bugfixes to multiple sessions with OmsiHookRPCPlugin
- Loading branch information
Showing
30 changed files
with
2,760 additions
and
908 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmsiHook; | ||
|
||
internal static class FastBinaryWriter | ||
{ | ||
public static void Write(Span<byte> buffer, ref int pos, int data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 4; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, uint data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 4; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, short data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 2; | ||
} | ||
public static void Write(Span<byte> buffer, ref int pos, ushort data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 2; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, byte data, int advance = 1) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += advance; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, sbyte data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 1; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, bool data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 1; | ||
} | ||
|
||
public static void Write(Span<byte> buffer, ref int pos, float data) | ||
{ | ||
MemoryMarshal.Write(buffer[pos..], ref data); | ||
pos += 4; | ||
} | ||
|
||
public static void Write(byte[] buffer, ref int pos, int data) | ||
{ | ||
MemoryMarshal.Write(buffer.AsSpan()[pos..], ref data); | ||
pos += 4; | ||
} | ||
} |
Oops, something went wrong.