Skip to content

Commit

Permalink
+ OmsiSound Completed for @sjain882 (#43)
Browse files Browse the repository at this point in the history
* + OmsiSound Completed for @sjain882
 + OmsiBoolClass
 + Required Structs

* + Convert to IntPtr

* + BetterCast

* + .ToInt32()
  • Loading branch information
amathieson authored May 23, 2022
1 parent cab059e commit e021204
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 8 deletions.
30 changes: 30 additions & 0 deletions OmsiHook/OmsiBoolClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OmsiHook
{
/// <summary>
/// Defines a set of conditions based on various data types.
/// </summary>
public class OmsiBoolClass : OmsiObject
{
internal OmsiBoolClass(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
public OmsiBoolClass() : base() { }

public OmsiBoolClassCondiBool[] CondisBool
{
get => Memory.ReadMemoryStructArray<OmsiBoolClassCondiBool>(Address + 0x4);
}
public OmsiBoolClassCondiInt[] CondisInt
{
get => Memory.ReadMemoryStructArray<OmsiBoolClassCondiInt>(Address + 0x8);
}
public OmsiBoolClassCondiFloat[] CondisFloat
{
get => Memory.ReadMemoryStructArray<OmsiBoolClassCondiFloat>(Address + 0xc);
}
}
}
205 changes: 197 additions & 8 deletions OmsiHook/OmsiSound.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace OmsiHook
using System;

namespace OmsiHook
{
/// <summary>
/// Sound that is playable by OMSI
Expand All @@ -7,17 +9,204 @@ public class OmsiSound : OmsiObject
{
internal OmsiSound(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
public OmsiSound() : base() { }

/*public DirectSound8 Device
public string FileName
{
get => Memory.ReadMemory<DirectSound8>(Address + 0x4);
get => Memory.ReadMemoryString(Address + 0x4);
set => Memory.WriteMemory(Address + 0x4, value);
}*/
public string FileName
}
/// <summary>
/// Pointer to an IDirectSound8
/// </summary>
public IntPtr Device
{
get => new(Memory.ReadMemory<int>(Address + 0x8));
set => Memory.WriteMemory(Address + 0x8, value.ToInt32());
}
/// <summary>
/// Pointer to an IDirectSoundBuffer8
/// </summary>
public IntPtr SoundBuffer
{
get => new(Memory.ReadMemory<int>(Address + 0xc));
set => Memory.WriteMemory(Address + 0xc, value.ToInt32());
}
/// <summary>
/// Pointer to an IDirectSoundFXWavesReverb8
/// </summary>
public IntPtr FX_Hall
{
get => new(Memory.ReadMemory<int>(Address + 0x10));
set => Memory.WriteMemory(Address + 0x10, value.ToInt32());
}
public float FX_Hall_Gain
{
get => Memory.ReadMemory<float>(Address + 0x14);
set => Memory.WriteMemory(Address + 0x14, value);
}
public float FX_Hall_Time
{
get => Memory.ReadMemory<float>(Address + 0x18);
set => Memory.WriteMemory(Address + 0x18, value);
}
public bool Failed
{
get => Memory.ReadMemory<bool>(Address + 0x1c);
set => Memory.WriteMemory(Address + 0x1c, value);
}
public float[] InternVars
{
get => Memory.ReadMemoryStructArray<float>(Address + 0x20);
}
public uint StartTime
{
get => Memory.ReadMemory<uint>(Address + 0x24);
set => Memory.WriteMemory(Address + 0x24, value);
}
public int BufferSize
{
get => Memory.ReadMemory<int>(Address + 0x28);
set => Memory.WriteMemory(Address + 0x28, value);
}
public float Prev_Volume
{
get => Memory.ReadMemory<float>(Address + 0x2c);
set => Memory.WriteMemory(Address + 0x2c, value);
}
public int FreqVar
{
get => Memory.ReadMemory<int>(Address + 0x30);
set => Memory.WriteMemory(Address + 0x30, value);
}
public int SampleRate
{
get => Memory.ReadMemory<int>(Address + 0x34);
set => Memory.WriteMemory(Address + 0x34, value);
}
public float RefValue
{
get => Memory.ReadMemory<float>(Address + 0x38);
set => Memory.WriteMemory(Address + 0x38, value);
}
public bool Loop
{
get => Memory.ReadMemory<bool>(Address + 0x3c);
set => Memory.WriteMemory(Address + 0x3c, value);
}
public bool Pitch
{
get => Memory.ReadMemory<bool>(Address + 0x3d);
set => Memory.WriteMemory(Address + 0x3d, value);
}
public bool Triggered
{
get => Memory.ReadMemory<bool>(Address + 0x3e);
set => Memory.WriteMemory(Address + 0x3e, value);
}
public bool CheckLoading
{
get => Memory.ReadMemory<bool>(Address + 0x3f);
set => Memory.WriteMemory(Address + 0x3f, value);
}
public bool OnlyOne
{
get => Memory.ReadMemoryString(Memory.ReadMemory<int>(Address + 0x8));
set => Memory.WriteMemory(Address + 0x8, value);
get => Memory.ReadMemory<bool>(Address + 0x40);
set => Memory.WriteMemory(Address + 0x40, value);
}
/// <summary>
/// Only One _ Prohibition?
/// </summary>
public bool OnlyOne_Verbot
{
get => Memory.ReadMemory<bool>(Address + 0x41);
set => Memory.WriteMemory(Address + 0x41, value);
}
public bool Important
{
get => Memory.ReadMemory<bool>(Address + 0x42);
set => Memory.WriteMemory(Address + 0x42, value);
}
public string[] TriggerList
{
get => Memory.ReadMemoryStringArray(Address + 0x44);
}
public bool StartTrigSnd
{
get => Memory.ReadMemory<bool>(Address + 0x48);
set => Memory.WriteMemory(Address + 0x48, value);
}
public byte Flag_Viewpoint
{
get => Memory.ReadMemory<byte>(Address + 0x49);
set => Memory.WriteMemory(Address + 0x49, value);
}
public bool Is3D
{
get => Memory.ReadMemory<bool>(Address + 0x4a);
set => Memory.WriteMemory(Address + 0x4a, value);
}
public D3DVector SndPos
{
get => Memory.ReadMemory<D3DVector>(Address + 0x4b);
set => Memory.WriteMemory(Address + 0x4b, value);
}
public float VolDist
{
get => Memory.ReadMemory<float>(Address + 0x58);
set => Memory.WriteMemory(Address + 0x58, value);
}
public bool HasDir
{
get => Memory.ReadMemory<bool>(Address + 0x5c);
set => Memory.WriteMemory(Address + 0x5c, value);
}
public D3DVector Dir
{
get => Memory.ReadMemory<D3DVector>(Address + 0x5d);
set => Memory.WriteMemory(Address + 0x5d, value);
}
public float VolFaktor
{
get => Memory.ReadMemory<float>(Address + 0x6c);
set => Memory.WriteMemory(Address + 0x6c, value);
}
public int[] VolVars
{
get => Memory.ReadMemoryStructArray<int>(Address + 0x70);
}
public OmsiFuncClass[] VolCurves
{
get => Memory.ReadMemoryObjArray<OmsiFuncClass>(Address + 0x74);
}
public OmsiBoolClass BoolClass
{
get => new(Memory, Memory.ReadMemory<int>(Address + 0x78));
}
public bool Playing
{
get => Memory.ReadMemory<bool>(Address + 0x7c);
set => Memory.WriteMemory(Address + 0x7c, value);
}
public bool MayPlay
{
get => Memory.ReadMemory<bool>(Address + 0x7d);
set => Memory.WriteMemory(Address + 0x7d, value);
}
public bool Stopped_TooFar
{
get => Memory.ReadMemory<bool>(Address + 0x7e);
set => Memory.WriteMemory(Address + 0x7e, value);
}
/// <summary>
/// Pointer to an IDirectSound3DBuffer
/// </summary>
public IntPtr Int3D
{
get => new(Memory.ReadMemory<int>(Address + 0x80));
set => Memory.WriteMemory(Address + 0x80, value.ToInt32());
}




}
}
31 changes: 31 additions & 0 deletions OmsiHook/OmsiStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,4 +1765,35 @@ internal struct OmsiRVFileInternal
[OmsiStructArrayPtr(typeof(OmsiRVTypeTour), typeof(OmsiRVTypeTourInternal))] public int list_type_tour;
[OmsiStruct(typeof(OmsiRVTypesLine), typeof(OmsiRVTypesLineInternal))] public int list_types_line;
}

/* TODO: Parse the pointers better to get the variables */
public struct OmsiBoolClassCondiBool
{
/// <summary>
/// Pointer to array of float var pointers (OSC accessible variables)
/// </summary>
public int vars;
public int varNum;
public bool negative;
}
public struct OmsiBoolClassCondiInt
{
/// <summary>
/// Pointer to array of float var pointers (OSC accessible variables)
/// </summary>
public int vars;
public int varNum;
public int refValue;
public int comparison;
}
public struct OmsiBoolClassCondiFloat
{
/// <summary>
/// Pointer to array of float var pointers (OSC accessible variables)
/// </summary>
public int vars;
public int varNum;
public float refValue;
public int comparison;
}
}

0 comments on commit e021204

Please sign in to comment.