C: Get Magnetic Variation for any lat/lon: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
m (JB3DG moved page C: C++: Get Magnetic Variation for any lat/lon to C: Get Magnetic Variation for any lat/lon over redirect) |
m (FSVersion Infobox rollout) |
||
| Line 1: | Line 1: | ||
{{Infobox-Applicable-FSVersion | {{Infobox-Applicable-FSVersion | ||
| FS2020 = unknown | |||
| FSXI = unknown | |||
| P3D4 = true | | P3D4 = true | ||
| P3D3 = true | |||
| P3D2 = true | | P3D2 = true | ||
| P3D = true | | P3D = true | ||
| | | FSW = unknown | ||
| FSXSE = true | |||
| FSXA = true | | FSXA = true | ||
| FSX = true | | FSX = true | ||
| FS2004 = | | FS2004 = unknown | ||
| FS2002 | | FS2002 = unknown | ||
| XP11 = false | |||
| | | XP10 = false | ||
| XP10 = false | | XP9 = false | ||
| XP9 = false | |||
}} | }} | ||
The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful. | The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful. | ||
Latest revision as of 10:10, 29 March 2020
| Applicable |
|---|
| MS Flight |
| LM P3D4 |
| LM P3D3 |
| LM P3D2 |
| LM P3D |
| FS World |
| FSXSE |
| FSXA |
| FSX |
| FS2004 |
| FS2002 |
| XP11 |
| XP10 |
| XP9 |
The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful.
In your choice of your project's header files, do the following function prototype:
typedef float(__stdcall *ffe_get_magvar64)(const _llaf64*);
Then in your module_init function:
#ifdef _M_X64
#define PWORDX unsigned __int64
#else
#define PWORDX DWORD
#end
ffe_get_magvar64 fe_get_magvar64 = NULL;
void FSAPI module_init(void)
{
HMODULE hfedll = NULL;
GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, L"fe.dll", &hfedll);
if(hfedll )
GetSimTime6 = (fGetSimTime)GetProcAddress(hfedll , MAKEINTRESOURCEA(4)); }
Now wherever you wish to call this function, include the header where the prototype is contained and add:
extern ffe_get_magvar64 fe_get_magvar64;
To call it and find out how much time has passed:
_llaf64 lla = {lat, lon, alt};//_llaf64 is a struct in the gauges.h. lat/lon are in degrees and alt is in meters.
float mvar = fe_get_magvar64(&lla);
NOTE:
All FSX versions use ordinal 4. For all 32bit versions of P3D however, use the following:
fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, "?fe_get_magvar64@@YGMQAU_llaf64@@@Z");
For all versions of P3D v4, use the following:
fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, "?fe_get_magvar64@@YAMQEAU_llaf64@@@Z");