From d932cb12057715b82cb0cd3e1907a5bd2a133228 Mon Sep 17 00:00:00 2001 From: ttimo Date: Sun, 20 Aug 2023 14:46:53 -0500 Subject: [PATCH] netrun mode was on all the time because of a buggy implementation --- radiant/preferences.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index f8575cfe..2c7e817f 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -1108,7 +1108,7 @@ void CGameDialog::UpdateData( bool retrieve ) { i++; } #ifdef _WIN32 - UpdateNetrun( false ); + UpdateNetrun( retrieve ); #endif } Dialog::UpdateData( retrieve ); @@ -1122,7 +1122,7 @@ void CGameDialog::UpdateData( bool retrieve ) { } m_sGameFile = ( *iGame )->mGameFile; #ifdef _WIN32 - UpdateNetrun( true ); + UpdateNetrun( retrieve ); #endif } } @@ -1391,7 +1391,8 @@ bool CGameDialog::m_bNetRun; void CGameDialog::UpdateNetrun( bool retrieve ){ FILE *f_netrun; CString strNetrun; - strNetrun = g_strAppPath; strNetrun += NETRUN_FILENAME; + strNetrun = g_strAppPath; + strNetrun += NETRUN_FILENAME; if ( !retrieve ) { // now check if we are running from a network installation // use a dummy file as the flag @@ -1420,16 +1421,14 @@ void CGameDialog::UpdateNetrun( bool retrieve ){ } else { - if ( remove( strNetrun.GetBuffer() ) == -1 ) { - if ( errno != ENOENT ) { - Sys_FPrintf( SYS_ERR, "Failed to remove netrun file '%s'\n", strNetrun.GetBuffer() ); - } - m_bNetRun = true; - } - else + if ( CheckFile( strNetrun.GetBuffer() ) == PATH_FAIL || remove( strNetrun.GetBuffer() ) == 0 ) { Sys_Printf( "Netrun mode is disabled\n" ); + return; } + // prefer keeping it on rather than going out of sync + Sys_FPrintf( SYS_ERR, "Problem deleting netrun file '%s', leaving netrun mode on\n", strNetrun.GetBuffer() ); + m_bNetRun = true; } } }