SimConnect removes my AI object

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
mitch99
Posts: 1
Joined: Mon Nov 28, 2016 9:37 pm

SimConnect removes my AI object

Post by mitch99 »

I hope I'm not stepping on any toes here - I posted this in FSDeveloper.com forum, but I think it pertains also to Prepar3D.

I have a SimConnect DLL module set up that loads a number of AI object(s) from a list specified in a FLT file (I added my own custom entries that only my DLL reads). They get read in and loaded as soon as the main user object has been loaded from simulator's FLT file.

When I load the AI object just after the main user object, it is read in and loaded, and the new object ID is issued and everything seems fine... except, immediately after, server rejects the AI object by issuing "ObjectRemoved " system event and removes the object.

To check my sanity level, I rigged a little Sleep() command to cause a pause, and if I give it about 3.5 seconds of wait time, everything loads properly.

Also, I rigged the AI loading on a custom key press, and again, everything works ok.

The related SDK demo AI Objects and Waypoints loads AI objects on key press, so I never noticed this. It seems as if the system needs a bit of time to put everything on screen, and then perhaps it is ready to accept AI objects. Is there a system event that would notify me when the "picture"appears upon loading the sim? SimStart, SimStop and Sim events are unreliable (as per SDK's own admmission) as they get fired several times during the sim loading.

Full topic and discussion , with a kludgy solution, can be found here. Any insight on this would be really helpful!
Locked