Skip to content

Commit 1770d87

Browse files
committed
Refactored/renamed download callback.
Removed some unused code.
1 parent 24179f7 commit 1770d87

22 files changed

+98
-162
lines changed

MTA10/core/CCommunity.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,12 @@ CNetHTTPDownloadManagerInterface* CCommunity::GetHTTP( void )
115115

116116

117117
// Handle server response
118-
bool CCommunity::StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
118+
void CCommunity::StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
119119
{
120120
if ( bSuccess )
121121
((CCommunity*)pObj)->DownloadSuccess( pCompletedData, completedLength );
122122
else
123123
((CCommunity*)pObj)->DownloadFailed( iErrorCode );
124-
return true;
125124
}
126125

127126
void CCommunity::DownloadSuccess( char* pCompletedData, size_t completedLength )

MTA10/core/CCommunity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CCommunity : public CCommunityInterface, public CSingleton < CCommunity >
6161
void Logout ( void );
6262

6363
CNetHTTPDownloadManagerInterface* GetHTTP ( void );
64-
static bool StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
64+
static void StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
6565
void DownloadFailed ( int iErrorCode );
6666
void DownloadSuccess ( char* pCompletedData, size_t completedLength );
6767

MTA10/core/CCommunityRegistration.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,12 @@ CNetHTTPDownloadManagerInterface* CCommunityRegistration::GetHTTP( void )
168168

169169

170170
// Handle server response
171-
bool CCommunityRegistration::StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
171+
void CCommunityRegistration::StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
172172
{
173173
if ( bSuccess )
174174
((CCommunityRegistration*)pObj)->DownloadSuccess( pCompletedData, completedLength );
175175
else
176176
((CCommunityRegistration*)pObj)->DownloadFailed( iErrorCode );
177-
return true;
178177
}
179178

180179
void CCommunityRegistration::DownloadSuccess( char* szBuffer, size_t uiBufferLength )

MTA10/core/CCommunityRegistration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CCommunityRegistration
4949

5050
protected:
5151
void CreateWindows ( void );
52-
static bool StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
52+
static void StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
5353
void DownloadSuccess ( char* pCompletedData, size_t completedLength );
5454
void DownloadFailed ( int iErrorCode );
5555
CNetHTTPDownloadManagerInterface* GetHTTP ( void );

MTA10/core/CServerBrowser.RemoteMasterServer.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class CRemoteMasterServer : public CRemoteMasterServerInterface
3535
bool ParseListVer2 ( CServerListItemList& itemList );
3636
CServerListItem* GetServerListItem ( CServerListItemList& itemList, in_addr Address, ushort usGamePort );
3737
CNetHTTPDownloadManagerInterface* GetHTTP ( void );
38-
static bool StaticDownloadProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError );
39-
void DownloadProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, bool bComplete, int iError );
38+
static void StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
39+
void DownloadFinished ( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode );
4040

4141
long long m_llLastRefreshTime;
4242
SString m_strStage;
@@ -107,7 +107,7 @@ void CRemoteMasterServer::Init ( const SString& strURL )
107107
///////////////////////////////////////////////////////////////
108108
CNetHTTPDownloadManagerInterface* CRemoteMasterServer::GetHTTP( void )
109109
{
110-
return g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadMode::CORE_ASE_LIST );
110+
return g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadMode::CORE_ASE_LIST );
111111
}
112112

113113

@@ -128,37 +128,35 @@ void CRemoteMasterServer::Refresh ( void )
128128
m_strStage = "waitingreply";
129129
m_llLastRefreshTime = GetTickCount64_ ();
130130
AddRef(); // Keep alive
131-
GetHTTP()->QueueFile( m_strURL, NULL, 0, NULL, 0, false, this, &CRemoteMasterServer::StaticDownloadProgress, false, 1 );
131+
GetHTTP()->QueueFile( m_strURL, NULL, 0, NULL, 0, false, this, &CRemoteMasterServer::StaticDownloadFinished, false, 1 );
132132
}
133133

134134

