![]() |
|
|||||||
| Register | Wiki | Downloads | FAQ | Members List | Social Groups | Calendar | Search | Today's Posts | Mark Forums Read |
| Tools programming Use this forum to discuss anything related to creating tools for addon developers |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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);
}
}
Manuel Ambulo Last edited by Manuel Ambulo; 02 Mar 2008 at 12:22. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |