C++ SimConnect_SetDataOnSimObject for SIMCONNECT_DATA_WAYPOINT

Dear Asobo, Is there a way via C++ to send a dynamic array via
SimConnect_SetDataOnSimObject to set a list of waypoints instead of a fixed
size one? I been trying everything (I could be doing something wrong of
course), and it never works… I have to always set an array of a fixed size,
but this is not ideal or safe since my waypoints are not warrantied to prevent
overflowing the array of course. I also tried to send a list instead of an
array, but it also fails. In both cases (dynamic array size or a list) the
object doesn’t seem to accept the waypoint list. I checked your AIObject
example, it also has a fixed size SIMCONNECT_DATA_WAYPOINT array. Is there
something wrong? or how can I achieve this? tried this:

int arraySize = 20;
SIMCONNECT_DATA_WAYPOINT  *waypoints = new SIMCONNECT_DATA_WAYPOINT [arraySize]
..
fill waypoints
..

SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_WAYPOINT, myObjectID, 0, ARRAYSIZE(waypoints), sizeof(waypoints [0]), waypoints);

That fails, object nevers accepts the Waypoints… if instead I change the
array to be:

SIMCONNECT_DATA_WAYPOINT  waypoints[20];

Then everything works… however the amount of waypoints can be variable, I
cannot set a fix array. Via C# I can do it by converting the array to an
object and pass the reference, so something is odd hre Best, Raul

Hi @Simbol, When using a dynamic array, you shouldn’t use the ARRAYSIZE macro
(it won’t work as you seem to expect on a pointer). Pass “arraySize” as an
argument instead. Please let us know if it doesn’t fix the issue. Best
regards, Eric / Asobo

Hi @EPellissier , Ok will try and revert with feedback. Best, R.

Hi @EPellissier Eric, Ok that didn’t work, I think this code below is going
wrong for some reason:

SIMCONNECT_DATA_WAYPOINT *waypoints = new SIMCONNECT_DATA_WAYPOINT [arraysize]

However I did something else that worked, and leaving it here for others in
case it helps, I created a vector of SIMCONNECT_DATA_WAYPOINT , put everything
in there and then created an array from the vector this did the trick.

int arraysize = waypoints_vector.size();
SIMCONNECT_DATA_WAYPOINT *waypoints = waypoints_vector.data();

Thanks for all your help with this. Best, Raul

Hi @Simbol, I cannot see any good reason why the solution I proposed wouldn’t
work - it would be strange that the allocation fails too. Do you still have
the version of your code that did not work? I am curious to understand what
failed. Best regards, Eric / Asobo

Hi Eric, Not unfortunately, I am on a tight deadline for a project. When I get
that out of the way I will write some sample code to replicate this, and if it
happens I will post it here for you. Best, Raul