135135
///////////////////////////////////////////////////////////////
136136
//
137-
// CRemoteMasterServer::StaticDownloadProgress
137+
// CRemoteMasterServer::StaticDownloadFinished
138138
//
139139
// Callback during ProcessQueuedFiles
140140
//
141141
///////////////////////////////////////////////////////////////
142-
bool CRemoteMasterServer::StaticDownloadProgress( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError )
142+
void CRemoteMasterServer::StaticDownloadFinished( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
143143
{
144144
CRemoteMasterServer* pRemoteMasterServer = (CRemoteMasterServer*)pObj;
145-
pRemoteMasterServer->DownloadProgress( dDownloadNow, dDownloadTotal, pCompletedData, completedLength, bComplete, iError );
146-
if ( bComplete || iError )
147-
pRemoteMasterServer->Release(); // Unkeep alive
148-
return true;
145+
pRemoteMasterServer->DownloadFinished( pCompletedData, completedLength, bSuccess, iErrorCode );
146+
pRemoteMasterServer->Release(); // Unkeep alive
149147
}
150148

151149

152150
///////////////////////////////////////////////////////////////
153151
//
154-
// CRemoteMasterServer::DownloadProgress
152+
// CRemoteMasterServer::DownloadFinished
155153
//
156154
// Callback during ProcessQueuedFiles
157155
//
158156
///////////////////////////////////////////////////////////////
159-
void CRemoteMasterServer::DownloadProgress( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, bool bComplete, int iError )
157+
void CRemoteMasterServer::DownloadFinished( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode )
160158
{
161-
if ( bComplete )
159+
if ( bSuccess )
162160
{
163161
if ( m_strStage == "waitingreply" )
164162
{

MTA10/core/CServerCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace
4545
SString strVersion; // Version
4646
};
4747

48-
// Variables used for saving the screen shot file on a separate thread
48+
// Variables used for saving the server cache file on a separate thread
4949
static bool ms_bIsSaving = false;
5050
static std::map < CCachedKey, CCachedInfo > ms_ServerCachedMap;
5151
}

MTA10/core/CVersionUpdater.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class CVersionUpdater : public CVersionUpdaterInterface
7474
CNetHTTPDownloadManagerInterface* GetHTTP ( void );
7575
void GetSaveLocationList ( std::list < SString >& outSaveLocationList, const SString& strFilename );
7676
SString GetResumableSaveLocation ( const SString& strFilename, const SString& strMD5, uint iFilesize );
77-
static bool StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
78-
bool DownloadFinished ( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode );
77+
static void StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
78+
void DownloadFinished ( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode );
7979

8080
// Commands
8181
void _UseMasterFetchURLs ( void );
@@ -3287,12 +3287,12 @@ int CVersionUpdater::DoSendDownloadRequestToNextServer ( void )
32873287
// Handle when download finishes
32883288
//
32893289
///////////////////////////////////////////////////////////////
3290-
bool CVersionUpdater::StaticDownloadFinished ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
3290+
void CVersionUpdater::StaticDownloadFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
32913291
{
3292-
return ((CVersionUpdater*)pObj)->DownloadFinished( pCompletedData, completedLength, bSuccess, iErrorCode );
3292+
((CVersionUpdater*)pObj)->DownloadFinished( pCompletedData, completedLength, bSuccess, iErrorCode );
32933293
}
32943294

3295-
bool CVersionUpdater::DownloadFinished( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode )
3295+
void CVersionUpdater::DownloadFinished( char* pCompletedData, size_t completedLength, bool bSuccess, int iErrorCode )
32963296
{
32973297
if ( bSuccess )
32983298
{
@@ -3308,7 +3308,6 @@ bool CVersionUpdater::DownloadFinished( char* pCompletedData, size_t completedLe
33083308
m_JobInfo.downloadStatus = EDownloadStatus::Failure;
33093309
m_JobInfo.iDownloadResultCode = iErrorCode;
33103310
}
3311-
return true;
33123311
}
33133312

33143313

MTA10/core/CWebCore.cpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ bool CWebCore::UpdateListsFromMaster ()
492492
OutputDebugLine ( "Updating white- and blacklist..." );
493493
#endif
494494
g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadModeType::WEBBROWSER_LISTS )->QueueFile ( SString("%s?type=getrev", BROWSER_UPDATE_URL),
495-
NULL, 0, NULL, 0, false, this, &CWebCore::StaticFetchRevisionProgress, false, 3 );
495+
NULL, 0, NULL, 0, false, this, &CWebCore::StaticFetchRevisionFinished, false, 3 );
496496

497497
pLastUpdateNode->SetTagContent ( SString ( "%d", (long long)currentTime ) );
498498
m_pXmlConfig->Write ();
@@ -672,10 +672,10 @@ void CWebCore::GetFilterEntriesByType ( std::vector<std::pair<SString, bool>>& o
672672
}
673673
}
674674

675-
bool CWebCore::StaticFetchRevisionProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError )
675+
void CWebCore::StaticFetchRevisionFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
676676
{
677677
CWebCore* pWebCore = static_cast < CWebCore* > ( pObj );
678-
if ( bComplete )
678+
if ( bSuccess )
679679
{
680680
SString strData = pCompletedData;
681681
SString strWhiteRevision, strBlackRevision;
@@ -687,43 +687,41 @@ bool CWebCore::StaticFetchRevisionProgress ( double dDownloadNow, double dDownlo
687687
if ( iWhiteListRevision > pWebCore->m_iWhitelistRevision )
688688
{
689689
g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadModeType::WEBBROWSER_LISTS )->QueueFile ( SString("%s?type=fetchwhite", BROWSER_UPDATE_URL ),
690-
NULL, 0, NULL, 0, false, pWebCore, &CWebCore::StaticFetchWhitelistProgress, false, 3 );
690+
NULL, 0, NULL, 0, false, pWebCore, &CWebCore::StaticFetchWhitelistFinished, false, 3 );
691691

692692
pWebCore->m_iWhitelistRevision = iWhiteListRevision;
693693
}
694694
int iBlackListRevision = atoi ( strBlackRevision );
695695
if ( iBlackListRevision > pWebCore->m_iBlacklistRevision )
696696
{
697697
g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadModeType::WEBBROWSER_LISTS )->QueueFile ( SString("%s?type=fetchblack", BROWSER_UPDATE_URL),
698-
NULL, 0, NULL, 0, false, pWebCore, &CWebCore::StaticFetchBlacklistProgress, false, 3 );
698+
NULL, 0, NULL, 0, false, pWebCore, &CWebCore::StaticFetchBlacklistFinished, false, 3 );
699699

700700
pWebCore->m_iBlacklistRevision = iBlackListRevision;
701701
}
702702
}
703703
}
704-
705-
return true;
706704
}
707705

708-
bool CWebCore::StaticFetchWhitelistProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError )
706+
void CWebCore::StaticFetchWhitelistFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
709707
{
710-
if ( !bComplete )
711-
return false;
708+
if ( !bSuccess )
709+
return;
712710

713711
CWebCore* pWebCore = static_cast < CWebCore* > ( pObj );
714712
if ( !pWebCore->m_pXmlConfig )
715-
return false;
713+
return;
716714

717715
if ( !pWebCore->MakeSureXMLNodesExist () )
718-
return false;
716+
return;
719717

720718
CXMLNode* pRootNode = pWebCore->m_pXmlConfig->GetRootNode ();
721719
std::vector<SString> whitelist;
722720
SString strData = pCompletedData;
723721
strData.Split ( ";", whitelist );
724722
CXMLNode* pListNode = pRootNode->FindSubNode ( "globalwhitelist" );
725723
if ( !pListNode )
726-
return false;
724+
return;
727725
pListNode->DeleteAllSubNodes ();
728726

729727
for ( std::vector<SString>::const_iterator iter = whitelist.begin (); iter != whitelist.end (); ++iter )
@@ -735,7 +733,7 @@ bool CWebCore::StaticFetchWhitelistProgress ( double dDownloadNow, double dDownl
735733
// Set whitelist revision
736734
CXMLNode* pNode = pRootNode->FindSubNode ( "whitelistrev" );
737735
if ( !pNode )
738-
return false;
736+
return;
739737
pNode->SetTagContent ( pWebCore->m_iWhitelistRevision );
740738

741739
// Write changes to the XML file
@@ -746,28 +744,27 @@ bool CWebCore::StaticFetchWhitelistProgress ( double dDownloadNow, double dDownl
746744
#ifdef MTA_DEBUG
747745
OutputDebugLine ( "Updated whitelist!" );
748746
#endif
749-
return true;
750747
}
751748

752-
bool CWebCore::StaticFetchBlacklistProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError )
749+
void CWebCore::StaticFetchBlacklistFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
753750
{
754-
if ( !bComplete )
755-
return false;
751+
if ( !bSuccess )
752+
return;
756753

757754
CWebCore* pWebCore = static_cast < CWebCore* > ( pObj );
758755
if ( !pWebCore->m_pXmlConfig )
759-
return false;
756+
return;
760757

761758
if ( !pWebCore->MakeSureXMLNodesExist () )
762-
return false;
759+
return;
763760

764761
CXMLNode* pRootNode = pWebCore->m_pXmlConfig->GetRootNode ();
765762
std::vector<SString> blacklist;
766763
SString strData = pCompletedData;
767764
strData.Split ( ";", blacklist );
768765
CXMLNode* pListNode = pRootNode->FindSubNode ( "globalblacklist" );
769766
if ( !pListNode )
770-
return false;
767+
return;
771768
pListNode->DeleteAllSubNodes ();
772769

773770
for ( std::vector<SString>::const_iterator iter = blacklist.begin (); iter != blacklist.end (); ++iter )
@@ -779,7 +776,7 @@ bool CWebCore::StaticFetchBlacklistProgress ( double dDownloadNow, double dDownl
779776
// Set blacklist revision
780777
CXMLNode* pNode = pRootNode->FindSubNode ( "blacklistrev" );
781778
if ( !pNode )
782-
return false;
779+
return;
783780
pNode->SetTagContent ( pWebCore->m_iBlacklistRevision );
784781

785782
// Write changes to the XML file
@@ -790,7 +787,6 @@ bool CWebCore::StaticFetchBlacklistProgress ( double dDownloadNow, double dDownl
790787
#ifdef MTA_DEBUG
791788
OutputDebugLine ( "Updated browser blacklist!" );
792789
#endif
793-
return true;
794790
}
795791

796792
//////////////////////////////////////////////////////////////

MTA10/core/CWebCore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class CWebCore : public CWebCoreInterface
9393
void LoadListsFromXML ( bool bWhitelist, bool bBlacklist, bool bCustomLists );
9494
void WriteCustomList ( const SString& strListName, const std::vector<SString>& customList, bool bReset = true );
9595
void GetFilterEntriesByType( std::vector<std::pair<SString, bool>>& outEntries, eWebFilterType filterType, eWebFilterState state = eWebFilterState::WEBFILTER_ALL );
96-
static bool StaticFetchRevisionProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError );
97-
static bool StaticFetchWhitelistProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError );
98-
static bool StaticFetchBlacklistProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError );
96+
static void StaticFetchRevisionFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
97+
static void StaticFetchWhitelistFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
98+
static void StaticFetchBlacklistFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode );
9999

100100
private:
101101
typedef std::pair<bool, eWebFilterType> WebFilterPair;

MTA10/mods/deathmatch/logic/CDownloadableResource.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,7 @@ CChecksum CDownloadableResource::GenerateClientChecksum ( void )
5959
return m_LastClientChecksum;
6060
}
6161

62-
CChecksum CDownloadableResource::GetLastClientChecksum ( void )
63-
{
64-
return m_LastClientChecksum;
65-
}
66-
6762
CChecksum CDownloadableResource::GetServerChecksum ( void )
6863
{
6964
return m_ServerChecksum;
7065
}
71-
72-
void CDownloadableResource::SetServerChecksum ( CChecksum serverChecksum )
73-
{
74-
m_ServerChecksum = serverChecksum;
75-
}

0 commit comments

Comments
 (0)