• 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.

Here is how to set AI Traffic density from a custom DLL inside FSX

Messages
175
Country
panama
Here is how to set AI Traffic density from a custom DLL loaded by FSX

Hi,

I just discovered a way for set the AI Traffic density, automatly, from a DLL written in C++. Here is the basic code:

Code:
// FS10 FS-TRAFFIC.DLL - Settings Structure
typedef struct FS10TRAFFIC_SETTINGS
{
    unsigned long Traffic_Density; // Traffic Density %(percent, from 0 to 100)
	unsigned long IFR_or_VFR; // 0 = IFR and VFR, 1 = IFR (Only)
	unsigned long Airline; // 0 = Disable, 1 = Enabled
	unsigned long General_Aviation; // 0 = Disable, 1 = Enabled
} FS10TRAFFIC_SETTINGS;


// FS10 - Exported Function Pointers Types Definitions
typedef void  (FSAPI *FS10TRAFFICWRITESETTINGS)(FS10TRAFFIC_SETTINGS* info);
typedef void  (FSAPI *FS10TRAFFICREADSETTINGS)(FS10TRAFFIC_SETTINGS* info);


FS10TRAFFIC_SETTINGS FS10Traffic_Settings;


// Initializate this structure
memset(&FS10Traffic_Settings, 0, sizeof(FS10TRAFFIC_SETTINGS));


// Get the handle of the TRAFFIC.DLL module
hTraffic = GetModuleHandle("FS-TRAFFIC.DLL");


// READ AND CHANGE THE TRAFFIC SETTINGS
// If we got the handle of the TRAFFIC.DLL module then
if (hTraffic != NULL)
{
	// 1) READ THE CURRENT TRAFFIC SETTINGS
	// Get a pointer to the TRAFFIC.DLL module's exported function
	FS10ReadTrafficSettings = (FS10TRAFFICREADSETTINGS)GetProcAddress(hTraffic, (char*)6);

	// If we got a pointer to the TRAFFIC.DLL module's exported function then
	if (FS10ReadTrafficSettings != NULL)
	{
		// Get the *CURRENT* traffic settings
		FS10ReadTrafficSettings(&FS10Traffic_Settings);

		// Notify to user
		MessageBox(hWnd, "The traffic settings had been read SUCCESSFULLY!", "FSIntruder.dll - Message", 0);
	}

	// 2) CHANGE THE TRAFFIC SETTINGS
	// Get a pointer to the TRAFFIC.DLL module's exported function
	FS10WriteTrafficSettings = (FS10TRAFFICWRITESETTINGS)GetProcAddress(hTraffic, (char*)5);

	// If we got a pointer to the TRAFFIC.DLL module's exported function then
	if (FS10WriteTrafficSettings != NULL)
	{
		// Build the new traffic settings structure
		FS10Traffic_Settings.Traffic_Density = 100; // 100% of Traffic density
		FS10Traffic_Settings.IFR_or_VFR = 0; // IFR and VFR
		FS10Traffic_Settings.Airline = TRUE; // Enabled
		FS10Traffic_Settings.General_Aviation = TRUE; // Enabled

		// Set the *NEW* traffic settings
		FS10WriteTrafficSettings(&FS10Traffic_Settings);

		// Notify to user
		MessageBox(hWnd, "The traffic settings had been CHANGED SUCCESSFULLY!", "FSIntruder.dll - Message", 0);
	}
}

This is for anyone wanting to change the traffic settings dynamicly from your DLL...


Manuel Ambulo
 
Last edited:

Paavo

Resource contributor
Messages
192
Country
estonia
What tools do you use to explore exported functions?
 
Last edited:
Messages
175
Country
panama
I had learnned from this thread:

http://www.fsdeveloper.com/forum/showthread.php?t=3330&highlight=AdvBar

Since that time i had tried to see if i can call some of the exported functions from the FSX DLLs and tried to see what do they do. That process needs a lot of patients, and time....then after hours trying, i found a little number of functions but what is impressive is the job that the author of FSUIPC did with all FS versions, he figured out almost all of the functions used in FS2002/2004/X, that is something that is admirable and impressive, hehehehe.... :). In FSX, i use the Dependency Walker, but the problem is that the exported functions are not exported with the functions names, but only with the ordinal number....so then the pain comes when then you need to figure out what arguments to pass to the function and what it does returns or if it doesnt returns anything....and also to see what does it does....

Best Regards,

Manuel Ambulo
 
Last edited:
Top