Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OmsiExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TriggersSample", "_OmsiHook
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoDemo", "_OmsiHookExamples\VideoDemo\VideoDemo.csproj", "{D94FF6D3-08AA-41CB-B9B9-F82E860E6E96}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClickablePlaneDemo", "_OmsiHookExamples\ClickablePlaneDemo\ClickablePlaneDemo.csproj", "{49428923-732C-4541-8C97-C6D9C004D726}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClickablePlaneDemo", "_OmsiHookExamples\ClickablePlaneDemo\ClickablePlaneDemo.csproj", "{49428923-732C-4541-8C97-C6D9C004D726}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -97,8 +97,8 @@ Global
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|Any CPU.Build.0 = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.ActiveCfg = Release|Win32
{CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.Build.0 = Release|Win32
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.ActiveCfg = Debug|x86
{CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.Build.0 = Debug|x86
{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|Any CPU
Expand Down
1 change: 1 addition & 0 deletions OmsiHook/MemArray/MemArrayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public virtual void Dispose()
// TODO: Free the old array
//Memory.Free(Memory.ReadMemory<int>(Address));
// Remove references from current array. TODO: Does this work? Is this safe?
// https://github.com/space928/Omsi-Extensions/issues/109
Memory.WriteMemory(Memory.ReadMemory<int>(Address) - 8, 0);
Memory.WriteMemory(Address, Memory.AllocateStructArray<int>(0, 0).Result);

Expand Down
2 changes: 2 additions & 0 deletions OmsiHook/MemArray/MemArrayObjList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public override T this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<T> GetEnumerator() => ((IEnumerable<T>)WrappedArray).GetEnumerator();
Expand Down Expand Up @@ -207,6 +208,7 @@ public override T this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<T> GetEnumerator() => ((IEnumerable<T>)WrappedArray).GetEnumerator();
Expand Down
3 changes: 2 additions & 1 deletion OmsiHook/MemArray/MemArrayString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override string this[int index]
{
if (cached)
arrayCache[index] = value;
Memory.WriteMemoryArrayItemSafe(Address, Memory.AllocateString(value).Result, index);
Memory.WriteMemoryArrayItemSafe(Address, Memory.AllocateString(value, wide).Result, index);
}
}

Expand Down Expand Up @@ -119,6 +119,7 @@ public override void Clear()
public override void CopyTo(string[] array, int arrayIndex) => WrappedArray.CopyTo(array, arrayIndex);

//TODO: Implement efficient enumerator for non-cached arrays.
// https://github.com/space928/Omsi-Extensions/issues/110
public override IEnumerator<string> GetEnumerator() => (IEnumerator<string>)WrappedArray.GetEnumerator();

public override int IndexOf(string item) => Array.IndexOf(WrappedArray, item);
Expand Down
1 change: 1 addition & 0 deletions OmsiHook/MemArray/MemArrayStringList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public override string this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<string> GetEnumerator() => ((IEnumerable<string>)WrappedArray).GetEnumerator();
Expand Down
1 change: 1 addition & 0 deletions OmsiHook/MemArray/MemArrayStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public override Struct this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<Struct> GetEnumerator() => ((IEnumerable<Struct>)WrappedArray).GetEnumerator();
Expand Down
2 changes: 2 additions & 0 deletions OmsiHook/MemArray/MemArrayStructList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public override Struct this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<Struct> GetEnumerator() => ((IEnumerable<Struct>)WrappedArray).GetEnumerator();
Expand Down Expand Up @@ -206,6 +207,7 @@ public override Struct this[int index]

/// <summary>
/// TODO: Implement efficient enumerator for non-cached arrays.
/// https://github.com/space928/Omsi-Extensions/issues/110
/// </summary>
/// <returns></returns>
public override IEnumerator<Struct> GetEnumerator() => ((IEnumerable<Struct>)WrappedArray).GetEnumerator();
Expand Down
1 change: 1 addition & 0 deletions OmsiHook/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ public string ReadMemoryString(int address, bool wide = false, bool raw = false,
var readBuff = readBuffer.Value;
//int readSize = 16;
// TODO: Rewrite this to read chunks of memory all at once instead of one char at a time...
// https://github.com/space928/Omsi-Extensions/issues/111
while (true)
{
var bytes = ReadMemory(i, wide ? 2 : 1, readBuff);
Expand Down
1 change: 1 addition & 0 deletions OmsiHook/OmsiHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private void OmsiHook_OnOmsiGotD3DContext(object sender, EventArgs e)
public OmsiRoadVehicleInst GetRoadVehicleInst(int index)
{
// TODO: A More permanant fix should be done at some point.
//https://github.com/space928/Omsi-Extensions/issues/112
var vehPtr = GetListItem(0x00861508, index);
return vehPtr < 1000 ? null : new OmsiRoadVehicleInst(omsiMemory, vehPtr);
}
Expand Down
2 changes: 1 addition & 1 deletion OmsiHook/OmsiHook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>2.5.3.1</AssemblyVersion>
<FileVersion>2.5.3.1</FileVersion>
<Version>2.5.3</Version>
<Version>2.5.4</Version>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<SignAssembly>False</SignAssembly>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
3 changes: 2 additions & 1 deletion OmsiHook/OmsiRemoteMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ private void ResultReaderTask()
}
} catch
{
// TODO: This shouldn't really fail silently if it isn't meant to
// TODO: This shouldn't really fail silently if it isn't meant to
// but closing the RPC session results in ReadInt32 throwing
// an exception, so we should catch that...
// https://github.com/space928/Omsi-Extensions/issues/113
}
}

Expand Down
12 changes: 9 additions & 3 deletions OmsiHook/OmsiStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public struct D3DMaterial9
public struct D3DOBB
{
// TODO: Check Axis Data Type
// https://github.com/space928/Omsi-Extensions/issues/114
public int Axis;
public D3DVector Depth;
public D3DVector Center;
Expand Down Expand Up @@ -450,7 +451,6 @@ public struct OmsiTicketPack
[StructLayout(LayoutKind.Explicit, Size = 0x2c)]
internal struct OmsiTicketInternal
{
//TODO: I don't think these are decoding correctly (I saw nothing when I looked), check this actually works.
[FieldOffset(0x0)][OmsiStrPtr(StrPtrType.RawDelphiAnsiString)] public int name;
[FieldOffset(0x4)][OmsiStrPtr(StrPtrType.RawDelphiAnsiString)] public int name_english;
[FieldOffset(0x8)][OmsiStrPtr(StrPtrType.RawDelphiAnsiString)] public int name_display;
Expand Down Expand Up @@ -482,6 +482,7 @@ public struct OmsiSeat
public byte flag;
public float height;
public int getInteriorLights; // TODO: Check Data Type
// https://github.com/space928/Omsi-Extensions/issues/115
}
public struct OmsiEntryProp
{
Expand Down Expand Up @@ -554,11 +555,12 @@ public struct OmsiVector3Double
public struct OmsiAchseInstance
{
//TODO: Translate field names
public double phi; //TODO: Verify all double types
// https://github.com/space928/Omsi-Extensions/issues/116
public double phi; //TODO: Verify all double types // https://github.com/space928/Omsi-Extensions/issues/116
public float alpha;
public double drehzahl;
public double federung;
public OmsiVector3Double anpress; //TODO: Verify type
public OmsiVector3Double anpress; //TODO: Verify type // https://github.com/space928/Omsi-Extensions/issues/116
public float contact;
public float antrieb;
public double brems;
Expand Down Expand Up @@ -716,6 +718,7 @@ public struct OmsiPathBelegung
}

//TODO: Bug when dereferencing this
// https://github.com/space928/Omsi-Extensions/issues/117
[StructLayout(LayoutKind.Explicit, Size = 0x110)]
internal struct OmsiPathInfoInternal
{
Expand Down Expand Up @@ -878,6 +881,7 @@ public struct OmsiPathInfo

/// <summary>
/// Temporary struct to store unknown data type in OmsiPathInfo.nextPathSeg
/// https://github.com/space928/Omsi-Extensions/issues/118
/// </summary>
public struct OmsiNextPathSegment
{
Expand All @@ -886,6 +890,7 @@ public struct OmsiNextPathSegment

/// <summary>
/// Temporary struct to store unkown data type in OmsiPathInfo.nextPathID
/// https://github.com/space928/Omsi-Extensions/issues/118
/// </summary>
public struct OmsiNextPathID
{
Expand Down Expand Up @@ -1873,6 +1878,7 @@ internal struct OmsiRVFileInternal
[OmsiStruct(typeof(OmsiRVTypesLine), typeof(OmsiRVTypesLineInternal))] public int list_types_line;
}
/* TODO: Parse the pointers better to get the variables */
// https://github.com/space928/Omsi-Extensions/issues/119
public struct OmsiBoolClassCondiBool
{
/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions OmsiHook/ReflectionCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static ReflectionCache GetOrBuildReflectionCache(Memory mem, Type nativeT
/// <returns></returns>
/// <exception cref="FieldAccessException"></exception>
// TODO: Rewrite this to use IL generation to avoid unnecessary boxing...
// https://github.com/space928/Omsi-Extensions/issues/120
public static ReflectionCache BuildReflectionCache(Memory mem, Type nativeType, Type localType)
{
var ret = new ReflectionCache(nativeType, localType);
Expand Down Expand Up @@ -207,6 +208,7 @@ public static ReflectionCache BuildReflectionCache(Memory mem, Type nativeType,
map.toNative = val =>
{
// TODO: I might add a dedicated method for allocating string arrays
// https://github.com/space928/Omsi-Extensions/issues/121
var stringTasks = ((string[])val).Select(x => mem.AllocateString(x, a.Wide, 1, a.Raw));
var strings = Task.WhenAll(stringTasks);
return mem.AllocateAndInitStructArray(strings.Result).Result;
Expand Down Expand Up @@ -421,6 +423,7 @@ public static void Compile(Memory mem)
map.toNative = val =>
{
// TODO: I might add a dedicated method for allocating string arrays
// https://github.com/space928/Omsi-Extensions/issues/121
var stringTasks = ((string[])val).Select(x => mem.AllocateString(x, a.Wide, 1, a.Raw));
var strings = Task.WhenAll(stringTasks);
return mem.AllocateAndInitStructArray(strings.Result).Result;
Expand Down Expand Up @@ -730,6 +733,7 @@ private static string GetCustomAttributeDebugString(FieldInfo field)
private static int AllocateStrings(Memory mem, string[] val, bool wide, bool raw)
{
// TODO: I might add a dedicated method for allocating string arrays
// https://github.com/space928/Omsi-Extensions/issues/121
var stringTasks = val.Select(x => mem.AllocateString(x, wide, 1, raw));
var strings = Task.WhenAll(stringTasks);
return mem.AllocateAndInitStructArray(strings.Result).Result;
Expand Down
3 changes: 3 additions & 0 deletions OmsiHook/WrappedOmsiClasses/OmsiAnimSubMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public int AnimParent
//public MemArrayList<D3DMatrix> origin
//public MemArrayList<D3DMatrix> originI
//public MemArrayList<OmsiAnimation> anim
//https://github.com/space928/Omsi-Extensions/issues/123
public int Visible
{
get => Memory.ReadMemory<int>(Address + 0x1a4);
Expand All @@ -46,6 +47,7 @@ public int VisibleValue
//public MemArrayList<OmsiLampenSetting> LampenSettings
//public MemArrayList<OmsiInteriorLight> InteriorLights
//public MemArrayList<OmsiBoneProp> BoneProps
//https://github.com/space928/Omsi-Extensions/issues/123
public bool SmoothSkin
{
get => Memory.ReadMemory<bool>(Address + 0x1bc);
Expand All @@ -72,6 +74,7 @@ public byte Flag_GetLights
set => Memory.WriteMemory(Address + 0x1cc, value);
}
/* TODO:
* https://github.com/space928/Omsi-Extensions/issues/122
public int GetInteriorLights
{
get => Memory.ReadMemory<int>(Address + 0x1cd);
Expand Down
3 changes: 3 additions & 0 deletions OmsiHook/WrappedOmsiClasses/OmsiAnimSubMeshInst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal OmsiAnimSubMeshInst(Memory omsiMemory, int baseAddress) : base(omsiMemo
public OmsiAnimSubMeshInst() : base() { }

public D3DTransformObject ShadowObject // TODO: Should be a D3DShadowObject
// https://github.com/space928/Omsi-Extensions/issues/124
{
get => Memory.ReadMemoryObject<D3DTransformObject>(Address, 0x4);
}
Expand All @@ -37,6 +38,7 @@ public D3DMatrix LocalMatrix
set => Memory.WriteMemory(Address + 0x88, value);
}
/* TODO:
* https://github.com/space928/Omsi-Extensions/issues/123
public MemArrayList<OmsiMaterialProp> Matl
{
get => new(Memory, Address + 0xc8);
Expand All @@ -54,6 +56,7 @@ public bool Visible
// TODO: MemArrayList<OmsiLampe> Lampen @ 0xd4
// TODO: MemArrayList<OmsiInteriorLight> InteriorLights @ 0xd8
// TODO: MemArrayList<float> Anim_LastValue @ 0xdc
// https://github.com/space928/Omsi-Extensions/issues/123
public IntPtr SkinMesh // ID3DXMesh
{
get => Memory.ReadMemory<IntPtr>(Address + 0xe0);
Expand Down
2 changes: 2 additions & 0 deletions OmsiHook/WrappedOmsiClasses/OmsiCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ public D3DMatrix CamPntMatrix_Calc


// TODO: VFDPlane_Render - struct D3DXPlane[6] @ 0x229
//https://github.com/space928/Omsi-Extensions/issues/125
/*public D3DXPlane[] VFDPlane_Render
{
get => omsiMemory.ReadMemory<D3DXPlane[6]>(baseAddress + 0x229);
set => omsiMemory.WriteMemory(baseAddress + 0x229, value);
}*/
// TODO: VFDPlane_Calc - struct D3DXPlane[6] @ 0x289
//https://github.com/space928/Omsi-Extensions/issues/125
/*public D3DXPlane[] VFDPlane_Calc
{
get => omsiMemory.ReadMemory<D3DXPlane[6]>(baseAddress + 0x289);
Expand Down
6 changes: 4 additions & 2 deletions OmsiHook/WrappedOmsiClasses/OmsiChrono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ internal OmsiChrono(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseA
public OmsiChrono() : base() { }

/*
TODO: public Array? Timeline
TODO: public MemArray<TTimeLineEntry> Timeline
//https://github.com/space928/Omsi-Extensions/issues/126
{
get => omsiMemory.ReadMemory<Array?>(baseAddress + 0x4);
set => omsiMemory.WriteMemory(baseAddress + 0x4, value);
Expand All @@ -28,7 +29,8 @@ public bool Scenario_Changed
}

/*
TODO: public Array? Scenarios
TODO: public MemArray<TChronoScenario> Scenarios
//https://github.com/space928/Omsi-Extensions/issues/126
{
get => omsiMemory.ReadMemory<Array?>(baseAddress + 0x10);
set => omsiMemory.WriteMemory(baseAddress + 0x10, value);
Expand Down
15 changes: 8 additions & 7 deletions OmsiHook/WrappedOmsiClasses/OmsiComplMapObj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public float NoSound
get => Memory.ReadMemory<float>(Memory.ReadMemory<int>(Address + 0x1b8));
set => Memory.WriteMemory(Memory.ReadMemory<int>(Address + 0x1b8), value);
}
public byte Complexity // Byte maybe?
public byte Complexity
{
get => Memory.ReadMemory<byte>(Address + 0x1bc);
set => Memory.WriteMemory(Address + 0x1bc, value);
Expand Down Expand Up @@ -114,6 +114,7 @@ public int Switch_State_Count
set => Memory.WriteMemory(Address + 0x1d0, value);
}
// TODO: Implement internal struct for OmsiTreeInfo
//https://github.com/space928/Omsi-Extensions/issues/127
/*public OmsiTreeInfo TreeInfo
{
get => Memory.ReadMemory<OmsiTreeInfo>(Address + 0x1d4);
Expand Down Expand Up @@ -185,6 +186,7 @@ public int FirstUser
set => Memory.WriteMemory(Address + 0x204, value);
}
/* TODO:
* https://github.com/space928/Omsi-Extensions/issues/127
public OmsiXPC_CreateReturn Script_Return
{
get => Memory.ReadMemory<OmsiXPC_CreateReturn>(Address + 0x208);
Expand Down Expand Up @@ -224,6 +226,7 @@ public OmsiAmpelGroup AmpelGroup
Memory.ReadMemory<OmsiAmpelGroupInternal>(Address + 0x230));
//TODO:
//set => Memory.WriteMemory(Address + 0x230, value);
// https://github.com/space928/Omsi-Extensions/issues/127
}
public int CTC_FarbSchema
{
Expand All @@ -232,13 +235,11 @@ public int CTC_FarbSchema
}
public OmsiTriggerBox[] TriggerBoxes => Memory.ReadMemoryStructArray<OmsiTriggerBox>(Address + 0x248);

/* TODO:
public OmsiComplObjPtr ComplObj
public OmsiComplObj ComplObj
{
get => Memory.ReadMemory<OmsiComplObjPtr>(Address + 0x24c);
set => Memory.WriteMemory(Address + 0x24c, value);
}*/
public OmsiPathManager ComplObj
get => Memory.ReadMemoryObject<OmsiComplObj>(Address + 0x24c);
}
public OmsiPathManager PathManager
{
get => Memory.ReadMemoryObject<OmsiPathManager>(Address, 0x250, false);
}
Expand Down
Loading