Skip to content

Commit a9345d6

Browse files
committed
Added autofix for black screen on startup
1 parent 5c0fecb commit a9345d6

File tree

7 files changed

+86
-1
lines changed

7 files changed

+86
-1
lines changed

MTA10/core/CConnectManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ bool CConnectManager::Connect ( const char* szHost, unsigned short usPort, const
6060

6161
m_bNotifyServerBrowser = bNotifyServerBrowser;
6262

63+
// For detecting startup problems
64+
WatchDogUserDidInteractWithMenu();
65+
6366
// Hide certain questions
6467
CCore::GetSingleton ().GetLocalGUI ()->GetMainMenu ()->GetQuestionWindow ()->OnConnect ();
6568

MTA10/core/CMainMenu.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ bool CMainMenu::OnMenuClick ( CGUIElement* pElement )
769769
// Handle all our clicks to the menu from here
770770
if ( m_pHoveredItem )
771771
{
772+
// For detecting startup problems
773+
WatchDogUserDidInteractWithMenu();
774+
772775
// Possible disconnect question for user
773776
if ( g_pCore->IsConnected() )
774777
{

MTA10/core/CQuestionBox.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ bool CQuestionBox::IsVisible ( void )
211211

212212
bool CQuestionBox::OnButtonClick ( CGUIElement* pElement )
213213
{
214+
// For detecting startup problems
215+
WatchDogUserDidInteractWithMenu();
216+
214217
m_uiLastButton = reinterpret_cast < unsigned int > ( pElement->GetUserData () );
215218
if ( m_Callback)
216219
m_Callback ( m_CallbackParameter, m_uiLastButton );

MTA10/loader/MainFunctions.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ void HandleSpecialLaunchOptions( void )
141141
if ( CommandLineContains( "/kdinstall" ) )
142142
{
143143
UpdateMTAVersionApplicationSetting( true );
144+
WatchDogReset();
145+
WatchDogBeginSection( WD_SECTION_POST_INSTALL );
144146
if ( CheckService( CHECK_SERVICE_POST_INSTALL ) )
145147
return ExitProcess( EXIT_OK );
146148
return ExitProcess( EXIT_ERROR );
@@ -320,6 +322,53 @@ void HandleResetSettings ( void )
320322
}
321323

322324

325+
//////////////////////////////////////////////////////////
326+
//
327+
// HandleNotUsedMainMenu
328+
//
329+
// Called when a problem occured before the main menu was used by user
330+
// If Win10 and fullscreen, then maybe change fullscreen mode
331+
//
332+
//////////////////////////////////////////////////////////
333+
void HandleNotUsedMainMenu ( void )
334+
{
335+
AddReportLog( 9310, "Loader - HandleNotUsedMainMenu" );
336+
if ( IsWindows10OrGreater() )
337+
{
338+
// Slighty hacky way of checking in-game settings
339+
SString strCoreConfigFilename = CalcMTASAPath( PathJoin( "mta", "config", "coreconfig.xml" ) );
340+
SString strCoreConfig;
341+
FileLoad( strCoreConfigFilename, strCoreConfig );
342+
SString strWindowed = strCoreConfig.SplitRight( "<display_windowed>" ).Left( 1 );
343+
SString strFullscreenStyle = strCoreConfig.SplitRight( "<display_fullscreen_style>" ).Left( 1 );
344+
if ( !strWindowed.empty() && !strFullscreenStyle.empty())
345+
{
346+
if ( strWindowed == "0" && strFullscreenStyle == "0" ) // 0=FULLSCREEN_STANDARD
347+
{
348+
// Inform user
349+
SString strMessage = _("Are you having problems running MTA:SA?.\n\nDo you want to change the following setting?");
350+
strMessage += "\n" + _("Fullscreen mode:") + " -> " + _("Borderless window");
351+
int iResponse = MessageBoxUTF8 ( NULL, strMessage, "MTA: San Andreas", MB_YESNO | MB_ICONQUESTION | MB_TOPMOST );
352+
if ( iResponse == IDYES )
353+
{
354+
// Very hacky way of changing in-game settings
355+
strCoreConfig = strCoreConfig.Replace( "<display_fullscreen_style>0", "<display_fullscreen_style>1" );
356+
FileSave( strCoreConfigFilename, strCoreConfig );
357+
AddReportLog( 9311, "Loader - HandleNotUsedMainMenu - User change to Borderless window" );
358+
}
359+
}
360+
}
361+
else
362+
{
363+
// If no valid settings file yet, do the change without asking
364+
strCoreConfig = "<mainconfig><settings><display_fullscreen_style>1</display_fullscreen_style></settings></mainconfig>";
365+
FileSave( strCoreConfigFilename, strCoreConfig );
366+
AddReportLog( 9312, "Loader - HandleNotUsedMainMenu - Set Borderless window" );
367+
}
368+
}
369+
}
370+
371+
323372
//////////////////////////////////////////////////////////
324373
//
325374
// HandleCustomStartMessage
@@ -417,6 +466,13 @@ void PreLaunchWatchDogs ( void )
417466
HandleResetSettings ();
418467
}
419468

469+
// Check for possible fullscreen problems after install
470+
if ( WatchDogIsSectionOpen( WD_SECTION_NOT_USED_MAIN_MENU ) && WatchDogIsSectionOpen( WD_SECTION_POST_INSTALL ) )
471+
{
472+
WatchDogCompletedSection( WD_SECTION_NOT_USED_MAIN_MENU );
473+
HandleNotUsedMainMenu();
474+
}
475+
420476
// Clear down freeze on quit detection
421477
WatchDogCompletedSection( "Q0" );
422478

@@ -874,6 +930,7 @@ int LaunchGame ( SString strCmdLine )
874930

875931
WatchDogBeginSection ( "L2" ); // Gets closed when loading screen is shown
876932
WatchDogBeginSection ( "L3" ); // Gets closed when loading screen is shown, or a startup problem is handled elsewhere
933+
WatchDogBeginSection ( WD_SECTION_NOT_USED_MAIN_MENU ); // Gets closed when the main menu is used
877934

878935
// Extract 'done-admin' flag from command line
879936
bool bDoneAdmin = strCmdLine.Contains ( "/done-admin" );

Shared/sdk/SharedUtil.Game.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ namespace SharedUtil
110110

111111

112112
// Common strings for SetApplicationSetting
113-
#define WD_SECTION_PRELOAD_UPGRADES "preload-upgrades"
114113
#define DIAG_PRELOAD_UPGRADES_SLOW "diagnostics", "preloading-upgrades-slow"
115114
#define DIAG_PRELOAD_UPGRADE_ATTEMPT_ID "diagnostics", "preloading-upgrade-attempt-id"
116115
#define DIAG_PRELOAD_UPGRADES_LOWEST_UNSAFE "diagnostics", "preloading-upgrades-lowest-unsafe"
@@ -121,4 +120,15 @@ namespace SharedUtil
121120
#define DIAG_BSOD_DETECT_SKIP "diagnostics", "bsod-detect-skip"
122121
#define GENERAL_PROGRESS_ANIMATION_DISABLE "progress-animation-disable"
123122

123+
// Common strings for watchdog detections
124+
#define WD_SECTION_PRELOAD_UPGRADES "preload-upgrades"
125+
#define WD_SECTION_NOT_CLEAN_GTA_EXIT "L0" // Opened in loader, closed if GTA exits with no error
126+
#define WD_SECTION_NOT_STARTED_ONLINE_GAME "L1" // Opened in loader, closed when online game has started
127+
#define WD_SECTION_NOT_SHOWN_LOADING_SCREEN "L2" // Opened in loader, closed when loading screen is shown
128+
#define WD_SECTION_STARTUP_FREEZE "L3" // Opened in loader, closed when loading screen is shown, or a startup problem is handled elsewhere
129+
#define WD_SECTION_NOT_USED_MAIN_MENU "L4" // Opened in loader, closed when main menu is used
130+
#define WD_SECTION_POST_INSTALL "L5" // Opened in when installer runs, closed when main menu is used
131+
#define WD_SECTION_IS_QUITTING "Q0" // Open during quit
132+
#define WD_COUNTER_CRASH_CHAIN_BEFORE_ONLINE_GAME "CR1" // Counts consecutive crashes before the online game starts
133+
#define WD_COUNTER_CRASH_CHAIN_BEFORE_LOADING_SCREEN "CR2" // Counts consecutive crashes before the loading screen is shown
124134
}

Shared/sdk/SharedUtil.Misc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ namespace SharedUtil
121121
void WatchDogSetUncleanStop ( bool bOn );
122122
bool WatchDogWasLastRunCrash ( void );
123123
void WatchDogSetLastRunCrash ( bool bOn );
124+
void WatchDogUserDidInteractWithMenu ( void );
124125

125126
// BrowseToSolution flags
126127
enum

Shared/sdk/SharedUtil.Misc.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,14 @@ void SharedUtil::WatchDogSetLastRunCrash( bool bOn )
523523
bWatchDogWasLastRunCrashValue = bOn;
524524
}
525525

526+
//
527+
// Special things
528+
//
529+
void SharedUtil::WatchDogUserDidInteractWithMenu( void )
530+
{
531+
WatchDogCompletedSection( WD_SECTION_NOT_USED_MAIN_MENU );
532+
WatchDogCompletedSection( WD_SECTION_POST_INSTALL );
533+
}
526534

527535

528536
void SharedUtil::SetClipboardText ( const SString& strText )

0 commit comments

Comments
 (0)