-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arrayCache.Length NullReferenceException #76
Comments
ok so it is confirmed that it crashed after i spawned my bus |
i used the CLI project |
This can happen if a MemArray is created but not properly initialised. To
construct a MemArray you must either use the two-parameter constructor (eg:
new MemArray(memory, address)) or use the zero-parameter constructor and
then call InitObject before you use it (eg: var ma = new MemArray();
ma.InitObject(memory, address)).
If you're not constructing the MemArray yourself, then this could be a bug
with one of our wrapper classes, in which case I would need the full stack
trace to see where it went wrong.
…On Thu, 30 Nov 2023 at 14:32, Ed ***@***.***> wrote:
i used the CLI project
—
Reply to this email directly, view it on GitHub
<#76 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADTN4AWPKBSLCYKGFYPJFLTYHCKIHAVCNFSM6AAAAABABIP3KWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZTHA4TCMRUGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Thomas
|
i used the original CLI and did not change anything.
|
Ah, ok I see what the problem is. It seems that the vehicle's script texture array is null in Omsi, which means OmsiHook can't dereference it. In the future I might make it so that So for instance in the // [...]
var scriptTexes = omsi.Globals.PlayerVehicle.ComplObjInst.ScriptTextures;
//+++++++++++ BEGIN
if (scriptTexes.WrappedArray == null)
return; // The player vehicle has no script textures to replace
//+++++++++++ END
for (int i = 0; i < scriptTexes.Count; i++)
{
var old = scriptTexes[i];
Console.WriteLine($"Replacing script tex: texPn:uint[{old.TexPn?.Length??-1}], color:{old.color}, tex:{old.tex} with tex:{texture.TextureAddress}");
scriptTexes[i] = new()
{
TexPn = old.TexPn,
color = old.color,
tex = unchecked((IntPtr)texture.TextureAddress)
};
} |
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=OmsiHook
StackTrace:
at OmsiHook.MemArrayBase`1.get_Count() in D:\users\suityan\Source\Repos\Omsi-Extensions2\OmsiHook\MemArrayBase.cs:line 26
do not know sure why it happens
The text was updated successfully, but these errors were encountered: