Skip to content

Commit 057392f

Browse files
committed
Added online help option if updater download fails.
Fixed FileLoad return value. Modified server announce error message.
1 parent 575602a commit 057392f

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

MTA10/core/CQuestionBox.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ void CQuestionBox::SetCallbackEdit ( pfnQuestionEditCallback callback, void* ptr
195195
}
196196

197197

198+
// Call after the main message has been set
199+
void CQuestionBox::SetOnLineHelpOption( const SString& strTroubleLink )
200+
{
201+
SString strMessage = "\n\n";
202+
strMessage += _("Do you want to see some on-line help about this problem ?");
203+
AppendMessage( strMessage );
204+
SetButton( 0, _("No") );
205+
SetButton( 1, _("Yes") );
206+
SetCallback( CCore::ErrorMessageBoxCallBack, new SString( strTroubleLink ) );
207+
}
208+
209+
198210
unsigned int CQuestionBox::PollButtons ( void )
199211
{
200212
if ( !m_pWindow->IsVisible () )

MTA10/core/CQuestionBox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CQuestionBox
3838
CGUIEdit* SetEditbox ( unsigned int uiEditbox, const SString& strText );
3939
void SetCallback ( pfnQuestionCallback callback, void* ptr = NULL );
4040
void SetCallbackEdit ( pfnQuestionEditCallback callback, void* ptr = NULL );
41+
void SetOnLineHelpOption ( const SString& strTroubleType );
4142
unsigned int PollButtons ( void );
4243
bool IsVisible ( void );
4344
void SetAutoCloseOnConnect ( bool bEnable );

MTA10/core/CVersionUpdater.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,13 @@ void CVersionUpdater::_PollAnyButton ( void )
17601760
while( true )
17611761
{
17621762
UpdaterYield();
1763+
1764+
// Abort if external force has closed the question box
1765+
if ( !GetQuestionBox ().IsVisible () )
1766+
_QuitCurrentProgram();
1767+
17631768
// Wait for button press before continuing
1764-
if ( GetQuestionBox ().PollButtons () != -1 )
1769+
if ( GetQuestionBox ().PollButtons () != BUTTON_NONE )
17651770
{
17661771
GetQuestionBox ().Reset ();
17671772
return;
@@ -1782,6 +1787,11 @@ void CVersionUpdater::_PollQuestionNoYes ( void )
17821787
while( true )
17831788
{
17841789
UpdaterYield();
1790+
1791+
// Abort if external force has closed the question box
1792+
if ( !GetQuestionBox ().IsVisible () )
1793+
_QuitCurrentProgram();
1794+
17851795
switch ( GetQuestionBox ().PollButtons () )
17861796
{
17871797
case BUTTON_NONE:
@@ -1982,7 +1992,7 @@ void CVersionUpdater::_DialogUpdateResult(void)
19821992
GetQuestionBox ().Reset ();
19831993
GetQuestionBox ().SetTitle ( _("ERROR DOWNLOADING") );
19841994
GetQuestionBox ().SetMessage ( _("The downloaded file appears to be incorrect.") );
1985-
GetQuestionBox ().SetButton ( 0, _("OK") );
1995+
GetQuestionBox ().SetOnLineHelpOption ( SString( "dl-incorrect&fname=%s", *m_JobInfo.strFilename ) );
19861996
GetQuestionBox ().Show ();
19871997
_PollAnyButton();
19881998
}
@@ -2591,7 +2601,7 @@ void CVersionUpdater::_ProcessPatchFileDownload ( void )
25912601
if ( m_JobInfo.serverList.size () )
25922602
ListRemoveIndex( m_JobInfo.serverList, m_JobInfo.iCurrent-- );
25932603
m_ConditionMap.SetCondition ( "Download", "Fail", "Checksum" );
2594-
AddReportLog ( 5003, SString ( "DoPollDownload: Checksum wrong for %s (%s %s)", m_JobInfo.strFilename.c_str(), m_JobInfo.strMD5.c_str(), szMD5 ) );
2604+
AddReportLog ( 5003, SString ( "DoPollDownload: Checksum wrong for %s (Want:%d-%s Got:%d-%s)", m_JobInfo.strFilename.c_str(), (int)m_JobInfo.iFilesize, m_JobInfo.strMD5.c_str(), uiSize, szMD5 ) );
25952605
return;
25962606
}
25972607
}
@@ -2771,7 +2781,7 @@ int CVersionUpdater::_PollDownload ( void )
27712781
if ( GetQuestionBox ().IsVisible () )
27722782
{
27732783
// Handle progress/cancel if visible
2774-
if ( GetQuestionBox ().PollButtons () == 0 )
2784+
if ( GetQuestionBox ().PollButtons () == BUTTON_0 )
27752785
{
27762786
GetHTTP()->Reset();
27772787
GetQuestionBox ().Reset ();

MTA10_Server/mods/deathmatch/utils/CMasterServerAnnouncer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CMasterServer : public CRefCountable
7878
// Send request
7979
this->AddRef(); // Keep object alive
8080
m_bStatusBusy = true;
81-
GetDownloadManager()->QueueFile( m_Definition.strURL, NULL, 0, "", 0, false, this, StaticProgressCallback, false, 1 );
81+
GetDownloadManager()->QueueFile( m_Definition.strURL, NULL, 0, "", 0, false, this, StaticProgressCallback, false, 2 );
8282
}
8383
}
8484
else
@@ -153,7 +153,7 @@ class CMasterServer : public CRefCountable
153153
if ( !m_Definition.bHideProblems )
154154
{
155155
// Log initial failure
156-
CLogger::LogPrintf( "%s problem (%u). Retrying...\n", *m_Definition.strDesc, iError );
156+
CLogger::LogPrintf( "%s no response. Retrying...\n", *m_Definition.strDesc );
157157
}
158158
}
159159
}

Shared/sdk/SharedUtil.File.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ bool SharedUtil::FileLoad ( const SString& strFilename, std::vector < char >& bu
111111
// Get size
112112
fseek ( fh, 0, SEEK_END );
113113
int size = ftell ( fh );
114-
rewind ( fh );
115114

116115
// Set offset
116+
iOffset = Min ( iOffset, size );
117117
fseek ( fh, iOffset, SEEK_SET );
118+
size -= iOffset;
118119

119120
int bytesRead = 0;
120121
if ( size > 0 && size < 1e9 ) // 1GB limit
@@ -448,8 +449,8 @@ uint SharedUtil::GetPathFreeSpaceMB( const SString& strPath )
448449

449450
SString SharedUtil::GetDriveNameWithNotEnoughSpace( uint uiResourcesPathMinMB, uint uiDataPathMinMB )
450451
{
451-
SString strFileCachePath = GetCommonRegistryValue( "", "File Cache Path" );
452-
if ( !strFileCachePath.empty() && DirectoryExists( PathJoin( strFileCachePath, "resources" ) ) )
452+
SString strFileCachePath = GetCommonRegistryValue( "", "File Cache Path" );
453+
if ( !strFileCachePath.empty() && DirectoryExists( PathJoin( strFileCachePath, "resources" ) ) )
453454
if ( GetPathFreeSpaceMB( strFileCachePath ) < uiResourcesPathMinMB )
454455
return GetPathDriveName( strFileCachePath );
455456

0 commit comments

Comments
 (0)