FSDeveloper Community

Go Back   FSDeveloper Community > Other > Tools programming

Tools programming Use this forum to discuss anything related to creating tools for addon developers

Reply
 
Thread Tools Display Modes
  #1  
Old 02 Mar 2008, 12:09
Manuel Ambulo Manuel Ambulo is offline
  panama
Join Date: Sep 2006
Posts: 163
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 by Manuel Ambulo; 02 Mar 2008 at 12:22.
Reply With Quote
  #2  
Old 02 Mar 2008, 14:14
Paavo's Avatar
Paavo Paavo is offline
  estonia
Join Date: May 2006
Posts: 138
What tools do you use to explore exported functions?
__________________
Estonian FSX Addons — http://www.lennusimu.net/

Last edited by Paavo; 02 Mar 2008 at 14:23.
Reply With Quote
  #3  
Old 10 Mar 2008, 16:29
Manuel Ambulo Manuel Ambulo is offline
  panama
Join Date: Sep 2006
Posts: 163
I had learnned from this thread:

http://www.fsdeveloper.com/forum/sho...ghlight=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 by Manuel Ambulo; 10 Mar 2008 at 16:31.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Discovering WPF and custom windows in FSX ziporama Tools programming 26 27 Jun 2012 03:59
update Population Density data lc0277 FSX terrain 4 03 Jul 2011 13:05
Traffic Density Sliders gadgets BGLComp XML, AFCAD, SceneGenX 3 25 Jul 2007 12:25
How do you make two way road traffic dcrandal FSX KML 11 14 May 2007 14:34
Freeways, a problem with two-way traffic Andy General 6 29 Dec 2006 12:11


All times are GMT -4. The time now is 08:10.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.