OMSI freezes when hooking the vehicle script texture
Closed this issue · 2 comments
Describe the bug
When I try to set a script texture via OMSI Hook in an OMSI plugin, OMSI freezes.
To Reproduce
I use the following code for this:
_texture = _context.OMSI.CreateTextureObject();
await _texture.CreateD3DTexture(1024, 1024);
Console.WriteLine(_context.OMSI.IsD3DReady); // True
var scriptTextures = _context.OMSI.Globals.Map.PlayerVehicle.ComplObjInst.ScriptTextures;
// but this works: var scriptTextures = _context.OMSI.Globals.Map.Kacheln[0].Objects[14].ComplObjInst.ScriptTextures;
var old = scriptTextures[0];
if (old.tex != (IntPtr)_texture.TextureAddress)
{
scriptTextures[0] = new()
{
TexPn = old.TexPn,
color = old.color,
tex = unchecked((IntPtr)_texture.TextureAddress)
};
}
If I comment out the last instruction (scriptTextures[0] = ...
), OMSI continues to run. Setting of script textures for scenery objects also works.
Expected behaviour
OMSI should not freeze after executing the code, but continue to run.
Hi, I had not noticed any particular freezing when doig it on my version previously, have you got the latest build of the OH plugin loaded? maybe its a version mis-match issue?
Can you provide a complete minimal example that can reproduce this bug (including which bus you're using)?
Otherwise I might be able to gleam some insight into the issue if you can provide a minidump of OMSI; if you can get WinDbg or your favourite debugger to attach to Omsi (not always easy) then you should be able to create a minidump which I can analyse. In WinDbg the steps would be:
- Trigger the bug causing Omsi to freeze.
- Attach to omsi.exe in WinDbg
- Execute the command
.dump /mA C:\Users\<username>\Documents\omsi.dmp
- Private message me the dump (Discord or email)
That being said a reproduceable example would be ideal.