Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Possible FS X bugs causing CTDs

Featured Replies

Hey all,We may have identified some bugs.This code:wstring RadioPage::GetAdf1Active(){ FLOAT64 freq; WCHAR freqStr[7] = {0}; execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)", &freq, NULL, NULL); swprintf_s(freqStr, 6, L"%06.1f", freq); return freqStr;}crashes FS X. At first, I suspected it was our code, but it seems Bill Learning has been able to replicate it, and has similar problems:

This works just fine in a simple N-Registration gauge used in both FS9 and FSX:case PANEL_SERVICE_PRE_UPDATE: execute_calculator_code("(A:atc id, string)",NULL,NULL,&n_number);break;However, this causes FSX to crash while loading:execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)",&adf1_frequency,NULL,NULL);as does this:execute_calculator_code("(A:atc flight number,string)",NULL,NULL,&atc_flight_number);
Just wanted to post this so MS might see it.

Well the declaration of the function is:BOOL (FSAPI *format_calculator_string) (PSTRINGZ result, UINT32 resultsize, PCSTRINGZ format);a PCSTRINGZ is not a WCHAR* at all.Could this be the nature of the problem if your project settings are set to wide char? if so, I suspect any "xxxx" is a wide char string, not a char string in you code.

  • Moderator

Actually, the prototype declaration is:BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);In the case of the atc_id, note the following:PCSTRINGZ atc_flight_number; execute_calculator_code("(A:atc flight number,string)",NULL,NULL,&atc_flight_number);swprintf(buf,L"%S", atc_flight_number);Clearly, there isn't a problem with this, yet it crashes FSX. Commenting out the second line eliminates the crash...In the case of the ADF frequency:FLOAT64 adf1_frequency = 0;execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)",&adf1_frequency,NULL,NULL);The same applies to the following as the above. Clearly the variable is constructed per the prototype.Completely aside from which... this exact same code works in FS9 with no problems whatsoever.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Thanks for pointing that out, I had overlooked this, and it explains something else I was dealing with, however, as Bill points out below there is still a problem.I'll look at this again, but I am thinking that I can't get to the ADF2 freq due to that macro crashing FS X.

  • Commercial Member

>Actually, the prototype declaration is:>>BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code,>FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);>>In the case of the atc_id, note the following:>>PCSTRINGZ atc_flight_number; >execute_calculator_code("(A:atc flight>number,string)",NULL,NULL,&atc_flight_number);>swprintf(buf,L"%S", atc_flight_number);>>Clearly, there isn't a problem with this, yet it crashes FSX. >Commenting out the second line eliminates the crash...>This is crashing because FSX is returning a NULL pointer. Change your code to this:execute_calculator_code("(A:atc flight number,string)",NULL,NULL,&atc_flight_number);if (atc_flight_number){ swprintf(buf,L"%S", atc_flight_number);}else{// clear the buf here so nothing displays swprintf(buf,L"%S", "");}That will at least prevent the crash.

Ed Wilson

Mindstar Aviation
My Playland - I69

Ok, I tried this:wstring RadioPage::GetAdf1Active(){ FLOAT64 freq; WCHAR freqStr[10] = {0}; execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)", &freq, NULL, NULL); if(freq) { swprintf_s(freqStr, 6, L"%06.1f", freq); return freqStr; } else { return L""; }}and it still crashes FS9 or FS X. So, I'm thinking this is a bug. Those are not wide-charaters (that would be L"(A:ADF ...)".What surprises me is that I can't get it to work even in FS9.Any ideas?

Patrick,As noted in the FSDeveloper Forum,The A:ADF ACTIVE FREQUENCY:1 variable is not immediately available on aircraft load. You can either check for the passage of sim time before asking for this variable, or you can wrap it in an if statement: if ( execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)", &freq, NULL, NULL)) {} else freq = -1;Doug

Doug,>As noted in the FSDeveloper Forum,>The A:ADF ACTIVE FREQUENCY:1 variable is not immediately>available on aircraft load. You can either check for the>passage of sim time before asking for this variable, or you>can wrap it in an if statement:>> if ( execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1,>KHz)", &freq, NULL, NULL))> {}> else freq = -1;Yes, as I posted there, this didn't fix it. FS 9 and FS X still crash on the execute_calculator_code.The only thing I can think of that is wrong now is the .h I'm using.

The .h is not the problem, as I compiled with the old known good .h and it crashes too.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.