• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

detecting sim reset

Messages
46
Country
france
Hello,

I'd like to get some advice on how to detect properly the sim reset :

I am working on a TCAS implementation and I fill a table using EVENT_OBJECT_ADDED/REMOVED as planes are fed in by the AI engine.
Now when the sim reset (new situation loaded, flight restarted, ...) I need to cleanup the table and restart it.
How to detect that a reset is being done properly ? I also need to get it before AI traffic is generated. sim start/stop events does not seem appropriate since the doc mention that they are generated when the user navigate in the menus (I don't want to erase my TCAS table if the user opens a menu ...)

Thanks for your kind help,

Oliver
 
I am working on a TCAS implementation and I fill a table using EVENT_OBJECT_ADDED/REMOVED as planes are fed in by the AI engine.
Now when the sim reset (new situation loaded, flight restarted, ...) I need to cleanup the table and restart it.
How to detect that a reset is being done properly ? I also need to get it before AI traffic is generated.

There's really no need for any special actions. You will get the REMOVED notifications for everything being removed as well as ADDED notifications for everything added, when the user restarts, or chooses a new flight, or even changes the time or Traffic sliders (upwards) -- maybe you even forgot that traffic is reloaded in such events too?

Just process all REMOVED and ADDED events and you will be fine. That's all FSUIPC4 does and there's no problems maintaining the tables.

Regards

Pete
 
Hello Pete !

Thanks for the fast answer. When I read it, I realized that you were absolutely right (as always) - Then something must be wrong with my code. I stepped through it with the debugger while starting and resetting FSX and noticed something strange :
Starting the simulator, the first object allocated has ID# 2, and then objects ID keep increasing, so they are stored in my table.

Then when I reset the sim, it removes objets but I received a REMOVE event for object #1, which was not created at startup. Then my object count is false; hence the bug ...

Am I correct assuming object #1 is the user aircraft - Why I don't catch a creation event for it ?

regards

Olivier
 
Am I correct assuming object #1 is the user aircraft - Why I don't catch a creation event for it ?

Yes, the user aircraft ID is 1, initially in any case. It is created before you get any sort of connection, so you won't see that. It might not be 1 still when it comes back -- in multiplayer modes the ID can change.

You need to read the IS USER SIM variable for each aircraft notification, whether Added or Removed, and ignore it if that is TRUE.

Regards

Pete
 
Back
Top