I am currently doing some research and stumbled across something. I created a pair of structs -
struct uFirst
{
int a;
float b;
string c;
};
struct uSecond
{
struct uFirst d;
int e;
};
And tested to make sure there were no syntax or other errors. The toolset compiler had no trouble with that. However whenever I try to use struct d in uSecond even to just assign another instance of struct uFirst to it I get an access violation error. Is this a bug? Is this behaviour limited to EE? In C/C#/C++ what I am trying to do is perfectly valid and also it must be processed when you use an NwN variable of type location too. Ideas?
This was a well-documented issue with NWN from the outset. Nested structs don’t work.
A possible workaround is to expand the fields in the nested struct, then assign field by field. Another technique is to convert the simple struct contents to a delimited string, though I don’t think that helps much unless there are a vast number of fields in the struct.
Saved/Compiled as is works fine. Now uncomment that last line and you’ll get an access violation. It appears you can put data into a nested struct, you just can’t get it out again.
I haven’t coded for NWN and my coding knowledge is from a very long time ago, but I have an idea. What if you put a pointer to uFirst inside uSecond, instead of an actual uFirst? You would have to create a uFirst variable dynamically and have the pointer point to it.