diff --git a/OmsiExtensionsCLI/Program.cs b/OmsiExtensionsCLI/Program.cs index 37e6eb8..fba38fc 100644 --- a/OmsiExtensionsCLI/Program.cs +++ b/OmsiExtensionsCLI/Program.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using OmsiHook; +using System.Threading.Tasks; namespace OmsiExtensionsCLI { @@ -11,22 +12,31 @@ static void Main(string[] args) Console.WriteLine("#=#=#=#=#=# OmsiExtensions Testing #=#=#=#=#=#"); OmsiHook.OmsiHook omsi = new(); - omsi.AttachToOMSI(); + Task.WaitAll(omsi.AttachToOMSI()); + Console.Clear(); while (true) { var pos = omsi.PlayerVehicle.Position; + var posa = omsi.PlayerVehicle.AbsPosition; + var vel = omsi.PlayerVehicle.Velocity; var map = omsi.Map; var weather = omsi.Weather; var tickets = omsi.TicketPack; - Console.WriteLine($"Read data: x:{pos.x:F3}\ty:{pos.y:F3}\tz:{pos.z:F3}\t\t" + - $"tile:{0}\trow45:{0:F3}\trow47:{0:F3}"); + Console.SetCursorPosition(0, 0); + Console.WriteLine(($"Read data: x:{pos.x:F3} y:{pos.y:F3} z:{pos.z:F3} " + + $"tile:{omsi.PlayerVehicle.Kachel}").PadRight(Console.WindowWidth - 1)); + Console.WriteLine($"Read data: vx:{vel.x:F3} vy:{vel.y:F3} vz:{vel.z:F3}".PadRight(Console.WindowWidth-1)); + Console.WriteLine($"Read data: ax:{posa._30:F3} ay:{posa._31:F3} az:{posa._32:F3}".PadRight(Console.WindowWidth-1)); - Console.WriteLine($"Read data: map:{map.Name}\tpath:{map.Filename}\tfriendly:{map.FriendlyName}"); - Console.WriteLine($"Read data: act w name:{weather.ActWeather.name}"); + Console.WriteLine($"Read data: map:{map.Name} path:{map.Filename} friendly:{map.FriendlyName}".PadRight(Console.WindowWidth-1)); + Console.WriteLine($"{omsi.PlayerVehicle.PAI_LastBrake} {omsi.PlayerVehicle.Bremspedal}".PadRight(Console.WindowWidth - 1)); + Console.WriteLine("".PadRight(Console.WindowWidth-1)); + //omsi.PlayerVehicle.Velocity = new D3DVector { x=0, y=0, z=5 }; + //omsi.PlayerVehicle.Bremspedal = 0; - Thread.Sleep(500); + Thread.Sleep(50); } } } diff --git a/OmsiExtensionsCLI/Properties/launchSettings.json b/OmsiExtensionsCLI/Properties/launchSettings.json index 4b3b934..82d6650 100644 --- a/OmsiExtensionsCLI/Properties/launchSettings.json +++ b/OmsiExtensionsCLI/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "OmsiExtensionsCLI": { "commandName": "Project", - "nativeDebugging": true + "nativeDebugging": false } } } \ No newline at end of file diff --git a/OmsiHook/OmsiHook.cs b/OmsiHook/OmsiHook.cs index 196c980..d5acd5e 100644 --- a/OmsiHook/OmsiHook.cs +++ b/OmsiHook/OmsiHook.cs @@ -28,7 +28,7 @@ public class OmsiHook /// Attaches the hooking application to OMSI.exe. /// Always call this at some point before trying to read and write data. /// - public async void AttachToOMSI() + public async Task AttachToOMSI() { Console.WriteLine("Attaching to OMSI.exe..."); diff --git a/OmsiHook/OmsiHook.csproj b/OmsiHook/OmsiHook.csproj index 9410771..edaf645 100644 --- a/OmsiHook/OmsiHook.csproj +++ b/OmsiHook/OmsiHook.csproj @@ -12,7 +12,7 @@ false 1.0.1.0 1.0.1.0 - 1.3.0 + 1.4.0 LGPL-3.0-only False README.md diff --git a/OmsiHook/OmsiMap.cs b/OmsiHook/OmsiMap.cs index f4c6c27..a99a66c 100644 --- a/OmsiHook/OmsiMap.cs +++ b/OmsiHook/OmsiMap.cs @@ -5,7 +5,7 @@ namespace OmsiHook public class OmsiMap : OmsiObject { internal OmsiMap(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiMap() : base() { } + public OmsiMap() : base() { } public OmsiPoint NW_Corner { diff --git a/OmsiHook/OmsiMapObjInst.cs b/OmsiHook/OmsiMapObjInst.cs index 38f3333..ed999d7 100644 --- a/OmsiHook/OmsiMapObjInst.cs +++ b/OmsiHook/OmsiMapObjInst.cs @@ -3,27 +3,28 @@ public class OmsiMapObjInst : OmsiObject { internal OmsiMapObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiMapObjInst() : base() { } + public OmsiMapObjInst() : base() { } public D3DVector Position { get => Memory.ReadMemory(Address + 0x4); set => Memory.WriteMemory(Address + 0x4, value); } - public D3DMatrix Pos_Mat { get => Memory.ReadMemory(Address + 0x10); set => Memory.WriteMemory(Address + 0x10, value); } - - public D3DXQuaternion Rotation => Memory.ReadMemory(Address + 0x50); + public D3DXQuaternion Rotation + { + get => Memory.ReadMemory(Address + 0x50); + set => Memory.WriteMemory(Address + 0x50, value); + } public float Scale { get => Memory.ReadMemory(Address + 0x60); set => Memory.WriteMemory(Address + 0x60, value); } - public D3DMatrix RelMatrix => Memory.ReadMemory(Address + 0x64); public D3DMatrix Used_RelVec => Memory.ReadMemory(Address + 0x68); public int Kachel @@ -31,13 +32,11 @@ public int Kachel get => Memory.ReadMemory(Address + 0x74); set => Memory.WriteMemory(Address + 0x74, value); } - public D3DMatrix AbsPosition { get => Memory.ReadMemory(Address + 0x78); set => Memory.WriteMemory(Address + 0x78, value); } - public D3DMatrix AbsPosition_Inv => Memory.ReadMemory(Address + 0xb8); public D3DMatrix AbsPosition_ThreadFree => Memory.ReadMemory(Address + 0xf8); } diff --git a/OmsiHook/OmsiMovingMapObjInst.cs b/OmsiHook/OmsiMovingMapObjInst.cs index 9bb9265..4e83d76 100644 --- a/OmsiHook/OmsiMovingMapObjInst.cs +++ b/OmsiHook/OmsiMovingMapObjInst.cs @@ -3,6 +3,6 @@ public class OmsiMovingMapObjInst : OmsiComplMapObjInst { internal OmsiMovingMapObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiMovingMapObjInst() : base() { } + public OmsiMovingMapObjInst() : base() { } } } \ No newline at end of file diff --git a/OmsiHook/OmsiPartikel.cs b/OmsiHook/OmsiPartikel.cs index f6184c9..b05d2b8 100644 --- a/OmsiHook/OmsiPartikel.cs +++ b/OmsiHook/OmsiPartikel.cs @@ -18,7 +18,7 @@ public D3DVector Veloc set => Memory.WriteMemory(Address + 0x10, value); } /// - /// Birthday? + /// Birth time /// public uint Geburtsdatum { @@ -26,7 +26,7 @@ public uint Geburtsdatum set => Memory.WriteMemory(Address + 0x1c, value); } /// - /// Death Day? + /// Death time /// public uint Sterbedatum { @@ -114,6 +114,5 @@ public float TempAlpha get => Memory.ReadMemory(Address + 0x58); set => Memory.WriteMemory(Address + 0x58, value); } - } } diff --git a/OmsiHook/OmsiPartikelemitter.cs b/OmsiHook/OmsiPartikelemitter.cs index 5d1e228..0c7e481 100644 --- a/OmsiHook/OmsiPartikelemitter.cs +++ b/OmsiHook/OmsiPartikelemitter.cs @@ -106,11 +106,7 @@ public bool Spotlight_Calc get => Memory.ReadMemory(Address + 0x60); set => Memory.WriteMemory(Address + 0x60, value); } - public OmsiPartikel[] Partikel - { - get => Memory.ReadMemoryObjArray(Address + 0x64); - //set => omsiMemory.WriteMemory(baseAddress + 0x64, value); - } + public OmsiPartikel[] Partikel => Memory.ReadMemoryObjArray(Address + 0x64); public int Textur { get => Memory.ReadMemory(Address + 0x68); @@ -121,6 +117,5 @@ public D3DVector Position get => Memory.ReadMemory(Address + 0x6c); set => Memory.WriteMemory(Address + 0x6c, value); } - } } diff --git a/OmsiHook/OmsiPassengerCabin.cs b/OmsiHook/OmsiPassengerCabin.cs index 3676891..32d2593 100644 --- a/OmsiHook/OmsiPassengerCabin.cs +++ b/OmsiHook/OmsiPassengerCabin.cs @@ -3,24 +3,18 @@ public class OmsiPassengerCabin : OmsiObject { internal OmsiPassengerCabin(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiPassengerCabin() : base() { } + public OmsiPassengerCabin() : base() { } public OmsiSeat[] Seats { get => Memory.ReadMemoryStructArray(Address + 0x4); } - public OmsiPathPoint[] Entries - { - get => Memory.ReadMemoryObjArray(Address + 0x8); - } + public OmsiPathPoint[] Entries => Memory.ReadMemoryObjArray(Address + 0x8); public OmsiEntryProp[] EntriesProp { get => Memory.ReadMemoryStructArray(Address + 0xc); } - public OmsiPathPoint[] Exits - { - get => Memory.ReadMemoryObjArray(Address + 0x10); - } + public OmsiPathPoint[] Exits => Memory.ReadMemoryObjArray(Address + 0x10); public OmsiPassCabinStamper Stamper { get => Memory.ReadMemory(Address + 0x14); @@ -30,9 +24,6 @@ public OmsiPassCabinTicketSale TicketSale get => Memory.MarshalStruct( Memory.ReadMemory(Address + 0x28)); } - public OmsiPathPoint[] LinkToOtherVehicle - { - get => Memory.ReadMemoryObjArray(Address + 0x7c); - } + public OmsiPathPoint[] LinkToOtherVehicle => Memory.ReadMemoryObjArray(Address + 0x7c); } } \ No newline at end of file diff --git a/OmsiHook/OmsiPathManager.cs b/OmsiHook/OmsiPathManager.cs index b3e1cd1..b49d165 100644 --- a/OmsiHook/OmsiPathManager.cs +++ b/OmsiHook/OmsiPathManager.cs @@ -3,7 +3,7 @@ public class OmsiPathManager : OmsiObject { internal OmsiPathManager(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiPathManager() : base() { } + public OmsiPathManager() : base() { } public int StepSoundPacks { diff --git a/OmsiHook/OmsiPathPoint.cs b/OmsiHook/OmsiPathPoint.cs index 44eb5e2..35154c3 100644 --- a/OmsiHook/OmsiPathPoint.cs +++ b/OmsiHook/OmsiPathPoint.cs @@ -4,5 +4,7 @@ public class OmsiPathPoint : OmsiObject { internal OmsiPathPoint(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } public OmsiPathPoint() : base() { } + + //TODO: Complete OmsiPathPoint } } \ No newline at end of file diff --git a/OmsiHook/OmsiPhysObj.cs b/OmsiHook/OmsiPhysObj.cs index adde603..e6e6dbf 100644 --- a/OmsiHook/OmsiPhysObj.cs +++ b/OmsiHook/OmsiPhysObj.cs @@ -3,7 +3,7 @@ public class OmsiPhysObj : OmsiObject { internal OmsiPhysObj(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiPhysObj() : base() { } + public OmsiPhysObj() : base() { } public string FileName // ANSI String { diff --git a/OmsiHook/OmsiPhysObjInst.cs b/OmsiHook/OmsiPhysObjInst.cs index 8699570..137faa6 100644 --- a/OmsiHook/OmsiPhysObjInst.cs +++ b/OmsiHook/OmsiPhysObjInst.cs @@ -3,10 +3,10 @@ public class OmsiPhysObjInst : OmsiMapObjInst { internal OmsiPhysObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiPhysObjInst() : base() { } + public OmsiPhysObjInst() : base() { } /* - * Unimplemented fields: + * TODO:Unimplemented fields: * PdxBody PH_Body; 0x138 * PdxGeom PH_MainGeomTrafo; 0x13c * PdxGeom PH_MainGeom; 0x140 diff --git a/OmsiHook/OmsiRoadVehicle.cs b/OmsiHook/OmsiRoadVehicle.cs index 3fc14fe..0ff8070 100644 --- a/OmsiHook/OmsiRoadVehicle.cs +++ b/OmsiHook/OmsiRoadVehicle.cs @@ -4,12 +4,12 @@ public class OmsiRoadVehicle : OmsiVehicle { internal OmsiRoadVehicle(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } public OmsiRoadVehicle() : base() { } + /*public OMSIScriptVarIndizes ScriptVarIndizes { get => Memory.ReadMemory(Address + 0x2b8); set => Memory.WriteMemory(Address + 0x2b8, value); }*/ - public bool Show_Dialog { get => Memory.ReadMemory(Address + 0x500); diff --git a/OmsiHook/OmsiVehicleInst.cs b/OmsiHook/OmsiVehicleInst.cs index 5a9075d..92501a4 100644 --- a/OmsiHook/OmsiVehicleInst.cs +++ b/OmsiHook/OmsiVehicleInst.cs @@ -3,6 +3,223 @@ public class OmsiVehicleInst : OmsiMovingMapObjInst { internal OmsiVehicleInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { } - internal OmsiVehicleInst() : base() { } + public OmsiVehicleInst() : base() { } + + //TODO: + /*public OmsiCriticalSection CS_AI_BusStopData + { + get => Memory.ReadMemory(Address + 0x4f0); + set => Memory.WriteMemory(Address + 0x4f0, value); + }*/ + + /// + /// Last seat height + /// + public float LastSitzHgt + { + get => Memory.ReadMemory(Address + 0x510); + set => Memory.WriteMemory(Address + 0x510, value); + } + + /// + /// Last seat velocity + /// + public float LastSitzVeloc + { + get => Memory.ReadMemory(Address + 0x514); + set => Memory.WriteMemory(Address + 0x514, value); + } + + /// + /// Seat matrix + /// + public D3DMatrix SitzMatrix + { + get => Memory.ReadMemory(Address + 0x518); + set => Memory.WriteMemory(Address + 0x518, value); + } + + public D3DMatrix DriverMatrix + { + get => Memory.ReadMemory(Address + 0x558); + set => Memory.WriteMemory(Address + 0x558, value); + } + + public D3DVector HeadPos + { + get => Memory.ReadMemory(Address + 0x598); + set => Memory.WriteMemory(Address + 0x598, value); + } + + public D3DVector HeadVeloc + { + get => Memory.ReadMemory(Address + 0x5a4); + set => Memory.WriteMemory(Address + 0x5a4, value); + } + + public float CS_AI_BusStopData + { + get => Memory.ReadMemory(Address + 0x510); + set => Memory.WriteMemory(Address + 0x510, value); + } + + public OmsiCamera[] Cameras_Driver => Memory.ReadMemoryObjArray(Address + 0x5b0); + + public OmsiCamera[] Cameras_Pax => Memory.ReadMemoryObjArray(Address + 0x5b4); + + public OmsiCamera Camera_Driver => new(Memory, Memory.ReadMemory(Address + 0x5b8)); + + public OmsiCamera Camera_Pax => new(Memory, Memory.ReadMemory(Address + 0x5bc)); + + public int Act_Camera_Driver + { + get => Memory.ReadMemory(Address + 0x5c0); + set => Memory.WriteMemory(Address + 0x5c0, value); + } + + public int Act_Camera_Pax + { + get => Memory.ReadMemory(Address + 0x5c4); + set => Memory.WriteMemory(Address + 0x5c4, value); + } + + public float Rad_M_Ab + { + get => Memory.ReadMemory(Address + 0x5c8); + set => Memory.WriteMemory(Address + 0x5c8, value); + } + + public float Rad_N_Ab + { + get => Memory.ReadMemory(Address + 0x5cc); + set => Memory.WriteMemory(Address + 0x5cc, value); + } + + /// + /// Braking power + /// + public float Bremskraft + { + get => Memory.ReadMemory(Address + 0x5d0); + set => Memory.WriteMemory(Address + 0x5d0, value); + } + + public bool Amplify + { + get => Memory.ReadMemory(Address + 0x5d4); + set => Memory.WriteMemory(Address + 0x5d4, value); + } + + public bool Throttle_Pressed + { + get => Memory.ReadMemory(Address + 0x5d5); + set => Memory.WriteMemory(Address + 0x5d5, value); + } + + public bool WheelBackRunning + { + get => Memory.ReadMemory(Address + 0x5d6); + set => Memory.WriteMemory(Address + 0x5d6, value); + } + + public float MaxWert_Gas_O_Amplify + { + get => Memory.ReadMemory(Address + 0x5d8); + set => Memory.WriteMemory(Address + 0x5d8, value); + } + + public float Throttle + { + get => Memory.ReadMemory(Address + 0x5dc); + set => Memory.WriteMemory(Address + 0x5dc, value); + } + + /// + /// Brake pedal + /// + public float Bremspedal + { + get => Memory.ReadMemory(Address + 0x5e0); + set => Memory.WriteMemory(Address + 0x5e0, value); + } + + /// + /// Clutch + /// + public float Kupplung + { + get => Memory.ReadMemory(Address + 0x5e4); + set => Memory.WriteMemory(Address + 0x5e4, value); + } + + public float Microphone + { + get => Memory.ReadMemory(Address + 0x5e8); + set => Memory.WriteMemory(Address + 0x5e8, value); + } + + public float Radio + { + get => Memory.ReadMemory(Address + 0x5ec); + set => Memory.WriteMemory(Address + 0x5ec, value); + } + + public float PrecipRate + { + get => Memory.ReadMemory(Address + 0x5f0); + set => Memory.WriteMemory(Address + 0x5f0, value); + } + + public float DirtRate + { + get => Memory.ReadMemory(Address + 0x5f4); + set => Memory.WriteMemory(Address + 0x5f4, value); + } + + public float Dirt + { + get => Memory.ReadMemory(Address + 0x5f8); + set => Memory.WriteMemory(Address + 0x5f8, value); + } + + public float CabinAir_Temp + { + get => Memory.ReadMemory(Address + 0x5fc); + set => Memory.WriteMemory(Address + 0x5fc, value); + } + + public float CabinAir_RelHum + { + get => Memory.ReadMemory(Address + 0x600); + set => Memory.WriteMemory(Address + 0x600, value); + } + + public float CabinAir_AbsHum + { + get => Memory.ReadMemory(Address + 0x604); + set => Memory.WriteMemory(Address + 0x604, value); + } + + public D3DVector A_Trans + { + get => Memory.ReadMemory(Address + 0x608); + set => Memory.WriteMemory(Address + 0x608, value); + } + + public D3DVector A_Rot + { + get => Memory.ReadMemory(Address + 0x614); + set => Memory.WriteMemory(Address + 0x614, value); + } + + public OmsiCamera OutsideCamera => new(Memory, Memory.ReadMemory(Address + 0x620)); + + public bool PAI + { + get => Memory.ReadMemory(Address + 0x624); + set => Memory.WriteMemory(Address + 0x624, value); + } + + //TODO: A whole buch of AI fields and some other fields } } \ No newline at end of file diff --git a/OmsiHookPlugin/OmsiHookPlugin.cs b/OmsiHookPlugin/OmsiHookPlugin.cs index 80710db..aeaf11f 100644 --- a/OmsiHookPlugin/OmsiHookPlugin.cs +++ b/OmsiHookPlugin/OmsiHookPlugin.cs @@ -23,7 +23,7 @@ public static void PluginStart(IntPtr aOwner) Log("PluginStart()"); Log("Loading OmsiHook..."); hook = new(); - hook.AttachToOMSI(); + _ = hook.AttachToOMSI(); Log("Didn't crash!"); }